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 Encounter
extends ClinicalType
13 const OPTION_ENCOUNTER_COUNT
= 'count';
15 const ENC_OUTPATIENT
= 'enc_outpatient';
16 const ENC_NURS_FAC
= 'enc_nurs_fac';
17 const ENC_OFF_VIS
= 'enc_off_vis';
18 const ENC_HEA_AND_BEH
= 'enc_hea_and_beh';
19 const ENC_OCC_THER
= 'enc_occ_ther';
20 const ENC_PSYCH_AND_PSYCH
= 'enc_psych_and_psych';
21 const ENC_PRE_MED_SER_18_OLDER
= 'enc_pre_med_ser_18_older';
22 const ENC_PRE_MED_SER_40_OLDER
= 'enc_pre_med_ser_40_older';
23 const ENC_PRE_IND_COUNSEL
= 'enc_pre_ind_counsel';
24 const ENC_PRE_MED_GROUP_COUNSEL
= 'enc_pre_med_group_counsel';
25 const ENC_PRE_MED_OTHER_SERV
= 'enc_pre_med_other_serv';
26 const ENC_OUT_PCP_OBGYN
= 'enc_out_pcp_obgyn';
27 const ENC_PREGNANCY
= 'enc_pregnancy';
28 const ENC_ACUTE_INP_OR_ED
= 'enc_acute_inp_or_ed'; // encounter acute inpatient or ED
29 const ENC_NURS_DISCHARGE
= 'enc_nurs_discharge'; // encounter nursing discharge
30 const ENC_NONAC_INP_OUT_OR_OPTH
= 'enc_nonac_inp_out_or_opth'; // encounter non-acute inpt, outpatient, or ophthalmology
31 const ENC_INFLUENZA
= 'enc_influenza';
33 public static function getEncounterTypes()
35 $oClass = new ReflectionClass( 'Encounter' );
36 $constants = $oClass->getConstants();
37 $encounters = array();
38 foreach ( $constants as $constant ) {
39 if ( strpos( $constant, 'enc' ) === 0 ) {
40 $encounters[]= $constant;
46 public function getListId()
48 return "rule_enc_types";
52 * Fetch an array of all dates on which this encounter took place for a patient.
54 * @param (CqmPatient) $patient
55 * @param $beginDate beginning of date range to search in, if specified
56 * @param $endDate end of date range to search in, if specified
58 public function fetchDates( RsPatient
$patient, $beginDate = null, $endDate = null )
60 $encounters = getEncounters( $patient->id
, $beginDate, $endDate, $this->getOptionId() );
62 foreach ( $encounters as $encounter )
64 $dateRow = getEncounterDateByEncounter( $encounter['encounter'] );
65 $dates []= $dateRow['date'];
70 public function doPatientCheck( RsPatient
$patient, $beginMeasurement = null, $endMeasurement = null, $options = null )
72 $encounters = getEncounters( $patient->id
, $beginMeasurement, $endMeasurement, $this->getOptionId() );
73 ( empty($encounters) ) ?
$totalNumberAppt = 0 : $totalNumberAppt = count( $encounters );
75 if ( isset( $options[self
::OPTION_ENCOUNTER_COUNT
] ) ) {
76 $requiredCount = $options[self
::OPTION_ENCOUNTER_COUNT
];
78 if ( $totalNumberAppt < $requiredCount ) {