示例#1
0
 /**
  * @param $rule
  * @return bool
  */
 private function ckActiveProblems($rule)
 {
     if (isset($rule['concepts']['PROB']) && !empty($rule['concepts']['PROB'])) {
         $count = 0;
         foreach ($rule['concepts']['PROB'] as $concept) {
             $problems = $this->ActiveProblems->getPatientActiveProblemByPidAndCode($this->Patient->getPatientPid(), $concept['concept_code']);
             if (empty($problems)) {
                 continue;
             }
             if ($concept['frequency_interval'] == 0) {
                 $count++;
                 continue;
             }
             $frequency = 0;
             foreach ($problems as $problem) {
                 if ($this->isWithInterval($problem['begin_date'], $concept['frequency_interval'], $concept['frequency_operator'], 'Y-m-d')) {
                     $frequency++;
                     if ($concept['frequency'] == $frequency) {
                         break;
                     }
                 }
             }
             if ($concept['frequency_operator'] == '' || $this->compare($frequency, $concept['frequency_operator'], $concept['frequency'])) {
                 $count++;
             }
         }
         return $count == count($rule['concepts']['PROB']);
     }
     return true;
 }
示例#2
0
 private function getObjectiveExtraDataByEid($eid)
 {
     $ExtraData = '';
     $Medications = new Medications();
     $medications = $Medications->getPatientMedicationsByEid($eid);
     if (!empty($medications)) {
         $lis = '';
         foreach ($medications as $foo) {
             $lis .= '<li>' . $foo['STR'] . '</li>';
         }
         $ExtraData .= '<p>Medications:</p>';
         $ExtraData .= '<ul class="ProgressNote-ul">' . $lis . '</ul>';
     }
     unset($Medications);
     $Immunizations = new Immunizations();
     $immunizations = $Immunizations->getImmunizationsByEncounterID($eid);
     if (!empty($immunizations)) {
         $lis = '';
         foreach ($immunizations as $foo) {
             $lis .= '<li>Vaccine name: ' . $foo['vaccine_name'] . '<br>';
             $lis .= 'Vaccine ID: (' . $foo['code_type'] . ')' . $foo['code'] . '<br>';
             $lis .= 'Manufacturer: ' . $foo['manufacturer'] . '<br>';
             $lis .= 'Lot Number: ' . $foo['lot_number'] . '<br>';
             $lis .= 'Dose: ' . $foo['administer_amount'] . ' ' . $foo['administer_units'] . '<br>';
             $lis .= 'Administered By: ' . $foo['administered_by'] . ' </li>';
         }
         $ExtraData .= '<p>Immunizations:</p>';
         $ExtraData .= '<ul class="ProgressNote-ul">' . $lis . '</ul>';
     }
     unset($Immunizations);
     $Allergies = new Allergies();
     $allergies = $Allergies->getPatientAllergiesByEid($eid);
     if (!empty($allergies)) {
         $lis = '';
         foreach ($allergies as $foo) {
             $lis .= '<li>Allergy: ' . $foo['allergy'] . ' (' . $foo['allergy_type'] . ')<br>';
             $lis .= 'Reaction: ' . $foo['reaction'] . '<br>';
             $lis .= 'Severity: ' . $foo['severity'] . '<br>';
             $lis .= 'Location: ' . $foo['location'] . '<br>';
             $lis .= 'Active?: ' . ($foo['end_date'] != null ? 'Yes' : 'No') . '</li>';
         }
         $ExtraData .= '<p>Allergies:</p>';
         $ExtraData .= '<ul class="ProgressNote-ul">' . $lis . '</ul>';
     }
     unset($Allergies);
     /**
      * Active Problems found in this Encounter
      */
     $ActiveProblems = new ActiveProblems();
     $activeProblems = $ActiveProblems->getPatientActiveProblemByEid($eid);
     if (!empty($activeProblems)) {
         $lis = '';
         foreach ($activeProblems as $foo) {
             $lis .= '<li>[' . $foo['code'] . '] - ' . $foo['code_text'] . ' </li>';
         }
         $ExtraData .= '<p>Active Problems:</p>';
         $ExtraData .= '<ul class="ProgressNote-ul">' . $lis . '</ul>';
     }
     unset($ActiveProblems);
     return $ExtraData;
 }
