Files
2026-04-15 15:23:57 +07:00

227 lines
5.7 KiB
PHP

<?php
class Fisio extends MY_Controller
{
public function __construct()
{
parent::__construct();
}
function get($id)
{
$sql = "select * from so_resultentry_fisioterapi
where So_ResultEntdyFisioterapiSo_ResultEntryID=?";
$qry = $this->db->query($sql, [$id]);
if (!$qry) {
echo json_encode(["status" => "ERR", "message" => $this->db->error()["message"]]);
exit;
}
$rows = $qry->result_array();
if (count($rows) == 0) {
echo json_encode(["status" => "OK", "data" => []]);
exit;
}
$r = $rows[0];
$arr = json_decode($r["So_ResultEntdyFisioterapiDetails"], true);
if (json_last_error() != JSON_ERROR_NONE) {
echo json_encode(["status" => "ERR", "message" => "Json Error: " . json_last_error_msg()]);
exit;
}
$result = [];
foreach ($arr as $r) {
$xr = $this->get_det($r);
$result = array_merge($result, $xr);
}
//echo json_encode(["status" => "OK", "data" => $result]);
echo json_encode($result);
}
function get_det($arr)
{
$r = [];
$code = $arr["label"];
foreach ($arr["input"] as $k => $v) {
if ($arr["code"] == "A") {
if ($k == "type") {
$r[] = [
"code" => $code,
"label" => $k,
"value" => implode("\n", $v),
"unit" => ""
];
} else {
$r[] = [
"code" => $code,
"label" => ucwords(str_replace('_', ' ', $k)),
"value" => $v,
"unit" => ""
];
}
} else if ($arr["code"] == "B") {
$r[] = [
"code" => $code,
"label" => $v["label"],
"value" => $v["value"],
"unit" => $v["unit"],
];
} else if ($arr["code"] == "C") {
$r[] = [
"code" => $code,
"label" => $v["label"],
"value" => $v["value"],
"unit" => $v["unit"],
];
} else if ($arr["code"] == "D") {
$code = $arr["label"];
$hasil = $arr["resultValue"] ;
if ($k == 0) {
$r[] = [
"code" => $code,
"label" => "resultValue",
"value" => implode("\n", $hasil),
"unit" => "",
];
}
$r[] = [
"code" => $code,
"label" => $v["pertanyaan"],
"value" => $v["value"],
"unit" => $v["code"],
];
} else if ($arr["code"] == "E") {
$code = $arr["label"];
foreach ($v["input"] as $vv) {
$r[] = [
"code" => $code,
"label" => $v["label"],
"value" => $vv["code"].". " .$vv["keterangan"],
"unit" => $vv["value"],
];
}
}
else if ($arr["code"] == "F") {
$code = $arr["label"];
if ($v["label"] == "khusus note") {
$r[] = [
"code" => "",
"label" => "",
"value" => "",
"unit" => "",
];
} else {
$r[] = [
"code" => $code,
"label" => $v["label"],
"value" => $v["code"],
"unit" => $v["value"],
];
}
}
else if (
$arr["code"] == "G"
|| $arr["code"] == "H"
) {
$r[] = [
"code" => $code,
"label" => $v["label"],
"value" => implode("\n", $v["value"]),
"unit" => $v["value"],
];
}
if ($arr["code"] == "F") {
foreach ($arr["khusus"] as $v)
{
$r[] = [
"code" => $arr["label"] . " khusus",
"label" => $v["label"],
// "value" => implode("<br/>", $v["value"]),
"value" => $v["value"] ,
"unit" => "",
];
}
foreach ($arr["penunjang"] as $v) {
$r[] = [
"code" => $arr["label"] . " penunjang",
"label" => $v["label"],
// "value" => implode("<br/>", $v["value"]),
"value" => $v["value"] ,
"unit" => "",
];
}
// $r[] = [
// "code" => $arr["label"],
// "label" => " khusus note",
// "value" => $arr["khusus_note"],
// "unit" => "",
// ];
}
}
if ( $arr["code"] == "I" || $arr["code"] == "J") {
$r[] = [
"code" => $code,
"label" => $arr["label"],
"value" => $arr["value"],
"unit" => "",
];
}
else if ($arr["code"] == "L") {
$vals = $arr["value"];
$value = "";
foreach ($vals as $vv) {
if ($vv == "Pasien") {
$value = "Pasien";
}
}
$r[] = [
"code" => $code,
"label" => $arr["nama"],
"value" => $value,
"unit" => $arr["alasan"],
];
} else if ($arr["code"] == "M") {
$r[] = [
"code" => $code,
"label" => $arr["label"],
"value" => $arr["value"],
"unit" => "",
];
} else if ($arr["code"] == "K") {
$code = $arr["label"];
$hasil = $arr["data"] ;
foreach ($hasil as $vv) {
$r[] = [
"code" => $code,
"label" => $vv["tanggal"],
"value" => $vv["intervensi"],
"unit" => $vv["tempat"],
];
} }
foreach ($r as $idx => $rd) {
if (is_array($rd["value"])) {
$r[$idx]["value"] = implode(",", $rd["value"]);
}
}
return $r;
}
// function get($arr,$keys) {
// $rx = [];
// foreach($keys as $k) {
// foreach($arr[v] as $dt) {
// $label = $l;
// }
// $value = implode("<br/>",$v);
// $unit = "";
// if (key_
// $rx[] = ["label"=>$label, "value"=>$value, "unit" => $unit];
// }
// }
}