Skip to content

Commit

Permalink
sigh
Browse files Browse the repository at this point in the history
  • Loading branch information
joelsalisbury committed Dec 7, 2016
1 parent c190048 commit 8a317b4
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions api/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php
header( "Access-Control-Allow-Origin: *");
//header('Content-Type: application/json');
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");

require_once 'database.php';
require_once 'diagnosis.php';
require_once 'antibiotic.php';


if( isset( $_REQUEST['do'] ) ){
switch($_REQUEST['do']) {
case "getDiagnosis":

$did = $_GET['id'];
$diag = new Diagnosis($did);

prepareResponse($diag->get());


break;


case 'getAllDiagnoses':

$db = getDatabase();

$query = $db->prepare( "SELECT id, name from diagnosis" );
$query->execute();
$query->setFetchMode( PDO::FETCH_OBJ );
$data = $query->fetchAll();

prepareResponse($data);


break;

}
} else {
die("You need to specify an operation.");
}




function prepareResponse( $arr ) {
echo json_encode( $arr );
}

0 comments on commit 8a317b4

Please sign in to comment.