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() {
19 return 'Clinical_Rules_Phys_Exm_Type';
22 public function getListType() {
23 return "medical_problem"; // TODO this may not be the correct type for BMI icd9 codes
26 public function doPatientCheck( RsPatient
$patient, $beginDate = null, $endDate = null, $options = null )
28 $data = Codes
::lookup( $this->getOptionId() );
29 $type = $this->getListType();
30 foreach( $data as $codeType => $codes ) {
31 foreach ( $codes as $code ) {
32 if ( exist_lists_item( $patient->id
, $type, $codeType.'::'.$code, $endDate ) ) {
38 if ( $this->getOptionId() == self
::FINDING_BMI_PERC
) {
39 // check for any BMI percentile finding
40 // there are a few BMI codes, but it doesn't matter,
41 // because we just want to check for any finding
42 $query = "SELECT form_vitals.BMI " .
43 "FROM `form_vitals` " .
44 "WHERE form_vitals.BMI IS NOT NULL " .
45 "AND form_vitals.pid = ? " .
46 "AND DATE( form_vitals.date ) >= ? " .
47 "AND DATE( form_vitals.date ) <= ? ";
48 $res = sqlStatement( $query, array( $patient->id
, $beginDate, $endDate ) );
49 $number = sqlNumRows($res);