示例#3
0
 /**
  * Method setProblemsSection()
  *
  * This section lists and describes all relevant clinical problems at the time the document is generated.
  * At a minimum, all pertinent current and historical problems should be listed.  Overall health status may
  * be represented in this section.
  */
 private function setProblemsSection()
 {
     $ActiveProblems = new ActiveProblems();
     $problemsData = $ActiveProblems->getPatientAllProblemsByPid($this->pid);
     unset($ActiveProblems);
     if ($this->isExcluded('problems') || empty($problemsData)) {
         $problems['@attributes'] = ['nullFlavor' => 'NI'];
     }
     $problems['templateId'][] = ['@attributes' => ['root' => $this->requiredProblems ? '2.16.840.1.113883.10.20.22.2.5.1' : '2.16.840.1.113883.10.20.22.2.5']];
     $problems['templateId'][] = ['@attributes' => ['root' => '2.16.840.1.113883.3.88.11.83.103']];
     $problems['code'] = ['@attributes' => ['code' => '11450-4', 'codeSystemName' => 'LOINC', 'codeSystem' => '2.16.840.1.113883.6.1']];
     $problems['title'] = 'Problems';
     $problems['text'] = '';
     if ($this->isExcluded('problems')) {
         $this->addSection(['section' => $problems]);
         return;
     }
     if (!empty($problemsData)) {
         $problems['text'] = ['table' => ['@attributes' => ['border' => '1', 'width' => '100%'], 'thead' => ['tr' => [['th' => [['@value' => 'Condition'], ['@value' => 'Effective Dates'], ['@value' => 'Condition Status']]]]], 'tbody' => ['tr' => []]]];
         $problems['entry'] = [];
         foreach ($problemsData as $item) {
             $dateText = $this->parseDate($item['begin_date']) . ' - ';
             if ($item['end_date'] != '0000-00-00') {
                 $dateText .= $this->parseDate($item['end_date']);
             }
             $problems['text']['table']['tbody']['tr'][] = ['td' => [['@value' => $item['code_text']], ['@value' => $dateText], ['@value' => $item['status']]]];
             $entry = ['act' => ['@attributes' => ['classCode' => 'ACT', 'moodCode' => 'EVN'], 'templateId' => ['@attributes' => ['root' => '2.16.840.1.113883.10.20.22.4.3']], 'id' => ['@attributes' => ['root' => UUID::v4()]], 'code' => ['@attributes' => ['code' => 'CONC', 'codeSystemName' => 'ActClass', 'codeSystem' => '2.16.840.1.113883.5.6', 'displayName' => 'Concern']], 'statusCode' => ['@attributes' => ['code' => 'active']]]];
             $entry['act']['effectiveTime'] = ['@attributes' => ['xsi:type' => 'IVL_TS']];
             $entry['act']['effectiveTime']['low'] = ['@attributes' => ['value' => $this->parseDate($item['begin_date'])]];
             if ($item['end_date'] != '0000-00-00') {
                 $entry['act']['effectiveTime']['high'] = ['@attributes' => ['value' => $this->parseDate($item['end_date'])]];
             } else {
                 $entry['act']['effectiveTime']['high'] = ['@attributes' => ['nullFlavor' => 'NI']];
             }
             $entry['act']['entryRelationship'] = ['@attributes' => ['typeCode' => 'SUBJ'], 'observation' => ['@attributes' => ['classCode' => 'OBS', 'moodCode' => 'EVN'], 'templateId' => ['@attributes' => ['root' => '2.16.840.1.113883.10.20.22.4.4']], 'id' => ['@attributes' => ['root' => UUID::v4()]], 'code' => ['@attributes' => ['code' => '55607006', 'displayName' => 'Problem', 'codeSystemName' => 'SNOMED CT', 'codeSystem' => '2.16.840.1.113883.6.96']], 'statusCode' => ['@attributes' => ['code' => 'completed']]]];
             $entry['act']['entryRelationship']['observation']['effectiveTime'] = ['@attributes' => ['xsi:type' => 'IVL_TS']];
             $entry['act']['entryRelationship']['observation']['effectiveTime']['low'] = ['@attributes' => ['value' => $this->parseDate($item['begin_date'])]];
             if ($item['end_date'] != '0000-00-00') {
                 $entry['act']['entryRelationship']['observation']['effectiveTime']['high'] = ['@attributes' => ['value' => $this->parseDate($item['end_date'])]];
             } else {
                 $entry['act']['entryRelationship']['observation']['effectiveTime']['high'] = ['@attributes' => ['nullFlavor' => 'NI']];
             }
             $entry['act']['entryRelationship']['observation']['value'] = ['@attributes' => ['xsi:type' => 'CD', 'code' => $item['code'], 'codeSystemName' => $item['code_type'], 'codeSystem' => $this->codes($item['code_type'])]];
             $entry['act']['entryRelationship']['observation']['entryRelationship'] = ['@attributes' => ['typeCode' => 'REFR'], 'observation' => ['@attributes' => ['classCode' => 'OBS', 'moodCode' => 'EVN'], 'templateId' => ['@attributes' => ['root' => '2.16.840.1.113883.10.20.22.4.6']], 'code' => ['@attributes' => ['code' => '33999-4', 'displayName' => 'Status', 'codeSystemName' => 'LOINC', 'codeSystem' => '2.16.840.1.113883.6.1']], 'statusCode' => ['@attributes' => ['code' => 'completed']], 'value' => ['@attributes' => ['xsi:type' => 'CD', 'code' => $this->CombosData->getCodeValueByListIdAndOptionValue(112, $item['status']), 'displayName' => $item['status'], 'codeSystemName' => 'SNOMED CT', 'codeSystem' => '2.16.840.1.113883.6.96']]]];
             $problems['entry'][] = $entry;
             unset($entry);
         }
     }
     if ($this->requiredProblems || !empty($problems['entry'])) {
         $this->addSection(['section' => $problems]);
     }
     unset($problemsData, $problems);
 }
