$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="
"; $form=$form.""; foreach($schema->properties as $field=>$prop){ if($prop->type == "integer") $prop->type="number"; if($prop->type == "string") $prop->type="text"; if(!empty($data->$field)){ $value="value='".$data->$field."'"; $value2=$data->$field; } elseif(!empty($time) && $field=="date"){ $value="value='".date("Y-m-d", $time)."'"; $value2=date("Y-m-d", $time); } elseif(!empty($time) && $field=="time"){ $value="value='".date("H:i", $time)."'"; $value2=date("H:i", $time); } else{ $value=""; $value2=""; } if(in_array($field, $schema->required)){ $req="required"; } else{ $req=""; } if(isSet($prop->format)){ $type=$prop->format; } else{ $type=$prop->type; } $form=$form."
"; $form=$form.""; if(isSet($prop->enum)){ $form=$form.""; } elseif(isSet($prop->format) && $prop->format=="textarea"){ $form=$form.""; } elseif($field=="pid"){ $form=$form.""; } else{ $form=$form.""; } $form=$form."
"; } if(!empty($data->extra_note)){ $extra_note=$data->extra_note; } else{ $extra_note=""; } $form=$form."
"; $form=$form.""; $form=$form."
"; return $form; } function getInfo($pid){ global $db; $info=""; $info=$info.""; $info=$info.""; $info=$info.""; $info=$info.""; $info=$info.""; $info=$info.""; $info=$info."
ID".$pid."
Name".$db->getName($pid)->fetchArray()["name"]."
Age".$db->getAge($pid)->fetchArray()["age"]."
Sex".$db->getSex($pid)->fetchArray()["sex"]."
Bed".$db->getWard($pid)->fetchArray()["ward"]."-".$db->getBed($pid)->fetchArray()["bed"]."
Diagnosis".$db->getDiagnosis($pid)->fetchArray()["diagnosis"]."
"; 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.""; $view=$view.""; $view=$view.""; if(!empty($rdate)){ $view=$view.""; $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.""; if(!empty($schema->properties->$field->range)){ $view=$view.""; } else{ $view=$view.""; } $view=$view.""; } elseif($field=="extra_note"){ $view=$view.""; } else{ $view=$view.""; } } } if(!empty($edit)){ $view=$view."
".$description."".$date."
Reported".$rdate."
".$schema->properties->$field->description."".$value."".resolveRange($schema->properties->$field->range)."
Extra Notes
".$value."
".$field."".$value."
Edit"; } $view=$view."
"; return $view; } else{ return ""; } } function viewAntibiogram($data, $edit=null){ $data=json_decode($data); $view=""; $view=$view.""; if(!empty($data->rdate)){ $view=$view.""; } $view=$view.""; $view=$view.""; $view=$view.""; $view=$view.""; foreach($data as $k=>$v){ if(is_object($v)){ $view=$view.""; } } if(!empty($data->note)){ $view=$view.""; } if(!empty($edit)){ $view=$view.""; } $view=$view."
Vitek Report".$data->date."
Reported on".$data->rdate."
Sample".$data->sample."
Lab ID".$data->labid."
Organism".$data->organism."
AntibioticMICInterpretation
".$v->name."".$v->mic."".$v->interpretation."
Note".$data->note."
Edit
"; return $view; } function view_drug($file){ if(is_file($file)){ $druglist=json_decode(file_get_contents($file)); } else{ $druglist=[]; } $view="
"; $view=$view.""; foreach($druglist as $id=>$drug){ if($drug->omit){ $omit="style='display:none'"; } else{ $omit=""; } $view=$view.""; } $view=$view."
DrugDoseRouteFrequencyDuration
".$drug->drug."".$drug->dose."".$drug->route."".$drug->freq."".$drug->duration."".$drug->note."
"; return $view; } ?>