another minor fix to prior commit
[openemr.git] / library / classes / ClinicalTypes / Medication.php
blobd5f9249c838a2c26701e4dd889153c73bf6da97d
1 <?php
2 // Copyright (C) 2011 Ken Chapple <ken@mi-squared.com>
3 //
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.
8 //
9 require_once( 'ClinicalType.php' );
11 class Medication extends ClinicalType
13 const OPTION_COUNT = 'count';
14 const OPTION_UNIQUE_DATES = 'unique';
16 const DTAP_VAC = 'med_admin_dtap';
17 const HEP_A_VAC = 'med_admin_hep_a_vac';
18 const HEP_B_VAC = 'med_admin_hep_b_vac';
19 const HIB = 'med_admin_hib';
20 const MEASLES_VAC = 'med_admin_meas_vac';
21 const MMR = 'med_admin_mmr';
22 const IPV = 'med_admin_ipv';
23 const MUMPS_VAC = 'med_admin_mumps_vac';
24 const PNEUMOCOCCAL_VAC = 'med_admin_pneumococcal_vac';
25 const ROTAVIRUS_VAC = 'med_admin_rotavirus_vac';
26 const RUBELLA_VAC = 'med_admin_rubella_vac';
27 const VZV = 'med_admin_vzv';
28 const INFLUENZA_VAC = 'med_admin_influenza_vac';
30 const NO_INFLUENZA_CONTRADICTION = 'med_not_done_flu_immun_contradiction';
31 const NO_INFLUENZA_DECLINED = 'med_not_done_flu_immun_declined';
32 const NO_INFLUENZA_PATIENT = 'med_not_done_flu_vac_pat_reas';
33 const NO_INFLUENZA_MEDICAL = 'med_not_done_flu_vac_med_reas';
34 const NO_INFLUENZA_SYSTEM = 'med_not_done_flu_vac_sys_reas';
36 const ADVERSE_EVT_FLU_IMMUN = 'med_adverse_evt_flu_immun';
37 const INTOLERANCE_FLU_IMMUN = 'med_intolerance_flu_immun';
39 const DISP_DIABETES = 'med_disp_diabetes';
40 const ORDER_DIABETES = 'med_order_diabetes';
41 const ACTIVE_DIABETES = 'med_active_diabetes';
43 const SMOKING_CESSATION = 'med_active_smoking_cessation';
44 const SMOKING_CESSATION_ORDER = 'med_order_smoking_cessation';
46 const ANTIBIOTIC_FOR_PHARYNGITIS = 'med_antibiotic_pharyngitis';
47 const INFLUENZA_VACCINE = 'med_influenza_vaccination';
49 public function getListId() {
50 return "Clinical_Rules_Med_Types";
53 public function doPatientCheck( RsPatient $patient, $beginDate = null, $endDate = null, $options = null )
55 $return = false;
56 $listOptions = Codes::lookup( $this->getOptionId(), 'CVX' );
57 if ( count( $listOptions ) > 0 )
59 $sqlQueryBind= array();
60 $query = "SELECT * " .
61 "FROM immunizations " .
62 "WHERE patient_id = ? AND added_erroneously = '0' " .
63 "AND administered_date >= ? " .
64 "AND administered_date <= ? ";
65 $query.= "AND ( ";
66 $count = 0;
67 array_push($sqlQueryBind,$patient->id,$beginDate,$endDate);
68 foreach( $listOptions as $option_id ) {
69 $query.= "cvx_code = ? ";
70 $count++;
71 if ( $count < count( $listOptions ) ) {
72 $query.= "OR ";
74 array_push($sqlQueryBind,$option_id);
76 $query.= " ) ";
78 $result = sqlStatement( $query, $sqlQueryBind );
79 $rows = array();
80 for( $iter = 0; $row = sqlFetchArray( $result ); $iter++ ) {
81 $rows[$iter] = $row;
84 if ( isset( $options[self::OPTION_COUNT] ) &&
85 count( $rows ) >= $options[self::OPTION_COUNT] ) {
86 $return = true;
87 } else if ( !isset( $options[self::OPTION_COUNT] ) &&
88 count( $rows ) > 0 ) {
89 $return = true;
93 return $return;