示例#4
0
 public function get_EncounterTokensData($eid, $allNeededInfo, $tokens)
 {
     $params = new stdClass();
     $params->eid = $eid;
     $encounter = $this->encounter->getEncounter($params);
     if (!isset($encounter['encounter'])) {
         return $allNeededInfo;
     }
     $encounterCodes = $this->encounter->getEncounterCodes($params);
     $vitals = end($encounter['encounter']['vitals']);
     $soap = $encounter['encounter']['soap'];
     if (isset($encounter['encounter']['reviewofsystemschecks'])) {
         $rosCks = $encounter['encounter']['reviewofsystemschecks'];
         unset($rosCks['id'], $rosCks['pid'], $rosCks['eid'], $rosCks['uid'], $rosCks['date']);
         foreach ($rosCks as $rosc => $num) {
             if ($num == '' || $num == null || $num == 0) {
                 unset($rosCks[$rosc]);
             }
         }
     }
     if (isset($encounter['encounter']['reviewofsystems'])) {
         $reviewofsystems = $encounter['encounter']['reviewofsystems'];
         unset($reviewofsystems['pid'], $reviewofsystems['eid'], $reviewofsystems['uid'], $reviewofsystems['id'], $reviewofsystems['date']);
         foreach ($reviewofsystems as $ros => $num) {
             if ($num == '' || $num == null || $num == 'null') {
                 unset($reviewofsystems[$ros]);
             }
         }
     }
     $cpt = [];
     $dx = [];
     $hcpc = [];
     $cvx = [];
     if (isset($encounterCodes['rows'])) {
         foreach ($encounterCodes['rows'] as $code) {
             if ($code['code_type'] == 'CPT') {
                 $cpt[] = $code;
             } elseif ($code['code_type'] == 'ICD' || $code['code_type'] == 'ICD9' || $code['code_type'] == 'ICD10') {
                 $dx[] = $code;
             } elseif ($code['code_type'] == 'HCPC') {
                 $hcpc[] = $code;
             } elseif ($code['code_type'] == 'CVX') {
                 $cvx[] = $code;
             }
         }
     }
     $Medications = new Medications();
     $medications = $Medications->getPatientMedicationsByEid($eid);
     unset($Medications);
     $Immunizations = new Immunizations();
     $immunizations = $Immunizations->getImmunizationsByEid($eid);
     unset($Immunizations);
     $Allergies = new Allergies();
     $allergies = $Allergies->getPatientAllergiesByEid($eid);
     unset($Allergies);
     $ActiveProblems = new ActiveProblems();
     $activeProblems = $ActiveProblems->getPatientActiveProblemByEid($eid);
     unset($ActiveProblems);
     $encounter = $encounter['encounter'];
     $encounterInformation = ['[ENCOUNTER_START_DATE]' => $encounter['service_date'], '[ENCOUNTER_END_DATE]' => $encounter['close_date'], '[ENCOUNTER_BRIEF_DESCRIPTION]' => $encounter['brief_description'], '[ENCOUNTER_SENSITIVITY]' => $encounter['priority'], '[ENCOUNTER_WEIGHT_LBS]' => $vitals['weight_lbs'], '[ENCOUNTER_WEIGHT_KG]' => $vitals['weight_kg'], '[ENCOUNTER_HEIGHT_IN]' => $vitals['height_in'], '[ENCOUNTER_HEIGHT_CM]' => $vitals['height_cm'], '[ENCOUNTER_BP_SYSTOLIC]' => $vitals['bp_systolic'], '[ENCOUNTER_BP_DIASTOLIC]' => $vitals['bp_diastolic'], '[ENCOUNTER_PULSE]' => $vitals['pulse'], '[ENCOUNTER_RESPIRATION]' => $vitals['respiration'], '[ENCOUNTER_TEMP_FAHRENHEIT]' => $vitals['temp_f'], '[ENCOUNTER_TEMP_CELSIUS]' => $vitals['temp_c'], '[ENCOUNTER_TEMP_LOCATION]' => $vitals['temp_location'], '[ENCOUNTER_OXYGEN_SATURATION]' => $vitals['oxygen_saturation'], '[ENCOUNTER_HEAD_CIRCUMFERENCE_IN]' => $vitals['head_circumference_in'], '[ENCOUNTER_HEAD_CIRCUMFERENCE_CM]' => $vitals['head_circumference_cm'], '[ENCOUNTER_WAIST_CIRCUMFERENCE_IN]' => $vitals['waist_circumference_in'], '[ENCOUNTER_WAIST_CIRCUMFERENCE_CM]' => $vitals['waist_circumference_cm'], '[ENCOUNTER_BMI]' => $vitals['bmi'], '[ENCOUNTER_BMI_STATUS]' => $vitals['bmi_status'], '[ENCOUNTER_SUBJECTIVE]' => isset($soap['subjective']) ? $soap['subjective'] : '', '[ENCOUNTER_OBJECTIVE]' => isset($soap['objective']) ? $soap['objective'] : '', '[ENCOUNTER_ASSESSMENT]' => isset($soap['assessment']) ? $soap['assessment'] : '', '[ENCOUNTER_PLAN]' => isset($soap['plan']) ? $soap['plan'] : '', '[ENCOUNTER_CPT_CODES]' => $this->tokensForEncountersList($cpt, 1), '[ENCOUNTER_ICD_CODES]' => $this->tokensForEncountersList($dx, 2), '[ENCOUNTER_HCPC_CODES]' => $this->tokensForEncountersList($hcpc, 3), '[ENCOUNTER_ALLERGIES_LIST]' => $this->tokensForEncountersList($allergies, 4), '[ENCOUNTER_MEDICATIONS_LIST]' => $this->tokensForEncountersList($medications, 5), '[ENCOUNTER_ACTIVE_PROBLEMS_LIST]' => $this->tokensForEncountersList($activeProblems, 6), '[ENCOUNTER_IMMUNIZATIONS_LIST]' => $this->tokensForEncountersList($immunizations, 7), '[ENCOUNTER_REVIEWOFSYSTEMSCHECKS]' => isset($rosCks) ? $this->tokensForEncountersList($rosCks, 11) : '', '[ENCOUNTER_REVIEWOFSYSTEMS]' => isset($reviewofsystems) ? $this->tokensForEncountersList($reviewofsystems, 12) : ''];
     foreach ($tokens as $i => $tok) {
         if (isset($encounterInformation[$tok]) && ($allNeededInfo[$i] == '' || $allNeededInfo[$i] == null)) {
             $allNeededInfo[$i] = $encounterInformation[$tok];
         }
     }
     return $allNeededInfo;
 }