some more integration work for previous commit
[openemr.git] / library / classes / ClinicalTypes / Medication.php
blobebea3db848a1e45db1c2a59905ea166e4880589f
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 public function getListId() {
47 return "Clinical_Rules_Med_Types";
50 public function doPatientCheck( RsPatient $patient, $beginDate = null, $endDate = null, $options = null )
52 $return = false;
53 $listOptions = Codes::lookup( $this->getOptionId(), 'CVX' );
54 if ( count( $listOptions ) > 0 )
56 $sqlQueryBind= array();
57 $query = "SELECT * " .
58 "FROM immunizations " .
59 "WHERE patient_id = ? AND added_erroneously = '0' " .
60 "AND administered_date >= ? " .
61 "AND administered_date <= ? ";
62 $query.= "AND ( ";
63 $count = 0;
64 array_push($sqlQueryBind,$patient->id,$beginDate,$endDate);
65 foreach( $listOptions as $option_id ) {
66 $query.= "cvx_code = ? ";
67 $count++;
68 if ( $count < count( $listOptions ) ) {
69 $query.= "OR ";
71 array_push($sqlQueryBind,$option_id);
73 $query.= " ) ";
75 $result = sqlStatement( $query, $sqlQueryBind );
76 $rows = array();
77 for( $iter = 0; $row = sqlFetchArray( $result ); $iter++ ) {
78 $rows[$iter] = $row;
81 if ( isset( $options[self::OPTION_COUNT] ) &&
82 count( $rows ) >= $options[self::OPTION_COUNT] ) {
83 $return = true;
84 } else if ( !isset( $options[self::OPTION_COUNT] ) &&
85 count( $rows ) > 0 ) {
86 $return = true;
90 return $return;