another minor fix to prior commit
[openemr.git] / library / classes / ClinicalTypes / Encounter.php
blob093342b054b30ecaee6b8cf21eb3402f8623cd84
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 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';
32 const ENC_OPHTHAL = 'enc_ophthal_serv';
34 public static function getEncounterTypes()
36 $oClass = new ReflectionClass( 'Encounter' );
37 $constants = $oClass->getConstants();
38 $encounters = array();
39 foreach ( $constants as $constant ) {
40 if ( strpos( $constant, 'enc' ) === 0 ) {
41 $encounters[]= $constant;
44 return $encounters;
47 public function getListId()
49 return "rule_enc_types";
53 * Fetch an array of all dates on which this encounter took place for a patient.
55 * @param (CqmPatient) $patient
56 * @param $beginDate beginning of date range to search in, if specified
57 * @param $endDate end of date range to search in, if specified
59 public function fetchDates( RsPatient $patient, $beginDate = null, $endDate = null )
61 $encounters = getEncounters( $patient->id, $beginDate, $endDate, $this->getOptionId() );
62 $dates = array();
63 foreach ( $encounters as $encounter )
65 $dateRow = getEncounterDateByEncounter( $encounter['encounter'] );
66 $dates []= $dateRow['date'];
68 return $dates;
71 public function doPatientCheck( RsPatient $patient, $beginMeasurement = null, $endMeasurement = null, $options = null )
73 $encounters = getEncounters( $patient->id, $beginMeasurement, $endMeasurement, $this->getOptionId() );
74 ( empty($encounters) ) ? $totalNumberAppt = 0 : $totalNumberAppt = count( $encounters );
75 $requiredCount = 1;
76 if ( isset( $options[self::OPTION_ENCOUNTER_COUNT] ) ) {
77 $requiredCount = $options[self::OPTION_ENCOUNTER_COUNT];
79 if ( $totalNumberAppt < $requiredCount ) {
80 return false;
81 } else {
82 return true;