fix
This commit is contained in:
+147
-147
@@ -1,42 +1,44 @@
|
|||||||
<?
|
<?
|
||||||
|
|
||||||
/*
|
/*
|
||||||
THIS IS THE USER ENTRY POINT API
|
THIS IS THE USER ENTRY POINT API
|
||||||
*/
|
*/
|
||||||
require '../../backend.php';
|
require '../../backend.php';
|
||||||
require '../backend_defines.php';
|
require '../backend_defines.php';
|
||||||
//var_dump($mermsemr->cfgReadChar("database.host"));
|
//var_dump($mermsemr->cfgReadChar("database.host"));
|
||||||
if ($_SERVER['REQUEST_METHOD']=='OPTIONS') {
|
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
|
||||||
$headers = getallheaders();
|
$headers = getallheaders();
|
||||||
header('Access-Control-Allow-Origin: '.(isset($headers["Origin"])?$headers["Origin"]:'*'));
|
header('Access-Control-Allow-Origin: ' . (isset($headers["Origin"]) ? $headers["Origin"] : '*'));
|
||||||
header('Access-Control-Allow-Methods: POST, GET, DELETE, PUT, PATCH, OPTIONS');
|
header('Access-Control-Allow-Methods: POST, GET, DELETE, PUT, PATCH, OPTIONS');
|
||||||
header('Access-Control-Allow-Headers: access-control-allow-methods,access-control-allow-origin,content-type');
|
header('Access-Control-Allow-Headers: access-control-allow-methods,access-control-allow-origin,content-type');
|
||||||
//header('Access-Control-Max-Age: 1728000');
|
//header('Access-Control-Max-Age: 1728000');
|
||||||
header('Content-Length: 0');
|
header('Content-Length: 0');
|
||||||
header('Content-Type: text/plain');
|
header('Content-Type: text/plain');
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
header('Access-Control-Allow-Headers: access-control-allow-methods,access-control-allow-origin,content-type');
|
header('Access-Control-Allow-Headers: access-control-allow-methods,access-control-allow-origin,content-type');
|
||||||
header('Access-Control-Allow-Origin: *');
|
header('Access-Control-Allow-Origin: *');
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
$endpoints = array(
|
$endpoints = array(
|
||||||
'createuser' => array('POST'),
|
'createuser' => array('POST'),
|
||||||
'login' => array('POST'),
|
'login' => array('POST'),
|
||||||
'userlogin' => array('POST'),
|
'userlogin' => array('POST'),
|
||||||
'getprofile' => array('POST'),
|
'getprofile' => array('POST'),
|
||||||
'setprofile' => array('POST'),
|
'setprofile' => array('POST'),
|
||||||
'userstask' => array('POST'),
|
'userstask' => array('POST'),
|
||||||
'createtask' => array('POST'),
|
'createtask' => array('POST'),
|
||||||
'deletetask' => array('POST'),
|
'deletetask' => array('POST'),
|
||||||
'getpractice' => array('POST')
|
'getpractice' => array('POST'),
|
||||||
|
'userencounter' => array('POST')
|
||||||
);
|
);
|
||||||
/*
|
/*
|
||||||
header("Access-Control-Allow-Origin: *");
|
header("Access-Control-Allow-Origin: *");
|
||||||
header("Access-Control-Expose-Headers: Access-Control-Allow-Origin");
|
header("Access-Control-Expose-Headers: Access-Control-Allow-Origin");
|
||||||
header("Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With");
|
header("Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With");
|
||||||
header("Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS");
|
header("Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS");
|
||||||
header('Content-type: application/json');
|
header('Content-type: application/json');
|
||||||
*/
|
*/
|
||||||
$endpoint = strtolower(str_replace('/api/users/', '', strtok($_SERVER['REQUEST_URI'], '?')));
|
$endpoint = strtolower(str_replace('/api/users/', '', strtok($_SERVER['REQUEST_URI'], '?')));
|
||||||
|
|
||||||
if (!isset($endpoints[$endpoint])) {
|
if (!isset($endpoints[$endpoint])) {
|
||||||
@@ -72,94 +74,95 @@ $in["loc"] = $_SERVER["REMOTE_ADDR"];
|
|||||||
|
|
||||||
switch ($endpoint) {
|
switch ($endpoint) {
|
||||||
case 'userlogin':
|
case 'userlogin':
|
||||||
case 'login':
|
case 'login':
|
||||||
$in["action"] = MERMS_USER_LOGIN;
|
$in["action"] = MERMS_USER_LOGIN;
|
||||||
//$in["account_no"] = "7702222222";
|
//$in["account_no"] = "7702222222";
|
||||||
//$in["password"] = "1234";
|
//$in["password"] = "1234";
|
||||||
break;
|
break;
|
||||||
case 'createuser':
|
case 'createuser':
|
||||||
$in["action"] = MERMS_USER_CREATEACCOUNT;
|
$in["action"] = MERMS_USER_CREATEACCOUNT;
|
||||||
//$in["action_recieved"] = MERMS_USER_CREATEACCOUNT;
|
//$in["action_recieved"] = MERMS_USER_CREATEACCOUNT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'userstask':
|
|
||||||
$in["action"] = MERMS_USER_REMINDERS;
|
|
||||||
$in["task_mode"] = USER_LOADTASK;
|
|
||||||
break;
|
|
||||||
case 'createtask':
|
|
||||||
$in["action"] = MERMS_USER_REMINDERS;
|
|
||||||
$in["task_mode"] = USER_CREATETASK;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'getprofile':
|
case 'userstask':
|
||||||
$in["action"] = MERMS_USER_LOADPROFILE;
|
$in["action"] = MERMS_USER_REMINDERS;
|
||||||
$in["task_mode"] = MODE_GETVALUE;
|
$in["task_mode"] = USER_LOADTASK;
|
||||||
break;
|
break;
|
||||||
case 'setprofile':
|
case 'createtask':
|
||||||
$in["action"] = MERMS_USER_UPDATEPROFILE;
|
$in["action"] = MERMS_USER_REMINDERS;
|
||||||
$in["task_mode"] = MODE_SETVALUE;
|
$in["task_mode"] = USER_CREATETASK;
|
||||||
break;
|
break;
|
||||||
case 'deletetask':
|
|
||||||
$in["action"] = MERMS_USER_REMINDERS;
|
case 'getprofile':
|
||||||
$in["task_mode"] = USER_DELETETASK;
|
$in["action"] = MERMS_USER_LOADPROFILE;
|
||||||
break;
|
$in["task_mode"] = MODE_GETVALUE;
|
||||||
case 'getpractice':
|
break;
|
||||||
$in["action"] = MERMS_USER_PRACTICES;
|
case 'setprofile':
|
||||||
$in["task_mode"] = MODE_GETVALUE;
|
$in["action"] = MERMS_USER_UPDATEPROFILE;
|
||||||
break;
|
$in["task_mode"] = MODE_SETVALUE;
|
||||||
|
break;
|
||||||
|
case 'deletetask':
|
||||||
|
$in["action"] = MERMS_USER_REMINDERS;
|
||||||
|
$in["task_mode"] = USER_DELETETASK;
|
||||||
|
break;
|
||||||
|
case 'getpractice':
|
||||||
|
$in["action"] = MERMS_USER_PRACTICES;
|
||||||
|
$in["task_mode"] = MODE_GETVALUE;
|
||||||
|
break;
|
||||||
|
case 'userencounter':
|
||||||
|
$in["action"] = MERMS_USER_REMINDERS;
|
||||||
|
$in["task_mode"] = USER_LOADTASK;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$out = $in;
|
$out = $in;
|
||||||
|
|
||||||
switch ( $in["action"] ) {
|
switch ($in["action"]) {
|
||||||
case 100:
|
case 100:
|
||||||
$out["return"] = "REACH AND BACK";
|
$out["return"] = "REACH AND BACK";
|
||||||
$out["retrun_number"] = rand(1000,9999);
|
$out["retrun_number"] = rand(1000, 9999);
|
||||||
$out["endpoint"] = $endpoint;
|
$out["endpoint"] = $endpoint;
|
||||||
break;
|
break;
|
||||||
case MERMS_USER_BEFORESESSION:
|
case MERMS_USER_BEFORESESSION:
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MERMS_USER_CREATEACCOUNT:
|
case MERMS_USER_CREATEACCOUNT:
|
||||||
// start account
|
// start account
|
||||||
// complete account
|
// complete account
|
||||||
|
|
||||||
$out["return"] = "REACH AND BACK CREATE ACCOUNT";
|
$out["return"] = "REACH AND BACK CREATE ACCOUNT";
|
||||||
$out["retrun_number"] = rand(1000,9999);
|
$out["retrun_number"] = rand(1000, 9999);
|
||||||
$out["endpoint"] = $endpoint;
|
$out["endpoint"] = $endpoint;
|
||||||
|
|
||||||
break;
|
|
||||||
case MERMS_USER_RESETPASSWORD:
|
|
||||||
// start reset
|
|
||||||
// complete reset
|
|
||||||
// resend reset
|
|
||||||
|
|
||||||
break;
|
|
||||||
case MERMS_USER_LOGIN:
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MERMS_USER_DASHLOAD:
|
case MERMS_USER_RESETPASSWORD:
|
||||||
|
// start reset
|
||||||
|
// complete reset
|
||||||
|
// resend reset
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MERMS_USER_LOADPROFILE:
|
case MERMS_USER_LOGIN:
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MERMS_USER_UPDATEPROFILE:
|
case MERMS_USER_DASHLOAD:
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MERMS_USER_REMINDERS:
|
case MERMS_USER_LOADPROFILE:
|
||||||
// configure
|
|
||||||
// update
|
break;
|
||||||
// delete/stop
|
case MERMS_USER_UPDATEPROFILE:
|
||||||
break;
|
|
||||||
|
break;
|
||||||
|
case MERMS_USER_REMINDERS:
|
||||||
|
// configure
|
||||||
|
// update
|
||||||
|
// delete/stop
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// calling the backend
|
// calling the backend
|
||||||
$out["internal_return"]= $mermsemr->mermsemr_api($in,$out);
|
$out["internal_return"] = $mermsemr->mermsemr_api($in, $out);
|
||||||
|
|
||||||
header("HTTP/1.1 200 OK");
|
header("HTTP/1.1 200 OK");
|
||||||
header("Status: 200 OK");
|
header("Status: 200 OK");
|
||||||
@@ -179,67 +182,64 @@ function flatten($data, $parentkey = "") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function processOutJson($in, &$out) {
|
function processOutJson($in, &$out) {
|
||||||
|
|
||||||
switch ($in["action"]) {
|
switch ($in["action"]) {
|
||||||
case MERMS_USER_PRACTICES:
|
case MERMS_USER_PRACTICES:
|
||||||
if ( $in["task_mode"] == MODE_GETVALUE )
|
if ($in["task_mode"] == MODE_GETVALUE) {
|
||||||
{
|
$total = $out["total_record"];
|
||||||
$total = $out["total_record"];
|
$res = array(
|
||||||
$res = array(
|
"status" => $out["status"],
|
||||||
"status" => $out["status"],
|
"total_record" => ($total),
|
||||||
"total_record" => ($total),
|
"internal_return" => $out["internal_return"],
|
||||||
"internal_return" => $out["internal_return"],
|
"result_list" => array(),
|
||||||
"result_list" => array(),
|
);
|
||||||
);
|
for ($i = 0; $i < $total; $i++) {
|
||||||
for ($i = 0; $i < $total; $i++) {
|
$key = sprintf("%05d", $i);
|
||||||
$key = sprintf("%05d", $i);
|
$res["result_list"][] = array(
|
||||||
$res["result_list"][] = array(
|
"id" => $out["id_${key}"],
|
||||||
"id" => $out["id_${key}"],
|
"patient_id" => $out["patient_id_${key}"],
|
||||||
"patient_id" => $out["patient_id_${key}"],
|
"name" => $out["name_${key}"],
|
||||||
"name" => $out["name_${key}"],
|
"long_id" => $out["long_id_${key}"],
|
||||||
"long_id" => $out["long_id_${key}"],
|
"patient_added" => $out["patient_added_${key}"],
|
||||||
"patient_added" => $out["patient_added_${key}"],
|
"added_by" => $out["added_by_${key}"],
|
||||||
"added_by"=> $out["added_by_${key}"],
|
"patient_status" => $out["patient_status_${key}"]
|
||||||
"patient_status" => $out["patient_status_${key}"]
|
);
|
||||||
);
|
} // "request_id"
|
||||||
} // "request_id"
|
}
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MERMS_USER_REMINDERS:
|
case MERMS_USER_REMINDERS:
|
||||||
if ( $in["task_mode"] == USER_LOADTASK )
|
if ($in["task_mode"] == USER_LOADTASK) {
|
||||||
{
|
$total = $out["total_record"];
|
||||||
$total = $out["total_record"];
|
$res = array(
|
||||||
$res = array(
|
"status" => $out["status"],
|
||||||
"status" => $out["status"],
|
"total_record" => ($total),
|
||||||
"total_record" => ($total),
|
"internal_return" => $out["internal_return"],
|
||||||
"internal_return" => $out["internal_return"],
|
"result_list" => array(),
|
||||||
"result_list" => array(),
|
);
|
||||||
);
|
for ($i = 0; $i < $total; $i++) {
|
||||||
for ($i = 0; $i < $total; $i++) {
|
$key = sprintf("%05d", $i);
|
||||||
$key = sprintf("%05d", $i);
|
$res["result_list"][] = array(
|
||||||
$res["result_list"][] = array(
|
"id" => $out["id_${key}"],
|
||||||
"id" => $out["id_${key}"],
|
"description" => $out["description_${key}"],
|
||||||
"description" => $out["description_${key}"],
|
"reminder" => $out["reminder_${key}"],
|
||||||
"reminder" => $out["reminder_${key}"],
|
"start_date" => $out["start_date_${key}"],
|
||||||
"start_date" => $out["start_date_${key}"],
|
"end_date" => $out["end_date_${key}"],
|
||||||
"end_date" => $out["end_date_${key}"],
|
"reminder_text" => $out["reminder_text_${key}"]
|
||||||
"reminder_text" => $out["reminder_text_${key}"]
|
);
|
||||||
);
|
} // "request_id"
|
||||||
} // "request_id"
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user