/** * @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.6.2.12'), 'code' => ['@attributes' => ['code' => $PortionData['code'], 'codeSystem' => Utilities::CodingSystemId($PortionData['codeSystemName']), 'codeSystemName' => $PortionData['codeSystemName'], 'displayName' => $PortionData['displayName']]], 'value' => ['@attributes' => ['xsi:type' => 'ED'], 'reference' => ['@attributes' => ['value' => $PortionData['findingsTag']]]]]]; // SHALL contain at least one [1..*] entryRelationship // b. SHALL contain exactly one [1..1] SOP Instance Observation if (count($PortionData['SOPInstanceObservation']) > 0) { foreach ($PortionData['SOPInstanceObservation'] as $SOPInstanceObservation) { $Entry['observation']['entryRelationship'][] = sopInstanceObservation::Insert($SOPInstanceObservation, $CompleteData); } } // SHALL contain at least one [1..*] entryRelationship // b. SHALL contain exactly one [1..1] Quantity Measurement Observation if (count($PortionData['QuantityMeasurementObservation']) > 0) { foreach ($PortionData['QuantityMeasurementObservation'] as $QuantityMeasurementObservation) { $Entry['observation']['entryRelationship'][] = quantityMeasurementObservation::Insert($QuantityMeasurementObservation, $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' => ['classCode' => 'OBS', 'moodCode' => 'EVN'], 'templateId' => Component::templateId('2.16.840.1.113883.10.20.6.2.13'), 'code' => ['@attributes' => ['code' => '18782-3', 'codeSystem' => '2.16.840.1.113883.6.1', 'codeSystemName' => 'LOINC', 'displayName' => 'Study observation']], 'statusCode' => ['@attributes' => ['code' => 'completed']], 'value' => ['xsi:type' => 'CD', 'code' => $PortionData['code'], 'codeSystem' => Utilities::CodingSystemId($PortionData['systemCodeName']), 'codeSystemName' => $PortionData['systemCodeName'], 'displayName' => $PortionData['displayName']]]]; // SHALL contain exactly one [1..1] SOP Instance Observation // (templateId:2.16.840.1.113883.10.20.6.2.8) (CONF:16083). if (count($PortionData['SOPInstanceObservation'] > 0)) { $Entry['observation']['entryRelationship'][] = sopInstanceObservation::Insert($PortionData['SOPInstanceObservation'], $CompleteData); } // SHALL contain exactly one [1..1] Quantity Measurement Observation // (templateId:2.16.840.1.113883.10.20.6.2.14) (CONF:16084). if (count($PortionData['QuantityMeasurementObservation'] > 0)) { $Entry['observation']['entryRelationship'][] = quantityMeasurementObservation::Insert($PortionData['QuantityMeasurementObservation'], $CompleteData); } return $Entry; } catch (Exception $Error) { return $Error; } }