2 // Copyright (C) 2011 Ken Chapple <ken@mi-squared.com>
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 require_once('ClinicalType.php');
11 class PhysicalExam
extends ClinicalType
13 const NOT_DONE_PATIENT
= 'phys_exm_not_done_patient';
14 const NOT_DONE_MEDICAL
= 'phys_exm_not_done_medical';
15 const NOT_DONE_SYSTEM
= 'phys_exm_not_done_system';
16 const FINDING_BMI_PERC
= 'phys_exm_finding_bmi_perc';
18 public function getListId()
20 return 'Clinical_Rules_Phys_Exm_Type';
23 public function getListType()
25 return "medical_problem"; // TODO this may not be the correct type for BMI icd9 codes
28 public function doPatientCheck(RsPatient
$patient, $beginDate = null, $endDate = null, $options = null)
30 $data = Codes
::lookup($this->getOptionId());
31 $type = $this->getListType();
32 foreach ($data as $codeType => $codes) {
33 foreach ($codes as $code) {
34 if (exist_lists_item($patient->id
, $type, $codeType.'::'.$code, $endDate)) {
40 if ($this->getOptionId() == self
::FINDING_BMI_PERC
) {
41 // check for any BMI percentile finding
42 // there are a few BMI codes, but it doesn't matter,
43 // because we just want to check for any finding
44 $query = "SELECT form_vitals.BMI " .
45 "FROM `form_vitals` " .
46 "WHERE form_vitals.BMI IS NOT NULL " .
47 "AND form_vitals.pid = ? " .
48 "AND DATE( form_vitals.date ) >= ? " .
49 "AND DATE( form_vitals.date ) <= ? ";
50 $res = sqlStatement($query, array( $patient->id
, $beginDate, $endDate ));
51 $number = sqlNumRows($res);