This commit is contained in:
Olusesan Ameye
2021-01-30 19:40:25 -05:00
parent 53898af1d8
commit c6e0317813
+25 -25
View File
@@ -1,13 +1,14 @@
<? <?
/* /*
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');
@@ -28,15 +29,16 @@ $endpoints = array(
'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])) {
@@ -107,18 +109,19 @@ switch ($endpoint) {
$in["action"] = MERMS_USER_PRACTICES; $in["action"] = MERMS_USER_PRACTICES;
$in["task_mode"] = MODE_GETVALUE; $in["task_mode"] = MODE_GETVALUE;
break; 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:
@@ -129,7 +132,7 @@ switch ( $in["action"] ) {
// 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; break;
@@ -159,7 +162,7 @@ switch ( $in["action"] ) {
} }
// 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");
@@ -182,8 +185,7 @@ 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"],
@@ -199,17 +201,15 @@ function processOutJson($in, &$out) {
"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"],
@@ -228,7 +228,6 @@ function processOutJson($in, &$out) {
"reminder_text" => $out["reminder_text_${key}"] "reminder_text" => $out["reminder_text_${key}"]
); );
} // "request_id" } // "request_id"
} }
break; break;
@@ -242,4 +241,5 @@ function processOutJson($in, &$out) {
return $res; return $res;
} }
?> ?>