/** * @param $PortionData * @param $CompleteData * @return array|Exception */ public static function Insert($PortionData, $CompleteData) { try { // Validate first self::Validate($PortionData); $Entry = ['observation' => ['@attributes' => ['classCode' => 'OBS', 'moodCode' => 'EVN'], 'templateId' => Component::templateId('2.16.840.1.113883.10.20.22.4.46'), 'id' => Component::id(Utilities::UUIDv4()), 'code' => ['@attributes' => ['code' => $PortionData['problemTypeCode'], 'displayName' => $PortionData['problemTypeDisplayName'], 'codeSystem' => Utilities::CodingSystemId($PortionData['problemTypeCodeSystemName']), 'codeSystemName' => $PortionData['problemTypeCodeSystemName']]], 'statusCode' => Component::statusCode('completed'), 'effectiveTime' => Component::time($PortionData['effectiveTime']), 'value' => ['@attributes' => ['xsi:type' => 'CD', 'code' => $PortionData['problemValueCode'], 'displayName' => $PortionData['problemValueDisplayName'], 'codeSystem' => Utilities::CodingSystemId($PortionData['problemValueCodeSystemName']), 'codeSystemName' => $PortionData['problemValueCodeSystemName']]]]]; // MAY contain zero or one [0..1] entryRelationship (CONF:8675) // SHALL contain exactly one [1..1] Age Observation if (count($PortionData['AgeObservation']) > 0) { $Entry['observation']['entryRelationship'][] = ['@attributes' => ['typeCode' => 'SUBJ', 'inversionInd' => 'true'], 'observation' => ageObservation::Insert($PortionData['AgeObservation'][0], $CompleteData)]; } // MAY contain zero or one [0..1] entryRelationship (CONF:8678) // SHALL contain exactly one [1..1] Family History Death Observation if (count($PortionData['FamilyHistoryDeathObservation']) > 0) { $Entry['observation']['entryRelationship'][] = ['@attributes' => ['typeCode' => 'CAUS'], 'observation' => familyHistoryDeathObservation::Insert($PortionData['FamilyHistoryDeathObservation'][0], $CompleteData)]; } return $Entry; } catch (Exception $Error) { return $Error; } }
/** * @param $PortionData * @param $CompleteData * @return array|Exception */ public static function Insert($PortionData, $CompleteData) { try { // Validate first self::Validate($PortionData); $Entry = ['observation' => ['@attributes' => ['moodCode' => 'EVN', 'classCode' => 'OBS'], 'templateId' => Component::templateId('2.16.840.1.113883.10.20.22.4.4.2'), 'id' => Component::id(Utilities::UUIDv4()), 'code' => ['code' => '64572001', 'codeSystem' => '2.16.840.1.113883.6.96', 'displayName' => 'Condition'], 'statusCode' => Component::statusCode('completed'), 'effectiveTime' => ['low' => ['@attributes' => ['value' => $PortionData['onsetDate']]]], 'value' => ['@attributes' => ['xsi:type' => 'CD', 'code' => $PortionData['code'], 'codeSystem' => Utilities::CodingSystemId($PortionData['codeSystemName']), 'codeSystemName' => $PortionData['codeSystemName'], 'displayName' => $PortionData['displayName']]]]]; // SHOULD contain zero or one [0..1] text if (isset($PortionData['Narrated'])) { $Entry['observation']['text'] = self::Narrative($PortionData['Narrated']); } // This effectiveTime MAY contain zero or one [0..1] high (CONF:9033). // Note: The effectiveTime/high asserts when the concern was completed // (e.g. when the clinician deemed there is no longer any need to track the underlying condition) if (isset($PortionData['resolvedDate'])) { $Entry['observation']['effectiveTime']['high'] = ['@attributes' => ['value' => $PortionData['resolvedDate']]]; } // SHOULD contain zero or more [0..*] Author Participation (NEW) if (count($PortionData['Author']) > 0) { foreach ($PortionData['Author'] as $Author) { $Entry['observation']['author'][] = LevelOther\authorParticipation::Insert($Author, $CompleteData); } } // MAY contain zero or one [0..1] entryRelationship // SHALL contain exactly one [1..1] Age Observation if (count($PortionData['AgeObservation']) > 0) { foreach ($PortionData['AgeObservation'] as $AgeObservation) { $Entry['observation']['entryRelationship'][] = ['@attributes' => ['typeCode' => 'SUBJ'], ageObservation::Insert($AgeObservation, $CompleteData)]; } } // MAY contain zero or one [0..1] entryRelationship // SHALL contain exactly one [1..1] Prognosis Observation (NEW) if (count($PortionData['PrognosisObservation']) > 0) { foreach ($PortionData['PrognosisObservation'] as $PrognosisObservation) { $Entry['observation']['entryRelationship'][] = ['@attributes' => ['typeCode' => 'REFR'], prognosisObservation::Insert($PrognosisObservation, $CompleteData)]; } } // MAY contain zero or one [0..1] entryRelationship // SHALL contain exactly one [1..1] Patient Priority Preference (NEW) if (count($PortionData['PatientPriorityPreference']) > 0) { foreach ($PortionData['PatientPriorityPreference'] as $PatientPriorityPreference) { $Entry['observation']['entryRelationship'][] = ['@attributes' => ['typeCode' => 'REFR'], patientPriorityPreference::Insert($PatientPriorityPreference, $CompleteData)]; } } // MAY contain zero or one [0..1] entryRelationship // SHALL contain exactly one [1..1] Prognosis Observation (NEW) if (count($PortionData['ProviderPriorityPreference']) > 0) { foreach ($PortionData['ProviderPriorityPreference'] as $ProviderPriorityPreference) { $Entry['observation']['entryRelationship'][] = ['@attributes' => ['typeCode' => 'REFR'], providerPriorityPreference::Insert($ProviderPriorityPreference, $CompleteData)]; } } return $Entry; } catch (Exception $Error) { return $Error; } }