$arr[1]){
return "text-danger";
}
else{
return "";
}
}
else{
$part=["","","",""];
if(!empty($arr[0])){
$part[1]=$arr[0];
}
else{
$part[0]="<";
}
if(!empty($arr[1])){
$part[3]=$arr[1];
}
else{
$part[0]=">";
}
if(!empty($arr[0]) && !empty($arr[1])){
$part[2]="-";
}
return implode("",$part);
}
}
function schema2form($file, $pid=null, $id=null, $cat=null, $data=null, $time=null){
global $db;
$schema=json_decode(file_get_contents($file));
$lockpid="";
if(!empty($pid) && !empty($id) && !empty($cat)){
$data=json_decode($db->getData($pid, $id, $cat)->fetchArray()["data"]);
}
elseif(!empty($pid) && $file=="forms/admission.schema.json"){
$data=json_decode($db->getAdmissionData($pid)->fetchArray()["data"]);
$lockpid="readonly";
}
elseif(!empty($pid) && $file=="forms/history.schema.json"){
$data=json_decode($db->getHistory($pid)->fetchArray()["history"]);
$lockpid="readonly";
}
$form="
";
return $form;
}
function getInfo($pid){
global $db;
$info="";
$info=$info."ID | ".$pid." |
";
$info=$info."Name | ".$db->getName($pid)->fetchArray()["name"]." |
";
$info=$info."Age | ".$db->getAge($pid)->fetchArray()["age"]." |
";
$info=$info."Sex | ".$db->getSex($pid)->fetchArray()["sex"]." |
";
$info=$info."Bed | ".$db->getWard($pid)->fetchArray()["ward"]."-".$db->getBed($pid)->fetchArray()["bed"]." |
";
$info=$info."Diagnosis | ".$db->getDiagnosis($pid)->fetchArray()["diagnosis"]." |
";
$info=$info."
";
return $info;
}
function viewData($data, $edit=null){
if(!empty($data)){
$data=json_decode($data);
if(!empty($data->form)){
$schema=json_decode(file_get_contents("forms/".$data->form.".schema.json"));
}
unset($data->cat);
$view="";
if(!empty($schema->description)){
$description=$schema->description;
}
else{
$description="";
}
if(!empty($data->date)){
if(!empty($data->time)){
$date=date("M d, Y h:i a", strtotime($data->date." ".$data->time));
}
else{
$date=$data->date;
}
}
else{
$date="";
}
if(!empty($data->rdate)){
if(!empty($data->rtime)){
$rdate=date("M d, Y h:i a", strtotime($data->rdate." ".$data->rtime));
}
else{
$rdate=$data->rdate;
}
}
else{
$rdate="";
}
$view=$view."".$description." | ".$date." | ";
$view=$view." | ";
$view=$view."
";
if(!empty($rdate)){
$view=$view."Reported | ".$rdate." | ";
$view=$view." | ";
$view=$view."
";
}
foreach($data as $field=>$value){
$warn="";
if(!empty($schema->properties->$field->range)){
$warn=resolveRange($schema->properties->$field->range, $value);
}
else{
$warn="";
}
if(!empty($value) && $field!="form" && $field!="date" && $field!="time" && $field!="rdate" && $field!="rtime"){
if(!empty($schema->properties->$field)){
$view=$view."".$schema->properties->$field->description." | ".$value." | ";
if(!empty($schema->properties->$field->range)){
$view=$view."".resolveRange($schema->properties->$field->range)." | ";
}
else{
$view=$view." | ";
}
$view=$view."
";
}
elseif($field=="extra_note"){
$view=$view."Extra Notes | ".$value." | |
";
}
else{
$view=$view."".$field." | ".$value." | |
";
}
}
}
if(!empty($edit)){
$view=$view."Edit";
}
$view=$view." |
";
return $view;
}
else{
return "";
}
}
function viewAntibiogram($data, $edit=null){
$data=json_decode($data);
$view="";
$view=$view."Vitek Report | ".$data->date." |
";
if(!empty($data->rdate)){
$view=$view."Reported on | ".$data->rdate." |
";
}
$view=$view."Sample | ".$data->sample." |
";
$view=$view."Lab ID | ".$data->labid." |
";
$view=$view."Organism | ".$data->organism." |
";
$view=$view."Antibiotic | MIC | Interpretation | ";
foreach($data as $k=>$v){
if(is_object($v)){
$view=$view."
---|
".$v->name." | ".$v->mic." | ".$v->interpretation." |
";
}
}
if(!empty($data->note)){
$view=$view."Note | ".$data->note." |
";
}
if(!empty($edit)){
$view=$view."Edit |
";
}
$view=$view."
";
return $view;
}
function view_drug($file){
if(is_file($file)){
$druglist=json_decode(file_get_contents($file));
}
else{
$druglist=[];
}
$view="";
$view=$view."Drug | Dose | Route | Frequency | Duration |
";
foreach($druglist as $id=>$drug){
if($drug->omit){
$omit="style='display:none'";
}
else{
$omit="";
}
$view=$view."".$drug->drug." | ".$drug->dose." | ".$drug->route." | ".$drug->freq." | ".$drug->duration." | ".$drug->note." | |
";
}
$view=$view."
";
return $view;
}
?>