Initial import
This commit is contained in:
450
application/controllers/tools/101025_print/Listrptpatient.php
Normal file
450
application/controllers/tools/101025_print/Listrptpatient.php
Normal file
@@ -0,0 +1,450 @@
|
||||
<?php
|
||||
class Listrptpatient extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Listing Report Patient API";
|
||||
}
|
||||
|
||||
function get_list_patient_rpt($orderHeaderID)
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$lab = "";
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
from t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID AND mp.M_PatientIsActive = 'Y'
|
||||
JOIN t_orderdetail ON toh.T_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND Group_ResultName = 'LAB'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'
|
||||
LIMIT 1";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
//echo $this->db->last_query();
|
||||
if($row && count($row) > 0){
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_history.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql);
|
||||
//echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = "";
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
$kebugaran = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$value["so_id"]}&PLang=1&tm={$value["Datetime"]}";
|
||||
//$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$value["so_id"]}&PLang=1&tm={$value["Datetime"]}";
|
||||
|
||||
|
||||
if($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Treadmill'){
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y' AND `T_NonlabDocumentType` = 'pdf'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if(count($rows_attachment) > 0){
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/'.$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear_history.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro_2.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg_2_annual.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
|
||||
if($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0){
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = {$value["so_id"]}
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type);
|
||||
|
||||
if ($qry_type) {
|
||||
// echo "IN";
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$file_cover = "rpt_mcu_resume_cover";
|
||||
|
||||
$sql = "SELECT M_CoverRpt as file_cover, M_CoverRptLogo as file_logo
|
||||
FROM t_orderheader
|
||||
JOIN mgm_cover ON T_OrderHeaderMgm_McuID = Mgm_CoverMgm_McuID AND Mgm_CoverIsActive = 'Y'
|
||||
JOIN m_cover ON Mgm_CoverM_CoverCode = M_CoverCode AND M_CoverIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$qry_cover = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_cover) {
|
||||
$row_cover = $qry_cover->result_array();
|
||||
if(count($row_cover) > 0){
|
||||
$file_cover = $row_cover[0]['file_cover'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$cover_rpt = "";
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/".$file_cover.".rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$additional = "";
|
||||
if($fisik == ""){
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
//print_r($rows_addtional);
|
||||
if(count($rows_addtional) > 0){
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata_history.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://cpone.aplikasi.web.id";
|
||||
$prefix = "https://".$_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
|
||||
if(count($attachments) > 0){
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix."/one-media/one-files/".$value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if ($rontgen != "") {
|
||||
$list_rpt[] = $prefix . $rontgen;
|
||||
}
|
||||
/*if ($usg_abdomen != "") {
|
||||
$list_rpt[] = $prefix . $usg_abdomen;
|
||||
}*/
|
||||
if(count($usg) > 0){
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if(count($treadmill_attachment) > 0){
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "") {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/frameset?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/frameset?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
|
||||
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
$jsonData = json_encode($merge_input);
|
||||
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://".$_SERVER['SERVER_NAME']."/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $lab_number . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt(
|
||||
$ch,
|
||||
CURLOPT_HTTPHEADER,
|
||||
array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data)
|
||||
)
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,442 @@
|
||||
<?php
|
||||
class Listrptpatient extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Listing Report Patient API";
|
||||
}
|
||||
|
||||
function get_list_patient_rpt($orderHeaderID)
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$lab = "";
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
from t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID AND mp.M_PatientIsActive = 'Y'
|
||||
JOIN t_orderdetail ON toh.T_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND Group_ResultName = 'LAB'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'
|
||||
LIMIT 1";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
//echo $this->db->last_query();
|
||||
if($row && count($row) > 0){
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_history.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT group_resultName as rpt_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql);
|
||||
//echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = "";
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg_abdomen = "";
|
||||
$sds = "";
|
||||
$kebugaran = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$value["so_id"]}&PLang=1&tm={$value["Datetime"]}";
|
||||
//$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$value["so_id"]}&PLang=1&tm={$value["Datetime"]}";
|
||||
|
||||
|
||||
if($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Treadmill'){
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y' AND `T_NonlabDocumentType` = 'pdf'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if(count($rows_attachment) > 0){
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/'.$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear_history.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'USG' || $value['rpt_name'] == 'USG Abdominal Aorta' || $value['rpt_name'] == 'USG Upp & Low Abdomen' )
|
||||
$usg_abdomen = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg_2_annual.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
|
||||
if($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0){
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = {$value["so_id"]}
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type);
|
||||
|
||||
if ($qry_type) {
|
||||
// echo "IN";
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$file_cover = "rpt_mcu_resume_cover";
|
||||
|
||||
$sql = "SELECT M_CoverRpt as file_cover, M_CoverRptLogo as file_logo
|
||||
FROM t_orderheader
|
||||
JOIN mgm_cover ON T_OrderHeaderMgm_McuID = Mgm_CoverMgm_McuID AND Mgm_CoverIsActive = 'Y'
|
||||
JOIN m_cover ON Mgm_CoverM_CoverCode = M_CoverCode AND M_CoverIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$qry_cover = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_cover) {
|
||||
$row_cover = $qry_cover->result_array();
|
||||
if(count($row_cover) > 0){
|
||||
$file_cover = $row_cover[0]['file_cover'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$cover_rpt = "";
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/".$file_cover.".rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$additional = "";
|
||||
if($fisik == ""){
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
//print_r($rows_addtional);
|
||||
if(count($rows_addtional) > 0){
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata_history.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://cpone.aplikasi.web.id";
|
||||
$prefix = "https://".$_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
|
||||
if(count($attachments) > 0){
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix."/one-media/one-files/".$value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if ($rontgen != "") {
|
||||
$list_rpt[] = $prefix . $rontgen;
|
||||
}
|
||||
if ($usg_abdomen != "") {
|
||||
$list_rpt[] = $prefix . $usg_abdomen;
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if(count($treadmill_attachment) > 0){
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "") {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/frameset?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/frameset?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
|
||||
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
$jsonData = json_encode($merge_input);
|
||||
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://".$_SERVER['SERVER_NAME']."/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $lab_number . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt(
|
||||
$ch,
|
||||
CURLOPT_HTTPHEADER,
|
||||
array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data)
|
||||
)
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,844 @@
|
||||
<?php
|
||||
class Listrptpatientportal extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Listing Report Patient API";
|
||||
}
|
||||
|
||||
function get_list_patient_rpt($orderHeaderID, $dob = "")
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$lab = "";
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
from t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID AND mp.M_PatientIsActive = 'Y'
|
||||
JOIN t_orderdetail ON toh.T_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND Group_ResultName = 'LAB'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'
|
||||
LIMIT 1";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
if ($row && count($row) > 0) {
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_history_portal.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = "";
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
$kebugaran = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
//print_r($rows_rpt);
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if ($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_portal.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Treadmill'){
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if(count($rows_attachment) > 0){
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/'.$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear_history_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro_2_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0) {
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
if($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
$file_cover = "rpt_mcu_resume_cover_portal";
|
||||
|
||||
$sql = "SELECT M_CoverRpt as file_cover, M_CoverRptLogo as file_logo
|
||||
FROM t_orderheader
|
||||
JOIN mgm_cover ON T_OrderHeaderMgm_McuID = Mgm_CoverMgm_McuID AND Mgm_CoverIsActive = 'Y'
|
||||
JOIN m_cover ON Mgm_CoverM_CoverCode = M_CoverCode AND M_CoverIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$qry_cover = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_cover) {
|
||||
$row_cover = $qry_cover->result_array();
|
||||
if(count($row_cover) > 0){
|
||||
$file_cover = $row_cover[0]['file_logo'];
|
||||
}
|
||||
}
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_portal.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/".$file_cover.".rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$additional = "";
|
||||
if ($fisik == "") {
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
//print_r($rows_addtional);
|
||||
if (count($rows_addtional) > 0) {
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata_history_portal.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://devcpone.aplikasi.web.id";
|
||||
$prefix = "https://" . $_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if (count($attachments) > 0) {
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-files/" . $value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if ($rontgen != "") {
|
||||
$list_rpt[] = $prefix . $rontgen;
|
||||
}
|
||||
/*if ($usg_abdomen != "") {
|
||||
$list_rpt[] = $prefix . $usg_abdomen;
|
||||
}*/
|
||||
if(count($usg) > 0){
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if(count($treadmill_attachment) > 0){
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "") {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
//echo json_encode($list_rpt);
|
||||
//exit;
|
||||
//print_r($list_rpt);
|
||||
//exit;
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
|
||||
$jsonData = json_encode($merge_input);
|
||||
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $lab_number . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function get_list_patient_rpt_email($orderHeaderID, $dob = "")
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
IFNULL(mp.M_PatientNIP, '') AS M_PatientNIP,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID
|
||||
AND mp.M_PatientIsActive = 'Y'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$nip = "";
|
||||
$lab = "";
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$nip = $value["M_PatientNIP"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_history_portal.rptdesign&__format=pdf&PID={$value["M_PatientID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = "";
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
$kebugaran = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
//print_r($rows_rpt);
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if ($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_portal.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Treadmill'){
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y' AND `T_NonlabDocumentType` = 'pdf'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if(count($rows_attachment) > 0){
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/'.$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear_history_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
|
||||
if ($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0) {
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
if($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
$file_cover = "rpt_mcu_resume_cover_portal";
|
||||
|
||||
$sql = "SELECT M_CoverRpt as file_cover, M_CoverRptLogo as file_logo
|
||||
FROM t_orderheader
|
||||
JOIN mgm_cover ON T_OrderHeaderMgm_McuID = Mgm_CoverMgm_McuID AND Mgm_CoverIsActive = 'Y'
|
||||
JOIN m_cover ON Mgm_CoverM_CoverCode = M_CoverCode AND M_CoverIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$qry_cover = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_cover) {
|
||||
$row_cover = $qry_cover->result_array();
|
||||
if(count($row_cover) > 0){
|
||||
$file_cover = $row_cover[0]['file_logo'];
|
||||
}
|
||||
}
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_portal.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/".$file_cover.".rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$additional = "";
|
||||
if ($fisik == "") {
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
//print_r($rows_addtional);
|
||||
if (count($rows_addtional) > 0) {
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata_history_portal.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://devcpone.aplikasi.web.id";
|
||||
$prefix = "https://" . $_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if (count($attachments) > 0) {
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-files/" . $value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if ($rontgen != "") {
|
||||
$list_rpt[] = $prefix . $rontgen;
|
||||
}
|
||||
/*if ($usg_abdomen != "") {
|
||||
$list_rpt[] = $prefix . $usg_abdomen;
|
||||
}*/
|
||||
if(count($usg) > 0){
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if(count($treadmill_attachment) > 0){
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "") {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
//echo json_encode($list_rpt);
|
||||
// print_r($list_rpt);
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
if ($dob != "") {
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt,
|
||||
"dob" => $dob
|
||||
);
|
||||
}
|
||||
$jsonData = json_encode($merge_input);
|
||||
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $nip . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt(
|
||||
$ch,
|
||||
CURLOPT_HTTPHEADER,
|
||||
array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data)
|
||||
)
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,849 @@
|
||||
<?php
|
||||
class Listrptpatientportal extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Listing Report Patient API";
|
||||
}
|
||||
|
||||
function get_list_patient_rpt($orderHeaderID, $dob = "")
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$lab = "";
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
from t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID AND mp.M_PatientIsActive = 'Y'
|
||||
JOIN t_orderdetail ON toh.T_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND Group_ResultName = 'LAB'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'
|
||||
LIMIT 1";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
if ($row && count($row) > 0) {
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_history_portal.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = "";
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
$kebugaran = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
//print_r($rows_rpt);
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if ($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_portal.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Treadmill'){
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if(count($rows_attachment) > 0){
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/'.$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear_history_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0) {
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
if($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
$file_cover = "rpt_mcu_resume_cover_portal";
|
||||
|
||||
$sql = "SELECT M_CoverRpt as file_cover, M_CoverRptLogo as file_logo
|
||||
FROM t_orderheader
|
||||
JOIN mgm_cover ON T_OrderHeaderMgm_McuID = Mgm_CoverMgm_McuID AND Mgm_CoverIsActive = 'Y'
|
||||
JOIN m_cover ON Mgm_CoverM_CoverCode = M_CoverCode AND M_CoverIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$qry_cover = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_cover) {
|
||||
$row_cover = $qry_cover->result_array();
|
||||
if(count($row_cover) > 0){
|
||||
$file_cover = $row_cover[0]['file_logo'];
|
||||
}
|
||||
}
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_portal.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/".$file_cover.".rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$additional = "";
|
||||
if ($fisik == "") {
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
//print_r($rows_addtional);
|
||||
if (count($rows_addtional) > 0) {
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata_history_portal.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://devcpone.aplikasi.web.id";
|
||||
$prefix = "https://" . $_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if (count($attachments) > 0) {
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-files/" . $value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if ($rontgen != "") {
|
||||
$list_rpt[] = $prefix . $rontgen;
|
||||
}
|
||||
/*if ($usg_abdomen != "") {
|
||||
$list_rpt[] = $prefix . $usg_abdomen;
|
||||
}*/
|
||||
if(count($usg) > 0){
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if(count($treadmill_attachment) > 0){
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "") {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
//echo json_encode($list_rpt);
|
||||
//exit;
|
||||
//print_r($list_rpt);
|
||||
//exit;
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
|
||||
$jsonData = json_encode($merge_input);
|
||||
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $lab_number . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function get_list_patient_rpt_email($orderHeaderID, $dob = "")
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
IFNULL(mp.M_PatientNIP, '') AS M_PatientNIP,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID
|
||||
AND mp.M_PatientIsActive = 'Y'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$nip = "";
|
||||
$lab = "";
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$nip = $value["M_PatientNIP"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_history_portal.rptdesign&__format=pdf&PID={$value["M_PatientID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = "";
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
$kebugaran = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
//print_r($rows_rpt);
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if ($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_portal.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Treadmill'){
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y' AND `T_NonlabDocumentType` = 'pdf'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if(count($rows_attachment) > 0){
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/'.$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear_history_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
|
||||
if ($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0) {
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
if($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
$file_cover = "rpt_mcu_resume_cover_portal";
|
||||
|
||||
$sql = "SELECT M_CoverRpt as file_cover, M_CoverRptLogo as file_logo
|
||||
FROM t_orderheader
|
||||
JOIN mgm_cover ON T_OrderHeaderMgm_McuID = Mgm_CoverMgm_McuID AND Mgm_CoverIsActive = 'Y'
|
||||
JOIN m_cover ON Mgm_CoverM_CoverCode = M_CoverCode AND M_CoverIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$qry_cover = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_cover) {
|
||||
$row_cover = $qry_cover->result_array();
|
||||
if(count($row_cover) > 0){
|
||||
$file_cover = $row_cover[0]['file_logo'];
|
||||
}
|
||||
}
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_portal.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/".$file_cover.".rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$additional = "";
|
||||
if ($fisik == "") {
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
//print_r($rows_addtional);
|
||||
if (count($rows_addtional) > 0) {
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata_history_portal.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://devcpone.aplikasi.web.id";
|
||||
$prefix = "https://" . $_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if (count($attachments) > 0) {
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-files/" . $value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if ($rontgen != "") {
|
||||
$list_rpt[] = $prefix . $rontgen;
|
||||
}
|
||||
/*if ($usg_abdomen != "") {
|
||||
$list_rpt[] = $prefix . $usg_abdomen;
|
||||
}*/
|
||||
if(count($usg) > 0){
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if(count($treadmill_attachment) > 0){
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "") {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
//echo json_encode($list_rpt);
|
||||
// print_r($list_rpt);
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
if ($dob != "") {
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt,
|
||||
"dob" => $dob
|
||||
);
|
||||
}
|
||||
$jsonData = json_encode($merge_input);
|
||||
|
||||
// $jsonDebug = json_encode($merge_input, JSON_PRETTY_PRINT);
|
||||
|
||||
// echo '<pre>' . htmlspecialchars($jsonDebug) . '</pre>';
|
||||
// exit;
|
||||
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $nip . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt(
|
||||
$ch,
|
||||
CURLOPT_HTTPHEADER,
|
||||
array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data)
|
||||
)
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,856 @@
|
||||
<?php
|
||||
class Listrptpatientportalbg extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Listing Report Patient API";
|
||||
}
|
||||
|
||||
function get_list_patient_rpt($orderHeaderID, $background, $dob = "")
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
|
||||
if($background === "bgdflt"){
|
||||
$background = "";
|
||||
}
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$lab = "";
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
from t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID AND mp.M_PatientIsActive = 'Y'
|
||||
JOIN t_orderdetail ON toh.T_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND Group_ResultName = 'LAB'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'
|
||||
LIMIT 1";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
if ($row && count($row) > 0) {
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_history" . $background . "_portal.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = "";
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
$kebugaran = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
//print_r($rows_rpt);
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if ($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history" . $background . "_portal.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual" . $background . "_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual" . $background . "_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual" . $background . "_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual" . $background . "_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Treadmill') {
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual" . $background . "_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if (count($rows_attachment) > 0) {
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/' . $value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear_history" . $background . "_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro" . $background . "_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg_2_annual" . $background . "_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0) {
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan" . $background . "_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
$file_cover = "rpt_mcu_resume_cover" . $background . "_portal";
|
||||
|
||||
$sql = "SELECT M_CoverRpt as file_cover, M_CoverRptLogo as file_logo
|
||||
FROM t_orderheader
|
||||
JOIN mgm_cover ON T_OrderHeaderMgm_McuID = Mgm_CoverMgm_McuID AND Mgm_CoverIsActive = 'Y'
|
||||
JOIN m_cover ON Mgm_CoverM_CoverCode = M_CoverCode AND M_CoverIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$qry_cover = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_cover) {
|
||||
$row_cover = $qry_cover->result_array();
|
||||
if (count($row_cover) > 0) {
|
||||
$file_cover = $row_cover[0]['file_logo'];
|
||||
if (strpos($file_cover, '_portal') !== false) {
|
||||
$file_cover = str_replace('_portal', $background . '_portal', $file_cover);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan" . $background . "_portal.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/" . $file_cover . ".rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$additional = "";
|
||||
if ($fisik == "") {
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
//print_r($rows_addtional);
|
||||
if (count($rows_addtional) > 0) {
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata_history" . $background . "_portal.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://devcpone.aplikasi.web.id";
|
||||
$prefix = "https://" . $_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if (count($attachments) > 0) {
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-files/" . $value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if ($rontgen != "") {
|
||||
$list_rpt[] = $prefix . $rontgen;
|
||||
}
|
||||
/*if ($usg_abdomen != "") {
|
||||
$list_rpt[] = $prefix . $usg_abdomen;
|
||||
}*/
|
||||
if (count($usg) > 0) {
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if (count($treadmill_attachment) > 0) {
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "") {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
//echo json_encode($list_rpt);
|
||||
//exit;
|
||||
//print_r($list_rpt);
|
||||
//exit;
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
|
||||
$jsonData = json_encode($merge_input);
|
||||
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $lab_number . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function get_list_patient_rpt_email($orderHeaderID, $dob = "")
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
IFNULL(mp.M_PatientNIP, '') AS M_PatientNIP,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID
|
||||
AND mp.M_PatientIsActive = 'Y'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$nip = "";
|
||||
$lab = "";
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$nip = $value["M_PatientNIP"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_history_portal.rptdesign&__format=pdf&PID={$value["M_PatientID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = "";
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
$kebugaran = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
//print_r($rows_rpt);
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if ($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_portal.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Treadmill') {
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y' AND `T_NonlabDocumentType` = 'pdf'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if (count($rows_attachment) > 0) {
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/' . $value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear_history_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
|
||||
if ($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0) {
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
$file_cover = "rpt_mcu_resume_cover_portal";
|
||||
|
||||
$sql = "SELECT M_CoverRpt as file_cover, M_CoverRptLogo as file_logo
|
||||
FROM t_orderheader
|
||||
JOIN mgm_cover ON T_OrderHeaderMgm_McuID = Mgm_CoverMgm_McuID AND Mgm_CoverIsActive = 'Y'
|
||||
JOIN m_cover ON Mgm_CoverM_CoverCode = M_CoverCode AND M_CoverIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$qry_cover = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_cover) {
|
||||
$row_cover = $qry_cover->result_array();
|
||||
if (count($row_cover) > 0) {
|
||||
$file_cover = $row_cover[0]['file_logo'];
|
||||
}
|
||||
}
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_portal.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/" . $file_cover . ".rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$additional = "";
|
||||
if ($fisik == "") {
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
//print_r($rows_addtional);
|
||||
if (count($rows_addtional) > 0) {
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata_history_portal.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://devcpone.aplikasi.web.id";
|
||||
$prefix = "https://" . $_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if (count($attachments) > 0) {
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-files/" . $value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if ($rontgen != "") {
|
||||
$list_rpt[] = $prefix . $rontgen;
|
||||
}
|
||||
/*if ($usg_abdomen != "") {
|
||||
$list_rpt[] = $prefix . $usg_abdomen;
|
||||
}*/
|
||||
if (count($usg) > 0) {
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if (count($treadmill_attachment) > 0) {
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "") {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
//echo json_encode($list_rpt);
|
||||
// print_r($list_rpt);
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
if ($dob != "") {
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt,
|
||||
"dob" => $dob
|
||||
);
|
||||
}
|
||||
$jsonData = json_encode($merge_input);
|
||||
|
||||
// $jsonDebug = json_encode($merge_input, JSON_PRETTY_PRINT);
|
||||
|
||||
// echo '<pre>' . htmlspecialchars($jsonDebug) . '</pre>';
|
||||
// exit;
|
||||
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $nip . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt(
|
||||
$ch,
|
||||
CURLOPT_HTTPHEADER,
|
||||
array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data)
|
||||
)
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,856 @@
|
||||
<?php
|
||||
class Listrptpatientportalbg extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Listing Report Patient API";
|
||||
}
|
||||
|
||||
function get_list_patient_rpt($orderHeaderID, $background, $dob = "")
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
|
||||
if($background === "bgdflt"){
|
||||
$background = "";
|
||||
}
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$lab = "";
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
from t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID AND mp.M_PatientIsActive = 'Y'
|
||||
JOIN t_orderdetail ON toh.T_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND Group_ResultName = 'LAB'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'
|
||||
LIMIT 1";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
if ($row && count($row) > 0) {
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_history" . $background . "_portal.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = "";
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
$kebugaran = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
//print_r($rows_rpt);
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if ($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history" . $background . "_portal.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual" . $background . "_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual" . $background . "_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual" . $background . "_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual" . $background . "_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Treadmill') {
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual" . $background . "_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if (count($rows_attachment) > 0) {
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/' . $value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear_history" . $background . "_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro" . $background . "_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg_2_annual" . $background . "_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0) {
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan" . $background . "_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
$file_cover = "rpt_mcu_resume_cover" . $background . "_portal";
|
||||
|
||||
$sql = "SELECT M_CoverRpt as file_cover, M_CoverRptLogo as file_logo
|
||||
FROM t_orderheader
|
||||
JOIN mgm_cover ON T_OrderHeaderMgm_McuID = Mgm_CoverMgm_McuID AND Mgm_CoverIsActive = 'Y'
|
||||
JOIN m_cover ON Mgm_CoverM_CoverCode = M_CoverCode AND M_CoverIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$qry_cover = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_cover) {
|
||||
$row_cover = $qry_cover->result_array();
|
||||
if (count($row_cover) > 0) {
|
||||
$file_cover = $row_cover[0]['file_logo'];
|
||||
if (strpos($file_cover, '_portal') !== false) {
|
||||
$file_cover = str_replace('_portal', $background . '_portal', $file_cover);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan" . $background . "_portal.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/" . $file_cover . ".rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$additional = "";
|
||||
if ($fisik == "") {
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
//print_r($rows_addtional);
|
||||
if (count($rows_addtional) > 0) {
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata_history" . $background . "_portal.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://devcpone.aplikasi.web.id";
|
||||
$prefix = "https://" . $_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if (count($attachments) > 0) {
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-files/" . $value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if ($rontgen != "") {
|
||||
$list_rpt[] = $prefix . $rontgen;
|
||||
}
|
||||
/*if ($usg_abdomen != "") {
|
||||
$list_rpt[] = $prefix . $usg_abdomen;
|
||||
}*/
|
||||
if (count($usg) > 0) {
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if (count($treadmill_attachment) > 0) {
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "") {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
//echo json_encode($list_rpt);
|
||||
//exit;
|
||||
//print_r($list_rpt);
|
||||
//exit;
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
|
||||
$jsonData = json_encode($merge_input);
|
||||
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $lab_number . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function get_list_patient_rpt_email($orderHeaderID, $dob = "")
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
IFNULL(mp.M_PatientNIP, '') AS M_PatientNIP,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID
|
||||
AND mp.M_PatientIsActive = 'Y'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$nip = "";
|
||||
$lab = "";
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$nip = $value["M_PatientNIP"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_history_portal.rptdesign&__format=pdf&PID={$value["M_PatientID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = "";
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
$kebugaran = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
//print_r($rows_rpt);
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if ($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_portal.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Treadmill') {
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y' AND `T_NonlabDocumentType` = 'pdf'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if (count($rows_attachment) > 0) {
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/' . $value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear_history_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
|
||||
if ($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0) {
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
$file_cover = "rpt_mcu_resume_cover_portal";
|
||||
|
||||
$sql = "SELECT M_CoverRpt as file_cover, M_CoverRptLogo as file_logo
|
||||
FROM t_orderheader
|
||||
JOIN mgm_cover ON T_OrderHeaderMgm_McuID = Mgm_CoverMgm_McuID AND Mgm_CoverIsActive = 'Y'
|
||||
JOIN m_cover ON Mgm_CoverM_CoverCode = M_CoverCode AND M_CoverIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$qry_cover = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_cover) {
|
||||
$row_cover = $qry_cover->result_array();
|
||||
if (count($row_cover) > 0) {
|
||||
$file_cover = $row_cover[0]['file_logo'];
|
||||
}
|
||||
}
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_portal.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/" . $file_cover . ".rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$additional = "";
|
||||
if ($fisik == "") {
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
//print_r($rows_addtional);
|
||||
if (count($rows_addtional) > 0) {
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata_history_portal.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://devcpone.aplikasi.web.id";
|
||||
$prefix = "https://" . $_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if (count($attachments) > 0) {
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-files/" . $value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if ($rontgen != "") {
|
||||
$list_rpt[] = $prefix . $rontgen;
|
||||
}
|
||||
/*if ($usg_abdomen != "") {
|
||||
$list_rpt[] = $prefix . $usg_abdomen;
|
||||
}*/
|
||||
if (count($usg) > 0) {
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if (count($treadmill_attachment) > 0) {
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "") {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
//echo json_encode($list_rpt);
|
||||
// print_r($list_rpt);
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
if ($dob != "") {
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt,
|
||||
"dob" => $dob
|
||||
);
|
||||
}
|
||||
$jsonData = json_encode($merge_input);
|
||||
|
||||
// $jsonDebug = json_encode($merge_input, JSON_PRETTY_PRINT);
|
||||
|
||||
// echo '<pre>' . htmlspecialchars($jsonDebug) . '</pre>';
|
||||
// exit;
|
||||
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $nip . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt(
|
||||
$ch,
|
||||
CURLOPT_HTTPHEADER,
|
||||
array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data)
|
||||
)
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,407 @@
|
||||
<?php
|
||||
class Listrptpatienttahunan extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Listing Report Patient API";
|
||||
}
|
||||
|
||||
function get_list_patient_rpt($orderHeaderID,$timestamp='',$tanpa_kesimpulan='N')
|
||||
{
|
||||
try {
|
||||
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$lab = "";
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
from t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID AND mp.M_PatientIsActive = 'Y'
|
||||
JOIN t_orderdetail ON toh.T_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND Group_ResultName = 'LAB'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'
|
||||
LIMIT 1";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
if($row && count($row) > 0){
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&PID={$value["M_PatientID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$lab = "";
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = "";
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
$kebugaran = '';
|
||||
|
||||
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_v2.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_xray.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Treadmill'){
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y' AND `T_NonlabDocumentType` = 'pdf'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if(count($rows_attachment) > 0){
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/'.$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['group_name'] == 'USG' )
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0){
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
if($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
$file_cover = "rpt_mcu_resume_cover";
|
||||
|
||||
$sql = "SELECT M_CoverRpt as file_cover, M_CoverRptLogo as file_logo
|
||||
FROM t_orderheader
|
||||
JOIN mgm_cover ON T_OrderHeaderMgm_McuID = Mgm_CoverMgm_McuID AND Mgm_CoverIsActive = 'Y'
|
||||
JOIN m_cover ON Mgm_CoverM_CoverCode = M_CoverCode AND M_CoverIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$qry_cover = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_cover) {
|
||||
$row_cover = $qry_cover->result_array();
|
||||
if(count($row_cover) > 0){
|
||||
$file_cover = $row_cover[0]['file_cover'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_v2.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/".$file_cover.".rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$additional = "";
|
||||
if($fisik == ""){
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
//print_r($rows_addtional);
|
||||
if(count($rows_addtional) > 0){
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata_portal.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$prefix = "http://localhost";
|
||||
$prefix = "https://".$_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if(count($attachments) > 0){
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix."/one-media/one-files/".$value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if ($rontgen != "") {
|
||||
$list_rpt[] = $prefix . $rontgen;
|
||||
}
|
||||
/*if ($usg_abdomen != "") {
|
||||
$list_rpt[] = $prefix . $usg_abdomen;
|
||||
}*/
|
||||
if(count($usg) > 0){
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if(count($treadmill_attachment) > 0){
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "" && $tanpa_kesimpulan == "N") {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
//echo json_encode($list_rpt);
|
||||
//print_r($list_rpt);
|
||||
//exit;
|
||||
|
||||
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
$jsonData = json_encode($merge_input);
|
||||
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://".$_SERVER['SERVER_NAME']."/one-api/tools/merge_pdf/merge";
|
||||
//echo $target_pdf ;
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $lab_number . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt(
|
||||
$ch,
|
||||
CURLOPT_HTTPHEADER,
|
||||
array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data)
|
||||
)
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,407 @@
|
||||
<?php
|
||||
class Listrptpatienttahunaneng extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Listing Report Patient API";
|
||||
}
|
||||
|
||||
function get_list_patient_rpt($orderHeaderID,$timestamp='',$tanpa_kesimpulan='N')
|
||||
{
|
||||
try {
|
||||
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$lab = "";
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
from t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID AND mp.M_PatientIsActive = 'Y'
|
||||
JOIN t_orderdetail ON toh.T_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND Group_ResultName = 'LAB'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'
|
||||
LIMIT 1";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
if($row && count($row) > 0){
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_eng.rptdesign&__format=pdf&PID={$value["M_PatientID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$lab = "";
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_eng.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = "";
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
$kebugaran = '';
|
||||
|
||||
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_eng.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_xray_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Treadmill'){
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y' AND `T_NonlabDocumentType` = 'pdf'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if(count($rows_attachment) > 0){
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/'.$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear_eng.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro_eng.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0){
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
if($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
$file_cover = "rpt_mcu_resume_cover_eng";
|
||||
|
||||
$sql = "SELECT M_CoverRpt as file_cover, M_CoverRptLogo as file_logo, M_CoverRptEng as file_eng
|
||||
FROM t_orderheader
|
||||
JOIN mgm_cover ON T_OrderHeaderMgm_McuID = Mgm_CoverMgm_McuID AND Mgm_CoverIsActive = 'Y'
|
||||
JOIN m_cover ON Mgm_CoverM_CoverCode = M_CoverCode AND M_CoverIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$qry_cover = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_cover) {
|
||||
$row_cover = $qry_cover->result_array();
|
||||
if(count($row_cover) > 0){
|
||||
$file_cover = $row_cover[0]['file_eng'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_v2_eng.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/".$file_cover.".rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$additional = "";
|
||||
if($fisik == ""){
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
//print_r($rows_addtional);
|
||||
if(count($rows_addtional) > 0){
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata_portal.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$prefix = "http://localhost";
|
||||
$prefix = "https://".$_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if(count($attachments) > 0){
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix."/one-media/one-files/".$value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if ($rontgen != "") {
|
||||
$list_rpt[] = $prefix . $rontgen;
|
||||
}
|
||||
/*if ($usg_abdomen != "") {
|
||||
$list_rpt[] = $prefix . $usg_abdomen;
|
||||
}*/
|
||||
if(count($usg) > 0){
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if(count($treadmill_attachment) > 0){
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "" && $tanpa_kesimpulan == "N") {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
//echo json_encode($list_rpt);
|
||||
//print_r($list_rpt);
|
||||
//exit;
|
||||
|
||||
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
$jsonData = json_encode($merge_input);
|
||||
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://".$_SERVER['SERVER_NAME']."/one-api/tools/merge_pdf/merge";
|
||||
//echo $target_pdf ;
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $lab_number . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt(
|
||||
$ch,
|
||||
CURLOPT_HTTPHEADER,
|
||||
array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data)
|
||||
)
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,855 @@
|
||||
<?php
|
||||
class Listrptpatienttahunanportal extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Listing Report Patient API";
|
||||
}
|
||||
|
||||
function get_list_patient_rpt($orderHeaderID, $timestamp = '', $tanpa_kesimpulan = 'N')
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$lab = "";
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
from t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID AND mp.M_PatientIsActive = 'Y'
|
||||
JOIN t_orderdetail ON toh.T_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND Group_ResultName = 'LAB'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'
|
||||
LIMIT 1";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
if ($row && count($row) > 0) {
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_portal.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = "";
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
//print_r($rows_rpt);
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if ($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_v2_portal.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_xray_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Treadmill'){
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y' AND `T_NonlabDocumentType` = 'pdf'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if(count($rows_attachment) > 0){
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/'.$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0) {
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
if($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
$file_cover = "rpt_mcu_resume_cover_portal";
|
||||
|
||||
$sql = "SELECT M_CoverRpt as file_cover, M_CoverRptLogo as file_logo
|
||||
FROM t_orderheader
|
||||
JOIN mgm_cover ON T_OrderHeaderMgm_McuID = Mgm_CoverMgm_McuID AND Mgm_CoverIsActive = 'Y'
|
||||
JOIN m_cover ON Mgm_CoverM_CoverCode = M_CoverCode AND M_CoverIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$qry_cover = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_cover) {
|
||||
$row_cover = $qry_cover->result_array();
|
||||
if(count($row_cover) > 0){
|
||||
$file_cover = $row_cover[0]['file_logo'];
|
||||
}
|
||||
}
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_v2_portal.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/".$file_cover.".rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$additional = "";
|
||||
if ($fisik == "") {
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
//print_r($rows_addtional);
|
||||
if (count($rows_addtional) > 0) {
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata_portal.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://devcpone.aplikasi.web.id";
|
||||
$prefix = "https://" . $_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if (count($attachments) > 0) {
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-files/" . $value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if ($rontgen != "") {
|
||||
$list_rpt[] = $prefix . $rontgen;
|
||||
}
|
||||
/*if ($usg_abdomen != "") {
|
||||
$list_rpt[] = $prefix . $usg_abdomen;
|
||||
}*/
|
||||
if(count($usg) > 0){
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if(count($treadmill_attachment) > 0){
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "" && $tanpa_kesimpulan == 'N') {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
//echo json_encode($list_rpt);
|
||||
//print_r($list_rpt);
|
||||
//exit;
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
// if ($dob != "") {
|
||||
// $merge_input = array(
|
||||
// "output" => "test.pdf",
|
||||
// "input" => $list_rpt,
|
||||
// "dob" => $dob
|
||||
// );
|
||||
// }
|
||||
$jsonData = json_encode($merge_input);
|
||||
//print_r($jsonData); exit;
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $lab_number . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function get_list_patient_rpt_email($orderHeaderID, $dob = "", $tanpa_kesimpulan = "N")
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
IFNULL(mp.M_PatientNIP, '') AS M_PatientNIP,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID
|
||||
AND mp.M_PatientIsActive = 'Y'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$nip = "";
|
||||
$lab = "";
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$nip = $value["M_PatientNIP"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_portal.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = "";
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
$kebugaran = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
//print_r($rows_rpt);
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if ($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_v2_portal.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_xray_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Treadmill'){
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if(count($rows_attachment) > 0){
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/'.$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
|
||||
if ($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0) {
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
if($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
|
||||
$additional = "";
|
||||
if ($fisik == "") {
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
if (count($rows_addtional) > 0) {
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
$file_cover = "rpt_mcu_resume_cover_portal";
|
||||
|
||||
$sql = "SELECT M_CoverRpt as file_cover, M_CoverRptLogo as file_logo
|
||||
FROM t_orderheader
|
||||
JOIN mgm_cover ON T_OrderHeaderMgm_McuID = Mgm_CoverMgm_McuID AND Mgm_CoverIsActive = 'Y'
|
||||
JOIN m_cover ON Mgm_CoverM_CoverCode = M_CoverCode AND M_CoverIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$qry_cover = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_cover) {
|
||||
$row_cover = $qry_cover->result_array();
|
||||
if(count($row_cover) > 0){
|
||||
$file_cover = $row_cover[0]['file_logo'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_v2_portal.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/".$file_cover.".rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://devcpone.aplikasi.web.id";
|
||||
$prefix = "https://" . $_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if (count($attachments) > 0) {
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-files/" . $value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if ($rontgen != "") {
|
||||
$list_rpt[] = $prefix . $rontgen;
|
||||
}
|
||||
/*if ($usg_abdomen != "") {
|
||||
$list_rpt[] = $prefix . $usg_abdomen;
|
||||
}*/
|
||||
if(count($usg) > 0){
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if(count($treadmill_attachment) > 0){
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "" && $tanpa_kesimpulan == 'N') {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
|
||||
//print_r($list_rpt);
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
if ($dob != "") {
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt,
|
||||
"dob" => $dob
|
||||
);
|
||||
}
|
||||
$jsonData = json_encode($merge_input);
|
||||
// print_r($jsonData);
|
||||
// exit;
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $nip . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt(
|
||||
$ch,
|
||||
CURLOPT_HTTPHEADER,
|
||||
array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data)
|
||||
)
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,863 @@
|
||||
<?php
|
||||
class Listrptpatienttahunanportalbg extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Listing Report Patient API";
|
||||
}
|
||||
|
||||
function get_list_patient_rpt($orderHeaderID, $background, $timestamp = '', $tanpa_kesimpulan = 'N')
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
if($background === "bgdflt"){
|
||||
$background = "";
|
||||
}
|
||||
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$lab = "";
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
from t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID AND mp.M_PatientIsActive = 'Y'
|
||||
JOIN t_orderdetail ON toh.T_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND Group_ResultName = 'LAB'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'
|
||||
LIMIT 1";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
if ($row && count($row) > 0) {
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test" . $background . "_portal.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = "";
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
//print_r($rows_rpt);
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if ($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_v2" . $background . "_portal.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_xray" . $background . "_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri" . $background . "_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri" . $background . "_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg" . $background . "_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Treadmill') {
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill" . $background . "_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y' AND `T_NonlabDocumentType` = 'pdf'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if (count($rows_attachment) > 0) {
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/' . $value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear" . $background . "_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro" . $background . "_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg" . $background . "_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0) {
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds" . $background . "_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan" . $background . "_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
$file_cover = "rpt_mcu_resume_cover" . $background . "_portal";
|
||||
|
||||
$sql = "SELECT M_CoverRpt as file_cover, M_CoverRptLogo as file_logo
|
||||
FROM t_orderheader
|
||||
JOIN mgm_cover ON T_OrderHeaderMgm_McuID = Mgm_CoverMgm_McuID AND Mgm_CoverIsActive = 'Y'
|
||||
JOIN m_cover ON Mgm_CoverM_CoverCode = M_CoverCode AND M_CoverIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$qry_cover = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_cover) {
|
||||
$row_cover = $qry_cover->result_array();
|
||||
if (count($row_cover) > 0) {
|
||||
$file_cover = $row_cover[0]['file_logo'];
|
||||
|
||||
if (strpos($file_cover, '_portal') !== false) {
|
||||
$file_cover = str_replace('_portal', $background . '_portal', $file_cover);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_v2" . $background . "_portal.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/" . $file_cover . ".rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$additional = "";
|
||||
if ($fisik == "") {
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
//print_r($rows_addtional);
|
||||
if (count($rows_addtional) > 0) {
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata" . $background . "_portal.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://devcpone.aplikasi.web.id";
|
||||
$prefix = "https://" . $_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if (count($attachments) > 0) {
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-files/" . $value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if ($rontgen != "") {
|
||||
$list_rpt[] = $prefix . $rontgen;
|
||||
}
|
||||
/*if ($usg_abdomen != "") {
|
||||
$list_rpt[] = $prefix . $usg_abdomen;
|
||||
}*/
|
||||
if (count($usg) > 0) {
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if (count($treadmill_attachment) > 0) {
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "" && $tanpa_kesimpulan == 'N') {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
//echo json_encode($list_rpt);
|
||||
//print_r($list_rpt);
|
||||
//exit;
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
// if ($dob != "") {
|
||||
// $merge_input = array(
|
||||
// "output" => "test.pdf",
|
||||
// "input" => $list_rpt,
|
||||
// "dob" => $dob
|
||||
// );
|
||||
// }
|
||||
$jsonData = json_encode($merge_input);
|
||||
// print_r($jsonData);
|
||||
// exit;
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $lab_number . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function get_list_patient_rpt_email($orderHeaderID, $dob = "", $tanpa_kesimpulan = "N")
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
IFNULL(mp.M_PatientNIP, '') AS M_PatientNIP,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID
|
||||
AND mp.M_PatientIsActive = 'Y'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$nip = "";
|
||||
$lab = "";
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$nip = $value["M_PatientNIP"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_portal.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = "";
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
$kebugaran = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
//print_r($rows_rpt);
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if ($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_v2_portal.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_xray_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Treadmill') {
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if (count($rows_attachment) > 0) {
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/' . $value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
|
||||
if ($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0) {
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
|
||||
$additional = "";
|
||||
if ($fisik == "") {
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
if (count($rows_addtional) > 0) {
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
$file_cover = "rpt_mcu_resume_cover_portal";
|
||||
|
||||
$sql = "SELECT M_CoverRpt as file_cover, M_CoverRptLogo as file_logo
|
||||
FROM t_orderheader
|
||||
JOIN mgm_cover ON T_OrderHeaderMgm_McuID = Mgm_CoverMgm_McuID AND Mgm_CoverIsActive = 'Y'
|
||||
JOIN m_cover ON Mgm_CoverM_CoverCode = M_CoverCode AND M_CoverIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$qry_cover = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_cover) {
|
||||
$row_cover = $qry_cover->result_array();
|
||||
if (count($row_cover) > 0) {
|
||||
$file_cover = $row_cover[0]['file_logo'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_v2_portal.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/" . $file_cover . ".rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://devcpone.aplikasi.web.id";
|
||||
$prefix = "https://" . $_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if (count($attachments) > 0) {
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-files/" . $value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if ($rontgen != "") {
|
||||
$list_rpt[] = $prefix . $rontgen;
|
||||
}
|
||||
/*if ($usg_abdomen != "") {
|
||||
$list_rpt[] = $prefix . $usg_abdomen;
|
||||
}*/
|
||||
if (count($usg) > 0) {
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if (count($treadmill_attachment) > 0) {
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "" && $tanpa_kesimpulan == 'N') {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
|
||||
//print_r($list_rpt);
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
if ($dob != "") {
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt,
|
||||
"dob" => $dob
|
||||
);
|
||||
}
|
||||
$jsonData = json_encode($merge_input);
|
||||
// print_r($jsonData);
|
||||
// exit;
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $nip . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt(
|
||||
$ch,
|
||||
CURLOPT_HTTPHEADER,
|
||||
array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data)
|
||||
)
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,851 @@
|
||||
<?php
|
||||
class Listrptpatienttahunanportaleng extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Listing Report Patient API";
|
||||
}
|
||||
|
||||
function get_list_patient_rpt($orderHeaderID, $timestamp = '', $tanpa_kesimpulan = 'N')
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$lab = "";
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
from t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID AND mp.M_PatientIsActive = 'Y'
|
||||
JOIN t_orderdetail ON toh.T_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND Group_ResultName = 'LAB'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'
|
||||
LIMIT 1";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
if ($row && count($row) > 0) {
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_portal_eng.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = "";
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
//print_r($rows_rpt);
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if ($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_portal_eng.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_xray_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Treadmill'){
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y' AND `T_NonlabDocumentType` = 'pdf'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if(count($rows_attachment) > 0){
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/'.$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear_portal_eng.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro_portal_eng.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0) {
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
//if($value['rpt_name'] == 'Test Kebugaran')
|
||||
//$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
$file_cover = "rpt_mcu_resume_cover_portal_eng";
|
||||
|
||||
$sql = "SELECT M_CoverRpt as file_cover, M_CoverRptLogo as file_logo, M_CoverRptEngLogo as file_logo_eng
|
||||
FROM t_orderheader
|
||||
JOIN mgm_cover ON T_OrderHeaderMgm_McuID = Mgm_CoverMgm_McuID AND Mgm_CoverIsActive = 'Y'
|
||||
JOIN m_cover ON Mgm_CoverM_CoverCode = M_CoverCode AND M_CoverIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$qry_cover = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_cover) {
|
||||
$row_cover = $qry_cover->result_array();
|
||||
if(count($row_cover) > 0){
|
||||
$file_cover = $row_cover[0]['file_logo_eng'];
|
||||
}
|
||||
}
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_v2_portal_eng.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/".$file_cover.".rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$additional = "";
|
||||
if ($fisik == "") {
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
//print_r($rows_addtional);
|
||||
if (count($rows_addtional) > 0) {
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata_portal_eng.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://devcpone.aplikasi.web.id";
|
||||
$prefix = "https://" . $_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if (count($attachments) > 0) {
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-files/" . $value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if ($rontgen != "") {
|
||||
$list_rpt[] = $prefix . $rontgen;
|
||||
}
|
||||
/*if ($usg_abdomen != "") {
|
||||
$list_rpt[] = $prefix . $usg_abdomen;
|
||||
}*/
|
||||
if(count($usg) > 0){
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if(count($treadmill_attachment) > 0){
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kesimpulan_saran != "" && $tanpa_kesimpulan == 'N') {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
// echo json_encode($list_rpt);
|
||||
//print_r($list_rpt);
|
||||
// exit;
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
// if ($dob != "") {
|
||||
// $merge_input = array(
|
||||
// "output" => "test.pdf",
|
||||
// "input" => $list_rpt,
|
||||
// "dob" => $dob
|
||||
// );
|
||||
// }
|
||||
$jsonData = json_encode($merge_input);
|
||||
//print_r($jsonData); exit;
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $lab_number . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function get_list_patient_rpt_email($orderHeaderID, $dob = "", $tanpa_kesimpulan = "N")
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
IFNULL(mp.M_PatientNIP, '') AS M_PatientNIP,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID
|
||||
AND mp.M_PatientIsActive = 'Y'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$nip = "";
|
||||
$lab = "";
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$nip = $value["M_PatientNIP"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_portal_eng.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = "";
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
$kebugaran = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
//print_r($rows_rpt);
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if ($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_portal_eng.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_xray_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Treadmill'){
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y' AND `T_NonlabDocumentType` = 'pdf'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if(count($rows_attachment) > 0){
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/'.$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear_portal_eng.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
|
||||
if ($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro_portal_eng.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0) {
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
//if($value['rpt_name'] == 'Test Kebugaran')
|
||||
//$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
|
||||
$additional = "";
|
||||
if ($fisik == "") {
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
if (count($rows_addtional) > 0) {
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata_portal_eng.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
$file_cover = "rpt_mcu_resume_cover_portal_eng";
|
||||
|
||||
$sql = "SELECT M_CoverRpt as file_cover, M_CoverRptLogo as file_logo, M_CoverRptEngLogo as file_logo_eng
|
||||
FROM t_orderheader
|
||||
JOIN mgm_cover ON T_OrderHeaderMgm_McuID = Mgm_CoverMgm_McuID AND Mgm_CoverIsActive = 'Y'
|
||||
JOIN m_cover ON Mgm_CoverM_CoverCode = M_CoverCode AND M_CoverIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$qry_cover = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_cover) {
|
||||
$row_cover = $qry_cover->result_array();
|
||||
if(count($row_cover) > 0){
|
||||
$file_cover = $row_cover[0]['file_logo_eng'];
|
||||
}
|
||||
}
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_v2_portal.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/".$file_cover.".rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://devcpone.aplikasi.web.id";
|
||||
$prefix = "https://" . $_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if (count($attachments) > 0) {
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-files/" . $value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if ($rontgen != "") {
|
||||
$list_rpt[] = $prefix . $rontgen;
|
||||
}
|
||||
/*if ($usg_abdomen != "") {
|
||||
$list_rpt[] = $prefix . $usg_abdomen;
|
||||
}*/
|
||||
if(count($usg) > 0){
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if(count($treadmill_attachment) > 0){
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "" && $tanpa_kesimpulan == 'N') {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
//echo json_encode($list_rpt);
|
||||
//print_r($list_rpt);
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
if ($dob != "") {
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt,
|
||||
"dob" => $dob
|
||||
);
|
||||
}
|
||||
$jsonData = json_encode($merge_input);
|
||||
// print_r($jsonData);
|
||||
// exit;
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $nip . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt(
|
||||
$ch,
|
||||
CURLOPT_HTTPHEADER,
|
||||
array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data)
|
||||
)
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,857 @@
|
||||
<?php
|
||||
class Listrptpatienttahunanportalengbg extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Listing Report Patient API";
|
||||
}
|
||||
|
||||
function get_list_patient_rpt($orderHeaderID, $background, $timestamp = '', $tanpa_kesimpulan = 'N')
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
if($background === "bgdflt"){
|
||||
$background = "";
|
||||
}
|
||||
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$lab = "";
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
from t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID AND mp.M_PatientIsActive = 'Y'
|
||||
JOIN t_orderdetail ON toh.T_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND Group_ResultName = 'LAB'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'
|
||||
LIMIT 1";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
if ($row && count($row) > 0) {
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test".$background."_portal_eng.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = "";
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
//print_r($rows_rpt);
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if ($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history".$background."_portal_eng.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_xray".$background."_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri".$background."_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri".$background."_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg".$background."_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Treadmill'){
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill".$background."_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y' AND `T_NonlabDocumentType` = 'pdf'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if(count($rows_attachment) > 0){
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/'.$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear".$background."_portal_eng.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro".$background."_portal_eng.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg".$background."_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0) {
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds".$background."_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
//if($value['rpt_name'] == 'Test Kebugaran')
|
||||
//$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan".$background."_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
$file_cover = "rpt_mcu_resume_cover".$background."_portal_eng";
|
||||
|
||||
$sql = "SELECT M_CoverRpt as file_cover, M_CoverRptLogo as file_logo, M_CoverRptEngLogo as file_logo_eng
|
||||
FROM t_orderheader
|
||||
JOIN mgm_cover ON T_OrderHeaderMgm_McuID = Mgm_CoverMgm_McuID AND Mgm_CoverIsActive = 'Y'
|
||||
JOIN m_cover ON Mgm_CoverM_CoverCode = M_CoverCode AND M_CoverIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$qry_cover = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_cover) {
|
||||
$row_cover = $qry_cover->result_array();
|
||||
if(count($row_cover) > 0){
|
||||
$file_cover = $row_cover[0]['file_logo_eng'];
|
||||
if (strpos($file_cover, '_portal') !== false) {
|
||||
$file_cover = str_replace('_portal', $background . '_portal', $file_cover);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_v2".$background."_portal_eng.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/".$file_cover.".rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$additional = "";
|
||||
if ($fisik == "") {
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
//print_r($rows_addtional);
|
||||
if (count($rows_addtional) > 0) {
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata".$background."_portal_eng.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://devcpone.aplikasi.web.id";
|
||||
$prefix = "https://" . $_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if (count($attachments) > 0) {
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-files/" . $value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if ($rontgen != "") {
|
||||
$list_rpt[] = $prefix . $rontgen;
|
||||
}
|
||||
/*if ($usg_abdomen != "") {
|
||||
$list_rpt[] = $prefix . $usg_abdomen;
|
||||
}*/
|
||||
if(count($usg) > 0){
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if(count($treadmill_attachment) > 0){
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kesimpulan_saran != "" && $tanpa_kesimpulan == 'N') {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
// echo json_encode($list_rpt);
|
||||
//print_r($list_rpt);
|
||||
// exit;
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
// if ($dob != "") {
|
||||
// $merge_input = array(
|
||||
// "output" => "test.pdf",
|
||||
// "input" => $list_rpt,
|
||||
// "dob" => $dob
|
||||
// );
|
||||
// }
|
||||
$jsonData = json_encode($merge_input);
|
||||
// print_r($jsonData); exit;
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $lab_number . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function get_list_patient_rpt_email($orderHeaderID, $dob = "", $tanpa_kesimpulan = "N")
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
IFNULL(mp.M_PatientNIP, '') AS M_PatientNIP,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID
|
||||
AND mp.M_PatientIsActive = 'Y'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$nip = "";
|
||||
$lab = "";
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$nip = $value["M_PatientNIP"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_portal_eng.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = "";
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
$kebugaran = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
//print_r($rows_rpt);
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if ($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_portal_eng.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_xray_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Treadmill'){
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y' AND `T_NonlabDocumentType` = 'pdf'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if(count($rows_attachment) > 0){
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/'.$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear_portal_eng.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
|
||||
if ($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro_portal_eng.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0) {
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
//if($value['rpt_name'] == 'Test Kebugaran')
|
||||
//$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
|
||||
$additional = "";
|
||||
if ($fisik == "") {
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
if (count($rows_addtional) > 0) {
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata_portal_eng.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
$file_cover = "rpt_mcu_resume_cover_portal_eng";
|
||||
|
||||
$sql = "SELECT M_CoverRpt as file_cover, M_CoverRptLogo as file_logo, M_CoverRptEngLogo as file_logo_eng
|
||||
FROM t_orderheader
|
||||
JOIN mgm_cover ON T_OrderHeaderMgm_McuID = Mgm_CoverMgm_McuID AND Mgm_CoverIsActive = 'Y'
|
||||
JOIN m_cover ON Mgm_CoverM_CoverCode = M_CoverCode AND M_CoverIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$qry_cover = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_cover) {
|
||||
$row_cover = $qry_cover->result_array();
|
||||
if(count($row_cover) > 0){
|
||||
$file_cover = $row_cover[0]['file_logo_eng'];
|
||||
}
|
||||
}
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_v2_portal.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/".$file_cover.".rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://devcpone.aplikasi.web.id";
|
||||
$prefix = "https://" . $_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if (count($attachments) > 0) {
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-files/" . $value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if ($rontgen != "") {
|
||||
$list_rpt[] = $prefix . $rontgen;
|
||||
}
|
||||
/*if ($usg_abdomen != "") {
|
||||
$list_rpt[] = $prefix . $usg_abdomen;
|
||||
}*/
|
||||
if(count($usg) > 0){
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if(count($treadmill_attachment) > 0){
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "" && $tanpa_kesimpulan == 'N') {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
//echo json_encode($list_rpt);
|
||||
//print_r($list_rpt);
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
if ($dob != "") {
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt,
|
||||
"dob" => $dob
|
||||
);
|
||||
}
|
||||
$jsonData = json_encode($merge_input);
|
||||
// print_r($jsonData);
|
||||
// exit;
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $nip . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt(
|
||||
$ch,
|
||||
CURLOPT_HTTPHEADER,
|
||||
array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data)
|
||||
)
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,813 @@
|
||||
<?php
|
||||
class Listrptpatienttahunanportalprimaya extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Listing Report Patient API";
|
||||
}
|
||||
|
||||
function get_list_patient_rpt($orderHeaderID, $timestamp = '', $tanpa_kesimpulan = 'N')
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$lab = "";
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
from t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID AND mp.M_PatientIsActive = 'Y'
|
||||
JOIN t_orderdetail ON toh.T_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND Group_ResultName = 'LAB'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'
|
||||
LIMIT 1";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
if ($row && count($row) > 0) {
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_portal_primaya.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = "";
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
//print_r($rows_rpt);
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if ($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_v2_portal_primaya.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_xray_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Treadmill'){
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y' AND `T_NonlabDocumentType` = 'pdf'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if(count($rows_attachment) > 0){
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/'.$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear_portal_primaya.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro_portal_primaya.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0) {
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
if($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_v2_portal_primaya.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/rpt_mcu_resume_cover_portal_primaya.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$additional = "";
|
||||
if ($fisik == "") {
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
//print_r($rows_addtional);
|
||||
if (count($rows_addtional) > 0) {
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata_portal_primaya.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://devcpone.aplikasi.web.id";
|
||||
$prefix = "https://" . $_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if (count($attachments) > 0) {
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-files/" . $value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if ($rontgen != "") {
|
||||
$list_rpt[] = $prefix . $rontgen;
|
||||
}
|
||||
if(count($usg) > 0){
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if(count($treadmill_attachment) > 0){
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kesimpulan_saran != "" && $tanpa_kesimpulan == 'N') {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
//echo json_encode($list_rpt);
|
||||
//print_r($list_rpt);
|
||||
//exit;
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
// if ($dob != "") {
|
||||
// $merge_input = array(
|
||||
// "output" => "test.pdf",
|
||||
// "input" => $list_rpt,
|
||||
// "dob" => $dob
|
||||
// );
|
||||
// }
|
||||
$jsonData = json_encode($merge_input);
|
||||
//print_r($jsonData); exit;
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $lab_number . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function get_list_patient_rpt_email($orderHeaderID, $dob = "", $tanpa_kesimpulan = "N")
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
IFNULL(mp.M_PatientNIP, '') AS M_PatientNIP,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID
|
||||
AND mp.M_PatientIsActive = 'Y'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$nip = "";
|
||||
$lab = "";
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$nip = $value["M_PatientNIP"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_portal_primaya.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = "";
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
$kebugaran = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
//print_r($rows_rpt);
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if ($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_v2_portal_primaya.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_xray_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Treadmill'){
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y' AND `T_NonlabDocumentType` = 'pdf'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if(count($rows_attachment) > 0){
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/'.$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear_portal_primaya.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
|
||||
if ($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro_portal_primaya.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0) {
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
if($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
|
||||
$additional = "";
|
||||
if ($fisik == "") {
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
if (count($rows_addtional) > 0) {
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata_portal_primaya.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_v2_portal_primaya.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/rpt_mcu_resume_cover_portal_primaya.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://devcpone.aplikasi.web.id";
|
||||
$prefix = "https://" . $_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if (count($attachments) > 0) {
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-files/" . $value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if ($rontgen != "") {
|
||||
$list_rpt[] = $prefix . $rontgen;
|
||||
}
|
||||
if(count($usg) > 0){
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if(count($treadmill_attachment) > 0){
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "" && $tanpa_kesimpulan == 'N') {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
//echo json_encode($list_rpt);
|
||||
//print_r($list_rpt);
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
if ($dob != "") {
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt,
|
||||
"dob" => $dob
|
||||
);
|
||||
}
|
||||
$jsonData = json_encode($merge_input);
|
||||
// print_r($jsonData);
|
||||
// exit;
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $nip . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt(
|
||||
$ch,
|
||||
CURLOPT_HTTPHEADER,
|
||||
array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data)
|
||||
)
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,816 @@
|
||||
<?php
|
||||
class Listrptpatienttahunanportalprimayabg extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Listing Report Patient API";
|
||||
}
|
||||
|
||||
function get_list_patient_rpt($orderHeaderID, $background, $timestamp = '', $tanpa_kesimpulan = 'N')
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
if($background === "bgdflt"){
|
||||
$background = "";
|
||||
}
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$lab = "";
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
from t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID AND mp.M_PatientIsActive = 'Y'
|
||||
JOIN t_orderdetail ON toh.T_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND Group_ResultName = 'LAB'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'
|
||||
LIMIT 1";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
if ($row && count($row) > 0) {
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test".$background."_portal_primaya.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = "";
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
//print_r($rows_rpt);
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if ($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_v2".$background."_portal_primaya.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_xray".$background."_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri".$background."_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri".$background."_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg".$background."_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Treadmill'){
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill".$background."_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y' AND `T_NonlabDocumentType` = 'pdf'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if(count($rows_attachment) > 0){
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/'.$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear".$background."_portal_primaya.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro".$background."_portal_primaya.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg".$background."_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0) {
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds".$background."_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
if($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan".$background."_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_v2".$background."_portal_primaya.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/rpt_mcu_resume_cover".$background."_portal_primaya.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$additional = "";
|
||||
if ($fisik == "") {
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
//print_r($rows_addtional);
|
||||
if (count($rows_addtional) > 0) {
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata".$background."_portal_primaya.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://devcpone.aplikasi.web.id";
|
||||
$prefix = "https://" . $_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if (count($attachments) > 0) {
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-files/" . $value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if ($rontgen != "") {
|
||||
$list_rpt[] = $prefix . $rontgen;
|
||||
}
|
||||
if(count($usg) > 0){
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if(count($treadmill_attachment) > 0){
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kesimpulan_saran != "" && $tanpa_kesimpulan == 'N') {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
//echo json_encode($list_rpt);
|
||||
//print_r($list_rpt);
|
||||
//exit;
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
// if ($dob != "") {
|
||||
// $merge_input = array(
|
||||
// "output" => "test.pdf",
|
||||
// "input" => $list_rpt,
|
||||
// "dob" => $dob
|
||||
// );
|
||||
// }
|
||||
$jsonData = json_encode($merge_input);
|
||||
// print_r($jsonData); exit;
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $lab_number . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function get_list_patient_rpt_email($orderHeaderID, $dob = "", $tanpa_kesimpulan = "N")
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
IFNULL(mp.M_PatientNIP, '') AS M_PatientNIP,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID
|
||||
AND mp.M_PatientIsActive = 'Y'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$nip = "";
|
||||
$lab = "";
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$nip = $value["M_PatientNIP"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_portal_primaya.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = "";
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
$kebugaran = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
//print_r($rows_rpt);
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if ($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_v2_portal_primaya.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_xray_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Treadmill'){
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y' AND `T_NonlabDocumentType` = 'pdf'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if(count($rows_attachment) > 0){
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/'.$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear_portal_primaya.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
|
||||
if ($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro_portal_primaya.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0) {
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
if($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
|
||||
$additional = "";
|
||||
if ($fisik == "") {
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
if (count($rows_addtional) > 0) {
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata_portal_primaya.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_v2_portal_primaya.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/rpt_mcu_resume_cover_portal_primaya.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://devcpone.aplikasi.web.id";
|
||||
$prefix = "https://" . $_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if (count($attachments) > 0) {
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-files/" . $value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if ($rontgen != "") {
|
||||
$list_rpt[] = $prefix . $rontgen;
|
||||
}
|
||||
if(count($usg) > 0){
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if(count($treadmill_attachment) > 0){
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "" && $tanpa_kesimpulan == 'N') {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
//echo json_encode($list_rpt);
|
||||
//print_r($list_rpt);
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
if ($dob != "") {
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt,
|
||||
"dob" => $dob
|
||||
);
|
||||
}
|
||||
$jsonData = json_encode($merge_input);
|
||||
// print_r($jsonData);
|
||||
// exit;
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $nip . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt(
|
||||
$ch,
|
||||
CURLOPT_HTTPHEADER,
|
||||
array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data)
|
||||
)
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,388 @@
|
||||
<?php
|
||||
class Listrptpatienttahunanprimaya extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Listing Report Patient API";
|
||||
}
|
||||
|
||||
function get_list_patient_rpt($orderHeaderID,$timestamp='',$tanpa_kesimpulan='N')
|
||||
{
|
||||
try {
|
||||
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$lab = "";
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
from t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID AND mp.M_PatientIsActive = 'Y'
|
||||
JOIN t_orderdetail ON toh.T_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND Group_ResultName = 'LAB'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'
|
||||
LIMIT 1";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
if($row && count($row) > 0){
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_primaya.rptdesign&__format=pdf&PID={$value["M_PatientID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$lab = "";
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_primaya.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = "";
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
$kebugaran = '';
|
||||
|
||||
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_v2_primaya.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_xray_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Treadmill'){
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y' AND `T_NonlabDocumentType` = 'pdf'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if(count($rows_attachment) > 0){
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/'.$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear_primaya.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro_primaya.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0){
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
if($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_v2_primaya.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/rpt_mcu_resume_cover_primaya.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$additional = "";
|
||||
if($fisik == ""){
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
//print_r($rows_addtional);
|
||||
if(count($rows_addtional) > 0){
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata_portal_primaya.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$prefix = "http://localhost";
|
||||
$prefix = "https://".$_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if(count($attachments) > 0){
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix."/one-media/one-files/".$value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if ($rontgen != "") {
|
||||
$list_rpt[] = $prefix . $rontgen;
|
||||
}
|
||||
if(count($usg) > 0){
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if(count($treadmill_attachment) > 0){
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "" && $tanpa_kesimpulan == "N") {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
//echo json_encode($list_rpt);
|
||||
//print_r($list_rpt);
|
||||
//exit;
|
||||
|
||||
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
$jsonData = json_encode($merge_input);
|
||||
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://".$_SERVER['SERVER_NAME']."/one-api/tools/merge_pdf/merge";
|
||||
//echo $target_pdf ;
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $lab_number . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt(
|
||||
$ch,
|
||||
CURLOPT_HTTPHEADER,
|
||||
array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data)
|
||||
)
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
615
application/controllers/tools/Audiometry_chart.php
Normal file
615
application/controllers/tools/Audiometry_chart.php
Normal file
@@ -0,0 +1,615 @@
|
||||
<?php
|
||||
|
||||
class Audiometry_chart extends MY_Controller
|
||||
{
|
||||
var $url_renderer;
|
||||
var $url_audio_new;
|
||||
var $db_onedev;
|
||||
var $load;
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->url_renderer = "http://localhost:3030/chart";
|
||||
$this->url_audio_new = "http://localhost/xcharts/audio_metry.php";
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function v01($id)
|
||||
{
|
||||
|
||||
$icon_shape_url = array(
|
||||
'image://https://cpone.aplikasi.web.id/icon/red_circle.png',
|
||||
'image://https://cpone.aplikasi.web.id/icon/red_star.png',
|
||||
'image://https://cpone.aplikasi.web.id/icon/four_star_blue.png',
|
||||
'image://https://cpone.aplikasi.web.id/icon/blue_plus.png',
|
||||
);
|
||||
|
||||
$sql = "SELECT
|
||||
So_ResultEntryDetailID as trx_id,
|
||||
NonlabTemplateDetailCode as code,
|
||||
So_ResultEntryDetailNonlab_TemplateDetailID as template_detail_id,
|
||||
So_ResultEntryDetailNonlab_TemplateDetailName as result_label,
|
||||
IFNULL(So_ResultEntryDetailResult, 0) as result_value,
|
||||
So_ResultEntryDetailFlagPrint as flag_print,
|
||||
So_ResultEntryDetailResult as result_value_before,
|
||||
NonlabTemplateDetailIsResult as isResult,
|
||||
CASE
|
||||
WHEN NonlabTemplateDetailCode LIKE '%AR%' AND NonlabTemplateDetailIsResult='Y' THEN 'AR'
|
||||
WHEN NonlabTemplateDetailCode LIKE '%AL%' AND NonlabTemplateDetailIsResult='Y' THEN 'AL'
|
||||
WHEN NonlabTemplateDetailCode LIKE '%BR%' AND NonlabTemplateDetailIsResult='Y' THEN 'BR'
|
||||
WHEN NonlabTemplateDetailCode LIKE '%BL%' AND NonlabTemplateDetailIsResult='Y' THEN 'BL'
|
||||
ELSE 'N'
|
||||
END as type,
|
||||
GROUP_CONCAT(CASE
|
||||
WHEN So_ResultEntryDetailResult IS NULL THEN 0
|
||||
WHEN TRIM(So_ResultEntryDetailResult) = '' THEN 0
|
||||
WHEN So_ResultEntryDetailResult REGEXP '^[0-9]+$' THEN So_ResultEntryDetailResult
|
||||
ELSE 0
|
||||
END ORDER BY So_ResultEntryDetailNonlab_TemplateDetailID) as value
|
||||
FROM so_resultentrydetail
|
||||
JOIN nonlab_template_detail ON So_ResultEntryDetailNonlab_TemplateDetailID = NonlabTemplateDetailID
|
||||
AND NonlabTemplateDetaiM_LangID = 1
|
||||
WHERE
|
||||
So_ResultEntryDetailSo_ResultEntryID = '{$id}' AND So_ResultEntryDetailisActive = 'Y'
|
||||
GROUP BY type
|
||||
ORDER BY So_ResultEntryDetailNonlab_TemplateDetailID
|
||||
";
|
||||
//echo $sql;
|
||||
$qry = $this->db_onedev->query($sql);
|
||||
if (!$qry) {
|
||||
$message = $this->db_onedev->error();
|
||||
$message['qry'] = $this->db_onedev->last_query();
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
$acR = array();
|
||||
$acL = array();
|
||||
$bcR = array();
|
||||
$bcL = array();
|
||||
$dtls = $qry->result_array();
|
||||
foreach ($dtls as $key => $v) {
|
||||
if ($v['type'] == 'AR') {
|
||||
$acR = explode(',', $v['value']);
|
||||
$cek = array();
|
||||
for ($i = 0; $i < count($acR); $i++) {
|
||||
if (intval($acR[$i]) == 0) {
|
||||
array_push($cek, 1);
|
||||
}
|
||||
}
|
||||
if (count($cek) == count($acR)) {
|
||||
$acR = [];
|
||||
}
|
||||
}
|
||||
if ($v['type'] == 'AL') {
|
||||
$acL = explode(',', $v['value']);
|
||||
$cek = array();
|
||||
for ($i = 0; $i < count($acL); $i++) {
|
||||
if (intval($acL[$i]) == 0) {
|
||||
array_push($cek, 1);
|
||||
}
|
||||
}
|
||||
if (count($cek) == count($acL)) {
|
||||
$acL = [];
|
||||
}
|
||||
}
|
||||
if ($v['type'] == 'BR') {
|
||||
$bcR = explode(',', $v['value']);
|
||||
$cek = array();
|
||||
for ($i = 0; $i < count($bcR); $i++) {
|
||||
if (intval($bcR[$i]) == 0) {
|
||||
array_push($cek, 1);
|
||||
}
|
||||
}
|
||||
if (count($cek) == count($bcR)) {
|
||||
$bcR = [];
|
||||
}
|
||||
}
|
||||
if ($v['type'] == 'BL') {
|
||||
$bcL = explode(',', $v['value']);
|
||||
$cek = array();
|
||||
for ($i = 0; $i < count($bcL); $i++) {
|
||||
if (intval($bcL[$i]) == 0) {
|
||||
array_push($cek, 1);
|
||||
}
|
||||
}
|
||||
if (count($cek) == count($bcL)) {
|
||||
$bcL = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
$param = array(
|
||||
|
||||
'tooltip' => array(
|
||||
"show" => true,
|
||||
'trigger' => 'item'
|
||||
),
|
||||
'color' => [
|
||||
"#ff0000",
|
||||
"#00ff00",
|
||||
"#0000ff",
|
||||
"#00ffff",
|
||||
],
|
||||
'xAxis' => [
|
||||
"name" => "Frequency in hertz (Hz)",
|
||||
"nameLocation" => "center",
|
||||
"nameGap" => 30,
|
||||
"showGrid" => true,
|
||||
"type" => "category",
|
||||
"data" => [250, 500, 1000, 2000, 3000, 4000, 6000, 8000],
|
||||
"forceLabelIsEnabled" => true,
|
||||
"labelCount" => 8,
|
||||
"splitLine" => [
|
||||
"show" => true,
|
||||
"lineStyle" => [
|
||||
"color" => "#bbbbbb"
|
||||
]
|
||||
]
|
||||
],
|
||||
'yAxis' => [
|
||||
"name" => "Hearing treshold level (dB)",
|
||||
"nameLocation" => "middle",
|
||||
"nameGap" => 30,
|
||||
"type" => "value",
|
||||
"inverse" => true,
|
||||
"min" => 0,
|
||||
"max" => 120,
|
||||
"interval" => 10,
|
||||
"splitLine" => [
|
||||
"interval" => 0,
|
||||
"lineStyle" => [
|
||||
"color" => "#bbbbbb"
|
||||
]
|
||||
]
|
||||
],
|
||||
'legend' => array(
|
||||
'top' => 'bottom',
|
||||
'left' => 'center',
|
||||
'orient' => 'horizontal'
|
||||
),
|
||||
'series' => array(
|
||||
array(
|
||||
"name" => "1 Right Ear",
|
||||
// "symbol" => "image://https://cpone.aplikasi.web.id/icon/red_circle.png",
|
||||
"symbol" => "circle",
|
||||
"showSymbol" => true,
|
||||
"symbolSize" => 10,
|
||||
"data" => [5, 25, 20, 25, 20, 15, 20, 25],
|
||||
// "data" => $acR,
|
||||
"type" => "line",
|
||||
"stackStrategy" => "all",
|
||||
"lineStyle" => array(
|
||||
"color" => 'red',
|
||||
"width" => 3,
|
||||
"type" => 'solid'
|
||||
),
|
||||
"itemStyle" => array(
|
||||
"color" => 'red',
|
||||
"borderWidth" => 3,
|
||||
"borderColor" => '#EE6666',
|
||||
)
|
||||
),
|
||||
[
|
||||
"name" => "2 BC Right",
|
||||
// "symbol" => "image://https://cpone.aplikasi.web.id/icon/red_circle.png",
|
||||
"symbol" => "triangle",
|
||||
// "showSymbol" => true,
|
||||
// "data" => [],
|
||||
"data" => $bcR,
|
||||
"type" => "line",
|
||||
"lineStyle" => array(
|
||||
"color" => 'red',
|
||||
"width" => 3,
|
||||
"type" => 'dashed'
|
||||
),
|
||||
"itemStyle" => array(
|
||||
"color" => 'red'
|
||||
)
|
||||
],
|
||||
[
|
||||
"name" => "3 Left Ear",
|
||||
// "symbol" => $icon_shape_url[2],
|
||||
"symbol" => "diamond",
|
||||
// "showSymbol" => true,
|
||||
// "data" => [30, 30, 25, 25, 30, 20, 30, 30],
|
||||
"data" => $acL,
|
||||
"type" => "line",
|
||||
"lineStyle" => array(
|
||||
"color" => 'blue',
|
||||
"width" => 3,
|
||||
"type" => 'solid'
|
||||
),
|
||||
"itemStyle" => array(
|
||||
"color" => 'blue'
|
||||
)
|
||||
],
|
||||
[
|
||||
"name" => "4 BC Left ",
|
||||
// "symbol" => $icon_shape_url[3],
|
||||
"symbol" => "rect",
|
||||
// "showSymbol" => true,
|
||||
"data" => $bcL,
|
||||
// "data" => [],
|
||||
"type" => "line",
|
||||
"lineStyle" => array(
|
||||
"color" => 'blue',
|
||||
"width" => 3,
|
||||
"type" => 'dashed'
|
||||
),
|
||||
"itemStyle" => array(
|
||||
"color" => 'blue',
|
||||
)
|
||||
]
|
||||
)
|
||||
);
|
||||
// 3. encapsulate in config attribute and json encode
|
||||
// print_r($param);
|
||||
$config = ["config" => $param];
|
||||
$j_param = json_encode($config);
|
||||
header("Content-Type: image/png");
|
||||
// 4. post to chart renderer
|
||||
echo $this->post($this->url_renderer, $j_param);
|
||||
}
|
||||
function v02($id)
|
||||
{
|
||||
|
||||
$icon_shape_url = array(
|
||||
'image://https://cpone.aplikasi.web.id/icon/red_circle.png',
|
||||
'image://https://cpone.aplikasi.web.id/icon/red_star.png',
|
||||
'image://https://cpone.aplikasi.web.id/icon/four_star_blue.png',
|
||||
'image://https://cpone.aplikasi.web.id/icon/blue_plus.png',
|
||||
);
|
||||
|
||||
$sql = "SELECT
|
||||
So_ResultEntryDetailID as trx_id,
|
||||
NonlabTemplateDetailCode as code,
|
||||
So_ResultEntryDetailNonlab_TemplateDetailID as template_detail_id,
|
||||
So_ResultEntryDetailNonlab_TemplateDetailName as result_label,
|
||||
IFNULL(So_ResultEntryDetailResult, 0) as result_value,
|
||||
So_ResultEntryDetailFlagPrint as flag_print,
|
||||
So_ResultEntryDetailResult as result_value_before,
|
||||
NonlabTemplateDetailIsResult as isResult,
|
||||
CASE
|
||||
WHEN NonlabTemplateDetailCode LIKE '%AR%' AND NonlabTemplateDetailIsResult='Y' THEN 'AR'
|
||||
WHEN NonlabTemplateDetailCode LIKE '%AL%' AND NonlabTemplateDetailIsResult='Y' THEN 'AL'
|
||||
WHEN NonlabTemplateDetailCode LIKE '%BR%' AND NonlabTemplateDetailIsResult='Y' THEN 'BR'
|
||||
WHEN NonlabTemplateDetailCode LIKE '%BL%' AND NonlabTemplateDetailIsResult='Y' THEN 'BL'
|
||||
ELSE 'N'
|
||||
END as type,
|
||||
GROUP_CONCAT(CASE
|
||||
WHEN So_ResultEntryDetailResult IS NULL THEN 0
|
||||
WHEN TRIM(So_ResultEntryDetailResult) = '' THEN 0
|
||||
WHEN So_ResultEntryDetailResult REGEXP '^[0-9]+$' THEN So_ResultEntryDetailResult
|
||||
ELSE 0
|
||||
END ORDER BY So_ResultEntryDetailNonlab_TemplateDetailID) as value
|
||||
FROM so_resultentrydetail
|
||||
JOIN nonlab_template_detail ON So_ResultEntryDetailNonlab_TemplateDetailID = NonlabTemplateDetailID
|
||||
AND NonlabTemplateDetaiM_LangID = 1
|
||||
WHERE
|
||||
So_ResultEntryDetailSo_ResultEntryID = '{$id}' AND So_ResultEntryDetailisActive = 'Y'
|
||||
GROUP BY type
|
||||
ORDER BY So_ResultEntryDetailNonlab_TemplateDetailID
|
||||
";
|
||||
//echo $sql;
|
||||
$qry = $this->db_onedev->query($sql);
|
||||
if (!$qry) {
|
||||
$message = $this->db_onedev->error();
|
||||
$message['qry'] = $this->db_onedev->last_query();
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
$acR = array();
|
||||
$acL = array();
|
||||
$bcR = array();
|
||||
$bcL = array();
|
||||
$dtls = $qry->result_array();
|
||||
foreach ($dtls as $key => $v) {
|
||||
if ($v['type'] == 'AR') {
|
||||
$acR = explode(',', $v['value']);
|
||||
$cek = array();
|
||||
for ($i = 0; $i < count($acR); $i++) {
|
||||
if (intval($acR[$i]) == 0) {
|
||||
array_push($cek, 1);
|
||||
}
|
||||
}
|
||||
if (count($cek) == count($acR)) {
|
||||
$acR = [];
|
||||
}
|
||||
}
|
||||
if ($v['type'] == 'AL') {
|
||||
$acL = explode(',', $v['value']);
|
||||
$cek = array();
|
||||
for ($i = 0; $i < count($acL); $i++) {
|
||||
if (intval($acL[$i]) == 0) {
|
||||
array_push($cek, 1);
|
||||
}
|
||||
}
|
||||
if (count($cek) == count($acL)) {
|
||||
$acL = [];
|
||||
}
|
||||
}
|
||||
if ($v['type'] == 'BR') {
|
||||
$bcR = explode(',', $v['value']);
|
||||
$cek = array();
|
||||
for ($i = 0; $i < count($bcR); $i++) {
|
||||
if (intval($bcR[$i]) == 0) {
|
||||
array_push($cek, 1);
|
||||
}
|
||||
}
|
||||
if (count($cek) == count($bcR)) {
|
||||
$bcR = [];
|
||||
}
|
||||
}
|
||||
if ($v['type'] == 'BL') {
|
||||
$bcL = explode(',', $v['value']);
|
||||
$cek = array();
|
||||
for ($i = 0; $i < count($bcL); $i++) {
|
||||
if (intval($bcL[$i]) == 0) {
|
||||
array_push($cek, 1);
|
||||
}
|
||||
}
|
||||
if (count($cek) == count($bcL)) {
|
||||
$bcL = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
$param = array(
|
||||
'tooltip' => array(
|
||||
'trigger' => 'item'
|
||||
),
|
||||
// 'color' => [
|
||||
// "#ff0000",
|
||||
// "#00ff00",
|
||||
// "#0000ff",
|
||||
// "#00ffff",
|
||||
// ],
|
||||
'xAxis' => [
|
||||
"name" => "Frequency in hertz (Hz)",
|
||||
"nameLocation" => "center",
|
||||
"nameGap" => 30,
|
||||
"type" => "category",
|
||||
"data" => [250, 500, 1000, 2000, 3000, 4000, 6000, 8000],
|
||||
"splitLine" => [
|
||||
"show" => true,
|
||||
"lineStyle" => [
|
||||
"color" => "#bbbbbb"
|
||||
]
|
||||
]
|
||||
],
|
||||
'yAxis' => [
|
||||
"name" => "Hearing threshold level (dB)",
|
||||
"nameLocation" => "middle",
|
||||
"nameGap" => 30,
|
||||
"type" => "value",
|
||||
"inverse" => true,
|
||||
"min" => 0,
|
||||
"max" => 120,
|
||||
"interval" => 10,
|
||||
"splitLine" => [
|
||||
"show" => true,
|
||||
"lineStyle" => [
|
||||
"color" => "#bbbbbb"
|
||||
]
|
||||
]
|
||||
],
|
||||
'legend' => array(
|
||||
'top' => 'bottom',
|
||||
'left' => 'center',
|
||||
'orient' => 'horizontal'
|
||||
),
|
||||
'series' => array(
|
||||
[
|
||||
"name" => "1 Right Ear",
|
||||
"symbol" => "circle", // Gunakan simbol default untuk tes
|
||||
"showSymbol" => true,
|
||||
"showAllSymbol" => true,
|
||||
"symbolSize" => 10,
|
||||
"data" => $acR,
|
||||
"type" => "line",
|
||||
"lineStyle" => array(
|
||||
"color" => 'red',
|
||||
"width" => 3,
|
||||
"type" => 'solid'
|
||||
),
|
||||
"itemStyle" => array(
|
||||
"color" => 'red',
|
||||
)
|
||||
],
|
||||
array(
|
||||
"name" => "2 BC Right",
|
||||
"symbol" => "triangle",
|
||||
"showSymbol" => true,
|
||||
"symbolSize" => 10,
|
||||
"data" => $bcR,
|
||||
"type" => "line",
|
||||
"lineStyle" => array(
|
||||
"color" => 'red',
|
||||
"width" => 3,
|
||||
"type" => 'dashed'
|
||||
),
|
||||
"itemStyle" => array(
|
||||
"color" => 'red'
|
||||
)
|
||||
),
|
||||
array(
|
||||
"name" => "3 Left Ear",
|
||||
"symbol" => "diamond",
|
||||
"showSymbol" => true,
|
||||
"symbolSize" => 10,
|
||||
"data" => $acL,
|
||||
"type" => "line",
|
||||
"lineStyle" => array(
|
||||
"color" => 'blue',
|
||||
"width" => 3,
|
||||
"type" => 'solid'
|
||||
),
|
||||
"itemStyle" => array(
|
||||
"color" => 'blue'
|
||||
)
|
||||
),
|
||||
array(
|
||||
"name" => "4 BC Left",
|
||||
"symbol" => "rect",
|
||||
"showSymbol" => true,
|
||||
"symbolSize" => 10,
|
||||
"data" => $bcL,
|
||||
"type" => "line",
|
||||
"lineStyle" => array(
|
||||
"color" => 'blue',
|
||||
"width" => 3,
|
||||
"type" => 'dashed'
|
||||
),
|
||||
"itemStyle" => array(
|
||||
"color" => 'blue'
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// 3. encapsulate in config attribute and json encode
|
||||
// print_r($param);
|
||||
$config = ["config" => $param];
|
||||
$j_param = json_encode($config);
|
||||
header("Content-Type: image/jpeg");
|
||||
// 4. post to chart renderer
|
||||
echo $this->post($this->url_renderer, $j_param);
|
||||
}
|
||||
|
||||
function v03($id)
|
||||
{
|
||||
$sql = "SELECT
|
||||
So_ResultEntryDetailID as trx_id,
|
||||
NonlabTemplateDetailCode as code,
|
||||
So_ResultEntryDetailNonlab_TemplateDetailID as template_detail_id,
|
||||
So_ResultEntryDetailNonlab_TemplateDetailName as result_label,
|
||||
IFNULL(So_ResultEntryDetailResult, 0) as result_value,
|
||||
So_ResultEntryDetailFlagPrint as flag_print,
|
||||
So_ResultEntryDetailResult as result_value_before,
|
||||
NonlabTemplateDetailIsResult as isResult,
|
||||
CASE
|
||||
WHEN NonlabTemplateDetailCode LIKE '%AR%' AND NonlabTemplateDetailIsResult='Y' THEN 'AR'
|
||||
WHEN NonlabTemplateDetailCode LIKE '%AL%' AND NonlabTemplateDetailIsResult='Y' THEN 'AL'
|
||||
WHEN NonlabTemplateDetailCode LIKE '%BR%' AND NonlabTemplateDetailIsResult='Y' THEN 'BR'
|
||||
WHEN NonlabTemplateDetailCode LIKE '%BL%' AND NonlabTemplateDetailIsResult='Y' THEN 'BL'
|
||||
ELSE 'N'
|
||||
END as type,
|
||||
GROUP_CONCAT(CASE
|
||||
WHEN So_ResultEntryDetailResult IS NULL THEN 0
|
||||
WHEN TRIM(So_ResultEntryDetailResult) = '' THEN 0
|
||||
WHEN So_ResultEntryDetailResult REGEXP '^[0-9]+$' THEN So_ResultEntryDetailResult
|
||||
ELSE 0
|
||||
END ORDER BY So_ResultEntryDetailNonlab_TemplateDetailID) as value
|
||||
FROM so_resultentrydetail
|
||||
JOIN nonlab_template_detail ON So_ResultEntryDetailNonlab_TemplateDetailID = NonlabTemplateDetailID
|
||||
AND NonlabTemplateDetaiM_LangID = 1
|
||||
WHERE
|
||||
So_ResultEntryDetailSo_ResultEntryID = '{$id}' AND So_ResultEntryDetailisActive = 'Y'
|
||||
GROUP BY type
|
||||
ORDER BY So_ResultEntryDetailNonlab_TemplateDetailID
|
||||
";
|
||||
$qry = $this->db_onedev->query($sql);
|
||||
if (!$qry) {
|
||||
$message = $this->db_onedev->error();
|
||||
$message['qry'] = $this->db_onedev->last_query();
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
$acR = array();
|
||||
$acL = array();
|
||||
$bcR = array();
|
||||
$bcL = array();
|
||||
$dtls = $qry->result_array();
|
||||
|
||||
foreach ($dtls as $key => $v) {
|
||||
if ($v['type'] == 'AR') {
|
||||
$acR = explode(',', $v['value']);
|
||||
$cek = array();
|
||||
for ($i = 0; $i < count($acR); $i++) {
|
||||
if (intval($acR[$i]) == 0) {
|
||||
array_push($cek, 1);
|
||||
}
|
||||
}
|
||||
if (count($cek) == count($acR)) {
|
||||
$acR = [];
|
||||
}
|
||||
}
|
||||
if ($v['type'] == 'AL') {
|
||||
$acL = explode(',', $v['value']);
|
||||
$cek = array();
|
||||
for ($i = 0; $i < count($acL); $i++) {
|
||||
if (intval($acL[$i]) == 0) {
|
||||
array_push($cek, 1);
|
||||
}
|
||||
}
|
||||
if (count($cek) == count($acL)) {
|
||||
$acL = [];
|
||||
}
|
||||
}
|
||||
if ($v['type'] == 'BR') {
|
||||
$bcR = explode(',', $v['value']);
|
||||
$cek = array();
|
||||
for ($i = 0; $i < count($bcR); $i++) {
|
||||
if (intval($bcR[$i]) == 0) {
|
||||
array_push($cek, 1);
|
||||
}
|
||||
}
|
||||
if (count($cek) == count($bcR)) {
|
||||
$bcR = [];
|
||||
}
|
||||
}
|
||||
if ($v['type'] == 'BL') {
|
||||
$bcL = explode(',', $v['value']);
|
||||
$cek = array();
|
||||
for ($i = 0; $i < count($bcL); $i++) {
|
||||
if (intval($bcL[$i]) == 0) {
|
||||
array_push($cek, 1);
|
||||
}
|
||||
}
|
||||
if (count($cek) == count($bcL)) {
|
||||
$bcL = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$param = array(
|
||||
"right_ear" => $acR,
|
||||
"left_ear" => $acL,
|
||||
"bc_right" => $bcR,
|
||||
"bc_left" => $bcL
|
||||
);
|
||||
|
||||
$j_param = json_encode($param);
|
||||
// print_r($j_param);
|
||||
header("Content-Type: image/jpeg");
|
||||
echo $this->post($this->url_audio_new, $j_param);
|
||||
}
|
||||
|
||||
function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
"Content-Type: application/json",
|
||||
"Content-Length: " . strlen($data),
|
||||
]);
|
||||
$result = curl_exec($ch);
|
||||
print_r($result);
|
||||
if (curl_errno($ch) > 0) {
|
||||
return [
|
||||
"status" => "ERR",
|
||||
"message" => curl_error($ch),
|
||||
];
|
||||
}
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
if ($httpCode != 200) {
|
||||
return [
|
||||
"status" => "ERR",
|
||||
"message" => "Http Response : $httpCode",
|
||||
];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
240
application/controllers/tools/Audiometry_chart_backup.php
Normal file
240
application/controllers/tools/Audiometry_chart_backup.php
Normal file
@@ -0,0 +1,240 @@
|
||||
<?php
|
||||
|
||||
class Audiometry_chart extends MY_Controller
|
||||
{
|
||||
var $url_renderer;
|
||||
var $db_onedev;
|
||||
var $load;
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->url_renderer = "http://localhost:3030/chart";
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function v01($id)
|
||||
{
|
||||
|
||||
$sql = "SELECT
|
||||
So_ResultEntryDetailID as trx_id,
|
||||
NonlabTemplateDetailCode as code,
|
||||
So_ResultEntryDetailNonlab_TemplateDetailID as template_detail_id,
|
||||
So_ResultEntryDetailNonlab_TemplateDetailName as result_label,
|
||||
IFNULL(So_ResultEntryDetailResult, 0) as result_value,
|
||||
So_ResultEntryDetailFlagPrint as flag_print,
|
||||
So_ResultEntryDetailResult as result_value_before,
|
||||
NonlabTemplateDetailIsResult as isResult,
|
||||
CASE
|
||||
WHEN NonlabTemplateDetailCode LIKE '%AR%' AND NonlabTemplateDetailIsResult='Y' THEN 'AR'
|
||||
WHEN NonlabTemplateDetailCode LIKE '%AL%' AND NonlabTemplateDetailIsResult='Y' THEN 'AL'
|
||||
WHEN NonlabTemplateDetailCode LIKE '%BR%' AND NonlabTemplateDetailIsResult='Y' THEN 'BR'
|
||||
WHEN NonlabTemplateDetailCode LIKE '%BL%' AND NonlabTemplateDetailIsResult='Y' THEN 'BL'
|
||||
ELSE 'N'
|
||||
END as type,
|
||||
GROUP_CONCAT(CASE
|
||||
WHEN So_ResultEntryDetailResult IS NULL THEN 0
|
||||
WHEN TRIM(So_ResultEntryDetailResult) = '' THEN 0
|
||||
WHEN So_ResultEntryDetailResult REGEXP '^[0-9]+$' THEN So_ResultEntryDetailResult
|
||||
ELSE 0
|
||||
END ORDER BY So_ResultEntryDetailNonlab_TemplateDetailID) as value
|
||||
FROM so_resultentrydetail
|
||||
JOIN nonlab_template_detail ON So_ResultEntryDetailNonlab_TemplateDetailID = NonlabTemplateDetailID
|
||||
AND NonlabTemplateDetaiM_LangID = 1
|
||||
WHERE
|
||||
So_ResultEntryDetailSo_ResultEntryID = '{$id}' AND So_ResultEntryDetailisActive = 'Y'
|
||||
GROUP BY type
|
||||
ORDER BY So_ResultEntryDetailNonlab_TemplateDetailID
|
||||
|
||||
|
||||
|
||||
";
|
||||
//echo $sql;
|
||||
$qry = $this->db_onedev->query($sql);
|
||||
if (!$qry) {
|
||||
$message = $this->db_onedev->error();
|
||||
$message['qry'] = $this->db_onedev->last_query();
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
$acR = array();
|
||||
$acL = array();
|
||||
$bcR = array();
|
||||
$bcL = array();
|
||||
$dtls = $qry->result_array();
|
||||
foreach ($dtls as $key => $v) {
|
||||
if ($v['type'] == 'AR') {
|
||||
$acR = explode(',', $v['value']);
|
||||
$cek = array();
|
||||
for ($i = 0; $i < count($acR); $i++) {
|
||||
if (intval($acR[$i]) == 0) {
|
||||
array_push($cek, 1);
|
||||
}
|
||||
}
|
||||
if (count($cek) == count($acR)) {
|
||||
$acR = [];
|
||||
}
|
||||
}
|
||||
if ($v['type'] == 'AL') {
|
||||
$acL = explode(',', $v['value']);
|
||||
$cek = array();
|
||||
for ($i = 0; $i < count($acL); $i++) {
|
||||
if (intval($acL[$i]) == 0) {
|
||||
array_push($cek, 1);
|
||||
}
|
||||
}
|
||||
if (count($cek) == count($acL)) {
|
||||
$acL = [];
|
||||
}
|
||||
}
|
||||
if ($v['type'] == 'BR') {
|
||||
$bcR = explode(',', $v['value']);
|
||||
$cek = array();
|
||||
for ($i = 0; $i < count($bcR); $i++) {
|
||||
if (intval($bcR[$i]) == 0) {
|
||||
array_push($cek, 1);
|
||||
}
|
||||
}
|
||||
if (count($cek) == count($bcR)) {
|
||||
$bcR = [];
|
||||
}
|
||||
}
|
||||
if ($v['type'] == 'BL') {
|
||||
$bcL = explode(',', $v['value']);
|
||||
$cek = array();
|
||||
for ($i = 0; $i < count($bcL); $i++) {
|
||||
if (intval($bcL[$i]) == 0) {
|
||||
array_push($cek, 1);
|
||||
}
|
||||
}
|
||||
if (count($cek) == count($bcL)) {
|
||||
$bcL = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
$param = array(
|
||||
|
||||
'tooltip' => array(
|
||||
"show" => true,
|
||||
'trigger' => 'item'
|
||||
),
|
||||
'color' => [
|
||||
"#ff0000",
|
||||
"#00ff00",
|
||||
"#0000ff",
|
||||
"#00ffff",
|
||||
],
|
||||
'xAxis' => [
|
||||
"name"=>"Frequency in hertz (Hz)",
|
||||
"nameLocation" => "center",
|
||||
"nameGap" => 30,
|
||||
"showGrid" => true,
|
||||
"type" => "category",
|
||||
"data" => [250, 500, 1000, 2000, 3000, 4000, 6000, 8000],
|
||||
"forceLabelIsEnabled" => true,
|
||||
"labelCount" => 8,
|
||||
"splitLine" => [
|
||||
"show" => true,
|
||||
"lineStyle" => [
|
||||
"color" => "#bbbbbb"
|
||||
]
|
||||
]
|
||||
],
|
||||
'yAxis' => [
|
||||
"name" =>"Hearing treshold level (dB)",
|
||||
"nameLocation" => "middle",
|
||||
"nameGap" => 30,
|
||||
"type" => "value",
|
||||
"inverse" => true,
|
||||
"min" => 0,
|
||||
"max" => 120,
|
||||
"interval" => 10,
|
||||
"splitLine" => [
|
||||
"interval" => 0,
|
||||
"lineStyle" => [
|
||||
"color" => "#bbbbbb"
|
||||
]
|
||||
]
|
||||
],
|
||||
'legend' => array(
|
||||
'top' => 'bottom',
|
||||
'left' => 'center',
|
||||
'orient' => 'horizontal'
|
||||
),
|
||||
'series' => array(
|
||||
[
|
||||
"name" => "1 Right Ear",
|
||||
"symbol" => "none",
|
||||
// "symbolSize" => 200,
|
||||
// "data" => [25, 25, 20, 25, 20, 15, 20, 25],
|
||||
"data" => $acR,
|
||||
"type" => "line",
|
||||
],
|
||||
[
|
||||
"name" => "2 BC Right",
|
||||
"symbol" => "none",
|
||||
// "symbol" => "circle",
|
||||
// "showSymbol" => true,
|
||||
// "data" => [],
|
||||
"data" => $bcR,
|
||||
"type" => "line",
|
||||
],
|
||||
[
|
||||
"name" => "3 Left Ear",
|
||||
"symbol" => "none",
|
||||
// "symbol" => "plus",
|
||||
// "showSymbol" => true,
|
||||
// "data" => [30, 30, 25, 25, 30, 20, 30, 30],
|
||||
"data" => $acL,
|
||||
"type" => "line",
|
||||
],
|
||||
[
|
||||
"name" => "4 BC Left ",
|
||||
"symbol" => "none",
|
||||
// "symbol" => "triangle",
|
||||
// "showSymbol" => true,
|
||||
"data" => $bcL,
|
||||
// "data" => [],
|
||||
"type" => "line",
|
||||
]
|
||||
)
|
||||
);
|
||||
// 3. encapsulate in config attribute and json encode
|
||||
// print_r($param);
|
||||
$config = ["config" => $param];
|
||||
$j_param = json_encode($config);
|
||||
header("Content-Type: image/png");
|
||||
// 4. post to chart renderer
|
||||
echo $this->post($this->url_renderer, $j_param);
|
||||
}
|
||||
|
||||
|
||||
function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
"Content-Type: application/json",
|
||||
"Content-Length: " . strlen($data),
|
||||
]);
|
||||
$result = curl_exec($ch);
|
||||
print_r($result);
|
||||
if (curl_errno($ch) > 0) {
|
||||
return [
|
||||
"status" => "ERR",
|
||||
"message" => curl_error($ch),
|
||||
];
|
||||
}
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
if ($httpCode != 200) {
|
||||
return [
|
||||
"status" => "ERR",
|
||||
"message" => "Http Response : $httpCode",
|
||||
];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
240
application/controllers/tools/Audiometry_chart_kosongan.php
Normal file
240
application/controllers/tools/Audiometry_chart_kosongan.php
Normal file
@@ -0,0 +1,240 @@
|
||||
<?php
|
||||
|
||||
class Audiometry_chart_kosongan extends MY_Controller
|
||||
{
|
||||
var $url_renderer;
|
||||
var $db_onedev;
|
||||
var $load;
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->url_renderer = "http://localhost:3030/chart";
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function v01()
|
||||
{
|
||||
|
||||
// $sql = "SELECT
|
||||
// So_ResultEntryDetailID as trx_id,
|
||||
// NonlabTemplateDetailCode as code,
|
||||
// So_ResultEntryDetailNonlab_TemplateDetailID as template_detail_id,
|
||||
// So_ResultEntryDetailNonlab_TemplateDetailName as result_label,
|
||||
// IFNULL(So_ResultEntryDetailResult, 0) as result_value,
|
||||
// So_ResultEntryDetailFlagPrint as flag_print,
|
||||
// So_ResultEntryDetailResult as result_value_before,
|
||||
// NonlabTemplateDetailIsResult as isResult,
|
||||
// CASE
|
||||
// WHEN NonlabTemplateDetailCode LIKE '%AR%' AND NonlabTemplateDetailIsResult='Y' THEN 'AR'
|
||||
// WHEN NonlabTemplateDetailCode LIKE '%AL%' AND NonlabTemplateDetailIsResult='Y' THEN 'AL'
|
||||
// WHEN NonlabTemplateDetailCode LIKE '%BR%' AND NonlabTemplateDetailIsResult='Y' THEN 'BR'
|
||||
// WHEN NonlabTemplateDetailCode LIKE '%BL%' AND NonlabTemplateDetailIsResult='Y' THEN 'BL'
|
||||
// ELSE 'N'
|
||||
// END as type,
|
||||
// GROUP_CONCAT(CASE
|
||||
// WHEN So_ResultEntryDetailResult IS NULL THEN 0
|
||||
// WHEN TRIM(So_ResultEntryDetailResult) = '' THEN 0
|
||||
// WHEN So_ResultEntryDetailResult REGEXP '^[0-9]+$' THEN So_ResultEntryDetailResult
|
||||
// ELSE 0
|
||||
// END ORDER BY So_ResultEntryDetailNonlab_TemplateDetailID) as value
|
||||
// FROM so_resultentrydetail
|
||||
// JOIN nonlab_template_detail ON So_ResultEntryDetailNonlab_TemplateDetailID = NonlabTemplateDetailID
|
||||
// AND NonlabTemplateDetaiM_LangID = 1
|
||||
// WHERE
|
||||
// So_ResultEntryDetailSo_ResultEntryID = '{$id}' AND So_ResultEntryDetailisActive = 'Y'
|
||||
// GROUP BY type
|
||||
// ORDER BY So_ResultEntryDetailNonlab_TemplateDetailID
|
||||
|
||||
|
||||
|
||||
// ";
|
||||
//echo $sql;
|
||||
// $qry = $this->db_onedev->query($sql);
|
||||
// if (!$qry) {
|
||||
// $message = $this->db_onedev->error();
|
||||
// $message['qry'] = $this->db_onedev->last_query();
|
||||
// $this->sys_error($message);
|
||||
// exit;
|
||||
// }
|
||||
// $acR = array();
|
||||
// $acL = array();
|
||||
// $bcR = array();
|
||||
// $bcL = array();
|
||||
// $dtls = $qry->result_array();
|
||||
// foreach ($dtls as $key => $v) {
|
||||
// if ($v['type'] == 'AR') {
|
||||
// $acR = explode(',', $v['value']);
|
||||
// $cek = array();
|
||||
// for ($i = 0; $i < count($acR); $i++) {
|
||||
// if (intval($acR[$i]) == 0) {
|
||||
// array_push($cek, 1);
|
||||
// }
|
||||
// }
|
||||
// if (count($cek) == count($acR)) {
|
||||
// $acR = [];
|
||||
// }
|
||||
// }
|
||||
// if ($v['type'] == 'AL') {
|
||||
// $acL = explode(',', $v['value']);
|
||||
// $cek = array();
|
||||
// for ($i = 0; $i < count($acL); $i++) {
|
||||
// if (intval($acL[$i]) == 0) {
|
||||
// array_push($cek, 1);
|
||||
// }
|
||||
// }
|
||||
// if (count($cek) == count($acL)) {
|
||||
// $acL = [];
|
||||
// }
|
||||
// }
|
||||
// if ($v['type'] == 'BR') {
|
||||
// $bcR = explode(',', $v['value']);
|
||||
// $cek = array();
|
||||
// for ($i = 0; $i < count($bcR); $i++) {
|
||||
// if (intval($bcR[$i]) == 0) {
|
||||
// array_push($cek, 1);
|
||||
// }
|
||||
// }
|
||||
// if (count($cek) == count($bcR)) {
|
||||
// $bcR = [];
|
||||
// }
|
||||
// }
|
||||
// if ($v['type'] == 'BL') {
|
||||
// $bcL = explode(',', $v['value']);
|
||||
// $cek = array();
|
||||
// for ($i = 0; $i < count($bcL); $i++) {
|
||||
// if (intval($bcL[$i]) == 0) {
|
||||
// array_push($cek, 1);
|
||||
// }
|
||||
// }
|
||||
// if (count($cek) == count($bcL)) {
|
||||
// $bcL = [];
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
$param = array(
|
||||
|
||||
'tooltip' => array(
|
||||
"show" => true,
|
||||
'trigger' => 'item'
|
||||
),
|
||||
'color' => [
|
||||
"#ff0000",
|
||||
"#00ff00",
|
||||
"#0000ff",
|
||||
"#00ffff",
|
||||
],
|
||||
'xAxis' => [
|
||||
"name" => "Frequency in hertz (Hz)",
|
||||
"nameLocation" => "center",
|
||||
"nameGap" => 30,
|
||||
"showGrid" => true,
|
||||
"type" => "category",
|
||||
"data" => [250, 500, 1000, 2000, 3000, 4000, 6000, 8000],
|
||||
"forceLabelIsEnabled" => true,
|
||||
"labelCount" => 8,
|
||||
"splitLine" => [
|
||||
"show" => true,
|
||||
"lineStyle" => [
|
||||
"color" => "#bbbbbb"
|
||||
]
|
||||
]
|
||||
],
|
||||
'yAxis' => [
|
||||
"name" => "Hearing treshold level (dB)",
|
||||
"nameLocation" => "middle",
|
||||
"nameGap" => 30,
|
||||
"type" => "value",
|
||||
"inverse" => true,
|
||||
"min" => 0,
|
||||
"max" => 120,
|
||||
"interval" => 10,
|
||||
"splitLine" => [
|
||||
"interval" => 0,
|
||||
"lineStyle" => [
|
||||
"color" => "#bbbbbb"
|
||||
]
|
||||
]
|
||||
],
|
||||
'legend' => array(
|
||||
'top' => 'bottom',
|
||||
'left' => 'center',
|
||||
'orient' => 'horizontal'
|
||||
),
|
||||
'series' => array(
|
||||
[
|
||||
"name" => "1 Right Ear",
|
||||
"symbol" => "none",
|
||||
// "symbolSize" => 200,
|
||||
// "data" => [25, 25, 20, 25, 20, 15, 20, 25],
|
||||
"data" => [],
|
||||
"type" => "line",
|
||||
],
|
||||
[
|
||||
"name" => "2 BC Right",
|
||||
"symbol" => "none",
|
||||
// "symbol" => "circle",
|
||||
// "showSymbol" => true,
|
||||
// "data" => [],
|
||||
"data" => [],
|
||||
"type" => "line",
|
||||
],
|
||||
[
|
||||
"name" => "3 Left Ear",
|
||||
"symbol" => "none",
|
||||
// "symbol" => "plus",
|
||||
// "showSymbol" => true,
|
||||
// "data" => [30, 30, 25, 25, 30, 20, 30, 30],
|
||||
"data" => [],
|
||||
"type" => "line",
|
||||
],
|
||||
[
|
||||
"name" => "4 BC Left ",
|
||||
"symbol" => "none",
|
||||
// "symbol" => "triangle",
|
||||
// "showSymbol" => true,
|
||||
// "data" => $bcL,
|
||||
"data" => [],
|
||||
"type" => "line",
|
||||
]
|
||||
)
|
||||
);
|
||||
// 3. encapsulate in config attribute and json encode
|
||||
// print_r($param);
|
||||
$config = ["config" => $param];
|
||||
$j_param = json_encode($config);
|
||||
header("Content-Type: image/png");
|
||||
// 4. post to chart renderer
|
||||
echo $this->post($this->url_renderer, $j_param);
|
||||
}
|
||||
|
||||
|
||||
function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
"Content-Type: application/json",
|
||||
"Content-Length: " . strlen($data),
|
||||
]);
|
||||
$result = curl_exec($ch);
|
||||
print_r($result);
|
||||
if (curl_errno($ch) > 0) {
|
||||
return [
|
||||
"status" => "ERR",
|
||||
"message" => curl_error($ch),
|
||||
];
|
||||
}
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
if ($httpCode != 200) {
|
||||
return [
|
||||
"status" => "ERR",
|
||||
"message" => "Http Response : $httpCode",
|
||||
];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
275
application/controllers/tools/Audiometry_chart_old.php
Normal file
275
application/controllers/tools/Audiometry_chart_old.php
Normal file
@@ -0,0 +1,275 @@
|
||||
<?php
|
||||
|
||||
class Audiometry_chart_old extends MY_Controller
|
||||
{
|
||||
var $url_renderer;
|
||||
var $db_onedev;
|
||||
var $load;
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->url_renderer = "http://localhost:3030/chart";
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function v01($id)
|
||||
{
|
||||
|
||||
$sql = "SELECT
|
||||
So_ResultEntryDetailID as trx_id,
|
||||
NonlabTemplateDetailCode as code,
|
||||
So_ResultEntryDetailNonlab_TemplateDetailID as template_detail_id,
|
||||
So_ResultEntryDetailNonlab_TemplateDetailName as result_label,
|
||||
IFNULL(fn_get_old_result_audiometri(M_PatientOldPID,NonlabTemplateDetailID), 0) as result_value,
|
||||
So_ResultEntryDetailFlagPrint as flag_print,
|
||||
fn_get_old_result_audiometri(M_PatientOldPID,NonlabTemplateDetailID) as result_value_before,
|
||||
NonlabTemplateDetailIsResult as isResult,
|
||||
CASE
|
||||
WHEN NonlabTemplateDetailCode LIKE '%AR%' AND NonlabTemplateDetailIsResult='Y' THEN 'AR'
|
||||
WHEN NonlabTemplateDetailCode LIKE '%AL%' AND NonlabTemplateDetailIsResult='Y' THEN 'AL'
|
||||
WHEN NonlabTemplateDetailCode LIKE '%BR%' AND NonlabTemplateDetailIsResult='Y' THEN 'BR'
|
||||
WHEN NonlabTemplateDetailCode LIKE '%BL%' AND NonlabTemplateDetailIsResult='Y' THEN 'BL'
|
||||
ELSE 'N'
|
||||
END as type,
|
||||
GROUP_CONCAT(CASE
|
||||
WHEN fn_get_old_result_audiometri(M_PatientOldPID,NonlabTemplateDetailID) IS NULL THEN 0
|
||||
WHEN TRIM(fn_get_old_result_audiometri(M_PatientOldPID,NonlabTemplateDetailID)) = '' THEN 0
|
||||
WHEN fn_get_old_result_audiometri(M_PatientOldPID,NonlabTemplateDetailID) REGEXP '^[0-9]+$' THEN So_ResultEntryDetailResult
|
||||
ELSE 0
|
||||
END ORDER BY So_ResultEntryDetailNonlab_TemplateDetailID) as value
|
||||
FROM so_resultentrydetail
|
||||
JOIN so_resultentry ON So_ResultEntryDetailSo_ResultEntryID = So_ResultEntryID
|
||||
JOIN t_orderheader ON So_ResultEntryT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN m_patient ON M_PatientID = T_OrderHeaderM_PatientID
|
||||
JOIN nonlab_template_detail ON So_ResultEntryDetailNonlab_TemplateDetailID = NonlabTemplateDetailID
|
||||
AND NonlabTemplateDetaiM_LangID = 1
|
||||
WHERE
|
||||
So_ResultEntryDetailSo_ResultEntryID = '{$id}' AND So_ResultEntryDetailisActive = 'Y'
|
||||
GROUP BY type
|
||||
ORDER BY So_ResultEntryDetailNonlab_TemplateDetailID
|
||||
|
||||
|
||||
|
||||
";
|
||||
//echo $sql;
|
||||
$qry = $this->db_onedev->query($sql);
|
||||
if (!$qry) {
|
||||
$message = $this->db_onedev->error();
|
||||
$message['qry'] = $this->db_onedev->last_query();
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
$acR = array();
|
||||
$acL = array();
|
||||
$bcR = array();
|
||||
$bcL = array();
|
||||
$dtls = $qry->result_array();
|
||||
foreach ($dtls as $key => $v) {
|
||||
if ($v['type'] == 'AR') {
|
||||
$acR = explode(',', $v['value']);
|
||||
$cek = array();
|
||||
for ($i = 0; $i < count($acR); $i++) {
|
||||
if (intval($acR[$i]) == 0) {
|
||||
array_push($cek, 1);
|
||||
}
|
||||
}
|
||||
if (count($cek) == count($acR)) {
|
||||
$acR = [];
|
||||
}
|
||||
}
|
||||
if ($v['type'] == 'AL') {
|
||||
$acL = explode(',', $v['value']);
|
||||
$cek = array();
|
||||
for ($i = 0; $i < count($acL); $i++) {
|
||||
if (intval($acL[$i]) == 0) {
|
||||
array_push($cek, 1);
|
||||
}
|
||||
}
|
||||
if (count($cek) == count($acL)) {
|
||||
$acL = [];
|
||||
}
|
||||
}
|
||||
if ($v['type'] == 'BR') {
|
||||
$bcR = explode(',', $v['value']);
|
||||
$cek = array();
|
||||
for ($i = 0; $i < count($bcR); $i++) {
|
||||
if (intval($bcR[$i]) == 0) {
|
||||
array_push($cek, 1);
|
||||
}
|
||||
}
|
||||
if (count($cek) == count($bcR)) {
|
||||
$bcR = [];
|
||||
}
|
||||
}
|
||||
if ($v['type'] == 'BL') {
|
||||
$bcL = explode(',', $v['value']);
|
||||
$cek = array();
|
||||
for ($i = 0; $i < count($bcL); $i++) {
|
||||
if (intval($bcL[$i]) == 0) {
|
||||
array_push($cek, 1);
|
||||
}
|
||||
}
|
||||
if (count($cek) == count($bcL)) {
|
||||
$bcL = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
$param = array(
|
||||
|
||||
'tooltip' => array(
|
||||
"show" => true,
|
||||
'trigger' => 'item'
|
||||
),
|
||||
'color' => [
|
||||
"#ff0000",
|
||||
"#00ff00",
|
||||
"#0000ff",
|
||||
"#00ffff",
|
||||
],
|
||||
'xAxis' => [
|
||||
"name"=>"Frequency in hertz (Hz)",
|
||||
"nameLocation" => "center",
|
||||
"nameGap" => 30,
|
||||
"showGrid" => true,
|
||||
"type" => "category",
|
||||
"data" => [250, 500, 1000, 2000, 3000, 4000, 6000, 8000],
|
||||
"forceLabelIsEnabled" => true,
|
||||
"labelCount" => 8,
|
||||
"splitLine" => [
|
||||
"show" => true,
|
||||
"lineStyle" => [
|
||||
"color" => "#bbbbbb"
|
||||
]
|
||||
]
|
||||
],
|
||||
'yAxis' => [
|
||||
"name" =>"Hearing treshold level (dB)",
|
||||
"nameLocation" => "middle",
|
||||
"nameGap" => 30,
|
||||
"type" => "value",
|
||||
"inverse" => true,
|
||||
"min" => 0,
|
||||
"max" => 120,
|
||||
"interval" => 10,
|
||||
"splitLine" => [
|
||||
"interval" => 0,
|
||||
"lineStyle" => [
|
||||
"color" => "#bbbbbb"
|
||||
]
|
||||
]
|
||||
],
|
||||
'legend' => array(
|
||||
'top' => 'bottom',
|
||||
'left' => 'center',
|
||||
'orient' => 'horizontal'
|
||||
),
|
||||
'series' => array(
|
||||
[
|
||||
"name" => "1 Right Ear",
|
||||
"symbol" => "circle",
|
||||
// "symbolSize" => 200,
|
||||
// "data" => [25, 25, 20, 25, 20, 15, 20, 25],
|
||||
"data" => $acR,
|
||||
"type" => "line",
|
||||
"lineStyle" => array(
|
||||
"color" => 'red',
|
||||
"width" => 3,
|
||||
"type" => 'solid'
|
||||
),
|
||||
"itemStyle"=> array(
|
||||
"color"=> 'red'
|
||||
)
|
||||
],
|
||||
[
|
||||
"name" => "2 BC Right",
|
||||
"symbol" => "triangle",
|
||||
// "symbol" => "circle",
|
||||
// "showSymbol" => true,
|
||||
// "data" => [],
|
||||
"data" => $bcR,
|
||||
"type" => "line",
|
||||
"lineStyle" => array(
|
||||
"color" => 'red',
|
||||
"width" => 3,
|
||||
"type" => 'dashed'
|
||||
),
|
||||
"itemStyle"=> array(
|
||||
"color"=> 'red'
|
||||
)
|
||||
],
|
||||
[
|
||||
"name" => "3 Left Ear",
|
||||
"symbol" => "diamond",
|
||||
// "symbol" => "plus",
|
||||
// "showSymbol" => true,
|
||||
// "data" => [30, 30, 25, 25, 30, 20, 30, 30],
|
||||
"data" => $acL,
|
||||
"type" => "line",
|
||||
"lineStyle" => array(
|
||||
"color" => 'blue',
|
||||
"width" => 3,
|
||||
"type" => 'solid'
|
||||
),
|
||||
"itemStyle"=> array(
|
||||
"color"=> 'blue'
|
||||
)
|
||||
],
|
||||
[
|
||||
"name" => "4 BC Left ",
|
||||
"symbol" => "rect",
|
||||
// "symbol" => "triangle",
|
||||
// "showSymbol" => true,
|
||||
"data" => $bcL,
|
||||
// "data" => [],
|
||||
"type" => "line",
|
||||
"lineStyle" => array(
|
||||
"color" => 'blue',
|
||||
"width" => 3,
|
||||
"type" => 'dashed'
|
||||
),
|
||||
"itemStyle"=> array(
|
||||
"color"=> 'blue'
|
||||
)
|
||||
]
|
||||
)
|
||||
);
|
||||
// 3. encapsulate in config attribute and json encode
|
||||
// print_r($param);
|
||||
$config = ["config" => $param];
|
||||
$j_param = json_encode($config);
|
||||
header("Content-Type: image/png");
|
||||
// 4. post to chart renderer
|
||||
echo $this->post($this->url_renderer, $j_param);
|
||||
}
|
||||
|
||||
|
||||
function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
"Content-Type: application/json",
|
||||
"Content-Length: " . strlen($data),
|
||||
]);
|
||||
$result = curl_exec($ch);
|
||||
print_r($result);
|
||||
if (curl_errno($ch) > 0) {
|
||||
return [
|
||||
"status" => "ERR",
|
||||
"message" => curl_error($ch),
|
||||
];
|
||||
}
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
if ($httpCode != 200) {
|
||||
return [
|
||||
"status" => "ERR",
|
||||
"message" => "Http Response : $httpCode",
|
||||
];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
243
application/controllers/tools/Audiometry_chart_old_backup.php
Normal file
243
application/controllers/tools/Audiometry_chart_old_backup.php
Normal file
@@ -0,0 +1,243 @@
|
||||
<?php
|
||||
|
||||
class Audiometry_chart_old extends MY_Controller
|
||||
{
|
||||
var $url_renderer;
|
||||
var $db_onedev;
|
||||
var $load;
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->url_renderer = "http://localhost:3030/chart";
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function v01($id)
|
||||
{
|
||||
|
||||
$sql = "SELECT
|
||||
So_ResultEntryDetailID as trx_id,
|
||||
NonlabTemplateDetailCode as code,
|
||||
So_ResultEntryDetailNonlab_TemplateDetailID as template_detail_id,
|
||||
So_ResultEntryDetailNonlab_TemplateDetailName as result_label,
|
||||
IFNULL(fn_get_old_result_audiometri(M_PatientOldPID,NonlabTemplateDetailID), 0) as result_value,
|
||||
So_ResultEntryDetailFlagPrint as flag_print,
|
||||
fn_get_old_result_audiometri(M_PatientOldPID,NonlabTemplateDetailID) as result_value_before,
|
||||
NonlabTemplateDetailIsResult as isResult,
|
||||
CASE
|
||||
WHEN NonlabTemplateDetailCode LIKE '%AR%' AND NonlabTemplateDetailIsResult='Y' THEN 'AR'
|
||||
WHEN NonlabTemplateDetailCode LIKE '%AL%' AND NonlabTemplateDetailIsResult='Y' THEN 'AL'
|
||||
WHEN NonlabTemplateDetailCode LIKE '%BR%' AND NonlabTemplateDetailIsResult='Y' THEN 'BR'
|
||||
WHEN NonlabTemplateDetailCode LIKE '%BL%' AND NonlabTemplateDetailIsResult='Y' THEN 'BL'
|
||||
ELSE 'N'
|
||||
END as type,
|
||||
GROUP_CONCAT(CASE
|
||||
WHEN fn_get_old_result_audiometri(M_PatientOldPID,NonlabTemplateDetailID) IS NULL THEN 0
|
||||
WHEN TRIM(fn_get_old_result_audiometri(M_PatientOldPID,NonlabTemplateDetailID)) = '' THEN 0
|
||||
WHEN fn_get_old_result_audiometri(M_PatientOldPID,NonlabTemplateDetailID) REGEXP '^[0-9]+$' THEN So_ResultEntryDetailResult
|
||||
ELSE 0
|
||||
END ORDER BY So_ResultEntryDetailNonlab_TemplateDetailID) as value
|
||||
FROM so_resultentrydetail
|
||||
JOIN so_resultentry ON So_ResultEntryDetailSo_ResultEntryID = So_ResultEntryID
|
||||
JOIN t_orderheader ON So_ResultEntryT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN m_patient ON M_PatientID = T_OrderHeaderM_PatientID
|
||||
JOIN nonlab_template_detail ON So_ResultEntryDetailNonlab_TemplateDetailID = NonlabTemplateDetailID
|
||||
AND NonlabTemplateDetaiM_LangID = 1
|
||||
WHERE
|
||||
So_ResultEntryDetailSo_ResultEntryID = '{$id}' AND So_ResultEntryDetailisActive = 'Y'
|
||||
GROUP BY type
|
||||
ORDER BY So_ResultEntryDetailNonlab_TemplateDetailID
|
||||
|
||||
|
||||
|
||||
";
|
||||
//echo $sql;
|
||||
$qry = $this->db_onedev->query($sql);
|
||||
if (!$qry) {
|
||||
$message = $this->db_onedev->error();
|
||||
$message['qry'] = $this->db_onedev->last_query();
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
$acR = array();
|
||||
$acL = array();
|
||||
$bcR = array();
|
||||
$bcL = array();
|
||||
$dtls = $qry->result_array();
|
||||
foreach ($dtls as $key => $v) {
|
||||
if ($v['type'] == 'AR') {
|
||||
$acR = explode(',', $v['value']);
|
||||
$cek = array();
|
||||
for ($i = 0; $i < count($acR); $i++) {
|
||||
if (intval($acR[$i]) == 0) {
|
||||
array_push($cek, 1);
|
||||
}
|
||||
}
|
||||
if (count($cek) == count($acR)) {
|
||||
$acR = [];
|
||||
}
|
||||
}
|
||||
if ($v['type'] == 'AL') {
|
||||
$acL = explode(',', $v['value']);
|
||||
$cek = array();
|
||||
for ($i = 0; $i < count($acL); $i++) {
|
||||
if (intval($acL[$i]) == 0) {
|
||||
array_push($cek, 1);
|
||||
}
|
||||
}
|
||||
if (count($cek) == count($acL)) {
|
||||
$acL = [];
|
||||
}
|
||||
}
|
||||
if ($v['type'] == 'BR') {
|
||||
$bcR = explode(',', $v['value']);
|
||||
$cek = array();
|
||||
for ($i = 0; $i < count($bcR); $i++) {
|
||||
if (intval($bcR[$i]) == 0) {
|
||||
array_push($cek, 1);
|
||||
}
|
||||
}
|
||||
if (count($cek) == count($bcR)) {
|
||||
$bcR = [];
|
||||
}
|
||||
}
|
||||
if ($v['type'] == 'BL') {
|
||||
$bcL = explode(',', $v['value']);
|
||||
$cek = array();
|
||||
for ($i = 0; $i < count($bcL); $i++) {
|
||||
if (intval($bcL[$i]) == 0) {
|
||||
array_push($cek, 1);
|
||||
}
|
||||
}
|
||||
if (count($cek) == count($bcL)) {
|
||||
$bcL = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
$param = array(
|
||||
|
||||
'tooltip' => array(
|
||||
"show" => true,
|
||||
'trigger' => 'item'
|
||||
),
|
||||
'color' => [
|
||||
"#ff0000",
|
||||
"#00ff00",
|
||||
"#0000ff",
|
||||
"#00ffff",
|
||||
],
|
||||
'xAxis' => [
|
||||
"name"=>"Frequency in hertz (Hz)",
|
||||
"nameLocation" => "center",
|
||||
"nameGap" => 30,
|
||||
"showGrid" => true,
|
||||
"type" => "category",
|
||||
"data" => [250, 500, 1000, 2000, 3000, 4000, 6000, 8000],
|
||||
"forceLabelIsEnabled" => true,
|
||||
"labelCount" => 8,
|
||||
"splitLine" => [
|
||||
"show" => true,
|
||||
"lineStyle" => [
|
||||
"color" => "#bbbbbb"
|
||||
]
|
||||
]
|
||||
],
|
||||
'yAxis' => [
|
||||
"name" =>"Hearing treshold level (dB)",
|
||||
"nameLocation" => "middle",
|
||||
"nameGap" => 30,
|
||||
"type" => "value",
|
||||
"inverse" => true,
|
||||
"min" => 0,
|
||||
"max" => 120,
|
||||
"interval" => 10,
|
||||
"splitLine" => [
|
||||
"interval" => 0,
|
||||
"lineStyle" => [
|
||||
"color" => "#bbbbbb"
|
||||
]
|
||||
]
|
||||
],
|
||||
'legend' => array(
|
||||
'top' => 'bottom',
|
||||
'left' => 'center',
|
||||
'orient' => 'horizontal'
|
||||
),
|
||||
'series' => array(
|
||||
[
|
||||
"name" => "1 Right Ear",
|
||||
"symbol" => "none",
|
||||
// "symbolSize" => 200,
|
||||
// "data" => [25, 25, 20, 25, 20, 15, 20, 25],
|
||||
"data" => $acR,
|
||||
"type" => "line",
|
||||
],
|
||||
[
|
||||
"name" => "2 BC Right",
|
||||
"symbol" => "none",
|
||||
// "symbol" => "circle",
|
||||
// "showSymbol" => true,
|
||||
// "data" => [],
|
||||
"data" => $bcR,
|
||||
"type" => "line",
|
||||
],
|
||||
[
|
||||
"name" => "3 Left Ear",
|
||||
"symbol" => "none",
|
||||
// "symbol" => "plus",
|
||||
// "showSymbol" => true,
|
||||
// "data" => [30, 30, 25, 25, 30, 20, 30, 30],
|
||||
"data" => $acL,
|
||||
"type" => "line",
|
||||
],
|
||||
[
|
||||
"name" => "4 BC Left ",
|
||||
"symbol" => "none",
|
||||
// "symbol" => "triangle",
|
||||
// "showSymbol" => true,
|
||||
"data" => $bcL,
|
||||
// "data" => [],
|
||||
"type" => "line",
|
||||
]
|
||||
)
|
||||
);
|
||||
// 3. encapsulate in config attribute and json encode
|
||||
// print_r($param);
|
||||
$config = ["config" => $param];
|
||||
$j_param = json_encode($config);
|
||||
header("Content-Type: image/png");
|
||||
// 4. post to chart renderer
|
||||
echo $this->post($this->url_renderer, $j_param);
|
||||
}
|
||||
|
||||
|
||||
function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
"Content-Type: application/json",
|
||||
"Content-Length: " . strlen($data),
|
||||
]);
|
||||
$result = curl_exec($ch);
|
||||
print_r($result);
|
||||
if (curl_errno($ch) > 0) {
|
||||
return [
|
||||
"status" => "ERR",
|
||||
"message" => curl_error($ch),
|
||||
];
|
||||
}
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
if ($httpCode != 200) {
|
||||
return [
|
||||
"status" => "ERR",
|
||||
"message" => "Http Response : $httpCode",
|
||||
];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
148
application/controllers/tools/Auth_patient.php
Normal file
148
application/controllers/tools/Auth_patient.php
Normal file
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
class Auth_patient extends MY_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
function generate($mouID)
|
||||
{
|
||||
$this->db->trans_begin();
|
||||
$sql = "select distinct T_OrderHeaderCorporateID,
|
||||
T_OrderHeaderM_PatientID, M_PatientEmail,
|
||||
concat (
|
||||
ifnull(M_PatientPrefix,''),
|
||||
if(M_PatientPrefix is null,'',' '),
|
||||
M_PatientName,
|
||||
if(M_PatientSuffix is null,'',' '),
|
||||
ifnull(M_PatientSuffix,'')
|
||||
) M_PatientName
|
||||
from
|
||||
t_orderheader
|
||||
join m_patient
|
||||
on T_OrderHeaderIsActive = 'Y'
|
||||
and T_OrderHeaderMgm_McuID = ?
|
||||
and T_OrderHeaderM_PatientID = M_PatientID
|
||||
and M_PatientEmail <> ''";
|
||||
$qry = $this->db->query($sql, [$mouID]);
|
||||
if (!$qry) {
|
||||
echo json_encode(["status" => "ERR", "message" => print_r($this->db->error(), true)]);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$count = count($rows);
|
||||
if ($count == 0) {
|
||||
echo json_encode(["status" => "OK", "message" => "0 patient found"]);
|
||||
$this->db->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
$sql = "select XAuthRandCode,XAuthRandID
|
||||
from x_auth_rand
|
||||
where XAuthRandIsUsed = 'N' limit 0,$count";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
echo json_encode(["status" => "ERR", "message" => print_r($this->db->error(), true)]);
|
||||
$this->db->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
$x_rows = $qry->result_array();
|
||||
if (count($x_rows) == 0) {
|
||||
echo json_encode(["status" => "ERR", "message" => "Random Auth already used up"]);
|
||||
$this->db->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
$x_idx = array_map(function ($r) {
|
||||
return $r["XAuthRandID"];
|
||||
}, $x_rows);
|
||||
$s_idx = implode(",", $x_idx);
|
||||
$sql = "update x_auth_rand set XAuthRandIsUsed='P' where XAuthRandID in($s_idx)";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
echo json_encode(["status" => "ERR", "message" => print_r($this->db->error(), true)]);
|
||||
$this->db->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
$sql_c = "select AuthPatientID
|
||||
from auth_patient
|
||||
where AuthPatientCorporateID =? and AuthPatientM_PatientID = ?";
|
||||
$sql_i = "insert into auth_patient(AuthPatientCorporateID,
|
||||
AuthPatientM_PatientID,AuthPatientEmail, AuthPatientPassword)
|
||||
values(?,?,?,?)";
|
||||
|
||||
$sql_u = "update x_auth_rand set XAuthRandIsUsed = 'Y' where XAuthRandID=?";
|
||||
|
||||
$sql_email = "insert into x_email_outbox(XEmailOutboxSubject,XEmailOutboxSender,XEmailOutboxRecipients,
|
||||
XEmailOutboxCc, XEmailOutboxIsHtml, XEmailOutboxBody)
|
||||
values(?,?,?, ?,?,?)";
|
||||
|
||||
$subject = "Pemberitahuan CpOne Akses";
|
||||
$sender = json_encode(["name" => "CpOne SAS", "email" => "sascpone@gmail.com"]);
|
||||
$tpl_body = "<h4>Pemberitahuan CpOne Akses</h4>
|
||||
<br/>
|
||||
{NAME},<br/>
|
||||
Bersama ini kami ingin memberitahukan akses CpOne, sebagai berikut
|
||||
Laman : https://devcpone.aplikasi.web.id/
|
||||
Username : {EMAIL}
|
||||
Password : {PASS}
|
||||
<br/>
|
||||
Terima Kasih.
|
||||
|
||||
|
||||
*) Email ini autogenerated by system.
|
||||
";
|
||||
$total = 0;
|
||||
foreach ($rows as $idx => $r) {
|
||||
$corpID = $r["T_OrderHeaderCorporateID"];
|
||||
$patID = $r["T_OrderHeaderM_PatientID"];
|
||||
$email = $r["M_PatientEmail"];
|
||||
$qry = $this->db->query($sql_c, [$corpID, $patID]);
|
||||
if (!$qry) {
|
||||
echo json_encode(["status" => "ERR", "message" => print_r($this->db->error(), true)]);
|
||||
$this->db->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
$c_rows = $qry->result_array();
|
||||
if (count($c_rows) > 0) {
|
||||
continue;
|
||||
}
|
||||
$xid = $x_rows[$idx]["XAuthRandID"];
|
||||
$o_passwd = $this->one_salt . $x_rows[$idx]["XAuthRandCode"] . $this->one_salt;
|
||||
$passwd = md5($o_passwd);
|
||||
$qry = $this->db->query($sql_i, [$corpID, $patID, $email, $passwd]);
|
||||
if (!$qry) {
|
||||
echo json_encode(["status" => "ERR", "message" => print_r($this->db->error(), true)]);
|
||||
$this->db->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
$qry = $this->db->query($sql_u, [$xid]);
|
||||
if (!$qry) {
|
||||
echo json_encode(["status" => "ERR", "message" => print_r($this->db->error(), true)]);
|
||||
$this->db->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
$recipients = json_encode(["name" => $r["M_PatientName"], "email" => $r["M_PatientEmail"]]);
|
||||
$cc = json_encode([]);
|
||||
$body = str_replace("{NAME}", $r["M_PatientName"], $tpl_body);
|
||||
$body = str_replace("{EMAIL}", $r["M_PatientEmail"], $body);
|
||||
$body = str_replace("{PASS}", $x_rows[$idx]["XAuthRandCode"], $body);
|
||||
$qry = $this->db->query($sql_email, [$subject, $sender, $recipients, $cc, "Y", $body]);
|
||||
|
||||
if (!$qry) {
|
||||
echo json_encode(["status" => "ERR", "message" => print_r($this->db->error(), true)]);
|
||||
$this->db->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
$total++;
|
||||
}
|
||||
$sql = "update x_auth_rand set XAuthRandIsUsed='N' where XAuthRandIsUsed = 'P'";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
echo json_encode(["status" => "ERR", "message" => print_r($this->db->error(), true)]);
|
||||
$this->db->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_commit();
|
||||
echo json_encode(["status" => "OK", "message" => "$total added"]);
|
||||
}
|
||||
}
|
||||
61
application/controllers/tools/Backup.php
Normal file
61
application/controllers/tools/Backup.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
class Backup extends MY_Controller {
|
||||
var $backup_folder;
|
||||
function __construct(){
|
||||
parent::__construct();
|
||||
$this->backup_folder = "/data-sda/backup-db/";
|
||||
}
|
||||
public function list_backup() {
|
||||
$cpones = glob($this->backup_folder . 'cpone/*');
|
||||
$cpone_logs = glob($this->backup_folder . 'cpone_log/*');
|
||||
// Recursive function to scan files
|
||||
$files = [];
|
||||
$files["cpone"]= [];
|
||||
foreach ($cpones as $file) {
|
||||
if (is_file($file)) {
|
||||
$files["cpone"][] = [
|
||||
'name' => basename($file),
|
||||
'full_path'=> $file,
|
||||
'last_modified' => date("Y-m-d H:i:s", filemtime($file)),
|
||||
'size' => $this->formatSize(filesize($file))
|
||||
];
|
||||
} else {
|
||||
echo $file . " not file\n";
|
||||
}
|
||||
}
|
||||
|
||||
$files["cpone_log"]= [];
|
||||
foreach ($cpone_logs as $file) {
|
||||
if (is_file($file)) {
|
||||
$files["cpone_log"][] = [
|
||||
'name' => basename($file),
|
||||
'full_path'=> $file,
|
||||
'last_modified' => date("Y-m-d H:i:s", filemtime($file)),
|
||||
'size' => $this->formatSize(filesize($file))
|
||||
];
|
||||
}
|
||||
}
|
||||
// Sort files by last modified date descending
|
||||
usort($files["cpone"], function($a, $b) {
|
||||
return strtotime($b['last_modified']) - strtotime($a['last_modified']);
|
||||
});
|
||||
usort($files["cpone_log"], function($a, $b) {
|
||||
return strtotime($b['last_modified']) - strtotime($a['last_modified']);
|
||||
});
|
||||
|
||||
// Return JSON response
|
||||
echo json_encode(["status"=>"OK","result"=>$files]);
|
||||
}
|
||||
|
||||
private function formatSize($size) {
|
||||
$units = ['B', 'KB', 'MB', 'GB', 'TB'];
|
||||
$i = 0;
|
||||
while ($size >= 1024 && $i < count($units) - 1) {
|
||||
$size /= 1024;
|
||||
$i++;
|
||||
}
|
||||
return round($size, 2) . ' ' . $units[$i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
54
application/controllers/tools/Billissueemaillog.php
Normal file
54
application/controllers/tools/Billissueemaillog.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
class Billissueemaillog extends MY_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
function show($logfile) {
|
||||
$fp = file_get_contents("/xtmp/{$logfile}.log");
|
||||
$arr = explode("\n", $fp);
|
||||
$arr = array_slice($arr, -1000);
|
||||
$arr = array_reverse($arr);
|
||||
$msg = implode("\n", $arr);
|
||||
echo "<pre>$msg</pre>";
|
||||
}
|
||||
function read_log($logfile)
|
||||
{
|
||||
$fp = fopen("/xtmp/{$logfile}.log", 'r');
|
||||
$pos = -1; // Skip final new line character (Set to -1 if not present)
|
||||
|
||||
$lines = array();
|
||||
$currentLine = '';
|
||||
$idx = 0;
|
||||
$msg = "<pre>";
|
||||
while (-1 !== fseek($fp, $pos, SEEK_END)) {
|
||||
$char = fgetc($fp);
|
||||
if (PHP_EOL == $char) {
|
||||
$msg .= $currentLine;
|
||||
echo $msg;
|
||||
$currentLine = '';
|
||||
} else {
|
||||
$currentLine = $char . $currentLine;
|
||||
}
|
||||
$pos--;
|
||||
$idx++;
|
||||
if ($idx > 1000) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
$msg .= "</pre>";
|
||||
return $msg;
|
||||
}
|
||||
function index()
|
||||
{
|
||||
|
||||
$fp = file_get_contents("/xtmp/aging_on_hold_reminder.log");
|
||||
$arr = explode("\n", $fp);
|
||||
$arr = array_slice($arr, -500);
|
||||
$arr = array_reverse($arr);
|
||||
$msg = implode("\n", $arr);
|
||||
echo "<pre>$msg</pre>";
|
||||
}
|
||||
}
|
||||
54
application/controllers/tools/Billissuelog.php
Normal file
54
application/controllers/tools/Billissuelog.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
class Billissuelog extends MY_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
function show($logfile) {
|
||||
$fp = file_get_contents("/xtmp/{$logfile}.log");
|
||||
$arr = explode("\n", $fp);
|
||||
$arr = array_slice($arr, -1000);
|
||||
$arr = array_reverse($arr);
|
||||
$msg = implode("\n", $arr);
|
||||
echo "<pre>$msg</pre>";
|
||||
}
|
||||
function read_log($logfile)
|
||||
{
|
||||
$fp = fopen("/xtmp/{$logfile}.log", 'r');
|
||||
$pos = -1; // Skip final new line character (Set to -1 if not present)
|
||||
|
||||
$lines = array();
|
||||
$currentLine = '';
|
||||
$idx = 0;
|
||||
$msg = "<pre>";
|
||||
while (-1 !== fseek($fp, $pos, SEEK_END)) {
|
||||
$char = fgetc($fp);
|
||||
if (PHP_EOL == $char) {
|
||||
$msg .= $currentLine;
|
||||
echo $msg;
|
||||
$currentLine = '';
|
||||
} else {
|
||||
$currentLine = $char . $currentLine;
|
||||
}
|
||||
$pos--;
|
||||
$idx++;
|
||||
if ($idx > 1000) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
$msg .= "</pre>";
|
||||
return $msg;
|
||||
}
|
||||
function index()
|
||||
{
|
||||
|
||||
$fp = file_get_contents("/xtmp/aging_on_hold.log");
|
||||
$arr = explode("\n", $fp);
|
||||
$arr = array_slice($arr, -500);
|
||||
$arr = array_reverse($arr);
|
||||
$msg = implode("\n", $arr);
|
||||
echo "<pre>$msg</pre>";
|
||||
}
|
||||
}
|
||||
68
application/controllers/tools/Booking_comp.php
Normal file
68
application/controllers/tools/Booking_comp.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
class Booking_comp extends MY_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
function get($code)
|
||||
{
|
||||
$sql = "select m_branch.*,M_CityName
|
||||
from m_branch
|
||||
join m_city on M_BranchM_CityID = M_CityID
|
||||
where M_BranchIsActive = 'Y' and M_BranchIsDefault='Y'";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
echo json_encode(["status" => "ERR", "message" => "Err " .
|
||||
$this->db->error()["message"]]);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo json_encode(["status" => "ERR",
|
||||
"message" => "No Default Branch" ]);
|
||||
exit;
|
||||
}
|
||||
$branchName = $rows[0]["M_BranchName"];
|
||||
$branchAddress = $rows[0]["M_BranchAddress"];
|
||||
$branchCity = $rows[0]["M_CityName"];
|
||||
$sql = "select
|
||||
FutureOrderNumber,
|
||||
M_TitleName, M_PatientPrefix,
|
||||
M_PatientName, M_PatientSuffix
|
||||
from future_order
|
||||
join m_patient on
|
||||
FutureOrderNumber=?
|
||||
and FutureOrderM_PatientID = M_PatientID
|
||||
join m_title on M_PatientM_TitleID = M_TitleID";
|
||||
$qry = $this->db->query($sql,[$code]);
|
||||
if (!$qry) {
|
||||
echo json_encode(["status" => "ERR", "message" => "Err " .
|
||||
$this->db->error()["message"]]);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows)==0){
|
||||
echo json_encode(["status" => "ERR",
|
||||
"message" => "Kode Booking $code not found." ]);
|
||||
exit;
|
||||
}
|
||||
$r = $rows[0];
|
||||
$patient = $r["M_TitleName"];
|
||||
if ($r["M_PatientPrefix"] != "") {
|
||||
if ($patient!= "") $patient .= " " .$r["M_PatientPrefix"];
|
||||
}
|
||||
if ($r["M_PatientName"] != "") {
|
||||
if ($patient!= "") $patient .= " " .$r["M_PatientName"];
|
||||
}
|
||||
if ($r["M_PatientSuffix"] != "") {
|
||||
if ($patient!= "") $patient .= " " .$r["M_PatientSuffix"];
|
||||
}
|
||||
echo json_encode([
|
||||
"branchName"=> $branchName,
|
||||
"branchCity"=> $branchCity,
|
||||
"branchAddress"=> $branchAddress,
|
||||
"patient"=> $patient
|
||||
]);
|
||||
}
|
||||
}
|
||||
11
application/controllers/tools/Broadcast.php
Normal file
11
application/controllers/tools/Broadcast.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
class Broadcast extends MY_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function msg($prm) {
|
||||
$this->broadcast($prm);
|
||||
}
|
||||
}
|
||||
360
application/controllers/tools/Check_on_hold.php
Normal file
360
application/controllers/tools/Check_on_hold.php
Normal file
@@ -0,0 +1,360 @@
|
||||
<?php
|
||||
class Check_on_hold extends MY_Controller
|
||||
{
|
||||
//re-upload to devone
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
function lokal()
|
||||
{
|
||||
echo "<H4>Tagihan Lokal Hold Status</H4><br/>";
|
||||
$mou_id = "0";
|
||||
$query = "SELECT GROUP_CONCAT(M_MouID SEPARATOR ',') as mou_id
|
||||
FROM
|
||||
(SELECT
|
||||
distinct
|
||||
M_MouID
|
||||
FROM
|
||||
f_bill_issue
|
||||
join f_bill on F_BillIssueF_BillID = F_BillID
|
||||
and F_BillIsActive = 'Y'
|
||||
join m_mou on M_MouID = F_BillIssueM_MouID
|
||||
and F_BillIssueIsAllMou = 'N'
|
||||
and M_MouIsActive = 'H'
|
||||
and F_BillIssueIsActive = 'Y'
|
||||
and F_BillIssueIsLunas = 'N'
|
||||
and F_BillIssueIsReceive = 'Y'
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
|
||||
union
|
||||
SELECT
|
||||
distinct
|
||||
M_MouID
|
||||
FROM
|
||||
f_bill_issue
|
||||
join f_bill on F_BillIssueF_BillID = F_BillID
|
||||
and F_BillIsActive = 'Y'
|
||||
join f_bill_mou on F_BillIssueF_BillID = F_BillMouF_BillID
|
||||
join m_mou on M_MouID = F_BillMouM_MouID
|
||||
and F_BillIssueIsAllMou = 'Y'
|
||||
and M_MouIsActive = 'H'
|
||||
and F_BillIssueIsActive = 'Y'
|
||||
and F_BillIssueIsLunas = 'N'
|
||||
and F_BillIssueIsReceive = 'Y'
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID) a;";
|
||||
$mou_id = $this->db->query($query)->row()->mou_id;
|
||||
|
||||
$sql = "select
|
||||
M_CompanyName,
|
||||
M_MouName, F_BillNo, M_MouID, F_BillID ,
|
||||
max(F_PaymentDate) PaymentDate,'' Aktivasi,F_BillIssueIsAllMou
|
||||
from m_mou
|
||||
join m_company on M_MouIsActive = 'H'
|
||||
and M_MouM_CompanyID = M_CompanyID
|
||||
and M_MouM_BillTypeID = 3
|
||||
join f_bill_issue ON F_BillIssueM_MouID = M_MouID and F_BillIssueIsAllMou = 'N' AND F_BillIssueIsActive = 'Y'
|
||||
join f_bill on F_BillID = F_BillIssueF_BillID
|
||||
and F_BillIsActive = 'Y' and F_BillIsLunas = 'Y'
|
||||
join f_bill_detail on F_BillID = F_BillDetailF_BillID
|
||||
and F_BillDetailIsActive = 'Y'
|
||||
join f_payment on F_BillDetailT_OrderHeaderID = F_PaymentT_OrderHeaderID
|
||||
and F_PaymentIsActive = 'Y'
|
||||
where M_MouID NOT IN($mou_id)
|
||||
group by M_MouID,F_BillID
|
||||
union
|
||||
select
|
||||
M_CompanyName,
|
||||
M_MouName, F_BillNo, M_MouID, F_BillID ,
|
||||
max(F_PaymentDate) PaymentDate,'' Aktivasi, F_BillIssueIsAllMou
|
||||
from m_mou
|
||||
join m_company on M_MouIsActive = 'H'
|
||||
and M_MouM_CompanyID = M_CompanyID
|
||||
and M_MouM_BillTypeID = 3
|
||||
join f_bill_issue ON F_BillIssueM_MouID = M_MouID and F_BillIssueIsAllMou = 'Y' AND F_BillIssueIsActive = 'Y'
|
||||
join f_bill_mou on F_BillIssueF_BillID = F_BillMouF_BillID AND M_MouID = F_BillMouM_MouID
|
||||
join f_bill on F_BillID = F_BillIssueF_BillID
|
||||
and F_BillIsActive = 'Y' and F_BillIsLunas = 'Y'
|
||||
join f_bill_detail on F_BillID = F_BillDetailF_BillID
|
||||
and F_BillDetailIsActive = 'Y'
|
||||
join f_payment on F_BillDetailT_OrderHeaderID = F_PaymentT_OrderHeaderID
|
||||
and F_PaymentIsActive = 'Y'
|
||||
where M_MouID NOT IN($mou_id)
|
||||
group by M_MouID,F_BillID
|
||||
order by M_MouID
|
||||
";
|
||||
$qry = $this->db->query($sql);
|
||||
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => $this->db->error()["message"],
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
echo $this->print_table_style();
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo "No Data";
|
||||
}
|
||||
foreach ($rows as $idx => $r) {
|
||||
$url_fix = "/one-api/tools/check_on_hold/lokal_fix/" . $r["M_MouID"];
|
||||
$rows[$idx][
|
||||
"Aktivasi"
|
||||
] = "<button onClick=\"document.location.href='{$url_fix}'\"
|
||||
style='padding:5px; color:white; border: solid 0px; border-radius: 5px;
|
||||
background-color:blue; margin-top:20px; display:block;' >Aktivasi</button>";
|
||||
}
|
||||
$this->print_table($rows, array_keys($rows[0]));
|
||||
}
|
||||
|
||||
function index()
|
||||
{
|
||||
echo "<H4>Tagihan Terpusat Hold Status</H4><br/>";
|
||||
$mou_id = "0";
|
||||
$query = "select GROUP_CONCAT(DISTINCT M_MouID SEPARATOR ',') as mou_id
|
||||
from mou_hold_status
|
||||
join m_mou on MouHoldStatusM_MouID = M_MouID
|
||||
and M_MouIsActive = 'H'
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
join f_bill on MouHoldStatusF_BillID = F_BillID
|
||||
and F_BillIsActive = 'Y' and F_BillIsLunas = 'N'
|
||||
join f_bill_detail on F_BillID = F_BillDetailF_BillID
|
||||
and F_BillDetailIsActive = 'Y';";
|
||||
$mou_id = $this->db->query($query)->row()->mou_id;
|
||||
$sql = "select MouHoldStatusPusatBranchCode
|
||||
CabangTitipanPusat,
|
||||
MouHoldStatusDueDate DueDate,
|
||||
min(MouHoldStatusHoldDate) HoldDate,
|
||||
max(F_PaymentDate) PaymentDate,
|
||||
M_CompanyName,
|
||||
M_MouName,
|
||||
F_BillNo, M_MouID, F_BillID ,
|
||||
group_concat(distinct MouHoldStatusRefNumber) BillPusatRefNumber,
|
||||
'' Aktivasi
|
||||
from mou_hold_status
|
||||
join m_mou on MouHoldStatusM_MouID = M_MouID
|
||||
and M_MouIsActive = 'H'
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
join f_bill on MouHoldStatusF_BillID = F_BillID
|
||||
and F_BillIsActive = 'Y' and F_BillIsLunas = 'Y'
|
||||
join f_bill_detail on F_BillID = F_BillDetailF_BillID
|
||||
and F_BillDetailIsActive = 'Y'
|
||||
join f_payment on F_BillDetailT_OrderHeaderID = F_PaymentT_OrderHeaderID
|
||||
and F_PaymentIsActive = 'Y'
|
||||
where M_MouID NOT IN($mou_id)
|
||||
group by M_MouID,F_BillID
|
||||
order by M_MouID
|
||||
";
|
||||
$qry = $this->db->query($sql);
|
||||
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => $this->db->error()["message"],
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
echo $this->print_table_style();
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo "No Data";
|
||||
}
|
||||
foreach ($rows as $idx => $r) {
|
||||
$url_fix = "/one-api/tools/check_on_hold/fix/" . $r["M_MouID"];
|
||||
$rows[$idx][
|
||||
"Aktivasi"
|
||||
] = "<button onClick=\"document.location.href='{$url_fix}'\"
|
||||
style='padding:5px; color:white; border: solid 0px; border-radius: 5px;
|
||||
background-color:blue; margin-top:20px; display:block;' >Aktivasi</button>";
|
||||
}
|
||||
$this->print_table($rows, array_keys($rows[0]));
|
||||
}
|
||||
function check_log_table()
|
||||
{
|
||||
$sql = "select count(*) from hold_open_log";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
$sql = "create table hold_open_log(holdOpenLogID int not null auto_increment primary key,
|
||||
holdOpenLogDate datetime default current_timestamp(),
|
||||
holdOpenLogM_MouID int,
|
||||
holdOpenLogJson text,
|
||||
key(holdOpenLogDate),
|
||||
key(holdOpenLogM_MouID)
|
||||
)";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
echo "Error : " . $this->db->error()["message"];
|
||||
exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function lokal_fix($mouID)
|
||||
{
|
||||
$this->check_log_table();
|
||||
$this->db->trans_begin();
|
||||
$sql_check = "select
|
||||
M_CompanyName,
|
||||
M_MouName, F_BillNo, M_MouID, F_BillID ,
|
||||
max(F_PaymentDate) maxPaymentDate,'' Aktivasi
|
||||
from m_mou
|
||||
join m_company on M_MouIsActive = 'H'
|
||||
and M_MouM_CompanyID = M_CompanyID
|
||||
and M_MouM_BillTypeID = 3 and M_MouID = ?
|
||||
join f_bill on F_BillM_MouID = M_MouID
|
||||
and F_BillIsActive = 'Y' and F_BillIsLunas = 'Y'
|
||||
join f_bill_detail on F_BillID = F_BillDetailF_BillID
|
||||
and F_BillDetailIsActive = 'Y'
|
||||
join f_payment on F_BillDetailT_OrderHeaderID = F_PaymentT_OrderHeaderID
|
||||
and F_PaymentIsActive = 'Y'
|
||||
group by F_BillID
|
||||
";
|
||||
$qryx = $this->db->query($sql_check, [$mouID]);
|
||||
if (!$qryx) {
|
||||
echo "Error : " . $this->db->error()["message"];
|
||||
$this->db->trans_rollback();
|
||||
exit();
|
||||
}
|
||||
$rows = $qryx->result_array();
|
||||
print_r($qryx);
|
||||
print_r($rows);
|
||||
if (count($rows) == 0) {
|
||||
echo "Error : MouID $mouID, tidak memenuhi kriteria <br/> <pre>" .
|
||||
$this->db->last_query();
|
||||
$this->db->trans_rollback();
|
||||
exit();
|
||||
}
|
||||
$dataJson = json_encode($rows);
|
||||
$sql =
|
||||
"insert into hold_open_log(holdOpenLogM_MouID,holdOpenLogJson) values(?,?)";
|
||||
$qry = $this->db->query($sql, [$mouID, $dataJson]);
|
||||
if (!$qry) {
|
||||
echo "Error : " . $this->db->error()["message"];
|
||||
$this->db->trans_rollback();
|
||||
exit();
|
||||
}
|
||||
|
||||
$qry = $this->db->query(
|
||||
"update m_mou set M_MouIsActive = 'Y' where M_MouID = ?",
|
||||
[$mouID]
|
||||
);
|
||||
|
||||
if (!$qry) {
|
||||
echo "Error : " . $this->db->error()["message"];
|
||||
$this->db->trans_rollback();
|
||||
exit();
|
||||
}
|
||||
$this->db->trans_commit();
|
||||
header("Location: /one-api/tools/check_on_hold/lokal");
|
||||
}
|
||||
function fix($mouID)
|
||||
{
|
||||
$this->check_log_table();
|
||||
$this->db->trans_begin();
|
||||
$sql_check = "select MouHoldStatusPusatBranchCode
|
||||
CabangTitipanPusat,
|
||||
min(MouHoldStatusHoldDate) HoldDateMin,
|
||||
max(MouHoldStatusHoldDate) HoldDateMax,
|
||||
MouHoldStatusDueDate DueDate,
|
||||
M_CompanyName,
|
||||
M_MouName, F_BillNo, M_MouID, F_BillID ,
|
||||
max(F_PaymentDate) maxPaymentDate
|
||||
from mou_hold_status
|
||||
join m_mou on MouHoldStatusM_MouID = ?
|
||||
and MouHoldStatusM_MouID = M_MouID
|
||||
and M_MouIsActive = 'H'
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
join f_bill on MouHoldStatusF_BillID = F_BillID
|
||||
and F_BillIsActive = 'Y' and F_BillIsLunas = 'Y'
|
||||
join f_bill_detail on F_BillID = F_BillDetailF_BillID
|
||||
and F_BillDetailIsActive = 'Y'
|
||||
join f_payment on F_BillDetailT_OrderHeaderID = F_PaymentT_OrderHeaderID
|
||||
and F_PaymentIsActive = 'Y'
|
||||
group by F_BillID
|
||||
";
|
||||
$qryx = $this->db->query($sql_check, [$mouID]);
|
||||
if (!$qryx) {
|
||||
echo "Error : " . $this->db->error()["message"];
|
||||
$this->db->trans_rollback();
|
||||
exit();
|
||||
}
|
||||
$rows = $qryx->result_array();
|
||||
print_r($qryx);
|
||||
print_r($rows);
|
||||
if (count($rows) == 0) {
|
||||
echo "Error : MouID $mouID, tidak memenuhi kriteria <br/> <pre>" .
|
||||
$this->db->last_query();
|
||||
$this->db->trans_rollback();
|
||||
exit();
|
||||
}
|
||||
$dataJson = json_encode($rows);
|
||||
$sql =
|
||||
"insert into hold_open_log(holdOpenLogM_MouID,holdOpenLogJson) values(?,?)";
|
||||
$qry = $this->db->query($sql, [$mouID, $dataJson]);
|
||||
if (!$qry) {
|
||||
echo "Error : " . $this->db->error()["message"];
|
||||
$this->db->trans_rollback();
|
||||
exit();
|
||||
}
|
||||
|
||||
$qry = $this->db->query(
|
||||
"update m_mou set M_MouIsActive = 'Y' where M_MouID = ?",
|
||||
[$mouID]
|
||||
);
|
||||
|
||||
if (!$qry) {
|
||||
echo "Error : " . $this->db->error()["message"];
|
||||
$this->db->trans_rollback();
|
||||
exit();
|
||||
}
|
||||
$this->db->trans_commit();
|
||||
header("Location: /one-api/tools/check_on_hold");
|
||||
}
|
||||
function print_table_style()
|
||||
{
|
||||
return "
|
||||
<style>
|
||||
th, td {
|
||||
padding: 15px;
|
||||
text-align: left;
|
||||
}
|
||||
tr:nth-child(even) {background-color: #f2f2f2;}
|
||||
table {
|
||||
border: solid 1px ;
|
||||
min-width:600px;
|
||||
margin-left:auto;
|
||||
margin-right:auto;
|
||||
}
|
||||
</style>
|
||||
";
|
||||
}
|
||||
public function print_table_one_column($rows)
|
||||
{
|
||||
$rst = "<table>";
|
||||
foreach ($rows as $r) {
|
||||
$rst .= "<tr>";
|
||||
$rst .= "<td>" . $r . "</td>";
|
||||
$rst .= "</tr>";
|
||||
}
|
||||
$rst .= "</table>";
|
||||
return $rst;
|
||||
}
|
||||
public function print_table($rows, $keys)
|
||||
{
|
||||
echo "<table>";
|
||||
echo "<tr>";
|
||||
foreach ($keys as $k) {
|
||||
echo "<td>$k</td>";
|
||||
}
|
||||
echo "</tr>\n";
|
||||
foreach ($rows as $r) {
|
||||
echo "<tr>";
|
||||
foreach ($keys as $k) {
|
||||
echo "<td>" . $r[$k] . "</td>";
|
||||
}
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
}
|
||||
579
application/controllers/tools/Check_ref_order.php
Normal file
579
application/controllers/tools/Check_ref_order.php
Normal file
@@ -0,0 +1,579 @@
|
||||
<?php
|
||||
class Check_ref_order extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Cek Ref Order ";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function cek($incomingRefID, $id) {
|
||||
$adminUserID = 3;
|
||||
$id = str_replace("-",",",$id);
|
||||
$sql = "select * from incoming_ref where incomingRefID = ?";
|
||||
$qry = $this->db_onedev->query($sql, array($incomingRefID) );
|
||||
$rows = array();
|
||||
$branchID = 0;
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if ( count($rows) > 0 ) $branchID = $rows[0]["incomingRefM_BranchID"];
|
||||
}
|
||||
|
||||
if ($branchID == 0 ) {
|
||||
echo json_encode(array(
|
||||
"status" => "ERR",
|
||||
"message" => "Branch belum di set"));
|
||||
}
|
||||
$companyID = 0;
|
||||
if ($branchID > 0 ) {
|
||||
$sql = "select *
|
||||
from m_branch where M_BranchID = ?";
|
||||
$qry = $this->db_onedev->query($sql, array($branchID) );
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$companyID = $rows[0]["M_BranchM_CompanyID"];
|
||||
$mouID = $rows[0]["M_BranchM_MouID"];
|
||||
$doctorID = $rows[0]["M_BranchM_DoctorID"];
|
||||
$doctorAddressID = $rows[0]["M_BranchM_DoctorAddressID"];
|
||||
$branchKelurahanID= $rows[0]["M_BranchM_KelurahanID"];
|
||||
$branchAddresss = $rows[0]["M_BranchAddress"];
|
||||
}
|
||||
}
|
||||
if ($companyID == 0 ) {
|
||||
echo json_encode(array(
|
||||
"status" => "ERR",
|
||||
"message" => "Branch / Company/MOU belum di set"));
|
||||
}
|
||||
//create order yg di confirm saja
|
||||
$sql = "select *
|
||||
from incoming_ref_detail
|
||||
where incomingRefDetailID in ( $id )
|
||||
and incomingRefDetailStatus = 'Y'
|
||||
order by incomingRefDetailT_OrderHeaderID";
|
||||
$qry = $this->db_onedev->query($sql );
|
||||
$orders = array();
|
||||
$ax_test = array();
|
||||
$a_promise = array();
|
||||
$a_barcode = array();
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$prev_oh_id = 0;
|
||||
foreach($rows as $r) {
|
||||
$oh_id = $r["incomingRefDetailT_OrderHeaderID"];
|
||||
$incomingRefDetailFoNote = str_replace("'", " ", $r["incomingRefDetailFoNote"]);
|
||||
if ( ! isset($orders[$oh_id]) ) {
|
||||
$orders[$oh_id]["patient"] = json_decode($r["incomingRefDetailPatient"],true);
|
||||
$orders[$oh_id]["foNote"] = $incomingRefDetailFoNote;
|
||||
$orders[$oh_id]["verificationNote"] = $r["incomingRefDetailVefificationNote"];
|
||||
$orders[$oh_id]["samplingNote"] = $r["incomingRefDetailSamplingNote"];
|
||||
$orders[$oh_id]["LabNumber"] = $r["incomingRefDetailT_OrderHeaderLabNumber"];
|
||||
$orders[$oh_id]["test"] = array();
|
||||
}
|
||||
$orders[$oh_id]["test"][] = array (
|
||||
"T_TestID" => $r["incomingRefDetailT_TestID"],
|
||||
"Promise" => $r["incomingRefDetailT_OrderPromiseDateTime"],
|
||||
"T_OrderDetailID" => $r["incomingRefDetailT_OrderDetailID"],
|
||||
"T_BarcodeLabBarcode" => $r["incomingRefDetailT_BarcodeLabBarcode"],
|
||||
"Requirements" => json_decode($r["incomingRefDetailRequirements"],true)
|
||||
);
|
||||
$ax_test[] = $r["incomingRefDetailT_TestID"];
|
||||
$a_promise[$oh_id][$r["incomingRefDetailT_TestID"]] = $r["incomingRefDetailT_OrderPromiseDateTime"];
|
||||
$a_barcode[$oh_id][$r["incomingRefDetailT_TestID"]] = $r["incomingRefDetailT_BarcodeLabBarcode"];
|
||||
}
|
||||
}
|
||||
$s_test = "0," . join(",",$ax_test);
|
||||
$sql = "select * from ss_price_mou
|
||||
where Ss_PriceMouM_MouID = ? and T_TestID in ( $s_test ) ";
|
||||
$qry = $this->db_onedev->query($sql, array($mouID) );
|
||||
//test primer sama dengan T_TestID
|
||||
$a_test = array();
|
||||
if ($qry ) {
|
||||
$rows = $qry->result_array();
|
||||
foreach($rows as $r) {
|
||||
$testID = $r["T_TestID"];
|
||||
$a_test[$testID] = array(
|
||||
"T_PriceAmount" => $r["T_PriceAmount"],
|
||||
"T_PriceDiscRp" => $r["T_PriceDiscRp"],
|
||||
"T_PriceDisc" => $r["T_PriceDisc"]
|
||||
);
|
||||
}
|
||||
}
|
||||
//test sekunder dari Nat_Test
|
||||
$a_test_v2 = array();
|
||||
$sql = "select ss_price_mou.*
|
||||
from ss_price_mou
|
||||
where Ss_PriceMouM_MouID = ? and
|
||||
ss_price_mou.T_TestID in (
|
||||
select s.T_TestID
|
||||
from t_test s
|
||||
join t_test p on s.T_TestNat_TestID = p.T_TestNat_TestID
|
||||
and p.T_TestID in ( $s_test )
|
||||
) ";
|
||||
$qry = $this->db_onedev->query($sql, array($mouID) );
|
||||
//test primer sama dengan T_TestID
|
||||
if ($qry ) {
|
||||
$rows = $qry->result_array();
|
||||
foreach($rows as $r) {
|
||||
$testID = $r["T_TestID"];
|
||||
$a_test_v2[$testID] = array(
|
||||
"T_PriceAmount" => $r["T_PriceAmount"],
|
||||
"T_PriceDiscRp" => $r["T_PriceDiscRp"],
|
||||
"T_PriceDisc" => $r["T_PriceDisc"]
|
||||
);
|
||||
}
|
||||
}
|
||||
$message = "";
|
||||
|
||||
foreach($orders as $oh_id => $o){
|
||||
$noreg = $o["patient"]["M_PatientNoReg"];
|
||||
$lab_number= $o["LabNumber"];
|
||||
//if noreg not exists create patient
|
||||
$sql = "select count(*) tot from m_patient where M_PatientNoReg=? and M_PatientIsActive = 'Y'";
|
||||
$qry = $this->db_onedev->query($sql, array($noreg));
|
||||
$patientID = 0;
|
||||
if($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if ($rows[0]["tot"] == 0 ) {
|
||||
$patientID = $this->create_patient($orders[$oh_id]["patient"], $adminUserID);
|
||||
} else {
|
||||
$patientID = $orders[$oh_id]["patient"]["M_PatientID"];
|
||||
}
|
||||
}
|
||||
if ($patientID == 0 ) {
|
||||
if ($message != "" ) $message .= ",";
|
||||
$message .= "[ $lab_number, gagal buat pasien $noreg ]";
|
||||
continue;
|
||||
}
|
||||
$sql = "select fn_global_age_count(M_PatientDOB,now()) age
|
||||
from m_patient where M_PatientID = ? ";
|
||||
$qry = $this->db_onedev->query($sql, array($patientID) );
|
||||
$patientAge = "";
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$patientAge = $rows[0]["age"];
|
||||
}
|
||||
}
|
||||
//echo "1. $lab_number : $patientID \n";
|
||||
//register order
|
||||
$xheader = array(
|
||||
'patient_id' => $patientID,
|
||||
'age' => $patientAge,
|
||||
'sender_doctor_id' => $doctorID,
|
||||
'sender_address_id' => $doctorAddressID,
|
||||
'company_id' => $companyID,
|
||||
'mou_id' => $mouID,
|
||||
'lang_id' => '1',
|
||||
'lang_si' => 'N',
|
||||
'doctor_note' => '',
|
||||
'fo_note' => $orders[$oh_id]["foNote"],
|
||||
'queue' => '',
|
||||
'received_sample' => 'Y',
|
||||
'lang_id_2' => '2',
|
||||
'lang_si_2' => 'N',
|
||||
);
|
||||
$xdel = array(
|
||||
array(
|
||||
'address_id' => $branchID,
|
||||
'delivery_id' => '10',
|
||||
'delivery_type_id' => '2',
|
||||
'senderdoctorid' => $doctorID,
|
||||
'senderaddressid' => $doctorAddressID,
|
||||
'note' => $branchAddresss,
|
||||
'kelurahan' => $branchKelurahanID
|
||||
));
|
||||
$xdet = array();
|
||||
$reqs = array();
|
||||
foreach($orders[$oh_id]["test"] as $t ) {
|
||||
if ( isset($a_test[$t["T_TestID"]]) ) {
|
||||
$v=$a_test[$t["T_TestID"]];
|
||||
$xdet[] = array(
|
||||
't_id' => $t['T_TestID'],
|
||||
't_cito' => 'N',
|
||||
't_price' => $v['T_PriceAmount'],
|
||||
't_disc' => $v['T_PriceDisc'],
|
||||
't_discrp' => $v['T_PriceDiscRp'],
|
||||
't_req' => 'Y',
|
||||
't_reqnote' => '',
|
||||
't_ispacket' => "N",
|
||||
't_packettype' => "PX",
|
||||
't_packetid' => '0'
|
||||
);
|
||||
} elseif ( isset($a_test_v2["T_TestID"] ) ) {
|
||||
$v=$a_test_v2[$t["T_TestID"]];
|
||||
$xdet[] = array(
|
||||
't_id' => $t['T_TestID'],
|
||||
't_cito' => 'N',
|
||||
't_price' => $v['T_PriceAmount'],
|
||||
't_disc' => $v['T_PriceDisc'],
|
||||
't_discrp' => $v['T_PriceDiscRp'],
|
||||
't_req' => 'Y',
|
||||
't_reqnote' => '',
|
||||
't_ispacket' => "N",
|
||||
't_packettype' => "PX",
|
||||
't_packetid' => '0'
|
||||
);
|
||||
} else {
|
||||
$xdet[] = array(
|
||||
't_id' => $t['T_TestID'],
|
||||
't_cito' => 'N',
|
||||
't_price' => 0,
|
||||
't_disc' => 0,
|
||||
't_discrp' => 0,
|
||||
't_req' => 'Y',
|
||||
't_reqnote' => '',
|
||||
't_ispacket' => "N",
|
||||
't_packettype' => "PX",
|
||||
't_packetid' => '0'
|
||||
);
|
||||
}
|
||||
if (count($t["Requirements"]) > 0 ) {
|
||||
$reqs = array_merge($reqs, $t["Requirements"]);
|
||||
}
|
||||
}
|
||||
//requirements
|
||||
$xreq = array(
|
||||
'status' => 'Y',
|
||||
'reqs' => '[]'
|
||||
);
|
||||
$header_json = addslashes(str_replace('\n', '\\\n', json_encode($xheader)));
|
||||
$delivery_json = addslashes(str_replace('\n', '\\\n', json_encode($xdel)));
|
||||
$detail_json = addslashes(str_replace('\n', '\\\n', json_encode($xdet)));
|
||||
$req_json = json_encode($xreq);
|
||||
$sql = "CALL `sp_fo_register_save_v5`(
|
||||
0,
|
||||
'{$header_json}',
|
||||
'{$delivery_json}',
|
||||
'{$detail_json}',
|
||||
'{$req_json}',
|
||||
'{$adminUserID}'
|
||||
);";
|
||||
//exit sebelum create order
|
||||
echo $sql . "\n";
|
||||
// exit;
|
||||
$r = $this->db_onedev->query($sql)->row();
|
||||
$this->clean_mysqli_connection($this->db_onedev->conn_id);
|
||||
if ($r->status != "OK" ) {
|
||||
if ($message != "" ) $message .= ",";
|
||||
$xmsg = print_r($r, true);
|
||||
$message .= "[ $lab_number, gagal sp_fo_register_save_v5 : $xmsg ]";
|
||||
$g_date = date("Y-m-d H:i:s");
|
||||
file_put_contents("/xtmp/gagal-order.log","$g_date $message\n", FILE_APPEND);
|
||||
continue;
|
||||
}
|
||||
$data = json_decode($r->data,true);
|
||||
$new_oh_id = $data["id"];
|
||||
$new_lab_number= $data["number"];
|
||||
|
||||
//echo "2. $new_oh_id : $lab_number => $new_lab_number \n";
|
||||
//update incoming_ref
|
||||
$sql = "update incoming_ref_detail set incomingRefDetailNewT_OrderHeaderID=?,
|
||||
incomingRefDetailNewM_PatientID = ?
|
||||
where incomingRefDetailIncomingRefID = ?
|
||||
and incomingRefDetailT_OrderHeaderID=?";
|
||||
$this->db_onedev->query($sql,array($new_oh_id, $patientID, $incomingRefID, $oh_id));
|
||||
|
||||
$sql = "update t_orderheaderaddon set T_OrderHeaderAddOnLabNumberOrigin=?
|
||||
where T_OrderHeaderAddOnT_OrderHeaderID = ?";
|
||||
$this->db_onedev->query($sql,array($lab_number,$new_oh_id));
|
||||
|
||||
|
||||
//update promise
|
||||
$a_promise_test = array();
|
||||
$a_promise_date= array();
|
||||
$a_promise_id= array();
|
||||
foreach($a_promise[$oh_id] as $testID => $promise ) {
|
||||
if(!isset($a_promise_date[$promise])) {
|
||||
$sql = "insert into t_orderpromise(T_OrderPromiseT_OrderHeaderID, T_OrderPromiseDateTime)
|
||||
values(?,?)";
|
||||
$this->db_onedev->query($sql, array($new_oh_id,$promise));
|
||||
$promise_id = $this->db_onedev->insert_id();
|
||||
$a_promise_test[$testID] = $promise_id;
|
||||
$a_promise_date["$promise"] = $promise_id;
|
||||
} else {
|
||||
$a_promise_test[$testID] = $a_promise_date["$promise"];
|
||||
}
|
||||
}
|
||||
if ( count($a_promise_test) > 0 ) {
|
||||
$s_test = join(",", array_keys($a_promise_test));
|
||||
$sql = "update t_orderpromise,t_orderdetail
|
||||
set T_OrderPromiseIsActive = 'N'
|
||||
where T_OrderPromiseID = T_OrderDetailT_OrderPromiseID
|
||||
and T_OrderDetailT_OrderHeaderID = ?
|
||||
and T_OrderDetailT_TestID in ($s_test) ";
|
||||
$this->db_onedev->query($sql, array($new_oh_id));
|
||||
}
|
||||
foreach($a_promise_test as $testID => $promiseID ) {
|
||||
$sql = "update t_orderdetail
|
||||
set T_OrderDetailT_OrderPromiseID= ?
|
||||
where T_OrderDetailT_OrderHeaderID = ?
|
||||
and T_OrderDetailT_TestID = ? ";
|
||||
$this->db_onedev->query($sql, array($promiseID , $new_oh_id, $testID) );
|
||||
}
|
||||
//insert requirements
|
||||
foreach($reqs as $r) {
|
||||
$sql ="insert into t_orderreq(T_OrderReqT_OrderHeaderID,T_OrderReqNat_PositionID,
|
||||
T_OrderReqStatus, T_OrderReqT_TestID, T_OrderReqs)
|
||||
values(?,?, ?,?,?)";
|
||||
$this->db_onedev->query($sql, array($new_oh_id, $r["T_OrderReqNat_PositionID"],
|
||||
$r["T_OrderReqStatus"], $r["T_OrderReqT_TestID"], $r["T_OrderReqs"] ));
|
||||
}
|
||||
//update note
|
||||
$sql = "update t_orderheader
|
||||
set T_OrderHeaderFoNote = ? , T_OrderHeaderFoNoteM_UserID = ?,
|
||||
T_OrderHeaderSamplingNote = ?, T_OrderHeaderSamplingNoteM_UserID = ?,
|
||||
T_OrderHeaderVerificationNote = ?, T_OrderHeaderVerificationNoteM_UserID = ?
|
||||
where T_OrderHeaderID = ? ";
|
||||
$this->db_onedev->query($sql, array( $o["foNote"],$adminUserID,
|
||||
$o["samplingNote"], $adminUserID, $o["verificationNote"], $adminUserID,
|
||||
$new_oh_id));
|
||||
$result = $this->fo_verify($new_oh_id,$adminUserID);
|
||||
|
||||
//update t_barcodelab
|
||||
foreach($a_barcode[$oh_id] as $testID => $barcode) {
|
||||
$sql = "update t_barcodelab,t_test
|
||||
set T_BarcodeLabBarcodeOrigin =?
|
||||
where T_BarcodeLabT_OrderHeaderID = ?
|
||||
and T_TestID = ?
|
||||
and T_TestIsActive = 'Y' and T_BarcodeLabT_SampleTypeID = T_TestT_SampleTypeID";
|
||||
$this->db_onedev->query($sql, array($barcode, $new_oh_id, $testID));
|
||||
}
|
||||
|
||||
// update nilai normal
|
||||
$sql = "select distinct T_OrderDetailT_OrderHeaderID id,
|
||||
T_TestT_SampleTypeID sid
|
||||
from t_orderdetail
|
||||
join t_test on T_OrderDetailT_OrderHeaderID = ?
|
||||
and T_OrderDetailIsActive = 'Y' and
|
||||
T_OrderDetailT_TestID = T_TestID
|
||||
and T_TestIsActive = 'Y' ";
|
||||
$qry = $this->db_onedev->query($sql, array($new_oh_id));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
foreach($rows as $r) {
|
||||
$sql = "call sp_sampling_set_normal(?,?)";
|
||||
$this->db_onedev->query($sql,array($r["id"],$r["sid"]));
|
||||
}
|
||||
}
|
||||
if ($message != "" ) $message .= ",";
|
||||
$message .= "[ $lab_number -> $new_lab_number Fo Verify : $result ]";
|
||||
}
|
||||
try {
|
||||
//update child test
|
||||
$sql = "update incoming_ref_child, incoming_ref_detail
|
||||
set incomingRefChildNewT_OrderHeaderID = incomingRefDetailNewT_OrderHeaderID
|
||||
where incomingRefChildIncomingRefID = incomingRefDetailIncomingRefID
|
||||
and incomingRefChildT_OrderHeaderID = incomingRefDetailT_OrderHeaderID
|
||||
and incomingRefChildNewT_OrderHeaderID is null
|
||||
and incomingRefChildIncomingRefID = ? ";
|
||||
$this->db_onedev->query($sql,array($incomingRefID));
|
||||
} catch(Exception $e) {
|
||||
echo "Err Update Child Test \n";
|
||||
print_r($e);
|
||||
}
|
||||
try {
|
||||
//update barcode
|
||||
$sql = "update incoming_ref_detail, t_test, t_barcodelab
|
||||
set T_BarcodeLabBarcodeOrigin = incomingRefDetailT_BarcodeLabBarcode
|
||||
where
|
||||
incomingRefDetailT_TestID = T_TestID
|
||||
and incomingRefDetailNewT_OrderHeaderID = T_BarcodeLabT_OrderHeaderID
|
||||
and T_BarcodeLabT_SampleTypeID =
|
||||
json_extract(fn_worklist_get_info(incomingRefDetailNewT_OrderHeaderID,T_TestID), '$.sampleTypeID')
|
||||
and incomingRefDetailIncomingRefID = ?
|
||||
and T_TestT_SampleTypeID = 0
|
||||
and T_BarcodeLabBarcodeOrigin is null";
|
||||
$this->db_onedev->query($sql,array($incomingRefID));
|
||||
} catch(Exception $e) {
|
||||
echo "Err Update Barcode \n";
|
||||
print_r($e);
|
||||
}
|
||||
echo json_encode(array( "status" => "OK",
|
||||
"message" => $message ));
|
||||
}
|
||||
function create_patient($p, $userID) {
|
||||
$sql = "insert into m_patient";
|
||||
//check title
|
||||
$sql = "select M_TitleID from m_title where M_TitleName = ? and M_TitleIsActive = 'Y'";
|
||||
$qry = $this->db_onedev->query($sql, array($p["title"]["M_TitleName"]));
|
||||
$titleID = 0;
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) $titleID = $rows[0]["M_TitleID"];
|
||||
}
|
||||
if ($titleID == 0) {
|
||||
$sql = "insert into m_title(M_TitleName, M_TitleM_SexID) values ( ? , ? )";
|
||||
$qry = $this->db_onedev->query($sql, array($p["title"]["M_TitleName"], $p["title"]["M_TitleM_SexID"]));
|
||||
if ($qry) {
|
||||
$titleID = $this->db_onedev->insert_id();
|
||||
}
|
||||
}
|
||||
if ($titleID == 0 ) {
|
||||
return 0;
|
||||
}
|
||||
$patient_name = str_replace("'", "\\'", $p['M_PatientName']);
|
||||
$pdob = date('Y-m-d',strtotime($p['M_PatientDOB']));
|
||||
$query ="INSERT INTO m_patient (
|
||||
M_PatientM_TitleID,
|
||||
M_PatientName,
|
||||
M_PatientDOB,
|
||||
M_PatientM_SexID,
|
||||
M_PatientM_ReligionID,
|
||||
M_PatientEmail,
|
||||
M_PatientPOB,
|
||||
M_PatientHP,
|
||||
M_PatientPhone,
|
||||
M_PatientM_IdTypeID,
|
||||
M_PatientIDNumber,
|
||||
M_PatientNote,
|
||||
M_PatientUserID
|
||||
)
|
||||
VALUES(
|
||||
'{$titleID}',
|
||||
'{$patient_name}',
|
||||
'{$pdob}',
|
||||
'{$p['M_PatientM_SexID']}',
|
||||
'{$p['M_PatientM_ReligionID']}',
|
||||
'{$p['M_PatientEmail']}',
|
||||
'{$p['M_PatientPOB']}',
|
||||
'{$p['M_PatientHP']}',
|
||||
'{$p['M_PatientPhone']}',
|
||||
'{$p['M_PatientM_IdTypeID']}',
|
||||
'{$p['M_PatientIDNumber']}',
|
||||
'{$p['M_PatientNote']}',
|
||||
$userID
|
||||
)";
|
||||
$qry = $this->db_onedev->query($query);
|
||||
$patientID = 0;
|
||||
if ($qry ) {
|
||||
$patientID = $this->db_onedev->insert_id();
|
||||
}
|
||||
echo $this->db_onedev->last_query();
|
||||
//
|
||||
|
||||
$sql = "insert into m_patientaddress(M_PatientAddressM_PatientID, M_PatientAddressNote,
|
||||
M_PatientAddressDescription,M_PatientAddressLocation,M_PatientAddressM_KelurahanID,
|
||||
M_PatientAddressOldCityID, M_PatientAddressPostCodeID, M_PatientAddressFax,
|
||||
M_PatientAddressEmail, M_PatientAddressPhone)
|
||||
values(?,?, ?,?,?, ?,?,?, ?,?) ";
|
||||
foreach($p["address"] as $adr) {
|
||||
$address_description = str_replace("'", "\\'", $adr['M_PatientAddressDescription']);
|
||||
$prm = array($patientID , $adr["M_PatientAddressNote"],
|
||||
$address_description,$adr["M_PatientAddressLocation"],$adr["M_PatientAddressM_KelurahanID"],
|
||||
$adr["M_PatientAddressOldCityID"], $adr["M_PatientAddressPostCodeID"], $adr["M_PatientAddressFax"],
|
||||
$adr["M_PatientAddressEmail"], $adr["M_PatientAddressPhone"] );
|
||||
$this->db_onedev->query($sql,$prm);
|
||||
}
|
||||
|
||||
return $patientID;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function fo_verify($orderID,$userID) {
|
||||
$sql="INSERT INTO fo_verificationsvalue (
|
||||
Fo_VerificationsValueT_OrderHeaderID,
|
||||
Fo_VerificationsValueFo_VerificationsLabelID,
|
||||
Fo_VerificationsValueCheck,
|
||||
Fo_VerificationsValueNote,
|
||||
Fo_VerificationsValueUserID,
|
||||
Fo_VerificationsValueCreated )
|
||||
SELECT {$orderID},
|
||||
Fo_VerificationsLabelID,
|
||||
'Y',
|
||||
'', {$userID},
|
||||
NOW()
|
||||
FROM fo_verificationslabel
|
||||
WHERE
|
||||
Fo_VerificationsLabelIsActive = 'Y' ";
|
||||
$this->db_onedev->query($sql);
|
||||
|
||||
$sql = "call sp_fo_barcode_generate({$orderID})";
|
||||
$this->db_onedev->query($sql);
|
||||
|
||||
$fostatusid = 3;
|
||||
$fologcode = 'FO.VERIFICATION.CONFIRM';
|
||||
|
||||
$sql = "insert into fo_status(
|
||||
Fo_StatusDate,
|
||||
Fo_StatusT_OrderHeaderID,
|
||||
Fo_StatusM_StatusID,
|
||||
Fo_StatusM_UserID,
|
||||
Fo_StatusCreated,
|
||||
Fo_StatusUpdated)
|
||||
values( now(), ?, ?, ?, now(),now())";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$orderID,
|
||||
$fostatusid, $userID
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
return "Error Fo Status";
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM fo_verificationsvalue WHERE Fo_VerificationsValueT_OrderHeaderID = {$orderID}";
|
||||
|
||||
$data_log = array();
|
||||
$data_log['orderid'] = $orderID;
|
||||
$data_log['values'] = $this->db_onedev->query($sql)->result_array();
|
||||
$data_log['note'] = '';
|
||||
|
||||
$json_dt_log = json_encode($data_log);
|
||||
$sql = "insert into one_log.log_fo(
|
||||
Log_FoDate,
|
||||
Log_FoCode,
|
||||
Log_FoJson,
|
||||
Log_FoUserID)
|
||||
values( now(), ?, ?, ?)";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$fologcode,
|
||||
$json_dt_log,
|
||||
$userID
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
return "Error Fo Log";
|
||||
}
|
||||
|
||||
/* T_OrderSample */
|
||||
$adminUserID = $userID;
|
||||
$sql = "update t_ordersample
|
||||
set T_OrderSampleSampling='Y', T_OrderSampleSamplingDate = now(),
|
||||
T_OrderSampleSamplingTime = now(),T_OrderSampleSamplingUserID = $adminUserID,
|
||||
T_OrderSampleReceive='Y', T_OrderSampleReceiveDate = now() , T_OrderSampleReceiveTime = now(),
|
||||
T_OrderSampleReceiveUserID = $adminUserID,
|
||||
T_OrderSampleVerification='Y', T_OrderSampleVerificationDate=now(), T_OrderSampleVerificationTime=now(),
|
||||
T_OrderSampleVerificationUserID = $adminUserID,
|
||||
T_OrderSampleSendHandling = 'Y', T_OrderSampleSendHandlingDate =now(), T_OrderSampleSendHandlingTime=now(),
|
||||
T_OrderSampleSendHandlingUserID = $adminUserID,
|
||||
T_OrderSampleReceiveHandling = 'Y', T_OrderSampleReceiveHandlingDate=now(), T_OrderSampleReceiveHandlingTime=now(),
|
||||
T_OrderSampleReceiveHandlingUserID=$adminUserID,
|
||||
T_OrderSampleHandling='Y', T_OrderSampleHandlingDate=now(), T_OrderSampleHandlingTime=now(),
|
||||
T_OrderSampleHandlingUserID=$adminUserID,
|
||||
T_OrderSampleProcessing='Y', T_OrderSampleReadyToProcessDateTime=now(), T_OrderSampleProcessingDate=now(),
|
||||
T_OrderSampleProcessingTime=now(), T_OrderSampleProcessingUserID=$adminUserID,
|
||||
T_OrderSampleUserID=$adminUserID
|
||||
where T_OrderSampleT_OrderHeaderID = ?";
|
||||
|
||||
|
||||
$qry = $this->db_onedev->query($sql, array($orderID) );
|
||||
if (!$qry) {
|
||||
return "Error T_OrderSample : " . $this->db_onedev->last_query();
|
||||
}
|
||||
return "OK";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
115
application/controllers/tools/Check_verify.php
Normal file
115
application/controllers/tools/Check_verify.php
Normal file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
class Check_verify extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Cek Verify ";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function fo_verify($orderID,$userID) {
|
||||
$sql="INSERT INTO fo_verificationsvalue (
|
||||
Fo_VerificationsValueT_OrderHeaderID,
|
||||
Fo_VerificationsValueFo_VerificationsLabelID,
|
||||
Fo_VerificationsValueCheck,
|
||||
Fo_VerificationsValueNote,
|
||||
Fo_VerificationsValueUserID,
|
||||
Fo_VerificationsValueCreated )
|
||||
SELECT {$orderID},
|
||||
Fo_VerificationsLabelID,
|
||||
'Y',
|
||||
'', {$userID},
|
||||
NOW()
|
||||
FROM fo_verificationslabel
|
||||
WHERE
|
||||
Fo_VerificationsLabelIsActive = 'Y' ";
|
||||
$this->db_onedev->query($sql);
|
||||
|
||||
$sql = "call sp_fo_barcode_generate({$orderID})";
|
||||
$this->db_onedev->query($sql);
|
||||
|
||||
$fostatusid = 3;
|
||||
$fologcode = 'FO.VERIFICATION.CONFIRM';
|
||||
|
||||
$sql = "insert into fo_status(
|
||||
Fo_StatusDate,
|
||||
Fo_StatusT_OrderHeaderID,
|
||||
Fo_StatusM_StatusID,
|
||||
Fo_StatusM_UserID,
|
||||
Fo_StatusCreated,
|
||||
Fo_StatusUpdated)
|
||||
values( now(), ?, ?, ?, now(),now())";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$orderID,
|
||||
$fostatusid, $userID
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
return "Error Fo Status";
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM fo_verificationsvalue WHERE Fo_VerificationsValueT_OrderHeaderID = {$orderID}";
|
||||
|
||||
$data_log = array();
|
||||
$data_log['orderid'] = $orderID;
|
||||
$data_log['values'] = $this->db_onedev->query($sql)->result_array();
|
||||
$data_log['note'] = '';
|
||||
|
||||
$json_dt_log = json_encode($data_log);
|
||||
$sql = "insert into one_log.log_fo(
|
||||
Log_FoDate,
|
||||
Log_FoCode,
|
||||
Log_FoJson,
|
||||
Log_FoUserID)
|
||||
values( now(), ?, ?, ?)";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$fologcode,
|
||||
$json_dt_log,
|
||||
$userID
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
return "Error Fo Log";
|
||||
}
|
||||
|
||||
/* T_OrderSample */
|
||||
$adminUserID = $userID;
|
||||
$sql = "update t_ordersample
|
||||
set T_OrderSampleSampling='Y', T_OrderSampleSamplingDate = now(),
|
||||
T_OrderSampleSamplingTime = now(),T_OrderSampleSamplingUserID = $adminUserID,
|
||||
T_OrderSampleReceive='Y', T_OrderSampleReceiveDate = now() , T_OrderSampleReceiveTime = now(),
|
||||
T_OrderSampleReceiveUserID = $adminUserID,
|
||||
T_OrderSampleVerification='Y', T_OrderSampleVerificationDate=now(), T_OrderSampleVerificationTime=now(),
|
||||
T_OrderSampleVerificationUserID = $adminUserID,
|
||||
T_OrderSampleSendHandling = 'Y', T_OrderSampleSendHandlingDate =now(), T_OrderSampleSendHandlingTime=now(),
|
||||
T_OrderSampleSendHandlingUserID = $adminUserID,
|
||||
T_OrderSampleReceiveHandling = 'Y', T_OrderSampleReceiveHandlingDate=now(), T_OrderSampleReceiveHandlingTime=now(),
|
||||
T_OrderSampleReceiveHandlingUserID=$adminUserID,
|
||||
T_OrderSampleHandling='Y', T_OrderSampleHandlingDate=now(), T_OrderSampleHandlingTime=now(),
|
||||
T_OrderSampleHandlingUserID=$adminUserID,
|
||||
T_OrderSampleProcessing='Y', T_OrderSampleReadyToProcessDateTime=now(), T_OrderSampleProcessingDate=now(),
|
||||
T_OrderSampleProcessingTime=now(), T_OrderSampleProcessingUserID=$adminUserID,
|
||||
T_OrderSampleUserID=$adminUserID
|
||||
where T_OrderSampleT_OrderHeaderID = ?";
|
||||
|
||||
|
||||
$qry = $this->db_onedev->query($sql, array($orderID) );
|
||||
if (!$qry) {
|
||||
return "Error T_OrderSample : " . $this->db_onedev->last_query();
|
||||
}
|
||||
return "OK";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
47
application/controllers/tools/Company.php
Normal file
47
application/controllers/tools/Company.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
class Company extends MY_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
//$this->db = $this->load->database('regional', true);
|
||||
$this->db = $this->load->database('onedev', true);
|
||||
}
|
||||
|
||||
function is_exists($table, $field, $value) {
|
||||
$this->db->where($field,$value);
|
||||
$qry = $this->db->get($table);
|
||||
if (! $qry) {
|
||||
echo json_encode(array("status" => "ERR", "message" => "Cek exists $table $field $value". print_r($this->db->error(),true) ));
|
||||
exit;
|
||||
}
|
||||
if (! empty($qry->result_array())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function editcompanyafterrelease() {
|
||||
$md5 = $this->sys_input["md5"];
|
||||
$param = $this->sys_input["param"];
|
||||
$j_param = json_encode($param);
|
||||
$l_md5 = md5($j_param);
|
||||
if ($md5 != $l_md5 ) {
|
||||
echo json_encode(array("status" => "ERR", "message" => "MD5 $md5 <> $l_md5"));
|
||||
exit;
|
||||
}
|
||||
$company = $param["company"];
|
||||
|
||||
if ( $this->is_exists("m_company","M_CompanyID", $company["M_CompanyID"]) ) {
|
||||
$this->db->where("M_CompanyID", $company["M_CompanyID"]);
|
||||
$qry = $this->db->update("m_company",$company);
|
||||
}
|
||||
if (! $qry ) {
|
||||
echo json_encode(array("status" => "ERR", "message" => "Update Company : " . print_r($this->db->error(),true) ));
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
echo json_encode( array("status" => "OK" , "message" => "" , "companyID" => $company["M_MouID"]));
|
||||
}
|
||||
}
|
||||
2105
application/controllers/tools/Download_v2.php
Normal file
2105
application/controllers/tools/Download_v2.php
Normal file
File diff suppressed because it is too large
Load Diff
132
application/controllers/tools/Downloadbackup.php
Normal file
132
application/controllers/tools/Downloadbackup.php
Normal file
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
class Downloadbackup extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
|
||||
var $backup_folder;
|
||||
var $load;
|
||||
var $output;
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->backup_folder = "/data-sda/backup-db/";
|
||||
$this->load->helper(array('url', 'file')); // Load helper untuk URL dan file
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "CPONE DOWNLOAD BACKUP API";
|
||||
}
|
||||
public function list_backup()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$cpones = glob($this->backup_folder . 'cpone/*');
|
||||
$cpone_logs = glob($this->backup_folder . 'cpone_log/*');
|
||||
// Recursive function to scan files
|
||||
$allFile = [];
|
||||
$files = [];
|
||||
$files["cpone"] = [];
|
||||
foreach ($cpones as $file) {
|
||||
if (is_file($file)) {
|
||||
$files["cpone"][] = [
|
||||
'name' => basename($file),
|
||||
'full_path' => $file,
|
||||
'last_modified' => date("Y-m-d H:i:s", filemtime($file)),
|
||||
'size' => $this->formatSize(filesize($file)),
|
||||
'type' => 'cpone'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$files["cpone_log"] = [];
|
||||
foreach ($cpone_logs as $file) {
|
||||
if (is_file($file)) {
|
||||
$files["cpone_log"][] = [
|
||||
'name' => basename($file),
|
||||
'full_path' => $file,
|
||||
'last_modified' => date("Y-m-d H:i:s", filemtime($file)),
|
||||
'size' => $this->formatSize(filesize($file)),
|
||||
'type' => 'log'
|
||||
];
|
||||
}
|
||||
}
|
||||
// Sort files by last modified date descending
|
||||
usort($files["cpone"], function ($a, $b) {
|
||||
return strtotime($b['last_modified']) - strtotime($a['last_modified']);
|
||||
});
|
||||
usort($files["cpone_log"], function ($a, $b) {
|
||||
return strtotime($b['last_modified']) - strtotime($a['last_modified']);
|
||||
});
|
||||
|
||||
|
||||
// Return JSON response
|
||||
// echo json_encode(["status" => "OK", "result" => $files]);
|
||||
$this->sys_ok($files);
|
||||
}
|
||||
|
||||
private function formatSize($size)
|
||||
{
|
||||
$units = ['B', 'KB', 'MB', 'GB', 'TB'];
|
||||
$i = 0;
|
||||
while ($size >= 1024 && $i < count($units) - 1) {
|
||||
$size /= 1024;
|
||||
$i++;
|
||||
}
|
||||
return round($size, 2) . ' ' . $units[$i];
|
||||
}
|
||||
public function file()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$path = $prm['path'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
if (!file_exists($path)) {
|
||||
$this->sys_error("File not exist");
|
||||
exit;
|
||||
}
|
||||
|
||||
$filesize = filesize($path);
|
||||
$filename = basename($path);
|
||||
|
||||
// Set header yang benar untuk mendukung progress
|
||||
header('Content-Type: application/octet-stream');
|
||||
header('Content-Disposition: attachment; filename="' . $filename . '"');
|
||||
header('Content-Length: ' . $filesize);
|
||||
header('Accept-Ranges: bytes');
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
header('Access-Control-Expose-Headers: Content-Length, Content-Disposition, Accept-Ranges');
|
||||
|
||||
// Matikan output buffering
|
||||
if (ob_get_level()) {
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
// Untuk file kecil (<10MB), gunakan readfile
|
||||
if ($filesize < 10 * 1024 * 1024) {
|
||||
readfile($path);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Untuk file besar, gunakan chunked transfer
|
||||
$handle = fopen($path, 'rb');
|
||||
$chunkSize = 8192; // Gunakan chunk yang lebih kecil (8KB)
|
||||
|
||||
while (!feof($handle)) {
|
||||
echo fread($handle, $chunkSize);
|
||||
flush();
|
||||
}
|
||||
|
||||
fclose($handle);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
78
application/controllers/tools/Downloadphoto.php
Normal file
78
application/controllers/tools/Downloadphoto.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
class Downloadphoto extends MY_Controller
|
||||
{
|
||||
var $base_dir = "/home/one/project/one/one-media/one-photo/patient/";
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
$this->load->helper(array('form', 'url'));
|
||||
|
||||
}
|
||||
|
||||
function start(){
|
||||
$companynumber = $this->input->get("companynumber");
|
||||
$start_date = $this->input->get("startdate");
|
||||
$end_date = $this->input->get("enddate");
|
||||
$sql = "SELECT m_patient.*, T_OrderHeaderLabNumber,M_CompanyNumber FROM t_orderheader
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
WHERE `M_PatientPhoto` IS NOT NULL AND M_CompanyNumber = '{$companynumber}' AND ( DATE(T_OrderHeaderDate) >= '{$start_date}' AND DATE(T_OrderHeaderDate) <= '{$end_date}' ) AND T_OrderHeaderIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rst = $this->db_onedev->query($sql)->result_array();
|
||||
if($rst){
|
||||
$companynumber = $rst[0]['M_CompanyNumber'];
|
||||
$newdir = $this->base_dir."xphoto".$companynumber;
|
||||
//echo $newdir;
|
||||
if (!file_exists($newdir)) {
|
||||
//echo $newdir;
|
||||
mkdir($newdir, 0777, true);
|
||||
}
|
||||
else{
|
||||
unlink($newdir);
|
||||
mkdir($newdir, 0777, true);
|
||||
}
|
||||
foreach($rst as $k => $v){
|
||||
$photo_explode = explode('/',$v['M_PatientPhoto']);
|
||||
copy('/home/one/project/one/'.$v['M_PatientPhoto'], $newdir.'/'.$photo_explode[5]);
|
||||
}
|
||||
$this->download($companynumber);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function small(){
|
||||
|
||||
$y = $this->input->get("y");
|
||||
$pid = $this->input->get("pid");
|
||||
$foto_file = $this->base_dir . "$y" . "/" . $pid . "_thumb.jpg";
|
||||
header('Content-type: image/jpg');
|
||||
|
||||
echo file_get_contents($foto_file);
|
||||
}
|
||||
|
||||
function download($companynumber) {
|
||||
$filenow = $this->base_dir."xphoto".$companynumber;
|
||||
//$filenow = "/home/one/project/one/one-media/one-photo/patient/xcoba";
|
||||
|
||||
$temp_file = tempnam(sys_get_temp_dir(), 'photo-'.$companynumber.'-') . ".tar.gz";
|
||||
if ( file_exists($temp_file) ) unlink($temp_file);
|
||||
$cmd = "tar -C $filenow -cvf $temp_file ./";
|
||||
exec($cmd);
|
||||
if (file_exists($temp_file)) {
|
||||
header('Content-Description: File Transfer');
|
||||
header('Content-Type: application/octet-stream');
|
||||
header('Content-Disposition: attachment; filename="'.basename($temp_file).'"');
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate');
|
||||
header('Pragma: public');
|
||||
header('Content-Length: ' . filesize($temp_file));
|
||||
readfile($temp_file);
|
||||
unlink($temp_file);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
415
application/controllers/tools/Email_gateway.php
Normal file
415
application/controllers/tools/Email_gateway.php
Normal file
@@ -0,0 +1,415 @@
|
||||
<?php
|
||||
|
||||
class Email_gateway extends MY_Controller
|
||||
{
|
||||
var $sender_std, $sender_keu, $sender_result, $password_result, $password_keu, $password_std;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$sql = "SELECT ConfOnHoldSenderEmail as email,
|
||||
ConfOnHoldSenderName as name,
|
||||
ConfOnHoldSenderPassword as password
|
||||
FROM conf_on_hold
|
||||
WHERE ConfOnHoldIsActive = 'Y';";
|
||||
$qry = $this->db->query($sql);
|
||||
|
||||
$keu = $qry->row_array();
|
||||
$this->password_keu = $keu['password'];
|
||||
unset($keu['password']);
|
||||
$this->sender_keu = $keu;
|
||||
|
||||
$sql = "SELECT M_EmailConfigSender as email,
|
||||
M_EmailConfigUsername as name,
|
||||
M_EmailConfigPassword as password
|
||||
FROM m_emailconfig
|
||||
WHERE M_EmailConfigIsActive = 'Y';";
|
||||
$qry = $this->db->query($sql);
|
||||
|
||||
$rst = $qry->row_array();
|
||||
$this->password_result = $rst['password'];
|
||||
unset($rst['password']);
|
||||
$this->sender_result = $rst;
|
||||
$this->sender_std = $rst;
|
||||
// print_r($this->sender_result);
|
||||
}
|
||||
function coba()
|
||||
{
|
||||
print_r($this->sender_result);
|
||||
print_r($this->sender_keu);
|
||||
}
|
||||
//Email type standard
|
||||
function log($type, $message)
|
||||
{
|
||||
$fname = "/xtmp/x-email-$type.log";
|
||||
$dt = date("Y-m-d H:i:s");
|
||||
echo "$dt $message\n";
|
||||
$st = file_put_contents($fname, "$dt $message\n", FILE_APPEND);
|
||||
if ($st === false) {
|
||||
echo "$dt Error writing to log file $fname\n";
|
||||
}
|
||||
}
|
||||
function standard()
|
||||
{
|
||||
$wait_in_minute = 30; //staled process wait till 30 minute
|
||||
$delay = 3; // email delay 3s
|
||||
$max_per_batch = 20;
|
||||
$log_type = "std";
|
||||
$tmp_mark_file = "/xtmp/standard-file.json";
|
||||
$this->load->library("Gmail");
|
||||
$is_running = false;
|
||||
$last_pid = "---";
|
||||
if (file_exists($tmp_mark_file)) {
|
||||
$j_mark = file_get_contents($tmp_mark_file);
|
||||
$mark = json_decode($j_mark, true);
|
||||
$last_run = $mark["time"];
|
||||
$last_pid = $mark["pid"];
|
||||
if ($last_run != "") {
|
||||
$x_now = date("Y-m-d H:i:s");
|
||||
$last_run_stale = date("Y-m-d H:i:s", strtotime($j_mark . " + $wait_in_minute minute"));
|
||||
if ($last_run_stale > $x_now) {
|
||||
$is_running = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($is_running) {
|
||||
$this->log($log_type, "Process Already Running : $last_pid");
|
||||
exit;
|
||||
}
|
||||
$xpid = getmygid();
|
||||
if ($xpid === false) {
|
||||
$xpid = "-1"; //
|
||||
}
|
||||
file_put_contents($tmp_mark_file, json_encode([
|
||||
"time" => date("Y-m-d H:i:s"),
|
||||
"pid" => $xpid
|
||||
]));
|
||||
$sql = "select * from x_email_outbox where XEmailOutboxType='STD'
|
||||
and XEmailOutboxIsActive='Y' and XEmailOutboxIsSent='N'
|
||||
union
|
||||
select * from x_email_outbox where XEmailOutboxType='STD'
|
||||
and XEmailOutboxIsActive='Y' and XEmailOutboxIsSent='E'
|
||||
and XEmailOutboxRetry < 5
|
||||
order by XEmailOutboxIsSent desc,XEmailOutboxRetry desc
|
||||
limit 0,$max_per_batch";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
$this->log($log_type, "Error query Get " . $this->db->error()["message"]);
|
||||
unlink($tmp_mark_file);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
$this->log($log_type, "No Pending Email");
|
||||
unlink($tmp_mark_file);
|
||||
exit;
|
||||
}
|
||||
$sql_u = "update x_email_outbox set XEmailOutboxIsSent=?, XEmailOutboxRetry = XEmailOutboxRetry +1
|
||||
, XEmailOutboxSentDate = now()
|
||||
where XEmailOutboxID =?";
|
||||
$sender = $this->sender_std;
|
||||
foreach ($rows as $r) {
|
||||
//$sender = json_decode($r["XEmailOutboxSender"], true);
|
||||
// if (json_last_error() != JSON_ERROR_NONE) {
|
||||
// $this->log($log_type, "Error Sender format {$r["XEmailOutboxSender"]}");
|
||||
// }
|
||||
$recipients = json_decode($r["XEmailOutboxRecipients"], true);
|
||||
if (json_last_error() != JSON_ERROR_NONE) {
|
||||
$this->log($log_type, "Error Recipients format {$r["XEmailOutboxSender"]}");
|
||||
continue;
|
||||
}
|
||||
$cc = [];
|
||||
$jcc = json_decode($r["XEmailOutboxCc"], true);
|
||||
if (json_last_error() != JSON_ERROR_NONE) {
|
||||
$cc = $jcc;
|
||||
}
|
||||
$arr_recs = array_map(function ($r) {
|
||||
return $r["email"];
|
||||
}, $recipients);
|
||||
$recs = implode(", ", $arr_recs);
|
||||
$atts = json_decode($r["XEmailOutboxAttachments"], true);
|
||||
if (json_last_error() != JSON_ERROR_NONE) {
|
||||
$atts = [];
|
||||
}
|
||||
list($status, $message) = $this->gmail->send(
|
||||
$sender,
|
||||
$r["XEmailOutboxSubject"],
|
||||
$r["XEmailOutboxBody"],
|
||||
$recipients,
|
||||
$cc,
|
||||
$r["XEmailOutboxIsHtml"],
|
||||
$atts
|
||||
);
|
||||
if ($status) {
|
||||
$this->log($log_type, "Email {$r["XEmailOutboxSubject"]} sent to {$recs} [OK]");
|
||||
$qry_u = $this->db->query($sql_u, ["Y", $r["XEmailOutboxID"]]);
|
||||
} else {
|
||||
$this->log($log_type, "Email {$r["XEmailOutboxSubject"]} sent to {$recs} [ERR]\n $message");
|
||||
$qry_u = $this->db->query($sql_u, ["E", $r["XEmailOutboxID"]]);
|
||||
}
|
||||
if (!$qry_u) {
|
||||
$this->log($log_type, "Error query Update" . $this->db->error()["message"]);
|
||||
unlink($tmp_mark_file);
|
||||
exit;
|
||||
}
|
||||
$this->log($log_type, "Wait {$delay}s");
|
||||
sleep($delay);
|
||||
}
|
||||
}
|
||||
|
||||
function keu()
|
||||
{
|
||||
$log_type = "keu";
|
||||
$wait_in_minute = 30; //staled process wait till 30 minute
|
||||
$delay = 3; // email delay 3s
|
||||
$max_per_batch = 20;
|
||||
|
||||
$this->log($log_type, "Start Process Keu Email");
|
||||
$tmp_mark_file = "/xtmp/{$log_type}-file.json";
|
||||
$this->load->library("Gmail");
|
||||
$is_running = false;
|
||||
$last_pid = "---";
|
||||
if (file_exists($tmp_mark_file)) {
|
||||
$j_mark = file_get_contents($tmp_mark_file);
|
||||
$mark = json_decode($j_mark, true);
|
||||
$last_run = $mark["time"];
|
||||
$last_pid = $mark["pid"];
|
||||
if ($last_run != "") {
|
||||
$x_now = date("Y-m-d H:i:s");
|
||||
$last_run_stale = date("Y-m-d H:i:s", strtotime($last_run . " + $wait_in_minute minutes"));
|
||||
if ($last_run_stale > $x_now) {
|
||||
$is_running = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($is_running) {
|
||||
$this->log($log_type, "Process Already Running : $last_pid @ $last_run");
|
||||
exit;
|
||||
}
|
||||
$xpid = getmygid();
|
||||
if ($xpid === false) {
|
||||
$xpid = "-1"; //
|
||||
}
|
||||
file_put_contents($tmp_mark_file, json_encode([
|
||||
"time" => date("Y-m-d H:i:s"),
|
||||
"pid" => $xpid
|
||||
]));
|
||||
$sql = "select * from x_email_outbox
|
||||
where XEmailOutboxType='KEU'
|
||||
and XEmailOutboxIsActive='Y' and XEmailOutboxIsSent='N'
|
||||
union
|
||||
select * from x_email_outbox
|
||||
where XEmailOutboxType='KEU'
|
||||
and XEmailOutboxIsActive='Y' and XEmailOutboxIsSent='E'
|
||||
and XEmailOutboxRetry < 5
|
||||
order by XEmailOutboxIsSent desc,XEmailOutboxRetry desc
|
||||
limit 0,$max_per_batch";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
$this->log($log_type, "Error query Get " . $this->db->error()["message"]);
|
||||
unlink($tmp_mark_file);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
|
||||
if (count($rows) == 0) {
|
||||
$this->log($log_type, "No Pending Email");
|
||||
unlink($tmp_mark_file);
|
||||
exit;
|
||||
}
|
||||
$sql_u = "update x_email_outbox set XEmailOutboxIsSent=?, XEmailOutboxRetry = XEmailOutboxRetry +1
|
||||
, XEmailOutboxSentDate = now()
|
||||
where XEmailOutboxID =?";
|
||||
|
||||
|
||||
$sender = $this->sender_keu;
|
||||
foreach ($rows as $r) {
|
||||
//$sender = json_decode($r["XEmailOutboxSender"], true);
|
||||
// if (json_last_error() != JSON_ERROR_NONE) {
|
||||
// $this->log($log_type, "Error Sender format {$r["XEmailOutboxSender"]}");
|
||||
// }
|
||||
$recipients = json_decode($r["XEmailOutboxRecipients"], true);
|
||||
if (json_last_error() != JSON_ERROR_NONE) {
|
||||
$this->log($log_type, "Error Recipients format {$r["XEmailOutboxRecipients"]}");
|
||||
$this->log($log_type, "Debug : " . print_r($r, true));
|
||||
continue;
|
||||
}
|
||||
$cc = [];
|
||||
$jcc = json_decode($r["XEmailOutboxCc"], true);
|
||||
if (json_last_error() != JSON_ERROR_NONE) {
|
||||
$cc = $jcc;
|
||||
}
|
||||
$arr_recs = array_map(function ($r) {
|
||||
return $r["email"];
|
||||
}, $recipients);
|
||||
$recs = implode(", ", $arr_recs);
|
||||
$atts = json_decode($r["XEmailOutboxAttachments"], true);
|
||||
if (json_last_error() != JSON_ERROR_NONE) {
|
||||
$atts = [];
|
||||
}
|
||||
list($status, $message) = $this->gmail->send(
|
||||
$sender,
|
||||
$r["XEmailOutboxSubject"],
|
||||
$r["XEmailOutboxBody"],
|
||||
$recipients,
|
||||
$cc,
|
||||
$r["XEmailOutboxIsHtml"],
|
||||
$atts,
|
||||
$this->sender_keu['email'],
|
||||
$this->password_keu
|
||||
);
|
||||
if ($status) {
|
||||
$this->log($log_type, "Email {$r["XEmailOutboxSubject"]} sent to {$recs} [OK]");
|
||||
$qry_u = $this->db->query($sql_u, ["Y", $r["XEmailOutboxID"]]);
|
||||
} else {
|
||||
$this->log($log_type, "Email {$r["XEmailOutboxSubject"]} sent to {$recs} [ERR]\n $message");
|
||||
$qry_u = $this->db->query($sql_u, ["E", $r["XEmailOutboxID"]]);
|
||||
}
|
||||
if (!$qry_u) {
|
||||
$this->log($log_type, "Error query Update" . $this->db->error()["message"]);
|
||||
unlink($tmp_mark_file);
|
||||
exit;
|
||||
}
|
||||
$this->log($log_type, "Wait {$delay}s");
|
||||
sleep($delay);
|
||||
}
|
||||
unlink($tmp_mark_file);
|
||||
}
|
||||
|
||||
function result()
|
||||
{
|
||||
$log_type = "result";
|
||||
$wait_in_minute = 30; //staled process wait till 30 minute
|
||||
$delay = 3; // email delay 3s
|
||||
$max_per_batch = 20;
|
||||
|
||||
$this->log($log_type, "Start Process $log_type Email");
|
||||
$tmp_mark_file = "/xtmp/{$log_type}-file.json";
|
||||
$this->load->library("Gmail");
|
||||
$is_running = false;
|
||||
$last_pid = "---";
|
||||
if (file_exists($tmp_mark_file)) {
|
||||
$j_mark = file_get_contents($tmp_mark_file);
|
||||
$mark = json_decode($j_mark, true);
|
||||
$last_run = $mark["time"];
|
||||
$last_pid = $mark["pid"];
|
||||
if ($last_run != "") {
|
||||
$x_now = date("Y-m-d H:i:s");
|
||||
$last_run_stale = date("Y-m-d H:i:s", strtotime($last_run . " + $wait_in_minute minutes"));
|
||||
if ($last_run_stale > $x_now) {
|
||||
$is_running = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($is_running) {
|
||||
$this->log($log_type, "Process Already Running : $last_pid @ $last_run");
|
||||
exit;
|
||||
}
|
||||
$xpid = getmygid();
|
||||
if ($xpid === false) {
|
||||
$xpid = "-1"; //
|
||||
}
|
||||
file_put_contents($tmp_mark_file, json_encode([
|
||||
"time" => date("Y-m-d H:i:s"),
|
||||
"pid" => $xpid
|
||||
]));
|
||||
$sql = "select * from x_email_outbox
|
||||
where XEmailOutboxType='RESULT'
|
||||
and XEmailOutboxIsActive='Y' and XEmailOutboxIsSent='N'
|
||||
union
|
||||
select * from x_email_outbox
|
||||
where XEmailOutboxType='RESULT'
|
||||
and XEmailOutboxIsActive='Y' and XEmailOutboxIsSent='R'
|
||||
and XEmailOutboxRetry < 5
|
||||
union
|
||||
select * from x_email_outbox
|
||||
where XEmailOutboxType='RESULT'
|
||||
and XEmailOutboxIsActive='Y' and XEmailOutboxIsSent='E'
|
||||
and XEmailOutboxRetry < 5
|
||||
order by XEmailOutboxIsSent desc,XEmailOutboxRetry desc
|
||||
limit 0,$max_per_batch";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
$this->log($log_type, "Error query Get " . $this->db->error()["message"]);
|
||||
unlink($tmp_mark_file);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
|
||||
if (count($rows) == 0) {
|
||||
$this->log($log_type, "No Pending Email");
|
||||
unlink($tmp_mark_file);
|
||||
exit;
|
||||
}
|
||||
$sql_u = "update x_email_outbox set XEmailOutboxIsSent=?, XEmailOutboxRetry = XEmailOutboxRetry +1
|
||||
, XEmailOutboxSentDate = now()
|
||||
where XEmailOutboxID =?";
|
||||
$sender = $this->sender_result;
|
||||
foreach ($rows as $r) {
|
||||
$recipients = json_decode($r["XEmailOutboxRecipients"], true);
|
||||
if (json_last_error() != JSON_ERROR_NONE) {
|
||||
$this->log($log_type, "Error Recipients format {$r["XEmailOutboxRecipients"]}");
|
||||
continue;
|
||||
}
|
||||
$cc = json_decode($r["XEmailOutboxCc"], true);
|
||||
if (json_last_error() != JSON_ERROR_NONE) {
|
||||
$this->log($log_type, "Error Cc format {$r["XEmailOutbox"]}");
|
||||
$cc = [];
|
||||
}
|
||||
//fix email
|
||||
$new_recipients = [];
|
||||
foreach ($recipients as $r01) {
|
||||
if (strpos($r01["email"], ",") > 0) {
|
||||
$a_email = explode(",", $r01["email"]);
|
||||
foreach ($a_email as $email) {
|
||||
$new_recipients[] = ["name" => $r01["name"], "email" => $email];
|
||||
}
|
||||
} else {
|
||||
$new_recipients[] = $r01;
|
||||
}
|
||||
}
|
||||
$recipients = $new_recipients;
|
||||
$arr_recs = array_map(function ($r) {
|
||||
return $r["email"];
|
||||
}, $recipients);
|
||||
$recs = implode(", ", $arr_recs);
|
||||
$atts = json_decode($r["XEmailOutboxAttachment"], true);
|
||||
if (json_last_error() != JSON_ERROR_NONE) {
|
||||
$this->log($log_type, "Error Attachments {$r["XEmailOutboxAttachment"]}");
|
||||
$atts = [];
|
||||
}
|
||||
list($status, $message) = $this->gmail->send(
|
||||
$sender,
|
||||
$r["XEmailOutboxSubject"],
|
||||
$r["XEmailOutboxBody"],
|
||||
$recipients,
|
||||
$cc,
|
||||
$r["XEmailOutboxIsHtml"],
|
||||
$atts,
|
||||
$this->sender_result['email'],
|
||||
$this->password_result,
|
||||
false
|
||||
);
|
||||
|
||||
if ($status) {
|
||||
$this->log($log_type, "Email {$r["XEmailOutboxSubject"]} sent to {$recs} [OK]");
|
||||
$qry_u = $this->db->query($sql_u, ["Y", $r["XEmailOutboxID"]]);
|
||||
} else {
|
||||
$this->log($log_type, "Email {$r["XEmailOutboxSubject"]} sent to {$recs} [ERR]\n $message");
|
||||
$qry_u = $this->db->query($sql_u, ["E", $r["XEmailOutboxID"]]);
|
||||
}
|
||||
if (!$qry_u) {
|
||||
$this->log($log_type, "Error query Update" . $this->db->error()["message"]);
|
||||
unlink($tmp_mark_file);
|
||||
exit;
|
||||
}
|
||||
$this->log($log_type, "Wait {$delay}s");
|
||||
sleep($delay);
|
||||
}
|
||||
unlink($tmp_mark_file);
|
||||
}
|
||||
}
|
||||
373
application/controllers/tools/Email_gateway.php050824
Normal file
373
application/controllers/tools/Email_gateway.php050824
Normal file
@@ -0,0 +1,373 @@
|
||||
<?php
|
||||
|
||||
class Email_gateway extends MY_Controller
|
||||
{
|
||||
var $sender_std, $sender_keu, $sender_result;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->sender_std = [
|
||||
"name" => "CpOne SAS",
|
||||
"email" => "sascpone@gmail.com"
|
||||
];
|
||||
$this->sender_keu = [
|
||||
"name" => "CpOne SAS",
|
||||
"email" => "sascpone@gmail.com"
|
||||
];
|
||||
$this->sender_result = [
|
||||
"name" => "CpOne SAS",
|
||||
"email" => "sascpone@gmail.com"
|
||||
];
|
||||
}
|
||||
//Email type standard
|
||||
function log($type, $message)
|
||||
{
|
||||
$fname = "/xtmp/x-email-$type.log";
|
||||
$dt = date("Y-m-d H:i:s");
|
||||
echo "$dt $message\n";
|
||||
$st = file_put_contents($fname, "$dt $message\n", FILE_APPEND);
|
||||
if ($st === false) {
|
||||
echo "$dt Error writing to log file $fname\n";
|
||||
}
|
||||
}
|
||||
function standard()
|
||||
{
|
||||
$wait_in_minute = 30; //staled process wait till 30 minute
|
||||
$delay = 3; // email delay 3s
|
||||
$max_per_batch = 20;
|
||||
$log_type = "std";
|
||||
$tmp_mark_file = "/xtmp/standard-file.json";
|
||||
$this->load->library("Gmail");
|
||||
$is_running = false;
|
||||
$last_pid = "---";
|
||||
if (file_exists($tmp_mark_file)) {
|
||||
$j_mark = file_get_contents($tmp_mark_file);
|
||||
$mark = json_decode($j_mark, true);
|
||||
$last_run = $mark["time"];
|
||||
$last_pid = $mark["pid"];
|
||||
if ($last_run != "") {
|
||||
$x_now = date("Y-m-d H:i:s");
|
||||
$last_run_stale = date("Y-m-d H:i:s", strtotime($j_mark . " + $wait_in_minute minute"));
|
||||
if ($last_run_stale > $x_now) {
|
||||
$is_running = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($is_running) {
|
||||
$this->log($log_type, "Process Already Running : $last_pid");
|
||||
exit;
|
||||
}
|
||||
$xpid = getmygid();
|
||||
if ($xpid === false) {
|
||||
$xpid = "-1"; //
|
||||
}
|
||||
file_put_contents($tmp_mark_file, json_encode([
|
||||
"time" => date("Y-m-d H:i:s"),
|
||||
"pid" => $xpid
|
||||
]));
|
||||
$sql = "select * from x_email_outbox where XEmailOutboxType='STD'
|
||||
and XEmailOutboxIsActive='Y' and XEmailOutboxIsSent='N'
|
||||
union
|
||||
select * from x_email_outbox where XEmailOutboxType='STD'
|
||||
and XEmailOutboxIsActive='Y' and XEmailOutboxIsSent='E'
|
||||
and XEmailOutboxRetry < 5
|
||||
order by XEmailOutboxIsSent desc,XEmailOutboxRetry desc
|
||||
limit 0,$max_per_batch";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
$this->log($log_type, "Error query Get " . $this->db->error()["message"]);
|
||||
unlink($tmp_mark_file);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
$this->log($log_type, "No Pending Email");
|
||||
unlink($tmp_mark_file);
|
||||
exit;
|
||||
}
|
||||
$sql_u = "update x_email_outbox set XEmailOutboxIsSent=?, XEmailOutboxRetry = XEmailOutboxRetry +1
|
||||
, XEmailOutboxSentDate = now()
|
||||
where XEmailOutboxID =?";
|
||||
$sender = $this->sender_std;
|
||||
foreach ($rows as $r) {
|
||||
//$sender = json_decode($r["XEmailOutboxSender"], true);
|
||||
// if (json_last_error() != JSON_ERROR_NONE) {
|
||||
// $this->log($log_type, "Error Sender format {$r["XEmailOutboxSender"]}");
|
||||
// }
|
||||
$recipients = json_decode($r["XEmailOutboxRecipients"], true);
|
||||
if (json_last_error() != JSON_ERROR_NONE) {
|
||||
$this->log($log_type, "Error Recipients format {$r["XEmailOutboxSender"]}");
|
||||
continue;
|
||||
}
|
||||
$cc = [];
|
||||
$jcc = json_decode($r["XEmailOutboxCc"], true);
|
||||
if (json_last_error() != JSON_ERROR_NONE) {
|
||||
$cc = $jcc;
|
||||
}
|
||||
$arr_recs = array_map(function ($r) {
|
||||
return $r["email"];
|
||||
}, $recipients);
|
||||
$recs = implode(", ", $arr_recs);
|
||||
$atts = json_decode($r["XEmailOutboxAttachments"], true);
|
||||
if (json_last_error() != JSON_ERROR_NONE) {
|
||||
$atts = [];
|
||||
}
|
||||
list($status, $message) = $this->gmail->send(
|
||||
$sender,
|
||||
$r["XEmailOutboxSubject"],
|
||||
$r["XEmailOutboxBody"],
|
||||
$recipients,
|
||||
$cc,
|
||||
$r["XEmailOutboxIsHtml"],
|
||||
$atts
|
||||
);
|
||||
if ($status) {
|
||||
$this->log($log_type, "Email {$r["XEmailOutboxSubject"]} sent to {$recs} [OK]");
|
||||
$qry_u = $this->db->query($sql_u, ["Y", $r["XEmailOutboxID"]]);
|
||||
} else {
|
||||
$this->log($log_type, "Email {$r["XEmailOutboxSubject"]} sent to {$recs} [ERR]\n $message");
|
||||
$qry_u = $this->db->query($sql_u, ["E", $r["XEmailOutboxID"]]);
|
||||
}
|
||||
if (!$qry_u) {
|
||||
$this->log($log_type, "Error query Update" . $this->db->error()["message"]);
|
||||
unlink($tmp_mark_file);
|
||||
exit;
|
||||
}
|
||||
$this->log($log_type, "Wait {$delay}s");
|
||||
sleep($delay);
|
||||
}
|
||||
}
|
||||
|
||||
function keu()
|
||||
{
|
||||
$log_type = "keu";
|
||||
$wait_in_minute = 30; //staled process wait till 30 minute
|
||||
$delay = 3; // email delay 3s
|
||||
$max_per_batch = 20;
|
||||
|
||||
$this->log($log_type, "Start Process Keu Email");
|
||||
$tmp_mark_file = "/xtmp/{$log_type}-file.json";
|
||||
$this->load->library("Gmail");
|
||||
$is_running = false;
|
||||
$last_pid = "---";
|
||||
if (file_exists($tmp_mark_file)) {
|
||||
$j_mark = file_get_contents($tmp_mark_file);
|
||||
$mark = json_decode($j_mark, true);
|
||||
$last_run = $mark["time"];
|
||||
$last_pid = $mark["pid"];
|
||||
if ($last_run != "") {
|
||||
$x_now = date("Y-m-d H:i:s");
|
||||
$last_run_stale = date("Y-m-d H:i:s", strtotime($last_run . " + $wait_in_minute minutes"));
|
||||
if ($last_run_stale > $x_now) {
|
||||
$is_running = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($is_running) {
|
||||
$this->log($log_type, "Process Already Running : $last_pid @ $last_run");
|
||||
exit;
|
||||
}
|
||||
$xpid = getmygid();
|
||||
if ($xpid === false) {
|
||||
$xpid = "-1"; //
|
||||
}
|
||||
file_put_contents($tmp_mark_file, json_encode([
|
||||
"time" => date("Y-m-d H:i:s"),
|
||||
"pid" => $xpid
|
||||
]));
|
||||
$sql = "select * from x_email_outbox
|
||||
where XEmailOutboxType='KEU'
|
||||
and XEmailOutboxIsActive='Y' and XEmailOutboxIsSent='N'
|
||||
union
|
||||
select * from x_email_outbox
|
||||
where XEmailOutboxType='KEU'
|
||||
and XEmailOutboxIsActive='Y' and XEmailOutboxIsSent='E'
|
||||
and XEmailOutboxRetry < 5
|
||||
order by XEmailOutboxIsSent desc,XEmailOutboxRetry desc
|
||||
limit 0,$max_per_batch";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
$this->log($log_type, "Error query Get " . $this->db->error()["message"]);
|
||||
unlink($tmp_mark_file);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
|
||||
if (count($rows) == 0) {
|
||||
$this->log($log_type, "No Pending Email");
|
||||
unlink($tmp_mark_file);
|
||||
exit;
|
||||
}
|
||||
$sql_u = "update x_email_outbox set XEmailOutboxIsSent=?, XEmailOutboxRetry = XEmailOutboxRetry +1
|
||||
, XEmailOutboxSentDate = now()
|
||||
where XEmailOutboxID =?";
|
||||
|
||||
|
||||
$sender = $this->sender_keu;
|
||||
foreach ($rows as $r) {
|
||||
//$sender = json_decode($r["XEmailOutboxSender"], true);
|
||||
// if (json_last_error() != JSON_ERROR_NONE) {
|
||||
// $this->log($log_type, "Error Sender format {$r["XEmailOutboxSender"]}");
|
||||
// }
|
||||
$recipients = json_decode($r["XEmailOutboxRecipients"], true);
|
||||
if (json_last_error() != JSON_ERROR_NONE) {
|
||||
$this->log($log_type, "Error Recipients format {$r["XEmailOutboxRecipients"]}");
|
||||
$this->log($log_type, "Debug : " . print_r($r, true));
|
||||
continue;
|
||||
}
|
||||
$cc = [];
|
||||
$jcc = json_decode($r["XEmailOutboxCc"], true);
|
||||
if (json_last_error() != JSON_ERROR_NONE) {
|
||||
$cc = $jcc;
|
||||
}
|
||||
$arr_recs = array_map(function ($r) {
|
||||
return $r["email"];
|
||||
}, $recipients);
|
||||
$recs = implode(", ", $arr_recs);
|
||||
$atts = json_decode($r["XEmailOutboxAttachments"], true);
|
||||
if (json_last_error() != JSON_ERROR_NONE) {
|
||||
$atts = [];
|
||||
}
|
||||
list($status, $message) = $this->gmail->send(
|
||||
$sender,
|
||||
$r["XEmailOutboxSubject"],
|
||||
$r["XEmailOutboxBody"],
|
||||
$recipients,
|
||||
$cc,
|
||||
$r["XEmailOutboxIsHtml"],
|
||||
$atts
|
||||
);
|
||||
if ($status) {
|
||||
$this->log($log_type, "Email {$r["XEmailOutboxSubject"]} sent to {$recs} [OK]");
|
||||
$qry_u = $this->db->query($sql_u, ["Y", $r["XEmailOutboxID"]]);
|
||||
} else {
|
||||
$this->log($log_type, "Email {$r["XEmailOutboxSubject"]} sent to {$recs} [ERR]\n $message");
|
||||
$qry_u = $this->db->query($sql_u, ["E", $r["XEmailOutboxID"]]);
|
||||
}
|
||||
if (!$qry_u) {
|
||||
$this->log($log_type, "Error query Update" . $this->db->error()["message"]);
|
||||
unlink($tmp_mark_file);
|
||||
exit;
|
||||
}
|
||||
$this->log($log_type, "Wait {$delay}s");
|
||||
sleep($delay);
|
||||
}
|
||||
unlink($tmp_mark_file);
|
||||
}
|
||||
|
||||
function result()
|
||||
{
|
||||
$log_type = "result";
|
||||
$wait_in_minute = 30; //staled process wait till 30 minute
|
||||
$delay = 3; // email delay 3s
|
||||
$max_per_batch = 20;
|
||||
|
||||
$this->log($log_type, "Start Process $log_type Email");
|
||||
$tmp_mark_file = "/xtmp/{$log_type}-file.json";
|
||||
$this->load->library("Gmail");
|
||||
$is_running = false;
|
||||
$last_pid = "---";
|
||||
if (file_exists($tmp_mark_file)) {
|
||||
$j_mark = file_get_contents($tmp_mark_file);
|
||||
$mark = json_decode($j_mark, true);
|
||||
$last_run = $mark["time"];
|
||||
$last_pid = $mark["pid"];
|
||||
if ($last_run != "") {
|
||||
$x_now = date("Y-m-d H:i:s");
|
||||
$last_run_stale = date("Y-m-d H:i:s", strtotime($last_run . " + $wait_in_minute minutes"));
|
||||
if ($last_run_stale > $x_now) {
|
||||
$is_running = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($is_running) {
|
||||
$this->log($log_type, "Process Already Running : $last_pid @ $last_run");
|
||||
exit;
|
||||
}
|
||||
$xpid = getmygid();
|
||||
if ($xpid === false) {
|
||||
$xpid = "-1"; //
|
||||
}
|
||||
file_put_contents($tmp_mark_file, json_encode([
|
||||
"time" => date("Y-m-d H:i:s"),
|
||||
"pid" => $xpid
|
||||
]));
|
||||
$sql = "select * from x_email_outbox
|
||||
where XEmailOutboxType='RESULT'
|
||||
and XEmailOutboxIsActive='Y' and XEmailOutboxIsSent='N'
|
||||
union
|
||||
select * from x_email_outbox
|
||||
where XEmailOutboxType='RESULT'
|
||||
and XEmailOutboxIsActive='Y' and XEmailOutboxIsSent='E'
|
||||
and XEmailOutboxRetry < 5
|
||||
order by XEmailOutboxIsSent desc,XEmailOutboxRetry desc
|
||||
limit 0,$max_per_batch";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
$this->log($log_type, "Error query Get " . $this->db->error()["message"]);
|
||||
unlink($tmp_mark_file);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
|
||||
if (count($rows) == 0) {
|
||||
$this->log($log_type, "No Pending Email");
|
||||
unlink($tmp_mark_file);
|
||||
exit;
|
||||
}
|
||||
$sql_u = "update x_email_outbox set XEmailOutboxIsSent=?, XEmailOutboxRetry = XEmailOutboxRetry +1
|
||||
, XEmailOutboxSentDate = now()
|
||||
where XEmailOutboxID =?";
|
||||
$sender = $this->sender_result;
|
||||
foreach ($rows as $r) {
|
||||
$recipients = json_decode($r["XEmailOutboxRecipients"], true);
|
||||
if (json_last_error() != JSON_ERROR_NONE) {
|
||||
$this->log($log_type, "Error Recipients format {$r["XEmailOutboxRecipients"]}");
|
||||
continue;
|
||||
}
|
||||
$cc = json_decode($r["XEmailOutboxCc"], true);
|
||||
if (json_last_error() != JSON_ERROR_NONE) {
|
||||
$this->log($log_type, "Error Cc format {$r["XEmailOutbox"]}");
|
||||
$cc = [];
|
||||
}
|
||||
$arr_recs = array_map(function ($r) {
|
||||
return $r["email"];
|
||||
}, $recipients);
|
||||
$recs = implode(", ", $arr_recs);
|
||||
$atts = json_decode($r["XEmailOutboxAttachment"], true);
|
||||
if (json_last_error() != JSON_ERROR_NONE) {
|
||||
$this->log($log_type, "Error Attachments {$r["XEmailOutboxAttachment"]}");
|
||||
$atts = [];
|
||||
}
|
||||
list($status, $message) = $this->gmail->send(
|
||||
$sender,
|
||||
$r["XEmailOutboxSubject"],
|
||||
$r["XEmailOutboxBody"],
|
||||
$recipients,
|
||||
$cc,
|
||||
$r["XEmailOutboxIsHtml"],
|
||||
$atts
|
||||
);
|
||||
|
||||
if ($status) {
|
||||
$this->log($log_type, "Email {$r["XEmailOutboxSubject"]} sent to {$recs} [OK]");
|
||||
$qry_u = $this->db->query($sql_u, ["Y", $r["XEmailOutboxID"]]);
|
||||
} else {
|
||||
$this->log($log_type, "Email {$r["XEmailOutboxSubject"]} sent to {$recs} [ERR]\n $message");
|
||||
$qry_u = $this->db->query($sql_u, ["E", $r["XEmailOutboxID"]]);
|
||||
}
|
||||
if (!$qry_u) {
|
||||
$this->log($log_type, "Error query Update" . $this->db->error()["message"]);
|
||||
unlink($tmp_mark_file);
|
||||
exit;
|
||||
}
|
||||
$this->log($log_type, "Wait {$delay}s");
|
||||
sleep($delay);
|
||||
}
|
||||
unlink($tmp_mark_file);
|
||||
}
|
||||
}
|
||||
183
application/controllers/tools/Fisik_organ.php
Normal file
183
application/controllers/tools/Fisik_organ.php
Normal file
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
|
||||
class Fisik_organ extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Fisik Organ API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
public function generate($labnumber) {
|
||||
if (isset($labnumber)) {
|
||||
// cari orderid
|
||||
$sql = "SELECT DISTINCT T_OrderHeaderID
|
||||
FROM t_orderheader
|
||||
WHERE T_OrderHeaderOldLabNumber = '{$labnumber}'";
|
||||
$qry = $this->db->query($sql);
|
||||
// echo $this->db->last_query();
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Error get t_orderheader | " . $this->db->error()["message"]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->row();
|
||||
if ( count($rows) > 0 ) {
|
||||
$orderid = $rows->T_OrderHeaderID;
|
||||
//echo $orderid;
|
||||
//cari detailid
|
||||
$sql = "SELECT T_OrderDetailID
|
||||
FROM t_orderdetail
|
||||
WHERE T_OrderDetailT_OrderHeaderID = {$orderid}
|
||||
AND T_OrderDetailT_TestID = 2562
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
";
|
||||
$qry = $this->db->query($sql);
|
||||
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Error get t_orderdetail | " . $this->db->error()["message"]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$row_details = $qry->row();
|
||||
if(count($row_details) > 0 ){
|
||||
$detailid = $row_details->T_OrderDetailID;
|
||||
// print_r($row_details);
|
||||
$qry = "SELECT COUNT(*) as exist FROM so_resultentry WHERE So_ResultEntryT_OrderHeaderID = {$orderid}
|
||||
AND So_ResultEntryT_OrderDetailID = {$detailid}
|
||||
AND So_ResultEntryNonlab_TemplateID = 27
|
||||
AND So_ResultEntryIsActive = 'Y'";
|
||||
$exist_data = $this->db->query($qry)->row()->exist;
|
||||
if($exist_data == 0){
|
||||
$sql = "INSERT INTO so_resultentry(So_ResultEntryT_OrderHeaderID,
|
||||
So_ResultEntryT_OrderDetailID,
|
||||
So_ResultEntryNonlab_TemplateID,
|
||||
So_ResultEntryNonlab_TemplateName,
|
||||
So_ResultEntryCreated)
|
||||
VALUES({$orderid},
|
||||
{$detailid},
|
||||
27,
|
||||
'Fisik Umum',
|
||||
now())";
|
||||
$query = $this->db->query($sql);
|
||||
if (!$query) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Error insert so_resultentry | " . $this->db->error()["message"]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
$so_id = $this->db->insert_id();
|
||||
}else{
|
||||
$qry = "SELECT So_ResultEntryID FROM so_resultentry WHERE So_ResultEntryT_OrderHeaderID = {$orderid}
|
||||
AND So_ResultEntryT_OrderDetailID = {$detailid}
|
||||
AND So_ResultEntryNonlab_TemplateID = 27
|
||||
AND So_ResultEntryIsActive = 'Y'";
|
||||
$so_id = $this->db->query($qry)->row()->So_ResultEntryID;
|
||||
}
|
||||
// echo 'so id '.$so_id;
|
||||
|
||||
//PROSES
|
||||
$arr_map = $this->getArrayMap();
|
||||
$sql = "select * from x_adm_rekap_fisik_organ where REG_NO = '{$labnumber}'";
|
||||
$qry = $this->db->query($sql, [$reg_no]);
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Error get x_adm_rekap_fisik_organ | " . $this->db->error()["message"]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
foreach ($rows as $r) {
|
||||
foreach ($r as $key => $value) {
|
||||
if ($key == "REG_NO") continue;
|
||||
list($id_code, $templateID) = $arr_map[$key];
|
||||
list($soResultEntryFisikUmumID, $strJsonAwal) = $this->getSoResultEntryFisikUmumID($so_id, $templateID);
|
||||
$jsonAwal = json_decode($strJsonAwal, true);
|
||||
// update jsonAwal sesuai dengan id_code dan value nya
|
||||
// kalau sudah update ke so_resultentryfisikumum
|
||||
switch ($id_code) {
|
||||
case "gizi_1":
|
||||
//update jsonAwal utk gizi_1
|
||||
break;
|
||||
case "gizi_2":
|
||||
//update jsonAwal utk gizi_1
|
||||
break;
|
||||
}
|
||||
print_r($jsonAwal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Tidak ditemukan data"
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
function getArrayMap()
|
||||
{
|
||||
$sql = "select * from x_map_fisik_organ";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Error get x_map_fisik_organ | " . $this->db->error()["message"]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
$arr_map = [];
|
||||
$rows = $qry->result_array();
|
||||
foreach ($rows as $r) {
|
||||
$arr_map[$r["name"]] = [$r["code_id"], $r["templateID"]];
|
||||
}
|
||||
return $arr_map;
|
||||
}
|
||||
function getSoResultEntryFisikUmumID($soResultEntryID, $templateID)
|
||||
{
|
||||
$so_resultentryid = $soResultEntryID;
|
||||
$templateid = $templateID;
|
||||
$sql = "SELECT *
|
||||
FROM so_resultentry_fisik_umum
|
||||
WHERE So_ResultEntryFisikUmumSo_ResultEntryID = ?
|
||||
AND So_ResultEntryFisikUmumFisikTemplateID = ?
|
||||
AND So_ResultEntryFisikUmumIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Error get so_resultentry_fisik_umum | " . $this->db->error()["message"]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
$arr_map = [];
|
||||
$rows = $qry->result_array();
|
||||
|
||||
foreach ($rows as $r) {
|
||||
$arr_map[$r["So_ResultEntryFisikUmumID"]] = [$r["So_ResultEntryFisikUmumID"], $r["So_ResultEntryFisikUmumDetails"]];
|
||||
}
|
||||
|
||||
print_r($arr_map);
|
||||
exit;
|
||||
|
||||
return $arr_map;
|
||||
|
||||
//cari di so_resultentryfisikumum
|
||||
// jika ketemu returnkan So_ResultEntryFisikUmumDetails
|
||||
// jika tidak ketemu cari dari fisik template , FisikTemplateJSON
|
||||
// insertkan ke so_resultentryfisikumum
|
||||
|
||||
//retun nya [So_ResultEntryFisikUmumID, JSON]
|
||||
}
|
||||
}
|
||||
71
application/controllers/tools/Fix_resample.php
Normal file
71
application/controllers/tools/Fix_resample.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
class Fix_resample extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
function check($date = "") {
|
||||
if ($date == "" ) $date = date("Y-m-d");
|
||||
$sql = "select T_OrderHeaderLabNumber, T_TestName, T_OrderHeaderID,
|
||||
T_TestT_SampleTypeID, group_concat(T_OrderDetailAddOnID) xids
|
||||
from t_orderdetail
|
||||
join t_orderheader on T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
and date(T_OrderHeaderDate) = ?
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join t_orderdetailaddon on T_OrderDetailID = T_OrderDetailAddOnT_OrderDetailID
|
||||
where T_OrderDetailAddOnReSample = 'Y'
|
||||
and T_OrderDetailAddOnReSampleStatus = 'R'
|
||||
group by T_OrderHeaderID,T_TestT_SampleTypeID";
|
||||
$qry = $this->db_onedev->query($sql, array($date) );
|
||||
if (!$qry) {
|
||||
print_r($this->db->error());
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
|
||||
$sql = "select T_OrderSampleBarcode, T_OrderSampleSampling
|
||||
from t_ordersample
|
||||
where T_OrderSampleT_OrderHeaderID = ? and T_OrderSampleT_SampleTypeID = ?
|
||||
and T_OrderSampleIsActive = 'Y'";
|
||||
foreach($rows as $r ) {
|
||||
//check if all already sampling
|
||||
echo $r["T_OrderHeaderLabNumber"] . ", " . $r["T_TestName"] . " :\n";
|
||||
$headerID = $r["T_OrderHeaderID"];
|
||||
$sampleID = $r["T_TestT_SampleTypeID"];
|
||||
$addonIDS = $r["xids"];
|
||||
$qry = $this->db->query($sql, array($headerID,$sampleID));
|
||||
|
||||
if ($qry) {
|
||||
$d_rows = $qry->result_array();
|
||||
$all_is_sampling = true;
|
||||
foreach($d_rows as $d_r) {
|
||||
echo $d_r["T_OrderSampleBarcode"] . " is sampling " . $d_r["T_OrderSampleSampling"] . "\n";
|
||||
if ($d_r["T_OrderSampleSampling"] == "N" ) $all_is_sampling = false;
|
||||
}
|
||||
echo "All : $all_is_sampling\n ";
|
||||
if ($all_is_sampling ) {
|
||||
echo "ids : $addonIDS \n";
|
||||
if ($addonIDS != "" ) {
|
||||
$sql_u = "update t_orderdetailaddon set T_OrderDetailAddOnReSampleStatus = 'W'
|
||||
where T_OrderDetailAddOnID in ($addonIDS ) ";
|
||||
$this->db->query($sql_u);
|
||||
echo "Fixed Resample\n";
|
||||
}
|
||||
} else {
|
||||
echo "Belum semua barcode di sampling\n";
|
||||
}
|
||||
} else {
|
||||
print_r($this->db->error());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
73
application/controllers/tools/Fixexpertisi.php
Normal file
73
application/controllers/tools/Fixexpertisi.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
class Fixexpertisi extends MY_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function fix_all() {
|
||||
$sql = "update ss_expertisi,t_orderdetail
|
||||
set SsExpertisiAmount = T_OrderDetailTotal
|
||||
where SsExpertisiT_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and SsExpertisiT_TestID = T_OrderDetailT_TestID and SsExpertisiAmount = 0
|
||||
";
|
||||
$this->db->query($sql);
|
||||
|
||||
$sql = "select SsExpertisiID, SsExpertisiT_OrderHeaderID,SsExpertisiT_TestID,
|
||||
T_OrderDetailT_TestSasCode T_TestSasCode
|
||||
from ss_expertisi
|
||||
join t_orderdetail on T_OrderDetailT_OrderHeaderID= SsExpertisiT_OrderHeaderID
|
||||
and T_OrderDetailT_TestID = SsExpertisiT_TestID
|
||||
where SsExpertisiAmount = 0";
|
||||
$qry = $this->db->query($sql );
|
||||
$rows = array();
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
foreach($rows as $r) {
|
||||
$orderHeaderID= $r["SsExpertisiT_OrderHeaderID"];
|
||||
$testID= $r["SsExpertisiT_TestID"];
|
||||
$sasCode = $r["T_TestSasCode"];
|
||||
$SsExpertisiID = $r["SsExpertisiID"];
|
||||
|
||||
$sql = "select T_OrderDetailAddOnT_PacketID
|
||||
from
|
||||
t_orderdetail
|
||||
join t_orderdetailaddon on T_OrderDetailID = T_OrderDetailAddOnT_OrderDetailID
|
||||
and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderDetailT_OrderHeaderID = ?
|
||||
and T_OrderDetailAddOnIsPacket = 'Y'
|
||||
and instr(?, T_OrderDetailT_TestSasCode)
|
||||
";
|
||||
|
||||
$qry = $this->db->query($sql, array($orderHeaderID, $sasCode));
|
||||
if($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$packetID = $rows[0]["T_OrderDetailAddOnT_PacketID"];
|
||||
$sql = "select T_PacketDetailPrice
|
||||
from t_packetdetail
|
||||
where T_PacketDetailIsActive = 'Y'
|
||||
and t_PacketDetailT_PacketID = ? and T_PacketDetailT_TestID = ? ";
|
||||
$qry = $this->db->query($sql, array($packetID, $testID));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$price = $rows[0]["T_PacketDetailPrice"];
|
||||
if ($price > 0 ) {
|
||||
$sql = "update ss_expertisi set SsExpertisiAmount = ?
|
||||
where SsExpertisiID = ? ";
|
||||
$this->db->query($sql, array($price,$SsExpertisiID));
|
||||
echo "update $SsExpertisiID , price : $price \n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print_r($this->db->error());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print_r($this->db->error());
|
||||
}
|
||||
}
|
||||
}
|
||||
105
application/controllers/tools/Fixsspayment.php
Normal file
105
application/controllers/tools/Fixsspayment.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
class Fixsspayment extends MY_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function fix_is_last($orderID) {
|
||||
$sql = "update ss_piutang set SsPiutangIsLast = 'N' where SsPiutangT_OrderHeaderID = ?";
|
||||
$this->db->query($sql, array($orderID));
|
||||
$sql = "select max(SsPiutangID) mID from ss_piutang where SsPiutangT_OrderHeaderID = ?";
|
||||
$qry = $this->db->query($sql,array($orderID)) ;
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$id = $rows[0]["mID"];
|
||||
$sql = "update ss_piutang set SsPiutangIsLast = 'Y' where SsPiutangID = ?";
|
||||
$this->db->query($sql, array($id));
|
||||
}
|
||||
}
|
||||
}
|
||||
function fix_date($date) {
|
||||
$sql = "select * from ss_piutang where SsPiutangType = 'B2' and SsPiutangDate = ?";
|
||||
$qry = $this->db->query($sql , array($date));
|
||||
$rows = array();
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
foreach($rows as $r) {
|
||||
$ssPiutangID = $r["SsPiutangID"];
|
||||
$ssPiutangTotal = $r["SsPiutangTotal"];
|
||||
$ssPiutangPayment = $r["SsPiutangPayment"];
|
||||
|
||||
$orderID = $r["SsPiutangT_OrderHeaderID"];
|
||||
$date = $r["SsPiutangDate"];
|
||||
$sql = "select sum(SsPiutangPayment) as tot
|
||||
from ss_piutang
|
||||
where SsPiutangT_OrderHeaderID = ?
|
||||
and SsPiutangDate < ? ";
|
||||
$qryd = $this->db->query($sql, array($orderID,$date));
|
||||
if ($qryd) {
|
||||
$rows = $qryd->result_array();
|
||||
$total = $rows[0]["tot"];
|
||||
$isLunas = "N";
|
||||
if ($total == $ssPiutangTotal - $ssPiutangPayment) {
|
||||
$isLunas = "Y";
|
||||
}
|
||||
|
||||
$sql = "update
|
||||
ss_piutang
|
||||
set SsPiutangPaymentBefore = ?,
|
||||
SsPiutangIsLunas = ?
|
||||
where
|
||||
SsPiutangID = ? ";
|
||||
$this->db->query($sql, array($total, $isLunas, $ssPiutangID));
|
||||
|
||||
$this->fix_is_last($orderID);
|
||||
echo "Update $ssPiutangID : $orderID \n";
|
||||
} else {
|
||||
print_r($this->db->error());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function fix_all() {
|
||||
$sql = "select * from ss_piutang where SsPiutangType = 'B2'";
|
||||
$qry = $this->db->query($sql );
|
||||
$rows = array();
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
foreach($rows as $r) {
|
||||
$ssPiutangID = $r["SsPiutangID"];
|
||||
$ssPiutangTotal = $r["SsPiutangTotal"];
|
||||
$ssPiutangPayment = $r["SsPiutangPayment"];
|
||||
|
||||
$orderID = $r["SsPiutangT_OrderHeaderID"];
|
||||
$date = $r["SsPiutangDate"];
|
||||
$sql = "select sum(SsPiutangPayment) as tot
|
||||
from ss_piutang
|
||||
where SsPiutangT_OrderHeaderID = ?
|
||||
and SsPiutangDate < ? ";
|
||||
$qryd = $this->db->query($sql, array($orderID,$date));
|
||||
if ($qryd) {
|
||||
$rows = $qryd->result_array();
|
||||
$total = $rows[0]["tot"];
|
||||
$isLunas = "N";
|
||||
if ($total == $ssPiutangTotal - $ssPiutangPayment) {
|
||||
$isLunas = "Y";
|
||||
}
|
||||
|
||||
$sql = "update
|
||||
ss_piutang
|
||||
set SsPiutangPaymentBefore = ?,
|
||||
SsPiutangIsLunas = ?
|
||||
where
|
||||
SsPiutangID = ? ";
|
||||
$this->db->query($sql, array($total, $isLunas, $ssPiutangID));
|
||||
|
||||
echo "Update $ssPiutangID : $orderID \n";
|
||||
} else {
|
||||
print_r($this->db->error());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
429
application/controllers/tools/Future_generate.php
Normal file
429
application/controllers/tools/Future_generate.php
Normal file
@@ -0,0 +1,429 @@
|
||||
<?php
|
||||
class Future_generate extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->debug = false;
|
||||
$this->PJ_DOCTOR_ID = 0;
|
||||
$this->SENDER_DOCTOR_ID = 0;
|
||||
$this->SENDER_ADDRESS_ID = 0;
|
||||
$this->ONLINE_USER_ID=1500;
|
||||
}
|
||||
public function now()
|
||||
{
|
||||
return Date("Y-m-d H:i:s");
|
||||
}
|
||||
|
||||
|
||||
public function get_branch_default()
|
||||
{
|
||||
$sql = "select * from m_branch where M_BranchIsDefault = 'Y' and M_BranchIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
echo "{$this->now()} ERR : {$this->db->error()['message']}\n";
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo "{$this->now()} ERR Get Default Branch: {$this->db->error()['message']}\n";
|
||||
exit;
|
||||
}
|
||||
$branchKelurahanID = $rows[0]["M_BranchM_KelurahanID"];
|
||||
$this->SENDER_DOCTOR_ID = $rows[0]["M_BranchM_DoctorID"];
|
||||
$this->SENDER_ADDRESS_ID = $rows[0]["M_BranchM_DoctorAddressID"];
|
||||
|
||||
$sql = "select * from m_doctorpj where M_DoctorPjIsActive = 'Y' and M_DoctorPjIsDefaultPJ='Y'";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
echo "{$this->now()} ERR : {$this->db->error()['message']}\n";
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo "{$this->now()} ERR Get Default PJ: {$this->db->error()['message']}\n";
|
||||
exit;
|
||||
}
|
||||
$this->PJ_DOCTOR_ID = $rows[0]["M_DoctorPjM_DoctorID"];
|
||||
|
||||
return array($branchKelurahanID);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function do_pelunasan(
|
||||
$headerID,
|
||||
$bankAccountID,
|
||||
$paymentTypeID,
|
||||
$paymentNote,
|
||||
$amount
|
||||
) {
|
||||
$paymentTotal = $amount;
|
||||
$paymentDate = date("Y-m-d H:i:s");
|
||||
$arr = array(
|
||||
"F_PaymentT_OrderHeaderID" => $headerID,
|
||||
"F_PaymentDate" => $paymentDate,
|
||||
"F_PaymentNote" => $paymentNote,
|
||||
"F_PaymentTotal" => $paymentTotal,
|
||||
"F_PaymentM_UserID" => $this->ONLINE_USER_ID
|
||||
);
|
||||
$qry = $this->db->insert("f_payment", $arr);
|
||||
if (!$qry) {
|
||||
echo "{$this->now()} ERR Get Total Order: {$this->db->error()['message']} | {$this->db->last_query()}\n";
|
||||
return false;
|
||||
}
|
||||
$paymentID = $this->db->insert_id();
|
||||
$detailNote = "";
|
||||
|
||||
$arr = array(
|
||||
"F_PaymentDetailF_PaymentID" => $paymentID,
|
||||
"F_PaymentDetailM_PaymentTypeID" => $paymentTypeID,
|
||||
"F_PaymentDetailEDCNat_BankID" => 0,
|
||||
"F_PaymentDetailCardNat_BankID" => 0,
|
||||
"F_PaymentDetailM_BankAccountID" => $bankAccountID,
|
||||
"F_PaymentDetailNote" => $paymentNote,
|
||||
"F_PaymentDetailAmount" => $paymentTotal,
|
||||
"F_PaymentDetailActual" => $paymentTotal,
|
||||
"F_PaymentDetailChange" => 0
|
||||
);
|
||||
$qry = $this->db->insert("f_paymentdetail", $arr);
|
||||
if (!$qry) {
|
||||
echo "{$this->now()} ERR Pelunasan: {$this->db->error()['message']} | {$this->db->last_query()}\n";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function add_delivery_note($orderHeaderID,$delivery_note) {
|
||||
$rst_id = $orderHeaderID;
|
||||
$db_msg = "";
|
||||
foreach($delivery_note as $k => $v){
|
||||
if($v['noteplus'] != ''){
|
||||
if($v['delivery_code'] == 'EMAIL' || $v['delivery_code'] == 'WHATSAPP' || $v['delivery_code'] == 'TELEGRAM'){
|
||||
$sql = "UPDATE t_orderdelivery SET T_OrderDeliveryDestination = '{$v['noteplus']}'
|
||||
WHERE
|
||||
T_OrderDeliveryT_OrderHeaderID = {$rst_id} AND
|
||||
T_OrderDeliveryM_DeliveryID = {$v['delivery_id']} AND
|
||||
T_OrderDeliveryM_DeliveryTypeID = {$v['delivery_type_id']} AND
|
||||
T_OrderDeliveryAddressID = {$v['address_id']} AND
|
||||
T_OrderDeliveryIsActive = 'Y'";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
if(! $qry) {
|
||||
$db_msg .= "ERR : Update T_orderDelivery " . $this->db->error()['message'] . " | " . $$this->db->last_query();
|
||||
$db_msg .= "\n";
|
||||
}
|
||||
}
|
||||
else{
|
||||
$sql = "SELECT T_OrderDeliveryID as xdel_id
|
||||
FROM t_orderdelivery
|
||||
WHERE
|
||||
T_OrderDeliveryT_OrderHeaderID = {$rst_id} AND
|
||||
T_OrderDeliveryM_DeliveryID = {$v['delivery_id']} AND
|
||||
T_OrderDeliveryM_DeliveryTypeID = {$v['delivery_type_id']} AND
|
||||
T_OrderDeliveryAddressID = {$v['address_id']} AND
|
||||
T_OrderDeliveryIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
if(! $qry) {
|
||||
$db_msg .= "ERR : Get T_orderDelivery for XDel " . $this->db->error()['message'] . " | " . $$this->db->last_query();
|
||||
$db_msg .= "\n";
|
||||
}
|
||||
$xdel_id = $qry->row()->xdel_id;
|
||||
|
||||
$sql = "INSERT INTO t_orderdeliverynote(
|
||||
T_OrderDeliveryNoteT_OrderDeliveryID,
|
||||
T_OrderDeliveryNoteValue,
|
||||
T_OrderDeliveryNoteCreated,
|
||||
T_OrderDeliveryNoteUserID
|
||||
)
|
||||
VALUES(
|
||||
{$xdel_id},
|
||||
'{$v['noteplus']}',
|
||||
NOW(),
|
||||
{$this->sys_user['M_UserID']}
|
||||
)";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
if(! $qry) {
|
||||
$db_msg .= "ERR : Update T_orderDelivery " . $this->db->error()['message'] . " | " . $$this->db->last_query();
|
||||
$db_msg .= "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $db_msg;
|
||||
}
|
||||
|
||||
public function daily() {
|
||||
echo "{$this->now()} Get Daily FutureOrder Process.\n";
|
||||
$sql = "select FutureOrderID, FutureOrderNumber
|
||||
from future_order
|
||||
left join future_map on FutureOrderID = FutureMapFutureOrderID
|
||||
and FutureMapIsActive = 'Y'
|
||||
where FutureOrderIsActive = 'Y'
|
||||
and FutureOrderDateBooking = date(now())
|
||||
and FutureMapID is null";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
echo "{$this->now()} Err Get Daily FutureOrder {$this->db->error()['message']} | {$this->db->last_query()}\n";
|
||||
return;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
foreach($rows as $r ) {
|
||||
$futureOrderID = $r["FutureOrderID"];
|
||||
$futureOrderNumber = $r["FutureOrderNumber"];
|
||||
echo "{$this->now()} Processing {$futureOrderNumber}\n";
|
||||
$this->generate_order($futureOrderID);
|
||||
}
|
||||
}
|
||||
public function generate_order($futureOrderID)
|
||||
{
|
||||
$this->db->trans_begin();
|
||||
$this->get_branch_default();
|
||||
|
||||
$sql = "select future_order.*,
|
||||
if(FutureMapIsActive is null , 'N', 'Y') isMapped
|
||||
from future_order
|
||||
left join future_map
|
||||
on FutureOrderID = FutureMapFutureOrderID
|
||||
where FutureOrderID = ?
|
||||
";
|
||||
$qry = $this->db->query($sql,[$futureOrderID]);
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
echo "{$this->now()} Err GetFutureOrder {$this->db->error()['message']} | {$this->db->last_query()}\n";
|
||||
return;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if(count($rows) == 0 ){
|
||||
$this->db->trans_rollback();
|
||||
echo "{$this->now()} Err GetFutureOrder not found | {$this->db->last_query()}\n";
|
||||
return;
|
||||
}
|
||||
if ($rows[0]["isMapped"] == "Y" ) {
|
||||
$this->db->trans_rollback();
|
||||
echo "{$this->now()} Err Order sudah di future_map | {$this->db->last_query()}\n";
|
||||
return;
|
||||
}
|
||||
$futureOrder = $rows[0];
|
||||
echo "{$this->now()} Create Order from {$futureOrder['FutureOrderNumber']} \n";
|
||||
|
||||
$header = json_decode($futureOrder["FutureOrderJSONHeader"],true);
|
||||
$delivery = json_decode($futureOrder["FutureOrderJSONDelivery"],true);
|
||||
$delivery_note = json_decode($futureOrder["FutureOrderJSONDeliveryNote"],true);
|
||||
$req = json_decode($futureOrder["FutureOrderJSONReq"],true);
|
||||
$detail= json_decode($futureOrder["FutureOrderJSONDetail"],true);
|
||||
$header_json = addslashes(str_replace('\n', '\\\n', json_encode($header)));
|
||||
$detail_json = str_replace('\n', '\\\n', json_encode($detail));
|
||||
$delivery_json = addslashes(str_replace('\n', '\\\n', json_encode($delivery)));
|
||||
|
||||
$req_json = json_encode($req);
|
||||
$sql = "CALL sp_fo_register_save_v5('', '{$header_json}', '{$delivery_json}',
|
||||
'{$detail_json}', '{$req_json}', '3');";
|
||||
$query = $this->db->query($sql);
|
||||
if (!$query) {
|
||||
$this->db->trans_rollback();
|
||||
echo "{$this->now()} Err Create Order : {$this->db->error()['message']} | {$this->db->last_query()}\n";
|
||||
return;
|
||||
}
|
||||
$rst = $query->row();
|
||||
$rst->data = json_decode($rst->data);
|
||||
$rst_id = $rst->data->id;
|
||||
|
||||
$this->clean_mysqli_connection($this->db->conn_id);
|
||||
|
||||
$orderHeaderID = $rst_id;
|
||||
|
||||
if($orderHeaderID == 0 ){
|
||||
$this->db->trans_rollback();
|
||||
echo "{$this->now()} Err Generate Order | {$this->db->last_query()}\n";
|
||||
return;
|
||||
}
|
||||
$orderHeaderNo = $rst->data->number;
|
||||
|
||||
$db_msg = $this->add_delivery_note($orderHeaderID,$delivery_note);
|
||||
if ($db_msg != "" ) {
|
||||
$this->db->trans_rollback();
|
||||
echo "{$this->now()} Err Add Delivery Note $db_msg\n";
|
||||
return;
|
||||
}
|
||||
|
||||
//Doctor Alias
|
||||
$sql = "UPDATE t_orderheaderaddon
|
||||
SET T_OrderHeaderAddOnAliasDoctorName = '{$futureOrder['FutureOrderDoctorAlias']}',
|
||||
T_OrderHeaderAddOnAliasDoctorAddress = '{$futureOrder['FutureOrderDoctorAddress']}',
|
||||
T_OrderHeaderAddOnFoTimeStart = '{$futureOrder['FutureOrderFoTimeStart']}',
|
||||
T_OrderHeaderAddOnFoTimeEnd = '{$futureOrder['FutureOrderFoTimeEnd']}'
|
||||
WHERE
|
||||
T_OrderHeaderAddOnT_OrderHeaderID = '{$orderHeaderID}'";
|
||||
$query = $this->db->query($sql);
|
||||
if (!$query) {
|
||||
$this->db->trans_rollback();
|
||||
echo "{$this->now()} Err Create Order : {$this->db->error()['message']} | {$this->db->last_query()}\n";
|
||||
return;
|
||||
}
|
||||
|
||||
// futtureMap
|
||||
$arr = array(
|
||||
"FutureMapT_OrderHeaderID" => $orderHeaderID,
|
||||
"FutureMapFutureOrderID" => $futureOrderID,
|
||||
);
|
||||
$qry = $this->db->insert("future_map", $arr);
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
echo "{$this->now()} Err Future Map: {$this->db->error()['message']} | {$this->db->last_query()}\n";
|
||||
return;
|
||||
}
|
||||
//
|
||||
// Down payment
|
||||
//
|
||||
$sql = "select group_concat(FutureDownpaymentNumber) as dpNo,
|
||||
sum(FutureDownpaymentTotal) dpTotal
|
||||
from future_downpayment
|
||||
where FutureDownpaymentFutureOrderID = ?
|
||||
and FutureDownpaymentIsActive='Y'";
|
||||
|
||||
$query = $this->db->query($sql,$futureOrderID);
|
||||
if (!$query) {
|
||||
$this->db->trans_rollback();
|
||||
echo "{$this->now()} Err Get DownPaymentNumber : {$this->db->error()['message']} | {$this->db->last_query()}\n";
|
||||
return;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
$dpTotal = 0;
|
||||
$dpNo = "";
|
||||
if (count($rows) > 0 ) {
|
||||
$dpTotal = $rows[0]["dpTotal"];
|
||||
$dpNo = $rows[0]["dpNo"];
|
||||
}
|
||||
|
||||
if ($dpTotal == 0 ) {
|
||||
echo "{$this->now()} ERR : No Down Payment\nDP NO. $dpNo \n Amount: $dpTotal\n";
|
||||
$this->db->trans_rollback();
|
||||
return;
|
||||
}
|
||||
$bankAccountID = 0;
|
||||
$paymentTypeID = 10;
|
||||
$paymentNote = "DP : $dpNo";
|
||||
$rst_payment = $this->do_pelunasan(
|
||||
$orderHeaderID,
|
||||
$bankAccountID,
|
||||
$paymentTypeID,
|
||||
$paymentNote,
|
||||
$dpTotal
|
||||
);
|
||||
|
||||
|
||||
if ($this->db->trans_status === false) {
|
||||
$this->db->trans_rollback();
|
||||
echo "{$this->now()} ERR : {$db_msg}\n";
|
||||
} else {
|
||||
$this->db->trans_commit();
|
||||
echo "{$this->now()} $orderHeaderNo [Success]\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function do_order_log($orderHeaderID,$delivery) {
|
||||
$rst_id = $$orderHeaderID;
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM t_orderheader
|
||||
JOIN m_patient ON M_PatientID = T_OrderHeaderM_PatientID
|
||||
WHERE
|
||||
T_OrderHeaderID = {$rst_id}";
|
||||
//echo $sql;
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
echo "{$this->now()} ERR : {$db_msg}\n";
|
||||
return false;
|
||||
}
|
||||
$x_header = $qry->row_array();
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$rst_id} AND
|
||||
T_OrderDetailT_TestIsPrice = 'Y' AND
|
||||
T_OrderDetailIsActive = 'Y'";
|
||||
|
||||
$x_details = $this->db_smartone->query($sql)->result_array();
|
||||
$x_details = json_encode($x_details);
|
||||
$x_deliveries = json_encode($delivery);
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM t_orderpromise
|
||||
WHERE
|
||||
T_OrderPromiseT_OrderHeaderID = {$rst_id} AND T_OrderPromiseIsActive = 'Y'";
|
||||
$x_promises = $this->db_smartone->query($sql)->result_array();
|
||||
$x_promises = json_encode($x_promises);
|
||||
|
||||
$sql = "INSERT INTO order_log(
|
||||
OrderLogT_OrderHeaderID,
|
||||
OrderLogM_PatientDOB,
|
||||
OrderLogM_CompanyID,
|
||||
OrderLogM_MouID,
|
||||
OrderLogM_DoctorSenderID,
|
||||
OrderLogM_DoctorSenderAddressID,
|
||||
orderLogT_OrderHeaderAddOnAliasDoctorName,
|
||||
orderLogT_OrderHeaderAddOnAliasDoctorAddress,
|
||||
OrderLogAge,
|
||||
OrderLogFoNote,
|
||||
OrderLogSubtotal,
|
||||
OrderLogTotal,
|
||||
OrderLogUserID,
|
||||
OrderLogDetails,
|
||||
OrderLogDeliveries,
|
||||
OrderLogPromises
|
||||
)
|
||||
VALUES(
|
||||
{$rst_id},
|
||||
'{$x_header['M_PatientDOB']}',
|
||||
{$x_header['T_OrderHeaderM_CompanyID']},
|
||||
{$x_header['T_OrderHeaderM_MouID']},
|
||||
{$x_header['T_OrderHeaderSenderM_DoctorID']},
|
||||
{$x_header['T_OrderHeaderSenderM_DoctorAddressID']},
|
||||
'{$hdr['alias_doctor']}',
|
||||
'{$hdr['alias_doctor_address']}',
|
||||
'{$x_header['T_OrderHeaderM_PatientAge']}',
|
||||
'{$x_header['T_OrderHeaderFoNote']}',
|
||||
'{$x_header['T_OrderHeaderSubTotal']}',
|
||||
'{$x_header['T_OrderHeaderTotal']}',
|
||||
{$this->sys_user['M_UserID']},
|
||||
'{$x_details}',
|
||||
'{$x_deliveries}',
|
||||
'{$x_promises}'
|
||||
)";
|
||||
$this->db->query($sql);
|
||||
}
|
||||
|
||||
|
||||
public function update_delivery($orderID, $deliveries)
|
||||
{
|
||||
$db_msg = "";
|
||||
$sql = "update t_orderdelivery set T_OrderDeliveryIsActive = 'N'
|
||||
where T_OrderDeliveryT_OrderHeaderID = ?";
|
||||
$qry = $this->db->query($sql, array($orderID));
|
||||
if (!$qry) {
|
||||
return "ERR Update Delivery | " . $this->db->error()["message"] . "|"
|
||||
. $this->db->last_query();
|
||||
}
|
||||
foreach ($deliveries as $d) {
|
||||
$arr = array(
|
||||
"T_OrderDeliveryT_OrderHeaderID" => $orderID,
|
||||
"T_OrderDeliveryM_DeliveryID" => $d["T_OrderDeliveriesM_DeliveryID"],
|
||||
"T_OrderDeliveryM_DeliveryTypeID" => $d["T_OrderDeliveriesM_DeliveryTypeID"],
|
||||
"T_OrderDeliveryDestination" => $d["T_OrderDeliveriesDestination"]
|
||||
);
|
||||
$qry = $this->db->insert("t_orderdelivery", $arr);
|
||||
if (!$qry) {
|
||||
$db_msg .= "ERR Update Delivery | " . $this->db->error()["message"] . "|"
|
||||
. $this->db->last_query() . "\n";
|
||||
}
|
||||
}
|
||||
return $db_msg;
|
||||
}
|
||||
|
||||
}
|
||||
// asumsi 1 order 1 janji hasil
|
||||
160
application/controllers/tools/Futureorderfix.php
Normal file
160
application/controllers/tools/Futureorderfix.php
Normal file
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
|
||||
class Futureorderfix extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "CONTROL API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
function lookuptransaction(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm['search'];
|
||||
$all = $prm['all'];
|
||||
$sdate = $prm['sdate'];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql = "select COUNT(*) as total
|
||||
from future_order
|
||||
LEFT JOIN future_map ON FutureMapFutureOrderID = FutureOrderID AND FutureMapIsActive = 'Y'
|
||||
LEFT JOIN t_orderheader ON T_OrderHeaderID = FutureMapT_OrderHeaderID
|
||||
where
|
||||
FutureOrderIsActive = 'Y' AND
|
||||
(FutureOrderNumber LIKE CONCAT('%','{$search}','%') OR
|
||||
T_OrderHeaderLabNumber LIKE CONCAT('%','{$search}','%')) AND
|
||||
T_OrderHeaderID IS NULL";
|
||||
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count/$number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("future_order count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select FutureOrderID as id,
|
||||
DATE_FORMAT(FutureOrderDateBooking,'%d-%m-%Y') as tanggal,
|
||||
future_order.*,
|
||||
T_OrderHeaderLabNumber,
|
||||
IF(FutureOrderDateBooking <= date(now()) , 'N','Y') as ishide,
|
||||
JSON_UNQUOTE(JSON_EXTRACT(fn_get_patient_atribute(FutureOrderM_PatientID), '$.patient_fullname')) as M_PatientName
|
||||
from future_order
|
||||
LEFT JOIN future_map ON FutureMapFutureOrderID = FutureOrderID AND FutureMapIsActive = 'Y'
|
||||
LEFT JOIN t_orderheader ON T_OrderHeaderID = FutureMapT_OrderHeaderID
|
||||
where
|
||||
FutureOrderIsActive = 'Y' AND
|
||||
(FutureOrderNumber LIKE CONCAT('%','{$search}','%') OR
|
||||
T_OrderHeaderLabNumber LIKE CONCAT('%','{$search}','%')) AND
|
||||
T_OrderHeaderID IS NULL
|
||||
GROUP BY FutureOrderID
|
||||
ORDER BY FutureOrderDateBooking ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("future_order select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => $tot_page, "total_filter"=>count($rows),"records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function fix()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$nomor = md5($prm['nomor']);
|
||||
$sql = $this->db_onedev->query("SELECT M_BranchIPAddress as branch_ip_address FROM m_branch WHERE M_BranchIsDefault = 'Y'")->row();
|
||||
$branch_ip_address = $sql->branch_ip_address;
|
||||
$param = array (
|
||||
"id" => $id,
|
||||
"nomor" => $nomor);
|
||||
$j_param = json_encode($param);
|
||||
$url = "http://$branch_ip_address/one-api/fix/fix_future/do_fix/".$id."/".$nomor;
|
||||
$post_rst = $this->post($url);
|
||||
// echo "to $url \nresponse : $post_rst\n";
|
||||
$j_rst = json_decode($post_rst,true);
|
||||
$xstatus = $j_rst["status"];
|
||||
$xpesan = $j_rst["message"];
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0),"pesan"=>$post_rst);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function post($url) {
|
||||
//$data = $data;
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
$result = curl_exec($ch);
|
||||
//echo "RST : $result ";
|
||||
return $result;
|
||||
}
|
||||
function postold($url,$data) {
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 12);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data))
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
if (curl_errno($ch)){
|
||||
return json_encode( array("status" => "ERR",
|
||||
"message" => curl_error($ch)) );
|
||||
}
|
||||
curl_close($ch);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
54
application/controllers/tools/Futureorderlog.php
Normal file
54
application/controllers/tools/Futureorderlog.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
class Futureorderlog extends MY_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
function show($logfile) {
|
||||
$fp = file_get_contents("/xtmp/{$logfile}.log");
|
||||
$arr = explode("\n", $fp);
|
||||
$arr = array_slice($arr, -1000);
|
||||
$arr = array_reverse($arr);
|
||||
$msg = implode("\n", $arr);
|
||||
echo "<pre>$msg</pre>";
|
||||
}
|
||||
function read_log($logfile)
|
||||
{
|
||||
$fp = fopen("/xtmp/{$logfile}.log", 'r');
|
||||
$pos = -1; // Skip final new line character (Set to -1 if not present)
|
||||
|
||||
$lines = array();
|
||||
$currentLine = '';
|
||||
$idx = 0;
|
||||
$msg = "<pre>";
|
||||
while (-1 !== fseek($fp, $pos, SEEK_END)) {
|
||||
$char = fgetc($fp);
|
||||
if (PHP_EOL == $char) {
|
||||
$msg .= $currentLine;
|
||||
echo $msg;
|
||||
$currentLine = '';
|
||||
} else {
|
||||
$currentLine = $char . $currentLine;
|
||||
}
|
||||
$pos--;
|
||||
$idx++;
|
||||
if ($idx > 1000) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
$msg .= "</pre>";
|
||||
return $msg;
|
||||
}
|
||||
function index()
|
||||
{
|
||||
|
||||
$fp = file_get_contents("/xtmp/future_order.log");
|
||||
$arr = explode("\n", $fp);
|
||||
$arr = array_slice($arr, -500);
|
||||
$arr = array_reverse($arr);
|
||||
$msg = implode("\n", $arr);
|
||||
echo "<pre>$msg</pre>";
|
||||
}
|
||||
}
|
||||
138
application/controllers/tools/Icopy.php
Normal file
138
application/controllers/tools/Icopy.php
Normal file
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
ini_set('display_errors', '1');
|
||||
ini_set('display_startup_errors', '1');
|
||||
error_reporting(E_ALL);
|
||||
|
||||
class Icopy extends MY_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
function getimage() {
|
||||
$xdb = $this->load->database("onedev",true);
|
||||
$pwd = $xdb->password;
|
||||
$filenow = "/home/one/project/one/one-media/one-photo/patient/".date("Y");
|
||||
//$filenow = "/home/one/project/one/one-media/one-photo/patient/xcoba";
|
||||
|
||||
$temp_file = tempnam(sys_get_temp_dir(), 'photo-') . ".tar.gz";
|
||||
if ( file_exists($temp_file) ) unlink($temp_file);
|
||||
$cmd = "tar -C $filenow -cvf $temp_file ./";
|
||||
exec($cmd);
|
||||
if (file_exists($temp_file)) {
|
||||
header('Content-Description: File Transfer');
|
||||
header('Content-Type: application/octet-stream');
|
||||
header('Content-Disposition: attachment; filename="'.basename($temp_file).'"');
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate');
|
||||
header('Pragma: public');
|
||||
header('Content-Length: ' . filesize($temp_file));
|
||||
readfile($temp_file);
|
||||
unlink($temp_file);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function update($mcuCode) {
|
||||
$sql = "update mcu_offline_prepare set McuOfflinePrepareIsDownloaded = 'Y'
|
||||
where McuOfflinePrepareCode = ?";
|
||||
$query = $this->db->query($sql,array($mcuCode));
|
||||
if (! $query) {
|
||||
echo "ERR| MCU Code : $mcuCode is not found !";
|
||||
echo $this->db->error()->message;
|
||||
exit;
|
||||
}
|
||||
echo "OK |MCU Offline $mcuCode sudah ter download !";
|
||||
}
|
||||
|
||||
function info($branchCode,$mcuCode) {
|
||||
$sql = "select * from m_branch where M_BranchIsActive = 'Y' and M_BranchCode = ? and M_BranchIsDefault = 'Y'";
|
||||
$query = $this->db->query($sql,array($branchCode));
|
||||
if (! $query) {
|
||||
echo "ERR|$branchCode is not the default branch !";
|
||||
echo $this->db->error()->message;
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo "ERR|$branchCode is not the default branch !";
|
||||
echo $this->db->error()->message;
|
||||
exit;
|
||||
}
|
||||
$branchName = $rows[0]["M_BranchName"];
|
||||
$sql = "select M_CompanyName, McuOfflinePrepareStartDate, McuOfflinePrepareEndDate , McuOfflinePrepareIsDownloaded
|
||||
from mcu_offline_prepare join m_company on McuOfflinePrepareM_CompanyID = M_CompanyID
|
||||
where McuOfflinePrepareCode = ? and McuOfflinePrepareIsActive = 'Y'";
|
||||
$query = $this->db->query($sql, array($mcuCode));
|
||||
if (! $query) {
|
||||
echo "ERR|Kode MCU $mcuCode tidak ada";
|
||||
echo $this->db->error()->message;
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo "ERR|Kode MCU $mcuCode tidak ada";
|
||||
exit;
|
||||
}
|
||||
if ( $rows[0]["McuOfflinePrepareIsDownloaded"] == "Y" ) {
|
||||
echo "ERR|Kode MCU $mcuCode sudah di download.";
|
||||
exit;
|
||||
}
|
||||
$startDate = $rows[0]["McuOfflinePrepareStartDate"];
|
||||
$endDate = $rows[0]["McuOfflinePrepareEndDate"];
|
||||
$companyName = $rows[0]["M_CompanyName"];
|
||||
echo "OK|Cabang\t\t: $branchName\nKode MCU\t: $mcuCode\nCompany\t\t: $companyName\nStart\t\t: $startDate\nEnd\t\t: $endDate";
|
||||
}
|
||||
|
||||
function db() {
|
||||
$xdb = $this->load->database("onedev",true);
|
||||
$pwd = $xdb->password;
|
||||
|
||||
$temp_c = tempnam(sys_get_temp_dir(), 'temp_c') . ".sql";
|
||||
$xname = tempnam(sys_get_temp_dir(), 'temp_c');
|
||||
if ( file_exists($temp_c) ) unlink($temp_c);
|
||||
|
||||
// add routines
|
||||
$cmd = "mysqldump --skip-triggers -u root -p$pwd one > $temp_c";
|
||||
exec($cmd);
|
||||
|
||||
$cmd = "gzip $temp_c";
|
||||
exec($cmd);
|
||||
//$temp_c = str_replace(".sql","",$temp_c);
|
||||
$temp_c .= ".gz";
|
||||
//print_r(file_exists($temp_c));
|
||||
if (file_exists($temp_c)) {
|
||||
$xname = str_replace(".sql","",basename($temp_c));
|
||||
header('Content-Description: File Transfer');
|
||||
header('Content-Type: application/octet-stream');
|
||||
header('Content-Disposition: attachment; filename="'.$xname.'"');
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate');
|
||||
header('Pragma: public');
|
||||
header('Content-Length: ' . filesize($temp_c));
|
||||
readfile($temp_c);
|
||||
unlink($temp_c);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function app() {
|
||||
$temp_file = tempnam(sys_get_temp_dir(), 'x-copy-tar') . "tar.gz";
|
||||
if ( file_exists($temp_file) ) unlink($temp_file);
|
||||
$cmd="tar --exclude=database.php --exclude-vcs -zcf $temp_file -C /home/one/project/one one-api one-ui -C /home/one/project/birt one";
|
||||
exec($cmd);
|
||||
if (file_exists($temp_file)) {
|
||||
header('Content-Description: File Transfer');
|
||||
header('Content-Type: application/octet-stream');
|
||||
header('Content-Disposition: attachment; filename="'.basename($temp_file).'"');
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate');
|
||||
header('Pragma: public');
|
||||
header('Content-Length: ' . filesize($temp_file));
|
||||
readfile($temp_file);
|
||||
unlink($temp_file);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
87
application/controllers/tools/Imagetofolder.php
Normal file
87
application/controllers/tools/Imagetofolder.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
ini_set('display_errors', '1');
|
||||
ini_set('display_startup_errors', '1');
|
||||
error_reporting(E_ALL);
|
||||
|
||||
class Imagetofolder extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
$this->load->helper(array('form', 'url'));
|
||||
}
|
||||
|
||||
|
||||
public function savedata()
|
||||
{
|
||||
$filename = $_FILES['filephoto']['name'];
|
||||
$path = '/home/one/project/one/one-media/one-photo/patient/'.date("Y").'/';
|
||||
if (!file_exists($path)) {
|
||||
if (! mkdir($path)) {
|
||||
$this->sys_error("Gagal membuat folder $path");
|
||||
}
|
||||
}
|
||||
$check = is_uploaded_file($_FILES["filephoto"]["tmp_name"]);
|
||||
if ($check) {
|
||||
if (move_uploaded_file($_FILES["filephoto"]["tmp_name"], $path . $filename)) {
|
||||
$cmd = "tar -xf $path$filename -C /home/one/project/one/one-media/one-photo/patient/".date('Y');
|
||||
// echo $cmd;
|
||||
exec($cmd);
|
||||
unlink($path.$filename);
|
||||
|
||||
$this->sys_ok(array("status" => "OK", "messge" => "file $filename uploaded"));
|
||||
} else {
|
||||
$this->sys_error("Gagal upload file $filename");
|
||||
}
|
||||
}
|
||||
}
|
||||
public function savedata_old()
|
||||
{
|
||||
//print_r($_FILES['file']);
|
||||
$filename = $_FILES['filephoto']['name'];
|
||||
|
||||
$path = '/home/one/project/one/one-media/one-photo/patient/'.date("Y").'/';
|
||||
if (!file_exists($path)) {
|
||||
mkdir($path);
|
||||
}
|
||||
//echo $path.$filename;
|
||||
//print_r(file_exists($path.$filename));
|
||||
unlink($path.$filename);
|
||||
if (!file_exists($path.$filename)) {
|
||||
$config['upload_path'] = $path;
|
||||
$config['allowed_types'] = '*';
|
||||
$config['max_size'] = 20000;
|
||||
$config['max_width'] = 1024;
|
||||
$config['max_height'] = 768;
|
||||
|
||||
$this->load->library('upload', $config);
|
||||
|
||||
if (! $this->upload->do_upload('filephoto')) {
|
||||
$error = array('error' => $this->upload->display_errors());
|
||||
$this->sys_error($this->upload->display_errors());
|
||||
exit;
|
||||
} else {
|
||||
$data = array('upload_data' => $this->upload->data());
|
||||
$cmd = "tar -xf $path$filename -C /home/one/project/one/one-media/one-photo/patient/".date('Y');
|
||||
//echo $cmd;
|
||||
exec($cmd);
|
||||
unlink($path.$filename);
|
||||
$this->sys_ok(array("status" => "OK", "messge" => "file $filename uploaded"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function uncompress($srcName, $dstName)
|
||||
{
|
||||
$sfp = gzopen($srcName, "rb");
|
||||
$fp = fopen($dstName, "w");
|
||||
|
||||
while (!gzeof($sfp)) {
|
||||
$string = gzread($sfp, 10000);
|
||||
fwrite($fp, $string, strlen($string));
|
||||
}
|
||||
gzclose($sfp);
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
203
application/controllers/tools/Incomingref.php
Normal file
203
application/controllers/tools/Incomingref.php
Normal file
@@ -0,0 +1,203 @@
|
||||
<?php
|
||||
class IncomingRef extends MY_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function ref_order($incomingRefID) {
|
||||
$sql = "select * from incoming_ref where incomingRefID = ?";
|
||||
$qry = $this->db->query($sql, array($incomingRefID) );
|
||||
$rows = array();
|
||||
$branchID = 0;
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if ( count($rows) > 0 ) $branchID = $rows[0]["incomingRefM_BranchID"];
|
||||
}
|
||||
$companyID = 0;
|
||||
if ($branchID > 0 ) {
|
||||
$sql = "select *
|
||||
from m_branch where M_BranchID = ?";
|
||||
$qry = $this->db->query($sql, array($branchID) );
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$companyID = $rows[0]["M_BranchM_CompanyID"];
|
||||
$mouID = $rows[0]["M_BranchM_MouID"];
|
||||
$doctorID = $rows[0]["M_BranchM_DoctorID"];
|
||||
$doctorAddressID = $rows[0]["M_BranchM_DoctorAddressID"];
|
||||
}
|
||||
}
|
||||
if ($companyID > 0 ) {
|
||||
|
||||
$sql = "";
|
||||
}
|
||||
}
|
||||
function fo_verify($orderID,$userID) {
|
||||
$sql="INSERT INTO fo_verificationsvalue (
|
||||
Fo_VerificationsValueT_OrderHeaderID,
|
||||
Fo_VerificationsValueFo_VerificationsLabelID,
|
||||
Fo_VerificationsValueCheck,
|
||||
Fo_VerificationsValueNote,
|
||||
Fo_VerificationsValueUserID,
|
||||
Fo_VerificationsValueCreated )
|
||||
SELECT {$orderID},
|
||||
Fo_VerificationsLabelID,
|
||||
'Y',
|
||||
'', {$userID},
|
||||
NOW()
|
||||
FROM fo_verificationslabel
|
||||
WHERE
|
||||
Fo_VerificationsLabelIsActive = 'Y' ";
|
||||
$this->db->query($sql);
|
||||
|
||||
$sql = "call sp_fo_barcode_generate({$orderID})";
|
||||
$this->db->query($sql);
|
||||
|
||||
$fostatusid = 3;
|
||||
$fologcode = 'FO.VERIFICATION.CONFIRM';
|
||||
|
||||
$sql = "insert into fo_status(
|
||||
Fo_StatusDate,
|
||||
Fo_StatusT_OrderHeaderID,
|
||||
Fo_StatusM_StatusID,
|
||||
Fo_StatusM_UserID,
|
||||
Fo_StatusCreated,
|
||||
Fo_StatusUpdated)
|
||||
values( now(), ?, ?, ?, now(),now())";
|
||||
|
||||
$query = $this->db->query($sql,
|
||||
array(
|
||||
$orderID,
|
||||
$fostatusid, $userID
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("fo_status insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM fo_verificationsvalue WHERE Fo_VerificationsValueT_OrderHeaderID = {$orderID}";
|
||||
|
||||
$data_log = array();
|
||||
$data_log['orderid'] = $orderID;
|
||||
$data_log['values'] = $this->db->query($sql)->result_array();
|
||||
$data_log['note'] = '';
|
||||
|
||||
$json_dt_log = json_encode($data_log);
|
||||
$sql = "insert into one_log.log_fo(
|
||||
Log_FoDate,
|
||||
Log_FoCode,
|
||||
Log_FoJson,
|
||||
Log_FoUserID)
|
||||
values( now(), ?, ?, ?)";
|
||||
$query = $this->db->query($sql,
|
||||
array(
|
||||
$fologcode,
|
||||
$json_dt_log,
|
||||
$userID
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("one_log.fo_log insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
/* T_OrderSample */
|
||||
$adminUserID = 3;
|
||||
$sql = "update t_ordersample
|
||||
set T_OrderSampleSampling='Y', T_OrderSampleSamplingDate = now(),
|
||||
T_OrderSampleSamplingTime = now(),T_OrderSampleSamplingUserID = $adminUserID,
|
||||
T_OrderSampleReceive='Y', T_OrderSampleReceiveDate = now() , T_OrderSampleReceiveTime = now(),
|
||||
T_OrderSampleReceiveUserID = $adminUserID,
|
||||
T_OrderSampleVerification='Y', T_OrderSampleVerificationDate=now(), T_OrderSampleVerificationTime=now(),
|
||||
T_OrderSampleVerificationUserID = $adminUserID,
|
||||
T_OrderSampleSendHandling = 'Y', T_OrderSampleSendHandlingDate =now(), T_OrderSampleSendHandlingTime=now(),
|
||||
T_OrderSampleSendHandlingUserID = $adminUserID,
|
||||
T_OrderSampleReceiveHandling = 'Y', T_OrderSampleReceiveHandlingDate=now(), T_OrderSampleReceiveHandlingTime=now(),
|
||||
T_OrderSampleReceiveHandlingUserID=$adminUserID,
|
||||
T_OrderSampleHandling='Y', T_OrderSampleHandlingDate=now(), T_OrderSampleHandlingTime=now(),
|
||||
T_OrderSampleHandlingUserID=$adminUserID,
|
||||
T_OrderSampleProcessing='Y', T_OrderSampleReadyToProcessDateTime=now(), T_OrderSampleProcessingDate=now(),
|
||||
T_OrderSampleProcessingTime=now(), T_OrderSampleProcessingUserID=$adminUserID,
|
||||
T_OrderSampleUserID=$adminUserID
|
||||
where T_OrderSampleT_OrderHeaderID = ?";
|
||||
|
||||
|
||||
$qry = $this->db->query($sql, array($orderID) );
|
||||
if (!$qry) {
|
||||
echo $this->db->last_query();
|
||||
$this->sys_error_db("one_log.fo_log insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->sys_ok("Verified");
|
||||
$this->broadcast("fo-verification-y");
|
||||
}
|
||||
function receive() {
|
||||
$prm = $this->sys_input;
|
||||
$branchCode = $prm[0]["OriginM_BranchCode"];
|
||||
$sql = "select M_BranchID from m_branch where M_BranchIsActive = 'Y' and
|
||||
M_BranchCode=?";
|
||||
$qry = $this->db->query($sql,array($branchCode));
|
||||
$branchID = 0;
|
||||
if ($qry ) {
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) $branchID = $rows[0]["M_BranchID"];
|
||||
}
|
||||
$flag_first = true;
|
||||
try
|
||||
{
|
||||
|
||||
$this->db->trans_start();
|
||||
foreach($prm as $p ) {
|
||||
if ($flag_first) {
|
||||
$flag_first = false;
|
||||
$sql_h = "insert into incoming_ref(incomingRefT_RefDeliveryOrderID,
|
||||
incomingRefOriginM_BranchCode,incomingRefM_BranchID, incomingRefT_RefDeliveryOrderDate,
|
||||
incomingRefT_RefDeliveryOrderNumber) values(?,
|
||||
?,?,?,
|
||||
?)";
|
||||
$this->db->query($sql_h,array($p["T_RefDeliveryOrderID"],
|
||||
$p["OriginM_BranchCode"], $branchID, $p["T_RefDeliveryOrderDate"],
|
||||
$p["T_RefDeliveryOrderNumber"]));
|
||||
$orderID = $this->db->insert_id();
|
||||
}
|
||||
//insert detail
|
||||
$sql_d = "insert into incoming_ref_detail(incomingRefDetailIncomingRefID,
|
||||
incomingRefDetailT_OrderHeaderID, incomingRefDetailT_OrderHeaderLabNumber,
|
||||
incomingRefDetailM_PatientName, incomingRefDetailFoNote,
|
||||
incomingRefDetailVefificationNote, incomingRefDetailSamplingNote,
|
||||
incomingRefDetailT_TestID, incomingRefDetailT_TestName,
|
||||
incomingRefDetailT_OrderPromiseDateTime, incomingRefDetailT_OrderDetailID,
|
||||
incomingRefDetailT_BarcodeLabBarcode,incomingRefDetailRequirements,
|
||||
incomingRefDetailPatient)
|
||||
values( ?,
|
||||
?, ?,
|
||||
?, ?,
|
||||
?, ?,
|
||||
?, ?,
|
||||
?, ?,
|
||||
?, ?,
|
||||
?)";
|
||||
$patient = json_encode($p["patient"]);
|
||||
$requirements = json_encode($p["requirements"]);
|
||||
foreach($p["test"] as $t ) {
|
||||
$this->db->query($sql_d , array($orderID,
|
||||
$p["T_OrderHeaderID"], $p["T_OrderHeaderLabNumber"],
|
||||
$p["M_PatientName"], $p["FoNote"],
|
||||
$p["VerificationNote"], $p["SamplingNote"],
|
||||
$t["T_TestID"], $p["T_TestName"],
|
||||
$t["T_OrderPromiseDateTime"], $t["T_OrderDetailID"],
|
||||
$t["T_BarcodeLabBarcode"],$requirements, $patient));
|
||||
}
|
||||
}
|
||||
$this->db->trans_complete();
|
||||
$this->sys_ok("Data Inserted");
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error($e->message);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
245
application/controllers/tools/Incomingref_v2.php
Normal file
245
application/controllers/tools/Incomingref_v2.php
Normal file
@@ -0,0 +1,245 @@
|
||||
<?php
|
||||
class IncomingRef_v2 extends MY_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function ref_order($incomingRefID) {
|
||||
$sql = "select * from incoming_ref where incomingRefID = ?";
|
||||
$qry = $this->db->query($sql, array($incomingRefID) );
|
||||
$rows = array();
|
||||
$branchID = 0;
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if ( count($rows) > 0 ) $branchID = $rows[0]["incomingRefM_BranchID"];
|
||||
}
|
||||
$companyID = 0;
|
||||
if ($branchID > 0 ) {
|
||||
$sql = "select *
|
||||
from m_branch where M_BranchID = ?";
|
||||
$qry = $this->db->query($sql, array($branchID) );
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$companyID = $rows[0]["M_BranchM_CompanyID"];
|
||||
$mouID = $rows[0]["M_BranchM_MouID"];
|
||||
$doctorID = $rows[0]["M_BranchM_DoctorID"];
|
||||
$doctorAddressID = $rows[0]["M_BranchM_DoctorAddressID"];
|
||||
}
|
||||
}
|
||||
if ($companyID > 0 ) {
|
||||
|
||||
$sql = "";
|
||||
}
|
||||
}
|
||||
function fo_verify($orderID,$userID) {
|
||||
$sql="INSERT INTO fo_verificationsvalue (
|
||||
Fo_VerificationsValueT_OrderHeaderID,
|
||||
Fo_VerificationsValueFo_VerificationsLabelID,
|
||||
Fo_VerificationsValueCheck,
|
||||
Fo_VerificationsValueNote,
|
||||
Fo_VerificationsValueUserID,
|
||||
Fo_VerificationsValueCreated )
|
||||
SELECT {$orderID},
|
||||
Fo_VerificationsLabelID,
|
||||
'Y',
|
||||
'', {$userID},
|
||||
NOW()
|
||||
FROM fo_verificationslabel
|
||||
WHERE
|
||||
Fo_VerificationsLabelIsActive = 'Y' ";
|
||||
$this->db->query($sql);
|
||||
|
||||
$sql = "call sp_fo_barcode_generate({$orderID})";
|
||||
$this->db->query($sql);
|
||||
|
||||
$fostatusid = 3;
|
||||
$fologcode = 'FO.VERIFICATION.CONFIRM';
|
||||
|
||||
$sql = "insert into fo_status(
|
||||
Fo_StatusDate,
|
||||
Fo_StatusT_OrderHeaderID,
|
||||
Fo_StatusM_StatusID,
|
||||
Fo_StatusM_UserID,
|
||||
Fo_StatusCreated,
|
||||
Fo_StatusUpdated)
|
||||
values( now(), ?, ?, ?, now(),now())";
|
||||
|
||||
$query = $this->db->query($sql,
|
||||
array(
|
||||
$orderID,
|
||||
$fostatusid, $userID
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("fo_status insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM fo_verificationsvalue WHERE Fo_VerificationsValueT_OrderHeaderID = {$orderID}";
|
||||
|
||||
$data_log = array();
|
||||
$data_log['orderid'] = $orderID;
|
||||
$data_log['values'] = $this->db->query($sql)->result_array();
|
||||
$data_log['note'] = '';
|
||||
|
||||
$json_dt_log = json_encode($data_log);
|
||||
$sql = "insert into one_log.log_fo(
|
||||
Log_FoDate,
|
||||
Log_FoCode,
|
||||
Log_FoJson,
|
||||
Log_FoUserID)
|
||||
values( now(), ?, ?, ?)";
|
||||
$query = $this->db->query($sql,
|
||||
array(
|
||||
$fologcode,
|
||||
$json_dt_log,
|
||||
$userID
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("one_log.fo_log insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
/* T_OrderSample */
|
||||
$adminUserID = 3;
|
||||
$sql = "update t_ordersample
|
||||
set T_OrderSampleSampling='Y', T_OrderSampleSamplingDate = now(),
|
||||
T_OrderSampleSamplingTime = now(),T_OrderSampleSamplingUserID = $adminUserID,
|
||||
T_OrderSampleReceive='Y', T_OrderSampleReceiveDate = now() , T_OrderSampleReceiveTime = now(),
|
||||
T_OrderSampleReceiveUserID = $adminUserID,
|
||||
T_OrderSampleVerification='Y', T_OrderSampleVerificationDate=now(), T_OrderSampleVerificationTime=now(),
|
||||
T_OrderSampleVerificationUserID = $adminUserID,
|
||||
T_OrderSampleSendHandling = 'Y', T_OrderSampleSendHandlingDate =now(), T_OrderSampleSendHandlingTime=now(),
|
||||
T_OrderSampleSendHandlingUserID = $adminUserID,
|
||||
T_OrderSampleReceiveHandling = 'Y', T_OrderSampleReceiveHandlingDate=now(), T_OrderSampleReceiveHandlingTime=now(),
|
||||
T_OrderSampleReceiveHandlingUserID=$adminUserID,
|
||||
T_OrderSampleHandling='Y', T_OrderSampleHandlingDate=now(), T_OrderSampleHandlingTime=now(),
|
||||
T_OrderSampleHandlingUserID=$adminUserID,
|
||||
T_OrderSampleProcessing='Y', T_OrderSampleReadyToProcessDateTime=now(), T_OrderSampleProcessingDate=now(),
|
||||
T_OrderSampleProcessingTime=now(), T_OrderSampleProcessingUserID=$adminUserID,
|
||||
T_OrderSampleUserID=$adminUserID
|
||||
where T_OrderSampleT_OrderHeaderID = ?";
|
||||
|
||||
|
||||
$qry = $this->db->query($sql, array($orderID) );
|
||||
if (!$qry) {
|
||||
echo $this->db->last_query();
|
||||
$this->sys_error_db("one_log.fo_log insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->sys_ok("Verified");
|
||||
$this->broadcast("fo-verification-y");
|
||||
}
|
||||
function receive() {
|
||||
$date = date("Y-m-d h:m:s");
|
||||
$prm = $this->sys_input;
|
||||
//file_put_contents("/xtmp/debung-incoming-rujukan.log", $date . "\n" . print_r($prm ,true) . "\n" ,FILE_APPEND);
|
||||
$branchCode = $prm[0]["OriginM_BranchCode"];
|
||||
$sql = "select M_BranchID from m_branch where M_BranchIsActive = 'Y' and
|
||||
M_BranchCode=?";
|
||||
$qry = $this->db->query($sql,array($branchCode));
|
||||
$branchID = 0;
|
||||
if ($qry ) {
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) $branchID = $rows[0]["M_BranchID"];
|
||||
}
|
||||
$flag_first = true;
|
||||
try
|
||||
{
|
||||
|
||||
$this->db->trans_start();
|
||||
|
||||
$err_msg = "";
|
||||
foreach($prm as $p ) {
|
||||
if ($flag_first) {
|
||||
$flag_first = false;
|
||||
|
||||
|
||||
$donumber = $p["T_RefDeliveryOrderNumber"];
|
||||
$cbranch = $p["OriginM_BranchCode"];
|
||||
|
||||
$sql = $this->db->query("SELECT COUNT(*) as inc_available FROM incoming_ref
|
||||
WHERE incomingRefOriginM_BranchCode = '{$cbranch}'
|
||||
AND incomingRefM_BranchID = $branchID
|
||||
AND incomingRefT_RefDeliveryOrderNumber = '{$donumber}'")->row();
|
||||
$inc_available = $sql->inc_available;
|
||||
|
||||
if($inc_available == 0){
|
||||
$sql_h = "insert into incoming_ref(incomingRefT_RefDeliveryOrderID,
|
||||
incomingRefOriginM_BranchCode,incomingRefM_BranchID, incomingRefT_RefDeliveryOrderDate,
|
||||
incomingRefT_RefDeliveryOrderNumber) values(?,
|
||||
?,?,?,
|
||||
?)";
|
||||
$this->db->query($sql_h,array($p["T_RefDeliveryOrderID"],
|
||||
$p["OriginM_BranchCode"], $branchID, $p["T_RefDeliveryOrderDate"],
|
||||
$p["T_RefDeliveryOrderNumber"]));
|
||||
$orderID = $this->db->insert_id();
|
||||
}
|
||||
//insert detail
|
||||
$sql_d = "insert into incoming_ref_detail(incomingRefDetailIncomingRefID,
|
||||
incomingRefDetailT_OrderHeaderID, incomingRefDetailT_OrderHeaderLabNumber,
|
||||
incomingRefDetailM_PatientName, incomingRefDetailFoNote,
|
||||
incomingRefDetailVefificationNote, incomingRefDetailSamplingNote,
|
||||
incomingRefDetailT_TestID, incomingRefDetailT_TestName,
|
||||
incomingRefDetailT_OrderPromiseDateTime, incomingRefDetailT_OrderDetailID,
|
||||
incomingRefDetailT_BarcodeLabBarcode,incomingRefDetailRequirements,
|
||||
incomingRefDetailPatient)
|
||||
values( ?,
|
||||
?, ?,
|
||||
?, ?,
|
||||
?, ?,
|
||||
?, ?,
|
||||
?, ?,
|
||||
?, ?,
|
||||
?)";
|
||||
$patient = json_encode($p["patient"]);
|
||||
$requirements = json_encode($p["requirements"]);
|
||||
foreach($p["test"] as $t ) {
|
||||
$x_qry = $this->db->query($sql_d , array($orderID,
|
||||
$p["T_OrderHeaderID"], $p["T_OrderHeaderLabNumber"],
|
||||
$p["M_PatientName"], $p["FoNote"],
|
||||
$p["VerificationNote"], $p["SamplingNote"],
|
||||
$t["T_TestID"], $t["T_TestName"],
|
||||
$t["T_OrderPromiseDateTime"], $t["T_OrderDetailID"],
|
||||
$t["T_BarcodeLabBarcode"],$requirements, $patient));
|
||||
if(! $x_qry) {
|
||||
$err_msg .= print_r($this->db->error(),true) . "\n";
|
||||
}
|
||||
}
|
||||
//insert child
|
||||
$sql_child = "insert into incoming_ref_child(incomingRefChildIncomingRefID,
|
||||
incomingRefChildT_TestID, incomingRefChildT_TestName,
|
||||
incomingRefChildT_OrderPromiseDateTime, incomingRefChildT_OrderDetailID,
|
||||
incomingRefChildT_OrderHeaderID)
|
||||
values( ?,
|
||||
?, ?,
|
||||
?, ?,?)";
|
||||
foreach($p["child_test"] as $t ) {
|
||||
$x_qry = $this->db->query($sql_child , array($orderID,
|
||||
$t["T_TestID"], $t["T_TestName"],
|
||||
$t["T_OrderPromiseDateTime"], $t["T_OrderDetailID"],
|
||||
$t["T_OrderHeaderID"] ));
|
||||
if(! $x_qry) {
|
||||
$err_msg .= print_r($this->db->error(),true) . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->db->trans_complete();
|
||||
if ($this->db->trans_status() === FALSE ) {
|
||||
$this->sys_error("Error Insert Data " . $err_msg );
|
||||
} else {
|
||||
$this->sys_ok("Data Inserted");
|
||||
}
|
||||
}
|
||||
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error($e->message);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
236
application/controllers/tools/Incomingref_v4.php
Normal file
236
application/controllers/tools/Incomingref_v4.php
Normal file
@@ -0,0 +1,236 @@
|
||||
<?php
|
||||
class IncomingRef_v4 extends MY_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function ref_order($incomingRefID) {
|
||||
$sql = "select * from incoming_ref where incomingRefID = ?";
|
||||
$qry = $this->db->query($sql, array($incomingRefID) );
|
||||
$rows = array();
|
||||
$branchID = 0;
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if ( count($rows) > 0 ) $branchID = $rows[0]["incomingRefM_BranchID"];
|
||||
}
|
||||
$companyID = 0;
|
||||
if ($branchID > 0 ) {
|
||||
$sql = "select *
|
||||
from m_branch where M_BranchID = ?";
|
||||
$qry = $this->db->query($sql, array($branchID) );
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$companyID = $rows[0]["M_BranchM_CompanyID"];
|
||||
$mouID = $rows[0]["M_BranchM_MouID"];
|
||||
$doctorID = $rows[0]["M_BranchM_DoctorID"];
|
||||
$doctorAddressID = $rows[0]["M_BranchM_DoctorAddressID"];
|
||||
}
|
||||
}
|
||||
if ($companyID > 0 ) {
|
||||
|
||||
$sql = "";
|
||||
}
|
||||
}
|
||||
function fo_verify($orderID,$userID) {
|
||||
$sql="INSERT INTO fo_verificationsvalue (
|
||||
Fo_VerificationsValueT_OrderHeaderID,
|
||||
Fo_VerificationsValueFo_VerificationsLabelID,
|
||||
Fo_VerificationsValueCheck,
|
||||
Fo_VerificationsValueNote,
|
||||
Fo_VerificationsValueUserID,
|
||||
Fo_VerificationsValueCreated )
|
||||
SELECT {$orderID},
|
||||
Fo_VerificationsLabelID,
|
||||
'Y',
|
||||
'', {$userID},
|
||||
NOW()
|
||||
FROM fo_verificationslabel
|
||||
WHERE
|
||||
Fo_VerificationsLabelIsActive = 'Y' ";
|
||||
$this->db->query($sql);
|
||||
|
||||
$sql = "call sp_fo_barcode_generate({$orderID})";
|
||||
$this->db->query($sql);
|
||||
|
||||
$fostatusid = 3;
|
||||
$fologcode = 'FO.VERIFICATION.CONFIRM';
|
||||
|
||||
$sql = "insert into fo_status(
|
||||
Fo_StatusDate,
|
||||
Fo_StatusT_OrderHeaderID,
|
||||
Fo_StatusM_StatusID,
|
||||
Fo_StatusM_UserID,
|
||||
Fo_StatusCreated,
|
||||
Fo_StatusUpdated)
|
||||
values( now(), ?, ?, ?, now(),now())";
|
||||
|
||||
$query = $this->db->query($sql,
|
||||
array(
|
||||
$orderID,
|
||||
$fostatusid, $userID
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("fo_status insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM fo_verificationsvalue WHERE Fo_VerificationsValueT_OrderHeaderID = {$orderID}";
|
||||
|
||||
$data_log = array();
|
||||
$data_log['orderid'] = $orderID;
|
||||
$data_log['values'] = $this->db->query($sql)->result_array();
|
||||
$data_log['note'] = '';
|
||||
|
||||
$json_dt_log = json_encode($data_log);
|
||||
$sql = "insert into one_log.log_fo(
|
||||
Log_FoDate,
|
||||
Log_FoCode,
|
||||
Log_FoJson,
|
||||
Log_FoUserID)
|
||||
values( now(), ?, ?, ?)";
|
||||
$query = $this->db->query($sql,
|
||||
array(
|
||||
$fologcode,
|
||||
$json_dt_log,
|
||||
$userID
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("one_log.fo_log insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
/* T_OrderSample */
|
||||
$adminUserID = 3;
|
||||
$sql = "update t_ordersample
|
||||
set T_OrderSampleSampling='Y', T_OrderSampleSamplingDate = now(),
|
||||
T_OrderSampleSamplingTime = now(),T_OrderSampleSamplingUserID = $adminUserID,
|
||||
T_OrderSampleReceive='Y', T_OrderSampleReceiveDate = now() , T_OrderSampleReceiveTime = now(),
|
||||
T_OrderSampleReceiveUserID = $adminUserID,
|
||||
T_OrderSampleVerification='Y', T_OrderSampleVerificationDate=now(), T_OrderSampleVerificationTime=now(),
|
||||
T_OrderSampleVerificationUserID = $adminUserID,
|
||||
T_OrderSampleSendHandling = 'Y', T_OrderSampleSendHandlingDate =now(), T_OrderSampleSendHandlingTime=now(),
|
||||
T_OrderSampleSendHandlingUserID = $adminUserID,
|
||||
T_OrderSampleReceiveHandling = 'Y', T_OrderSampleReceiveHandlingDate=now(), T_OrderSampleReceiveHandlingTime=now(),
|
||||
T_OrderSampleReceiveHandlingUserID=$adminUserID,
|
||||
T_OrderSampleHandling='Y', T_OrderSampleHandlingDate=now(), T_OrderSampleHandlingTime=now(),
|
||||
T_OrderSampleHandlingUserID=$adminUserID,
|
||||
T_OrderSampleProcessing='Y', T_OrderSampleReadyToProcessDateTime=now(), T_OrderSampleProcessingDate=now(),
|
||||
T_OrderSampleProcessingTime=now(), T_OrderSampleProcessingUserID=$adminUserID,
|
||||
T_OrderSampleUserID=$adminUserID
|
||||
where T_OrderSampleT_OrderHeaderID = ?";
|
||||
|
||||
|
||||
$qry = $this->db->query($sql, array($orderID) );
|
||||
if (!$qry) {
|
||||
echo $this->db->last_query();
|
||||
$this->sys_error_db("one_log.fo_log insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->sys_ok("Verified");
|
||||
$this->broadcast("fo-verification-y");
|
||||
}
|
||||
function get_param() {
|
||||
$zdata = file_get_contents("php://input");
|
||||
$data = gzinflate($zdata);
|
||||
return json_decode($data,true);
|
||||
}
|
||||
function receive() {
|
||||
$prm = $this->get_param();
|
||||
$branchCode = $prm[0]["OriginM_BranchCode"];
|
||||
$sql = "select M_BranchID from m_branch where M_BranchIsActive = 'Y' and
|
||||
M_BranchCode=?";
|
||||
$qry = $this->db->query($sql,array($branchCode));
|
||||
$branchID = 0;
|
||||
if ($qry ) {
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) $branchID = $rows[0]["M_BranchID"];
|
||||
}
|
||||
$flag_first = true;
|
||||
try
|
||||
{
|
||||
$this->db->trans_begin();
|
||||
$err_msg = "";
|
||||
foreach($prm as $p ) {
|
||||
if ($flag_first) {
|
||||
$flag_first = false;
|
||||
$sql_h = "insert into incoming_ref(incomingRefT_RefDeliveryOrderID,
|
||||
incomingRefOriginM_BranchCode,incomingRefM_BranchID, incomingRefT_RefDeliveryOrderDate,
|
||||
incomingRefT_RefDeliveryOrderNumber) values(?,
|
||||
?,?,?,
|
||||
?)";
|
||||
$qry = $this->db->query($sql_h,array($p["T_RefDeliveryOrderID"],
|
||||
$p["OriginM_BranchCode"], $branchID, $p["T_RefDeliveryOrderDate"],
|
||||
$p["T_RefDeliveryOrderNumber"]));
|
||||
if (! $qry ) {
|
||||
$err_msg .= print_r($this->db->error(),true);
|
||||
}
|
||||
$orderID = $this->db->insert_id();
|
||||
}
|
||||
//insert detail
|
||||
$sql_d = "insert into incoming_ref_detail(incomingRefDetailIncomingRefID,
|
||||
incomingRefDetailT_OrderHeaderID, incomingRefDetailT_OrderHeaderLabNumber,
|
||||
incomingRefDetailM_PatientName, incomingRefDetailFoNote,
|
||||
incomingRefDetailVefificationNote, incomingRefDetailSamplingNote,
|
||||
incomingRefDetailT_TestID, incomingRefDetailT_TestName,
|
||||
incomingRefDetailT_OrderPromiseDateTime, incomingRefDetailT_OrderDetailID,
|
||||
incomingRefDetailT_BarcodeLabBarcode,incomingRefDetailRequirements,
|
||||
incomingRefDetailPatient
|
||||
)
|
||||
values( ?,
|
||||
?, ?,
|
||||
?, ?,
|
||||
?, ?,
|
||||
?, ?,
|
||||
?, ?,
|
||||
?, ?,
|
||||
?)";
|
||||
$patient = json_encode($p["patient"]);
|
||||
$requirements = json_encode($p["requirements"]);
|
||||
foreach($p["test"] as $t ) {
|
||||
$qry = $this->db->query($sql_d , array($orderID,
|
||||
$p["T_OrderHeaderID"], $p["T_OrderHeaderLabNumber"],
|
||||
$p["M_PatientName"], $p["FoNote"],
|
||||
$p["VerificationNote"], $p["SamplingNote"],
|
||||
$t["T_TestID"], $t["T_TestName"],
|
||||
$t["T_OrderPromiseDateTime"], $t["T_OrderDetailID"],
|
||||
$t["T_BarcodeLabBarcode"],$requirements, $patient));
|
||||
if (! $qry ) {
|
||||
$err_msg .= print_r($this->db->error(),true);
|
||||
}
|
||||
}
|
||||
//insert child
|
||||
$sql_child = "insert into incoming_ref_child(incomingRefChildIncomingRefID,
|
||||
incomingRefChildT_TestID, incomingRefChildT_TestName,
|
||||
incomingRefChildT_OrderPromiseDateTime, incomingRefChildT_OrderDetailID,
|
||||
incomingRefChildT_OrderHeaderID)
|
||||
values( ?,
|
||||
?, ?,
|
||||
?, ?,?)";
|
||||
foreach($p["child_test"] as $t ) {
|
||||
$qry = $this->db->query($sql_child , array($orderID,
|
||||
$t["T_TestID"], $t["T_TestName"],
|
||||
$t["T_OrderPromiseDateTime"], $t["T_OrderDetailID"],
|
||||
$t["T_OrderHeaderID"]));
|
||||
if (! $qry ) {
|
||||
$err_msg .= print_r($this->db->error(),true);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($this->db->trans_status() === FALSE ) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error("Error Insert Data " . $err_msg );
|
||||
} else {
|
||||
$this->db->trans_commit();
|
||||
$this->sys_ok("Data Inserted");
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error($e->message);
|
||||
}
|
||||
}
|
||||
}
|
||||
97
application/controllers/tools/Inject_all.php
Normal file
97
application/controllers/tools/Inject_all.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
class Inject_all extends MY_Controller
|
||||
{
|
||||
var $base_url = "http://localhost/one-api/";
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
function patient()
|
||||
{
|
||||
// inject patient get distinct date
|
||||
$sql = "select distinct REG_DATE
|
||||
from x_adm_rekap_patient";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
echo "Invalid query : \n";
|
||||
print_r($this->db->error());
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
foreach ($rows as $r) {
|
||||
echo "Generating Patient {$r["REG_DATE"]}\n";
|
||||
$param = ["date" => $r["REG_DATE"], "corporateID" => 46];
|
||||
$resp = $this->post("cpone/patient/generate_adm_patient", $param);
|
||||
print_r(substr($resp, 0, 20) . " ...");
|
||||
echo "\n";
|
||||
echo "Wait 3s\n";
|
||||
sleep(3);
|
||||
}
|
||||
}
|
||||
function lab()
|
||||
{
|
||||
$sql = "select PATIENT_ID,REG_NO
|
||||
from x_adm_rekap_patient";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
echo "Invalid query : \n";
|
||||
print_r($this->db->error());
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$ctr = 0;
|
||||
foreach ($rows as $r) {
|
||||
echo "Generating Order {$r["PATIENT_ID"]}\n";
|
||||
$param = ["patientoldID" => $r["PATIENT_ID"]];
|
||||
$resp = $this->post("cpone/patient/insert_patient", $param);
|
||||
print_r($resp);
|
||||
echo "\n";
|
||||
echo "Update Result {$r["REG_NO"]}\n";
|
||||
$resp = $this->get("tools/inject_lab/update/{$r["REG_NO"]}");
|
||||
print_r($resp);
|
||||
echo "\n";
|
||||
$ctr++;
|
||||
if ($ctr >= 20) {
|
||||
$ctr = 0;
|
||||
echo "Wait 3s\n";
|
||||
sleep(3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function post($service, $data)
|
||||
{
|
||||
$xbase_url = $this->base_url;
|
||||
$url = $xbase_url . "$service";
|
||||
echo "url : $url \n";
|
||||
$ch = curl_init($url);
|
||||
$payload = json_encode($data);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$result = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
function get($service, $debug = "")
|
||||
{
|
||||
$xbase_url = "http://localhost/one-api/";
|
||||
$url = $xbase_url . "$service";
|
||||
$ch = curl_init($url);
|
||||
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$result = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
if ($debug != "") {
|
||||
echo "url : $url \n";
|
||||
print_r($result);
|
||||
}
|
||||
$data_rst = json_decode($result);
|
||||
return $data_rst;
|
||||
}
|
||||
}
|
||||
395
application/controllers/tools/Inject_fisik_vital.php
Normal file
395
application/controllers/tools/Inject_fisik_vital.php
Normal file
@@ -0,0 +1,395 @@
|
||||
<?php
|
||||
class Inject_fisik_vital extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// db wilayah contoh surabaya
|
||||
// $this->db = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "API Inject fisik vital";
|
||||
}
|
||||
|
||||
public function getOrderDetailID($reg_no)
|
||||
{
|
||||
if (isset($reg_no)) {
|
||||
$sql = "SELECT T_OrderHeaderID
|
||||
FROM t_orderheader
|
||||
WHERE T_OrderHeaderOldLabNumber = ?
|
||||
AND T_OrderHeaderIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, $reg_no);
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Error get t_orderheader | " . $this->db->error()["message"]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result();
|
||||
// print_r(json_encode($getOrderHeaderID));
|
||||
// exit;
|
||||
if (count($rows) != 0) {
|
||||
// echo ("getOrderHeaderID tidak 0\n");
|
||||
$t_orderheaderid = $rows[0]->T_OrderHeaderID;
|
||||
$t_testid = 2562;
|
||||
echo "Regno : {$reg_no}\n";
|
||||
echo "T_OrderHeaderID: " . $t_orderheaderid . "\n";
|
||||
echo "T_OrderHeaderID: " . $t_testid . "\n";
|
||||
|
||||
$sql = "SELECT T_OrderDetailID
|
||||
FROM t_orderdetail
|
||||
WHERE T_OrderDetailT_OrderHeaderID = ?
|
||||
AND T_OrderDetailT_TestID = ?
|
||||
AND T_OrderDetailIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, array($t_orderheaderid, $t_testid));
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Error get t_orderdetail | " . $this->db->error()["message"]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
$rows_detail = $qry->result();
|
||||
// print_r(json_encode($getOrderDetailID));
|
||||
// exit;
|
||||
if (count($rows_detail) != 0) {
|
||||
// echo ("getOrderDetailID tidak 0\n");
|
||||
$t_orderdetailid = $rows_detail[0]->T_OrderDetailID;
|
||||
echo "T_OrderDetailID: " . $t_orderdetailid . "\n";
|
||||
}
|
||||
return [$t_orderheaderid, $t_orderdetailid];
|
||||
} else {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Tidak ditemukan Registrasi dengan nomor
|
||||
registrasi : " . $reg_no
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getSoResultEntryID($t_orderdetailid_v)
|
||||
{
|
||||
$t_orderdetailid = $t_orderdetailid_v;
|
||||
$nonlab_templateid = 27;
|
||||
$nonlab_templatename = 'Fisik Umum';
|
||||
|
||||
$sql = "SELECT So_ResultEntryID
|
||||
FROM so_resultentry
|
||||
WHERE So_ResultEntryT_OrderDetailID = ?
|
||||
AND So_ResultEntryNonlab_TemplateID = ?
|
||||
AND So_ResultEntryNonlab_TemplateName = ?
|
||||
AND So_ResultEntryIsActive= 'Y'";
|
||||
$qry = $this->db->query($sql, array($t_orderdetailid, $nonlab_templateid, $nonlab_templatename));
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Error get so_resultentry | " . $this->db->error()["message"]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result();
|
||||
$so_resultentryid = 0;
|
||||
if (count($rows) == 0) {
|
||||
$insert_sql = "INSERT INTO so_resultentry (
|
||||
So_ResultEntryT_OrderDetailID,
|
||||
So_ResultEntryNonlab_TemplateID,
|
||||
So_ResultEntryNonlab_TemplateName)
|
||||
VALUES (?, ?, ?)";
|
||||
// tanyakan
|
||||
$update_qry = $this->db->query($insert_sql, array($t_orderdetailid, $nonlab_templateid, $nonlab_templatename));
|
||||
if (!$update_qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Error insert so_resultentry | " . $this->db->error()["message"]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
// tanyakan
|
||||
echo "so_resultentry baru dibuat \n";
|
||||
$so_resultentryid = $this->db->insert_id();
|
||||
} else {
|
||||
$so_resultentryid = $rows[0]->So_ResultEntryID;
|
||||
}
|
||||
echo "So_ResultEntryID: " . $so_resultentryid . "\n";
|
||||
return $so_resultentryid;
|
||||
}
|
||||
|
||||
function getArrayMap()
|
||||
{
|
||||
$sql = "select * from x_map_fisik_vital";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Error get x_map_fisik_vital | " . $this->db->error()["message"]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
$arr_map = [];
|
||||
$rows = $qry->result_array();
|
||||
foreach ($rows as $r) {
|
||||
$arr_map[$r["name"]] = [$r["id_code"], $r["templateID"]];
|
||||
}
|
||||
return $arr_map;
|
||||
}
|
||||
function getSoResultEntryFisikUmumID($soResultEntryID, $templateID)
|
||||
{
|
||||
// jika tidak ketemu cari dari fisik template , FisikTemplateJSON
|
||||
$sql = "SELECT *
|
||||
FROM so_resultentry_fisik_umum
|
||||
WHERE So_ResultEntryFisikUmumSo_ResultEntryID = ?
|
||||
AND So_ResultEntryFisikUmumFisikTemplateID = ?
|
||||
AND So_ResultEntryFisikUmumIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, array($soResultEntryID, $templateID));
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Error get so_resultentry_fisik_umum | " . $this->db->error()["message"]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (empty($rows)) {
|
||||
echo ("JSON dengan ID :" . $soResultEntryID . " dan template id {$templateID} tidak ada. \n");
|
||||
$sql = "SELECT *
|
||||
FROM fisik_template
|
||||
WHERE FisikTemplateID = ?
|
||||
-- AND FisikTemplateIsActive = 'Y' ";
|
||||
$qryIsEmpty = $this->db->query($sql, array($templateID));
|
||||
if (!$qryIsEmpty) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Error get fisik_template | " . $this->db->error()["message"]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
$rowsIsNew = $qryIsEmpty->result_array();
|
||||
foreach ($rowsIsNew as $r) {
|
||||
$arr_map[$r["FisikTemplateID"]] = [$r["FisikTemplateID"], $r["FisikTemplateJSON"]];
|
||||
}
|
||||
// print_r("ini JSON baru :" . json_encode($arr_map, JSON_PRETTY_PRINT) . "\n");
|
||||
// exit;
|
||||
// insertkan ke so_resultentryfisikumum
|
||||
$so_resultentryfisikumumid = 0;
|
||||
$insert_sql = "INSERT INTO so_resultentry_fisik_umum(
|
||||
So_ResultEntryFisikUmumSo_ResultEntryID,
|
||||
So_ResultEntryFisikUmumFisikTemplateID,
|
||||
So_ResultEntryFisikUmumDetails)
|
||||
VALUES (?,?,?)";
|
||||
foreach ($arr_map as $key => $value) {
|
||||
$insert_qry = $this->db->query($insert_sql, array($soResultEntryID, $value[0], $value[1]));
|
||||
if (!$insert_qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Error get fisik_template | " . $this->db->error()["message"]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
$so_resultentryfisikumumid = $this->db->insert_id();
|
||||
echo "so_resultentry_fisik_umum baru dibuat dengan ID: {$so_resultentryfisikumumid} dan template ID : {$value[0]}\n";
|
||||
$arr_map[$key] = [
|
||||
'id' => $so_resultentryfisikumumid,
|
||||
'FisikTemplateID' => $value[0],
|
||||
'So_ResultEntryFisikUmumDetails' => $value[1]
|
||||
];
|
||||
}
|
||||
return $arr_map;
|
||||
} else {
|
||||
//retun nya [So_ResultEntryFisikUmumID, JSON]
|
||||
return array(
|
||||
$rows[0]["So_ResultEntryFisikUmumID"],
|
||||
$rows[0]["So_ResultEntryFisikUmumDetails"]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function getTSamplingSoID($orderHeaderID)
|
||||
{
|
||||
// search
|
||||
$sql = "SELECT *
|
||||
FROM t_samplingso
|
||||
WHERE T_SamplingSoT_OrderHeaderID = ?";
|
||||
$qry = $this->db->query($sql, array($orderHeaderID));
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Error get t_samplingso | " . $this->db->error()["message"]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (empty($rows)) {
|
||||
echo ("t_samplingso dengan ID :{} dan template id {$templateID} tidak ada. \n");
|
||||
} else {
|
||||
echo json_encode($rows);
|
||||
}
|
||||
// kalau belum ada di buat
|
||||
// kalau ada di return ()
|
||||
// insert ke t_samplingso
|
||||
// required field T_SamplingSoT_SampleStationID == 7, T_SamplingSoT_OrderHeaderID== parameter, T_SamplingSoT_TestID== 2562, T_SamplingSoFlag == D
|
||||
}
|
||||
|
||||
function proses($reg_no)
|
||||
{
|
||||
list($orderHeaderID, $orderDetailID) = $this->getOrderDetailID($reg_no);
|
||||
// jgn lupa uncomment
|
||||
$arr_map = $this->getArrayMap();
|
||||
$soResultEntryID = $this->getSoResultEntryID($orderDetailID);
|
||||
// echo "ini arr_map : " . json_encode($arr_map);
|
||||
// buat fungsi get t_samplingso
|
||||
// kalau belum ada di buat
|
||||
// kalau ada di return ()
|
||||
|
||||
$sql = "select * from x_adm_rekap_fisik_vital where REG_NO = ?";
|
||||
$qry = $this->db->query($sql, [$reg_no]);
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Error get x_adm_rekap_fisik_vital | " . $this->db->error()["message"]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
// echo ("ini rows : " . json_encode($rows) . "\n");
|
||||
// exit;
|
||||
foreach ($rows as $r) {
|
||||
foreach ($r as $key => $value) {
|
||||
|
||||
// echo "arr_map : " . json_encode($arr_map[$key]) . "\n";
|
||||
if ($key == "REG_NO") continue;
|
||||
$id_code = $arr_map[$key][0];
|
||||
$templateID = $arr_map[$key][1];
|
||||
if ($templateID == "") continue;
|
||||
|
||||
// set value_x dan value_y
|
||||
// if (isset($key['value_x']) && isset($key['value_y'])) {
|
||||
// $value_x = $key['value_x'];
|
||||
// $value_y = $key['value_y'];
|
||||
// echo "Value X: $value_x, Value Y: $value_y\n";
|
||||
// } else {
|
||||
// echo "Value X or Value Y not found in current row.\n";
|
||||
// }
|
||||
// set value_x dan value_y
|
||||
|
||||
list($soResultEntryFisikUmumID, $strJsonAwal) = $this->getSoResultEntryFisikUmumID($soResultEntryID, $templateID);
|
||||
// echo "\n ini soResultEntryFisikUmumID {$soResultEntryFisikUmumID} dan TemplateID {$templateID}\n\n";
|
||||
echo " ini key {$key} , value {$value}, dan id_code {$id_code}\n\n";
|
||||
$jsonAwal = json_decode($strJsonAwal, true);
|
||||
// print_r($jsonAwal);
|
||||
// echo "\n";
|
||||
// update jsonAwal sesuai dengan id_code dan value nya
|
||||
// kalau sudah update ke so_resultentryfisikumum
|
||||
switch ($id_code) {
|
||||
case "status_gizi_1":
|
||||
$idx_id_code = $this->find_id_code_index($jsonAwal['details'], "status_gizi_1");
|
||||
if ($idx_id_code == -1) continue;
|
||||
$jsonAwal['details'][$idx_id_code]['value'] = $value;
|
||||
//update jsonAwal utk gizi_1
|
||||
break;
|
||||
case "status_gizi_2":
|
||||
// echo "ini json awal details : ";
|
||||
// print_r($jsonAwal['details']);
|
||||
$idx_id_code = $this->find_id_code_index($jsonAwal['details'], "status_gizi_2");
|
||||
if ($idx_id_code == -1) continue;
|
||||
$jsonAwal['details'][$idx_id_code]['value'] = $value;
|
||||
// echo "ini json awal setelah diubah : ";
|
||||
// print_r($jsonAwal['details']);
|
||||
//update jsonAwal utk gizi_1
|
||||
break;
|
||||
case "status_gizi_4":
|
||||
$idx_id_code = $this->find_id_code_index($jsonAwal['details'], "status_gizi_4");
|
||||
if ($idx_id_code == -1) continue;
|
||||
$jsonAwal['details'][$idx_id_code]['value'] = $value;
|
||||
//update jsonAwal utk gizi_1
|
||||
break;
|
||||
case "tanda_vital_1":
|
||||
$idx_id_code = $this->find_id_code_index($jsonAwal['details'], "tanda_vital_1");
|
||||
if ($idx_id_code == -1) continue;
|
||||
$jsonAwal['details'][$idx_id_code]['value'] = $value;
|
||||
//update jsonAwal utk gizi_1
|
||||
break;
|
||||
case "tanda_vital_2":
|
||||
$idx_id_code = $this->find_id_code_index($jsonAwal['details'], "tanda_vital_2");
|
||||
if ($idx_id_code == -1) continue;
|
||||
$jsonAwal['details'][$idx_id_code]['value'] = $value;
|
||||
//update jsonAwal utk gizi_1
|
||||
break;
|
||||
case "tanda_vital_5":
|
||||
$idx_id_code = $this->find_id_code_index($jsonAwal['details'], "tanda_vital_5");
|
||||
if ($idx_id_code == -1) continue;
|
||||
if ($key == 'Sistolik') {
|
||||
$jsonAwal['details'][$idx_id_code]['value_x'] = $value;
|
||||
}
|
||||
if ($key == 'Diastolik') {
|
||||
$jsonAwal['details'][$idx_id_code]['value_y'] = $value;
|
||||
}
|
||||
//update jsonAwal utk gizi_1
|
||||
break;
|
||||
|
||||
default:
|
||||
echo "tidak ada case dengan code {$id_code} \n";
|
||||
}
|
||||
if ($key == 'Kenal_Warna') {
|
||||
if ($value == 'Normal') {
|
||||
$jsonAwal['details'][0]['chx'] = true;
|
||||
} elseif ($value == '') {
|
||||
$jsonAwal['details'][0]['chx'] = true;
|
||||
} else {
|
||||
$jsonAwal['details'][1]['chx'] = true;
|
||||
$jsonAwal['details'][0]['value'] = $value;
|
||||
}
|
||||
}
|
||||
$sql_u = "UPDATE so_resultentry_fisik_umum
|
||||
SET So_ResultEntryFisikUmumDetails = ?
|
||||
WHERE So_ResultEntryFisikUmumID = ?";
|
||||
//
|
||||
// echo "ini json yang di update :" . json_encode($jsonAwal) . "\n";
|
||||
// echo "ini fisik id :" . $soResultEntryFisikUmumID . "\n";
|
||||
|
||||
|
||||
//
|
||||
$qry = $this->db->query($sql_u, [json_encode($jsonAwal), $soResultEntryFisikUmumID]);
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Error update so_resultentry_fisik_umum | " . $this->db->error()["message"]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function find_id_code_index($details, $id_code)
|
||||
{
|
||||
$result = -1;
|
||||
foreach ($details as $idx => $value) {
|
||||
|
||||
if ($value["id_code"] == $id_code) {
|
||||
return $idx;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
function insert_or_update_TB($torderheaderid, $value)
|
||||
{
|
||||
//qry search table t_samplingso_additional_fisik_bbtb menggunakan torderheaderid
|
||||
// kalau ketemu di update
|
||||
// kalai tudak di insert
|
||||
}
|
||||
function insert_or_update_BB($torderheaderid, $value)
|
||||
{
|
||||
//qry search table t_samplingso_additional_fisik_bbtb menggunakan torderheaderid
|
||||
// kalau ketemu di update
|
||||
// kalai tudak di insert
|
||||
}
|
||||
}
|
||||
134
application/controllers/tools/Inject_lab.php
Normal file
134
application/controllers/tools/Inject_lab.php
Normal file
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
class Inject_lab extends MY_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// $this->db_antrione = $this->load->database("antrione", true);
|
||||
}
|
||||
|
||||
function loop_regno(){
|
||||
$sql = "SELECT *
|
||||
FROM x_t_orderheader
|
||||
WHERE
|
||||
T_OrderheaderID > 6771";
|
||||
$qry = $this->db->query($sql);
|
||||
//echo $sql;
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Error get get header | " . $this->db->error()["message"]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$datas = $qry->result_array();
|
||||
foreach ($datas as $key => $value) {
|
||||
$this->update($value['T_OrderHeaderOldLabNumber']);
|
||||
}
|
||||
}
|
||||
|
||||
function update($regno)
|
||||
{
|
||||
if (isset($regno)) {
|
||||
$sql = "SELECT DISTINCT T_OrderHeaderID
|
||||
FROM x_t_orderheader
|
||||
WHERE T_OrderHeaderOldLabNumber = ?
|
||||
";
|
||||
$qry = $this->db->query($sql, [$regno]);
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Error get x_t_orderheader | " . $this->db->error()["message"]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
if(count($rows) != 0 ){
|
||||
$t_orderheaderid = $rows[0]['T_OrderHeaderID'];
|
||||
|
||||
$sql = "SELECT T_OrderDetailT_TestID, name
|
||||
FROM x_t_orderdetail
|
||||
JOIN x_map_lab ON test_id = T_OrderDetailT_TestID
|
||||
WHERE T_OrderDetailT_OrderHeaderID = ?
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
";
|
||||
$qry = $this->db->query($sql, [$t_orderheaderid]);
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Error get x_t_orderdetail | " . $this->db->error()["message"]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$row_details = $qry->result_array();
|
||||
|
||||
|
||||
if(count($row_details) != 0 ){
|
||||
$arr_map =[];
|
||||
foreach ($row_details as $row_detail) {
|
||||
$testid = $row_detail['T_OrderDetailT_TestID'];
|
||||
$x_name = $row_detail['name'];
|
||||
$arr_map[$x_name] = $testid;
|
||||
}
|
||||
}
|
||||
|
||||
$sql="SELECT * FROM x_adm_rekap_fisik_lab WHERE REG_NO = ? ";
|
||||
$query = $this->db->query($sql, [$regno]);
|
||||
if (!$query) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Error get x_t_orderdetail | " . $this->db->error()["message"]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
|
||||
if(count($rows) == 0 ){
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Tidak Ada REG_NO yang ditemukan"
|
||||
]);
|
||||
exit;
|
||||
}else{
|
||||
foreach($rows as $r){
|
||||
foreach($r as $key=> $value){
|
||||
$test_id = $arr_map[$key];
|
||||
|
||||
$sql = "UPDATE x_t_orderdetail
|
||||
SET t_orderdetailresult = ?
|
||||
WHERE T_OrderDetailT_OrderHeaderID = ?
|
||||
AND T_OrderDetailT_TestID = ?
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
";
|
||||
|
||||
$query = $this->db->query($sql, [$value, $t_orderheaderid, $test_id]);
|
||||
|
||||
if (!$query) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Error update x_t_orderdetail | " . $this->db->error()["message"]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
echo json_encode([
|
||||
"status" => "Success",
|
||||
"message" => "Success Update orderdetailresult"
|
||||
]);
|
||||
}
|
||||
}else{
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Tidak Ada data"
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
465
application/controllers/tools/Inject_riwayat.php
Normal file
465
application/controllers/tools/Inject_riwayat.php
Normal file
@@ -0,0 +1,465 @@
|
||||
<?php
|
||||
class Inject_riwayat extends MY_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
function proses($regno)
|
||||
{
|
||||
list($orderHeaderID, $orderDetailID) = $this->getOrderDetailID($regno);
|
||||
$arr_map = $this->getArrayMap();
|
||||
$soResultEntryID = $this->getSoResultEntryID($orderDetailID);
|
||||
$sql_u = "update so_resultentryfisikumum set So_ResultEntryFisikUmumDetails = ?
|
||||
where So_ResultEntryFisikUmumID = ?";
|
||||
|
||||
$sql = "SELECT DISTINCT REG_NO, Keluhan,
|
||||
`Riwayat Penyakit Dahulu`, Ayah , Ibu ,
|
||||
Alergi, `Kebiasaan Merokok`,
|
||||
`Kebiasaan Alkohol`,
|
||||
`Kebiasaan Olahraga`
|
||||
FROM x_adm_rekap_riwayat WHERE REG_NO = ?";
|
||||
$qry = $this->db->query($sql, [$regno]);
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Error get x_adm_rekap_riwayat | " . $this->db->error()["message"]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
|
||||
foreach ($rows as $r) {
|
||||
foreach ($r as $key => $value) {
|
||||
if ($key == "REG_NO") continue;
|
||||
|
||||
$templateID = $arr_map[$key][1];
|
||||
if ($templateID == "") continue;
|
||||
list($soResultEntryFisikUmumID, $strJsonAwal) = $this->getSoResultEntryFisikUmumID($soResultEntryID, $templateID);
|
||||
echo $soResultEntryFisikUmumID;
|
||||
echo "\n";
|
||||
echo "$key,$value\n\n";
|
||||
$jsonAwal = json_decode($strJsonAwal, true);
|
||||
switch ($key) {
|
||||
case "Keluhan":
|
||||
|
||||
$idx_id_code = $this->find_label_index($jsonAwal['details'], $value);
|
||||
if ($idx_id_code == -1) {
|
||||
if(strlen($value) > 3){
|
||||
$jsonAwal['details'][27]['chx'] = true;
|
||||
$jsonAwal['details'][27]['value'] = $value;
|
||||
}
|
||||
}else{
|
||||
$jsonAwal['details'][$idx_id_code]['chx'] = true;
|
||||
}
|
||||
// update json detail utk riwayat keluhan
|
||||
break;
|
||||
case "Riwayat Penyakit Dahulu":
|
||||
$explode = explode("\n", $value);
|
||||
$etc_values = [];
|
||||
foreach ($explode as $xpld){
|
||||
for ($i=0; $i < count($jsonAwal['details']); $i++) {
|
||||
|
||||
print_r("\n----");
|
||||
print_r($xpld);
|
||||
print_r("---\n");
|
||||
$idx_name_code = $this->find_label_index($jsonAwal['details'][$i]['details'], $xpld);
|
||||
if ($idx_id_code == -1) {
|
||||
$etc_value = $xpld;
|
||||
$idx_id_code = 0;
|
||||
break;
|
||||
}else {
|
||||
|
||||
}
|
||||
}
|
||||
$etc_values[] = $etc_value;
|
||||
// switch($xpld){
|
||||
// case "Operasi":
|
||||
// $etc_value = [$xpld];
|
||||
|
||||
// }
|
||||
|
||||
}
|
||||
print_r("\n----");
|
||||
print_r("---\n");
|
||||
exit;
|
||||
// $idx_id_code = $this->find_label_index($jsonAwal['details'], $value);
|
||||
// if ($idx_id_code == -1) {
|
||||
// if(strlen($value) > 3){
|
||||
// $jsonAwal['details'][27]['chx'] = true;
|
||||
// $jsonAwal['details'][27]['value'] = $value;
|
||||
// }
|
||||
// }else{
|
||||
// $jsonAwal['details'][$idx_id_code]['chx'] = true;
|
||||
// }
|
||||
// update json detail utk riwayat keluhan
|
||||
break;
|
||||
// case "fisik_keluhan_2":
|
||||
// $idx_id_code = $this->find_id_code_index($jsonAwal['details'], "fisik_keluhan_2");
|
||||
// if ($idx_id_code == -1) continue;
|
||||
// $jsonAwal['details'][$idx_id_code]['value'] = $value;
|
||||
// //update jsonAwal utk gizi_1
|
||||
// break;
|
||||
// case "fisik_keluhan_3":
|
||||
// $idx_id_code = $this->find_id_code_index($jsonAwal['details'], "fisik_keluhan_3");
|
||||
// if ($idx_id_code == -1) continue;
|
||||
// $jsonAwal['details'][$idx_id_code]['value'] = $value;
|
||||
// //update jsonAwal utk gizi_1
|
||||
// break;
|
||||
default:
|
||||
echo "tidak ada case dengan code {$key} \n";
|
||||
}
|
||||
// $sql_u = "UPDATE so_resultentry_fisik_umum
|
||||
// SET So_ResultEntryFisikUmumDetails = ?
|
||||
// WHERE So_ResultEntryFisikUmumID = ?";
|
||||
// $qry = $this->db->query($sql_u, [json_encode($jsonAwal), $soResultEntryFisikUmumID]);
|
||||
// if (!$qry) {
|
||||
// echo json_encode([
|
||||
// "status" => "ERR",
|
||||
// "message" => "Error update so_resultentry_fisik_umum | " . $this->db->error()["message"]
|
||||
// ]);
|
||||
// exit;
|
||||
// }
|
||||
// echo "ini qry : ";
|
||||
// print_r($qry);
|
||||
// exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
function getOrderDetailID($reg_no)
|
||||
{
|
||||
if (isset($reg_no)) {
|
||||
$sql = "SELECT T_OrderHeaderID
|
||||
FROM t_orderheader
|
||||
WHERE T_OrderHeaderOldLabNumber = ?";
|
||||
$qry = $this->db->query($sql, $reg_no);
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Error get t_orderheader | " . $this->db->error()["message"]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) != 0) {
|
||||
$t_orderheaderid = $rows[0]['T_OrderHeaderID'];
|
||||
$t_testid = 2562;
|
||||
echo "T_OrderHeaderID: " . $t_orderheaderid . "\n";
|
||||
echo "t_testid: " . $t_testid . "\n";
|
||||
|
||||
$sql = "SELECT T_OrderDetailID
|
||||
FROM t_orderdetail
|
||||
WHERE T_OrderDetailT_OrderHeaderID = ?
|
||||
AND T_OrderDetailT_TestID = ?
|
||||
AND T_OrderDetailIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$t_orderheaderid, $t_testid]);
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Error get t_orderdetail | " . $this->db->error()["message"]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
$rows_detail = $qry->result_array();
|
||||
if (count($rows_detail) != 0) {
|
||||
$t_orderdetailid = $rows_detail[0]['T_OrderDetailID'];
|
||||
}
|
||||
echo "t_orderdetailid: " . $t_orderdetailid . "\n";
|
||||
return [$t_orderheaderid, $t_orderdetailid];
|
||||
} else {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Tidak ditemukan Registrasi dengan nomor registrasi : " . $reg_no
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getArrayMap()
|
||||
{
|
||||
$sql = "SELECT * FROM x_map_riwayat";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Error get x_map_riwayat | " . $this->db->error()["message"]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
$arr_map = [];
|
||||
$rows = $qry->result_array();
|
||||
foreach ($rows as $r) {
|
||||
$arr_map[$r["X_Map_RiwayatName"]] = [$r["X_Map_RiwayatCodeID"], $r["X_Map_RiwayatTemplateID"]];
|
||||
}
|
||||
return $arr_map;
|
||||
}
|
||||
|
||||
public function getSoResultEntryID($t_orderdetailid_v)
|
||||
{
|
||||
$t_orderdetailid = $t_orderdetailid_v;
|
||||
$nonlab_templateid = 27;
|
||||
$nonlab_templatename = 'Fisik Umum';
|
||||
|
||||
$sql = "SELECT So_ResultEntryID
|
||||
FROM so_resultentry
|
||||
WHERE So_ResultEntryT_OrderDetailID = ?
|
||||
AND So_ResultEntryNonlab_TemplateID = ?
|
||||
AND So_ResultEntryNonlab_TemplateName = ?
|
||||
AND So_ResultEntryIsActive= 'Y'";
|
||||
$qry = $this->db->query($sql, [$t_orderdetailid, $nonlab_templateid, $nonlab_templatename]);
|
||||
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Error get so_resultentry | " . $this->db->error()["message"]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$so_resultentryid = 0;
|
||||
if(count($rows) == 0) {
|
||||
$insert_sql = "INSERT INTO so_resultentry (
|
||||
So_ResultEntryT_OrderDetailID,
|
||||
So_ResultEntryNonlab_TemplateID,
|
||||
So_ResultEntryNonlab_TemplateName)
|
||||
VALUES (?, ?, ?)";
|
||||
$this->db->query($insert_sql, [$t_orderdetailid, $nonlab_templateid, $nonlab_templatename]);
|
||||
echo "so_resultentry baru dibuat \n";
|
||||
$so_resultentryid = $this->db->insert_id();
|
||||
} else {
|
||||
$so_resultentryid = $rows[0]['So_ResultEntryID'];
|
||||
}
|
||||
echo "So_ResultEntryID: " . $so_resultentryid . "\n";
|
||||
return $so_resultentryid;
|
||||
}
|
||||
|
||||
function getSoResultEntryFisikUmumID($soResultEntryID, $templateID)
|
||||
{
|
||||
$sql = "SELECT *
|
||||
FROM so_resultentry_fisik_umum
|
||||
WHERE So_ResultEntryFisikUmumSo_ResultEntryID = ?
|
||||
AND So_ResultEntryFisikUmumFisikTemplateID = ?
|
||||
AND So_ResultEntryFisikUmumIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, array($soResultEntryID, $templateID));
|
||||
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Error get so_resultentry | " . $this->db->error()["message"]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$So_ResultEntryFisikUmumDetails = [];
|
||||
$So_ResultEntryFisikUmumID = 0;
|
||||
if(count($rows) == 0) {
|
||||
echo ("JSON dengan ID :" . $soResultEntryID . " dan template id {$templateID} tidak ada. \n");
|
||||
$search_sql = "SELECT *
|
||||
FROM fisik_template
|
||||
WHERE FisikTemplateID = ?
|
||||
-- AND FisikTemplateIsActive = 'Y'
|
||||
";
|
||||
$qry_search = $this->db->query($search_sql, [$templateID]);
|
||||
if (!$qry_search) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Error get so_resultentry | " . $this->db->error()["message"]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
$search_rows = $qry_search->result_array();
|
||||
if(count($search_rows) != 0) {
|
||||
$FisikTemplateID = $search_rows[0]['FisikTemplateID'];
|
||||
$FisikTemplateJSON = $search_rows[0]['FisikTemplateJSON'];
|
||||
|
||||
echo "FisikTemplateID :" . $FisikTemplateID . "\n";
|
||||
|
||||
$insert_sql = "INSERT INTO so_resultentry_fisik_umum
|
||||
(So_ResultEntryFisikUmumSo_ResultEntryID,
|
||||
So_ResultEntryFisikUmumFisikTemplateID,
|
||||
So_ResultEntryFisikUmumDetails)
|
||||
VALUES ( ?, ?, ? )
|
||||
";
|
||||
$this->db->query($insert_sql, array($soResultEntryID, $FisikTemplateID, $FisikTemplateJSON ));
|
||||
echo "so_resultentry_fisik_umum baru dibuat \n";
|
||||
|
||||
$So_ResultEntryFisikUmumID = $this->db->insert_id();
|
||||
$So_ResultEntryFisikUmumDetails = $FisikTemplateJSON;
|
||||
}else{
|
||||
echo "Gagal INSERT ke so_resultentry_fisik_umum karena fisik_template tidak ditemukan";
|
||||
exit;
|
||||
}
|
||||
$So_ResultEntryFisikUmumID = $rows[0]['So_ResultEntryFisikUmumID'];
|
||||
$So_ResultEntryFisikUmumDetails = $rows[0]['So_ResultEntryFisikUmumDetails'];
|
||||
} else {
|
||||
$So_ResultEntryFisikUmumID = $rows[0]['So_ResultEntryFisikUmumID'];
|
||||
$So_ResultEntryFisikUmumDetails = $rows[0]['So_ResultEntryFisikUmumDetails'];
|
||||
}
|
||||
|
||||
echo "So_ResultEntryFisikUmumID: " . $So_ResultEntryFisikUmumID . "\n";
|
||||
// echo "so_resultentrydetails: " . $So_ResultEntryFisikUmumDetails . "\n\n";
|
||||
return [$So_ResultEntryFisikUmumID, $So_ResultEntryFisikUmumDetails];
|
||||
// echo "So_ResultEntryFisikUmumDetails: " . $so_resultentrydetails . "\n";
|
||||
// return $so_resultentryid;
|
||||
//cari di so_resultentryfisikumum
|
||||
// jika ketemu returnkan So_ResultEntryFisikUmumDetails
|
||||
// jika tidak ketemu cari dari fisik template , FisikTemplateJSON
|
||||
// insertkan ke so_resultentryfisikumum
|
||||
//retun nya [So_ResultEntryFisikUmumID, JSON]
|
||||
}
|
||||
|
||||
function find_label_index($details, $inp_value)
|
||||
{
|
||||
$result = -1;
|
||||
foreach ($details as $idx => $value) {
|
||||
echo("\nmmmm\n");
|
||||
echo "ini search labelnya " . $value["label"];
|
||||
echo "ini search valuenya " . $inp_value;
|
||||
echo("\nmmmm\n");
|
||||
if ($value["label"] == $inp_value) {
|
||||
echo $idx;
|
||||
echo "sama";
|
||||
return $idx;
|
||||
}
|
||||
}
|
||||
echo $inp_value;
|
||||
return $result;
|
||||
}
|
||||
function find_id_code_index($details, $id_code)
|
||||
{
|
||||
$result = -1;
|
||||
foreach ($details as $idx => $value) {
|
||||
|
||||
if ($value["id_code"] == $id_code) {
|
||||
return $idx;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function coba(){
|
||||
$sql = "SELECT DISTINCT REG_NO, Keluhan,
|
||||
`Riwayat Penyakit Dahulu`, Ayah , Ibu ,
|
||||
Alergi, `Kebiasaan Merokok`,
|
||||
`Kebiasaan Alkohol`,
|
||||
`Kebiasaan Olahraga`
|
||||
FROM x_adm_rekap_riwayat WHERE REG_NO = '23ADM20004Z'";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Error get x_adm_rekap_riwayat | " . $this->db->error()["message"]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
|
||||
foreach ($rows as $r) {
|
||||
foreach ($r as $key => $value) {
|
||||
$var = explode("\n", $value);
|
||||
echo "value: |$value|\n";
|
||||
print_r ($var);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// function update($regno)
|
||||
// {
|
||||
// if (isset($reg_no)) {
|
||||
// $sql = "SELECT T_OrderHeaderID
|
||||
// FROM t_orderheader
|
||||
// WHERE T_OrderHeaderOldLabNumber = ?";
|
||||
// $qry = $this->db->query($sql, $reg_no);
|
||||
// if (!$qry) {
|
||||
// echo json_encode([
|
||||
// "status" => "ERR",
|
||||
// "message" => "Error get t_orderheader | " . $this->db->error()["message"]
|
||||
// ]);
|
||||
// exit;
|
||||
// }
|
||||
// $rows = $qry->result();
|
||||
|
||||
// if (count($rows) != 0) {
|
||||
// $t_orderheaderid = $rows[0]->T_OrderHeaderID;
|
||||
// $t_testid = 2562;
|
||||
// echo "T_OrderHeaderID: " . $t_orderheaderid . "\n";
|
||||
// echo "T_OrderHeaderID: " . $t_testid . "\n";
|
||||
|
||||
// $sql = "SELECT T_OrderDetailID
|
||||
// FROM t_orderdetail
|
||||
// WHERE T_OrderDetailT_OrderHeaderID = ?
|
||||
// AND T_OrderDetailT_TestID = ?
|
||||
// AND T_OrderDetailIsActive = 'Y'";
|
||||
// $qry = $this->db->query($sql, array($t_orderheaderid, $t_testid));
|
||||
// if (!$qry) {
|
||||
// echo json_encode([
|
||||
// "status" => "ERR",
|
||||
// "message" => "Error get t_orderdetail | " . $this->db->error()["message"]
|
||||
// ]);
|
||||
// exit;
|
||||
// }
|
||||
// $rows_detail = $qry->result();
|
||||
// if (count($rows_detail) != 0) {
|
||||
// $t_orderdetailid = $rows_detail[0]->T_OrderDetailID;
|
||||
// echo "T_OrderDetailID: " . $t_orderdetailid . "\n";
|
||||
// }
|
||||
// return [$t_orderheaderid, $t_orderdetailid];
|
||||
// } else {
|
||||
// echo json_encode([
|
||||
// "status" => "ERR",
|
||||
// "message" => "Tidak ditemukan Registrasi dengan nomor
|
||||
// registrasi : " . $reg_no
|
||||
// ]);
|
||||
// exit;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (isset($regno)) {
|
||||
// $sql = "SELECT DISTINCT T_OrderHeaderID, T_OrderHeaderMgm_McuID
|
||||
// FROM t_orderheader
|
||||
// WHERE T_OrderHeaderOldLabNumber = ?
|
||||
// ";
|
||||
// $qry = $this->db->query($sql, [$regno]);
|
||||
// if (!$qry) {
|
||||
// echo json_encode([
|
||||
// "status" => "ERR",
|
||||
// "message" => "Error get t_orderheader | " . $this->db->error()["message"]
|
||||
// ]);
|
||||
// exit;
|
||||
// }
|
||||
|
||||
// $rows = $qry->result_array();
|
||||
// if (count($rows) != 0) {
|
||||
// $t_orderheaderid = $rows[0]['T_OrderHeaderID'];
|
||||
// $mgm_mcu_id = $rows[0]['T_OrderHeaderMgm_McuID'];
|
||||
|
||||
// $sql = "SELECT FisikTemplateTitle, FisikTemplateJSON
|
||||
// FROM mgm_mcutemplate
|
||||
// JOIN fisik_template_mapping ON FisikTemplateMappingID = Mgm_McuTemplateFisikTemplateMappingID
|
||||
// AND Mgm_McuTemplateMgm_McuID = $mgm_mcu_id
|
||||
// AND Mgm_McuTemplateIsActive = 'Y'
|
||||
// AND FisikTemplateMappingIsActive = 'Y'
|
||||
// JOIN fisik_template_mapping_detail ON FisikTemplateMappingDetailFisikTemplateMappingID = FisikTemplateMappingID
|
||||
// AND FisikTemplateMappingDetailIsActive = 'Y'
|
||||
// JOIN fisik_template ON FisikTemplateID = FisikTemplateMappingDetailFisikTemplateID
|
||||
// AND FisikTemplateType LIKE 'Riwayat'
|
||||
// AND FisikTemplateIsActive = 'Y'
|
||||
// ";
|
||||
|
||||
|
||||
// } else {
|
||||
// echo json_encode([
|
||||
// "status" => "ERR",
|
||||
// "message" => "Tidak Ada Id ticket"
|
||||
// ]);
|
||||
// exit;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
483
application/controllers/tools/Listrptpatient.php
Normal file
483
application/controllers/tools/Listrptpatient.php
Normal file
@@ -0,0 +1,483 @@
|
||||
<?php
|
||||
class Listrptpatient extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Listing Report Patient API";
|
||||
}
|
||||
|
||||
|
||||
function get_list_patient_rpt($orderHeaderID,$debug='N')
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$lab = "";
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
from t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID AND mp.M_PatientIsActive = 'Y'
|
||||
JOIN t_orderdetail ON toh.T_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND Group_ResultName = 'LAB'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'
|
||||
LIMIT 1";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
//echo $this->db->last_query();
|
||||
if($row && count($row) > 0){
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_history.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY so_id
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql);
|
||||
//echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = [];
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
$kebugaran = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$value["so_id"]}&PLang=1&tm={$value["Datetime"]}";
|
||||
//$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$value["so_id"]}&PLang=1&tm={$value["Datetime"]}";
|
||||
|
||||
|
||||
if($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Treadmill'){
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if(count($rows_attachment) > 0){
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/'.$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear_history.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro_2.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg_2_annual.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
|
||||
if($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0){
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = {$value["so_id"]}
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type);
|
||||
|
||||
if ($qry_type) {
|
||||
// echo "IN";
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$file_cover = "rpt_mcu_resume_cover";
|
||||
|
||||
$sql = "SELECT M_CoverRpt as file_cover, M_CoverRptLogo as file_logo
|
||||
FROM t_orderheader
|
||||
JOIN mgm_cover ON T_OrderHeaderMgm_McuID = Mgm_CoverMgm_McuID AND Mgm_CoverIsActive = 'Y'
|
||||
JOIN m_cover ON Mgm_CoverM_CoverCode = M_CoverCode AND M_CoverIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$qry_cover = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_cover) {
|
||||
$row_cover = $qry_cover->result_array();
|
||||
if(count($row_cover) > 0){
|
||||
$file_cover = $row_cover[0]['file_cover'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$cover_rpt = "";
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/".$file_cover.".rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$additional = "";
|
||||
if($fisik == ""){
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
//print_r($rows_addtional);
|
||||
if(count($rows_addtional) > 0){
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata_history.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID NOT IN (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND T_NonlabDocumentIsActive = 'Y'
|
||||
GROUP BY T_SamplingSoID";
|
||||
$qry_nonlabdocument = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_nonlabdocument) {
|
||||
$rows_nonlabdocument = $qry_nonlabdocument->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get nonlabdocument", $this->db);
|
||||
exit;
|
||||
}
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://cpone.aplikasi.web.id";
|
||||
$prefix = "https://".$_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
|
||||
if(count($attachments) > 0){
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix."/one-media/one-files/".$value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if(count($rontgen) > 0){
|
||||
foreach ($rontgen as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
/*if ($usg_abdomen != "") {
|
||||
$list_rpt[] = $prefix . $usg_abdomen;
|
||||
}*/
|
||||
if(count($usg) > 0){
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if(count($treadmill_attachment) > 0){
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "") {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
if(count($rows_nonlabdocument) > 0){
|
||||
foreach ($rows_nonlabdocument as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-document-nonlab/".$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($debug == 'Y'){
|
||||
print_r($rows_nonlabdocument);
|
||||
exit;
|
||||
foreach ($list_rpt as $key => $value) {
|
||||
echo "<a href='".$value."' target='_blank'>".$value."</a><br>";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/frameset?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/frameset?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
|
||||
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
$jsonData = json_encode($merge_input);
|
||||
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://".$_SERVER['SERVER_NAME']."/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $lab_number . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt(
|
||||
$ch,
|
||||
CURLOPT_HTTPHEADER,
|
||||
array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data)
|
||||
)
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
410
application/controllers/tools/Listrptpatienthaji.php
Normal file
410
application/controllers/tools/Listrptpatienthaji.php
Normal file
@@ -0,0 +1,410 @@
|
||||
<?php
|
||||
class Listrptpatienthaji extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Listing Report Patient API";
|
||||
}
|
||||
|
||||
|
||||
function get_list_patient_rpt($so_resultentry_id,$timestamp='',$tanpa_kesimpulan='N',$debug='N')
|
||||
{
|
||||
try {
|
||||
|
||||
$attachments = [];
|
||||
|
||||
$rpt_haji = "";
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$lab = "";
|
||||
$orderHeaderID = "";
|
||||
|
||||
$sql = "SELECT
|
||||
So_ResultEntryID as id,
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
from so_resultentry
|
||||
JOIN t_orderheader toh ON toh.T_OrderHeaderID = So_ResultEntryT_OrderHeaderID AND toh.T_OrderHeaderIsActive = 'Y'
|
||||
JOIN t_orderdetail tdet ON tdet.T_OrderDetailID = So_ResultEntryT_OrderDetailID AND tdet.T_OrderDetailIsActive = 'Y'
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID AND mp.M_PatientIsActive = 'Y'
|
||||
WHERE
|
||||
So_ResultEntryID = ? AND
|
||||
So_ResultEntryIsActive = 'Y'
|
||||
LIMIT 1";
|
||||
$qry = $this->db->query($sql, [$so_resultentry_id]);
|
||||
|
||||
if(!$qry){
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
$row = $qry->result_array();
|
||||
if(count($row) > 0){
|
||||
$lab_number = $row[0]['T_OrderHeaderLabNumber'];
|
||||
$patient_name = $row[0]['M_PatientName'];
|
||||
$orderHeaderID = $row[0]['T_OrderHeaderID'];
|
||||
}
|
||||
|
||||
//$rpt_haji = "/birt/run?__report=report/one/mcu/mcu_fisik_haji.rptdesign&__format=pdf&PID={$so_resultentry_id}&tm={$row[0]['Datetime']}&username=admin";
|
||||
|
||||
$rpt_haji = "/birt/run?__report=report/one/mcu/mcu_fisik_haji.rptdesign&__format=pdf&username=admin&PID={$so_resultentry_id}&PType=Fisik&tm={$row[0]['Datetime']}";
|
||||
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY so_id
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = [];
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
$kebugaran = '';
|
||||
|
||||
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
/*if($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_v2.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
*/
|
||||
|
||||
if($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_xray.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
/*
|
||||
if($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
*/
|
||||
if($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
/*if($value['rpt_name'] == 'Treadmill'){
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if(count($rows_attachment) > 0){
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/'.$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['group_name'] == 'USG' )
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0){
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
if($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
*/
|
||||
}
|
||||
|
||||
/*$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
$file_cover = "rpt_mcu_resume_cover";
|
||||
|
||||
$sql = "SELECT M_CoverRpt as file_cover, M_CoverRptLogo as file_logo
|
||||
FROM t_orderheader
|
||||
JOIN mgm_cover ON T_OrderHeaderMgm_McuID = Mgm_CoverMgm_McuID AND Mgm_CoverIsActive = 'Y'
|
||||
JOIN m_cover ON Mgm_CoverM_CoverCode = M_CoverCode AND M_CoverIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$qry_cover = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_cover) {
|
||||
$row_cover = $qry_cover->result_array();
|
||||
if(count($row_cover) > 0){
|
||||
$file_cover = $row_cover[0]['file_cover'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_v2.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/".$file_cover.".rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$additional = "";
|
||||
if($fisik == ""){
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
//print_r($rows_addtional);
|
||||
if(count($rows_addtional) > 0){
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata_portal.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
$prefix = "http://localhost";
|
||||
$prefix = "https://".$_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($rpt_haji != "") {
|
||||
$list_rpt[] = $prefix . $rpt_haji;
|
||||
}
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if(count($attachments) > 0){
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix."/one-media/one-files/".$value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if(count($rontgen) > 0){
|
||||
foreach ($rontgen as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
/*if ($usg_abdomen != "") {
|
||||
$list_rpt[] = $prefix . $usg_abdomen;
|
||||
}*/
|
||||
if(count($usg) > 0){
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if(count($treadmill_attachment) > 0){
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "" && $tanpa_kesimpulan == "N") {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
if($debug == 'Y'){
|
||||
foreach ($list_rpt as $key => $value) {
|
||||
echo "<a href='".$value."' target='_blank'>".$value."</a><br>";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
if ($dob != "") {
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt,
|
||||
"dob" => $dob
|
||||
);
|
||||
}
|
||||
$jsonData = json_encode($merge_input);
|
||||
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $nip . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt(
|
||||
$ch,
|
||||
CURLOPT_HTTPHEADER,
|
||||
array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data)
|
||||
)
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
409
application/controllers/tools/Listrptpatienthajiportal.php
Normal file
409
application/controllers/tools/Listrptpatienthajiportal.php
Normal file
@@ -0,0 +1,409 @@
|
||||
<?php
|
||||
class Listrptpatienthajiportal extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Listing Report Patient API";
|
||||
}
|
||||
|
||||
|
||||
function get_list_patient_rpt($so_resultentry_id,$timestamp='',$tanpa_kesimpulan='N',$debug='N')
|
||||
{
|
||||
try {
|
||||
|
||||
$attachments = [];
|
||||
|
||||
$rpt_haji = "";
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$lab = "";
|
||||
$orderHeaderID = "";
|
||||
|
||||
$sql = "SELECT
|
||||
So_ResultEntryID as id,
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
from so_resultentry
|
||||
JOIN t_orderheader toh ON toh.T_OrderHeaderID = So_ResultEntryT_OrderHeaderID AND toh.T_OrderHeaderIsActive = 'Y'
|
||||
JOIN t_orderdetail tdet ON tdet.T_OrderDetailID = So_ResultEntryT_OrderDetailID AND tdet.T_OrderDetailIsActive = 'Y'
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID AND mp.M_PatientIsActive = 'Y'
|
||||
WHERE
|
||||
So_ResultEntryID = ? AND
|
||||
So_ResultEntryIsActive = 'Y'
|
||||
LIMIT 1";
|
||||
$qry = $this->db->query($sql, [$so_resultentry_id]);
|
||||
|
||||
if(!$qry){
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
$row = $qry->result_array();
|
||||
if(count($row) > 0){
|
||||
$lab_number = $row[0]['T_OrderHeaderLabNumber'];
|
||||
$patient_name = $row[0]['M_PatientName'];
|
||||
$orderHeaderID = $row[0]['T_OrderHeaderID'];
|
||||
}
|
||||
|
||||
//$rpt_haji = "/birt/run?__report=report/one/mcu/mcu_fisik_haji.rptdesign&__format=pdf&PID={$so_resultentry_id}&tm={$row[0]['Datetime']}&username=admin";
|
||||
|
||||
$rpt_haji = "/birt/run?__report=report/one/mcu/mcu_fisik_haji_portal.rptdesign&__format=pdf&username=admin&PID={$so_resultentry_id}&PType=Fisik&tm={$row[0]['Datetime']}";
|
||||
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY so_id
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = [];
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
$kebugaran = '';
|
||||
|
||||
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
/*if($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_v2.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
*/
|
||||
|
||||
if($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_xray_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
/*
|
||||
if($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
*/
|
||||
if($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
/*if($value['rpt_name'] == 'Treadmill'){
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if(count($rows_attachment) > 0){
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/'.$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['group_name'] == 'USG' )
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0){
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
if($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
*/
|
||||
}
|
||||
|
||||
/*$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
$file_cover = "rpt_mcu_resume_cover";
|
||||
|
||||
$sql = "SELECT M_CoverRpt as file_cover, M_CoverRptLogo as file_logo
|
||||
FROM t_orderheader
|
||||
JOIN mgm_cover ON T_OrderHeaderMgm_McuID = Mgm_CoverMgm_McuID AND Mgm_CoverIsActive = 'Y'
|
||||
JOIN m_cover ON Mgm_CoverM_CoverCode = M_CoverCode AND M_CoverIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$qry_cover = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_cover) {
|
||||
$row_cover = $qry_cover->result_array();
|
||||
if(count($row_cover) > 0){
|
||||
$file_cover = $row_cover[0]['file_cover'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_v2.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/".$file_cover.".rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$additional = "";
|
||||
if($fisik == ""){
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
//print_r($rows_addtional);
|
||||
if(count($rows_addtional) > 0){
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata_portal.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
$prefix = "http://localhost";
|
||||
$prefix = "https://".$_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($rpt_haji != "") {
|
||||
$list_rpt[] = $prefix . $rpt_haji;
|
||||
}
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if(count($attachments) > 0){
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix."/one-media/one-files/".$value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if(count($rontgen) > 0){
|
||||
foreach ($rontgen as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
/*if ($usg_abdomen != "") {
|
||||
$list_rpt[] = $prefix . $usg_abdomen;
|
||||
}*/
|
||||
if(count($usg) > 0){
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if(count($treadmill_attachment) > 0){
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "" && $tanpa_kesimpulan == "N") {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
if($debug == 'Y'){
|
||||
foreach ($list_rpt as $key => $value) {
|
||||
echo "<a href='".$value."' target='_blank'>".$value."</a><br>";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
if ($dob != "") {
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt,
|
||||
"dob" => $dob
|
||||
);
|
||||
}
|
||||
$jsonData = json_encode($merge_input);
|
||||
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $nip . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt(
|
||||
$ch,
|
||||
CURLOPT_HTTPHEADER,
|
||||
array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data)
|
||||
)
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
913
application/controllers/tools/Listrptpatientportal.php
Normal file
913
application/controllers/tools/Listrptpatientportal.php
Normal file
@@ -0,0 +1,913 @@
|
||||
<?php
|
||||
class Listrptpatientportal extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Listing Report Patient API";
|
||||
}
|
||||
|
||||
function get_list_patient_rpt($orderHeaderID, $dob = "",$debug='N')
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$lab = "";
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
from t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID AND mp.M_PatientIsActive = 'Y'
|
||||
JOIN t_orderdetail ON toh.T_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND Group_ResultName = 'LAB'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'
|
||||
LIMIT 1";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
if ($row && count($row) > 0) {
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_history_portal.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY so_id
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = [];
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
$kebugaran = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
//print_r($rows_rpt);
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if ($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_portal.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Treadmill'){
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if(count($rows_attachment) > 0){
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/'.$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear_history_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro_2_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0) {
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
if($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
$file_cover = "rpt_mcu_resume_cover_portal";
|
||||
|
||||
$sql = "SELECT M_CoverRpt as file_cover, M_CoverRptLogo as file_logo
|
||||
FROM t_orderheader
|
||||
JOIN mgm_cover ON T_OrderHeaderMgm_McuID = Mgm_CoverMgm_McuID AND Mgm_CoverIsActive = 'Y'
|
||||
JOIN m_cover ON Mgm_CoverM_CoverCode = M_CoverCode AND M_CoverIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$qry_cover = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_cover) {
|
||||
$row_cover = $qry_cover->result_array();
|
||||
if(count($row_cover) > 0){
|
||||
$file_cover = $row_cover[0]['file_logo'];
|
||||
}
|
||||
}
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_portal.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/".$file_cover.".rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$additional = "";
|
||||
if ($fisik == "") {
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
//print_r($rows_addtional);
|
||||
if (count($rows_addtional) > 0) {
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata_history_portal.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID NOT IN (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND T_NonlabDocumentIsActive = 'Y'
|
||||
GROUP BY T_SamplingSoID";
|
||||
$qry_nonlabdocument = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_nonlabdocument) {
|
||||
$rows_nonlabdocument = $qry_nonlabdocument->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get nonlabdocument", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://devcpone.aplikasi.web.id";
|
||||
$prefix = "https://" . $_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if (count($attachments) > 0) {
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-files/" . $value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if(count($rontgen) > 0){
|
||||
foreach ($rontgen as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
/*if ($usg_abdomen != "") {
|
||||
$list_rpt[] = $prefix . $usg_abdomen;
|
||||
}*/
|
||||
if(count($usg) > 0){
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if(count($treadmill_attachment) > 0){
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "") {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
if(count($rows_nonlabdocument) > 0){
|
||||
foreach ($rows_nonlabdocument as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-document-nonlab/".$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
|
||||
if($debug == 'Y'){
|
||||
print_r($rows_nonlabdocument);
|
||||
exit;
|
||||
foreach ($list_rpt as $key => $value) {
|
||||
echo "<a href='".$value."' target='_blank'>".$value."</a><br>";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
//echo json_encode($list_rpt);
|
||||
//exit;
|
||||
//print_r($list_rpt);
|
||||
//exit;
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
|
||||
$jsonData = json_encode($merge_input);
|
||||
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $lab_number . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function get_list_patient_rpt_email($orderHeaderID, $dob = "",$debug='N')
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
IFNULL(mp.M_PatientNIP, '') AS M_PatientNIP,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID
|
||||
AND mp.M_PatientIsActive = 'Y'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$nip = "";
|
||||
$lab = "";
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$nip = $value["M_PatientNIP"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_history_portal.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY so_id
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = [];
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
$kebugaran = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
//print_r($rows_rpt);
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if ($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_portal.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Treadmill'){
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if(count($rows_attachment) > 0){
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/'.$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear_history_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
|
||||
if ($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0) {
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
if($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
$file_cover = "rpt_mcu_resume_cover_portal";
|
||||
|
||||
$sql = "SELECT M_CoverRpt as file_cover, M_CoverRptLogo as file_logo
|
||||
FROM t_orderheader
|
||||
JOIN mgm_cover ON T_OrderHeaderMgm_McuID = Mgm_CoverMgm_McuID AND Mgm_CoverIsActive = 'Y'
|
||||
JOIN m_cover ON Mgm_CoverM_CoverCode = M_CoverCode AND M_CoverIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$qry_cover = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_cover) {
|
||||
$row_cover = $qry_cover->result_array();
|
||||
if(count($row_cover) > 0){
|
||||
$file_cover = $row_cover[0]['file_logo'];
|
||||
}
|
||||
}
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_portal.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/".$file_cover.".rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$additional = "";
|
||||
if ($fisik == "") {
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
//print_r($rows_addtional);
|
||||
if (count($rows_addtional) > 0) {
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata_history_portal.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID NOT IN (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND T_NonlabDocumentIsActive = 'Y'
|
||||
GROUP BY T_SamplingSoID";
|
||||
$qry_nonlabdocument = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_nonlabdocument) {
|
||||
$rows_nonlabdocument = $qry_nonlabdocument->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get nonlabdocument", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://devcpone.aplikasi.web.id";
|
||||
$prefix = "https://" . $_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if (count($attachments) > 0) {
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-files/" . $value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if(count($rontgen) > 0){
|
||||
foreach ($rontgen as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
/*if ($usg_abdomen != "") {
|
||||
$list_rpt[] = $prefix . $usg_abdomen;
|
||||
}*/
|
||||
if(count($usg) > 0){
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if(count($treadmill_attachment) > 0){
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "") {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
if(count($rows_nonlabdocument) > 0){
|
||||
foreach ($rows_nonlabdocument as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-document-nonlab/".$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
|
||||
if($debug == 'Y'){
|
||||
print_r($rows_nonlabdocument);
|
||||
exit;
|
||||
foreach ($list_rpt as $key => $value) {
|
||||
echo "<a href='".$value."' target='_blank'>".$value."</a><br>";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
//echo json_encode($list_rpt);
|
||||
//exit;
|
||||
// print_r($list_rpt);
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
if ($dob != "") {
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt,
|
||||
"dob" => $dob
|
||||
);
|
||||
}
|
||||
$jsonData = json_encode($merge_input);
|
||||
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $nip . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt(
|
||||
$ch,
|
||||
CURLOPT_HTTPHEADER,
|
||||
array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data)
|
||||
)
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
922
application/controllers/tools/Listrptpatientportalbg.php
Normal file
922
application/controllers/tools/Listrptpatientportalbg.php
Normal file
@@ -0,0 +1,922 @@
|
||||
<?php
|
||||
class Listrptpatientportalbg extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Listing Report Patient API";
|
||||
}
|
||||
|
||||
function get_list_patient_rpt($orderHeaderID, $background, $dob = "",$debug='N')
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
|
||||
if($background === "bgdflt"){
|
||||
$background = "";
|
||||
}
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$lab = "";
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
from t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID AND mp.M_PatientIsActive = 'Y'
|
||||
JOIN t_orderdetail ON toh.T_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND Group_ResultName = 'LAB'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'
|
||||
LIMIT 1";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
if ($row && count($row) > 0) {
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_history" . $background . "_portal.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY so_id
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = [];
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
$kebugaran = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
//print_r($rows_rpt);
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if ($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history" . $background . "_portal.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual" . $background . "_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual" . $background . "_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual" . $background . "_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual" . $background . "_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Treadmill') {
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual" . $background . "_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if (count($rows_attachment) > 0) {
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/' . $value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear_history" . $background . "_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro" . $background . "_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg_2_annual" . $background . "_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0) {
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan" . $background . "_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
$file_cover = "rpt_mcu_resume_cover" . $background . "_portal";
|
||||
|
||||
$sql = "SELECT M_CoverRpt as file_cover, M_CoverRptLogo as file_logo
|
||||
FROM t_orderheader
|
||||
JOIN mgm_cover ON T_OrderHeaderMgm_McuID = Mgm_CoverMgm_McuID AND Mgm_CoverIsActive = 'Y'
|
||||
JOIN m_cover ON Mgm_CoverM_CoverCode = M_CoverCode AND M_CoverIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$qry_cover = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_cover) {
|
||||
$row_cover = $qry_cover->result_array();
|
||||
if (count($row_cover) > 0) {
|
||||
$file_cover = $row_cover[0]['file_logo'];
|
||||
if (strpos($file_cover, '_portal') !== false) {
|
||||
$file_cover = str_replace('_portal', $background . '_portal', $file_cover);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan" . $background . "_portal.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/" . $file_cover . ".rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$additional = "";
|
||||
if ($fisik == "") {
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
//print_r($rows_addtional);
|
||||
if (count($rows_addtional) > 0) {
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata_history" . $background . "_portal.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID NOT IN (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND T_NonlabDocumentIsActive = 'Y'
|
||||
GROUP BY T_SamplingSoID";
|
||||
$qry_nonlabdocument = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_nonlabdocument) {
|
||||
$rows_nonlabdocument = $qry_nonlabdocument->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get nonlabdocument", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://devcpone.aplikasi.web.id";
|
||||
$prefix = "https://" . $_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if (count($attachments) > 0) {
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-files/" . $value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if(count($rontgen) > 0){
|
||||
foreach ($rontgen as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
/*if ($usg_abdomen != "") {
|
||||
$list_rpt[] = $prefix . $usg_abdomen;
|
||||
}*/
|
||||
if (count($usg) > 0) {
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if (count($treadmill_attachment) > 0) {
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "") {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
if(count($rows_nonlabdocument) > 0){
|
||||
foreach ($rows_nonlabdocument as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-document-nonlab/".$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
|
||||
if($debug == 'Y'){
|
||||
print_r($rows_nonlabdocument);
|
||||
exit;
|
||||
foreach ($list_rpt as $key => $value) {
|
||||
echo "<a href='".$value."' target='_blank'>".$value."</a><br>";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
//echo json_encode($list_rpt);
|
||||
//exit;
|
||||
//print_r($list_rpt);
|
||||
//exit;
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
|
||||
$jsonData = json_encode($merge_input);
|
||||
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $lab_number . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function get_list_patient_rpt_email($orderHeaderID, $dob = "",$debug='N')
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
IFNULL(mp.M_PatientNIP, '') AS M_PatientNIP,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID
|
||||
AND mp.M_PatientIsActive = 'Y'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$nip = "";
|
||||
$lab = "";
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$nip = $value["M_PatientNIP"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_history_portal.rptdesign&__format=pdf&PID={$value["M_PatientID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY so_id
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = [];
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
$kebugaran = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
//print_r($rows_rpt);
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if ($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_portal.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Treadmill') {
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if (count($rows_attachment) > 0) {
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/' . $value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear_history_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg_2_annual_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
|
||||
if ($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0) {
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
$file_cover = "rpt_mcu_resume_cover_portal";
|
||||
|
||||
$sql = "SELECT M_CoverRpt as file_cover, M_CoverRptLogo as file_logo
|
||||
FROM t_orderheader
|
||||
JOIN mgm_cover ON T_OrderHeaderMgm_McuID = Mgm_CoverMgm_McuID AND Mgm_CoverIsActive = 'Y'
|
||||
JOIN m_cover ON Mgm_CoverM_CoverCode = M_CoverCode AND M_CoverIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$qry_cover = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_cover) {
|
||||
$row_cover = $qry_cover->result_array();
|
||||
if (count($row_cover) > 0) {
|
||||
$file_cover = $row_cover[0]['file_logo'];
|
||||
}
|
||||
}
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_portal.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/" . $file_cover . ".rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$additional = "";
|
||||
if ($fisik == "") {
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
//print_r($rows_addtional);
|
||||
if (count($rows_addtional) > 0) {
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata_history_portal.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID NOT IN (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND T_NonlabDocumentIsActive = 'Y'
|
||||
GROUP BY T_SamplingSoID";
|
||||
$qry_nonlabdocument = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_nonlabdocument) {
|
||||
$rows_nonlabdocument = $qry_nonlabdocument->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get nonlabdocument", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://devcpone.aplikasi.web.id";
|
||||
$prefix = "https://" . $_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if (count($attachments) > 0) {
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-files/" . $value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if(count($rontgen) > 0){
|
||||
foreach ($rontgen as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
/*if ($usg_abdomen != "") {
|
||||
$list_rpt[] = $prefix . $usg_abdomen;
|
||||
}*/
|
||||
if (count($usg) > 0) {
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if (count($treadmill_attachment) > 0) {
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "") {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
if(count($rows_nonlabdocument) > 0){
|
||||
foreach ($rows_nonlabdocument as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-document-nonlab/".$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
|
||||
if($debug == 'Y'){
|
||||
print_r($rows_nonlabdocument);
|
||||
exit;
|
||||
foreach ($list_rpt as $key => $value) {
|
||||
echo "<a href='".$value."' target='_blank'>".$value."</a><br>";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
//echo json_encode($list_rpt);
|
||||
// print_r($list_rpt);
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
if ($dob != "") {
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt,
|
||||
"dob" => $dob
|
||||
);
|
||||
}
|
||||
$jsonData = json_encode($merge_input);
|
||||
|
||||
// $jsonDebug = json_encode($merge_input, JSON_PRETTY_PRINT);
|
||||
|
||||
// echo '<pre>' . htmlspecialchars($jsonDebug) . '</pre>';
|
||||
// exit;
|
||||
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $nip . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt(
|
||||
$ch,
|
||||
CURLOPT_HTTPHEADER,
|
||||
array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data)
|
||||
)
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
440
application/controllers/tools/Listrptpatienttahunan.php
Normal file
440
application/controllers/tools/Listrptpatienttahunan.php
Normal file
@@ -0,0 +1,440 @@
|
||||
<?php
|
||||
class Listrptpatienttahunan extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Listing Report Patient API";
|
||||
}
|
||||
|
||||
function get_list_patient_rpt($orderHeaderID,$timestamp='',$tanpa_kesimpulan='N',$debug='N')
|
||||
{
|
||||
try {
|
||||
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$lab = "";
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
from t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID AND mp.M_PatientIsActive = 'Y'
|
||||
JOIN t_orderdetail ON toh.T_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND Group_ResultName = 'LAB'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'
|
||||
LIMIT 1";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
if($row && count($row) > 0){
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&PID={$value["M_PatientID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$lab = "";
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY so_id
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = array();
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
$kebugaran = '';
|
||||
|
||||
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_v2.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_xray.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Treadmill'){
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if(count($rows_attachment) > 0){
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/'.$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['group_name'] == 'USG' )
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0){
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
if($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
$file_cover = "rpt_mcu_resume_cover";
|
||||
|
||||
$sql = "SELECT M_CoverRpt as file_cover, M_CoverRptLogo as file_logo
|
||||
FROM t_orderheader
|
||||
JOIN mgm_cover ON T_OrderHeaderMgm_McuID = Mgm_CoverMgm_McuID AND Mgm_CoverIsActive = 'Y'
|
||||
JOIN m_cover ON Mgm_CoverM_CoverCode = M_CoverCode AND M_CoverIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$qry_cover = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_cover) {
|
||||
$row_cover = $qry_cover->result_array();
|
||||
if(count($row_cover) > 0){
|
||||
$file_cover = $row_cover[0]['file_cover'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_v2.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/".$file_cover.".rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$additional = "";
|
||||
if($fisik == ""){
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
//print_r($rows_addtional);
|
||||
if(count($rows_addtional) > 0){
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata_portal.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID NOT IN (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND T_NonlabDocumentIsActive = 'Y'
|
||||
GROUP BY T_SamplingSoID";
|
||||
$qry_nonlabdocument = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_nonlabdocument) {
|
||||
$rows_nonlabdocument = $qry_nonlabdocument->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get nonlabdocument", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$prefix = "http://localhost";
|
||||
$prefix = "https://".$_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if(count($attachments) > 0){
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix."/one-media/one-files/".$value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if(count($rontgen) > 0){
|
||||
foreach ($rontgen as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
/*if ($usg_abdomen != "") {
|
||||
$list_rpt[] = $prefix . $usg_abdomen;
|
||||
}*/
|
||||
if(count($usg) > 0){
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if(count($treadmill_attachment) > 0){
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "" && $tanpa_kesimpulan == "N") {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
if(count($rows_nonlabdocument) > 0){
|
||||
foreach ($rows_nonlabdocument as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-document-nonlab/".$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
|
||||
//echo json_encode($list_rpt);
|
||||
//print_r($list_rpt);
|
||||
//exit;
|
||||
|
||||
if($debug == 'Y'){
|
||||
foreach ($list_rpt as $key => $value) {
|
||||
echo "<a href='".$value."' target='_blank'>".$value."</a><br>";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
$jsonData = json_encode($merge_input);
|
||||
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://".$_SERVER['SERVER_NAME']."/one-api/tools/merge_pdf/merge";
|
||||
//echo $target_pdf ;
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $lab_number . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt(
|
||||
$ch,
|
||||
CURLOPT_HTTPHEADER,
|
||||
array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data)
|
||||
)
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
442
application/controllers/tools/Listrptpatienttahunaneng.php
Normal file
442
application/controllers/tools/Listrptpatienttahunaneng.php
Normal file
@@ -0,0 +1,442 @@
|
||||
<?php
|
||||
class Listrptpatienttahunaneng extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Listing Report Patient API";
|
||||
}
|
||||
|
||||
function get_list_patient_rpt($orderHeaderID,$timestamp='',$tanpa_kesimpulan='N',$debug='N')
|
||||
{
|
||||
try {
|
||||
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$lab = "";
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
from t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID AND mp.M_PatientIsActive = 'Y'
|
||||
JOIN t_orderdetail ON toh.T_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND Group_ResultName = 'LAB'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'
|
||||
LIMIT 1";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
if($row && count($row) > 0){
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_eng.rptdesign&__format=pdf&PID={$value["M_PatientID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$lab = "";
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_eng.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY so_id
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = [];
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
$kebugaran = '';
|
||||
|
||||
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_eng.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_xray_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Treadmill'){
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y' ";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if(count($rows_attachment) > 0){
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/'.$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear_eng.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro_eng.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0){
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
if($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
$file_cover = "rpt_mcu_resume_cover_eng";
|
||||
|
||||
$sql = "SELECT M_CoverRpt as file_cover, M_CoverRptLogo as file_logo, M_CoverRptEng as file_eng
|
||||
FROM t_orderheader
|
||||
JOIN mgm_cover ON T_OrderHeaderMgm_McuID = Mgm_CoverMgm_McuID AND Mgm_CoverIsActive = 'Y'
|
||||
JOIN m_cover ON Mgm_CoverM_CoverCode = M_CoverCode AND M_CoverIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$qry_cover = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_cover) {
|
||||
$row_cover = $qry_cover->result_array();
|
||||
if(count($row_cover) > 0){
|
||||
$file_cover = $row_cover[0]['file_eng'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_v2_eng.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/".$file_cover.".rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$additional = "";
|
||||
if($fisik == ""){
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
//print_r($rows_addtional);
|
||||
if(count($rows_addtional) > 0){
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata_portal.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID NOT IN (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND T_NonlabDocumentIsActive = 'Y'
|
||||
GROUP BY T_SamplingSoID";
|
||||
$qry_nonlabdocument = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_nonlabdocument) {
|
||||
$rows_nonlabdocument = $qry_nonlabdocument->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get nonlabdocument", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$prefix = "http://localhost";
|
||||
$prefix = "https://".$_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if(count($attachments) > 0){
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix."/one-media/one-files/".$value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if(count($rontgen) > 0){
|
||||
foreach ($rontgen as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
/*if ($usg_abdomen != "") {
|
||||
$list_rpt[] = $prefix . $usg_abdomen;
|
||||
}*/
|
||||
if(count($usg) > 0){
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if(count($treadmill_attachment) > 0){
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "" && $tanpa_kesimpulan == "N") {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
if(count($rows_nonlabdocument) > 0){
|
||||
foreach ($rows_nonlabdocument as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-document-nonlab/".$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
|
||||
//echo json_encode($list_rpt);
|
||||
//print_r($list_rpt);
|
||||
//exit;
|
||||
|
||||
if($debug == 'Y'){
|
||||
print_r($rows_nonlabdocument);
|
||||
exit;
|
||||
foreach ($list_rpt as $key => $value) {
|
||||
echo "<a href='".$value."' target='_blank'>".$value."</a><br>";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
$jsonData = json_encode($merge_input);
|
||||
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://".$_SERVER['SERVER_NAME']."/one-api/tools/merge_pdf/merge";
|
||||
//echo $target_pdf ;
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $lab_number . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt(
|
||||
$ch,
|
||||
CURLOPT_HTTPHEADER,
|
||||
array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data)
|
||||
)
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
926
application/controllers/tools/Listrptpatienttahunanportal.php
Normal file
926
application/controllers/tools/Listrptpatienttahunanportal.php
Normal file
@@ -0,0 +1,926 @@
|
||||
<?php
|
||||
class Listrptpatienttahunanportal extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Listing Report Patient API";
|
||||
}
|
||||
|
||||
function get_list_patient_rpt($orderHeaderID, $timestamp = '', $tanpa_kesimpulan = 'N',$debug='N')
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$lab = "";
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
from t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID AND mp.M_PatientIsActive = 'Y'
|
||||
JOIN t_orderdetail ON toh.T_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND Group_ResultName = 'LAB'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'
|
||||
LIMIT 1";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
if ($row && count($row) > 0) {
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_portal.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY so_id
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = [];
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
//print_r($rows_rpt);
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if ($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_v2_portal.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_xray_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Treadmill'){
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if(count($rows_attachment) > 0){
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/'.$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0) {
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
if($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
$file_cover = "rpt_mcu_resume_cover_portal";
|
||||
|
||||
$sql = "SELECT M_CoverRpt as file_cover, M_CoverRptLogo as file_logo
|
||||
FROM t_orderheader
|
||||
JOIN mgm_cover ON T_OrderHeaderMgm_McuID = Mgm_CoverMgm_McuID AND Mgm_CoverIsActive = 'Y'
|
||||
JOIN m_cover ON Mgm_CoverM_CoverCode = M_CoverCode AND M_CoverIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$qry_cover = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_cover) {
|
||||
$row_cover = $qry_cover->result_array();
|
||||
if(count($row_cover) > 0){
|
||||
$file_cover = $row_cover[0]['file_logo'];
|
||||
}
|
||||
}
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_v2_portal.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/".$file_cover.".rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$additional = "";
|
||||
if ($fisik == "") {
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
//print_r($rows_addtional);
|
||||
if (count($rows_addtional) > 0) {
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata_portal.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID NOT IN (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND T_NonlabDocumentIsActive = 'Y'
|
||||
GROUP BY T_SamplingSoID";
|
||||
$qry_nonlabdocument = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_nonlabdocument) {
|
||||
$rows_nonlabdocument = $qry_nonlabdocument->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get nonlabdocument", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://devcpone.aplikasi.web.id";
|
||||
$prefix = "https://" . $_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if (count($attachments) > 0) {
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-files/" . $value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if(count($rontgen) > 0){
|
||||
foreach ($rontgen as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
/*if ($usg_abdomen != "") {
|
||||
$list_rpt[] = $prefix . $usg_abdomen;
|
||||
}*/
|
||||
if(count($usg) > 0){
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if(count($treadmill_attachment) > 0){
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "" && $tanpa_kesimpulan == 'N') {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
if(count($rows_nonlabdocument) > 0){
|
||||
foreach ($rows_nonlabdocument as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-document-nonlab/".$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
|
||||
//echo json_encode($list_rpt);
|
||||
//print_r($list_rpt);
|
||||
//exit;
|
||||
|
||||
if($debug == 'Y'){
|
||||
print_r($rows_nonlabdocument);
|
||||
exit;
|
||||
foreach ($list_rpt as $key => $value) {
|
||||
echo "<a href='".$value."' target='_blank'>".$value."</a><br>";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt,
|
||||
"debug" => 0,
|
||||
"auto_repair" => 1,
|
||||
"skip_on_error" => 0
|
||||
);
|
||||
// if ($dob != "") {
|
||||
// $merge_input = array(
|
||||
// "output" => "test.pdf",
|
||||
// "input" => $list_rpt,
|
||||
// "dob" => $dob
|
||||
// );
|
||||
// }
|
||||
$jsonData = json_encode($merge_input);
|
||||
//print_r($jsonData); exit;
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
//print_r($response); exit;
|
||||
|
||||
$output_file_name = $lab_number . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function get_list_patient_rpt_email($orderHeaderID, $dob = "", $tanpa_kesimpulan = "N", $debug='N')
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
IFNULL(mp.M_PatientNIP, '') AS M_PatientNIP,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID
|
||||
AND mp.M_PatientIsActive = 'Y'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$nip = "";
|
||||
$lab = "";
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$nip = $value["M_PatientNIP"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_portal.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY so_id
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = [];
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
$kebugaran = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
//print_r($rows_rpt);
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if ($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_v2_portal.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_xray_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Treadmill'){
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if(count($rows_attachment) > 0){
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/'.$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
|
||||
if ($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0) {
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
if($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
|
||||
$additional = "";
|
||||
if ($fisik == "") {
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
if (count($rows_addtional) > 0) {
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
$file_cover = "rpt_mcu_resume_cover_portal";
|
||||
|
||||
$sql = "SELECT M_CoverRpt as file_cover, M_CoverRptLogo as file_logo
|
||||
FROM t_orderheader
|
||||
JOIN mgm_cover ON T_OrderHeaderMgm_McuID = Mgm_CoverMgm_McuID AND Mgm_CoverIsActive = 'Y'
|
||||
JOIN m_cover ON Mgm_CoverM_CoverCode = M_CoverCode AND M_CoverIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$qry_cover = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_cover) {
|
||||
$row_cover = $qry_cover->result_array();
|
||||
if(count($row_cover) > 0){
|
||||
$file_cover = $row_cover[0]['file_logo'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_v2_portal.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/".$file_cover.".rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$sql_nonlabdocument = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID NOT IN (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND T_NonlabDocumentIsActive = 'Y'
|
||||
GROUP BY T_SamplingSoID";
|
||||
$qry_nonlabdocument = $this->db->query($sql_nonlabdocument, [$orderHeaderID]);
|
||||
if ($qry_nonlabdocument) {
|
||||
$rows_nonlabdocument = $qry_nonlabdocument->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get nonlabdocument", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://devcpone.aplikasi.web.id";
|
||||
$prefix = "https://" . $_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if (count($attachments) > 0) {
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-files/" . $value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if(count($rontgen) > 0){
|
||||
foreach ($rontgen as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
/*if ($usg_abdomen != "") {
|
||||
$list_rpt[] = $prefix . $usg_abdomen;
|
||||
}*/
|
||||
if(count($usg) > 0){
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if(count($treadmill_attachment) > 0){
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "" && $tanpa_kesimpulan == 'N') {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
if(count($rows_nonlabdocument) > 0){
|
||||
foreach ($rows_nonlabdocument as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-document-nonlab/".$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
|
||||
if($debug == 'Y'){
|
||||
print_r($rows_nonlabdocument);
|
||||
exit;
|
||||
foreach ($list_rpt as $key => $value) {
|
||||
echo "<a href='".$value."' target='_blank'>".$value."</a><br>";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
//print_r($list_rpt);
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
if ($dob != "") {
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt,
|
||||
"dob" => $dob
|
||||
);
|
||||
}
|
||||
$jsonData = json_encode($merge_input);
|
||||
// print_r($jsonData);
|
||||
// exit;
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $nip . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt(
|
||||
$ch,
|
||||
CURLOPT_HTTPHEADER,
|
||||
array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data)
|
||||
)
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
882
application/controllers/tools/Listrptpatienttahunanportalbg.php
Normal file
882
application/controllers/tools/Listrptpatienttahunanportalbg.php
Normal file
@@ -0,0 +1,882 @@
|
||||
<?php
|
||||
class Listrptpatienttahunanportalbg extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Listing Report Patient API";
|
||||
}
|
||||
|
||||
function get_list_patient_rpt($orderHeaderID, $background, $timestamp = '', $tanpa_kesimpulan = 'N',$debug='N')
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
if($background === "bgdflt"){
|
||||
$background = "";
|
||||
}
|
||||
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$lab = "";
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
from t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID AND mp.M_PatientIsActive = 'Y'
|
||||
JOIN t_orderdetail ON toh.T_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND Group_ResultName = 'LAB'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'
|
||||
LIMIT 1";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
if ($row && count($row) > 0) {
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test" . $background . "_portal.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY so_id
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = [];
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
//print_r($rows_rpt);
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if ($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_v2" . $background . "_portal.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_xray" . $background . "_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri" . $background . "_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri" . $background . "_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg" . $background . "_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Treadmill') {
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill" . $background . "_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if (count($rows_attachment) > 0) {
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/' . $value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear" . $background . "_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro" . $background . "_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg" . $background . "_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0) {
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds" . $background . "_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan" . $background . "_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
$file_cover = "rpt_mcu_resume_cover" . $background . "_portal";
|
||||
|
||||
$sql = "SELECT M_CoverRpt as file_cover, M_CoverRptLogo as file_logo
|
||||
FROM t_orderheader
|
||||
JOIN mgm_cover ON T_OrderHeaderMgm_McuID = Mgm_CoverMgm_McuID AND Mgm_CoverIsActive = 'Y'
|
||||
JOIN m_cover ON Mgm_CoverM_CoverCode = M_CoverCode AND M_CoverIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$qry_cover = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_cover) {
|
||||
$row_cover = $qry_cover->result_array();
|
||||
if (count($row_cover) > 0) {
|
||||
$file_cover = $row_cover[0]['file_logo'];
|
||||
|
||||
if (strpos($file_cover, '_portal') !== false) {
|
||||
$file_cover = str_replace('_portal', $background . '_portal', $file_cover);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_v2" . $background . "_portal.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/" . $file_cover . ".rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$additional = "";
|
||||
if ($fisik == "") {
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
//print_r($rows_addtional);
|
||||
if (count($rows_addtional) > 0) {
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata" . $background . "_portal.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://devcpone.aplikasi.web.id";
|
||||
$prefix = "https://" . $_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if (count($attachments) > 0) {
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-files/" . $value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if(count($rontgen) > 0){
|
||||
foreach ($rontgen as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
/*if ($usg_abdomen != "") {
|
||||
$list_rpt[] = $prefix . $usg_abdomen;
|
||||
}*/
|
||||
if (count($usg) > 0) {
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if (count($treadmill_attachment) > 0) {
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "" && $tanpa_kesimpulan == 'N') {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
if($debug == 'Y'){
|
||||
foreach ($list_rpt as $key => $value) {
|
||||
echo "<a href='".$value."' target='_blank'>".$value."</a><br>";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
//echo json_encode($list_rpt);
|
||||
//print_r($list_rpt);
|
||||
//exit;
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
// if ($dob != "") {
|
||||
// $merge_input = array(
|
||||
// "output" => "test.pdf",
|
||||
// "input" => $list_rpt,
|
||||
// "dob" => $dob
|
||||
// );
|
||||
// }
|
||||
$jsonData = json_encode($merge_input);
|
||||
// print_r($jsonData);
|
||||
// exit;
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $lab_number . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function get_list_patient_rpt_email($orderHeaderID, $dob = "", $tanpa_kesimpulan = "N", $debug='N')
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
IFNULL(mp.M_PatientNIP, '') AS M_PatientNIP,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID
|
||||
AND mp.M_PatientIsActive = 'Y'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$nip = "";
|
||||
$lab = "";
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$nip = $value["M_PatientNIP"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_portal.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY so_id
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = [];
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
$kebugaran = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
//print_r($rows_rpt);
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if ($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_v2_portal.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_xray_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Treadmill') {
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if (count($rows_attachment) > 0) {
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/' . $value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
|
||||
if ($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro_portal.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0) {
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
|
||||
$additional = "";
|
||||
if ($fisik == "") {
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
if (count($rows_addtional) > 0) {
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
$file_cover = "rpt_mcu_resume_cover_portal";
|
||||
|
||||
$sql = "SELECT M_CoverRpt as file_cover, M_CoverRptLogo as file_logo
|
||||
FROM t_orderheader
|
||||
JOIN mgm_cover ON T_OrderHeaderMgm_McuID = Mgm_CoverMgm_McuID AND Mgm_CoverIsActive = 'Y'
|
||||
JOIN m_cover ON Mgm_CoverM_CoverCode = M_CoverCode AND M_CoverIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$qry_cover = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_cover) {
|
||||
$row_cover = $qry_cover->result_array();
|
||||
if (count($row_cover) > 0) {
|
||||
$file_cover = $row_cover[0]['file_logo'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_v2_portal.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/" . $file_cover . ".rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://devcpone.aplikasi.web.id";
|
||||
$prefix = "https://" . $_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if (count($attachments) > 0) {
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-files/" . $value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if(count($rontgen) > 0){
|
||||
foreach ($rontgen as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
/*if ($usg_abdomen != "") {
|
||||
$list_rpt[] = $prefix . $usg_abdomen;
|
||||
}*/
|
||||
if (count($usg) > 0) {
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if (count($treadmill_attachment) > 0) {
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "" && $tanpa_kesimpulan == 'N') {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
if($debug == 'Y'){
|
||||
foreach ($list_rpt as $key => $value) {
|
||||
echo "<a href='".$value."' target='_blank'>".$value."</a><br>";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
//print_r($list_rpt);
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
if ($dob != "") {
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt,
|
||||
"dob" => $dob
|
||||
);
|
||||
}
|
||||
$jsonData = json_encode($merge_input);
|
||||
// print_r($jsonData);
|
||||
// exit;
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $nip . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt(
|
||||
$ch,
|
||||
CURLOPT_HTTPHEADER,
|
||||
array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data)
|
||||
)
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
919
application/controllers/tools/Listrptpatienttahunanportaleng.php
Normal file
919
application/controllers/tools/Listrptpatienttahunanportaleng.php
Normal file
@@ -0,0 +1,919 @@
|
||||
<?php
|
||||
class Listrptpatienttahunanportaleng extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Listing Report Patient API";
|
||||
}
|
||||
|
||||
function get_list_patient_rpt($orderHeaderID, $timestamp = '', $tanpa_kesimpulan = 'N', $debug='N')
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$lab = "";
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
from t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID AND mp.M_PatientIsActive = 'Y'
|
||||
JOIN t_orderdetail ON toh.T_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND Group_ResultName = 'LAB'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'
|
||||
LIMIT 1";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
if ($row && count($row) > 0) {
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_portal_eng.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY so_id
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = [];
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
//print_r($rows_rpt);
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if ($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_portal_eng.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_xray_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Treadmill'){
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y' ";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if(count($rows_attachment) > 0){
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/'.$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear_portal_eng.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro_portal_eng.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0) {
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
//if($value['rpt_name'] == 'Test Kebugaran')
|
||||
//$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
$file_cover = "rpt_mcu_resume_cover_portal_eng";
|
||||
|
||||
$sql = "SELECT M_CoverRpt as file_cover, M_CoverRptLogo as file_logo, M_CoverRptEngLogo as file_logo_eng
|
||||
FROM t_orderheader
|
||||
JOIN mgm_cover ON T_OrderHeaderMgm_McuID = Mgm_CoverMgm_McuID AND Mgm_CoverIsActive = 'Y'
|
||||
JOIN m_cover ON Mgm_CoverM_CoverCode = M_CoverCode AND M_CoverIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$qry_cover = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_cover) {
|
||||
$row_cover = $qry_cover->result_array();
|
||||
if(count($row_cover) > 0){
|
||||
$file_cover = $row_cover[0]['file_logo_eng'];
|
||||
}
|
||||
}
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_v2_portal_eng.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/".$file_cover.".rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$additional = "";
|
||||
if ($fisik == "") {
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
//print_r($rows_addtional);
|
||||
if (count($rows_addtional) > 0) {
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata_portal_eng.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$sql_nonlabdocument = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID NOT IN (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND T_NonlabDocumentIsActive = 'Y'
|
||||
GROUP BY T_SamplingSoID";
|
||||
$qry_nonlabdocument = $this->db->query($sql_nonlabdocument, [$orderHeaderID]);
|
||||
if ($qry_nonlabdocument) {
|
||||
$rows_nonlabdocument = $qry_nonlabdocument->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get nonlabdocument", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://devcpone.aplikasi.web.id";
|
||||
$prefix = "https://" . $_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if (count($attachments) > 0) {
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-files/" . $value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if(count($rontgen) > 0){
|
||||
foreach ($rontgen as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
/*if ($usg_abdomen != "") {
|
||||
$list_rpt[] = $prefix . $usg_abdomen;
|
||||
}*/
|
||||
if(count($usg) > 0){
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if(count($treadmill_attachment) > 0){
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kesimpulan_saran != "" && $tanpa_kesimpulan == 'N') {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
if(count($rows_nonlabdocument) > 0){
|
||||
foreach ($rows_nonlabdocument as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-document-nonlab/".$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
|
||||
if($debug == 'Y'){
|
||||
print_r($rows_nonlabdocument);
|
||||
exit;
|
||||
foreach ($list_rpt as $key => $value) {
|
||||
echo "<a href='".$value."' target='_blank'>".$value."</a><br>";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
//echo json_encode($list_rpt);
|
||||
//print_r($list_rpt);
|
||||
//exit;
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
// if ($dob != "") {
|
||||
// $merge_input = array(
|
||||
// "output" => "test.pdf",
|
||||
// "input" => $list_rpt,
|
||||
// "dob" => $dob
|
||||
// );
|
||||
// }
|
||||
$jsonData = json_encode($merge_input);
|
||||
//print_r($jsonData); exit;
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $lab_number . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function get_list_patient_rpt_email($orderHeaderID, $dob = "", $tanpa_kesimpulan = "N",$debug='N')
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
IFNULL(mp.M_PatientNIP, '') AS M_PatientNIP,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID
|
||||
AND mp.M_PatientIsActive = 'Y'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$nip = "";
|
||||
$lab = "";
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$nip = $value["M_PatientNIP"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_portal_eng.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY so_id
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = [];
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
$kebugaran = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
//print_r($rows_rpt);
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if ($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_portal_eng.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_xray_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Treadmill'){
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if(count($rows_attachment) > 0){
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/'.$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear_portal_eng.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
|
||||
if ($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro_portal_eng.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0) {
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
//if($value['rpt_name'] == 'Test Kebugaran')
|
||||
//$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
|
||||
$additional = "";
|
||||
if ($fisik == "") {
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
if (count($rows_addtional) > 0) {
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata_portal_eng.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
$file_cover = "rpt_mcu_resume_cover_portal_eng";
|
||||
|
||||
$sql = "SELECT M_CoverRpt as file_cover, M_CoverRptLogo as file_logo, M_CoverRptEngLogo as file_logo_eng
|
||||
FROM t_orderheader
|
||||
JOIN mgm_cover ON T_OrderHeaderMgm_McuID = Mgm_CoverMgm_McuID AND Mgm_CoverIsActive = 'Y'
|
||||
JOIN m_cover ON Mgm_CoverM_CoverCode = M_CoverCode AND M_CoverIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$qry_cover = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_cover) {
|
||||
$row_cover = $qry_cover->result_array();
|
||||
if(count($row_cover) > 0){
|
||||
$file_cover = $row_cover[0]['file_logo_eng'];
|
||||
}
|
||||
}
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_v2_portal.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/".$file_cover.".rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$sql_nonlabdocument = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID NOT IN (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND T_NonlabDocumentIsActive = 'Y'
|
||||
GROUP BY T_SamplingSoID";
|
||||
$qry_nonlabdocument = $this->db->query($sql_nonlabdocument, [$orderHeaderID]);
|
||||
if ($qry_nonlabdocument) {
|
||||
$rows_nonlabdocument = $qry_nonlabdocument->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get nonlabdocument", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://devcpone.aplikasi.web.id";
|
||||
$prefix = "https://" . $_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if (count($attachments) > 0) {
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-files/" . $value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if(count($rontgen) > 0){
|
||||
foreach ($rontgen as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
/*if ($usg_abdomen != "") {
|
||||
$list_rpt[] = $prefix . $usg_abdomen;
|
||||
}*/
|
||||
if(count($usg) > 0){
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if(count($treadmill_attachment) > 0){
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "" && $tanpa_kesimpulan == 'N') {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
if(count($rows_nonlabdocument) > 0){
|
||||
foreach ($rows_nonlabdocument as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-document-nonlab/".$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
|
||||
if($debug == 'Y'){
|
||||
print_r($rows_nonlabdocument);
|
||||
exit;
|
||||
foreach ($list_rpt as $key => $value) {
|
||||
echo "<a href='".$value."' target='_blank'>".$value."</a><br>";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
//echo json_encode($list_rpt);
|
||||
//print_r($list_rpt);
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
if ($dob != "") {
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt,
|
||||
"dob" => $dob
|
||||
);
|
||||
}
|
||||
$jsonData = json_encode($merge_input);
|
||||
// print_r($jsonData);
|
||||
// exit;
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $nip . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt(
|
||||
$ch,
|
||||
CURLOPT_HTTPHEADER,
|
||||
array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data)
|
||||
)
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,923 @@
|
||||
<?php
|
||||
class Listrptpatienttahunanportalengbg extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Listing Report Patient API";
|
||||
}
|
||||
|
||||
function get_list_patient_rpt($orderHeaderID, $background, $timestamp = '', $tanpa_kesimpulan = 'N', $debug='N')
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
if($background === "bgdflt"){
|
||||
$background = "";
|
||||
}
|
||||
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$lab = "";
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
from t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID AND mp.M_PatientIsActive = 'Y'
|
||||
JOIN t_orderdetail ON toh.T_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND Group_ResultName = 'LAB'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'
|
||||
LIMIT 1";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
if ($row && count($row) > 0) {
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test".$background."_portal_eng.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY so_id
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = [];
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
//print_r($rows_rpt);
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if ($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history".$background."_portal_eng.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_xray".$background."_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri".$background."_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri".$background."_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg".$background."_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Treadmill'){
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill".$background."_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if(count($rows_attachment) > 0){
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/'.$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear".$background."_portal_eng.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro".$background."_portal_eng.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg".$background."_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0) {
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds".$background."_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
//if($value['rpt_name'] == 'Test Kebugaran')
|
||||
//$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan".$background."_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
$file_cover = "rpt_mcu_resume_cover".$background."_portal_eng";
|
||||
|
||||
$sql = "SELECT M_CoverRpt as file_cover, M_CoverRptLogo as file_logo, M_CoverRptEngLogo as file_logo_eng
|
||||
FROM t_orderheader
|
||||
JOIN mgm_cover ON T_OrderHeaderMgm_McuID = Mgm_CoverMgm_McuID AND Mgm_CoverIsActive = 'Y'
|
||||
JOIN m_cover ON Mgm_CoverM_CoverCode = M_CoverCode AND M_CoverIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$qry_cover = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_cover) {
|
||||
$row_cover = $qry_cover->result_array();
|
||||
if(count($row_cover) > 0){
|
||||
$file_cover = $row_cover[0]['file_logo_eng'];
|
||||
if (strpos($file_cover, '_portal') !== false) {
|
||||
$file_cover = str_replace('_portal', $background . '_portal', $file_cover);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_v2".$background."_portal_eng.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/".$file_cover.".rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$additional = "";
|
||||
if ($fisik == "") {
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
//print_r($rows_addtional);
|
||||
if (count($rows_addtional) > 0) {
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata".$background."_portal_eng.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$sql_nonlabdocument = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID NOT IN (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND T_NonlabDocumentIsActive = 'Y'
|
||||
GROUP BY T_SamplingSoID";
|
||||
$qry_nonlabdocument = $this->db->query($sql_nonlabdocument, [$orderHeaderID]);
|
||||
if ($qry_nonlabdocument) {
|
||||
$rows_nonlabdocument = $qry_nonlabdocument->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get nonlabdocument", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://devcpone.aplikasi.web.id";
|
||||
$prefix = "https://" . $_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if (count($attachments) > 0) {
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-files/" . $value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if(count($rontgen) > 0){
|
||||
foreach ($rontgen as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
/*if ($usg_abdomen != "") {
|
||||
$list_rpt[] = $prefix . $usg_abdomen;
|
||||
}*/
|
||||
if(count($usg) > 0){
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if(count($treadmill_attachment) > 0){
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kesimpulan_saran != "" && $tanpa_kesimpulan == 'N') {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
if(count($rows_nonlabdocument) > 0){
|
||||
foreach ($rows_nonlabdocument as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-document-nonlab/".$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
|
||||
if($debug == 'Y'){
|
||||
print_r($rows_nonlabdocument);
|
||||
exit;
|
||||
foreach ($list_rpt as $key => $value) {
|
||||
echo "<a href='".$value."' target='_blank'>".$value."</a><br>";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
// echo json_encode($list_rpt);
|
||||
//print_r($list_rpt);
|
||||
// exit;
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
// if ($dob != "") {
|
||||
// $merge_input = array(
|
||||
// "output" => "test.pdf",
|
||||
// "input" => $list_rpt,
|
||||
// "dob" => $dob
|
||||
// );
|
||||
// }
|
||||
$jsonData = json_encode($merge_input);
|
||||
// print_r($jsonData); exit;
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $lab_number . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function get_list_patient_rpt_email($orderHeaderID, $dob = "", $tanpa_kesimpulan = "N", $debug='N')
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
IFNULL(mp.M_PatientNIP, '') AS M_PatientNIP,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID
|
||||
AND mp.M_PatientIsActive = 'Y'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$nip = "";
|
||||
$lab = "";
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$nip = $value["M_PatientNIP"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_portal_eng.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY so_id
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = [];
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
$kebugaran = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
//print_r($rows_rpt);
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if ($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_portal_eng.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_xray_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Treadmill'){
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if(count($rows_attachment) > 0){
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/'.$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear_portal_eng.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
|
||||
if ($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro_portal_eng.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0) {
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds_portal_eng.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
//if($value['rpt_name'] == 'Test Kebugaran')
|
||||
//$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan_portal.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
|
||||
$additional = "";
|
||||
if ($fisik == "") {
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
if (count($rows_addtional) > 0) {
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata_portal_eng.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
$file_cover = "rpt_mcu_resume_cover_portal_eng";
|
||||
|
||||
$sql = "SELECT M_CoverRpt as file_cover, M_CoverRptLogo as file_logo, M_CoverRptEngLogo as file_logo_eng
|
||||
FROM t_orderheader
|
||||
JOIN mgm_cover ON T_OrderHeaderMgm_McuID = Mgm_CoverMgm_McuID AND Mgm_CoverIsActive = 'Y'
|
||||
JOIN m_cover ON Mgm_CoverM_CoverCode = M_CoverCode AND M_CoverIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$qry_cover = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_cover) {
|
||||
$row_cover = $qry_cover->result_array();
|
||||
if(count($row_cover) > 0){
|
||||
$file_cover = $row_cover[0]['file_logo_eng'];
|
||||
}
|
||||
}
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_v2_portal.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/".$file_cover.".rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$sql_nonlabdocument = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID NOT IN (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND T_NonlabDocumentIsActive = 'Y'
|
||||
GROUP BY T_SamplingSoID";
|
||||
$qry_nonlabdocument = $this->db->query($sql_nonlabdocument, [$orderHeaderID]);
|
||||
if ($qry_nonlabdocument) {
|
||||
$rows_nonlabdocument = $qry_nonlabdocument->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get nonlabdocument", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://devcpone.aplikasi.web.id";
|
||||
$prefix = "https://" . $_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if (count($attachments) > 0) {
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-files/" . $value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if(count($rontgen) > 0){
|
||||
foreach ($rontgen as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
/*if ($usg_abdomen != "") {
|
||||
$list_rpt[] = $prefix . $usg_abdomen;
|
||||
}*/
|
||||
if(count($usg) > 0){
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if(count($treadmill_attachment) > 0){
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "" && $tanpa_kesimpulan == 'N') {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
if(count($rows_nonlabdocument) > 0){
|
||||
foreach ($rows_nonlabdocument as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-document-nonlab/".$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
|
||||
if($debug == 'Y'){
|
||||
print_r($rows_nonlabdocument);
|
||||
exit;
|
||||
foreach ($list_rpt as $key => $value) {
|
||||
echo "<a href='".$value."' target='_blank'>".$value."</a><br>";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
//echo json_encode($list_rpt);
|
||||
//print_r($list_rpt);
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
if ($dob != "") {
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt,
|
||||
"dob" => $dob
|
||||
);
|
||||
}
|
||||
$jsonData = json_encode($merge_input);
|
||||
// print_r($jsonData);
|
||||
// exit;
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $nip . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt(
|
||||
$ch,
|
||||
CURLOPT_HTTPHEADER,
|
||||
array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data)
|
||||
)
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,879 @@
|
||||
<?php
|
||||
class Listrptpatienttahunanportalprimaya extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Listing Report Patient API";
|
||||
}
|
||||
|
||||
function get_list_patient_rpt($orderHeaderID, $timestamp = '', $tanpa_kesimpulan = 'N', $debug='N')
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$lab = "";
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
from t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID AND mp.M_PatientIsActive = 'Y'
|
||||
JOIN t_orderdetail ON toh.T_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND Group_ResultName = 'LAB'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'
|
||||
LIMIT 1";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
if ($row && count($row) > 0) {
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_portal_primaya.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY so_id
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = [];
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
//print_r($rows_rpt);
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if ($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_v2_portal_primaya.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_xray_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Treadmill'){
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if(count($rows_attachment) > 0){
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/'.$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear_portal_primaya.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro_portal_primaya.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0) {
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
if($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_v2_portal_primaya.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/rpt_mcu_resume_cover_portal_primaya.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$additional = "";
|
||||
if ($fisik == "") {
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
//print_r($rows_addtional);
|
||||
if (count($rows_addtional) > 0) {
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata_portal_primaya.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$sql_nonlabdocument = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID NOT IN (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND T_NonlabDocumentIsActive = 'Y'
|
||||
GROUP BY T_SamplingSoID";
|
||||
$qry_nonlabdocument = $this->db->query($sql_nonlabdocument, [$orderHeaderID]);
|
||||
if ($qry_nonlabdocument) {
|
||||
$rows_nonlabdocument = $qry_nonlabdocument->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get nonlabdocument", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://devcpone.aplikasi.web.id";
|
||||
$prefix = "https://" . $_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if (count($attachments) > 0) {
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-files/" . $value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if(count($rontgen) > 0){
|
||||
foreach ($rontgen as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if(count($usg) > 0){
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if(count($treadmill_attachment) > 0){
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kesimpulan_saran != "" && $tanpa_kesimpulan == 'N') {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
if(count($rows_nonlabdocument) > 0){
|
||||
foreach ($rows_nonlabdocument as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-document-nonlab/".$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
|
||||
if($debug == 'Y'){
|
||||
print_r($rows_nonlabdocument);
|
||||
exit;
|
||||
foreach ($list_rpt as $key => $value) {
|
||||
echo "<a href='".$value."' target='_blank'>".$value."</a><br>";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
//echo json_encode($list_rpt);
|
||||
//print_r($list_rpt);
|
||||
//exit;
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
// if ($dob != "") {
|
||||
// $merge_input = array(
|
||||
// "output" => "test.pdf",
|
||||
// "input" => $list_rpt,
|
||||
// "dob" => $dob
|
||||
// );
|
||||
// }
|
||||
$jsonData = json_encode($merge_input);
|
||||
//print_r($jsonData); exit;
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $lab_number . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function get_list_patient_rpt_email($orderHeaderID, $dob = "", $tanpa_kesimpulan = "N", $debug='N')
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
IFNULL(mp.M_PatientNIP, '') AS M_PatientNIP,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID
|
||||
AND mp.M_PatientIsActive = 'Y'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$nip = "";
|
||||
$lab = "";
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$nip = $value["M_PatientNIP"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_portal_primaya.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY so_id
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = [];
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
$kebugaran = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
//print_r($rows_rpt);
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if ($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_v2_portal_primaya.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_xray_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Treadmill'){
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if(count($rows_attachment) > 0){
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/'.$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear_portal_primaya.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
|
||||
if ($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro_portal_primaya.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0) {
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
if($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
|
||||
$additional = "";
|
||||
if ($fisik == "") {
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
if (count($rows_addtional) > 0) {
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata_portal_primaya.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_v2_portal_primaya.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/rpt_mcu_resume_cover_portal_primaya.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$sql_nonlabdocument = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID NOT IN (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND T_NonlabDocumentIsActive = 'Y'
|
||||
GROUP BY T_SamplingSoID";
|
||||
$qry_nonlabdocument = $this->db->query($sql_nonlabdocument, [$orderHeaderID]);
|
||||
if ($qry_nonlabdocument) {
|
||||
$rows_nonlabdocument = $qry_nonlabdocument->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get nonlabdocument", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://devcpone.aplikasi.web.id";
|
||||
$prefix = "https://" . $_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if (count($attachments) > 0) {
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-files/" . $value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if(count($rontgen) > 0){
|
||||
foreach ($rontgen as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if(count($usg) > 0){
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if(count($treadmill_attachment) > 0){
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "" && $tanpa_kesimpulan == 'N') {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
if(count($rows_nonlabdocument) > 0){
|
||||
foreach ($rows_nonlabdocument as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-document-nonlab/".$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
|
||||
if($debug == 'Y'){
|
||||
print_r($rows_nonlabdocument);
|
||||
exit;
|
||||
foreach ($list_rpt as $key => $value) {
|
||||
echo "<a href='".$value."' target='_blank'>".$value."</a><br>";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
//echo json_encode($list_rpt);
|
||||
//print_r($list_rpt);
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
if ($dob != "") {
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt,
|
||||
"dob" => $dob
|
||||
);
|
||||
}
|
||||
$jsonData = json_encode($merge_input);
|
||||
// print_r($jsonData);
|
||||
// exit;
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $nip . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt(
|
||||
$ch,
|
||||
CURLOPT_HTTPHEADER,
|
||||
array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data)
|
||||
)
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,885 @@
|
||||
<?php
|
||||
class Listrptpatienttahunanportalprimayabg extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Listing Report Patient API";
|
||||
}
|
||||
|
||||
function get_list_patient_rpt($orderHeaderID, $background, $timestamp = '', $tanpa_kesimpulan = 'N', $debug = 'N')
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
if($background === "bgdflt"){
|
||||
$background = "";
|
||||
}
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$lab = "";
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
from t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID AND mp.M_PatientIsActive = 'Y'
|
||||
JOIN t_orderdetail ON toh.T_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND Group_ResultName = 'LAB'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'
|
||||
LIMIT 1";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
if ($row && count($row) > 0) {
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test".$background."_portal_primaya.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY so_id
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = [];
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
$kebugaran = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
//print_r($rows_rpt);
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if ($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_v2".$background."_portal_primaya.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_xray".$background."_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri".$background."_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri".$background."_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg".$background."_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Treadmill'){
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill".$background."_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if(count($rows_attachment) > 0){
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/'.$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear".$background."_portal_primaya.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro".$background."_portal_primaya.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg".$background."_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0) {
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds".$background."_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
if($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan".$background."_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_v2".$background."_portal_primaya.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/rpt_mcu_resume_cover".$background."_portal_primaya.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$additional = "";
|
||||
if ($fisik == "") {
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
//print_r($rows_addtional);
|
||||
if (count($rows_addtional) > 0) {
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata".$background."_portal_primaya.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$sql_nonlabdocument = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID NOT IN (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND T_NonlabDocumentIsActive = 'Y'
|
||||
GROUP BY T_SamplingSoID";
|
||||
$qry_nonlabdocument = $this->db->query($sql_nonlabdocument, [$orderHeaderID]);
|
||||
if ($qry_nonlabdocument) {
|
||||
$rows_nonlabdocument = $qry_nonlabdocument->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get nonlabdocument", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://devcpone.aplikasi.web.id";
|
||||
$prefix = "https://" . $_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if (count($attachments) > 0) {
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-files/" . $value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
|
||||
if(count($rontgen) > 0){
|
||||
foreach ($rontgen as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(count($usg) > 0){
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if(count($treadmill_attachment) > 0){
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kesimpulan_saran != "" && $tanpa_kesimpulan == 'N') {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
if(count($rows_nonlabdocument) > 0){
|
||||
foreach ($rows_nonlabdocument as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-document-nonlab/".$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
|
||||
if($debug == 'Y'){
|
||||
print_r($rows_nonlabdocument);
|
||||
exit;
|
||||
foreach ($list_rpt as $key => $value) {
|
||||
echo "<a href='".$value."' target='_blank'>".$value."</a><br>";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
//echo json_encode($list_rpt);
|
||||
//print_r($list_rpt);
|
||||
//exit;
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
// if ($dob != "") {
|
||||
// $merge_input = array(
|
||||
// "output" => "test.pdf",
|
||||
// "input" => $list_rpt,
|
||||
// "dob" => $dob
|
||||
// );
|
||||
// }
|
||||
$jsonData = json_encode($merge_input);
|
||||
// print_r($jsonData); exit;
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $lab_number . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function get_list_patient_rpt_email($orderHeaderID, $dob = "", $tanpa_kesimpulan = "N", $debug='N')
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
// $prm = $this->sys_input;
|
||||
|
||||
// $orderHeaderID = $prm["orderHeaderID"];
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
IFNULL(mp.M_PatientNIP, '') AS M_PatientNIP,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID
|
||||
AND mp.M_PatientIsActive = 'Y'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$nip = "";
|
||||
$lab = "";
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$nip = $value["M_PatientNIP"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_portal_primaya.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY so_id
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = [];
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
$kebugaran = "";
|
||||
|
||||
/*foreach ($rows_so as $key => $value) {
|
||||
switch (true) {
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Fisik Umum', 'Fisik Umum K3']):
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Thorax', 'Thorax PA']):
|
||||
$rontgen = "/birt/run?__report=report/one/lab/rpt_hasil_so_radiology_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Audiometri':
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case $value["So_ResultEntryNonlab_TemplateName"] === 'Spirometri':
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['EKG', 'ECG']):
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
case in_array($value["So_ResultEntryNonlab_TemplateName"], ['Default', 'Treadmill']):
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_2_annual.rptdesign&__format=pdf&PID={$value["So_ResultEntryID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
break;
|
||||
default:
|
||||
// Default case
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
//print_r($rows_rpt);
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if ($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_v2_portal_primaya.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_xray_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'Treadmill'){
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if(count($rows_attachment) > 0){
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/'.$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear_portal_primaya.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
|
||||
if ($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro_portal_primaya.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if ($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0) {
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
if($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan_portal_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
|
||||
$additional = "";
|
||||
if ($fisik == "") {
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
if (count($rows_addtional) > 0) {
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata_portal_primaya.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_v2_portal_primaya.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/rpt_mcu_resume_cover_portal_primaya.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$sql_nonlabdocument = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID NOT IN (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND T_NonlabDocumentIsActive = 'Y'
|
||||
GROUP BY T_SamplingSoID";
|
||||
$qry_nonlabdocument = $this->db->query($sql_nonlabdocument, [$orderHeaderID]);
|
||||
if ($qry_nonlabdocument) {
|
||||
$rows_nonlabdocument = $qry_nonlabdocument->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get nonlabdocument", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
// $prefix = "http://localhost";
|
||||
$prefix = "https://devcpone.aplikasi.web.id";
|
||||
$prefix = "https://" . $_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if (count($attachments) > 0) {
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-files/" . $value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if(count($rontgen) > 0){
|
||||
foreach ($rontgen as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if(count($usg) > 0){
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if(count($treadmill_attachment) > 0){
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "" && $tanpa_kesimpulan == 'N') {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
if(count($rows_nonlabdocument) > 0){
|
||||
foreach ($rows_nonlabdocument as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-document-nonlab/".$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
|
||||
if($debug == 'Y'){
|
||||
print_r($rows_nonlabdocument);
|
||||
exit;
|
||||
foreach ($list_rpt as $key => $value) {
|
||||
echo "<a href='".$value."' target='_blank'>".$value."</a><br>";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
//echo json_encode($list_rpt);
|
||||
//print_r($list_rpt);
|
||||
|
||||
/* list_rpt hardcoded */
|
||||
// $hard_rpt = [
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&__format=pdf&username=ADMIN&PID=131891",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131911&tm=1699347690090",
|
||||
// "https://devone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_not_print.rptdesign&__format=pdf&username=ADMIN&PID=131890&tm=1699347726767"
|
||||
// ];
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
if ($dob != "") {
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt,
|
||||
"dob" => $dob
|
||||
);
|
||||
}
|
||||
$jsonData = json_encode($merge_input);
|
||||
// print_r($jsonData);
|
||||
// exit;
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $nip . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt(
|
||||
$ch,
|
||||
CURLOPT_HTTPHEADER,
|
||||
array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data)
|
||||
)
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
421
application/controllers/tools/Listrptpatienttahunanprimaya.php
Normal file
421
application/controllers/tools/Listrptpatienttahunanprimaya.php
Normal file
@@ -0,0 +1,421 @@
|
||||
<?php
|
||||
class Listrptpatienttahunanprimaya extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Listing Report Patient API";
|
||||
}
|
||||
|
||||
function get_list_patient_rpt($orderHeaderID,$timestamp='',$tanpa_kesimpulan='N',$debug='N')
|
||||
{
|
||||
try {
|
||||
|
||||
$attachments = [];
|
||||
|
||||
$sql = "SELECT File_AttachmentID as fid, File_AttachmentFileName as fname
|
||||
FROM file_attachment
|
||||
JOIN t_orderheader ON T_OrderHeaderID = File_AttachmentT_OrderHeaderID
|
||||
WHERE
|
||||
File_AttachmentT_OrderHeaderID = ? AND File_AttachmentIsActive = 'Y' AND File_AttachmentIsFCI = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$attachments = $qry->result_array();
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$lab = "";
|
||||
$sql = "SELECT
|
||||
toh.T_OrderHeaderID,
|
||||
toh.T_OrderHeaderLabNumber,
|
||||
mp.M_PatientID,
|
||||
mp.M_PatientName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
from t_orderheader toh
|
||||
JOIN m_patient mp ON toh.T_OrderHeaderM_PatientID = mp.M_PatientID AND mp.M_PatientIsActive = 'Y'
|
||||
JOIN t_orderdetail ON toh.T_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND Group_ResultName = 'LAB'
|
||||
WHERE toh.T_OrderHeaderID = ? AND toh.T_OrderHeaderIsActive = 'Y'
|
||||
LIMIT 1";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$row = $qry->result_array();
|
||||
if($row && count($row) > 0){
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_primaya.rptdesign&__format=pdf&PID={$value["M_PatientID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("error get nomor lab dan nama pasien", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$lab_number = "";
|
||||
$patient_name = "";
|
||||
$lab = "";
|
||||
foreach ($row as $key => $value) {
|
||||
$lab_number = $value["T_OrderHeaderLabNumber"];
|
||||
$patient_name = $value["M_PatientName"];
|
||||
$lab = "/birt/run?__report=report/one/lab/rpt_test_primaya.rptdesign&__format=pdf&PID={$value["T_OrderHeaderID"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
## non-lab rpt
|
||||
$sql_so = "SELECT
|
||||
sre.So_ResultEntryID,
|
||||
sre.So_ResultEntryT_OrderHeaderID,
|
||||
sre.So_ResultEntryT_OrderDetailID,
|
||||
sre.So_ResultEntryNonlab_TemplateID,
|
||||
sre.So_ResultEntryNonlab_TemplateName,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail tdet
|
||||
JOIN t_test tt ON tdet.T_OrderDetailT_TestID = tt.T_TestID
|
||||
AND tt.T_TestIsActive = 'Y'
|
||||
JOIN so_resultentry sre ON sre.So_ResultEntryT_OrderDetailID = tdet.T_OrderDetailID
|
||||
AND sre.So_ResultEntryIsActive = 'Y'
|
||||
WHERE tdet.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND tdet.T_OrderDetailIsActive = 'Y'";
|
||||
$qry_so = $this->db->query($sql_so, [$orderHeaderID]);
|
||||
if ($qry_so) {
|
||||
//$rows_so = $qry_so->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get so result entry", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'N'
|
||||
LEFT JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT group_resultName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'N' AND Group_ResultName <> 'LAB' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY so_id
|
||||
UNION
|
||||
SELECT DISTINCT T_TestName as rpt_name,
|
||||
group_resultName as group_name,
|
||||
IFNULL(So_ResultEntryID,0) as so_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_id,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestName NOT IN ('Visus Mata','Buta Warna','Pemeriksaan Lapang Pandang')
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultID = Group_ResultDetailGroup_ResultID AND
|
||||
Group_ResultFlagPerTest = 'Y' AND Group_ResultFlagNonLab = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y' AND
|
||||
So_ResultEntryStatus = 'VAL1'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderHeaderID} AND Group_ResultName <> 'Tanpa Hasil' AND T_OrderDetailIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows_rpt = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get rpts", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
## nonlab pid = so result id
|
||||
$fisik = "";
|
||||
$rontgen = [];
|
||||
$ekg = "";
|
||||
$audiometri = "";
|
||||
$spirometri = "";
|
||||
$treadmill = "";
|
||||
$treadmill_attachment = array();
|
||||
$papsmear = "";
|
||||
$mikro = "";
|
||||
$usg = array();
|
||||
$sds = "";
|
||||
$kebugaran = '';
|
||||
|
||||
|
||||
foreach ($rows_rpt as $key => $value) {
|
||||
if($value['rpt_name'] == 'Pemeriksaan Fisik')
|
||||
$fisik = "/birt/run?__report=report/one/mcu/mcu_fisik_history_v2_primaya.rptdesign&__format=pdf&PType=fisik&PLang=1&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Rontgen')
|
||||
$rontgen[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_xray_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Audiometri')
|
||||
$audiometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_audiometri_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Spirometri')
|
||||
$spirometri = "/birt/run?__report=report/one/lab/rpt_hasil_so_spirometri_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'ECG')
|
||||
$ekg = "/birt/run?__report=report/one/lab/rpt_hasil_so_ecg_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Treadmill'){
|
||||
$treadmill = "/birt/run?__report=report/one/lab/rpt_hasil_so_treadmill_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
$sql = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID in (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND
|
||||
T_NonlabDocumentIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows_attachment = $qry->result_array();
|
||||
if(count($rows_attachment) > 0){
|
||||
foreach ($rows_attachment as $key => $value) {
|
||||
$treadmill_attachment[] = '/one-media/one-document-nonlab/'.$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($value['rpt_name'] == 'Papsmear')
|
||||
$papsmear = "/birt/run?__report=report/one/lab/rpt_test_papsmear_primaya.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'Mikro')
|
||||
$mikro = "/birt/run?__report=report/one/lab/rpt_test_mikro_primaya.rptdesign&__format=pdf&PID={$value["order_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['group_name'] == 'USG')
|
||||
$usg[] = "/birt/run?__report=report/one/lab/rpt_hasil_so_usg_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
|
||||
if($value['rpt_name'] == 'SDS' && intval($value["so_id"]) > 0){
|
||||
$sql_type = "SELECT So_ResultEntrySDSTypeValue as xtype
|
||||
FROM so_resultentrysds_type
|
||||
WHERE So_ResultEntrySDSTypeSo_ResultEntryID = ?
|
||||
AND So_ResultEntrySDSTypeIsActive = 'Y' LIMIT 1";
|
||||
$qry_type = $this->db->query($sql_type, [$value["so_id"]]);
|
||||
if ($qry_type) {
|
||||
//https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_hasil_so_sds.rptdesign&__format=pdf&username=hrdisuzu@gmail.com&PID=9196&PType=30&tm=240926151412
|
||||
$type_rpt = $qry_type->row()->xtype;
|
||||
$sds = "/birt/run?__report=report/one/lab/rpt_hasil_so_sds_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&PType={$type_rpt}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
}
|
||||
|
||||
if($value['rpt_name'] == 'Test Kebugaran')
|
||||
$kebugaran = "/birt/run?__report=report/one/lab/rpt_hasil_so_layanan_primaya.rptdesign&__format=pdf&PID={$value["so_id"]}&tm={$value["Datetime"]}&username=admin";
|
||||
}
|
||||
|
||||
$sql_resume = "SELECT
|
||||
Mcu_ResumeID,
|
||||
DATE_FORMAT(NOW(), '%y%m%d%H%i%s') AS Datetime
|
||||
FROM mcu_resume
|
||||
WHERE Mcu_ResumeT_OrderHeaderID = ?
|
||||
AND Mcu_ResumeIsActive = 'Y' AND Mcu_ResumeStatus = 'VAL'";
|
||||
$qry_resume = $this->db->query($sql_resume, [$orderHeaderID]);
|
||||
if ($qry_resume) {
|
||||
$row_resume = $qry_resume->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get resume id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$kesimpulan_saran = "";
|
||||
$cover_rpt = "";
|
||||
|
||||
|
||||
## resume ID
|
||||
foreach ($row_resume as $key => $value) {
|
||||
$kesimpulan_saran = "/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_v2_primaya.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
$cover_rpt = "/birt/run?__report=report/one/mcu/rpt_mcu_resume_cover_primaya.rptdesign&__format=pdf&username=admin&PID={$value["Mcu_ResumeID"]}&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
$additional = "";
|
||||
if($fisik == ""){
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_TestID IN (2571,2573,2573,3450,2572)
|
||||
LIMIT 1";
|
||||
$qry_additional = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry_additional) {
|
||||
$rows_addtional = $qry_additional->result_array();
|
||||
//print_r($rows_addtional);
|
||||
if(count($rows_addtional) > 0){
|
||||
$id_additional = $rows_addtional[0]['So_ResultEntryID'];
|
||||
$additional = "/birt/run?__report=report/one/mcu/mcu_fisik_ttbbmata_portal_primaya.rptdesign&__format=pdf&username=admin&PType=fisik&PID={$id_additional}&PLang=1&tm={$value["Datetime"]}";
|
||||
}
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("error get addtional", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$sql_nonlabdocument = "SELECT *
|
||||
FROM t_nonlabdocument
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_NonlabDocumentT_OrderHeaderID AND
|
||||
T_NonlabDocumentT_SamplingSoID = T_SamplingSoID AND T_SamplingSoIsActive = 'Y'
|
||||
JOIN t_test ON T_SamplingSoT_TestID = T_TestID AND T_TestID NOT IN (1651)
|
||||
WHERE T_NonlabDocumentT_OrderHeaderID = ? AND T_NonlabDocumentIsActive = 'Y'
|
||||
GROUP BY T_SamplingSoID";
|
||||
$qry_nonlabdocument = $this->db->query($sql_nonlabdocument, [$orderHeaderID]);
|
||||
if ($qry_nonlabdocument) {
|
||||
$rows_nonlabdocument = $qry_nonlabdocument->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("error get nonlabdocument", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$prefix = "http://localhost";
|
||||
$prefix = "https://".$_SERVER['SERVER_NAME'];
|
||||
$list_rpt = array();
|
||||
|
||||
if ($cover_rpt != "") {
|
||||
$list_rpt[] = $prefix . $cover_rpt;
|
||||
}
|
||||
if(count($attachments) > 0){
|
||||
foreach ($attachments as $key => $value) {
|
||||
$list_rpt[] = $prefix."/one-media/one-files/".$value['fname'];
|
||||
}
|
||||
}
|
||||
if ($fisik != "") {
|
||||
$list_rpt[] = $prefix . $fisik;
|
||||
}
|
||||
if(count($rontgen) > 0){
|
||||
foreach ($rontgen as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if(count($usg) > 0){
|
||||
foreach ($usg as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
if ($ekg != "") {
|
||||
$list_rpt[] = $prefix . $ekg;
|
||||
}
|
||||
if ($audiometri != "") {
|
||||
$list_rpt[] = $prefix . $audiometri;
|
||||
}
|
||||
if ($spirometri != "") {
|
||||
$list_rpt[] = $prefix . $spirometri;
|
||||
}
|
||||
if ($treadmill != "") {
|
||||
$list_rpt[] = $prefix . $treadmill;
|
||||
if(count($treadmill_attachment) > 0){
|
||||
foreach ($treadmill_attachment as $key => $value) {
|
||||
$list_rpt[] = $prefix . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sds != "") {
|
||||
$list_rpt[] = $prefix . $sds;
|
||||
}
|
||||
if ($kebugaran != "") {
|
||||
$list_rpt[] = $prefix . $kebugaran;
|
||||
}
|
||||
if ($kesimpulan_saran != "" && $tanpa_kesimpulan == "N") {
|
||||
$list_rpt[] = $prefix . $kesimpulan_saran;
|
||||
}
|
||||
if ($lab != "") {
|
||||
$list_rpt[] = $prefix . $lab;
|
||||
}
|
||||
if ($papsmear != "") {
|
||||
$list_rpt[] = $prefix . $papsmear;
|
||||
}
|
||||
if ($mikro != "") {
|
||||
$list_rpt[] = $prefix . $mikro;
|
||||
}
|
||||
|
||||
if ($additional != "") {
|
||||
$list_rpt[] = $prefix . $additional;
|
||||
}
|
||||
|
||||
if(count($rows_nonlabdocument) > 0){
|
||||
foreach ($rows_nonlabdocument as $key => $value) {
|
||||
$list_rpt[] = $prefix . "/one-media/one-document-nonlab/".$value['T_NonlabDocumentFile'];
|
||||
}
|
||||
}
|
||||
|
||||
if($debug == 'Y'){
|
||||
print_r($rows_nonlabdocument);
|
||||
exit;
|
||||
foreach ($list_rpt as $key => $value) {
|
||||
echo "<a href='".$value."' target='_blank'>".$value."</a><br>";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
//echo json_encode($list_rpt);
|
||||
//print_r($list_rpt);
|
||||
//exit;
|
||||
|
||||
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
$jsonData = json_encode($merge_input);
|
||||
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://".$_SERVER['SERVER_NAME']."/one-api/tools/merge_pdf/merge";
|
||||
//echo $target_pdf ;
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = $lab_number . "_" . str_replace(" ", "_", $patient_name) . ".pdf";
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
// $this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt(
|
||||
$ch,
|
||||
CURLOPT_HTTPHEADER,
|
||||
array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data)
|
||||
)
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
2152
application/controllers/tools/Mcu_chart.php
Normal file
2152
application/controllers/tools/Mcu_chart.php
Normal file
File diff suppressed because it is too large
Load Diff
2953
application/controllers/tools/Mcu_chart_gan.php
Normal file
2953
application/controllers/tools/Mcu_chart_gan.php
Normal file
File diff suppressed because it is too large
Load Diff
2709
application/controllers/tools/Mcu_chart_v2.php
Normal file
2709
application/controllers/tools/Mcu_chart_v2.php
Normal file
File diff suppressed because it is too large
Load Diff
2342
application/controllers/tools/Mcu_chart_v2_backup.php
Normal file
2342
application/controllers/tools/Mcu_chart_v2_backup.php
Normal file
File diff suppressed because it is too large
Load Diff
3075
application/controllers/tools/Mcu_chart_v3.php
Normal file
3075
application/controllers/tools/Mcu_chart_v3.php
Normal file
File diff suppressed because it is too large
Load Diff
887
application/controllers/tools/Mcu_chartgenerator.php
Normal file
887
application/controllers/tools/Mcu_chartgenerator.php
Normal file
@@ -0,0 +1,887 @@
|
||||
<?php
|
||||
|
||||
class Mcu_chartgenerator extends MY_Controller
|
||||
{
|
||||
var $url_renderer;
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->url_renderer = "http://localhost:3030/chart";
|
||||
}
|
||||
|
||||
function get_graph_image($id){
|
||||
$sql = "SELECT *
|
||||
FROM mcu_image_grafik
|
||||
WHERE
|
||||
Mcu_ImageGrafikID = ?";
|
||||
$qry = $this->db->query($sql,[$id]);
|
||||
$data_graph = $qry->row_array();
|
||||
|
||||
$option = json_decode($data_graph['Mcu_ImageGrafikJsonRender'],true);
|
||||
//print_r($option);
|
||||
|
||||
$config = ["config" => $option];
|
||||
$j_param = json_encode($config);
|
||||
header("Content-Type: image/png");
|
||||
echo $this->post($this->url_renderer, $j_param);
|
||||
|
||||
}
|
||||
|
||||
function render_graph_global($id){
|
||||
$graph_global = [];
|
||||
$sql = "SELECT *
|
||||
FROM mcu_image_grafik
|
||||
WHERE
|
||||
Mcu_ImageGrafikGroupMenu = 'GLOBAL' AND Mcu_ImageGrafikMgm_McuID = ? AND Mcu_ImageGrafikIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql,[$id]);
|
||||
$data_graph = $qry->result_array();
|
||||
$option_not_found = [
|
||||
"title" => [
|
||||
"text" => "Kelainan Global (10 Terbesar)",
|
||||
"show" => true
|
||||
],
|
||||
"graphic" => [
|
||||
"elements" => [
|
||||
[
|
||||
"type" => "text",
|
||||
"left" => "center",
|
||||
"top" => "middle",
|
||||
"style" => [
|
||||
"text" => "Data tidak ditemukan",
|
||||
"fontSize" => 18,
|
||||
"color" => "#42aaf5"
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
$option = [
|
||||
'title' => [
|
||||
"text" => "Kelainan Global (10 Terbesar)",
|
||||
"show" => true,
|
||||
'left' => 'center'
|
||||
],
|
||||
'dataset' => [
|
||||
'source' => []
|
||||
],
|
||||
'grid' => ['containLabel' => true],
|
||||
'xAxis' => ['name' => 'persen'],
|
||||
'yAxis' => ['type' => 'category'],
|
||||
'series' => [
|
||||
[
|
||||
'type' => 'bar',
|
||||
'encode' => [
|
||||
'x' => 'persen',
|
||||
'y' => 'kelainan'
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
$datasource = [];
|
||||
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM mcu_mapping_kelainangroupsummary
|
||||
JOIN mcu_kelainangroupsummary ON Mcu_Mapping_KeliananGroupSummaryMcu_KelainanGroupSummaryID = Mcu_KelainanGroupSummaryID
|
||||
WHERE
|
||||
Mcu_Mapping_KeliananGroupSummaryMgm_McuID = ? AND Mcu_Mapping_KeliananGroupSummaryIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$id]);
|
||||
$datas = $qry->result_array();
|
||||
//echo $this->db->last_query();
|
||||
foreach ($datas as $key => $value) {
|
||||
$sql = "CALL sp_get_data_graph_summary_report_xtotal(?,?)";
|
||||
//echo $sql;
|
||||
$query = $this->db->query($sql,[
|
||||
$id,
|
||||
$value['Mcu_KelainanGroupSummaryID']
|
||||
]);
|
||||
//echo $this->db->last_query();
|
||||
if ($query)
|
||||
{
|
||||
$rst = $query->result_array();
|
||||
$this->clean_mysqli_connection($this->db->conn_id);
|
||||
|
||||
$total_peserta = 0;
|
||||
$total = 0;
|
||||
$percentase = 0;
|
||||
if($rst){
|
||||
foreach ($rst as $k => $v) {
|
||||
$total_peserta = $total_peserta + $v['total_peserta'];
|
||||
$total = $total + $v['total'];
|
||||
}
|
||||
|
||||
|
||||
if(intval($total) > 0){
|
||||
$percentase = ($total/$total_peserta) * 100;
|
||||
$percentase = round($percentase,2);
|
||||
}
|
||||
|
||||
//echo $percentase;
|
||||
}
|
||||
|
||||
$datasource[] = [$percentase,$value['Mcu_KelainanGroupSummaryName']];
|
||||
// print_r($datasource);
|
||||
}
|
||||
}
|
||||
// print_r($datasource);
|
||||
$option['dataset']['source'] = $datasource;
|
||||
//echo json_encode($option);
|
||||
|
||||
if(count($data_graph) == 0){
|
||||
$sql = "INSERT INTO mcu_image_grafik(
|
||||
Mcu_ImageGrafikMgm_McuID,
|
||||
Mcu_ImageGrafikMcu_KelainanGroupSummaryID,
|
||||
Mcu_ImageGrafikGroupMenu,
|
||||
Mcu_ImageGrafikName,
|
||||
Mcu_ImageGrafikType,
|
||||
Mcu_ImageGrafikUseRest,
|
||||
Mcu_ImageGrafikRestLabel,
|
||||
Mcu_ImageGrafikJsonRender,
|
||||
Mcu_ImageGrafikJsonNotFound,
|
||||
Mcu_ImageGrafikCreated
|
||||
)
|
||||
VALUES(?,?,?,?,?,?,?,?,?,NOW())";
|
||||
$qry = $this->db->query($sql,[
|
||||
$id,
|
||||
0,
|
||||
'GLOBAL',
|
||||
"Kelainan Global ( 10 Besar )",
|
||||
'bar ',
|
||||
'Y',
|
||||
'Normal',
|
||||
json_encode($option),
|
||||
json_encode($option_not_found)
|
||||
]);
|
||||
}else{
|
||||
$sql = "UPDATE mcu_image_grafik SET
|
||||
Mcu_ImageGrafikJsonRender = ?
|
||||
WHERE
|
||||
Mcu_ImageGrafikID = ?";
|
||||
$qry = $this->db->query($sql,[
|
||||
json_encode($option),
|
||||
$data_graph[0]['Mcu_ImageGrafikID']
|
||||
]);
|
||||
}
|
||||
|
||||
//echo json_encode($option);
|
||||
return true;
|
||||
}
|
||||
|
||||
function render_graph_image($id){
|
||||
$sql = "SELECT *
|
||||
FROM mcu_image_grafik
|
||||
WHERE
|
||||
Mcu_ImageGrafikID = ?";
|
||||
$qry = $this->db->query($sql,[$id]);
|
||||
$data_graph = $qry->row_array();
|
||||
|
||||
$datas = [];
|
||||
$data_axis = [];
|
||||
$typeResult = "";
|
||||
if($data_graph['Mcu_ImageGrafikGroupMenu'] == 'PESERTA' && intval($data_graph['Mcu_ImageGrafikMcu_KelainanGroupSummaryID']) == 1){
|
||||
$sql = "SELECT
|
||||
COUNT(distinct(T_OrderHeaderID)) as peserta,
|
||||
COUNT( distinct(Mcu_PreregisterPatientsM_PatientID)) as total
|
||||
FROM mcu_preregister_patients
|
||||
LEFT JOIN t_orderheader ON Mcu_PreregisterPatientsT_OrderHeaderID = T_OrderHeaderID AND
|
||||
T_OrderHeaderIsActive = 'Y'
|
||||
WHERE
|
||||
Mcu_PreregisterPatientsMgm_McuID = ? AND
|
||||
Mcu_PreregisterPatientsIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql, [$data_graph['Mcu_ImageGrafikMgm_McuID']]);
|
||||
//echo $this->db->last_query();
|
||||
$data_peserta = $qry->row_array();
|
||||
|
||||
$peserta = $data_peserta['peserta'];
|
||||
$total = $data_peserta['total'];
|
||||
$belummcu = $total - $peserta;
|
||||
$datas[] = array('value' => $peserta ,'name' => $peserta." : Sudah MCU");
|
||||
$datas[] = array('value' => $belummcu ,'name' => $belummcu.' : Belum MCU');
|
||||
$data_axis[] = $this->splitString('Sudah MCU');
|
||||
$data_axis[] = $this->splitString('Belum MCU');
|
||||
}
|
||||
|
||||
if($data_graph['Mcu_ImageGrafikGroupMenu'] == 'PESERTA' && intval($data_graph['Mcu_ImageGrafikMcu_KelainanGroupSummaryID']) == 2){
|
||||
$sql = "SELECT IF(M_PatientGender = 'male','Laki-laki','Perempuan') as M_PatientGender,
|
||||
COUNT(T_OrderHeaderID) as Jumlah
|
||||
FROM t_orderheader
|
||||
LEFT JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID AND M_PatientIsActive = 'Y'
|
||||
WHERE T_OrderHeaderMgm_McuID = ? AND T_OrderHeaderIsActive = 'Y'
|
||||
GROUP BY M_PatientGender";
|
||||
|
||||
$qry = $this->db->query($sql, [$data_graph['Mcu_ImageGrafikMgm_McuID']]);
|
||||
//echo $this->db->last_query();
|
||||
$data_peserta = $qry->result_array();
|
||||
foreach ($data_peserta as $key => $vx) {
|
||||
$datas[] = array(
|
||||
"value" => $vx["Jumlah"],
|
||||
"name" => $vx['Jumlah']." : ".$vx["M_PatientGender"]
|
||||
);
|
||||
$data_axis[] = $this->splitString($vx["M_PatientGender"]);
|
||||
}
|
||||
//print_r($datas);
|
||||
}
|
||||
|
||||
if($data_graph['Mcu_ImageGrafikGroupMenu'] == 'PESERTA' && intval($data_graph['Mcu_ImageGrafikMcu_KelainanGroupSummaryID']) == 3){
|
||||
$sql = "SELECT
|
||||
CASE
|
||||
WHEN LEFT(T_OrderHeaderM_PatientAge,2) < '30' THEN '< 30 tahun'
|
||||
WHEN LEFT(T_OrderHeaderM_PatientAge,2) >= '30' AND left(T_OrderHeaderM_PatientAge,2) < '40' THEN '30 - 40 tahun'
|
||||
WHEN LEFT(T_OrderHeaderM_PatientAge,2) >= '40' AND left(T_OrderHeaderM_PatientAge,2) < '50' THEN '40 - < 50 tahun'
|
||||
WHEN LEFT(T_OrderHeaderM_PatientAge,2) >= '50' THEN '4. > 50 tahun' ELSE ''
|
||||
END AS umur,
|
||||
COUNT(T_OrderHeaderID) as total
|
||||
FROM t_orderheader
|
||||
LEFT JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID AND M_PatientIsActive = 'Y'
|
||||
WHERE t_orderheaderMgm_McuID = ? AND T_OrderHeaderIsActive = 'Y'
|
||||
GROUP BY
|
||||
CASE
|
||||
WHEN LEFT(T_OrderHeaderM_PatientAge,2) < '30' THEN '< 30 tahun'
|
||||
WHEN LEFT(T_OrderHeaderM_PatientAge,2) >= '30' AND left(T_OrderHeaderM_PatientAge,2) < '40' THEN '30 - 40 tahun'
|
||||
WHEN LEFT(T_OrderHeaderM_PatientAge,2) >= '40' AND left(T_OrderHeaderM_PatientAge,2) < '50' THEN '40 - 50 tahun'
|
||||
WHEN LEFT(T_OrderHeaderM_PatientAge,2) >= '50' THEN '> 50 tahun' ELSE ''
|
||||
END
|
||||
ORDER BY umur";
|
||||
|
||||
$qry = $this->db->query($sql, [$data_graph['Mcu_ImageGrafikMgm_McuID']]);
|
||||
//echo $this->db->last_query();
|
||||
$data_peserta = $qry->result_array();
|
||||
foreach ($data_peserta as $key => $vx) {
|
||||
$datas[] = array(
|
||||
"value" => $vx["total"],
|
||||
"name" => $vx['total']." : ".$vx["umur"]
|
||||
);
|
||||
$data_axis[] = $this->splitString($vx["umur"]);
|
||||
}
|
||||
//print_r($datas);
|
||||
}
|
||||
$typeResult = "";
|
||||
|
||||
$nodata = false;
|
||||
$option_pie_normal = "";
|
||||
if($data_graph['Mcu_ImageGrafikGroupMenu'] == 'SUMMARY'){
|
||||
$sql = "CALL sp_get_data_graph_summary_report(?,?)";
|
||||
//echo $sql;
|
||||
$query = $this->db->query($sql,[
|
||||
$data_graph['Mcu_ImageGrafikMgm_McuID'],
|
||||
$data_graph['Mcu_ImageGrafikMcu_KelainanGroupSummaryID']
|
||||
]);
|
||||
//echo $this->db->last_query();
|
||||
if ($query)
|
||||
{
|
||||
$rst = $query->result_array();
|
||||
$this->clean_mysqli_connection($this->db->conn_id);
|
||||
//print_r($rst);
|
||||
$total_all = 0;
|
||||
$total = 0;
|
||||
if($rst){
|
||||
foreach ($rst as $key => $value) {
|
||||
$typeResult = $value['type'];
|
||||
$total_all = floatval($value['total_peserta']);
|
||||
$total = floatval($total) + floatval($value["total"]);
|
||||
if($value["kelainan"] != 'No Data'){
|
||||
$datas[] = array(
|
||||
"value" => $value["total"],
|
||||
"name" => $value["total"]." : ".$this->splitString($value["kelainan"])
|
||||
);
|
||||
$data_axis[] = $this->splitString($value["kelainan"]);
|
||||
}else{
|
||||
$nodata = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if($data_graph['Mcu_ImageGrafikType'] == 'pie' && $data_graph['Mcu_ImageGrafikUseRest'] == 'Y'){
|
||||
$total_rest = $total_all - $total;
|
||||
$xname = $total_rest." : ".$data_graph['Mcu_ImageGrafikRestLabel'];
|
||||
|
||||
$datas[] = array("value" => $total_rest, "name" => $xname);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
//echo count($datas) ;
|
||||
//echo $data_graph['Mcu_ImageGrafikName'];
|
||||
|
||||
if(count($datas) > 0){
|
||||
|
||||
$option = json_decode($data_graph['Mcu_ImageGrafikJson'], true);
|
||||
$option['title']['text'] = $data_graph['Mcu_ImageGrafikName'];
|
||||
|
||||
if($data_graph['Mcu_ImageGrafikType'] == 'bar' ){
|
||||
$option['series'][0]['name'] = $data_graph['Mcu_ImageGrafikName'];
|
||||
$option['series'][0]['data'] = $datas;
|
||||
$option['xAxis']['data'] = $data_axis;
|
||||
}else{
|
||||
$option['series']['name'] = $data_graph['Mcu_ImageGrafikName'];
|
||||
$option['series']['data'] = $datas;
|
||||
}
|
||||
|
||||
if($nodata){
|
||||
$option = [
|
||||
"title" => [
|
||||
"text" => $data_graph['Mcu_ImageGrafikName'],
|
||||
'subtext' => '',
|
||||
"show" => true,
|
||||
'left' => 'center'
|
||||
],
|
||||
"tooltip" => [
|
||||
"trigger" => "item"
|
||||
],
|
||||
"legend" => [
|
||||
"top" => "5%",
|
||||
"left" => "center",
|
||||
"show" => false
|
||||
],
|
||||
"series" => [
|
||||
[
|
||||
"name" => $data_graph['Mcu_ImageGrafikName'],
|
||||
"type" => "pie",
|
||||
"radius" => ["40%", "70%"],
|
||||
"avoidLabelOverlap" => false,
|
||||
"label" => [
|
||||
"show" => true,
|
||||
"position" => "center"
|
||||
],
|
||||
"emphasis" => [
|
||||
"label" => [
|
||||
"show" => true,
|
||||
"fontSize" => 40,
|
||||
"fontWeight" => "bold"
|
||||
]
|
||||
],
|
||||
"labelLine" => [
|
||||
"show" => true
|
||||
],
|
||||
"data" => [
|
||||
['value' => 0,'name' => $data_graph['Mcu_ImageGrafikRestLabel']]
|
||||
]
|
||||
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
//print_r($option);
|
||||
//echo json_encode($option);
|
||||
}else{
|
||||
$option = json_decode($data_graph['Mcu_ImageGrafikJsonNotFound'], true);
|
||||
$option['title']['text'] = $data_graph['Mcu_ImageGrafikName'];
|
||||
//$option = json_decode($data_graph['Mcu_ImageGrafikJsonNotFound']);
|
||||
}
|
||||
|
||||
|
||||
$sql = "UPDATE mcu_image_grafik
|
||||
SET
|
||||
Mcu_ImageGrafikJsonRender = ?,
|
||||
Mcu_ImageGrafikGroupResult = ?
|
||||
WHERE
|
||||
Mcu_ImageGrafikID = ?";
|
||||
$qry = $this->db->query($sql,[
|
||||
json_encode($option),
|
||||
$typeResult,
|
||||
$id
|
||||
]);
|
||||
|
||||
//echo json_encode($option);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function gengraph_global(){
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["Mgm_McuID"];
|
||||
$this->render_graph_global($id);
|
||||
$result = array(
|
||||
"status" => "OK"
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
function generate_graph(){
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["Mgm_McuID"];
|
||||
$this->render_graph_all($id);
|
||||
}
|
||||
|
||||
function render_graph_all($id){
|
||||
$def_gen = $this->generate_default_graph($id);
|
||||
if($def_gen){
|
||||
$sql = "SELECT *
|
||||
FROM mcu_image_grafik
|
||||
WHERE
|
||||
Mcu_ImageGrafikMgm_McuID = ? AND Mcu_ImageGrafikIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql,[$id]);
|
||||
$datas = $qry->result_array();
|
||||
if($datas){
|
||||
foreach ($datas as $key => $value) {
|
||||
$this->render_graph_image($value['Mcu_ImageGrafikID']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"status" => "OK"
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function generate_default_graph($id)
|
||||
{
|
||||
$title = "";
|
||||
$param_not_found = [
|
||||
"title" => [
|
||||
"text" => $title,
|
||||
'subtext' => '',
|
||||
"show" => true,
|
||||
'left' => 'center'
|
||||
],
|
||||
"graphic" => [
|
||||
"elements" => [
|
||||
[
|
||||
"type" => "text",
|
||||
"left" => "center",
|
||||
"top" => "middle",
|
||||
"style" => [
|
||||
"text" => "Data tidak ditemukan",
|
||||
"fontSize" => 18,
|
||||
"color" => "#42aaf5"
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
$param = array(
|
||||
'title' => array(
|
||||
"text" => $title,
|
||||
'subtext' => '',
|
||||
"show" => true,
|
||||
'left' => 'center'
|
||||
),
|
||||
'tooltip' => array(
|
||||
'trigger' => 'item'
|
||||
),
|
||||
'legend' => array(
|
||||
'orient' => 'vertical',
|
||||
'left' => 'left',
|
||||
'show' => false
|
||||
),
|
||||
'series' => array(
|
||||
'name' => 'Access From',
|
||||
'type' => 'pie',
|
||||
'radius' => ['40%', '70%'],
|
||||
'labelLine' => [
|
||||
'length' => 30
|
||||
],
|
||||
'data' => []
|
||||
)
|
||||
);
|
||||
|
||||
$option_not_found = [
|
||||
"title" => [
|
||||
"text" => $title,
|
||||
'subtext' => '',
|
||||
"show" => true,
|
||||
'left' => 'center'
|
||||
],
|
||||
"graphic" => [
|
||||
"elements" => [
|
||||
[
|
||||
"type" => "text",
|
||||
"left" => "center",
|
||||
"top" => "middle",
|
||||
"style" => [
|
||||
"text" => "Data tidak ditemukan",
|
||||
"fontSize" => 18,
|
||||
"color" => "#42aaf5"
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
$option = [
|
||||
"title" => [
|
||||
"text" => $title,
|
||||
'subtext' => '',
|
||||
"show" => true,
|
||||
'left' => 'center'
|
||||
],
|
||||
"dataset" => [
|
||||
"source" => []
|
||||
],
|
||||
"grid" => [
|
||||
"containLabel" => true
|
||||
],
|
||||
"xAxis" => [
|
||||
"data" => [],
|
||||
"type" => "category",
|
||||
/*"axisLabel" => [
|
||||
"interval" => 0,
|
||||
"rotate" => 20
|
||||
]*/
|
||||
"axisLabel" => [
|
||||
"interval" => 0,
|
||||
"width" => 80,
|
||||
"rotate" => 20,
|
||||
"margin" => 20
|
||||
]
|
||||
],
|
||||
"yAxis" => [
|
||||
"type" => "value",
|
||||
"name" => "",
|
||||
"nameTextStyle" => [
|
||||
"align" => "right"
|
||||
],
|
||||
"nameGap" => 20
|
||||
],
|
||||
"visualMap" => [
|
||||
"orient" => "horizontal",
|
||||
"left" => "center",
|
||||
"min" => 0,
|
||||
"max" => count($data),
|
||||
"dimension" => 0,
|
||||
"show" => false,
|
||||
"inRange" => [
|
||||
"color" => ["#42aaf5", "#00eaf2", "#035bff"]
|
||||
]
|
||||
],
|
||||
"series" => [
|
||||
[
|
||||
"label" => [
|
||||
"position" => "inside",
|
||||
"show" => true,
|
||||
"formatter" => "{@[1]}"
|
||||
],
|
||||
"type" => "bar",
|
||||
"encode" => [
|
||||
"x" => "kelainan",
|
||||
"y" => "jumlah"
|
||||
]
|
||||
]
|
||||
],
|
||||
"tooltip" => [
|
||||
"trigger" => "axis",
|
||||
"axisPointer" => [
|
||||
"type" => "shadow"
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
$title = "Peserta MCU";
|
||||
$sql = "INSERT INTO mcu_image_grafik(
|
||||
Mcu_ImageGrafikMgm_McuID,
|
||||
Mcu_ImageGrafikMcu_KelainanGroupSummaryID,
|
||||
Mcu_ImageGrafikGroupMenu,
|
||||
Mcu_ImageGrafikName,
|
||||
Mcu_ImageGrafikType,
|
||||
Mcu_ImageGrafikUseRest,
|
||||
Mcu_ImageGrafikRestLabel,
|
||||
Mcu_ImageGrafikJson,
|
||||
Mcu_ImageGrafikJsonNotFound,
|
||||
Mcu_ImageGrafikCreated
|
||||
)
|
||||
VALUES(?,?,?,?,?,?,?,?,?,NOW())";
|
||||
$qry = $this->db->query($sql,[
|
||||
$id,
|
||||
1,
|
||||
'PESERTA',
|
||||
"Peserta MCU",
|
||||
'pie',
|
||||
'Y',
|
||||
'Normal',
|
||||
json_encode($param),
|
||||
json_encode($param_not_found)
|
||||
]);
|
||||
|
||||
$sql = "INSERT INTO mcu_image_grafik(
|
||||
Mcu_ImageGrafikMgm_McuID,
|
||||
Mcu_ImageGrafikMcu_KelainanGroupSummaryID,
|
||||
Mcu_ImageGrafikGroupMenu,
|
||||
Mcu_ImageGrafikName,
|
||||
Mcu_ImageGrafikType,
|
||||
Mcu_ImageGrafikUseRest,
|
||||
Mcu_ImageGrafikRestLabel,
|
||||
Mcu_ImageGrafikJson,
|
||||
Mcu_ImageGrafikJsonNotFound,
|
||||
Mcu_ImageGrafikCreated
|
||||
)
|
||||
VALUES(?,?,?,?,?,?,?,?,?,NOW())";
|
||||
$qry = $this->db->query($sql,[
|
||||
$id,
|
||||
1,
|
||||
'PESERTA',
|
||||
"Peserta MCU",
|
||||
'bar',
|
||||
'Y',
|
||||
'Normal',
|
||||
json_encode($option),
|
||||
json_encode($option_not_found)
|
||||
]);
|
||||
|
||||
$title = "Peserta MCU Berdasarkan Jenis Kelamin";
|
||||
$sql = "INSERT INTO mcu_image_grafik(
|
||||
Mcu_ImageGrafikMgm_McuID,
|
||||
Mcu_ImageGrafikMcu_KelainanGroupSummaryID,
|
||||
Mcu_ImageGrafikGroupMenu,
|
||||
Mcu_ImageGrafikName,
|
||||
Mcu_ImageGrafikType,
|
||||
Mcu_ImageGrafikUseRest,
|
||||
Mcu_ImageGrafikRestLabel,
|
||||
Mcu_ImageGrafikJson,
|
||||
Mcu_ImageGrafikJsonNotFound,
|
||||
Mcu_ImageGrafikCreated
|
||||
)
|
||||
VALUES(?,?,?,?,?,?,?,?,?,NOW())";
|
||||
$qry = $this->db->query($sql,[
|
||||
$id,
|
||||
2,
|
||||
'PESERTA',
|
||||
"Peserta MCU Berdasarkan Jenis Kelamin",
|
||||
'pie',
|
||||
'Y',
|
||||
'Normal',
|
||||
json_encode($param),
|
||||
json_encode($param_not_found)
|
||||
]);
|
||||
|
||||
$sql = "INSERT INTO mcu_image_grafik(
|
||||
Mcu_ImageGrafikMgm_McuID,
|
||||
Mcu_ImageGrafikMcu_KelainanGroupSummaryID,
|
||||
Mcu_ImageGrafikGroupMenu,
|
||||
Mcu_ImageGrafikName,
|
||||
Mcu_ImageGrafikType,
|
||||
Mcu_ImageGrafikUseRest,
|
||||
Mcu_ImageGrafikRestLabel,
|
||||
Mcu_ImageGrafikJson,
|
||||
Mcu_ImageGrafikJsonNotFound,
|
||||
Mcu_ImageGrafikCreated
|
||||
)
|
||||
VALUES(?,?,?,?,?,?,?,?,?,NOW())";
|
||||
$qry = $this->db->query($sql,[
|
||||
$id,
|
||||
2,
|
||||
'PESERTA',
|
||||
"Peserta MCU Berdasarkan Jenis Kelamin",
|
||||
'bar',
|
||||
'Y',
|
||||
'Normal',
|
||||
json_encode($option),
|
||||
json_encode($option_not_found)
|
||||
]);
|
||||
|
||||
$title = "Peserta MCU Berdasarkan Umur";
|
||||
$sql = "INSERT INTO mcu_image_grafik(
|
||||
Mcu_ImageGrafikMgm_McuID,
|
||||
Mcu_ImageGrafikMcu_KelainanGroupSummaryID,
|
||||
Mcu_ImageGrafikGroupMenu,
|
||||
Mcu_ImageGrafikName,
|
||||
Mcu_ImageGrafikType,
|
||||
Mcu_ImageGrafikUseRest,
|
||||
Mcu_ImageGrafikRestLabel,
|
||||
Mcu_ImageGrafikJson,
|
||||
Mcu_ImageGrafikJsonNotFound,
|
||||
Mcu_ImageGrafikCreated
|
||||
)
|
||||
VALUES(?,?,?,?,?,?,?,?,?,NOW())";
|
||||
$qry = $this->db->query($sql,[
|
||||
$id,
|
||||
3,
|
||||
'PESERTA',
|
||||
"Peserta MCU Berdasarkan Umur",
|
||||
'pie',
|
||||
'Y',
|
||||
'Normal',
|
||||
json_encode($param),
|
||||
json_encode($param_not_found)
|
||||
]);
|
||||
|
||||
$sql = "INSERT INTO mcu_image_grafik(
|
||||
Mcu_ImageGrafikMgm_McuID,
|
||||
Mcu_ImageGrafikMcu_KelainanGroupSummaryID,
|
||||
Mcu_ImageGrafikGroupMenu,
|
||||
Mcu_ImageGrafikName,
|
||||
Mcu_ImageGrafikType,
|
||||
Mcu_ImageGrafikUseRest,
|
||||
Mcu_ImageGrafikRestLabel,
|
||||
Mcu_ImageGrafikJson,
|
||||
Mcu_ImageGrafikJsonNotFound,
|
||||
Mcu_ImageGrafikCreated
|
||||
)
|
||||
VALUES(?,?,?,?,?,?,?,?,?,NOW())";
|
||||
$qry = $this->db->query($sql,[
|
||||
$id,
|
||||
3,
|
||||
'PESERTA',
|
||||
"Peserta MCU Berdasarkan Umur",
|
||||
'bar',
|
||||
'Y',
|
||||
'Normal',
|
||||
json_encode($option),
|
||||
json_encode($option_not_found)
|
||||
]);
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM mcu_kelainangroupsummary
|
||||
WHERE
|
||||
Mcu_KelainanGroupSummaryIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql);
|
||||
$rows = $qry->result_array();
|
||||
if($rows){
|
||||
foreach ($rows as $key => $value) {
|
||||
$title = $value['Mcu_KelainanGroupSummaryName'];
|
||||
$sql = "INSERT INTO mcu_image_grafik(
|
||||
Mcu_ImageGrafikMgm_McuID,
|
||||
Mcu_ImageGrafikMcu_KelainanGroupSummaryID,
|
||||
Mcu_ImageGrafikGroupMenu,
|
||||
Mcu_ImageGrafikName,
|
||||
Mcu_ImageGrafikType,
|
||||
Mcu_ImageGrafikUseRest,
|
||||
Mcu_ImageGrafikRestLabel,
|
||||
Mcu_ImageGrafikJson,
|
||||
Mcu_ImageGrafikJsonNotFound,
|
||||
Mcu_ImageGrafikCreated
|
||||
)
|
||||
VALUES(?,?,?,?,?,?,?,?,?,NOW())";
|
||||
$qry = $this->db->query($sql,[
|
||||
$id,
|
||||
$value['Mcu_KelainanGroupSummaryID'],
|
||||
'SUMMARY',
|
||||
$value['Mcu_KelainanGroupSummaryName'],
|
||||
'pie',
|
||||
'Y',
|
||||
'Normal',
|
||||
json_encode($param),
|
||||
json_encode($param_not_found)
|
||||
]);
|
||||
|
||||
$sql = "INSERT INTO mcu_image_grafik(
|
||||
Mcu_ImageGrafikMgm_McuID,
|
||||
Mcu_ImageGrafikMcu_KelainanGroupSummaryID,
|
||||
Mcu_ImageGrafikGroupMenu,
|
||||
Mcu_ImageGrafikName,
|
||||
Mcu_ImageGrafikType,
|
||||
Mcu_ImageGrafikUseRest,
|
||||
Mcu_ImageGrafikRestLabel,
|
||||
Mcu_ImageGrafikJson,
|
||||
Mcu_ImageGrafikJsonNotFound,
|
||||
Mcu_ImageGrafikCreated
|
||||
)
|
||||
VALUES(?,?,?,?,?,?,?,?,?,NOW())";
|
||||
$qry = $this->db->query($sql,[
|
||||
$id,
|
||||
$value['Mcu_KelainanGroupSummaryID'],
|
||||
'SUMMARY',
|
||||
$value['Mcu_KelainanGroupSummaryName'],
|
||||
'bar',
|
||||
'Y',
|
||||
'Normal',
|
||||
json_encode($option),
|
||||
json_encode($option_not_found)
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
//echo "selesai default render";
|
||||
}
|
||||
|
||||
function render($type, $id)
|
||||
{
|
||||
switch ($type) {
|
||||
case "mcu001":
|
||||
$this->mcu001($id);
|
||||
break;
|
||||
|
||||
case "mcu002":
|
||||
$this->mcu002($id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function splitString($string, $wordsPerLine = 2)
|
||||
{
|
||||
$words = explode(' ', $string);
|
||||
$lines = [];
|
||||
for ($i = 0; $i < count($words); $i += $wordsPerLine) {
|
||||
$lines[] = implode(' ', array_slice($words, $i, $wordsPerLine));
|
||||
}
|
||||
return implode("\n", $lines);
|
||||
}
|
||||
|
||||
function check_error($qry, $stage)
|
||||
{
|
||||
if (!$qry) {
|
||||
$errMsg = $stage . "<br/>" . $this->db->error()["messge"];
|
||||
print_r($errMsg);
|
||||
$this->chart_error($errMsg);
|
||||
}
|
||||
}
|
||||
|
||||
function chart_error($msg)
|
||||
{
|
||||
$param = array(
|
||||
'title' => array(
|
||||
'show' => true,
|
||||
'textStyle' => array(
|
||||
'color' => 'grey',
|
||||
'fontSize' => 20
|
||||
),
|
||||
'text' => $msg,
|
||||
'left' => 'center',
|
||||
'top' => 'center'
|
||||
),
|
||||
'xAxis' => array(
|
||||
'show' => false
|
||||
),
|
||||
'yAxis' => array(
|
||||
'show' => false
|
||||
),
|
||||
'series' => array()
|
||||
);
|
||||
header("Content-Type: image/png");
|
||||
$config = ["config" => $param];
|
||||
$j_param = json_encode($config);
|
||||
echo $this->post($this->url_renderer, $j_param);
|
||||
exit;
|
||||
}
|
||||
|
||||
function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, j120);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
"Content-Type: application/json",
|
||||
"Content-Length: " . strlen($data),
|
||||
]);
|
||||
$result = curl_exec($ch);
|
||||
if (curl_errno($ch) > 0) {
|
||||
return [
|
||||
"status" => "ERR",
|
||||
"message" => curl_error($ch),
|
||||
];
|
||||
}
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
if ($httpCode != 200) {
|
||||
return [
|
||||
"status" => "ERR",
|
||||
"message" => "Http Response : $httpCode",
|
||||
];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
876
application/controllers/tools/Mcu_chartgenerator.php--141124
Normal file
876
application/controllers/tools/Mcu_chartgenerator.php--141124
Normal file
@@ -0,0 +1,876 @@
|
||||
<?php
|
||||
|
||||
class Mcu_chartgenerator extends MY_Controller
|
||||
{
|
||||
var $url_renderer;
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->url_renderer = "http://localhost:3030/chart";
|
||||
}
|
||||
|
||||
function get_graph_image($id){
|
||||
$sql = "SELECT *
|
||||
FROM mcu_image_grafik
|
||||
WHERE
|
||||
Mcu_ImageGrafikID = ?";
|
||||
$qry = $this->db->query($sql,[$id]);
|
||||
$data_graph = $qry->row_array();
|
||||
|
||||
$option = json_decode($data_graph['Mcu_ImageGrafikJsonRender'],true);
|
||||
//print_r($option);
|
||||
|
||||
$config = ["config" => $option];
|
||||
$j_param = json_encode($config);
|
||||
header("Content-Type: image/png");
|
||||
echo $this->post($this->url_renderer, $j_param);
|
||||
|
||||
}
|
||||
|
||||
function render_graph_global($id){
|
||||
$graph_global = [];
|
||||
$sql = "SELECT *
|
||||
FROM mcu_image_grafik
|
||||
WHERE
|
||||
Mcu_ImageGrafikGroupMenu = 'GLOBAL' AND Mcu_ImageGrafikIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql);
|
||||
$data_graph = $qry->result_array();
|
||||
$option_not_found = [
|
||||
"title" => [
|
||||
"text" => "Kelainan Global (10 Terbesar)",
|
||||
"show" => true
|
||||
],
|
||||
"graphic" => [
|
||||
"elements" => [
|
||||
[
|
||||
"type" => "text",
|
||||
"left" => "center",
|
||||
"top" => "middle",
|
||||
"style" => [
|
||||
"text" => "Data tidak ditemukan",
|
||||
"fontSize" => 18,
|
||||
"color" => "#42aaf5"
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
$option = [
|
||||
'title' => [
|
||||
"text" => "Kelainan Global (10 Terbesar)",
|
||||
"show" => true,
|
||||
'left' => 'center'
|
||||
],
|
||||
'dataset' => [
|
||||
'source' => []
|
||||
],
|
||||
'grid' => ['containLabel' => true],
|
||||
'xAxis' => ['name' => 'persen'],
|
||||
'yAxis' => ['type' => 'category'],
|
||||
'series' => [
|
||||
[
|
||||
'type' => 'bar',
|
||||
'encode' => [
|
||||
'x' => 'persen',
|
||||
'y' => 'kelainan'
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
$datasource = [];
|
||||
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM mcu_mapping_kelainangroupsummary
|
||||
JOIN mcu_kelainangroupsummary ON Mcu_Mapping_KeliananGroupSummaryMcu_KelainanGroupSummaryID = Mcu_KelainanGroupSummaryID
|
||||
WHERE
|
||||
Mcu_Mapping_KeliananGroupSummaryMgm_McuID = ? AND Mcu_Mapping_KeliananGroupSummaryIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$id]);
|
||||
$datas = $qry->result_array();
|
||||
//echo $this->db->last_query();
|
||||
foreach ($datas as $key => $value) {
|
||||
$sql = "CALL sp_get_data_graph_summary_report_xtotal(?,?)";
|
||||
//echo $sql;
|
||||
$query = $this->db->query($sql,[
|
||||
$id,
|
||||
$value['Mcu_KelainanGroupSummaryID']
|
||||
]);
|
||||
//echo $this->db->last_query();
|
||||
if ($query)
|
||||
{
|
||||
$rst = $query->result_array();
|
||||
$this->clean_mysqli_connection($this->db->conn_id);
|
||||
|
||||
$total_peserta = 0;
|
||||
$total = 0;
|
||||
if($rst){
|
||||
foreach ($rst as $k => $v) {
|
||||
$total_peserta = $total_peserta + $v['total_peserta'];
|
||||
$total = $total + $v['total'];
|
||||
}
|
||||
|
||||
$percentase = ($total/$total_peserta) * 100;
|
||||
$percentase = round($percentase,2);
|
||||
//echo $percentase;
|
||||
}
|
||||
|
||||
$datasource[] = [$percentase,$value['Mcu_KelainanGroupSummaryName']];
|
||||
// print_r($datasource);
|
||||
}
|
||||
}
|
||||
// print_r($datasource);
|
||||
$option['dataset']['source'] = $datasource;
|
||||
//echo json_encode($option);
|
||||
|
||||
if(count($data_graph) == 0){
|
||||
$sql = "INSERT INTO mcu_image_grafik(
|
||||
Mcu_ImageGrafikMgm_McuID,
|
||||
Mcu_ImageGrafikMcu_KelainanGroupSummaryID,
|
||||
Mcu_ImageGrafikGroupMenu,
|
||||
Mcu_ImageGrafikName,
|
||||
Mcu_ImageGrafikType,
|
||||
Mcu_ImageGrafikUseRest,
|
||||
Mcu_ImageGrafikRestLabel,
|
||||
Mcu_ImageGrafikJsonRender,
|
||||
Mcu_ImageGrafikJsonNotFound,
|
||||
Mcu_ImageGrafikCreated
|
||||
)
|
||||
VALUES(?,?,?,?,?,?,?,?,?,NOW())";
|
||||
$qry = $this->db->query($sql,[
|
||||
$id,
|
||||
0,
|
||||
'GLOBAL',
|
||||
"Kelainan Global ( 10 Besar )",
|
||||
'bar ',
|
||||
'Y',
|
||||
'Normal',
|
||||
json_encode($option),
|
||||
json_encode($option_not_found)
|
||||
]);
|
||||
}else{
|
||||
$sql = "UPDATE mcu_image_grafik SET
|
||||
Mcu_ImageGrafikJsonRender = ?
|
||||
WHERE
|
||||
Mcu_ImageGrafikID = ?";
|
||||
$qry = $this->db->query($sql,[
|
||||
json_encode($option),
|
||||
$data_graph[0]['Mcu_ImageGrafikID']
|
||||
]);
|
||||
}
|
||||
|
||||
//echo json_encode($option);
|
||||
return true;
|
||||
}
|
||||
|
||||
function render_graph_image($id){
|
||||
$sql = "SELECT *
|
||||
FROM mcu_image_grafik
|
||||
WHERE
|
||||
Mcu_ImageGrafikID = ?";
|
||||
$qry = $this->db->query($sql,[$id]);
|
||||
$data_graph = $qry->row_array();
|
||||
|
||||
$datas = [];
|
||||
$typeResult = "";
|
||||
if($data_graph['Mcu_ImageGrafikGroupMenu'] == 'PESERTA' && intval($data_graph['Mcu_ImageGrafikMcu_KelainanGroupSummaryID']) == 1){
|
||||
$sql = "SELECT
|
||||
COUNT(distinct(T_OrderHeaderID)) as peserta,
|
||||
COUNT( distinct(Mcu_PreregisterPatientsM_PatientID)) as total
|
||||
FROM mcu_preregister_patients
|
||||
LEFT JOIN t_orderheader ON Mcu_PreregisterPatientsT_OrderHeaderID = T_OrderHeaderID AND
|
||||
T_OrderHeaderIsActive = 'Y'
|
||||
WHERE
|
||||
Mcu_PreregisterPatientsMgm_McuID = ? AND
|
||||
Mcu_PreregisterPatientsIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql, [$data_graph['Mcu_ImageGrafikMgm_McuID']]);
|
||||
//echo $this->db->last_query();
|
||||
$data_peserta = $qry->row_array();
|
||||
|
||||
$peserta = $data_peserta['peserta'];
|
||||
$total = $data_peserta['total'];
|
||||
$belummcu = $total - $peserta;
|
||||
$datas[] = array('value' => $peserta ,'name' => $peserta." : Sudah MCU");
|
||||
$datas[] = array('value' => $belummcu ,'name' => $belummcu.' : Belum MCU');
|
||||
}
|
||||
|
||||
if($data_graph['Mcu_ImageGrafikGroupMenu'] == 'PESERTA' && intval($data_graph['Mcu_ImageGrafikMcu_KelainanGroupSummaryID']) == 2){
|
||||
$sql = "SELECT IF(M_PatientGender = 'male','Laki-laki','Perempuan') as M_PatientGender,
|
||||
COUNT(T_OrderHeaderID) as Jumlah
|
||||
FROM t_orderheader
|
||||
LEFT JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID AND M_PatientIsActive = 'Y'
|
||||
WHERE T_OrderHeaderMgm_McuID = ? AND T_OrderHeaderIsActive = 'Y'
|
||||
GROUP BY M_PatientGender";
|
||||
|
||||
$qry = $this->db->query($sql, [$data_graph['Mcu_ImageGrafikMgm_McuID']]);
|
||||
//echo $this->db->last_query();
|
||||
$data_peserta = $qry->result_array();
|
||||
foreach ($data_peserta as $key => $vx) {
|
||||
$datas[] = array(
|
||||
"value" => $vx["Jumlah"],
|
||||
"name" => $vx['Jumlah']." : ".$vx["M_PatientGender"]
|
||||
);
|
||||
}
|
||||
//print_r($datas);
|
||||
}
|
||||
|
||||
if($data_graph['Mcu_ImageGrafikGroupMenu'] == 'PESERTA' && intval($data_graph['Mcu_ImageGrafikMcu_KelainanGroupSummaryID']) == 3){
|
||||
$sql = "SELECT
|
||||
CASE
|
||||
WHEN LEFT(T_OrderHeaderM_PatientAge,2) < '30' THEN '< 30 tahun'
|
||||
WHEN LEFT(T_OrderHeaderM_PatientAge,2) >= '30' AND left(T_OrderHeaderM_PatientAge,2) < '40' THEN '30 - 40 tahun'
|
||||
WHEN LEFT(T_OrderHeaderM_PatientAge,2) >= '40' AND left(T_OrderHeaderM_PatientAge,2) < '50' THEN '40 - < 50 tahun'
|
||||
WHEN LEFT(T_OrderHeaderM_PatientAge,2) >= '50' THEN '4. > 50 tahun' ELSE ''
|
||||
END AS umur,
|
||||
COUNT(T_OrderHeaderID) as total
|
||||
FROM t_orderheader
|
||||
LEFT JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID AND M_PatientIsActive = 'Y'
|
||||
WHERE t_orderheaderMgm_McuID = ? AND T_OrderHeaderIsActive = 'Y'
|
||||
GROUP BY
|
||||
CASE
|
||||
WHEN LEFT(T_OrderHeaderM_PatientAge,2) < '30' THEN '< 30 tahun'
|
||||
WHEN LEFT(T_OrderHeaderM_PatientAge,2) >= '30' AND left(T_OrderHeaderM_PatientAge,2) < '40' THEN '30 - 40 tahun'
|
||||
WHEN LEFT(T_OrderHeaderM_PatientAge,2) >= '40' AND left(T_OrderHeaderM_PatientAge,2) < '50' THEN '40 - 50 tahun'
|
||||
WHEN LEFT(T_OrderHeaderM_PatientAge,2) >= '50' THEN '> 50 tahun' ELSE ''
|
||||
END
|
||||
ORDER BY umur";
|
||||
|
||||
$qry = $this->db->query($sql, [$data_graph['Mcu_ImageGrafikMgm_McuID']]);
|
||||
//echo $this->db->last_query();
|
||||
$data_peserta = $qry->result_array();
|
||||
foreach ($data_peserta as $key => $vx) {
|
||||
$datas[] = array(
|
||||
"value" => $vx["total"],
|
||||
"name" => $vx['total']." : ".$vx["umur"]
|
||||
);
|
||||
}
|
||||
//print_r($datas);
|
||||
}
|
||||
$typeResult = "";
|
||||
$data_axis = [];
|
||||
$nodata = false;
|
||||
$option_pie_normal = "";
|
||||
if($data_graph['Mcu_ImageGrafikGroupMenu'] == 'SUMMARY'){
|
||||
$sql = "CALL sp_get_data_graph_summary_report(?,?)";
|
||||
//echo $sql;
|
||||
$query = $this->db->query($sql,[
|
||||
$data_graph['Mcu_ImageGrafikMgm_McuID'],
|
||||
$data_graph['Mcu_ImageGrafikMcu_KelainanGroupSummaryID']
|
||||
]);
|
||||
//echo $this->db->last_query();
|
||||
if ($query)
|
||||
{
|
||||
$rst = $query->result_array();
|
||||
$this->clean_mysqli_connection($this->db->conn_id);
|
||||
//print_r($rst);
|
||||
$total_all = 0;
|
||||
$total = 0;
|
||||
if($rst){
|
||||
foreach ($rst as $key => $value) {
|
||||
$typeResult = $value['type'];
|
||||
$total_all = floatval($value['total_peserta']);
|
||||
$total = floatval($total) + floatval($value["total"]);
|
||||
if($value["kelainan"] != 'No Data'){
|
||||
$datas[] = array(
|
||||
"value" => $value["total"],
|
||||
"name" => $value["total"]." : ".$this->splitString($value["kelainan"])
|
||||
);
|
||||
$data_axis[] = $this->splitString($value["kelainan"]);
|
||||
}else{
|
||||
$nodata = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if($data_graph['Mcu_ImageGrafikType'] == 'pie' && $data_graph['Mcu_ImageGrafikUseRest'] == 'Y'){
|
||||
$total_rest = $total_all - $total;
|
||||
$xname = $total_rest." : ".$data_graph['Mcu_ImageGrafikRestLabel'];
|
||||
|
||||
$datas[] = array("value" => $total_rest, "name" => $xname);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
//echo count($datas) ;
|
||||
//echo $data_graph['Mcu_ImageGrafikName'];
|
||||
|
||||
if(count($datas) > 0){
|
||||
|
||||
$option = json_decode($data_graph['Mcu_ImageGrafikJson'], true);
|
||||
$option['title']['text'] = $data_graph['Mcu_ImageGrafikName'];
|
||||
|
||||
if($data_graph['Mcu_ImageGrafikType'] == 'bar' ){
|
||||
$option['series'][0]['name'] = $data_graph['Mcu_ImageGrafikName'];
|
||||
$option['series'][0]['data'] = $datas;
|
||||
$option['xAxis']['data'] = $data_axis;
|
||||
}else{
|
||||
$option['series']['name'] = $data_graph['Mcu_ImageGrafikName'];
|
||||
$option['series']['data'] = $datas;
|
||||
}
|
||||
|
||||
if($nodata){
|
||||
$option = [
|
||||
"title" => [
|
||||
"text" => $data_graph['Mcu_ImageGrafikName'],
|
||||
'subtext' => '',
|
||||
"show" => true,
|
||||
'left' => 'center'
|
||||
],
|
||||
"tooltip" => [
|
||||
"trigger" => "item"
|
||||
],
|
||||
"legend" => [
|
||||
"top" => "5%",
|
||||
"left" => "center",
|
||||
"show" => false
|
||||
],
|
||||
"series" => [
|
||||
[
|
||||
"name" => $data_graph['Mcu_ImageGrafikName'],
|
||||
"type" => "pie",
|
||||
"radius" => ["40%", "70%"],
|
||||
"avoidLabelOverlap" => false,
|
||||
"label" => [
|
||||
"show" => true,
|
||||
"position" => "center"
|
||||
],
|
||||
"emphasis" => [
|
||||
"label" => [
|
||||
"show" => true,
|
||||
"fontSize" => 40,
|
||||
"fontWeight" => "bold"
|
||||
]
|
||||
],
|
||||
"labelLine" => [
|
||||
"show" => true
|
||||
],
|
||||
"data" => [
|
||||
['value' => 0,'name' => $data_graph['Mcu_ImageGrafikRestLabel']]
|
||||
]
|
||||
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
//print_r($option);
|
||||
//echo json_encode($option);
|
||||
}else{
|
||||
$option = json_decode($data_graph['Mcu_ImageGrafikJsonNotFound'], true);
|
||||
$option['title']['text'] = $data_graph['Mcu_ImageGrafikName'];
|
||||
//$option = json_decode($data_graph['Mcu_ImageGrafikJsonNotFound']);
|
||||
}
|
||||
|
||||
|
||||
$sql = "UPDATE mcu_image_grafik
|
||||
SET
|
||||
Mcu_ImageGrafikJsonRender = ?,
|
||||
Mcu_ImageGrafikGroupResult = ?
|
||||
WHERE
|
||||
Mcu_ImageGrafikID = ?";
|
||||
$qry = $this->db->query($sql,[
|
||||
json_encode($option),
|
||||
$typeResult,
|
||||
$id
|
||||
]);
|
||||
|
||||
//echo json_encode($option);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function gengraph_global(){
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["Mgm_McuID"];
|
||||
$this->render_graph_global($id);
|
||||
$result = array(
|
||||
"status" => "OK"
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
function generate_graph(){
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["Mgm_McuID"];
|
||||
$this->render_graph_all($id);
|
||||
}
|
||||
|
||||
function render_graph_all($id){
|
||||
$def_gen = $this->generate_default_graph($id);
|
||||
if($def_gen){
|
||||
$sql = "SELECT *
|
||||
FROM mcu_image_grafik
|
||||
WHERE
|
||||
Mcu_ImageGrafikMgm_McuID = ? AND Mcu_ImageGrafikIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql,[$id]);
|
||||
$datas = $qry->result_array();
|
||||
if($datas){
|
||||
foreach ($datas as $key => $value) {
|
||||
$this->render_graph_image($value['Mcu_ImageGrafikID']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"status" => "OK"
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function generate_default_graph($id)
|
||||
{
|
||||
$title = "";
|
||||
$param_not_found = [
|
||||
"title" => [
|
||||
"text" => $title,
|
||||
'subtext' => '',
|
||||
"show" => true,
|
||||
'left' => 'center'
|
||||
],
|
||||
"graphic" => [
|
||||
"elements" => [
|
||||
[
|
||||
"type" => "text",
|
||||
"left" => "center",
|
||||
"top" => "middle",
|
||||
"style" => [
|
||||
"text" => "Data tidak ditemukan",
|
||||
"fontSize" => 18,
|
||||
"color" => "#42aaf5"
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
$param = array(
|
||||
'title' => array(
|
||||
"text" => $title,
|
||||
'subtext' => '',
|
||||
"show" => true,
|
||||
'left' => 'center'
|
||||
),
|
||||
'tooltip' => array(
|
||||
'trigger' => 'item'
|
||||
),
|
||||
'legend' => array(
|
||||
'orient' => 'vertical',
|
||||
'left' => 'left',
|
||||
'show' => false
|
||||
),
|
||||
'series' => array(
|
||||
'name' => 'Access From',
|
||||
'type' => 'pie',
|
||||
'radius' => ['40%', '70%'],
|
||||
'labelLine' => [
|
||||
'length' => 30
|
||||
],
|
||||
'data' => []
|
||||
)
|
||||
);
|
||||
|
||||
$option_not_found = [
|
||||
"title" => [
|
||||
"text" => $title,
|
||||
'subtext' => '',
|
||||
"show" => true,
|
||||
'left' => 'center'
|
||||
],
|
||||
"graphic" => [
|
||||
"elements" => [
|
||||
[
|
||||
"type" => "text",
|
||||
"left" => "center",
|
||||
"top" => "middle",
|
||||
"style" => [
|
||||
"text" => "Data tidak ditemukan",
|
||||
"fontSize" => 18,
|
||||
"color" => "#42aaf5"
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
$option = [
|
||||
"title" => [
|
||||
"text" => $title,
|
||||
'subtext' => '',
|
||||
"show" => true,
|
||||
'left' => 'center'
|
||||
],
|
||||
"dataset" => [
|
||||
"source" => []
|
||||
],
|
||||
"grid" => [
|
||||
"containLabel" => true
|
||||
],
|
||||
"xAxis" => [
|
||||
"data" => [],
|
||||
"type" => "category",
|
||||
/*"axisLabel" => [
|
||||
"interval" => 0,
|
||||
"rotate" => 20
|
||||
]*/
|
||||
"axisLabel" => [
|
||||
"interval" => 0,
|
||||
"width" => 80,
|
||||
"rotate" => 20
|
||||
]
|
||||
],
|
||||
"yAxis" => [
|
||||
"type" => "value",
|
||||
"name" => "",
|
||||
"nameTextStyle" => [
|
||||
"align" => "right"
|
||||
],
|
||||
"nameGap" => 20
|
||||
],
|
||||
"visualMap" => [
|
||||
"orient" => "horizontal",
|
||||
"left" => "center",
|
||||
"min" => 0,
|
||||
"max" => count($data),
|
||||
"dimension" => 0,
|
||||
"show" => false,
|
||||
"inRange" => [
|
||||
"color" => ["#42aaf5", "#00eaf2", "#035bff"]
|
||||
]
|
||||
],
|
||||
"series" => [
|
||||
[
|
||||
"label" => [
|
||||
"position" => "inside",
|
||||
"show" => true,
|
||||
"formatter" => "{@[1]}"
|
||||
],
|
||||
"type" => "bar",
|
||||
"encode" => [
|
||||
"x" => "kelainan",
|
||||
"y" => "jumlah"
|
||||
]
|
||||
]
|
||||
],
|
||||
"tooltip" => [
|
||||
"trigger" => "axis",
|
||||
"axisPointer" => [
|
||||
"type" => "shadow"
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
$title = "Peserta MCU";
|
||||
$sql = "INSERT INTO mcu_image_grafik(
|
||||
Mcu_ImageGrafikMgm_McuID,
|
||||
Mcu_ImageGrafikMcu_KelainanGroupSummaryID,
|
||||
Mcu_ImageGrafikGroupMenu,
|
||||
Mcu_ImageGrafikName,
|
||||
Mcu_ImageGrafikType,
|
||||
Mcu_ImageGrafikUseRest,
|
||||
Mcu_ImageGrafikRestLabel,
|
||||
Mcu_ImageGrafikJson,
|
||||
Mcu_ImageGrafikJsonNotFound,
|
||||
Mcu_ImageGrafikCreated
|
||||
)
|
||||
VALUES(?,?,?,?,?,?,?,?,?,NOW())";
|
||||
$qry = $this->db->query($sql,[
|
||||
$id,
|
||||
1,
|
||||
'PESERTA',
|
||||
"Peserta MCU",
|
||||
'pie',
|
||||
'Y',
|
||||
'Normal',
|
||||
json_encode($param),
|
||||
json_encode($param_not_found)
|
||||
]);
|
||||
|
||||
$sql = "INSERT INTO mcu_image_grafik(
|
||||
Mcu_ImageGrafikMgm_McuID,
|
||||
Mcu_ImageGrafikMcu_KelainanGroupSummaryID,
|
||||
Mcu_ImageGrafikGroupMenu,
|
||||
Mcu_ImageGrafikName,
|
||||
Mcu_ImageGrafikType,
|
||||
Mcu_ImageGrafikUseRest,
|
||||
Mcu_ImageGrafikRestLabel,
|
||||
Mcu_ImageGrafikJson,
|
||||
Mcu_ImageGrafikJsonNotFound,
|
||||
Mcu_ImageGrafikCreated
|
||||
)
|
||||
VALUES(?,?,?,?,?,?,?,?,?,NOW())";
|
||||
$qry = $this->db->query($sql,[
|
||||
$id,
|
||||
1,
|
||||
'PESERTA',
|
||||
"Peserta MCU",
|
||||
'bar',
|
||||
'Y',
|
||||
'Normal',
|
||||
json_encode($option),
|
||||
json_encode($option_not_found)
|
||||
]);
|
||||
|
||||
$title = "Peserta MCU Berdasarkan Jenis Kelamin";
|
||||
$sql = "INSERT INTO mcu_image_grafik(
|
||||
Mcu_ImageGrafikMgm_McuID,
|
||||
Mcu_ImageGrafikMcu_KelainanGroupSummaryID,
|
||||
Mcu_ImageGrafikGroupMenu,
|
||||
Mcu_ImageGrafikName,
|
||||
Mcu_ImageGrafikType,
|
||||
Mcu_ImageGrafikUseRest,
|
||||
Mcu_ImageGrafikRestLabel,
|
||||
Mcu_ImageGrafikJson,
|
||||
Mcu_ImageGrafikJsonNotFound,
|
||||
Mcu_ImageGrafikCreated
|
||||
)
|
||||
VALUES(?,?,?,?,?,?,?,?,?,NOW())";
|
||||
$qry = $this->db->query($sql,[
|
||||
$id,
|
||||
2,
|
||||
'PESERTA',
|
||||
"Peserta MCU Berdasarkan Jenis Kelamin",
|
||||
'pie',
|
||||
'Y',
|
||||
'Normal',
|
||||
json_encode($param),
|
||||
json_encode($param_not_found)
|
||||
]);
|
||||
|
||||
$sql = "INSERT INTO mcu_image_grafik(
|
||||
Mcu_ImageGrafikMgm_McuID,
|
||||
Mcu_ImageGrafikMcu_KelainanGroupSummaryID,
|
||||
Mcu_ImageGrafikGroupMenu,
|
||||
Mcu_ImageGrafikName,
|
||||
Mcu_ImageGrafikType,
|
||||
Mcu_ImageGrafikUseRest,
|
||||
Mcu_ImageGrafikRestLabel,
|
||||
Mcu_ImageGrafikJson,
|
||||
Mcu_ImageGrafikJsonNotFound,
|
||||
Mcu_ImageGrafikCreated
|
||||
)
|
||||
VALUES(?,?,?,?,?,?,?,?,?,NOW())";
|
||||
$qry = $this->db->query($sql,[
|
||||
$id,
|
||||
2,
|
||||
'PESERTA',
|
||||
"Peserta MCU Berdasarkan Jenis Kelamin",
|
||||
'bar',
|
||||
'Y',
|
||||
'Normal',
|
||||
json_encode($option),
|
||||
json_encode($option_not_found)
|
||||
]);
|
||||
|
||||
$title = "Peserta MCU Berdasarkan Umur";
|
||||
$sql = "INSERT INTO mcu_image_grafik(
|
||||
Mcu_ImageGrafikMgm_McuID,
|
||||
Mcu_ImageGrafikMcu_KelainanGroupSummaryID,
|
||||
Mcu_ImageGrafikGroupMenu,
|
||||
Mcu_ImageGrafikName,
|
||||
Mcu_ImageGrafikType,
|
||||
Mcu_ImageGrafikUseRest,
|
||||
Mcu_ImageGrafikRestLabel,
|
||||
Mcu_ImageGrafikJson,
|
||||
Mcu_ImageGrafikJsonNotFound,
|
||||
Mcu_ImageGrafikCreated
|
||||
)
|
||||
VALUES(?,?,?,?,?,?,?,?,?,NOW())";
|
||||
$qry = $this->db->query($sql,[
|
||||
$id,
|
||||
3,
|
||||
'PESERTA',
|
||||
"Peserta MCU Berdasarkan Umur",
|
||||
'pie',
|
||||
'Y',
|
||||
'Normal',
|
||||
json_encode($param),
|
||||
json_encode($param_not_found)
|
||||
]);
|
||||
|
||||
$sql = "INSERT INTO mcu_image_grafik(
|
||||
Mcu_ImageGrafikMgm_McuID,
|
||||
Mcu_ImageGrafikMcu_KelainanGroupSummaryID,
|
||||
Mcu_ImageGrafikGroupMenu,
|
||||
Mcu_ImageGrafikName,
|
||||
Mcu_ImageGrafikType,
|
||||
Mcu_ImageGrafikUseRest,
|
||||
Mcu_ImageGrafikRestLabel,
|
||||
Mcu_ImageGrafikJson,
|
||||
Mcu_ImageGrafikJsonNotFound,
|
||||
Mcu_ImageGrafikCreated
|
||||
)
|
||||
VALUES(?,?,?,?,?,?,?,?,?,NOW())";
|
||||
$qry = $this->db->query($sql,[
|
||||
$id,
|
||||
3,
|
||||
'PESERTA',
|
||||
"Peserta MCU Berdasarkan Umur",
|
||||
'bar',
|
||||
'Y',
|
||||
'Normal',
|
||||
json_encode($option),
|
||||
json_encode($option_not_found)
|
||||
]);
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM mcu_kelainangroupsummary
|
||||
WHERE
|
||||
Mcu_KelainanGroupSummaryIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql);
|
||||
$rows = $qry->result_array();
|
||||
if($rows){
|
||||
foreach ($rows as $key => $value) {
|
||||
$title = $value['Mcu_KelainanGroupSummaryName'];
|
||||
$sql = "INSERT INTO mcu_image_grafik(
|
||||
Mcu_ImageGrafikMgm_McuID,
|
||||
Mcu_ImageGrafikMcu_KelainanGroupSummaryID,
|
||||
Mcu_ImageGrafikGroupMenu,
|
||||
Mcu_ImageGrafikName,
|
||||
Mcu_ImageGrafikType,
|
||||
Mcu_ImageGrafikUseRest,
|
||||
Mcu_ImageGrafikRestLabel,
|
||||
Mcu_ImageGrafikJson,
|
||||
Mcu_ImageGrafikJsonNotFound,
|
||||
Mcu_ImageGrafikCreated
|
||||
)
|
||||
VALUES(?,?,?,?,?,?,?,?,?,NOW())";
|
||||
$qry = $this->db->query($sql,[
|
||||
$id,
|
||||
$value['Mcu_KelainanGroupSummaryID'],
|
||||
'SUMMARY',
|
||||
$value['Mcu_KelainanGroupSummaryName'],
|
||||
'pie',
|
||||
'Y',
|
||||
'Normal',
|
||||
json_encode($param),
|
||||
json_encode($param_not_found)
|
||||
]);
|
||||
|
||||
$sql = "INSERT INTO mcu_image_grafik(
|
||||
Mcu_ImageGrafikMgm_McuID,
|
||||
Mcu_ImageGrafikMcu_KelainanGroupSummaryID,
|
||||
Mcu_ImageGrafikGroupMenu,
|
||||
Mcu_ImageGrafikName,
|
||||
Mcu_ImageGrafikType,
|
||||
Mcu_ImageGrafikUseRest,
|
||||
Mcu_ImageGrafikRestLabel,
|
||||
Mcu_ImageGrafikJson,
|
||||
Mcu_ImageGrafikJsonNotFound,
|
||||
Mcu_ImageGrafikCreated
|
||||
)
|
||||
VALUES(?,?,?,?,?,?,?,?,?,NOW())";
|
||||
$qry = $this->db->query($sql,[
|
||||
$id,
|
||||
$value['Mcu_KelainanGroupSummaryID'],
|
||||
'SUMMARY',
|
||||
$value['Mcu_KelainanGroupSummaryName'],
|
||||
'bar',
|
||||
'Y',
|
||||
'Normal',
|
||||
json_encode($option),
|
||||
json_encode($option_not_found)
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
//echo "selesai default render";
|
||||
}
|
||||
|
||||
function render($type, $id)
|
||||
{
|
||||
switch ($type) {
|
||||
case "mcu001":
|
||||
$this->mcu001($id);
|
||||
break;
|
||||
|
||||
case "mcu002":
|
||||
$this->mcu002($id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function splitString($string, $wordsPerLine = 2)
|
||||
{
|
||||
$words = explode(' ', $string);
|
||||
$lines = [];
|
||||
for ($i = 0; $i < count($words); $i += $wordsPerLine) {
|
||||
$lines[] = implode(' ', array_slice($words, $i, $wordsPerLine));
|
||||
}
|
||||
return implode("\n", $lines);
|
||||
}
|
||||
|
||||
function check_error($qry, $stage)
|
||||
{
|
||||
if (!$qry) {
|
||||
$errMsg = $stage . "<br/>" . $this->db->error()["messge"];
|
||||
print_r($errMsg);
|
||||
$this->chart_error($errMsg);
|
||||
}
|
||||
}
|
||||
|
||||
function chart_error($msg)
|
||||
{
|
||||
$param = array(
|
||||
'title' => array(
|
||||
'show' => true,
|
||||
'textStyle' => array(
|
||||
'color' => 'grey',
|
||||
'fontSize' => 20
|
||||
),
|
||||
'text' => $msg,
|
||||
'left' => 'center',
|
||||
'top' => 'center'
|
||||
),
|
||||
'xAxis' => array(
|
||||
'show' => false
|
||||
),
|
||||
'yAxis' => array(
|
||||
'show' => false
|
||||
),
|
||||
'series' => array()
|
||||
);
|
||||
header("Content-Type: image/png");
|
||||
$config = ["config" => $param];
|
||||
$j_param = json_encode($config);
|
||||
echo $this->post($this->url_renderer, $j_param);
|
||||
exit;
|
||||
}
|
||||
|
||||
function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, j120);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
"Content-Type: application/json",
|
||||
"Content-Length: " . strlen($data),
|
||||
]);
|
||||
$result = curl_exec($ch);
|
||||
if (curl_errno($ch) > 0) {
|
||||
return [
|
||||
"status" => "ERR",
|
||||
"message" => curl_error($ch),
|
||||
];
|
||||
}
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
if ($httpCode != 200) {
|
||||
return [
|
||||
"status" => "ERR",
|
||||
"message" => "Http Response : $httpCode",
|
||||
];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
2189
application/controllers/tools/Mcu_proses_upload.php
Normal file
2189
application/controllers/tools/Mcu_proses_upload.php
Normal file
File diff suppressed because it is too large
Load Diff
54
application/controllers/tools/Mculog.php
Normal file
54
application/controllers/tools/Mculog.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
class Mculog extends MY_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
function show($logfile) {
|
||||
$fp = file_get_contents("/xtmp/{$logfile}.log");
|
||||
$arr = explode("\n", $fp);
|
||||
$arr = array_slice($arr, -1000);
|
||||
$arr = array_reverse($arr);
|
||||
$msg = implode("\n", $arr);
|
||||
echo "<pre>$msg</pre>";
|
||||
}
|
||||
function read_log($logfile)
|
||||
{
|
||||
$fp = fopen("/xtmp/{$logfile}.log", 'r');
|
||||
$pos = -1; // Skip final new line character (Set to -1 if not present)
|
||||
|
||||
$lines = array();
|
||||
$currentLine = '';
|
||||
$idx = 0;
|
||||
$msg = "<pre>";
|
||||
while (-1 !== fseek($fp, $pos, SEEK_END)) {
|
||||
$char = fgetc($fp);
|
||||
if (PHP_EOL == $char) {
|
||||
$msg .= $currentLine;
|
||||
echo $msg;
|
||||
$currentLine = '';
|
||||
} else {
|
||||
$currentLine = $char . $currentLine;
|
||||
}
|
||||
$pos--;
|
||||
$idx++;
|
||||
if ($idx > 1000) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
$msg .= "</pre>";
|
||||
return $msg;
|
||||
}
|
||||
function index()
|
||||
{
|
||||
|
||||
$fp = file_get_contents("/xtmp/mcu_upload.log");
|
||||
$arr = explode("\n", $fp);
|
||||
$arr = array_slice($arr, -500);
|
||||
$arr = array_reverse($arr);
|
||||
$msg = implode("\n", $arr);
|
||||
echo "<pre>$msg</pre>";
|
||||
}
|
||||
}
|
||||
57
application/controllers/tools/Merge_pdf.php
Normal file
57
application/controllers/tools/Merge_pdf.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
class Merge_pdf extends MY_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
function merge()
|
||||
{
|
||||
$param = $this->sys_input;
|
||||
$target = tempnam("/tmp", uniqid("target", true));
|
||||
$merge_cmd = "/usr/bin/pdfunite";
|
||||
$base_url = "http://localhost/";
|
||||
$fnames_del = [];
|
||||
$origin = $param["input"];
|
||||
$dob = $param["dob"];
|
||||
$output_file_name = $param["output"];
|
||||
foreach ($origin as $r) {
|
||||
$fname = tempnam("/tmp", uniqid("src", true));
|
||||
$rpt_data = file_get_contents($r);
|
||||
if (strlen($rpt_data) > 0) {
|
||||
file_put_contents($fname, $rpt_data);
|
||||
$merge_cmd .= " $fname ";
|
||||
}
|
||||
$fnames_del[] = $fname;
|
||||
}
|
||||
$merge_cmd .= " $target";
|
||||
$output = [];
|
||||
exec($merge_cmd, $output);
|
||||
if ($dob != "") {
|
||||
$target_enc = tempnam("/tmp", uniqid("targetenc", true));
|
||||
$enc_cmd = "/usr/bin/pdftk $target output $target_enc user_pw $dob";
|
||||
exec($enc_cmd, $output);
|
||||
}
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
if ($dob != "") {
|
||||
echo file_get_contents($target_enc);
|
||||
} else {
|
||||
echo file_get_contents($target);
|
||||
}
|
||||
foreach ($fnames_del as $fdel) {
|
||||
unlink($fdel);
|
||||
}
|
||||
if (file_exists($target)) {
|
||||
unlink($target);
|
||||
}
|
||||
if ($dob != "" && file_exists($target_enc)) {
|
||||
unlink($target_enc);
|
||||
}
|
||||
exit;
|
||||
}
|
||||
}
|
||||
30
application/controllers/tools/Myqueue.php
Normal file
30
application/controllers/tools/Myqueue.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
class Myqueue extends MY_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function list($time=0) {
|
||||
$sql = "select ID,USER,HOST,DB,COMMAND,TIME,STATE,PROGRESS,MEMORY_USED
|
||||
from INFORMATION_SCHEMA.processlist
|
||||
where USER <> 'system user' and TIME >= $time";
|
||||
$qry = $this->db->query($sql);
|
||||
//echo $this->db->last_query();
|
||||
if (! $qry ) {
|
||||
print_r($this->db->error());
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
echo "ID\t\tUSER\t\tDB\t\tTIME\t\tMEMORY_USED\t\tPROGRESS\n";
|
||||
foreach($rows as $r) {
|
||||
$id = $r["ID"];
|
||||
$user = $r["USER"];
|
||||
$db = $r["DB"];
|
||||
$time = $r["TIME"];
|
||||
$mem = $r["MEMORY_USED"];
|
||||
$progress = $r["PROGRESS"];
|
||||
echo "$id\t\t$user\t\t$db\t\t$time\t\t$mem\t\t$progress\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
461
application/controllers/tools/Order.php
Normal file
461
application/controllers/tools/Order.php
Normal file
@@ -0,0 +1,461 @@
|
||||
<?php
|
||||
class Order extends MY_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function ref_order($incomingRefID) {
|
||||
$adminUserID = 3;
|
||||
$this->sys_user["M_UserID"] = $adminUserID;
|
||||
|
||||
$sql = "select * from incoming_ref where incomingRefID = ?";
|
||||
$qry = $this->db->query($sql, array($incomingRefID) );
|
||||
$rows = array();
|
||||
$branchID = 0;
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if ( count($rows) > 0 ) $branchID = $rows[0]["incomingRefM_BranchID"];
|
||||
}
|
||||
|
||||
$companyID = 0;
|
||||
if ($branchID > 0 ) {
|
||||
$sql = "select *
|
||||
from m_branch where M_BranchID = ?";
|
||||
$qry = $this->db->query($sql, array($branchID) );
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$companyID = $rows[0]["M_BranchM_CompanyID"];
|
||||
$mouID = $rows[0]["M_BranchM_MouID"];
|
||||
$doctorID = $rows[0]["M_BranchM_DoctorID"];
|
||||
$doctorAddressID = $rows[0]["M_BranchM_DoctorAddressID"];
|
||||
$branchKelurahanID= $rows[0]["M_BranchM_KelurahanID"];
|
||||
$branchAddresss = $rows[0]["M_BranchAddress"];
|
||||
}
|
||||
}
|
||||
if ($companyID == 0 ) {
|
||||
$this->sys_error_db("Company / MOU belum di set");
|
||||
exit;
|
||||
}
|
||||
$sql = "select *
|
||||
from incoming_ref_detail
|
||||
where incomingRefDetailIncomingRefID = ?
|
||||
order by incomingRefDetailT_OrderHeaderID";
|
||||
$qry = $this->db->query($sql, array($incomingRefID) );
|
||||
$orders = array();
|
||||
$ax_test = array();
|
||||
$a_promise = array();
|
||||
$a_barcode = array();
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$prev_oh_id = 0;
|
||||
foreach($rows as $r) {
|
||||
$oh_id = $r["incomingRefDetailT_OrderHeaderID"];
|
||||
if ( ! isset($orders[$oh_id]) ) {
|
||||
$orders[$oh_id]["patient"] = json_decode($r["incomingRefDetailPatient"],true);
|
||||
$orders[$oh_id]["foNote"] = $r["incomingRefDetailFoNote"];
|
||||
$orders[$oh_id]["verificationNote"] = $r["incomingRefDetailVefificationNote"];
|
||||
$orders[$oh_id]["samplingNote"] = $r["incomingRefDetailSamplingNote"];
|
||||
$orders[$oh_id]["LabNumber"] = $r["incomingRefDetailT_OrderHeaderLabNumber"];
|
||||
$orders[$oh_id]["test"] = array();
|
||||
}
|
||||
$orders[$oh_id]["test"][] = array (
|
||||
"T_TestID" => $r["incomingRefDetailT_TestID"],
|
||||
"Promise" => $r["incomingRefDetailT_OrderPromiseDateTime"],
|
||||
"T_OrderDetailID" => $r["incomingRefDetailT_OrderDetailID"],
|
||||
"T_BarcodeLabBarcode" => $r["incomingRefDetailT_BarcodeLabBarcode"],
|
||||
"Requirements" => json_decode($r["incomingRefDetailRequirements"],true)
|
||||
);
|
||||
$ax_test[] = $r["incomingRefDetailT_TestID"];
|
||||
$a_promise[$oh_id][$r["incomingRefDetailT_TestID"]] = $r["incomingRefDetailT_OrderPromiseDateTime"];
|
||||
$a_barcode[$oh_id][$r["incomingRefDetailT_TestID"]] = $r["incomingRefDetailT_BarcodeLabBarcode"];
|
||||
}
|
||||
}
|
||||
$s_test = "0," . join(",",$ax_test);
|
||||
$sql = "select * from ss_price_mou
|
||||
where Ss_PriceMouM_MouID = ? and T_TestID in ( $s_test ) ";
|
||||
$qry = $this->db->query($sql, array($mouID) );
|
||||
$a_test = array();
|
||||
if ($qry ) {
|
||||
$rows = $qry->result_array();
|
||||
foreach($rows as $r) {
|
||||
$testID = $r["T_TestID"];
|
||||
$a_test[$testID] = array(
|
||||
"T_PriceAmount" => $r["T_PriceAmount"],
|
||||
"T_PriceDiscRp" => $r["T_PriceDiscRp"],
|
||||
"T_PriceDisc" => $r["T_PriceDisc"]
|
||||
);
|
||||
}
|
||||
}
|
||||
$message = "";
|
||||
foreach($orders as $oh_id => $o){
|
||||
$noreg = $o["patient"]["M_PatientNoReg"];
|
||||
$lab_number= $o["LabNumber"];
|
||||
//if noreg not exists create patient
|
||||
$sql = "select count(*) tot from m_patient where M_PatientNoReg=? and M_PatientIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, array($noreg));
|
||||
$patientID = $orders[$oh_id]["patient"]["M_PatientID"];
|
||||
if($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if ($rows[0]["tot"] == 0 ) {
|
||||
$patientID = $this->create_patient($orders[$oh_id]["patient"]);
|
||||
}
|
||||
}
|
||||
$sql = "select fn_global_age_count(M_PatientDOB,now()) age
|
||||
from m_patient where M_PatientID = ? ";
|
||||
$qry = $this->db->query($sql, array($patientID) );
|
||||
$patientAge = "";
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$patientAge = $rows[0]["age"];
|
||||
}
|
||||
}
|
||||
//echo "1. $lab_number : $patientID \n";
|
||||
//register order
|
||||
$xheader = array(
|
||||
'patient_id' => $patientID,
|
||||
'age' => $patientAge,
|
||||
'sender_doctor_id' => $doctorID,
|
||||
'sender_address_id' => $doctorAddressID,
|
||||
'company_id' => $companyID,
|
||||
'mou_id' => $mouID,
|
||||
'lang_id' => '1',
|
||||
'lang_si' => 'N',
|
||||
'doctor_note' => '',
|
||||
'fo_note' => $orders[$oh_id]["foNote"],
|
||||
'queue' => '',
|
||||
'received_sample' => 'Y',
|
||||
'lang_id_2' => '2',
|
||||
'lang_si_2' => 'N',
|
||||
);
|
||||
$xdel = array(
|
||||
array(
|
||||
'address_id' => $branchID,
|
||||
'delivery_id' => '10',
|
||||
'delivery_type_id' => '2',
|
||||
'senderdoctorid' => $doctorID,
|
||||
'senderaddressid' => $doctorAddressID,
|
||||
'note' => $branchAddresss,
|
||||
'kelurahan' => $branchKelurahanID
|
||||
));
|
||||
$xdet = array();
|
||||
$reqs = array();
|
||||
foreach($orders[$oh_id]["test"] as $t ) {
|
||||
$v = $a_test[$t["T_TestID" ]];
|
||||
$xdet[] = array(
|
||||
't_id' => $t['T_TestID'],
|
||||
't_cito' => 'N',
|
||||
't_price' => $v['T_PriceAmount'],
|
||||
't_disc' => $v['T_PriceDisc'],
|
||||
't_discrp' => $v['T_PriceDiscRp'],
|
||||
't_req' => 'Y',
|
||||
't_reqnote' => '',
|
||||
't_ispacket' => "N",
|
||||
't_packettype' => "PX",
|
||||
't_packetid' => '0'
|
||||
);
|
||||
if (count($t["Requirements"]) > 0 ) {
|
||||
$reqs = array_merge($reqs, $t["Requirements"]);
|
||||
}
|
||||
}
|
||||
//requirements
|
||||
$xreq = array(
|
||||
'status' => 'Y',
|
||||
'reqs' => '[]'
|
||||
);
|
||||
$header_json = json_encode($xheader);
|
||||
$delivery_json = json_encode($xdel);
|
||||
$detail_json = json_encode($xdet);
|
||||
$req_json = json_encode($xreq);
|
||||
$sql = "CALL `sp_fo_register_save_v5`(
|
||||
0,
|
||||
'{$header_json}',
|
||||
'{$delivery_json}',
|
||||
'{$detail_json}',
|
||||
'{$req_json}',
|
||||
'{$userid}'
|
||||
);";
|
||||
$r = $this->db->query($sql)->row();
|
||||
$this->clean_mysqli_connection($this->db->conn_id);
|
||||
if ($r->status != "OK" ) {
|
||||
print_r($r);
|
||||
exit;
|
||||
}
|
||||
$data = json_decode($r->data,true);
|
||||
$new_oh_id = $data["id"];
|
||||
$new_lab_number= $data["number"];
|
||||
|
||||
//echo "2. $new_oh_id : $lab_number => $new_lab_number \n";
|
||||
|
||||
//update incoming_ref
|
||||
$sql = "update incoming_ref_detail set incomingRefDetailNewT_OrderHeaderID=?,
|
||||
incomingRefDetailNewM_PatientID = ?
|
||||
where incomingRefDetailIncomingRefID = ?
|
||||
and incomingRefDetailT_OrderHeaderID=?";
|
||||
$this->db->query($sql,array($new_oh_id, $patientID, $incomingRefID, $oh_id));
|
||||
|
||||
$sql = "update t_orderheaderaddon set T_OrderHeaderAddOnLabNumberOrigin=?
|
||||
where T_OrderHeaderAddOnT_OrderHeaderID = ?";
|
||||
$this->db->query($sql,array($lab_number,$new_oh_id));
|
||||
|
||||
//update promise
|
||||
$a_promise_test = array();
|
||||
$a_promise_date= array();
|
||||
$a_promise_id= array();
|
||||
foreach($a_promise[$oh_id] as $testID => $promise ) {
|
||||
if(!isset($a_promise_date[$promise])) {
|
||||
$sql = "insert into t_orderpromise(T_OrderPromiseT_OrderHeaderID, T_OrderPromiseDateTime)
|
||||
values(?,?)";
|
||||
$this->db->query($sql, array($new_oh_id,$promise));
|
||||
$promise_id = $this->db->insert_id();
|
||||
$a_promise_test[$testID] = $promise_id;
|
||||
$a_promise_date["$promise"] = $promise_id;
|
||||
} else {
|
||||
$a_promise_test[$testID] = $a_promise_date["$promise"];
|
||||
}
|
||||
}
|
||||
if ( count($a_promise_test) > 0 ) {
|
||||
$s_test = join(",", array_keys($a_promise_test));
|
||||
$sql = "update t_orderpromise,t_orderdetail
|
||||
set T_OrderPromiseIsActive = 'N'
|
||||
where T_OrderPromiseID = T_OrderDetailT_OrderPromiseID
|
||||
and T_OrderDetailT_OrderHeaderID = ?
|
||||
and T_OrderDetailT_TestID in ($s_test) ";
|
||||
$this->db->query($sql, array($new_oh_id));
|
||||
}
|
||||
foreach($a_promise_test as $testID => $promiseID ) {
|
||||
$sql = "update t_orderdetail
|
||||
set T_OrderDetailT_OrderPromiseID= ?
|
||||
where T_OrderDetailT_OrderHeaderID = ?
|
||||
and T_OrderDetailT_TestID = ? ";
|
||||
$this->db->query($sql, array($promiseID , $new_oh_id, $testID) );
|
||||
}
|
||||
//insert requirements
|
||||
foreach($reqs as $r) {
|
||||
$sql ="insert into t_orderreq(T_OrderReqT_OrderHeaderID,T_OrderReqNat_PositionID,
|
||||
T_OrderReqStatus, T_OrderReqT_TestID, T_OrderReqs)
|
||||
values(?,?, ?,?,?)";
|
||||
$this->db->query($sql, array($new_oh_id, $r["T_OrderReqNat_PositionID"],
|
||||
$r["T_OrderReqStatus"], $r["T_OrderReqT_TestID"], $r["T_OrderReqs"] ));
|
||||
}
|
||||
//update note
|
||||
$sql = "update t_orderheader
|
||||
set T_OrderHeaderFoNote = ? , T_OrderHeaderFoNoteM_UserID = ?,
|
||||
T_OrderHeaderSamplingNote = ?, T_OrderHeaderSamplingNoteM_UserID = ?,
|
||||
T_OrderHeaderVerificationNote = ?, T_OrderHeaderVerificationNoteM_UserID = ?
|
||||
where T_OrderHeaderID = ?
|
||||
";
|
||||
$this->db->query($sql, array( $o["foNote"],$adminUserID,
|
||||
$o["samplingNote"], $adminUserID, $o["verificationNote"], $adminUserID,
|
||||
$new_oh_id));
|
||||
$result = $this->fo_verify($new_oh_id,$adminUserID);
|
||||
|
||||
//update t_barcodelab
|
||||
foreach($a_barcode[$oh_id] as $testID => $barcode) {
|
||||
$sql = "update t_barcodelab,t_test
|
||||
set T_BarcodeLabBarcodeOrigin =?
|
||||
where T_BarcodeLabT_OrderHeaderID = ?
|
||||
and T_TestID = ?
|
||||
and T_TestIsActive = 'Y' and T_BarcodeLabT_SampleTypeID = T_TestT_SampleTypeID";
|
||||
$this->db->query($sql, array($barcode, $new_oh_id, $testID));
|
||||
}
|
||||
// update nilai normal
|
||||
$sql = "select distinct T_OrderDetailT_OrderHeaderID id,
|
||||
T_TestT_SampleTypeID sid
|
||||
from t_orderdetail
|
||||
join t_test on T_OrderDetailT_OrderHeaderID = ?
|
||||
and T_OrderDetailIsActive = 'Y' and
|
||||
T_OrderDetailT_TestID = T_TestID
|
||||
and T_TestIsActive = 'Y'
|
||||
";
|
||||
$qry = $this->db->query($sql, array($new_oh_id));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
foreach($rows as $r) {
|
||||
$sql = "call sp_sampling_set_normal(?,?)";
|
||||
$this->db->query($sql,array($r["id"],$r["sid"]));
|
||||
}
|
||||
}
|
||||
|
||||
$message .= "$lab_number => $new_lab_number [ Fo Verify : $result ] \n";
|
||||
}
|
||||
echo $message;
|
||||
}
|
||||
function create_patient($p) {
|
||||
$sql = "insert into m_patient";
|
||||
$userID = 3;
|
||||
//check title
|
||||
$sql = "select M_TitleID from m_title where M_TitleName = ? and M_TitleIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, array($p["title"]["M_TitleName"]));
|
||||
$titleID = 0;
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) $titleID = $rows[0]["M_TitleID"];
|
||||
}
|
||||
if ($titleID == 0) {
|
||||
$sql = "insert into m_title(M_TitleName, M_TitleM_SexID) values ( ? , ? )";
|
||||
$qry = $this->db->query($sql, array($p["title"]["M_TitleName"], $p["title"]["M_TitleM_SexID"]));
|
||||
if ($qry) {
|
||||
$titleID = $this->db->insert_id();
|
||||
}
|
||||
}
|
||||
if ($titleID == 0 ) {
|
||||
$this->sys_error_db("Invalid Title");
|
||||
exit;
|
||||
}
|
||||
$pdob = date('Y-m-d',strtotime($p['M_PatientDOB']));
|
||||
$query ="INSERT INTO m_patient (
|
||||
M_PatientM_TitleID,
|
||||
M_PatientName,
|
||||
M_PatientDOB,
|
||||
M_PatientM_SexID,
|
||||
M_PatientM_ReligionID,
|
||||
M_PatientEmail,
|
||||
M_PatientPOB,
|
||||
M_PatientHP,
|
||||
M_PatientPhone,
|
||||
M_PatientM_IdTypeID,
|
||||
M_PatientIDNumber,
|
||||
M_PatientNote,
|
||||
M_PatientUserID
|
||||
)
|
||||
VALUES(
|
||||
'{$titleID}',
|
||||
'{$p['M_PatientName']}',
|
||||
'{$pdob}',
|
||||
'{$p['M_PatientM_SexID']}',
|
||||
'{$p['M_PatientM_ReligionID']}',
|
||||
'{$p['M_PatientEmail']}',
|
||||
'{$p['M_PatientPOB']}',
|
||||
'{$p['M_PatientHP']}',
|
||||
'{$p['M_PatientPhone']}',
|
||||
'{$p['M_PatientM_IdTypeID']}',
|
||||
'{$p['M_PatientIDNumber']}',
|
||||
'{$p['M_PatientNote']}',
|
||||
$userID
|
||||
)";
|
||||
$qry = $this->db->query($query);
|
||||
$patientID = 0;
|
||||
if ($qry ) {
|
||||
$patientID = $this->db->insert_id();
|
||||
}
|
||||
|
||||
//
|
||||
$sql = "insert into m_patientaddress(M_PatientAddressM_PatientID, M_PatientAddressNote,
|
||||
M_PatientAddressDescription,M_PatientAddressLocation,M_PatientAddressM_KelurahanID,
|
||||
M_PatientAddressOldCityID, M_PatientAddressPostCodeID, M_PatientAddressFax,
|
||||
M_PatientAddressEmail, M_PatientAddressPhone)
|
||||
values(?,?, ?,?,?, ?,?,?, ?,?) ";
|
||||
foreach($p["address"] as $adr) {
|
||||
$prm = array($patientID , $adr["M_PatientAddressNote"],
|
||||
$adr["M_PatientAddressDescription"],$adr["M_PatientAddressLocation"],$adr["M_PatientAddressM_KelurahanID"],
|
||||
$adr["M_PatientAddressOldCityID"], $adr["M_PatientAddressPostCodeID"], $adr["M_PatientAddressFax"],
|
||||
$adr["M_PatientAddressEmail"], $adr["M_PatientAddressPhone"] );
|
||||
$this->db->query($sql,$prm);
|
||||
}
|
||||
|
||||
return $patientID;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function fo_verify($orderID,$userID) {
|
||||
$sql="INSERT INTO fo_verificationsvalue (
|
||||
Fo_VerificationsValueT_OrderHeaderID,
|
||||
Fo_VerificationsValueFo_VerificationsLabelID,
|
||||
Fo_VerificationsValueCheck,
|
||||
Fo_VerificationsValueNote,
|
||||
Fo_VerificationsValueUserID,
|
||||
Fo_VerificationsValueCreated )
|
||||
SELECT {$orderID},
|
||||
Fo_VerificationsLabelID,
|
||||
'Y',
|
||||
'', {$userID},
|
||||
NOW()
|
||||
FROM fo_verificationslabel
|
||||
WHERE
|
||||
Fo_VerificationsLabelIsActive = 'Y' ";
|
||||
$this->db->query($sql);
|
||||
|
||||
$sql = "call sp_fo_barcode_generate({$orderID})";
|
||||
$this->db->query($sql);
|
||||
|
||||
$fostatusid = 3;
|
||||
$fologcode = 'FO.VERIFICATION.CONFIRM';
|
||||
|
||||
$sql = "insert into fo_status(
|
||||
Fo_StatusDate,
|
||||
Fo_StatusT_OrderHeaderID,
|
||||
Fo_StatusM_StatusID,
|
||||
Fo_StatusM_UserID,
|
||||
Fo_StatusCreated,
|
||||
Fo_StatusUpdated)
|
||||
values( now(), ?, ?, ?, now(),now())";
|
||||
|
||||
$query = $this->db->query($sql,
|
||||
array(
|
||||
$orderID,
|
||||
$fostatusid, $userID
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
return "Error Fo Status";
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM fo_verificationsvalue WHERE Fo_VerificationsValueT_OrderHeaderID = {$orderID}";
|
||||
|
||||
$data_log = array();
|
||||
$data_log['orderid'] = $orderID;
|
||||
$data_log['values'] = $this->db->query($sql)->result_array();
|
||||
$data_log['note'] = '';
|
||||
|
||||
$json_dt_log = json_encode($data_log);
|
||||
$sql = "insert into one_log.log_fo(
|
||||
Log_FoDate,
|
||||
Log_FoCode,
|
||||
Log_FoJson,
|
||||
Log_FoUserID)
|
||||
values( now(), ?, ?, ?)";
|
||||
$query = $this->db->query($sql,
|
||||
array(
|
||||
$fologcode,
|
||||
$json_dt_log,
|
||||
$userID
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
return "Error Fo Log";
|
||||
}
|
||||
|
||||
/* T_OrderSample */
|
||||
$adminUserID = 3;
|
||||
$sql = "update t_ordersample
|
||||
set T_OrderSampleSampling='Y', T_OrderSampleSamplingDate = now(),
|
||||
T_OrderSampleSamplingTime = now(),T_OrderSampleSamplingUserID = $adminUserID,
|
||||
T_OrderSampleReceive='Y', T_OrderSampleReceiveDate = now() , T_OrderSampleReceiveTime = now(),
|
||||
T_OrderSampleReceiveUserID = $adminUserID,
|
||||
T_OrderSampleVerification='Y', T_OrderSampleVerificationDate=now(), T_OrderSampleVerificationTime=now(),
|
||||
T_OrderSampleVerificationUserID = $adminUserID,
|
||||
T_OrderSampleSendHandling = 'Y', T_OrderSampleSendHandlingDate =now(), T_OrderSampleSendHandlingTime=now(),
|
||||
T_OrderSampleSendHandlingUserID = $adminUserID,
|
||||
T_OrderSampleReceiveHandling = 'Y', T_OrderSampleReceiveHandlingDate=now(), T_OrderSampleReceiveHandlingTime=now(),
|
||||
T_OrderSampleReceiveHandlingUserID=$adminUserID,
|
||||
T_OrderSampleHandling='Y', T_OrderSampleHandlingDate=now(), T_OrderSampleHandlingTime=now(),
|
||||
T_OrderSampleHandlingUserID=$adminUserID,
|
||||
T_OrderSampleProcessing='Y', T_OrderSampleReadyToProcessDateTime=now(), T_OrderSampleProcessingDate=now(),
|
||||
T_OrderSampleProcessingTime=now(), T_OrderSampleProcessingUserID=$adminUserID,
|
||||
T_OrderSampleUserID=$adminUserID
|
||||
where T_OrderSampleT_OrderHeaderID = ?";
|
||||
|
||||
|
||||
$qry = $this->db->query($sql, array($orderID) );
|
||||
if (!$qry) {
|
||||
return "Error T_OrderSample : " . $this->db->last_query();
|
||||
}
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
104
application/controllers/tools/Outgoingref.php
Normal file
104
application/controllers/tools/Outgoingref.php
Normal file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
class OutgoingRef extends MY_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function process() {
|
||||
$sql = "select tx_branch_status.*, M_BranchName
|
||||
from tx_branch_status
|
||||
join m_branch on TxBranchStatusM_BranchID = M_BranchID
|
||||
where TxBranchStatusIsSent = 'N' and TxBranchStatusRetry < 5
|
||||
limit 0,20";
|
||||
$qry = $this->db->query($sql);
|
||||
$sql_update = "update tx_branch_status set TxBranchStatusIsSent=?,
|
||||
TxBranchStatusRetry = TxBranchStatusRetry + 1
|
||||
where TxBranchStatusID = ?";
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
foreach($rows as $r) {
|
||||
$param = $r["TxBranchStatusJson"];
|
||||
$stage = $r["TxBranchStatusStage"];
|
||||
$ipAddress = $r["TxBranchStatusM_BranchIP"];
|
||||
$branchName = $r["M_BranchName"];
|
||||
$txID = $r["TxBranchStatusID"];
|
||||
|
||||
$url = "http://$ipAddress/one-api/tools/xstatusbranch/update";
|
||||
$rst = $this->post($url,$param);
|
||||
if ($rst["status"] == "OK" ) {
|
||||
$this->xlog("Update status $stage to $branchName @ $ipAddress [OK]");
|
||||
$this->db->query($sql_update, array('Y',$txID));
|
||||
} else {
|
||||
$err_msg = print_r($rst,true);
|
||||
$this->xlog("Update status $stage to $branchName @ $ipAddress [ERR] : $err_msg");
|
||||
$this->db->query($sql_update, array('N',$txID));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->xlog("Err: " . print_r($this->db->error(),true));
|
||||
}
|
||||
}
|
||||
function xlog($message) {
|
||||
$dt = date("Y-m-d H:i:s");
|
||||
echo "$dt $message\n";
|
||||
}
|
||||
function status($incomingRefID) {
|
||||
$sql = "select * from incoming_ref where incomingRefID = ?";
|
||||
$qry = $this->db->query($sql, array($incomingRefID) );
|
||||
$rows = array();
|
||||
$branchID = 0;
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if ( count($rows) > 0 ) $branchID = $rows[0]["incomingRefM_BranchID"];
|
||||
}
|
||||
$ip_address= "";
|
||||
if ($branchID > 0 ) {
|
||||
$sql = "select *
|
||||
from m_branch where M_BranchID = ?";
|
||||
$qry = $this->db->query($sql, array($branchID) );
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if(count($rows) > 0 ) $ip_address = $rows[0]["M_BranchIPAddress"];
|
||||
}
|
||||
}
|
||||
if ($ip_address == "" ) {
|
||||
echo "No IP Address from $branchID ";
|
||||
exit;
|
||||
}
|
||||
$sql = "select
|
||||
incomingRefT_RefDeliveryOrderID,
|
||||
incomingRefDetailT_OrderDetailID,
|
||||
incomingRefDetailStatus,
|
||||
T_OrderDetailResult,
|
||||
T_OrderDetailNat_NormalValueID,
|
||||
T_OrderDetailVerification,
|
||||
T_OrderDetailValidation
|
||||
from incoming_ref_detail
|
||||
join incoming_ref on incomingRefID = incomingRefDetailIncomingRefID
|
||||
and incomingRefID = ?
|
||||
left join t_orderdetail on incomingRefDetailNewT_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderDetailIsActive = 'Y' and incomingRefDetailT_TestID = T_OrderDetailT_TestID";
|
||||
$qry = $this->db->query($sql, array($incomingRefID));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$param = json_encode($rows);
|
||||
$url = "http://$ip_address/one-api/tools/xstatusbranch/update";
|
||||
$result = $this->post($url,$param);
|
||||
print_r($result);
|
||||
}
|
||||
}
|
||||
function post($url,$data) {
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data))
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return json_decode($result,true);
|
||||
}
|
||||
}
|
||||
212
application/controllers/tools/Outgoingref_other.php
Normal file
212
application/controllers/tools/Outgoingref_other.php
Normal file
@@ -0,0 +1,212 @@
|
||||
<?php
|
||||
class Outgoingref_other extends MY_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function get_origin_detail($type,$xid) {
|
||||
if ($type == "mikro") {
|
||||
$sql = "select * from other_mikro where Other_MikroID=? ";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
$result = array();
|
||||
if ($qry ) {
|
||||
$result["header"] = $qry->result_array();
|
||||
$sql = "select * from other_mikrodetails where Other_MikroDetailsOther_MikroID=? and
|
||||
Other_MikroDetailsIsActive = 'Y' ";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
if ($qry) {
|
||||
$result["detail"] = $qry->result_array();
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
return array();
|
||||
}
|
||||
function get_origin($orderHeaderID,$testID) {
|
||||
$sql = "select
|
||||
incomingRefDetailT_OrderHeaderID T_OrderHeaderID,
|
||||
incomingRefDetailT_OrderDetailID T_OrderDetailID,
|
||||
M_BranchID, M_BranchCode, M_BranchIPAddress
|
||||
from incoming_ref_detail
|
||||
join incoming_ref on incomingRefID = incomingRefDetailIncomingRefID
|
||||
join m_branch on M_BranchID = incomingRefM_BranchID
|
||||
where incomingRefDetailNewT_OrderHeaderID = ?
|
||||
and incomingRefDetailT_TestID = ?";
|
||||
$qry = $this->db->query($sql, array($orderHeaderID, $testID));
|
||||
if ( ! $qry ) {
|
||||
print_r($this->db->error());
|
||||
return false;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if ( count($rows) > 0 ) {
|
||||
$result = $rows[0];
|
||||
return $result;
|
||||
}
|
||||
$sql = "select
|
||||
incomingRefChildT_OrderHeaderID T_OrderHeaderID,
|
||||
M_BranchID, M_BranchCode, M_BranchIPAddress
|
||||
from incoming_ref_child
|
||||
join incoming_ref on incomingRefID = incomingRefChildIncomingRefID
|
||||
join m_branch on M_BranchID = incomingRefM_BranchID
|
||||
where incomingRefChildNewT_OrderHeaderID = ?
|
||||
and incomingRefChildT_TestID = ?";
|
||||
$qry = $this->db->query($sql, array($orderHeaderID, $testID));
|
||||
if ( ! $qry ) {
|
||||
print_r($this->db->error());
|
||||
return false;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if ( count($rows) > 0 ) {
|
||||
$result = $rows[0];
|
||||
return $result;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function gen($date) {
|
||||
$type = "cytologi";
|
||||
$sql = "select
|
||||
other_cytologi.*
|
||||
from other_cytologi
|
||||
join t_orderdetail on Other_CytologiT_OrderDetailID = T_OrderDetailID
|
||||
and Other_CytologiIsActive = 'Y' and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderDetailVerification = 'Y'
|
||||
join t_orderheaderaddon on T_OrderHeaderAddOnT_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderHeaderAddOnIsActive = 'Y' and T_OrderHeaderAddOnLabNumberOrigin is not null
|
||||
join t_orderheader on T_OrderHeaderAddOnT_OrderHeaderID = T_OrderHeaderID
|
||||
and T_OrderHeaderIsActive='Y' and date(T_OrderHeaderDate) = ?";
|
||||
$qry = $this->db->query($sql,array($date)) ;
|
||||
if ( ! $qry ) {
|
||||
$this->xlog("$type Err : " . print_r($this->db->error(),true));
|
||||
}
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$this->xlog("Proccessing $type");
|
||||
print_r($rows);
|
||||
}
|
||||
}
|
||||
$type = "fna";
|
||||
$sql = "select
|
||||
other_fna.*
|
||||
from other_fna
|
||||
join t_orderdetail on Other_FnaT_OrderDetailID = T_OrderDetailID
|
||||
and Other_FnaIsActive = 'Y' and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderDetailVerification = 'Y'
|
||||
join t_orderheaderaddon on T_OrderHeaderAddOnT_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderHeaderAddOnIsActive = 'Y' and T_OrderHeaderAddOnLabNumberOrigin is not null
|
||||
join t_orderheader on T_OrderHeaderAddOnT_OrderHeaderID = T_OrderHeaderID
|
||||
and T_OrderHeaderIsActive='Y' and date(T_OrderHeaderDate) = ?";
|
||||
$qry = $this->db->query($sql,array($date)) ;
|
||||
if ( ! $qry ) {
|
||||
$this->xlog("$type Err : " . print_r($this->db->error(),true));
|
||||
}
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$this->xlog("Proccessing $type");
|
||||
print_r($rows);
|
||||
}
|
||||
}
|
||||
$type = "lcprep";
|
||||
$sql = "select
|
||||
other_lcprep.*
|
||||
from other_lcprep
|
||||
join t_orderdetail on Other_LcprepT_OrderDetailID = T_OrderDetailID
|
||||
and Other_LcprepIsActive = 'Y' and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderDetailVerification = 'Y'
|
||||
join t_orderheaderaddon on T_OrderHeaderAddOnT_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderHeaderAddOnIsActive = 'Y' and T_OrderHeaderAddOnLabNumberOrigin is not null
|
||||
join t_orderheader on T_OrderHeaderAddOnT_OrderHeaderID = T_OrderHeaderID
|
||||
and T_OrderHeaderIsActive='Y' and date(T_OrderHeaderDate) = ?";
|
||||
$qry = $this->db->query($sql,array($date)) ;
|
||||
if ( ! $qry ) {
|
||||
$this->xlog("$type Err : " . print_r($this->db->error(),true));
|
||||
}
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$this->xlog("Proccessing $type");
|
||||
print_r($rows);
|
||||
}
|
||||
}
|
||||
$type = "mikro";
|
||||
$sql = "select T_OrderHeaderID,T_OrderDetailT_TestID,
|
||||
other_mikro.*
|
||||
from other_mikro
|
||||
join t_orderdetail on Other_MikroT_OrderDetailID = T_OrderDetailID
|
||||
and Other_MikroIsActive = 'Y' and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderDetailVerification = 'Y'
|
||||
join t_orderheaderaddon on T_OrderHeaderAddOnT_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderHeaderAddOnIsActive = 'Y' and T_OrderHeaderAddOnLabNumberOrigin is not null
|
||||
join t_orderheader on T_OrderHeaderAddOnT_OrderHeaderID = T_OrderHeaderID
|
||||
and T_OrderHeaderIsActive='Y' and date(T_OrderHeaderDate) = ?";
|
||||
$qry = $this->db->query($sql,array($date)) ;
|
||||
if ( ! $qry ) {
|
||||
$this->xlog("$type Err : " . print_r($this->db->error(),true));
|
||||
}
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$this->xlog("Proccessing $type");
|
||||
foreach($rows as $idx => $r) {
|
||||
$orderHeaderID = $r["T_OrderHeaderID"];
|
||||
$testID = $r["T_OrderDetailT_TestID"];
|
||||
$xid = $r["Other_MikroID"];
|
||||
$result = $this->get_origin($orderHeaderID, $testID);
|
||||
$rows[$idx] = array_merge($rows[$idx],$result);
|
||||
$rows[$idx] = array_merge($rows[$idx],$result);
|
||||
$rows[$idx]["other_detail"] = $this->get_origin_detail($type,$xid);
|
||||
}
|
||||
}
|
||||
print_r($rows);
|
||||
}
|
||||
$type = "papsmear";
|
||||
$sql = "select
|
||||
other_papsmear.*
|
||||
from other_papsmear
|
||||
join t_orderdetail on Other_PapsmearT_OrderDetailID = T_OrderDetailID
|
||||
and Other_PapsmearIsActive = 'Y' and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderDetailVerification = 'Y'
|
||||
join t_orderheaderaddon on T_OrderHeaderAddOnT_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderHeaderAddOnIsActive = 'Y' and T_OrderHeaderAddOnLabNumberOrigin is not null
|
||||
join t_orderheader on T_OrderHeaderAddOnT_OrderHeaderID = T_OrderHeaderID
|
||||
and T_OrderHeaderIsActive='Y' and date(T_OrderHeaderDate) = ?";
|
||||
$qry = $this->db->query($sql,array($date)) ;
|
||||
if ( ! $qry ) {
|
||||
$this->xlog("$type Err : " . print_r($this->db->error(),true));
|
||||
}
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$this->xlog("Proccessing $type");
|
||||
print_r($rows);
|
||||
}
|
||||
}
|
||||
}
|
||||
function xlog($message) {
|
||||
$dt = date("Y-m-d H:i:s");
|
||||
echo "$dt $message\n";
|
||||
}
|
||||
function post($url,$data) {
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data))
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
if ($result === false ) {
|
||||
$msg = json_encode( array("status"=>"ERR", "message" => curl_error($ch)));
|
||||
curl_close($ch);
|
||||
return $msg;
|
||||
}
|
||||
$msg = json_decode($result,true);
|
||||
curl_close($ch);
|
||||
return $msg;
|
||||
}
|
||||
}
|
||||
|
||||
104
application/controllers/tools/Outgoingref_v2-cabang.php
Normal file
104
application/controllers/tools/Outgoingref_v2-cabang.php
Normal file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
class OutgoingRef_v2 extends MY_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function process() {
|
||||
$sql = "select tx_branch_status.*, M_BranchName
|
||||
from tx_branch_status
|
||||
join m_branch on TxBranchStatusM_BranchID = M_BranchID
|
||||
where TxBranchStatusIsSent = 'N'
|
||||
and TxBranchStatusRetry < 5
|
||||
limit 0,20";
|
||||
$qry = $this->db->query($sql);
|
||||
$sql_update = "update tx_branch_status set TxBranchStatusIsSent=?,
|
||||
TxBranchStatusRetry = TxBranchStatusRetry + 1
|
||||
where TxBranchStatusID = ?";
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
foreach($rows as $r) {
|
||||
$param = $r["TxBranchStatusJson"];
|
||||
$stage = $r["TxBranchStatusStage"];
|
||||
$ipAddress = $r["TxBranchStatusM_BranchIP"];
|
||||
$branchName = $r["M_BranchName"];
|
||||
$txID = $r["TxBranchStatusID"];
|
||||
|
||||
$url = "http://$ipAddress/one-api/tools/xstatusbranch_v2/update";
|
||||
$rst = $this->post($url,$param);
|
||||
if ($rst["status"] == "OK" ) {
|
||||
$this->xlog("Update status $stage to $branchName @ $ipAddress [OK]");
|
||||
$this->db->query($sql_update, array('Y',$txID));
|
||||
} else {
|
||||
$err_msg = print_r($rst,true);
|
||||
$this->xlog("Update status $stage to $branchName @ $ipAddress [ERR] : $err_msg");
|
||||
$this->db->query($sql_update, array('N',$txID));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->xlog("Err: " . print_r($this->db->error(),true));
|
||||
}
|
||||
}
|
||||
function xlog($message) {
|
||||
$dt = date("Y-m-d H:i:s");
|
||||
echo "$dt $message\n";
|
||||
}
|
||||
function status($incomingRefID) {
|
||||
$sql = "select * from incoming_ref where incomingRefID = ?";
|
||||
$qry = $this->db->query($sql, array($incomingRefID) );
|
||||
$rows = array();
|
||||
$branchID = 0;
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if ( count($rows) > 0 ) $branchID = $rows[0]["incomingRefM_BranchID"];
|
||||
}
|
||||
$ip_address= "";
|
||||
if ($branchID > 0 ) {
|
||||
$sql = "select *
|
||||
from m_branch where M_BranchID = ?";
|
||||
$qry = $this->db->query($sql, array($branchID) );
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if(count($rows) > 0 ) $ip_address = $rows[0]["M_BranchIPAddress"];
|
||||
}
|
||||
}
|
||||
if ($ip_address == "" ) {
|
||||
echo "No IP Address from $branchID ";
|
||||
exit;
|
||||
}
|
||||
$sql = "select
|
||||
incomingRefT_RefDeliveryOrderID,
|
||||
incomingRefDetailT_OrderDetailID,
|
||||
incomingRefDetailStatus,
|
||||
T_OrderDetailResult,
|
||||
T_OrderDetailNat_NormalValueID,
|
||||
T_OrderDetailVerification,
|
||||
T_OrderDetailValidation
|
||||
from incoming_ref_detail
|
||||
join incoming_ref on incomingRefID = incomingRefDetailIncomingRefID
|
||||
and incomingRefID = ?
|
||||
left join t_orderdetail on incomingRefDetailNewT_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderDetailIsActive = 'Y' and incomingRefDetailT_TestID = T_OrderDetailT_TestID";
|
||||
$qry = $this->db->query($sql, array($incomingRefID));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$param = json_encode($rows);
|
||||
$url = "http://$ip_address/one-api/tools/xstatusbranch_v2/update";
|
||||
$result = $this->post($url,$param);
|
||||
}
|
||||
}
|
||||
function post($url,$data) {
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data))
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return json_decode($result,true);
|
||||
}
|
||||
}
|
||||
104
application/controllers/tools/Outgoingref_v2.php
Normal file
104
application/controllers/tools/Outgoingref_v2.php
Normal file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
class OutgoingRef_v2 extends MY_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function process() {
|
||||
$sql = "select tx_branch_status.*, M_BranchName
|
||||
from tx_branch_status
|
||||
join m_branch on TxBranchStatusM_BranchID = M_BranchID
|
||||
where TxBranchStatusIsSent = 'N' and TxBranchStatusRetry < 5
|
||||
limit 0,20";
|
||||
$qry = $this->db->query($sql);
|
||||
$sql_update = "update tx_branch_status set TxBranchStatusIsSent=?,
|
||||
TxBranchStatusRetry = TxBranchStatusRetry + 1
|
||||
where TxBranchStatusID = ?";
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
print_r($rows); exit;
|
||||
foreach($rows as $r) {
|
||||
$param = $r["TxBranchStatusJson"];
|
||||
$stage = $r["TxBranchStatusStage"];
|
||||
$ipAddress = $r["TxBranchStatusM_BranchIP"];
|
||||
$branchName = $r["M_BranchName"];
|
||||
$txID = $r["TxBranchStatusID"];
|
||||
|
||||
$url = "http://$ipAddress/one-api/tools/xstatusbranch_v2/update";
|
||||
$rst = $this->post($url,$param);
|
||||
if ($rst["status"] == "OK" ) {
|
||||
$this->xlog("Update status $stage to $branchName @ $ipAddress [OK]");
|
||||
$this->db->query($sql_update, array('Y',$txID));
|
||||
} else {
|
||||
$err_msg = print_r($rst,true);
|
||||
$this->xlog("Update status $stage to $branchName @ $ipAddress [ERR] : $err_msg");
|
||||
$this->db->query($sql_update, array('N',$txID));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->xlog("Err: " . print_r($this->db->error(),true));
|
||||
}
|
||||
}
|
||||
function xlog($message) {
|
||||
$dt = date("Y-m-d H:i:s");
|
||||
echo "$dt $message\n";
|
||||
}
|
||||
function status($incomingRefID) {
|
||||
$sql = "select * from incoming_ref where incomingRefID = ?";
|
||||
$qry = $this->db->query($sql, array($incomingRefID) );
|
||||
$rows = array();
|
||||
$branchID = 0;
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if ( count($rows) > 0 ) $branchID = $rows[0]["incomingRefM_BranchID"];
|
||||
}
|
||||
$ip_address= "";
|
||||
if ($branchID > 0 ) {
|
||||
$sql = "select *
|
||||
from m_branch where M_BranchID = ?";
|
||||
$qry = $this->db->query($sql, array($branchID) );
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if(count($rows) > 0 ) $ip_address = $rows[0]["M_BranchIPAddress"];
|
||||
}
|
||||
}
|
||||
if ($ip_address == "" ) {
|
||||
echo "No IP Address from $branchID ";
|
||||
exit;
|
||||
}
|
||||
$sql = "select
|
||||
incomingRefT_RefDeliveryOrderID,
|
||||
incomingRefDetailT_OrderDetailID,
|
||||
incomingRefDetailStatus,
|
||||
T_OrderDetailResult,
|
||||
T_OrderDetailNat_NormalValueID,
|
||||
T_OrderDetailVerification,
|
||||
T_OrderDetailValidation
|
||||
from incoming_ref_detail
|
||||
join incoming_ref on incomingRefID = incomingRefDetailIncomingRefID
|
||||
and incomingRefID = ?
|
||||
left join t_orderdetail on incomingRefDetailNewT_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderDetailIsActive = 'Y' and incomingRefDetailT_TestID = T_OrderDetailT_TestID";
|
||||
$qry = $this->db->query($sql, array($incomingRefID));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$param = json_encode($rows);
|
||||
$url = "http://$ip_address/one-api/tools/xstatusbranch_v2/update";
|
||||
$result = $this->post($url,$param);
|
||||
}
|
||||
}
|
||||
function post($url,$data) {
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data))
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return json_decode($result,true);
|
||||
}
|
||||
}
|
||||
418
application/controllers/tools/Outgoingref_v3-bkp.php
Normal file
418
application/controllers/tools/Outgoingref_v3-bkp.php
Normal file
@@ -0,0 +1,418 @@
|
||||
<?php
|
||||
class OutgoingRef_v3 extends MY_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function get_nonlab($type,$xid) {
|
||||
//mikro
|
||||
if ($type == "mikro") {
|
||||
$sql = "select * from other_mikro where Other_MikroID=? ";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
$result = array() ;
|
||||
if ($qry ) {
|
||||
$result["type"] = "mikro";
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$result["header"]= $rows[0];
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
$sql = "select * from other_mikrodetails where Other_MikroDetailsOther_MikroID=? and
|
||||
Other_MikroDetailsIsActive = 'Y' ";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
if ($qry) {
|
||||
$result["detail"] = $qry->result_array();
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
//cytologi
|
||||
if ($type == "cytologi") {
|
||||
$sql = "select * from other_cytologi where Other_CytologiID=? ";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
$result = array() ;
|
||||
if ($qry ) {
|
||||
$result["type"] = "cytologi";
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$result["header"]= $rows[0];
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
$sql = "select * from other_cytologidetails where Other_CytologiDetailsOther_CytologiID=? and
|
||||
Other_CytologiDetailsIsActive = 'Y' ";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
if ($qry) {
|
||||
$result["detail"] = $qry->result_array();
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
//fna
|
||||
if ($type == "fna") {
|
||||
$sql = "select * from other_fna where Other_FnaID=? ";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
$result = array() ;
|
||||
if ($qry ) {
|
||||
$result["type"] = "fna";
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$result["header"]= $rows[0];
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
$sql = "select * from other_fnadetails where Other_FnaDetailsOther_FnaID=? and
|
||||
Other_FnaDetailsIsActive = 'Y' ";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
if ($qry) {
|
||||
$result["detail"] = $qry->result_array();
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
//papsmear
|
||||
//
|
||||
if ($type == "papsmear") {
|
||||
$sql = "select * from other_papsmear where Other_PapSmearID=? ";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
$result = array() ;
|
||||
if ($qry ) {
|
||||
$result["type"] = "papsmear";
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$result["header"]= $rows[0];
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
$result["detail"] = array();
|
||||
//bahan
|
||||
$sql = "select * from other_papsmearbahan where Other_PapSmearBahanOther_PapSmearID = ?
|
||||
and Other_PapSmearBahanIsActive='Y'";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
if ($qry) {
|
||||
$result["detail"]["bahan"] = $qry->result_array();
|
||||
}
|
||||
//category
|
||||
$sql = "select * from other_papsmearcategory
|
||||
where Other_PapsmearCategoryOther_PapSmearID = ?
|
||||
and Other_PapsmearCategoryIsActive='Y'";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
if ($qry) {
|
||||
$result["detail"]["category"] = $qry->result_array();
|
||||
}
|
||||
// check
|
||||
$sql = "select * from other_papsmearcheck
|
||||
where Other_PapSmearCheckOther_PapSmearID= ?
|
||||
and Other_PapSmearCheckIsActive='Y'";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
if ($qry) {
|
||||
$result["detail"]["check"] = $qry->result_array();
|
||||
}
|
||||
// details
|
||||
$sql = "select * from other_papsmeardetails
|
||||
where Other_PapSmearDetailsOther_PapSmearID= ?
|
||||
and Other_PapSmearDetailsIsActive='Y'";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
if ($qry) {
|
||||
$result["detail"]["details"] = $qry->result_array();
|
||||
}
|
||||
// maturasi
|
||||
$sql = "select * from other_papsmearmaturasi
|
||||
where Other_PapSmearMaturasiOther_PapSmearID = ?
|
||||
and Other_PapSmearMaturasiIsActive='Y'";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
if ($qry) {
|
||||
$result["detail"]["maturasi"] = $qry->result_array();
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
//lcprep
|
||||
//
|
||||
if ($type == "lcprep") {
|
||||
$sql = "select * from other_lcprep where Other_LcprepID=? ";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
$result = array() ;
|
||||
if ($qry ) {
|
||||
$result["type"] = "lcprep";
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$result["header"]= $rows[0];
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
$result["detail"] = array();
|
||||
//adekuasi
|
||||
$sql = "select * from other_lcprepadekuasi where Other_LcprepAdekuasiOther_LcprepID = ?
|
||||
and Other_LcprepAdekuasiIsActive='Y'";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
if ($qry) {
|
||||
$result["detail"]["adekuasi"] = $qry->result_array();
|
||||
}
|
||||
//interpretasi
|
||||
$sql = "select * from other_lcprepinterpretasi
|
||||
where Other_PapsmearInterpretasiOther_LcprepID = ?
|
||||
and Other_PapsmearInterpretasiIsActive='Y'";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
if ($qry) {
|
||||
$result["detail"]["interpretasi"] = $qry->result_array();
|
||||
}
|
||||
// details
|
||||
$sql = "select * from other_lcprepdetails
|
||||
where Other_LcprepDetailsOther_LcprepID= ?
|
||||
and Other_LcprepDetailsIsActive='Y'";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
if ($qry) {
|
||||
$result["detail"]["details"] = $qry->result_array();
|
||||
}
|
||||
// kategoriumum
|
||||
$sql = "select * from other_lcprepkategoriumum
|
||||
where Other_LcprepKategoriUmumOther_LcprepID = ?
|
||||
and Other_LcprepKategoriUmumIsActive='Y'";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
if ($qry) {
|
||||
$result["detail"]["kategoriumum"] = $qry->result_array();
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
function process_nonlab($incomingRefDetailID) {
|
||||
//mikro
|
||||
$sql = "select ifnull(Other_MikroID,0) mikroID
|
||||
from incoming_ref_detail
|
||||
join t_orderdetail on T_OrderDetailT_OrderHeaderID = incomingRefDetailNewT_OrderHeaderID
|
||||
and T_OrderDetailT_TestID = incomingRefDetailT_TestID and T_OrderDetailIsActive = 'Y'
|
||||
left join other_mikro on T_OrderDetailID = Other_MikroT_OrderDetailID and
|
||||
Other_MikroIsActive = 'Y'
|
||||
where incomingRefDetailID = ? ";
|
||||
$qry = $this->db->query($sql,array($incomingRefDetailID));
|
||||
if ( ! $qry ) {
|
||||
echo "ERR : process_nonlab : $incomingRefDetailID : " . print_r($this->db->error(),true) . "\n";
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if ( count($rows) > 0 ) {
|
||||
$mikroID = $rows[0]["mikroID"];
|
||||
$nl = "";
|
||||
if ($mikroID > 0 ) {
|
||||
$nl = $this->get_nonlab("mikro", $mikroID);
|
||||
return $nl;
|
||||
}
|
||||
}
|
||||
|
||||
//papsmear
|
||||
$sql = "select ifnull(Other_PapSmearID,0) papsmearID
|
||||
from incoming_ref_detail
|
||||
join t_orderdetail on T_OrderDetailT_OrderHeaderID = incomingRefDetailNewT_OrderHeaderID
|
||||
and T_OrderDetailT_TestID = incomingRefDetailT_TestID and T_OrderDetailIsActive = 'Y'
|
||||
left join other_papsmear on T_OrderDetailID = Other_PapSmearT_OrderDetailID and
|
||||
Other_PapSmearIsActive = 'Y'
|
||||
where incomingRefDetailID = ? ";
|
||||
$qry = $this->db->query($sql,array($incomingRefDetailID));
|
||||
if ( ! $qry ) {
|
||||
echo "ERR : process_nonlab : $incomingRefDetailID : " . print_r($this->db->error(),true) . "\n";
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if ( count($rows) > 0 ) {
|
||||
$papsmearID = $rows[0]["papsmearID"];
|
||||
$nl = "";
|
||||
if ($papsmear> 0 ) {
|
||||
$nl = $this->get_nonlab("papsmear", $papsmearID);
|
||||
return $nl;
|
||||
}
|
||||
}
|
||||
|
||||
//lcprep
|
||||
$sql = "select ifnull(Other_LcprepID,0) lcprepID
|
||||
from incoming_ref_detail
|
||||
join t_orderdetail on T_OrderDetailT_OrderHeaderID = incomingRefDetailNewT_OrderHeaderID
|
||||
and T_OrderDetailT_TestID = incomingRefDetailT_TestID and T_OrderDetailIsActive = 'Y'
|
||||
left join other_lcprep on T_OrderDetailID = Other_LcprepT_OrderDetailID and
|
||||
Other_LcprepIsActive = 'Y'
|
||||
where incomingRefDetailID = ? ";
|
||||
$qry = $this->db->query($sql,array($incomingRefDetailID));
|
||||
if ( ! $qry ) {
|
||||
echo "ERR : process_nonlab : $incomingRefDetailID : " . print_r($this->db->error(),true) . "\n";
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if ( count($rows) > 0 ) {
|
||||
$lcprepID = $rows[0]["lcprepID"];
|
||||
$nl = "";
|
||||
if ($lcprepID > 0 ) {
|
||||
$nl = $this->get_nonlab("lcprep", $lcprepID);
|
||||
return $nl;
|
||||
}
|
||||
}
|
||||
|
||||
//fna
|
||||
$sql = "select ifnull(Other_FnaID,0) fnaID
|
||||
from incoming_ref_detail
|
||||
join t_orderdetail on T_OrderDetailT_OrderHeaderID = incomingRefDetailNewT_OrderHeaderID
|
||||
and T_OrderDetailT_TestID = incomingRefDetailT_TestID and T_OrderDetailIsActive = 'Y'
|
||||
left join other_fna on T_OrderDetailID = Other_FnaT_OrderDetailID and
|
||||
Other_FnaIsActive = 'Y'
|
||||
where incomingRefDetailID = ? ";
|
||||
$qry = $this->db->query($sql,array($incomingRefDetailID));
|
||||
if ( ! $qry ) {
|
||||
echo "ERR : process_nonlab : $incomingRefDetailID : " . print_r($this->db->error(),true) . "\n";
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if ( count($rows) > 0 ) {
|
||||
$fnaID = $rows[0]["fnaID"];
|
||||
$nl = "";
|
||||
if ($fnaID > 0 ) {
|
||||
$nl = $this->get_nonlab("fna", $fnaID);
|
||||
return $nl;
|
||||
}
|
||||
}
|
||||
//
|
||||
//cytology
|
||||
$sql = "select ifnull(Other_CytologiID,0) cytologiID
|
||||
from incoming_ref_detail
|
||||
join t_orderdetail on T_OrderDetailT_OrderHeaderID = incomingRefDetailNewT_OrderHeaderID
|
||||
and T_OrderDetailT_TestID = incomingRefDetailT_TestID and T_OrderDetailIsActive = 'Y'
|
||||
left join other_cytologi on T_OrderDetailID = Other_CytologiT_OrderDetailID and
|
||||
Other_CytologiIsActive = 'Y'
|
||||
where incomingRefDetailID = ? ";
|
||||
$qry = $this->db->query($sql,array($incomingRefDetailID));
|
||||
if ( ! $qry ) {
|
||||
echo "ERR : process_nonlab : $incomingRefDetailID : " . print_r($this->db->error(),true) . "\n";
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if ( count($rows) > 0 ) {
|
||||
$cytologiID = $rows[0]["cytologiID"];
|
||||
$nl = "";
|
||||
if ($cytologiID > 0 ) {
|
||||
$nl = $this->get_nonlab("cytologi", $cytologiID);
|
||||
return $nl;
|
||||
}
|
||||
}
|
||||
}
|
||||
function process() {
|
||||
$sql = "select tx_branch_status.*, M_BranchName
|
||||
from tx_branch_status
|
||||
join m_branch on TxBranchStatusM_BranchID = M_BranchID
|
||||
where TxBranchStatusIsSent = 'N' and TxBranchStatusRetry < 5
|
||||
limit 0,20";
|
||||
$qry = $this->db->query($sql);
|
||||
$sql_update = "update tx_branch_status set TxBranchStatusIsSent=?,
|
||||
TxBranchStatusRetry = TxBranchStatusRetry + 1
|
||||
where TxBranchStatusID = ?";
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
foreach($rows as $r) {
|
||||
$param = $r["TxBranchStatusJson"];
|
||||
$stage = $r["TxBranchStatusStage"];
|
||||
$ipAddress = $r["TxBranchStatusM_BranchIP"];
|
||||
$branchName = $r["M_BranchName"];
|
||||
$txID = $r["TxBranchStatusID"];
|
||||
if ($stage == "VALIDATION") {
|
||||
//cek nonlab
|
||||
$j_param = json_decode($param,true);
|
||||
foreach($j_param as $idx => $j ) {
|
||||
if (isset($j["incomingRefDetailID"])) {
|
||||
$nonlab_result = $this->process_nonlab( $j["incomingRefDetailID"] );
|
||||
if ($nonlab_result != array() ) {
|
||||
$j_param[$idx]["nonlab_result"] = $nonlab_result;
|
||||
$param = json_encode($j_param);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$url = "http://$ipAddress/one-api/tools/xstatusbranch_v3/update";
|
||||
$rst = $this->post($url,$param);
|
||||
if ($rst["status"] == "OK" ) {
|
||||
$this->xlog("Update status $stage to $branchName @ $ipAddress [OK]");
|
||||
$this->db->query($sql_update, array('Y',$txID));
|
||||
} else {
|
||||
$err_msg = print_r($rst,true);
|
||||
$this->xlog("Update status $stage to $branchName @ $ipAddress [ERR] : $err_msg");
|
||||
$this->db->query($sql_update, array('N',$txID));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->xlog("Err: " . print_r($this->db->error(),true));
|
||||
}
|
||||
}
|
||||
function xlog($message) {
|
||||
$dt = date("Y-m-d H:i:s");
|
||||
echo "$dt $message\n";
|
||||
}
|
||||
function status($incomingRefID) {
|
||||
$sql = "select * from incoming_ref where incomingRefID = ?";
|
||||
$qry = $this->db->query($sql, array($incomingRefID) );
|
||||
$rows = array();
|
||||
$branchID = 0;
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if ( count($rows) > 0 ) $branchID = $rows[0]["incomingRefM_BranchID"];
|
||||
}
|
||||
$ip_address= "";
|
||||
if ($branchID > 0 ) {
|
||||
$sql = "select *
|
||||
from m_branch where M_BranchID = ?";
|
||||
$qry = $this->db->query($sql, array($branchID) );
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if(count($rows) > 0 ) $ip_address = $rows[0]["M_BranchIPAddress"];
|
||||
}
|
||||
}
|
||||
if ($ip_address == "" ) {
|
||||
echo "No IP Address from $branchID ";
|
||||
exit;
|
||||
}
|
||||
$sql = "select
|
||||
incomingRefT_RefDeliveryOrderID,
|
||||
incomingRefDetailT_OrderDetailID,
|
||||
incomingRefDetailStatus,
|
||||
T_OrderDetailResult,
|
||||
T_OrderDetailNat_NormalValueID,
|
||||
T_OrderDetailVerification,
|
||||
T_OrderDetailValidation
|
||||
from incoming_ref_detail
|
||||
join incoming_ref on incomingRefID = incomingRefDetailIncomingRefID
|
||||
and incomingRefID = ?
|
||||
left join t_orderdetail on incomingRefDetailNewT_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderDetailIsActive = 'Y' and incomingRefDetailT_TestID = T_OrderDetailT_TestID";
|
||||
$qry = $this->db->query($sql, array($incomingRefID));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$param = json_encode($rows);
|
||||
$url = "http://$ip_address/one-api/tools/xstatusbranch_v2/update";
|
||||
$result = $this->post($url,$param);
|
||||
}
|
||||
}
|
||||
function post($url,$data) {
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data))
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
if ($result === false ) {
|
||||
return array("status" => "ERR" ,
|
||||
"message" => curl_error($ch)
|
||||
);
|
||||
}
|
||||
$rst = json_decode($result,true);
|
||||
return $rst;
|
||||
}
|
||||
}
|
||||
418
application/controllers/tools/Outgoingref_v3.php
Normal file
418
application/controllers/tools/Outgoingref_v3.php
Normal file
@@ -0,0 +1,418 @@
|
||||
<?php
|
||||
class OutgoingRef_v3 extends MY_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function get_nonlab($type,$xid) {
|
||||
//mikro
|
||||
if ($type == "mikro") {
|
||||
$sql = "select * from other_mikro where Other_MikroID=? ";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
$result = array() ;
|
||||
if ($qry ) {
|
||||
$result["type"] = "mikro";
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$result["header"]= $rows[0];
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
$sql = "select * from other_mikrodetails where Other_MikroDetailsOther_MikroID=? and
|
||||
Other_MikroDetailsIsActive = 'Y' ";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
if ($qry) {
|
||||
$result["detail"] = $qry->result_array();
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
//cytologi
|
||||
if ($type == "cytologi") {
|
||||
$sql = "select * from other_cytologi where Other_CytologiID=? ";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
$result = array() ;
|
||||
if ($qry ) {
|
||||
$result["type"] = "cytologi";
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$result["header"]= $rows[0];
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
$sql = "select * from other_cytologidetails where Other_CytologiDetailsOther_CytologiID=? and
|
||||
Other_CytologiDetailsIsActive = 'Y' ";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
if ($qry) {
|
||||
$result["detail"] = $qry->result_array();
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
//fna
|
||||
if ($type == "fna") {
|
||||
$sql = "select * from other_fna where Other_FnaID=? ";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
$result = array() ;
|
||||
if ($qry ) {
|
||||
$result["type"] = "fna";
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$result["header"]= $rows[0];
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
$sql = "select * from other_fnadetails where Other_FnaDetailsOther_FnaID=? and
|
||||
Other_FnaDetailsIsActive = 'Y' ";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
if ($qry) {
|
||||
$result["detail"] = $qry->result_array();
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
//papsmear
|
||||
//
|
||||
if ($type == "papsmear") {
|
||||
$sql = "select * from other_papsmear where Other_PapSmearID=? ";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
$result = array() ;
|
||||
if ($qry ) {
|
||||
$result["type"] = "papsmear";
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$result["header"]= $rows[0];
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
$result["detail"] = array();
|
||||
//bahan
|
||||
$sql = "select * from other_papsmearbahan where Other_PapSmearBahanOther_PapSmearID = ?
|
||||
and Other_PapSmearBahanIsActive='Y'";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
if ($qry) {
|
||||
$result["detail"]["bahan"] = $qry->result_array();
|
||||
}
|
||||
//category
|
||||
$sql = "select * from other_papsmearcategory
|
||||
where Other_PapsmearCategoryOther_PapSmearID = ?
|
||||
and Other_PapsmearCategoryIsActive='Y'";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
if ($qry) {
|
||||
$result["detail"]["category"] = $qry->result_array();
|
||||
}
|
||||
// check
|
||||
$sql = "select * from other_papsmearcheck
|
||||
where Other_PapSmearCheckOther_PapSmearID= ?
|
||||
and Other_PapSmearCheckIsActive='Y'";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
if ($qry) {
|
||||
$result["detail"]["check"] = $qry->result_array();
|
||||
}
|
||||
// details
|
||||
$sql = "select * from other_papsmeardetails
|
||||
where Other_PapSmearDetailsOther_PapSmearID= ?
|
||||
and Other_PapSmearDetailsIsActive='Y'";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
if ($qry) {
|
||||
$result["detail"]["details"] = $qry->result_array();
|
||||
}
|
||||
// maturasi
|
||||
$sql = "select * from other_papsmearmaturasi
|
||||
where Other_PapSmearMaturasiOther_PapSmearID = ?
|
||||
and Other_PapSmearMaturasiIsActive='Y'";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
if ($qry) {
|
||||
$result["detail"]["maturasi"] = $qry->result_array();
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
//lcprep
|
||||
//
|
||||
if ($type == "lcprep") {
|
||||
$sql = "select * from other_lcprep where Other_LcprepID=? ";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
$result = array() ;
|
||||
if ($qry ) {
|
||||
$result["type"] = "lcprep";
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$result["header"]= $rows[0];
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
$result["detail"] = array();
|
||||
//adekuasi
|
||||
$sql = "select * from other_lcprepadekuasi where Other_LcprepAdekuasiOther_LcprepID = ?
|
||||
and Other_LcprepAdekuasiIsActive='Y'";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
if ($qry) {
|
||||
$result["detail"]["adekuasi"] = $qry->result_array();
|
||||
}
|
||||
//interpretasi
|
||||
$sql = "select * from other_lcprepinterpretasi
|
||||
where Other_PapsmearInterpretasiOther_LcprepID = ?
|
||||
and Other_PapsmearInterpretasiIsActive='Y'";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
if ($qry) {
|
||||
$result["detail"]["interpretasi"] = $qry->result_array();
|
||||
}
|
||||
// details
|
||||
$sql = "select * from other_lcprepdetails
|
||||
where Other_LcprepDetailsOther_LcprepID= ?
|
||||
and Other_LcprepDetailsIsActive='Y'";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
if ($qry) {
|
||||
$result["detail"]["details"] = $qry->result_array();
|
||||
}
|
||||
// kategoriumum
|
||||
$sql = "select * from other_lcprepkategoriumum
|
||||
where Other_LcprepKategoriUmumOther_LcprepID = ?
|
||||
and Other_LcprepKategoriUmumIsActive='Y'";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
if ($qry) {
|
||||
$result["detail"]["kategoriumum"] = $qry->result_array();
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
function process_nonlab($incomingRefDetailID) {
|
||||
//mikro
|
||||
$sql = "select ifnull(Other_MikroID,0) mikroID
|
||||
from incoming_ref_detail
|
||||
join t_orderdetail on T_OrderDetailT_OrderHeaderID = incomingRefDetailNewT_OrderHeaderID
|
||||
and T_OrderDetailT_TestID = incomingRefDetailT_TestID and T_OrderDetailIsActive = 'Y'
|
||||
left join other_mikro on T_OrderDetailID = Other_MikroT_OrderDetailID and
|
||||
Other_MikroIsActive = 'Y'
|
||||
where incomingRefDetailID = ? ";
|
||||
$qry = $this->db->query($sql,array($incomingRefDetailID));
|
||||
if ( ! $qry ) {
|
||||
echo "ERR : process_nonlab : $incomingRefDetailID : " . print_r($this->db->error(),true) . "\n";
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if ( count($rows) > 0 ) {
|
||||
$mikroID = $rows[0]["mikroID"];
|
||||
$nl = "";
|
||||
if ($mikroID > 0 ) {
|
||||
$nl = $this->get_nonlab("mikro", $mikroID);
|
||||
return $nl;
|
||||
}
|
||||
}
|
||||
|
||||
//papsmear
|
||||
$sql = "select ifnull(Other_PapSmearID,0) papsmearID
|
||||
from incoming_ref_detail
|
||||
join t_orderdetail on T_OrderDetailT_OrderHeaderID = incomingRefDetailNewT_OrderHeaderID
|
||||
and T_OrderDetailT_TestID = incomingRefDetailT_TestID and T_OrderDetailIsActive = 'Y'
|
||||
left join other_papsmear on T_OrderDetailID = Other_PapSmearT_OrderDetailID and
|
||||
Other_PapSmearIsActive = 'Y'
|
||||
where incomingRefDetailID = ? ";
|
||||
$qry = $this->db->query($sql,array($incomingRefDetailID));
|
||||
if ( ! $qry ) {
|
||||
echo "ERR : process_nonlab : $incomingRefDetailID : " . print_r($this->db->error(),true) . "\n";
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if ( count($rows) > 0 ) {
|
||||
$papsmearID = $rows[0]["papsmearID"];
|
||||
$nl = "";
|
||||
if ($papsmear> 0 ) {
|
||||
$nl = $this->get_nonlab("papsmear", $papsmearID);
|
||||
return $nl;
|
||||
}
|
||||
}
|
||||
|
||||
//lcprep
|
||||
$sql = "select ifnull(Other_LcprepID,0) lcprepID
|
||||
from incoming_ref_detail
|
||||
join t_orderdetail on T_OrderDetailT_OrderHeaderID = incomingRefDetailNewT_OrderHeaderID
|
||||
and T_OrderDetailT_TestID = incomingRefDetailT_TestID and T_OrderDetailIsActive = 'Y'
|
||||
left join other_lcprep on T_OrderDetailID = Other_LcprepT_OrderDetailID and
|
||||
Other_LcprepIsActive = 'Y'
|
||||
where incomingRefDetailID = ? ";
|
||||
$qry = $this->db->query($sql,array($incomingRefDetailID));
|
||||
if ( ! $qry ) {
|
||||
echo "ERR : process_nonlab : $incomingRefDetailID : " . print_r($this->db->error(),true) . "\n";
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if ( count($rows) > 0 ) {
|
||||
$lcprepID = $rows[0]["lcprepID"];
|
||||
$nl = "";
|
||||
if ($lcprepID > 0 ) {
|
||||
$nl = $this->get_nonlab("lcprep", $lcprepID);
|
||||
return $nl;
|
||||
}
|
||||
}
|
||||
|
||||
//fna
|
||||
$sql = "select ifnull(Other_FnaID,0) fnaID
|
||||
from incoming_ref_detail
|
||||
join t_orderdetail on T_OrderDetailT_OrderHeaderID = incomingRefDetailNewT_OrderHeaderID
|
||||
and T_OrderDetailT_TestID = incomingRefDetailT_TestID and T_OrderDetailIsActive = 'Y'
|
||||
left join other_fna on T_OrderDetailID = Other_FnaT_OrderDetailID and
|
||||
Other_FnaIsActive = 'Y'
|
||||
where incomingRefDetailID = ? ";
|
||||
$qry = $this->db->query($sql,array($incomingRefDetailID));
|
||||
if ( ! $qry ) {
|
||||
echo "ERR : process_nonlab : $incomingRefDetailID : " . print_r($this->db->error(),true) . "\n";
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if ( count($rows) > 0 ) {
|
||||
$fnaID = $rows[0]["fnaID"];
|
||||
$nl = "";
|
||||
if ($fnaID > 0 ) {
|
||||
$nl = $this->get_nonlab("fna", $fnaID);
|
||||
return $nl;
|
||||
}
|
||||
}
|
||||
//
|
||||
//cytology
|
||||
$sql = "select ifnull(Other_CytologiID,0) cytologiID
|
||||
from incoming_ref_detail
|
||||
join t_orderdetail on T_OrderDetailT_OrderHeaderID = incomingRefDetailNewT_OrderHeaderID
|
||||
and T_OrderDetailT_TestID = incomingRefDetailT_TestID and T_OrderDetailIsActive = 'Y'
|
||||
left join other_cytologi on T_OrderDetailID = Other_CytologiT_OrderDetailID and
|
||||
Other_CytologiIsActive = 'Y'
|
||||
where incomingRefDetailID = ? ";
|
||||
$qry = $this->db->query($sql,array($incomingRefDetailID));
|
||||
if ( ! $qry ) {
|
||||
echo "ERR : process_nonlab : $incomingRefDetailID : " . print_r($this->db->error(),true) . "\n";
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if ( count($rows) > 0 ) {
|
||||
$cytologiID = $rows[0]["cytologiID"];
|
||||
$nl = "";
|
||||
if ($cytologiID > 0 ) {
|
||||
$nl = $this->get_nonlab("cytologi", $cytologiID);
|
||||
return $nl;
|
||||
}
|
||||
}
|
||||
}
|
||||
function process() {
|
||||
$sql = "select tx_branch_status.*, M_BranchName
|
||||
from tx_branch_status
|
||||
join m_branch on TxBranchStatusM_BranchID = M_BranchID
|
||||
where TxBranchStatusIsSent = 'N' and TxBranchStatusRetry < 5
|
||||
limit 0,20";
|
||||
$qry = $this->db->query($sql);
|
||||
$sql_update = "update tx_branch_status set TxBranchStatusIsSent=?,
|
||||
TxBranchStatusRetry = TxBranchStatusRetry + 1
|
||||
where TxBranchStatusID = ?";
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
foreach($rows as $r) {
|
||||
$param = $r["TxBranchStatusJson"];
|
||||
$stage = $r["TxBranchStatusStage"];
|
||||
$ipAddress = $r["TxBranchStatusM_BranchIP"];
|
||||
$branchName = $r["M_BranchName"];
|
||||
$txID = $r["TxBranchStatusID"];
|
||||
if ($stage == "VALIDATION") {
|
||||
//cek nonlab
|
||||
$j_param = json_decode($param,true);
|
||||
foreach($j_param as $idx => $j ) {
|
||||
if (isset($j["incomingRefDetailID"])) {
|
||||
$nonlab_result = $this->process_nonlab( $j["incomingRefDetailID"] );
|
||||
if ($nonlab_result != array() ) {
|
||||
$j_param[$idx]["nonlab_result"] = $nonlab_result;
|
||||
$param = json_encode($j_param);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$url = "http://$ipAddress/one-api/tools/xstatusbranch_v3/update";
|
||||
$rst = $this->post($url,$param);
|
||||
if ($rst["status"] == "OK" ) {
|
||||
$this->xlog("Update status $stage to $branchName @ $ipAddress [OK]");
|
||||
$this->db->query($sql_update, array('Y',$txID));
|
||||
} else {
|
||||
$err_msg = print_r($rst,true);
|
||||
$this->xlog("Update status $stage to $branchName @ $ipAddress [ERR] : $err_msg");
|
||||
$this->db->query($sql_update, array('N',$txID));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->xlog("Err: " . print_r($this->db->error(),true));
|
||||
}
|
||||
}
|
||||
function xlog($message) {
|
||||
$dt = date("Y-m-d H:i:s");
|
||||
echo "$dt $message\n";
|
||||
}
|
||||
function status($incomingRefID) {
|
||||
$sql = "select * from incoming_ref where incomingRefID = ?";
|
||||
$qry = $this->db->query($sql, array($incomingRefID) );
|
||||
$rows = array();
|
||||
$branchID = 0;
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if ( count($rows) > 0 ) $branchID = $rows[0]["incomingRefM_BranchID"];
|
||||
}
|
||||
$ip_address= "";
|
||||
if ($branchID > 0 ) {
|
||||
$sql = "select *
|
||||
from m_branch where M_BranchID = ?";
|
||||
$qry = $this->db->query($sql, array($branchID) );
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if(count($rows) > 0 ) $ip_address = $rows[0]["M_BranchIPAddress"];
|
||||
}
|
||||
}
|
||||
if ($ip_address == "" ) {
|
||||
echo "No IP Address from $branchID ";
|
||||
exit;
|
||||
}
|
||||
$sql = "select
|
||||
incomingRefT_RefDeliveryOrderID,
|
||||
incomingRefDetailT_OrderDetailID,
|
||||
incomingRefDetailStatus,
|
||||
T_OrderDetailResult,
|
||||
T_OrderDetailNat_NormalValueID,
|
||||
T_OrderDetailVerification,
|
||||
T_OrderDetailValidation
|
||||
from incoming_ref_detail
|
||||
join incoming_ref on incomingRefID = incomingRefDetailIncomingRefID
|
||||
and incomingRefID = ?
|
||||
left join t_orderdetail on incomingRefDetailNewT_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderDetailIsActive = 'Y' and incomingRefDetailT_TestID = T_OrderDetailT_TestID";
|
||||
$qry = $this->db->query($sql, array($incomingRefID));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$param = json_encode($rows);
|
||||
$url = "http://$ip_address/one-api/tools/xstatusbranch_v2/update";
|
||||
$result = $this->post($url,$param);
|
||||
}
|
||||
}
|
||||
function post($url,$data) {
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data))
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
if ($result === false ) {
|
||||
return array("status" => "ERR" ,
|
||||
"message" => curl_error($ch)
|
||||
);
|
||||
}
|
||||
$rst = json_decode($result,true);
|
||||
return $rst;
|
||||
}
|
||||
}
|
||||
402
application/controllers/tools/Outgoingref_v4.php
Normal file
402
application/controllers/tools/Outgoingref_v4.php
Normal file
@@ -0,0 +1,402 @@
|
||||
<?php
|
||||
class OutgoingRef_v4 extends MY_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function get_nonlab($type,$xid) {
|
||||
//mikro
|
||||
if ($type == "mikro") {
|
||||
$sql = "select * from other_mikro where Other_MikroID=? ";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
$result = array() ;
|
||||
if ($qry ) {
|
||||
$result["type"] = "mikro";
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$result["header"]= $rows[0];
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
$sql = "select * from other_mikrodetails where Other_MikroDetailsOther_MikroID=? and
|
||||
Other_MikroDetailsIsActive = 'Y' ";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
if ($qry) {
|
||||
$result["detail"] = $qry->result_array();
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
//cytologi
|
||||
if ($type == "cytologi") {
|
||||
$sql = "select * from other_cytologi where Other_CytologiID=? ";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
$result = array() ;
|
||||
if ($qry ) {
|
||||
$result["type"] = "cytologi";
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$result["header"]= $rows[0];
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
$sql = "select * from other_cytologidetails where Other_CytologiDetailsOther_CytologiID=? and
|
||||
Other_CytologiDetailsIsActive = 'Y' ";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
if ($qry) {
|
||||
$result["detail"] = $qry->result_array();
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
//fna
|
||||
if ($type == "fna") {
|
||||
$sql = "select * from other_fna where Other_FnaID=? ";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
$result = array() ;
|
||||
if ($qry ) {
|
||||
$result["type"] = "fna";
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$result["header"]= $rows[0];
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
$sql = "select * from other_fnadetails where Other_FnaDetailsOther_FnaID=? and
|
||||
Other_FnaDetailsIsActive = 'Y' ";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
if ($qry) {
|
||||
$result["detail"] = $qry->result_array();
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
//papsmear
|
||||
//
|
||||
if ($type == "papsmear") {
|
||||
$sql = "select * from other_papsmear where Other_PapSmearID=? ";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
$result = array() ;
|
||||
if ($qry ) {
|
||||
$result["type"] = "papsmear";
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$result["header"]= $rows[0];
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
$result["detail"] = array();
|
||||
//bahan
|
||||
$sql = "select * from other_papsmearbahan where Other_PapSmearBahanOther_PapSmearID = ?
|
||||
and Other_PapSmearBahanIsActive='Y'";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
if ($qry) {
|
||||
$result["detail"]["bahan"] = $qry->result_array();
|
||||
}
|
||||
//category
|
||||
$sql = "select * from other_papsmearcategory
|
||||
where Other_PapsmearCategoryOther_PapSmearID = ?
|
||||
and Other_PapsmearCategoryIsActive='Y'";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
if ($qry) {
|
||||
$result["detail"]["category"] = $qry->result_array();
|
||||
}
|
||||
// check
|
||||
$sql = "select * from other_papsmearcheck
|
||||
where Other_PapSmearCheckOther_PapSmearID= ?
|
||||
and Other_PapSmearCheckIsActive='Y'";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
if ($qry) {
|
||||
$result["detail"]["check"] = $qry->result_array();
|
||||
}
|
||||
// details
|
||||
$sql = "select * from other_papsmeardetails
|
||||
where Other_PapSmearDetailsOther_PapSmearID= ?
|
||||
and Other_PapSmearDetailsIsActive='Y'";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
if ($qry) {
|
||||
$result["detail"]["details"] = $qry->result_array();
|
||||
}
|
||||
// maturasi
|
||||
$sql = "select * from other_papsmearmaturasi
|
||||
where Other_PapSmearMaturasiOther_PapSmearID = ?
|
||||
and Other_PapSmearMaturasiIsActive='Y'";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
if ($qry) {
|
||||
$result["detail"]["maturasi"] = $qry->result_array();
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
//lcprep
|
||||
//
|
||||
if ($type == "lcprep") {
|
||||
$sql = "select * from other_lcprep where Other_LcprepID=? ";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
$result = array() ;
|
||||
if ($qry ) {
|
||||
$result["type"] = "lcprep";
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$result["header"]= $rows[0];
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
$result["detail"] = array();
|
||||
//adekuasi
|
||||
$sql = "select * from other_lcprepadekuasi where Other_LcprepAdekuasiOther_LcprepID = ?
|
||||
and Other_LcprepAdekuasiIsActive='Y'";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
if ($qry) {
|
||||
$result["detail"]["adekuasi"] = $qry->result_array();
|
||||
}
|
||||
//interpretasi
|
||||
$sql = "select * from other_lcprepinterpretasi
|
||||
where Other_PapsmearInterpretasiOther_LcprepID = ?
|
||||
and Other_PapsmearInterpretasiIsActive='Y'";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
if ($qry) {
|
||||
$result["detail"]["interpretasi"] = $qry->result_array();
|
||||
}
|
||||
// details
|
||||
$sql = "select * from other_lcprepdetails
|
||||
where Other_LcprepDetailsOther_LcprepID= ?
|
||||
and Other_LcprepDetailsIsActive='Y'";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
if ($qry) {
|
||||
$result["detail"]["details"] = $qry->result_array();
|
||||
}
|
||||
// kategoriumum
|
||||
$sql = "select * from other_lcprepkategoriumum
|
||||
where Other_LcprepKategoriUmumOther_LcprepID = ?
|
||||
and Other_LcprepKategoriUmumIsActive='Y'";
|
||||
$qry = $this->db->query($sql, array($xid));
|
||||
if ($qry) {
|
||||
$result["detail"]["kategoriumum"] = $qry->result_array();
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
function process_nonlab($incomingRefDetailID) {
|
||||
//mikro
|
||||
$sql = "select ifnull(Other_MikroID,0) mikroID
|
||||
from incoming_ref_detail
|
||||
join t_orderdetail on T_OrderDetailT_OrderHeaderID = incomingRefDetailNewT_OrderHeaderID
|
||||
and T_OrderDetailT_TestID = incomingRefDetailT_TestID and T_OrderDetailIsActive = 'Y'
|
||||
left join other_mikro on T_OrderDetailID = Other_MikroT_OrderDetailID and
|
||||
Other_MikroIsActive = 'Y'
|
||||
where incomingRefDetailID = ? ";
|
||||
$qry = $this->db->query($sql,array($incomingRefDetailID));
|
||||
if ( ! $qry ) {
|
||||
echo "ERR : process_nonlab : $incomingRefDetailID : " . print_r($this->db->error(),true) . "\n";
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if ( count($rows) > 0 ) {
|
||||
$mikroID = $rows[0]["mikroID"];
|
||||
$nl = "";
|
||||
if ($mikroID > 0 ) {
|
||||
$nl = $this->get_nonlab("mikro", $mikroID);
|
||||
return $nl;
|
||||
}
|
||||
}
|
||||
|
||||
//papsmear
|
||||
$sql = "select ifnull(Other_PapSmearID,0) papsmearID
|
||||
from incoming_ref_detail
|
||||
join t_orderdetail on T_OrderDetailT_OrderHeaderID = incomingRefDetailNewT_OrderHeaderID
|
||||
and T_OrderDetailT_TestID = incomingRefDetailT_TestID and T_OrderDetailIsActive = 'Y'
|
||||
left join other_papsmear on T_OrderDetailID = Other_PapSmearT_OrderDetailID and
|
||||
Other_PapSmearIsActive = 'Y'
|
||||
where incomingRefDetailID = ? ";
|
||||
$qry = $this->db->query($sql,array($incomingRefDetailID));
|
||||
if ( ! $qry ) {
|
||||
echo "ERR : process_nonlab : $incomingRefDetailID : " . print_r($this->db->error(),true) . "\n";
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if ( count($rows) > 0 ) {
|
||||
$papsmearID = $rows[0]["papsmearID"];
|
||||
$nl = "";
|
||||
if ($papsmear> 0 ) {
|
||||
$nl = $this->get_nonlab("papsmear", $papsmearID);
|
||||
return $nl;
|
||||
}
|
||||
}
|
||||
|
||||
//lcprep
|
||||
$sql = "select ifnull(Other_LcprepID,0) lcprepID
|
||||
from incoming_ref_detail
|
||||
join t_orderdetail on T_OrderDetailT_OrderHeaderID = incomingRefDetailNewT_OrderHeaderID
|
||||
and T_OrderDetailT_TestID = incomingRefDetailT_TestID and T_OrderDetailIsActive = 'Y'
|
||||
left join other_lcprep on T_OrderDetailID = Other_LcprepT_OrderDetailID and
|
||||
Other_LcprepIsActive = 'Y'
|
||||
where incomingRefDetailID = ? ";
|
||||
$qry = $this->db->query($sql,array($incomingRefDetailID));
|
||||
if ( ! $qry ) {
|
||||
echo "ERR : process_nonlab : $incomingRefDetailID : " . print_r($this->db->error(),true) . "\n";
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if ( count($rows) > 0 ) {
|
||||
$lcprepID = $rows[0]["lcprepID"];
|
||||
$nl = "";
|
||||
if ($lcprepID > 0 ) {
|
||||
$nl = $this->get_nonlab("lcprep", $lcprepID);
|
||||
return $nl;
|
||||
}
|
||||
}
|
||||
|
||||
//fna
|
||||
$sql = "select ifnull(Other_FnaID,0) fnaID
|
||||
from incoming_ref_detail
|
||||
join t_orderdetail on T_OrderDetailT_OrderHeaderID = incomingRefDetailNewT_OrderHeaderID
|
||||
and T_OrderDetailT_TestID = incomingRefDetailT_TestID and T_OrderDetailIsActive = 'Y'
|
||||
left join other_fna on T_OrderDetailID = Other_FnaT_OrderDetailID and
|
||||
Other_FnaIsActive = 'Y'
|
||||
where incomingRefDetailID = ? ";
|
||||
$qry = $this->db->query($sql,array($incomingRefDetailID));
|
||||
if ( ! $qry ) {
|
||||
echo "ERR : process_nonlab : $incomingRefDetailID : " . print_r($this->db->error(),true) . "\n";
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if ( count($rows) > 0 ) {
|
||||
$fnaID = $rows[0]["fnaID"];
|
||||
$nl = "";
|
||||
if ($fnaID > 0 ) {
|
||||
$nl = $this->get_nonlab("fna", $fnaID);
|
||||
return $nl;
|
||||
}
|
||||
}
|
||||
//
|
||||
//cytology
|
||||
$sql = "select ifnull(Other_CytologiID,0) cytologiID
|
||||
from incoming_ref_detail
|
||||
join t_orderdetail on T_OrderDetailT_OrderHeaderID = incomingRefDetailNewT_OrderHeaderID
|
||||
and T_OrderDetailT_TestID = incomingRefDetailT_TestID and T_OrderDetailIsActive = 'Y'
|
||||
left join other_cytologi on T_OrderDetailID = Other_CytologiT_OrderDetailID and
|
||||
Other_CytologiIsActive = 'Y'
|
||||
where incomingRefDetailID = ? ";
|
||||
$qry = $this->db->query($sql,array($incomingRefDetailID));
|
||||
if ( ! $qry ) {
|
||||
echo "ERR : process_nonlab : $incomingRefDetailID : " . print_r($this->db->error(),true) . "\n";
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if ( count($rows) > 0 ) {
|
||||
$cytologiID = $rows[0]["cytologiID"];
|
||||
$nl = "";
|
||||
if ($cytologiID > 0 ) {
|
||||
$nl = $this->get_nonlab("cytologi", $cytologiID);
|
||||
return $nl;
|
||||
}
|
||||
}
|
||||
}
|
||||
function cek() {
|
||||
$sql = "select tx_branch_status.*, M_BranchName
|
||||
from tx_branch_status
|
||||
join m_branch on TxBranchStatusM_BranchID = M_BranchID
|
||||
where TxBranchStatusIsSent = 'N' and TxBranchStatusRetry < 20
|
||||
|
||||
order by TxBranchStatusRetry, TxBranchStatusID
|
||||
limit 0,30";
|
||||
$qry = $this->db->query($sql);
|
||||
$sql_update = "update tx_branch_status set TxBranchStatusIsSent=?,
|
||||
TxBranchStatusRetry = TxBranchStatusRetry + 1
|
||||
where TxBranchStatusID = ?";
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
print_r($rows);
|
||||
}
|
||||
}
|
||||
function process() {
|
||||
$sql = "select tx_branch_status.*, M_BranchName
|
||||
from tx_branch_status
|
||||
join m_branch on TxBranchStatusM_BranchID = M_BranchID
|
||||
where TxBranchStatusIsSent = 'N' and TxBranchStatusRetry < 20
|
||||
|
||||
order by TxBranchStatusRetry, TxBranchStatusID
|
||||
limit 0,30";
|
||||
// $sql = "select tx_branch_status.*, M_BranchName
|
||||
// from tx_branch_status
|
||||
// join m_branch on TxBranchStatusM_BranchID = M_BranchID
|
||||
// where TxBranchStatusID = 234623
|
||||
// order by TxBranchStatusRetry, TxBranchStatusID
|
||||
// limit 0,30";
|
||||
$qry = $this->db->query($sql);
|
||||
$sql_update = "update tx_branch_status set TxBranchStatusIsSent=?,
|
||||
TxBranchStatusRetry = TxBranchStatusRetry + 1
|
||||
where TxBranchStatusID = ?";
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
foreach($rows as $r) {
|
||||
$param = $r["TxBranchStatusJson"];
|
||||
$stage = $r["TxBranchStatusStage"];
|
||||
$ipAddress = $r["TxBranchStatusM_BranchIP"];
|
||||
$branchName = $r["M_BranchName"];
|
||||
$txID = $r["TxBranchStatusID"];
|
||||
if ($stage == "VALIDATION") {
|
||||
//cek nonlab
|
||||
$j_param = json_decode($param,true);
|
||||
foreach($j_param as $idx => $j ) {
|
||||
if (isset($j["incomingRefDetailID"])) {
|
||||
$nonlab_result = $this->process_nonlab( $j["incomingRefDetailID"] );
|
||||
if ($nonlab_result != array() ) {
|
||||
$j_param[$idx]["nonlab_result"] = $nonlab_result;
|
||||
$param = json_encode($j_param);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$url = "http://$ipAddress/one-api/tools/xstatusbranch_v4/update";
|
||||
$rst = $this->post($url,$param);
|
||||
|
||||
if ($rst["status"] == "OK" ) {
|
||||
$this->xlog("Update status $stage to $branchName @ $ipAddress [OK]");
|
||||
$this->db->query($sql_update, array('Y',$txID));
|
||||
} else {
|
||||
$err_msg = print_r($rst,true);
|
||||
$this->xlog("Update status $stage to $branchName @ $ipAddress [ERR] : $err_msg");
|
||||
$this->db->query($sql_update, array('N',$txID));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->xlog("Err: " . print_r($this->db->error(),true));
|
||||
}
|
||||
}
|
||||
|
||||
function xlog($message) {
|
||||
$dt = date("Y-m-d H:i:s");
|
||||
echo "$dt $message\n";
|
||||
}
|
||||
function post($url,$data) {
|
||||
$zdata = gzdeflate($data,9);
|
||||
$ch = curl_init($url);
|
||||
$this->xlog("Post to : " . $url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $zdata);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($zdata))
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
if ($result === false ) {
|
||||
return array("status" => "ERR" ,
|
||||
"message" => curl_error($ch)
|
||||
);
|
||||
}
|
||||
$rst = json_decode($result,true);
|
||||
return $rst;
|
||||
}
|
||||
}
|
||||
104
application/controllers/tools/Pinger.php
Normal file
104
application/controllers/tools/Pinger.php
Normal file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
class Pinger extends MY_Controller
|
||||
{
|
||||
/*
|
||||
|
||||
create table pinger(
|
||||
pingerID int not null auto_increment primary key,
|
||||
pingerHost varchar(100),
|
||||
pingerDescription varchar(300),
|
||||
pingerLastPong datetime,
|
||||
pingerRttMs int,
|
||||
pingerIsActive varchar(1) default 'Y',
|
||||
key(pingerIsActive),
|
||||
key(pingerHost)
|
||||
);
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db->query("use x_logs");
|
||||
}
|
||||
function do($status = false)
|
||||
{
|
||||
$sql = "select * from pinger where pingerIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
echo "Err : " . $this->db->last_query();
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
foreach ($rows as $r) {
|
||||
$dt = "[" . date("Y-m-d h:i:s") . "] ";
|
||||
echo "$dt Ping " . $r["pingerHost"] . " " . $r["pingerDescription"] . " => ";
|
||||
$this->do_ping($r["pingerID"], $r["pingerHost"], $r["pingerDescription"], $status);
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
function status()
|
||||
{
|
||||
$this->do(true);
|
||||
}
|
||||
function do_ping($id, $host, $name, $status = false)
|
||||
{
|
||||
$rtt = $this->ping($host, 5);
|
||||
if ($rtt == -1) {
|
||||
$sql_u = "update pinger set pingerRttMs=? where pingerID = ?";
|
||||
} else {
|
||||
$sql_u = "update pinger set pingerLastPong=now(),pingerRttMs=? where pingerID = ?";
|
||||
}
|
||||
$qry = $this->db->query($sql_u, [$rtt, $id]);
|
||||
$dt = "[" . date("Y-m-d h:i:s") . "] ";
|
||||
if (!$qry) {
|
||||
echo "$dt Err : " . $this->db->last_query();
|
||||
exit;
|
||||
}
|
||||
$this->load->library("Wa_sas");
|
||||
if ($rtt == -1) {
|
||||
//sasone
|
||||
//6282113702602-1584412485
|
||||
$hp = "6282113702602-1584412485@g.us";
|
||||
// hore
|
||||
$hp = "120363280846797029@g.us";
|
||||
$msg = "$name [$host] unreacheable";
|
||||
$resp = $this->wa_sas->send_message($hp, $msg, true);
|
||||
echo "$dt OK : unreachable. " . print_r($resp, true);
|
||||
} else {
|
||||
if ($status) {
|
||||
$hp = "6282113702602-1584412485@g.us";
|
||||
// hore
|
||||
$hp = "120363280846797029@g.us";
|
||||
$msg = "$name [$host] : ping avg $rtt ms";
|
||||
$resp = $this->wa_sas->send_message($hp, $msg, true);
|
||||
echo "$dt OK : unreacheable. " . print_r($resp, true);
|
||||
} else {
|
||||
echo "$dt OK : avg $rtt ms";
|
||||
}
|
||||
}
|
||||
}
|
||||
function ping($host, $count = 5)
|
||||
{
|
||||
$rtts = [];
|
||||
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
// Use exec to ping the host and capture the output
|
||||
$output = [];
|
||||
exec("ping -c 1 -W 1 " . escapeshellarg($host), $output, $status);
|
||||
|
||||
// Check if ping was successful (status 0 means success)
|
||||
if ($status === 0) {
|
||||
// Extract the round-trip time from the output
|
||||
if (preg_match('/time=([0-9.]+) ms/', implode("\n", $output), $matches)) {
|
||||
$rtts[] = (float)$matches[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If there are successful pings, calculate the average RTT; otherwise, return -1
|
||||
if (count($rtts) > 0) {
|
||||
return array_sum($rtts) / count($rtts);
|
||||
} else {
|
||||
return -1; // Host unreachable in all attempts
|
||||
}
|
||||
}
|
||||
}
|
||||
107
application/controllers/tools/Qr_code.php
Normal file
107
application/controllers/tools/Qr_code.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
class Qr_code extends MY_Controller
|
||||
{
|
||||
var $url_renderer;
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "BRANCH API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
$this->url_renderer = "http://localhost/xcharts/qr.php";
|
||||
}
|
||||
|
||||
public function doctor($id)
|
||||
{
|
||||
try {
|
||||
//hardcode data
|
||||
$jabatan = "Penanggung Jawab Laboratorium Patologi Klinik";
|
||||
$situs = "https://westerindo.com/";
|
||||
$address = "Jl. Cipaku 1 No. 5 Kebayoran Baru, Jakarta Selatan ";
|
||||
$perusahaan = "Perusahaan: LABORATORIUM KLINIK UTAMA WESTERINDO";
|
||||
|
||||
//query sql mencari nama doctor
|
||||
$sql = "SELECT T_OrderHeaderPjM_DoctorID as m_doctor_id,
|
||||
CONCAT(m.M_DoctorPrefix2, m.M_DoctorName, m.M_DoctorSuffix) AS doctor_name,
|
||||
T_OrderHeaderPj2M_DoctorID as m_doctor_id_pj2,
|
||||
CONCAT(pj2.M_DoctorPrefix2, pj2.M_DoctorName, pj2.M_DoctorSuffix) AS doctor_name_pj2
|
||||
FROM
|
||||
t_orderheader
|
||||
JOIN
|
||||
m_doctor AS m ON T_OrderHeaderPjM_DoctorID = m.M_DoctorID
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
AND M_DoctorIsActive = 'Y'
|
||||
AND T_OrderHeaderID = ?
|
||||
LEFT JOIN
|
||||
m_doctor AS pj2 ON T_OrderHeaderPj2M_DoctorID = pj2.M_DoctorID
|
||||
";
|
||||
$qry = $this->db_onedev->query($sql, [$id]);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
|
||||
// Variabel untuk menyimpan hasil akhir sebagai string
|
||||
$output = "";
|
||||
|
||||
// Loop melalui hasil dan format output menjadi string
|
||||
foreach ($rows as $row) {
|
||||
$output .= "Nama: " . $row['doctor_name'] . "\n";
|
||||
$output .= "Jabatan: " . $jabatan . "\n\n";
|
||||
|
||||
if (!empty($row['doctor_name_pj2'])) {
|
||||
$output .= "Nama: " . $row['doctor_name_pj2'] . "\n";
|
||||
$output .= "Jabatan: " . $jabatan . "\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Tambahkan informasi tambahan ke string
|
||||
$output .= "Situs web: " . $situs . "\n";
|
||||
$output .= "Alamat: " . $address . "\n";
|
||||
$output .= "Perusahaan: " . $perusahaan . "\n";
|
||||
|
||||
// 3. encapsulate in config attribute and json encode
|
||||
// print_r($param);
|
||||
$config = ["data" => $output];
|
||||
$j_param = json_encode($config);
|
||||
header("Content-Type: image/png");
|
||||
// 4. post to chart renderer
|
||||
echo $this->post($this->url_renderer, $j_param);
|
||||
} else {
|
||||
$this->sys_error_db("t_orderheader rows", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
||||
curl_setopt(
|
||||
$ch,
|
||||
CURLOPT_HTTPHEADER,
|
||||
array(
|
||||
'Content-Type: application/text',
|
||||
'Content-Length: ' . strlen($data)
|
||||
)
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
|
||||
if (curl_error($ch) != "") {
|
||||
return "ERROR Accessing QrCode : " . curl_error($ch) . "\n";
|
||||
}
|
||||
curl_close($ch);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
49
application/controllers/tools/Reconfirmrujukan.php
Normal file
49
application/controllers/tools/Reconfirmrujukan.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
class Reconfirmrujukan extends CI_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function index() {
|
||||
echo "Re-send rujukan";
|
||||
}
|
||||
function check($date) {
|
||||
$sql = "select
|
||||
M_BranchCode, incomingRefT_RefDeliveryOrderNumber,
|
||||
incomingRefDetailT_OrderHeaderLabNumber,
|
||||
incomingRefDetailT_TestName, incomingRefDetailT_BarcodeLabBarcode
|
||||
from incoming_ref
|
||||
join incoming_ref_detail on incomingRefID = incomingRefDetailIncomingRefID
|
||||
and incomingRefT_RefDeliveryOrderDate = ?
|
||||
join m_branch on incomingRefM_BranchID = M_BranchID
|
||||
and M_BranchIsActive = 'Y'
|
||||
where
|
||||
incomingRefDetailStatus = 'N'
|
||||
order by M_BranchCode, incomingRefT_RefDeliveryOrderNumber
|
||||
";
|
||||
$qry = $this->db->query($sql, array($date));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
foreach($rows as $r) {
|
||||
$code = $r["M_BranchCode"];
|
||||
$number = $r["incomingRefT_RefDeliveryOrderNumber"];
|
||||
$test = $r["incomingRefDetailT_TestName"];
|
||||
$barcode = $r["incomingRefDetailT_BarcodeLabBarcode"];
|
||||
$regno = $r["incomingRefDetailT_OrderHeaderLabNumber"];
|
||||
echo "$code\t$number\t$regno\t$test\t$barcode\n";
|
||||
}
|
||||
if ( count($rows) == 0 ) {
|
||||
echo "NO Pending Data\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
function fix($regno) {
|
||||
$sql = "select
|
||||
T_OrderHeaderID, T_OrderHeaderLabNumber
|
||||
from t_orderheader
|
||||
join incoming_ref_detail on incomingRefDetailT_Orde
|
||||
where M_BranchIsActive = 'Y' and M_BranchCode = ?";
|
||||
$branchID = 0;
|
||||
}
|
||||
}
|
||||
46
application/controllers/tools/Replication.php
Normal file
46
application/controllers/tools/Replication.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
class Replication extends MY_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function index() {
|
||||
echo "Replication API";
|
||||
}
|
||||
function slave() {
|
||||
$sql = "show slave status";
|
||||
$qry = $this->db->query($sql);
|
||||
if (! $qry) {
|
||||
echo json_encode( array("status" => "ERR" , "message" => print_r($this->db->error(),true) ) );
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$slave = array();
|
||||
$slave["status"] = "Not Running";
|
||||
if(count($rows) == 0 ) {
|
||||
echo json_encode($slave);
|
||||
exit;
|
||||
}
|
||||
$r = $rows[0];
|
||||
$slave["status"] = "Running";
|
||||
$slave["MasterLogFile"] = $r["Master_Log_File"];
|
||||
$slave["ReadPosition"] = $r["Read_Master_Log_Pos"];
|
||||
$slave["Behind"] = $r["Seconds_Behind_Master"];
|
||||
$slave["Table"] = explode(",", $r["Replicate_Do_Table"]);
|
||||
echo json_encode($slave);
|
||||
}
|
||||
function post($url,$data) {
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data))
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
69
application/controllers/tools/Reportdownload.php
Normal file
69
application/controllers/tools/Reportdownload.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
//ini_set('display_errors', '1');
|
||||
//ini_set('display_startup_errors', '1');
|
||||
//error_reporting(E_ALL);
|
||||
//url
|
||||
// http://riau.aplikasi.web.id/birt/frameset?__report=report/one/lab/rpt_test_email.rptdesign&__format=pdf&username=adhi&PID=32626&tm=1591680178071
|
||||
class Reportdownload extends MY_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
function index() {
|
||||
//__report=report/one/lab/rpt_test_email.rptdesign&__format=pdf&username=adhi&PID=32626&tm=1591680178071
|
||||
$gets = $this->input->get();
|
||||
$order_header_id = $gets["PID"];
|
||||
$report = $gets["__report"];
|
||||
$report_name = $this->create_report_name($order_header_id,$report);
|
||||
$this->dl_report($gets,$report_name);
|
||||
}
|
||||
function create_report_name($id,$rpt) {
|
||||
$sql = "select T_OrderHeaderLabNumberExt, fn_get_name(T_OrderHeaderM_PatientID) name
|
||||
from t_orderheader where T_OrderHeaderID = ? ";
|
||||
$query = $this->db->query($sql,array($id));
|
||||
$nolab = "unknown-$id";
|
||||
$name = "unknown";
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$name = str_replace(" ", "_", $rows[0]["name"]);
|
||||
$nolab = $rows[0]["T_OrderHeaderLabNumberExt"];
|
||||
}
|
||||
}
|
||||
$pos = strpos($rpt, "rpt_");
|
||||
$rptname = "DEFAULT";
|
||||
if ($pos > 0 ) {
|
||||
$epos = strpos($rpt,"_email");
|
||||
if ($epos > 0 && $epos > $pos ) {
|
||||
$rptname = substr($rpt, $pos + 4 , $epos - $pos - 4 );
|
||||
$rptname = strtoupper($rptname);
|
||||
}
|
||||
}
|
||||
switch($rptname) {
|
||||
case "TEST" :
|
||||
$rptname = "LAB";
|
||||
break;
|
||||
|
||||
}
|
||||
return $rptname . "-" . $nolab . "-" . $name . ".pdf";
|
||||
}
|
||||
function dl_report($prm, $name) {
|
||||
$url = "http://localhost/birt/frameset?" ;
|
||||
$qry = "";
|
||||
foreach($prm as $k => $v) {
|
||||
if ($qry != "" ) $qry .= "&";
|
||||
$qry .= $k . "=" . urlencode($v);
|
||||
}
|
||||
$url .= $qry ;
|
||||
$data = file_get_contents($url);
|
||||
header('Content-Type: application/octet-stream');
|
||||
header('Content-Disposition: attachment; filename=' . $name);
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
header('Connection: Keep-Alive');
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
||||
header('Pragma: public');
|
||||
//header('Content-Length: ' . $size);
|
||||
echo $data;
|
||||
}
|
||||
}
|
||||
99
application/controllers/tools/Resendrujukan.php
Normal file
99
application/controllers/tools/Resendrujukan.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
class Resendrujukan extends CI_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function index() {
|
||||
echo "Re-send rujukan";
|
||||
}
|
||||
function nosj($cabang,$sj) {
|
||||
$sql = "select
|
||||
from
|
||||
";
|
||||
}
|
||||
function xnolab($nolab) {
|
||||
$sql = "select T_OrderHeaderID
|
||||
from t_orderheader
|
||||
where T_OrderHeaderLabNumber= ?";
|
||||
$qry = $this->db->query($sql, array($nolab));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$sql = "select T_OrderHeaderID
|
||||
from t_orderheader
|
||||
where T_OrderHeaderLabNumber= ?";
|
||||
$qry = $this->db->query($sql, array($nolab));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
}
|
||||
}
|
||||
if ( count($rows) > 0 ) {
|
||||
$orderHeaderID = $rows[0];
|
||||
$sql = "select T_OrderDetailID,M_StaffName, T_OrderDetailT_TestName
|
||||
from t_orderdetail
|
||||
join m_user on T_OrderDetailValUserID= M_UserID
|
||||
join m_staff on M_UserM_StaffID = M_StaffID
|
||||
where T_OrderDetailT_OrderHeaderID = ?";
|
||||
$qry = $this->db->query($sql, array($orderHeaderID));
|
||||
$name = "";
|
||||
$ids = array();
|
||||
$pxs = array();
|
||||
if($qry) {
|
||||
$rows = $qry->result_array();
|
||||
foreach($rows as $r) {
|
||||
if ($name == "" ) $name = $r["M_StaffName"];
|
||||
$ids[] = $r["T_OrderDetailID"];
|
||||
$pxs[] = $r["T_OrderDetailT_TestName"];
|
||||
}
|
||||
echo "resend : $nolab [" . join($pxs,",") . "]\n";
|
||||
$this->load->library("Txbranchstatus");
|
||||
$this->txbranchstatus->update_multi("VALIDATION",$ids,$name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function nolab($nolab) {
|
||||
$sql = "select T_OrderHeaderID
|
||||
from t_orderheader
|
||||
join t_orderheaderaddon on T_OrderHeaderID = T_OrderHeaderAddOnT_OrderHeaderID
|
||||
where T_OrderHeaderAddOnLabNumberOrigin = ?";
|
||||
$qry = $this->db->query($sql, array($nolab));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$sql = "select T_OrderHeaderID
|
||||
from t_orderheader
|
||||
where T_OrderHeaderLabNumber= ?";
|
||||
$qry = $this->db->query($sql, array($nolab));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
}
|
||||
}
|
||||
if ( count($rows) > 0 ) {
|
||||
$orderHeaderID = $rows[0];
|
||||
$sql = "select T_OrderDetailID,M_StaffName, T_OrderDetailT_TestName
|
||||
from t_orderdetail
|
||||
join m_user on T_OrderDetailValUserID= M_UserID
|
||||
join m_staff on M_UserM_StaffID = M_StaffID
|
||||
where T_OrderDetailT_OrderHeaderID = ?";
|
||||
$qry = $this->db->query($sql, array($orderHeaderID));
|
||||
$name = "";
|
||||
$ids = array();
|
||||
$pxs = array();
|
||||
if($qry) {
|
||||
$rows = $qry->result_array();
|
||||
foreach($rows as $r) {
|
||||
if ($name == "" ) $name = $r["M_StaffName"];
|
||||
$ids[] = $r["T_OrderDetailID"];
|
||||
$pxs[] = $r["T_OrderDetailT_TestName"];
|
||||
}
|
||||
echo "resend : $nolab [" . join($pxs,",") . "]\n";
|
||||
$this->load->library("Txbranchstatus");
|
||||
$this->txbranchstatus->update_multi("VALIDATION",$ids,$name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
102
application/controllers/tools/Resendrujukan_v2.php
Normal file
102
application/controllers/tools/Resendrujukan_v2.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
class Resendrujukan_v2 extends CI_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function index() {
|
||||
echo "Re-send rujukan";
|
||||
}
|
||||
function nosj($cabang,$sj) {
|
||||
$sql = "select
|
||||
from
|
||||
";
|
||||
}
|
||||
function verif($nolab) {
|
||||
$sql = "select T_OrderHeaderID,T_OrderHeaderLabNumber
|
||||
from t_orderheader
|
||||
join t_orderheaderaddon on T_OrderHeaderID = T_OrderHeaderAddOnT_OrderHeaderID
|
||||
where T_OrderHeaderAddOnLabNumberOrigin = ?";
|
||||
$qry = $this->db->query($sql, array($nolab));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$sql = "select T_OrderHeaderID,T_OrderHeaderLabNumber
|
||||
from t_orderheader
|
||||
where T_OrderHeaderLabNumber= ?";
|
||||
$qry = $this->db->query($sql, array($nolab));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
}
|
||||
}
|
||||
foreach($rows as $r) {
|
||||
$orderHeaderID = $r["T_OrderHeaderID"];
|
||||
$labNumber = $r["T_OrderHeaderLabNumber"];
|
||||
$sql = "select T_OrderDetailID,M_StaffName, T_OrderDetailT_TestName
|
||||
from t_orderdetail
|
||||
join m_user on T_OrderDetailVerUserID = M_UserID
|
||||
join m_staff on M_UserM_StaffID = M_StaffID
|
||||
where T_OrderDetailT_OrderHeaderID = ?";
|
||||
$qry = $this->db->query($sql, array($orderHeaderID));
|
||||
$name = "";
|
||||
$ids = array();
|
||||
$pxs = array();
|
||||
if($qry) {
|
||||
$rows = $qry->result_array();
|
||||
foreach($rows as $r) {
|
||||
if ($name == "" ) $name = $r["M_StaffName"];
|
||||
$ids[] = $r["T_OrderDetailID"];
|
||||
$pxs[] = $r["T_OrderDetailT_TestName"];
|
||||
}
|
||||
echo "resend : $nolab -> $labNumber [" . join($pxs,",") . "]\n";
|
||||
$this->load->library("Txbranchstatus");
|
||||
$this->txbranchstatus->update_multi("VERIFY",$ids,$name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function valid($nolab) {
|
||||
$sql = "select T_OrderHeaderID,T_OrderHeaderLabNumber
|
||||
from t_orderheader
|
||||
join t_orderheaderaddon on T_OrderHeaderID = T_OrderHeaderAddOnT_OrderHeaderID
|
||||
where T_OrderHeaderAddOnLabNumberOrigin = ?";
|
||||
$qry = $this->db->query($sql, array($nolab));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$sql = "select T_OrderHeaderID,T_OrderHeaderLabNumber
|
||||
from t_orderheader
|
||||
where T_OrderHeaderLabNumber= ?";
|
||||
$qry = $this->db->query($sql, array($nolab));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
}
|
||||
}
|
||||
foreach($rows as $r) {
|
||||
$orderHeaderID = $r["T_OrderHeaderID"];
|
||||
$labNumber = $r["T_OrderHeaderLabNumber"];
|
||||
$sql = "select T_OrderDetailID,M_StaffName, T_OrderDetailT_TestName
|
||||
from t_orderdetail
|
||||
join m_user on T_OrderDetailValUserID= M_UserID
|
||||
join m_staff on M_UserM_StaffID = M_StaffID
|
||||
where T_OrderDetailValidation = 'Y' and T_OrderDetailT_OrderHeaderID = ?";
|
||||
$qry = $this->db->query($sql, array($orderHeaderID));
|
||||
$name = "";
|
||||
$ids = array();
|
||||
$pxs = array();
|
||||
if($qry) {
|
||||
$rows = $qry->result_array();
|
||||
foreach($rows as $r) {
|
||||
if ($name == "" ) $name = $r["M_StaffName"];
|
||||
$ids[] = $r["T_OrderDetailID"];
|
||||
$pxs[] = $r["T_OrderDetailT_TestName"];
|
||||
}
|
||||
echo "resend : $nolab -> $labNumber [" . join($pxs,",") . "]\n";
|
||||
$this->load->library("Txbranchstatus");
|
||||
$this->txbranchstatus->update_multi("VALIDATION",$ids,$name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
75
application/controllers/tools/RptKasirKwitansiWa.php
Normal file
75
application/controllers/tools/RptKasirKwitansiWa.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
class RptKasirKwitansiWa extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Tools untuk ngakali upload Kwitansi ke Qontak karena kalau dari birt_run tidak bisa di upload";
|
||||
}
|
||||
|
||||
public function KwitansiWa(string $urlbirt)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
function get_list_patient_rpt()
|
||||
{
|
||||
try {
|
||||
$list_rpt = [];
|
||||
$prefix = "https://" . $_SERVER['SERVER_NAME'];
|
||||
$list_rpt[] = $prefix . "/birt/run?__report=report/one/fo/rpt_kwitansi_001.rptdesign&__format=pdf&username=PETUGAS SAMPLE LAB&PID=296";
|
||||
|
||||
$merge_input = array(
|
||||
"output" => "test.pdf",
|
||||
"input" => $list_rpt
|
||||
);
|
||||
|
||||
$jsonData = json_encode($merge_input);
|
||||
|
||||
$jsonDebug = json_encode($merge_input, JSON_PRETTY_PRINT);
|
||||
|
||||
echo '<pre>' . htmlspecialchars($jsonDebug) . '</pre>';
|
||||
exit;
|
||||
|
||||
// Initialize cURL session
|
||||
$target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge";
|
||||
|
||||
$response = $this->post($target_pdf, $jsonData);
|
||||
$output_file_name = "test_kwitansi.pdf";
|
||||
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' . $output_file_name .'"'
|
||||
);
|
||||
echo ($response);
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt(
|
||||
$ch,
|
||||
CURLOPT_HTTPHEADER,
|
||||
array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data)
|
||||
)
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
138
application/controllers/tools/Sp_csv.php
Normal file
138
application/controllers/tools/Sp_csv.php
Normal file
@@ -0,0 +1,138 @@
|
||||
|
||||
<?php
|
||||
class Sp_csv extends MY_Controller
|
||||
{
|
||||
var $intervalHour;
|
||||
var $tmp_body;
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->intervalHour = 12;
|
||||
}
|
||||
function param()
|
||||
{
|
||||
$body = file_get_contents("php://input");
|
||||
$this->tmp_body = $body;
|
||||
return json_decode($body, true);
|
||||
}
|
||||
function go()
|
||||
{
|
||||
$gets = $_GET;
|
||||
$arr_param = [];
|
||||
$idx = 1;
|
||||
$sp = $_GET["sp"];
|
||||
if ($sp == "") {
|
||||
echo "Invalid Sp: $sp";
|
||||
exit;
|
||||
}
|
||||
$format = $_GET["__format"];
|
||||
if ($format == "") {
|
||||
$format = "html";
|
||||
}
|
||||
$arr_place_holder = "";
|
||||
foreach ($_GET as $k => $v) {
|
||||
$p = "p" . $idx;
|
||||
if ($k == $p) {
|
||||
$arr_param[] = $_GET[$p];
|
||||
$idx++;
|
||||
if ($arr_place_holder != "") {
|
||||
$arr_place_holder .= ",";
|
||||
}
|
||||
$arr_place_holder .= "?";
|
||||
}
|
||||
}
|
||||
if ($arr_place_holder == "") {
|
||||
$sql = "call $sp()";
|
||||
} else {
|
||||
$sql = "call $sp($arr_place_holder)";
|
||||
}
|
||||
$qry = $this->db->query($sql, $arr_param);
|
||||
if (!$qry) {
|
||||
echo "Err: " . print_r($this->db->error(), true);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if ($format == "html") {
|
||||
$this->print_table_style();
|
||||
$this->print_table($rows, array_keys($rows[0]));
|
||||
} else {
|
||||
$fname = "rpt-$sp.csv";
|
||||
header('Content-Type: text/csv');
|
||||
header('Content-Disposition: attachment; filename="' . $fname . '"');
|
||||
$this->print_csv($rows, array_keys($rows[0]));
|
||||
}
|
||||
}
|
||||
|
||||
public function print_table_style()
|
||||
{
|
||||
echo "
|
||||
<style>
|
||||
th, td {
|
||||
padding: 15px;
|
||||
text-align: left;
|
||||
white-space:nowrap;
|
||||
}
|
||||
tr:nth-child(even) {background-color: #f2f2f2;}
|
||||
table {
|
||||
border: solid 1px ;
|
||||
min-width:600px;
|
||||
}
|
||||
</style>
|
||||
";
|
||||
}
|
||||
|
||||
public function print_table($rows, $keys, $title = false)
|
||||
{
|
||||
echo "<table>";
|
||||
if ($title) {
|
||||
$col_span = count($keys);
|
||||
echo "<tr>";
|
||||
echo "<th colspan=$col_span>$title</th>";
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "<tr>";
|
||||
foreach ($keys as $k) {
|
||||
$k = str_replace("|R", "", $k);
|
||||
echo "<td>$k</td>";
|
||||
}
|
||||
echo "</tr>\n";
|
||||
foreach ($rows as $r) {
|
||||
echo "<tr>";
|
||||
foreach ($keys as $k) {
|
||||
if (in_array($k, ["Debit", "Debit", "Kredit"])) {
|
||||
echo "<td style='text-align:right' >" .
|
||||
$r[$k] .
|
||||
"</td>";
|
||||
} else {
|
||||
echo "<td>" . $r[$k] . "</td>";
|
||||
}
|
||||
}
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
function print_csv($rows, $keys, $title = "")
|
||||
{
|
||||
$header = "";
|
||||
if ($title != "") {
|
||||
echo $title . "\n";
|
||||
}
|
||||
foreach ($keys as $idx => $k) {
|
||||
if ($idx > 0) {
|
||||
echo ",";
|
||||
}
|
||||
echo "\"$k\"";
|
||||
}
|
||||
echo "\n";
|
||||
foreach ($rows as $r) {
|
||||
foreach ($keys as $idx => $k) {
|
||||
if ($idx > 0) {
|
||||
echo ",";
|
||||
}
|
||||
$val = $r[$k];
|
||||
echo "\"$val\"";
|
||||
}
|
||||
echo "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
130
application/controllers/tools/Ssjpa.php
Normal file
130
application/controllers/tools/Ssjpa.php
Normal file
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
class SsJpa extends CI_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function jpa($date) {
|
||||
$sql = "select M_BranchCode from m_branch where M_BranchIsActive = 'Y'
|
||||
and M_BranchIsDefault = 'Y'";
|
||||
$qry = $this->db->query($sql);
|
||||
$branchCode ="";
|
||||
if($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) $branchCode = $rows[0]["M_BranchCode"];
|
||||
}
|
||||
if ($branchCode == "") {
|
||||
echo "Err : Branch Not Defined \n";
|
||||
return;
|
||||
}
|
||||
// Order hari ini
|
||||
$sql = "select
|
||||
'$branchCode' M_BranchCode,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderM_patientID M_PatientID,
|
||||
date(T_OrderHeaderDate) as OrderDate,
|
||||
T_OrderHeaderLabNumber as Noreg,
|
||||
T_OrderHeaderSenderM_DoctorID,
|
||||
T_OrderHeaderM_CompanyID M_CompanyID,
|
||||
T_OrderHeaderSenderM_DoctorAddressID,
|
||||
T_OrderHeaderM_MouID,
|
||||
T_TestID, T_TestName,
|
||||
T_OrderDetailPrice, T_OrderDetailTotal,
|
||||
Nat_JPADetailDiscount,Nat_JPAGroupName,
|
||||
M_DoctorAddressDescription,
|
||||
case
|
||||
when Nat_JPADetailDiscount <= Nat_JpaGroupMaxJpaDisc
|
||||
then T_OrderDetailTotal*(Nat_JPADetailDiscount/100)
|
||||
else
|
||||
0
|
||||
end as JpaAmount,
|
||||
Nat_JpaGroupMaxJpaDisc
|
||||
from
|
||||
t_orderheader
|
||||
join m_doctoraddress on T_OrderHeaderSenderM_DoctorAddressID = M_DoctorAddressID and M_DoctorAddressIsActive = 'Y'
|
||||
join m_doctor on M_DoctorAddressM_DoctorID = M_DoctorID and M_DoctorIsMarketingConfirm = 'Y'
|
||||
join t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
join t_test ON T_OrderDetailT_TestID = T_TestID and T_TestIsPrice = 'Y' AND T_TestIsActive = 'Y'
|
||||
join nat_test oN T_TestNat_TestID = Nat_TestID aND Nat_TestIsActive = 'Y'
|
||||
join jpa_test on JPA_TestNat_TestID = Nat_TestID and JPA_TestIsActive = 'Y'
|
||||
join nat_jpa on M_DoctorAddressNat_JpaID = Nat_JpaID and Nat_JpaIsActive = 'Y'
|
||||
join nat_jpagroup on JPA_TestNat_JpaGroupID = Nat_JPAGroupID and Nat_JPAGroupIsActive = 'Y'
|
||||
join nat_jpadetail on Nat_JPADetailNat_JPAID = Nat_JPAID
|
||||
and Nat_JPAGroupID = Nat_JPADetailNat_JPAGroupID and Nat_JPADetailIsActive = 'Y'
|
||||
where
|
||||
DATE(T_OrderHeaderDate) = ?
|
||||
order by T_OrderHeaderID" ;
|
||||
$qry = $this->db->query($sql, array($date));
|
||||
$rows = array();
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
}
|
||||
//order yg di update hari ini
|
||||
$sql = "select
|
||||
'$branchCode' M_BranchCode,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderM_patientID M_PatientID,
|
||||
date(T_OrderHeaderDate) as OrderDate,
|
||||
T_OrderHeaderLabNumber as Noreg,
|
||||
T_OrderHeaderSenderM_DoctorID,
|
||||
T_OrderHeaderM_CompanyID M_CompanyID,
|
||||
T_OrderHeaderSenderM_DoctorAddressID,
|
||||
T_OrderHeaderM_MouID,
|
||||
T_TestID, T_TestName,
|
||||
T_OrderDetailPrice, T_OrderDetailTotal,
|
||||
Nat_JPADetailDiscount,Nat_JPAGroupName,
|
||||
M_DoctorAddressDescription,
|
||||
case
|
||||
when Nat_JPADetailDiscount <= Nat_JpaGroupMaxJpaDisc
|
||||
then T_OrderDetailTotal*(Nat_JPADetailDiscount/100)
|
||||
else
|
||||
0
|
||||
end as JpaAmount,
|
||||
Nat_JpaGroupMaxJpaDisc
|
||||
from
|
||||
t_orderheader
|
||||
join m_doctoraddress on T_OrderHeaderSenderM_DoctorAddressID = M_DoctorAddressID and M_DoctorAddressIsActive = 'Y'
|
||||
join m_doctor on M_DoctorAddressM_DoctorID = M_DoctorID and M_DoctorIsMarketingConfirm = 'Y'
|
||||
join t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
join t_test ON T_OrderDetailT_TestID = T_TestID and T_TestIsPrice = 'Y' AND T_TestIsActive = 'Y'
|
||||
join nat_test oN T_TestNat_TestID = Nat_TestID aND Nat_TestIsActive = 'Y'
|
||||
join jpa_test on JPA_TestNat_TestID = Nat_TestID and JPA_TestIsActive = 'Y'
|
||||
join nat_jpa on M_DoctorAddressNat_JpaID = Nat_JpaID and Nat_JpaIsActive = 'Y'
|
||||
join nat_jpagroup on JPA_TestNat_JpaGroupID = Nat_JPAGroupID and Nat_JPAGroupIsActive = 'Y'
|
||||
join nat_jpadetail on Nat_JPADetailNat_JPAID = Nat_JPAID
|
||||
and Nat_JPAGroupID = Nat_JPADetailNat_JPAGroupID and Nat_JPADetailIsActive = 'Y'
|
||||
where
|
||||
DATE(T_OrderHeaderLastUpdated) = ?
|
||||
and
|
||||
DATE(T_OrderHeaderDate) < ?
|
||||
order by T_OrderHeaderID" ;
|
||||
$qry2 = $this->db->query($sql, array($date,$date));
|
||||
$rows2 = array();
|
||||
if ($qry2) {
|
||||
$rows2 = $qry2->result_array();
|
||||
}
|
||||
$rows = array_merge($rows,$rows2);
|
||||
if (count($rows) > 0 ) {
|
||||
$data = json_encode($rows);
|
||||
$result = $this->post("http://bandung.aplikasi.web.id/one-api/tools/ssjpa/jpa", $data);
|
||||
print_r($result);
|
||||
}
|
||||
}
|
||||
function post($url,$data) {
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data))
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return $result;
|
||||
}
|
||||
function expertisi() {
|
||||
echo "Expertisi";
|
||||
}
|
||||
}
|
||||
30
application/controllers/tools/Synctablev1.php
Normal file
30
application/controllers/tools/Synctablev1.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
class Synctablev1 extends MY_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
//$this->db = $this->load->database('regional', true);
|
||||
$this->db = $this->load->database('onedev', true);
|
||||
}
|
||||
|
||||
function update() {
|
||||
$md5 = $this->sys_input["md5"];
|
||||
$param = $this->sys_input["param"];
|
||||
$j_param = json_encode($param);
|
||||
$l_md5 = md5($j_param);
|
||||
if ($md5 != $l_md5 ) {
|
||||
echo json_encode(array("status" => "ERR", "message" => "MD5 $md5 <> $l_md5"));
|
||||
exit;
|
||||
}
|
||||
$table = $param["table"];
|
||||
$records = $param["records"];
|
||||
$id = $param["id"];
|
||||
$qry = $this->db->update_batch($table,$records,$id);
|
||||
if (! $qry ) {
|
||||
echo json_encode( array("status" => "ERR", "message" => print_r($this->db->error(),true)));
|
||||
} else {
|
||||
echo json_encode( array("status" => "OK", "message" => ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
61
application/controllers/tools/Syncupdate.http
Normal file
61
application/controllers/tools/Syncupdate.http
Normal file
@@ -0,0 +1,61 @@
|
||||
# params:
|
||||
# table: string - nama tabel
|
||||
# lastdownload: string - tanggal terakhir download dalam format YYYY-MM-DD
|
||||
|
||||
@url = cpone.aplikasi.web.id
|
||||
|
||||
// Tabel nat_test
|
||||
POST https://{{url}}/one-api/tools/syncupdate/getdata_nat_test/nat_test/2025-09-24
|
||||
Content-Type: application/json
|
||||
|
||||
###
|
||||
// Tabel t_test
|
||||
POST https://{{url}}/one-api/tools/syncupdate/getdata_t_test/t_test/2025-09-24
|
||||
Content-Type: application/json
|
||||
|
||||
###
|
||||
// Tabel nat_normalvalue
|
||||
POST https://{{url}}/one-api/tools/syncupdate/getdata_nat_normalvalue/nat_normalvalue/2025-09-24
|
||||
Content-Type: application/json
|
||||
|
||||
###
|
||||
// Tabel nat_subgroup
|
||||
POST https://{{url}}/one-api/tools/syncupdate/getdata_nat_subgroup/nat_subgroup/2025-09-24
|
||||
Content-Type: application/json
|
||||
|
||||
###
|
||||
// Tabel t_sampletype
|
||||
POST https://{{url}}/one-api/tools/syncupdate/getdata_t_sampletype/t_sampletype/2025-09-24
|
||||
Content-Type: application/json
|
||||
|
||||
###
|
||||
// Tabel t_bahan
|
||||
POST https://{{url}}/one-api/tools/syncupdate/getdata_t_bahan/t_bahan/2025-09-24
|
||||
Content-Type: application/json
|
||||
|
||||
###
|
||||
// Tabel nat_methode
|
||||
POST https://{{url}}/one-api/tools/syncupdate/getdata_nat_methode/nat_methode/2025-09-24
|
||||
Content-Type: application/json
|
||||
|
||||
###
|
||||
// Tabel nat_instrument
|
||||
POST https://{{url}}/one-api/tools/syncupdate/getdata_nat_instrument/nat_instrument/2025-09-24
|
||||
Content-Type: application/json
|
||||
|
||||
###
|
||||
// Tabel m_instrumentmethode
|
||||
POST https://{{url}}/one-api/tools/syncupdate/getdata_m_instrumentmethode/m_instrumentmethode/2025-09-24
|
||||
Content-Type: application/json
|
||||
|
||||
###
|
||||
// Tabel nat_unit
|
||||
POST https://{{url}}/one-api/tools/syncupdate/getdata_nat_unit/nat_unit/2025-09-24
|
||||
Content-Type: application/json
|
||||
|
||||
|
||||
###
|
||||
// gabungan dari beberapa url
|
||||
POST https://devcpone.aplikasi.web.id/one-api/tools/syncupdate/get_update/2025-10-06
|
||||
Content-Type: application/json
|
||||
|
||||
659
application/controllers/tools/Syncupdate.php
Normal file
659
application/controllers/tools/Syncupdate.php
Normal file
@@ -0,0 +1,659 @@
|
||||
<?php
|
||||
|
||||
class Syncupdate extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
var $hostname = "bdg-westone.aplikasi.web.id";
|
||||
public function index()
|
||||
{
|
||||
echo "Uploader API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
"Content-Type: application/text",
|
||||
"Content-Length: " . strlen($data),
|
||||
]);
|
||||
$result = curl_exec($ch);
|
||||
if (curl_error($ch) != "") {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Http Error : " . curl_error($ch),
|
||||
]);
|
||||
curl_close($ch);
|
||||
exit();
|
||||
}
|
||||
curl_close($ch);
|
||||
return $result;
|
||||
}
|
||||
|
||||
function reply($resp)
|
||||
{
|
||||
echo json_encode($resp);
|
||||
}
|
||||
|
||||
public function getdata_nat_test($table, $lastdownload)
|
||||
{
|
||||
$this->db->trans_begin();
|
||||
|
||||
$lastdownload_full = $lastdownload . " 00:00:00";
|
||||
|
||||
$sql = "SELECT * FROM $table WHERE Nat_TestLastUpdated > ?";
|
||||
$qry = $this->db->query($sql, [
|
||||
$lastdownload_full
|
||||
]);
|
||||
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("Failed get name tabel", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
|
||||
$dataparam = json_encode(array(
|
||||
"table" => $table,
|
||||
"data" => $rows
|
||||
));
|
||||
|
||||
if (count($rows) > 0) {
|
||||
$z_param = gzcompress($dataparam, 9);
|
||||
$url = "https://" . $this->hostname . "/one-api-lab/tools/synctable/update";
|
||||
$resp = $this->post($url, $z_param);
|
||||
$j_resp = json_decode($resp, true);
|
||||
|
||||
sleep(2);
|
||||
|
||||
if ($j_resp["status"] == "OK") {
|
||||
$this->db->trans_commit();
|
||||
$this->reply([
|
||||
"status" => "OK",
|
||||
"message" => 'Proses sync tabel ' . $table . ' berhasil',
|
||||
"total received" => $j_resp['total_received'],
|
||||
"total success" => $j_resp['total_success']
|
||||
]);
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->reply([
|
||||
"status" => "ERR",
|
||||
'message' => "Gagal sync pada tabel " . $table,
|
||||
'debug' => print_r($resp, true)
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->reply([
|
||||
"status" => "OK",
|
||||
'message' => "Tidak Ada Data Pada Tabel " . $table
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function getdata_t_test($table, $lastdownload)
|
||||
{
|
||||
$this->db->trans_begin();
|
||||
|
||||
$lastdownload_full = $lastdownload . " 00:00:00";
|
||||
|
||||
$sql = "SELECT * FROM $table WHERE T_TestLastUpdated > ?";
|
||||
$qry = $this->db->query($sql, [
|
||||
$lastdownload_full
|
||||
]);
|
||||
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("Failed get name tabel", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
|
||||
$dataparam = json_encode(array(
|
||||
"table" => $table,
|
||||
"data" => $rows
|
||||
));
|
||||
|
||||
if (count($rows) > 0) {
|
||||
$z_param = gzcompress($dataparam, 9);
|
||||
$url = "https://" . $this->hostname . "/one-api-lab/tools/synctable/update";
|
||||
$resp = $this->post($url, $z_param);
|
||||
$j_resp = json_decode($resp, true);
|
||||
|
||||
sleep(2);
|
||||
|
||||
if ($j_resp["status"] == "OK") {
|
||||
$this->db->trans_commit();
|
||||
$this->reply([
|
||||
"status" => "OK",
|
||||
"message" => 'Proses sync tabel ' . $table . ' berhasil',
|
||||
"total received" => $j_resp['total_received'],
|
||||
"total success" => $j_resp['total_success']
|
||||
]);
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->reply([
|
||||
"status" => "ERR",
|
||||
'message' => "Gagal sync pada tabel " . $table,
|
||||
'debug' => print_r($resp, true)
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->reply([
|
||||
"status" => "OK",
|
||||
'message' => "Tidak Ada Data Pada Tabel " . $table
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function getdata_nat_normalvalue($table, $lastdownload)
|
||||
{
|
||||
$this->db->trans_begin();
|
||||
|
||||
$lastdownload_full = $lastdownload . " 00:00:00";
|
||||
|
||||
$sql = "SELECT * FROM $table WHERE Nat_NormalValueLastUpdated > ?";
|
||||
$qry = $this->db->query($sql, [
|
||||
$lastdownload_full
|
||||
]);
|
||||
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("Failed get name tabel", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
|
||||
$dataparam = json_encode(array(
|
||||
"table" => $table,
|
||||
"data" => $rows
|
||||
));
|
||||
|
||||
if (count($rows) > 0) {
|
||||
$z_param = gzcompress($dataparam, 9);
|
||||
$url = "https://" . $this->hostname . "/one-api-lab/tools/synctable/update";
|
||||
$resp = $this->post($url, $z_param);
|
||||
$j_resp = json_decode($resp, true);
|
||||
|
||||
sleep(2);
|
||||
|
||||
if ($j_resp["status"] == "OK") {
|
||||
$this->db->trans_commit();
|
||||
$this->reply([
|
||||
"status" => "OK",
|
||||
"message" => 'Proses sync tabel ' . $table . ' berhasil',
|
||||
"total received" => $j_resp['total_received'],
|
||||
"total success" => $j_resp['total_success']
|
||||
]);
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->reply([
|
||||
"status" => "ERR",
|
||||
'message' => "Gagal sync pada tabel " . $table,
|
||||
'debug' => print_r($resp, true)
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->reply([
|
||||
"status" => "OK",
|
||||
'message' => "Tidak Ada Data Pada Tabel " . $table
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function getdata_nat_subgroup($table, $lastdownload)
|
||||
{
|
||||
$this->db->trans_begin();
|
||||
|
||||
$lastdownload_full = $lastdownload . " 00:00:00";
|
||||
|
||||
$sql = "SELECT * FROM $table WHERE Nat_SubGroupLastUpdated > ?";
|
||||
$qry = $this->db->query($sql, [
|
||||
$lastdownload_full
|
||||
]);
|
||||
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("Failed get name tabel", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
|
||||
$dataparam = json_encode(array(
|
||||
"table" => $table,
|
||||
"data" => $rows
|
||||
));
|
||||
|
||||
if (count($rows) > 0) {
|
||||
$z_param = gzcompress($dataparam, 9);
|
||||
$url = "https://" . $this->hostname . "/one-api-lab/tools/synctable/update";
|
||||
$resp = $this->post($url, $z_param);
|
||||
$j_resp = json_decode($resp, true);
|
||||
|
||||
sleep(2);
|
||||
|
||||
if ($j_resp["status"] == "OK") {
|
||||
$this->db->trans_commit();
|
||||
$this->reply([
|
||||
"status" => "OK",
|
||||
"message" => 'Proses sync tabel ' . $table . ' berhasil',
|
||||
"total received" => $j_resp['total_received'],
|
||||
"total success" => $j_resp['total_success']
|
||||
]);
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->reply([
|
||||
"status" => "ERR",
|
||||
'message' => "Gagal sync pada tabel " . $table,
|
||||
'debug' => print_r($resp, true)
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->reply([
|
||||
"status" => "OK",
|
||||
'message' => "Tidak Ada Data Pada Tabel " . $table
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function getdata_t_sampletype($table, $lastdownload)
|
||||
{
|
||||
$this->db->trans_begin();
|
||||
|
||||
$lastdownload_full = $lastdownload . " 00:00:00";
|
||||
|
||||
$sql = "SELECT * FROM $table WHERE T_SampleTypeLastUpdated > ?";
|
||||
$qry = $this->db->query($sql, [
|
||||
$lastdownload_full
|
||||
]);
|
||||
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("Failed get name tabel", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
|
||||
$dataparam = json_encode(array(
|
||||
"table" => $table,
|
||||
"data" => $rows
|
||||
));
|
||||
|
||||
if (count($rows) > 0) {
|
||||
$z_param = gzcompress($dataparam, 9);
|
||||
$url = "https://" . $this->hostname . "/one-api-lab/tools/synctable/update";
|
||||
$resp = $this->post($url, $z_param);
|
||||
$j_resp = json_decode($resp, true);
|
||||
|
||||
sleep(2);
|
||||
|
||||
if ($j_resp["status"] == "OK") {
|
||||
$this->db->trans_commit();
|
||||
$this->reply([
|
||||
"status" => "OK",
|
||||
"message" => 'Proses sync tabel ' . $table . ' berhasil',
|
||||
"total received" => $j_resp['total_received'],
|
||||
"total success" => $j_resp['total_success']
|
||||
]);
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->reply([
|
||||
"status" => "ERR",
|
||||
'message' => "Gagal sync pada tabel " . $table,
|
||||
'debug' => print_r($resp, true)
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->reply([
|
||||
"status" => "OK",
|
||||
'message' => "Tidak Ada Data Pada Tabel " . $table
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function getdata_t_bahan($table, $lastdownload)
|
||||
{
|
||||
$this->db->trans_begin();
|
||||
|
||||
$lastdownload_full = $lastdownload . " 00:00:00";
|
||||
|
||||
$sql = "SELECT * FROM $table WHERE T_BahanLastUpdated > ?";
|
||||
$qry = $this->db->query($sql, [
|
||||
$lastdownload_full
|
||||
]);
|
||||
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("Failed get name tabel", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
|
||||
$dataparam = json_encode(array(
|
||||
"table" => $table,
|
||||
"data" => $rows
|
||||
));
|
||||
|
||||
if (count($rows) > 0) {
|
||||
$z_param = gzcompress($dataparam, 9);
|
||||
$url = "https://" . $this->hostname . "/one-api-lab/tools/synctable/update";
|
||||
$resp = $this->post($url, $z_param);
|
||||
$j_resp = json_decode($resp, true);
|
||||
|
||||
sleep(2);
|
||||
|
||||
if ($j_resp["status"] == "OK") {
|
||||
$this->db->trans_commit();
|
||||
$this->reply([
|
||||
"status" => "OK",
|
||||
"message" => 'Proses sync tabel ' . $table . ' berhasil',
|
||||
"total received" => $j_resp['total_received'],
|
||||
"total success" => $j_resp['total_success']
|
||||
]);
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->reply([
|
||||
"status" => "ERR",
|
||||
'message' => "Gagal sync pada tabel " . $table,
|
||||
'debug' => print_r($resp, true)
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->reply([
|
||||
"status" => "OK",
|
||||
'message' => "Tidak Ada Data Pada Tabel " . $table
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function getdata_nat_methode($table, $lastdownload)
|
||||
{
|
||||
$this->db->trans_begin();
|
||||
|
||||
$lastdownload_full = $lastdownload . " 00:00:00";
|
||||
|
||||
$sql = "SELECT * FROM $table WHERE Nat_MethodeLastUpdated > ?";
|
||||
$qry = $this->db->query($sql, [
|
||||
$lastdownload_full
|
||||
]);
|
||||
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("Failed get name tabel", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
|
||||
$dataparam = json_encode(array(
|
||||
"table" => $table,
|
||||
"data" => $rows
|
||||
));
|
||||
|
||||
if (count($rows) > 0) {
|
||||
$z_param = gzcompress($dataparam, 9);
|
||||
$url = "https://" . $this->hostname . "/one-api-lab/tools/synctable/update";
|
||||
$resp = $this->post($url, $z_param);
|
||||
$j_resp = json_decode($resp, true);
|
||||
|
||||
sleep(2);
|
||||
|
||||
if ($j_resp["status"] == "OK") {
|
||||
$this->db->trans_commit();
|
||||
$this->reply([
|
||||
"status" => "OK",
|
||||
"message" => 'Proses sync tabel ' . $table . ' berhasil',
|
||||
"total received" => $j_resp['total_received'],
|
||||
"total success" => $j_resp['total_success']
|
||||
]);
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->reply([
|
||||
"status" => "ERR",
|
||||
'message' => "Gagal sync pada tabel " . $table,
|
||||
'debug' => print_r($resp, true)
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->reply([
|
||||
"status" => "OK",
|
||||
'message' => "Tidak Ada Data Pada Tabel " . $table
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function getdata_nat_instrument($table, $lastdownload)
|
||||
{
|
||||
$this->db->trans_begin();
|
||||
|
||||
$lastdownload_full = $lastdownload . " 00:00:00";
|
||||
|
||||
$sql = "SELECT * FROM $table WHERE Nat_InstrumentLastUpdated > ?";
|
||||
$qry = $this->db->query($sql, [
|
||||
$lastdownload_full
|
||||
]);
|
||||
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("Failed get name tabel", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
|
||||
$dataparam = json_encode(array(
|
||||
"table" => $table,
|
||||
"data" => $rows
|
||||
));
|
||||
|
||||
if (count($rows) > 0) {
|
||||
$z_param = gzcompress($dataparam, 9);
|
||||
$url = "https://" . $this->hostname . "/one-api-lab/tools/synctable/update";
|
||||
$resp = $this->post($url, $z_param);
|
||||
$j_resp = json_decode($resp, true);
|
||||
|
||||
sleep(2);
|
||||
|
||||
if ($j_resp["status"] == "OK") {
|
||||
$this->db->trans_commit();
|
||||
$this->reply([
|
||||
"status" => "OK",
|
||||
"message" => 'Proses sync tabel ' . $table . ' berhasil',
|
||||
"total received" => $j_resp['total_received'],
|
||||
"total success" => $j_resp['total_success']
|
||||
]);
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->reply([
|
||||
"status" => "ERR",
|
||||
'message' => "Gagal sync pada tabel " . $table,
|
||||
'debug' => print_r($resp, true)
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->reply([
|
||||
"status" => "OK",
|
||||
'message' => "Tidak Ada Data Pada Tabel " . $table
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function getdata_m_instrumentmethode($table, $lastdownload)
|
||||
{
|
||||
$this->db->trans_begin();
|
||||
|
||||
$lastdownload_full = $lastdownload . " 00:00:00";
|
||||
|
||||
$sql = "SELECT * FROM $table WHERE M_InstrumentMethodeLastUpdated > ?";
|
||||
$qry = $this->db->query($sql, [
|
||||
$lastdownload_full
|
||||
]);
|
||||
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("Failed get name tabel", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
|
||||
$dataparam = json_encode(array(
|
||||
"table" => $table,
|
||||
"data" => $rows
|
||||
));
|
||||
|
||||
if (count($rows) > 0) {
|
||||
$z_param = gzcompress($dataparam, 9);
|
||||
$url = "https://" . $this->hostname . "/one-api-lab/tools/synctable/update";
|
||||
$resp = $this->post($url, $z_param);
|
||||
$j_resp = json_decode($resp, true);
|
||||
|
||||
sleep(2);
|
||||
|
||||
if ($j_resp["status"] == "OK") {
|
||||
$this->db->trans_commit();
|
||||
$this->reply([
|
||||
"status" => "OK",
|
||||
"message" => 'Proses sync tabel ' . $table . ' berhasil',
|
||||
"total received" => $j_resp['total_received'],
|
||||
"total success" => $j_resp['total_success']
|
||||
]);
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->reply([
|
||||
"status" => "ERR",
|
||||
'message' => "Gagal sync pada tabel " . $table,
|
||||
'debug' => print_r($resp, true)
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->reply([
|
||||
"status" => "OK",
|
||||
'message' => "Tidak Ada Data Pada Tabel " . $table
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function getdata_nat_unit($table, $lastdownload)
|
||||
{
|
||||
$this->db->trans_begin();
|
||||
|
||||
$lastdownload_full = $lastdownload . " 00:00:00";
|
||||
|
||||
$sql = "SELECT * FROM $table WHERE Nat_UnitLastUpdated > ?";
|
||||
$qry = $this->db->query($sql, [
|
||||
$lastdownload_full
|
||||
]);
|
||||
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("Failed get name tabel", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
|
||||
$dataparam = json_encode(array(
|
||||
"table" => $table,
|
||||
"data" => $rows
|
||||
));
|
||||
|
||||
if (count($rows) > 0) {
|
||||
$z_param = gzcompress($dataparam, 9);
|
||||
$url = "https://" . $this->hostname . "/one-api-lab/tools/synctable/update";
|
||||
$resp = $this->post($url, $z_param);
|
||||
$j_resp = json_decode($resp, true);
|
||||
|
||||
sleep(2);
|
||||
|
||||
if ($j_resp["status"] == "OK") {
|
||||
$this->db->trans_commit();
|
||||
$this->reply([
|
||||
"status" => "OK",
|
||||
"message" => 'Proses sync tabel ' . $table . ' berhasil',
|
||||
"total received" => $j_resp['total_received'],
|
||||
"total success" => $j_resp['total_success']
|
||||
]);
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->reply([
|
||||
"status" => "ERR",
|
||||
'message' => "Gagal sync pada tabel " . $table,
|
||||
'debug' => print_r($resp, true)
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->reply([
|
||||
"status" => "OK",
|
||||
'message' => "Tidak Ada Data Pada Tabel " . $table
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function get_update($lastdownload)
|
||||
{
|
||||
$this->getdata_nat_test('nat_test', $lastdownload);
|
||||
echo "\n";
|
||||
$this->getdata_t_test('t_test', $lastdownload);
|
||||
echo "\n";
|
||||
$this->getdata_nat_normalvalue('nat_normalvalue', $lastdownload);
|
||||
echo "\n";
|
||||
$this->getdata_nat_subgroup('nat_subgroup', $lastdownload);
|
||||
echo "\n";
|
||||
$this->getdata_t_sampletype('t_sampletype', $lastdownload);
|
||||
echo "\n";
|
||||
$this->getdata_t_bahan('t_bahan', $lastdownload);
|
||||
echo "\n";
|
||||
$this->getdata_nat_methode('nat_methode', $lastdownload);
|
||||
echo "\n";
|
||||
$this->getdata_nat_instrument('nat_instrument', $lastdownload);
|
||||
echo "\n";
|
||||
$this->getdata_m_instrumentmethode('m_instrumentmethode', $lastdownload);
|
||||
echo "\n";
|
||||
$this->getdata_nat_unit('nat_unit', $lastdownload);
|
||||
}
|
||||
|
||||
public function getdata_bkp($table, $colupdated, $lastdownload)
|
||||
{
|
||||
$sql = "SELECT * FROM $table WHERE $colupdated > ?";
|
||||
$qry = $this->db->query($sql, [
|
||||
$lastdownload
|
||||
]);
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("Failed get name tabel", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
$result = array(
|
||||
"total" => count($rows),
|
||||
"record" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
13
application/controllers/tools/Syskapus.php
Normal file
13
application/controllers/tools/Syskapus.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
class Syskapus extends CI_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
public function calc($date) {
|
||||
$this->load->library("Kapus");
|
||||
$rst = $this->kapus->calc($date);
|
||||
print_r($rst);
|
||||
}
|
||||
}
|
||||
1242
application/controllers/tools/Tat-bkp.php
Normal file
1242
application/controllers/tools/Tat-bkp.php
Normal file
File diff suppressed because it is too large
Load Diff
1310
application/controllers/tools/Tat-devone.php
Normal file
1310
application/controllers/tools/Tat-devone.php
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user