Ejemplo n.º 1
0
 public function ajaxListInteractionsAction()
 {
     $severeNotify = PermissionTemplate::hasPermission('medication-alerts', 'severe-notification') ? true : false;
     $criticalNotify = PermissionTemplate::hasPermission('medication-alerts', 'critical-notification') ? true : false;
     $allergyNotify = PermissionTemplate::hasPermission('medication-alerts', 'allergy-notification') ? true : false;
     $personId = (int) $this->_getParam('personId');
     $md5 = preg_replace('/[^A-Za-z0-9]/', '', $this->_getParam('md5'));
     $vaclass = preg_replace('/[^A-Za-z0-9]/', '', $this->_getParam('vaclass'));
     // regular allergies search
     $interactionIterator = new BaseMed24InteractionIterator();
     $interactionIterator->setFilters(array('personId' => $personId, 'md5' => $md5));
     $regularAllergies = $interactionIterator->toJsonArray('hipaa_ndc', array('tradename', 'fda_drugname', 'notice'));
     $tmpArray = $regularAllergies;
     $regularAllergies = array();
     foreach ($tmpArray as $key => $value) {
         // notice: S, C, Y, ^
         if (!$severeNotify && $value['data'][2] == 'SIGNIFICANT' || !$criticalNotify && $value['data'][2] == 'CRITICAL') {
             continue;
         }
         $regularAllergies[] = $value;
     }
     $listSymptoms = array();
     $enumeration = new Enumeration();
     $enumeration->populateByEnumerationName(PatientAllergy::ENUM_SYMPTOM_PARENT_NAME);
     $enumerationsClosure = new EnumerationsClosure();
     $enumerationIterator = $enumerationsClosure->getAllDescendants($enumeration->enumerationId, 1);
     $ctr = 0;
     foreach ($enumerationIterator as $enum) {
         $listSymptoms[$enum->key] = $enum->name;
     }
     $listSeverities = array();
     $enumeration->populateByEnumerationName(PatientAllergy::ENUM_SEVERITY_PARENT_NAME);
     $enumerationsClosure = new EnumerationsClosure();
     $enumerationIterator = $enumerationsClosure->getAllDescendants($enumeration->enumerationId, 1);
     $ctr = 0;
     foreach ($enumerationIterator as $enum) {
         $listSeverities[$enum->key] = $enum->name;
     }
     // drug class search
     $patientAllergyIterator = new PatientAllergyIterator();
     $patientAllergyIterator->setFilters(array('patientId' => $personId, 'enteredInError' => 0, 'drugAllergy' => $vaclass, 'reactionType' => 'Drug Class Allergy'));
     $drugClassAllergies = array();
     foreach ($patientAllergyIterator as $allergy) {
         if (!$allergyNotify) {
             break;
         }
         /*if ((!$severeNotify && $allergy->severity == 'SEVERE') ||
           (!$criticalNotify && $allergy->severity == 'MOD')) continue;*/
         $symptoms = explode(',', $allergy->symptoms);
         $symptom = array();
         foreach ($symptoms as $sym) {
             $symptom[] = $listSymptoms[$sym];
         }
         $tmpArray = array();
         $tmpArray['id'] = $allergy->patientAllergyId;
         $tmpArray['data'][] = $allergy->causativeAgent;
         $tmpArray['data'][] = $allergy->reactionType;
         $tmpArray['data'][] = $listSeverities[$allergy->severity] . ' - ' . implode(',', $symptom);
         $drugClassAllergies[] = $tmpArray;
     }
     // specific drug search
     $patientAllergyIterator->setFilters(array('patientId' => $personId, 'enteredInError' => 0, 'drugAllergy' => $md5, 'reactionType' => 'Specific Drug Allergy'));
     $specificDrugAllergies = array();
     foreach ($patientAllergyIterator as $allergy) {
         if (!$allergyNotify) {
             break;
         }
         /*if ((!$severeNotify && $allergy->severity == 'SEVERE') ||
           (!$criticalNotify && $allergy->severity == 'MOD')) continue;*/
         $symptoms = explode(',', $allergy->symptoms);
         $symptom = array();
         foreach ($symptoms as $sym) {
             $symptom[] = $listSymptoms[$sym];
         }
         $tmpArray = array();
         $tmpArray['id'] = $allergy->patientAllergyId;
         $tmpArray['data'][] = $allergy->causativeAgent;
         $tmpArray['data'][] = $allergy->reactionType;
         $tmpArray['data'][] = $listSeverities[$allergy->severity] . ' - ' . implode(',', $symptom);
         $specificDrugAllergies[] = $tmpArray;
     }
     $interactions = array_merge_recursive($regularAllergies, $drugClassAllergies, $specificDrugAllergies);
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct(array('rows' => $interactions));
 }
Ejemplo n.º 2
0
 protected static function _checkMedication(HealthStatusHandler $handler, $patientId, $audit)
 {
     $ret = false;
     if ($audit->objectClass != 'Medication') {
         return $ret;
     }
     $db = Zend_Registry::get('dbAdapter');
     $medication = new Medication();
     $medication->medicationId = (int) $audit->objectId;
     $medication->populate();
     $s = $medication->description;
     if (preg_match('/avandia/i', $s)) {
         $message = 'Patient may be suitable for referral to Diabetes Counseling';
     } else {
         if (preg_match('/hydrochlorothiazide/i', $s)) {
             $message = 'Patient may be suitable for treatment of hypertension with a diuretic such as Hydrochlorothiazide';
         } else {
             if (preg_match('/lipitor/i', $s)) {
                 $message = 'Patient may benefit from hypercholesteremia drug such as Lipitor';
                 $sqlSelect = $db->select()->from('chmed.basemed24', array('md5', 'vaclass'))->where('pkey = ?', $medication->pkey);
                 $hasAllergy = false;
                 if ($row = $db->fetchRow($sqlSelect)) {
                     $personId = (int) $patientId;
                     $md5 = $row['md5'];
                     $vaclass = $row['vaclass'];
                     // check for allergy interactions
                     do {
                         // regular allergies search
                         $interactionIterator = new BaseMed24InteractionIterator();
                         $interactionIterator->setFilters(array('personId' => $personId, 'md5' => $md5));
                         $regularAllergies = $interactionIterator->toJsonArray('hipaa_ndc', array('tradename', 'fda_drugname', 'notice'));
                         $tmpArray = $regularAllergies;
                         $regularAllergies = array();
                         foreach ($tmpArray as $key => $value) {
                             $hasAllergy = true;
                             break 2;
                         }
                         // drug class search
                         $patientAllergyIterator = new PatientAllergyIterator();
                         $patientAllergyIterator->setFilters(array('patientId' => $personId, 'enteredInError' => 0, 'drugAllergy' => $vaclass, 'reactionType' => 'Drug Class Allergy'));
                         $drugClassAllergies = array();
                         foreach ($patientAllergyIterator as $allergy) {
                             $hasAllergy = true;
                             break 2;
                         }
                         // specific drug search
                         $patientAllergyIterator->setFilters(array('patientId' => $personId, 'enteredInError' => 0, 'drugAllergy' => $md5, 'reactionType' => 'Specific Drug Allergy'));
                         $specificDrugAllergies = array();
                         foreach ($patientAllergyIterator as $allergy) {
                             $hasAllergy = true;
                             break 2;
                         }
                     } while (false);
                 }
                 if ($hasAllergy) {
                     $message .= '. NOTE: Consult patients allergies: Lipitor/Atorvastatin';
                 }
             } else {
                 return $ret;
             }
         }
     }
     self::createHSA($handler, $patientId, $message);
     return true;
 }