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' );
13 public static function checkAllergy( $subType, RsPatient
$patient, $beginDate = null, $endDate = null, $options = null )
15 return self
::check( ClinicalType
::ALLERGY
, $subType, $patient, $beginDate, $endDate , $options );
18 public static function checkDiagActive( $subType, RsPatient
$patient, $beginDate = null, $endDate = null, $options = null )
20 // TODO append options array
21 return self
::check( ClinicalType
::DIAGNOSIS
, $subType, $patient, $beginDate, $endDate , array( Diagnosis
::OPTION_STATE
=> Diagnosis
::STATE_ACTIVE
) );
24 public static function checkDiagInactive( $subType, RsPatient
$patient, $beginDate = null, $endDate = null, $options = null )
26 return self
::check( ClinicalType
::DIAGNOSIS
, $subType, $patient, $beginDate, $endDate , array( Diagnosis
::OPTION_STATE
=> Diagnosis
::STATE_INACTIVE
) );
29 public static function checkDiagResolved( $subType, RsPatient
$patient, $beginDate = null, $endDate = null, $options = null )
31 return self
::check( ClinicalType
::DIAGNOSIS
, $subType, $patient, $beginDate, $endDate , array( Diagnosis
::OPTION_STATE
=> Diagnosis
::STATE_RESOLVED
) );
34 public static function checkEncounter( $subType, RsPatient
$patient, $beginDate = null, $endDate = null, $options = null )
36 return self
::check( ClinicalType
::ENCOUNTER
, $subType, $patient, $beginDate, $endDate, $options );
39 public static function checkLab( $subType, RsPatient
$patient, $beginDate = null, $endDate = null, $options = null )
41 return self
::check( ClinicalType
::LAB_RESULT
, $subType, $patient, $beginDate, $endDate , $options );
44 public static function checkMed( $subType, RsPatient
$patient, $beginDate = null, $endDate = null, $options = null )
46 return self
::check( ClinicalType
::MEDICATION
, $subType, $patient, $beginDate, $endDate , $options );
49 public static function check( $type, $subType, RsPatient
$patient, $beginDate = null, $endDate = null, $options = null )
51 $typeObj = new $type( $subType );
52 if ( $typeObj instanceof ClinicalType
) {
53 if ( $beginDate == null ) {
54 $beginDate = $patient->dob
;
56 if ( $endDate == null ) {
57 $endDate = date( "Y-m-d" );
59 return $typeObj->doPatientCheck( $patient, $beginDate, $endDate, $options );
61 throw new Exception( "Type must be a subclass of AbstractClinicalType" );
65 public static function fetchEncounterDates( $encounterType, RsPatient
$patient, $beginDate = null, $endDate = null )
67 $encounter = new Encounter( $encounterType );
68 return $encounter->fetchDates( $patient, $beginDate, $endDate );
71 public static function checkAnyEncounter( RsPatient
$patient, $beginDate = null, $endDate = null, $options = null )
73 $encounters = Encounter
::getEncounterTypes();
74 foreach ( $encounters as $encounter ) {
75 if ( self
::checkEncounter( $encounter, $patient, $beginDate, $endDate, $options ) ) {