update tm url, result username
This commit is contained in:
parent
0073762894
commit
aec00c113f
@ -6,6 +6,13 @@ use CodeIgniter\I18n\Time;
|
|||||||
|
|
||||||
class API_TM extends ResourceController {
|
class API_TM extends ResourceController {
|
||||||
|
|
||||||
|
public function __construct() {
|
||||||
|
$this->url_resultSBY = 'http://10.10.4.123:8001/api/webhook/lis?tenant=PadmaSurabaya';
|
||||||
|
$this->url_resultDPS = 'http://10.10.4.123:8001/api/webhook/lis?tenant=PadmaBali';
|
||||||
|
$this->url_masterSBY = "http://10.10.4.123:8001/api/webhook/lis-new-master?tenant=PadmaSurabaya";
|
||||||
|
$this->url_masterDPS = "http://10.10.4.123:8001/api/webhook/lis-new-master?tenant=PadmaBali";
|
||||||
|
}
|
||||||
|
|
||||||
public function sendHL7Message($host, $port, $message, $timeout = 5) {
|
public function sendHL7Message($host, $port, $message, $timeout = 5) {
|
||||||
try {
|
try {
|
||||||
// Create a TCP/IP socket
|
// Create a TCP/IP socket
|
||||||
@ -102,6 +109,7 @@ class API_TM extends ResourceController {
|
|||||||
$reffid = $qdata['reference_id'];
|
$reffid = $qdata['reference_id'];
|
||||||
$company = $qdata['company_name'];
|
$company = $qdata['company_name'];
|
||||||
$loc = $qdata['branch'];
|
$loc = $qdata['branch'];
|
||||||
|
$status = $qdata['status'];
|
||||||
|
|
||||||
$visitnum = $qpat['visit_number'];
|
$visitnum = $qpat['visit_number'];
|
||||||
$visitdesc = $qpat['visit_description'];
|
$visitdesc = $qpat['visit_description'];
|
||||||
@ -139,11 +147,11 @@ class API_TM extends ResourceController {
|
|||||||
// tests
|
// tests
|
||||||
$tests = json_decode(json_encode($qpat['tests']), true);;
|
$tests = json_decode(json_encode($qpat['tests']), true);;
|
||||||
$string = '';
|
$string = '';
|
||||||
|
if($status=='order') { $teststatus = 0;}
|
||||||
|
else { $teststatus = 1; }
|
||||||
foreach($tests as $test) {
|
foreach($tests as $test) {
|
||||||
$testcode = $test['service_id'];
|
$testcode = $test['service_id'];
|
||||||
$testreffid = $test['test_ref_id'];
|
$testreffid = $test['test_ref_id'];
|
||||||
if(isset($test['status'])) { $teststatus = $test['status'];}
|
|
||||||
else { $teststatus = ''; }
|
|
||||||
$string .= "( '$testreffid', '$reqid', '$testcode', '$teststatus' ),";
|
$string .= "( '$testreffid', '$reqid', '$testcode', '$teststatus' ),";
|
||||||
}
|
}
|
||||||
$string = rtrim($string, ',');
|
$string = rtrim($string, ',');
|
||||||
@ -230,8 +238,8 @@ class API_TM extends ResourceController {
|
|||||||
$liscode = $qdata['LISCODE'];
|
$liscode = $qdata['LISCODE'];
|
||||||
$status = $qdata['TESTSTATUS'];
|
$status = $qdata['TESTSTATUS'];
|
||||||
if($liscode != '') {
|
if($liscode != '') {
|
||||||
//if($status!=1 || $status !=2) {$status="NW";} else {$status="CA";}
|
if($status!=1 || $status !=2) {$status="NW";} else {$status="CA";}
|
||||||
if($status!='CANCEL') {$status="NW";} else {$status="CA";}
|
//if($status!='CANCEL') {$status="NW";} else {$status="CA";}
|
||||||
$orm .= "ORC|$status|$reffid||$reffid|||^^^$reqdate|||||$doc|$loc||$reqdate|||||||||\r";
|
$orm .= "ORC|$status|$reffid||$reffid|||^^^$reqdate|||||$doc|$loc||$reqdate|||||||||\r";
|
||||||
if($i==1) { $orm .= "NTE|1||$hosp|\r"; }
|
if($i==1) { $orm .= "NTE|1||$hosp|\r"; }
|
||||||
$orm .= "OBR|$i|||$liscode|||||||R|||||$doc|||||||||||||||||||||||||\r";
|
$orm .= "OBR|$i|||$liscode|||||||R|||||$doc|||||||||||||||||||||||||\r";
|
||||||
@ -366,6 +374,7 @@ where r.ACCESSNUMBER='$accessnumber' and t.NOTPRINTABLE is null ORDER BY t.TESTO
|
|||||||
$resdate = $result['RESDATE'];
|
$resdate = $result['RESDATE'];
|
||||||
if($resdate == "1900-01-01 00:00:00.000") { $resdate =''; }
|
if($resdate == "1900-01-01 00:00:00.000") { $resdate =''; }
|
||||||
$userval = $result['USERVAL'];
|
$userval = $result['USERVAL'];
|
||||||
|
$username = $result['USERNAME'];
|
||||||
$data = [
|
$data = [
|
||||||
"test_ref_id"=> "$refftestid",
|
"test_ref_id"=> "$refftestid",
|
||||||
"hiscode"=> "$hiscode",
|
"hiscode"=> "$hiscode",
|
||||||
@ -380,7 +389,7 @@ where r.ACCESSNUMBER='$accessnumber' and t.NOTPRINTABLE is null ORDER BY t.TESTO
|
|||||||
"test_summary"=> "$testsum",
|
"test_summary"=> "$testsum",
|
||||||
"resdate"=> "$resdate",
|
"resdate"=> "$resdate",
|
||||||
"userval"=> "$userval",
|
"userval"=> "$userval",
|
||||||
//"debug" => "d0=$d0 d1=$d1 d2=$d2",
|
"username"=> "$username",
|
||||||
];
|
];
|
||||||
if ( $depth == 0 || $depth == '' ) { // depth 0
|
if ( $depth == 0 || $depth == '' ) { // depth 0
|
||||||
$d0++;
|
$d0++;
|
||||||
@ -421,6 +430,7 @@ WHERE tu.SP_ACCESSNUMBER = '$accessnumber';";
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function sendjson( $method, $url, $message ) {
|
public function sendjson( $method, $url, $message ) {
|
||||||
|
$client = \Config\Services::curlrequest();
|
||||||
try {
|
try {
|
||||||
$response = $client->request($method, $url, $message);
|
$response = $client->request($method, $url, $message);
|
||||||
|
|
||||||
@ -431,34 +441,24 @@ WHERE tu.SP_ACCESSNUMBER = '$accessnumber';";
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
echo "<pre>$token \n".json_encode($json)."\n";
|
//echo "<pre> \n".json_encode($json)."\n";
|
||||||
echo "Error: " . $e->getMessage();
|
echo "Error: " . $e->getMessage();
|
||||||
log_message('error', 'API request exception: ' . $e->getMessage());
|
log_message('error', 'API request exception: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function results_send($accessnumber) {
|
public function results_send($accessnumber) {
|
||||||
//$TM_url = "https://api-transmedic1.transmedic.co.id/api/webhook/lis";
|
//$TMBali_bearerToken = file_get_contents('tokens/pbmc_dps.txt');
|
||||||
$TMSby_url = "http://10.10.4.123:8001/api/webhook/lis";
|
//$TMSby_bearerToken = file_get_contents('tokens/pbmc_sby.txt');
|
||||||
$TMBali_url = "http://10.10.12.90:8001/api/webhook/lis?tenant=PadmaBali";
|
|
||||||
$TMBali_bearerToken = file_get_contents('tokens/pbmc_dps.txt');
|
|
||||||
$TMSby_bearerToken = file_get_contents('tokens/pbmc_sby.txt');
|
|
||||||
|
|
||||||
$client = \Config\Services::curlrequest();
|
|
||||||
|
|
||||||
$json = $this->create_result_json($accessnumber);
|
$json = $this->create_result_json($accessnumber);
|
||||||
$location = $json['branch'];
|
$location = $json['branch'];
|
||||||
if($location == 'PBMC Surabaya') {
|
|
||||||
$token = $TMSby_bearerToken;
|
|
||||||
$url = $TMSby_url;
|
|
||||||
$headers = [
|
|
||||||
"Content-Type" => "application/json",
|
|
||||||
"Authorization" => "Bearer $token",
|
|
||||||
"appCode" => "2"
|
|
||||||
];
|
|
||||||
} else {
|
|
||||||
$token = $TMBali_bearerToken;
|
|
||||||
$url = $TMBali_url;
|
|
||||||
$headers = [ "Content-Type" => "application/json" ];
|
$headers = [ "Content-Type" => "application/json" ];
|
||||||
|
if($location == 'PBMC Surabaya') {
|
||||||
|
//$token = $TMSby_bearerToken;
|
||||||
|
$url = $this->url_resultSBY;
|
||||||
|
} else {
|
||||||
|
//$token = $TMBali_bearerToken;
|
||||||
|
$url = $this->url_resultDPS;
|
||||||
}
|
}
|
||||||
|
|
||||||
$method = "POST";
|
$method = "POST";
|
||||||
@ -468,32 +468,62 @@ WHERE tu.SP_ACCESSNUMBER = '$accessnumber';";
|
|||||||
"body" => json_encode($json),
|
"body" => json_encode($json),
|
||||||
"verify" => false
|
"verify" => false
|
||||||
];
|
];
|
||||||
|
echo "<pre>";
|
||||||
|
//print_r($message);
|
||||||
$this->sendjson($method, $url, $message);
|
$this->sendjson($method, $url, $message);
|
||||||
/*
|
|
||||||
try {
|
|
||||||
$response = $client->request('POST', $url, [
|
|
||||||
"headers" => $headers,
|
|
||||||
"body" => json_encode($json),
|
|
||||||
"verify" => false
|
|
||||||
]);
|
|
||||||
|
|
||||||
if ($response->getStatusCode() == 200) {
|
|
||||||
print_r($response);
|
|
||||||
} else {
|
|
||||||
print_r($response);
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
echo "<pre>$token \n".json_encode($json)."\n";
|
|
||||||
echo "Error: " . $e->getMessage();
|
|
||||||
log_message('error', 'API request exception: ' . $e->getMessage());
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function results_preview($accessnumber) {
|
public function results_preview($accessnumber) {
|
||||||
$json = $this->create_result_json($accessnumber);
|
$json = $this->create_result_json($accessnumber);
|
||||||
return $this->respond($json);
|
return $this->respond($json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function oc ($hon, $test) {
|
||||||
|
$db = \Config\Database::connect();
|
||||||
|
$sql = "select r.*, p.*, t.* from cmod.dbo.CM_TM_REQUESTS r
|
||||||
|
left join cmod.dbo.CM_TM_PATIENTS p on r.PATID=p.PATID
|
||||||
|
left join cmod.dbo.CM_DICT_MAPPINGS m on m.LISCODE='$test'
|
||||||
|
left join cmod.dbo.CM_TM_TESTS t on t.REQID=r.REQID and t.HISCODE=m.HISCODE
|
||||||
|
where r.REFFID='$hon' ";
|
||||||
|
$query = $db->query($sql);
|
||||||
|
$results = $query->getResultArray();
|
||||||
|
$visitnumber = $results[0]['REQNUMBER'];
|
||||||
|
$location = $results[0]['LOC'];
|
||||||
|
$patnumber = $results[0]['PATNUMBER'];
|
||||||
|
$firstname = $results[0]['FIRSTNAME'];
|
||||||
|
$lastname = $results[0]['LASTNAME'];
|
||||||
|
$hiscode = $results[0]['HISCODE'];
|
||||||
|
$refftestid = $results[0]['REFFTESTID'];
|
||||||
|
|
||||||
|
$method = "POST";
|
||||||
|
if($location == "PBMC Bali") { $url = $this->url_resultDPS; }
|
||||||
|
else { $url = $this->url_resultSBY; }
|
||||||
|
|
||||||
|
$headers = [ "Content-Type" => "application/json" ];
|
||||||
|
$json = [
|
||||||
|
"reference_id" => "$hon",
|
||||||
|
"company_name" => "Padma Medical Group",
|
||||||
|
"branch" => "$location",
|
||||||
|
"status" => "cancel",
|
||||||
|
"patient" => [
|
||||||
|
"rm_number" => "$patnumber",
|
||||||
|
"patient_first_name" => "$firstname",
|
||||||
|
"patient_last_name" => "$lastname",
|
||||||
|
"visit_number" => "$visitnumber"
|
||||||
|
],
|
||||||
|
"tests" => [
|
||||||
|
"test_ref_id" => trim($refftestid),
|
||||||
|
"service_id" => "$hiscode"
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
//return $this->respond($json);
|
||||||
|
$message = [
|
||||||
|
"headers" => $headers,
|
||||||
|
"body" => json_encode($json),
|
||||||
|
"verify" => false
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->sendjson($method, $url, $message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user