Exemplo n.º 1
0
 /**
  * @param $rule
  * @return bool
  */
 private function ckSocialHistory($rule)
 {
     if (isset($rule['concepts']['SOCI']) && !empty($rule['concepts']['SOCI'])) {
         $count = 0;
         foreach ($rule['concepts']['SOCI'] as $concept) {
             $socials = $this->SocialHistory->getSocialHistoryByPidAndCode($this->Patient->getPatientPid(), $concept['concept_code']);
             if ($concept['frequency_interval'] == '') {
                 if ($this->compare(count($socials), $concept['frequency_operator'], $concept['frequency'])) {
                     return true;
                 }
             } else {
                 $frequency = 0;
                 foreach ($socials as $social) {
                     $starDate = isset($social['create_date']) ? $social['create_date'] : $social['start_date'];
                     if ($this->isWithInterval($starDate, $concept['frequency_interval'], $concept['frequency_operator'], 'Y-m-d H:i:s')) {
                         $frequency++;
                         if ($concept['frequency'] == $frequency) {
                             break;
                         }
                     }
                 }
                 if ($concept['frequency_operator'] == '' || $this->compare($frequency, $concept['frequency_operator'], $concept['frequency'])) {
                     $count++;
                 }
             }
         }
         return $count == count($rule['concepts']['SOCI']);
     }
     return true;
 }
