98 lines
2.6 KiB
PHP
98 lines
2.6 KiB
PHP
<?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;
|
|
}
|
|
}
|