Exemplo n.º 2
0
 /**
  * Method setSocialHistorySection()
  */
 private function setSocialHistorySection()
 {
     $SocialHistory = new SocialHistory();
     if ($this->isExcluded('social')) {
         $socialHistory['@attributes'] = ['nullFlavor' => 'NI'];
         $this->addSection(['section' => $socialHistory]);
         return;
     }
     /**
      * Smoking Status Observation - This clinical statement represents a patient's current smoking
      * status. The vocabulary selected for this clinical statement is the best approximation of the
      * statuses in Meaningful Use (MU) Stage 1.
      *
      * If the patient is a smoker (77176002), the effectiveTime/low element must be present. If the patient
      * is an ex-smoker (8517006), both the effectiveTime/low and effectiveTime/high element must be present.
      *
      * The smoking status value set includes a special code to communicate if the smoking status is unknown
      * which is different from how Consolidated CDA generally communicates unknown information.
      */
     $smokingStatus = $SocialHistory->getSocialHistoryByPidAndCode($this->pid, 'smoking_status');
     if (count($smokingStatus) > 0) {
         $smokingStatus = end($smokingStatus);
         $socialHistory = ['templateId' => ['@attributes' => ['root' => '2.16.840.1.113883.10.20.22.2.17']], 'code' => ['@attributes' => ['code' => '29762-2', 'codeSystemName' => 'LOINC', 'codeSystem' => '2.16.840.1.113883.6.1', 'displayName' => "Social History"]], 'title' => 'Social History', 'text' => $smokingStatus['note']];
         $socialHistory['entry'][] = ['@attributes' => ['typeCode' => 'DRIV'], 'observation' => ['@attributes' => ['classCode' => 'OBS', 'moodCode' => 'EVN'], 'templateId' => ['@attributes' => ['root' => '2.16.840.1.113883.10.20.22.4.38.2']], 'code' => ['@attributes' => ['code' => 'ASSERTION', 'codeSystemName' => 'ActCode', 'codeSystem' => '2.16.840.1.113883.5.4']], 'statusCode' => ['@attributes' => ['code' => 'completed']], 'effectiveTime' => ['low' => ['@attributes' => ['value' => $this->parseDate($smokingStatus['create_date'])]]], 'value' => ['@attributes' => ['xsi:type' => 'CD', 'code' => $smokingStatus['status_code'], 'displayName' => $smokingStatus['status'], 'codeSystemName' => $smokingStatus['status_code_type'], 'codeSystem' => $this->codes($smokingStatus['status_code_type'])]]]];
     }
     unset($smokingStatus);
     /**
      * This Social History Observation defines the patient's occupational, personal (e.g., lifestyle),
      * social, and environmental history and health risk factors, as well as administrative data such
      * as marital status, race, ethnicity, and religious affiliation.
      */
     $socialHistories = $SocialHistory->getSocialHistoryByPidAndCode($this->pid);
     if (count($socialHistories) > 0) {
         $socialHistory['text'] = ['table' => ['@attributes' => ['border' => '1', 'width' => '100%'], 'thead' => ['tr' => [['th' => [['@value' => 'Social History Element'], ['@value' => 'Description'], ['@value' => 'Effective Dates']]]]], 'tbody' => ['tr' => []]]];
     }
     foreach ($socialHistories as $socialHistoryEntry) {
         $dateText = $this->parseDate($socialHistoryEntry['start_date']) . ' - ';
         if ($socialHistoryEntry['end_date'] != '0000-00-00 00:00:00') {
             $dateText .= $this->parseDate($socialHistoryEntry['end_date']);
         }
         $socialHistory['text']['table']['tbody']['tr'][] = ['td' => [['@value' => $socialHistoryEntry['category_code_text']], ['@value' => $socialHistoryEntry['observation']], ['@value' => $dateText]]];
         $entry = ['@attributes' => ['typeCode' => 'DRIV'], 'observation' => ['@attributes' => ['classCode' => 'OBS', 'moodCode' => 'EVN'], 'templateId' => ['@attributes' => ['root' => '2.16.840.1.113883.10.20.22.4.38']], 'id' => ['@attributes' => ['root' => UUID::v4()]], 'code' => ['@attributes' => ['code' => $socialHistoryEntry['category_code'], 'codeSystem' => $this->codes($socialHistoryEntry['category_code_type']), 'codeSystemName' => $socialHistoryEntry['category_code_text'], 'displayName' => $socialHistoryEntry['category_code_text']]], 'statusCode' => ['@attributes' => ['code' => 'completed']]]];
         $entry['observation']['effectiveTime'] = ['@attributes' => ['xsi:type' => 'IVL_TS']];
         $entry['observation']['effectiveTime']['low'] = ['@attributes' => ['value' => $this->parseDate($socialHistoryEntry['start_date'])]];
         if ($socialHistoryEntry['end_date'] != '0000-00-00 00:00:00') {
             $entry['observation']['effectiveTime']['high'] = ['@attributes' => ['value' => $this->parseDate($socialHistoryEntry['end_date'])]];
         } else {
             $entry['observation']['effectiveTime']['high'] = ['@attributes' => ['nullFlavor' => 'NI']];
         }
         $entry['observation']['value'] = ['@attributes' => ['xsi:type' => 'ST'], '@value' => $socialHistoryEntry['observation']];
         $socialHistory['entry'][] = $entry;
         unset($entry);
     }
     unset($socialHistories);
     //		/***************************************************************************************************************
     //		 * Pregnancy Observation - This clinical statement represents current and/or
     //		 * prior pregnancy dates enabling investigators to determine if the subject
     //		 * of the case report* was pregnant during the course of a condition.
     //		 */
     //		$socialHistory['text']['table']['tbody']['tr'][] = array(
     //			'td' => array(
     //				array(
     //					'@value' => 'Social History Element Data'
     //				),
     //				array(
     //					'@value' => 'ReactiDescriptionon Data'
     //				),
     //				array(
     //					'@value' => 'Effective Data'
     //				)
     //			)
     //		);
     //		$socialHistory['entry'][] = array(
     //			'@attributes' => array(
     //				'typeCode' => 'DRIV'
     //			),
     //			'observation' => array(
     //				'@attributes' => array(
     //					'classCode' => 'OBS',
     //					'moodCode' => 'EVN'
     //				),
     //				'templateId' => array(
     //					'@attributes' => array(
     //						'root' => '2.16.840.1.113883.10.20.15.3.8'
     //					)
     //				),
     //				'code' => array(
     //					'@attributes' => array(
     //						'code' => 'ASSERTION',
     //						'codeSystem' => '2.16.840.1.113883.5.4'
     //					)
     //				),
     //				'statusCode' => array(
     //					'@attributes' => array(
     //						'code' => 'completed',
     //					)
     //				),
     //				'value' => array(
     //					'@attributes' => array(
     //						'xsi:type' => 'CD',
     //						'code' => '77386006',
     //						'codeSystem' => '2.16.840.1.113883.6.96'
     //					)
     //				),
     //				'entryRelationship' => array(
     //					'@attributes' => array(
     //						'typeCode' => 'REFR'
     //					),
     //					'observation' => array(
     //						'@attributes' => array(
     //							'classCode' => 'OBS',
     //							'moodCode' => 'EVN'
     //						),
     //						'templateId' => array(
     //							'@attributes' => array(
     //								'root' => '2.16.840.1.113883.10.20.15.3.1'
     //							)
     //						),
     //						'code' => array(
     //							'@attributes' => array(
     //								'code' => '11778-8',
     //		                        'codeSystemName' => 'LOINC',
     //								'codeSystem' => '2.16.840.1.113883.6.1'
     //							)
     //						),
     //						'statusCode' => array(
     //							'@attributes' => array(
     //								'code' => 'completed'
     //							)
     //						),
     //						/**
     //						 * Estimated Date Of Delivery
     //						 */
     //						'value' => array(
     //							'@attributes' => array(
     //								'xsi:type' => 'TS',
     //								'value' => '20150123' // TODO
     //							)
     //						)
     //					)
     //				)
     //			)
     //		);
     $this->addSection(['section' => $socialHistory]);
     unset($socialHistoryData, $socialHistory);
 }