/** * @param $PortionData * @param $CompleteData * @return array|Exception */ public static function Insert($PortionData, $CompleteData) { try { // Validate first self::Validate($PortionData); $Entry = ['supply' => ['@attributes' => ['moodCode' => $PortionData['moodCode'], 'classCode' => 'OBS'], 'templateId' => Component::templateId('2.16.840.1.113883.10.20.22.4.43.2'), 'id' => Component::id(Utilities::UUIDv4()), 'statusCode' => Component::statusCode('completed')]]; // SHOULD contain zero or one [0..1] repeatNumber if (isset($PortionData['repeatNumber'])) { $Entry['supply']['repeatNumber'] = ['@attributes' => ['value' => $PortionData['repeatNumber']]]; } // SHOULD contain zero or one [0..1] quantity if (isset($PortionData['quantity'])) { $Entry['supply']['quantity'] = ['@attributes' => ['value' => $PortionData['quantity']]]; } // SHOULD contain zero or one [0..1] effectiveTime if (isset($PortionData['effectiveTime'])) { $Entry['supply']['effectiveTime'] = Component::time($PortionData['effectiveTime']); } // MAY contain zero or more [0..*] value // Participants represent those in supporting roles such as caregiver, // who participate in the patient's care. if (count($PortionData['Interval']) > 0) { foreach ($PortionData['Interval'] as $Interval) { $Entry['supply']['value'][] = ['@attributes' => ['xsi:type' => 'IVL_PQ'], 'low' => ['@attributes' => ['value' => $Interval['QuantityValue'], 'unit' => $Interval['QuantityUnit']]]]; } } // MAY contain zero or more [0..*] performer if (count($PortionData['Performer']) > 0) { foreach ($PortionData['Performer'] as $Performer) { $Entry['supply']['performer'][] = LevelDocument\performer::Insert($Performer, $CompleteData); } } // MAY contain zero or more [0..*] participant if (count($PortionData['Participant']) > 0) { foreach ($PortionData['Participant'] as $Participant) { $Entry['supply']['participant'][] = LevelDocument\participant::Insert($Participant, $CompleteData); } } // MAY contain zero or more [0..*] entryRelationship // SHALL contain exactly one [1..1] Service Delivery Location if (count($PortionData['ServiceDeliveryLocation']) > 0) { foreach ($PortionData['ServiceDeliveryLocation'] as $ServiceDeliveryLocation) { $Entry['supply']['participant'][] = serviceDeliveryLocation::Insert($ServiceDeliveryLocation, $CompleteData); } } // MAY contain zero or more [0..*] entryRelationship // SHALL contain exactly one [1..1] Patient Priority Preference (NEW) if (count($PortionData['PatientPriorityPreference']) > 0) { foreach ($PortionData['ProviderPriorityPreference'] as $ProviderPriorityPreference) { $Entry['supply']['entryRelationship'][] = ['@attributes' => ['typeCode' => 'REFR'], providerPriorityPreference::Insert($ProviderPriorityPreference, $CompleteData)]; } } // MAY contain zero or more [0..*] entryRelationship // SHALL contain exactly one [1..1] Patient Priority Preference (NEW) if (count($PortionData['ProviderPriorityPreference']) > 0) { foreach ($PortionData['ProviderPriorityPreference'] as $ProviderPriorityPreference) { $Entry['supply']['entryRelationship'][] = ['@attributes' => ['typeCode' => 'REFR'], providerPriorityPreference::Insert($ProviderPriorityPreference, $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 = ['substanceAdministration' => ['@attributes' => ['moodCode' => $PortionData['moodCode'], 'classCode' => 'SBADM'], 'templateId' => Component::templateId('2.16.840.1.113883.10.20.22.4.42.2'), 'text' => self::Narrative($PortionData), 'id' => Component::id(Utilities::UUIDv4()), 'code' => ['code' => $PortionData['code'], 'codeSystem' => Utilities::CodingSystemId($PortionData['codeSystemName']), 'codeSystemName' => $PortionData['codeSystemName'], 'displayName' => $PortionData['displayName']], 'statusCode' => Component::statusCode('active'), 'effectiveTime' => $PortionData['effectiveTime']]]; // MAY contain zero or more [0..*] performer if (count($PortionData['Performer']) > 0) { foreach ($PortionData['Performer'] as $Performer) { $Entry['procedure']['performer'][] = LevelDocument\performer::Insert($Performer, $CompleteData); } } // MAY contain zero or more [0..*] participant if (count($PortionData['Participant']) > 0) { foreach ($PortionData['Participant'] as $Performer) { $Entry['procedure']['participant'][] = LevelDocument\participant::Insert($Performer, $CompleteData); } } // MAY contain zero or more [0..*] entryRelationship // SHALL contain exactly one [1..1] Service Delivery Location if (count($PortionData['ServiceDeliveryLocation']) > 0) { foreach ($PortionData['ServiceDeliveryLocation'] as $ServiceDeliveryLocation) { $Entry['procedure']['participant'][] = serviceDeliveryLocation::Insert($ServiceDeliveryLocation, $CompleteData); } } // MAY contain zero or more [0..*] entryRelationship // SHALL contain exactly one [1..1] Patient Priority Preference (NEW) if (count($PortionData['PatientPriorityPreference']) > 0) { foreach ($PortionData['ProviderPriorityPreference'] as $ProviderPriorityPreference) { $Entry['procedure']['entryRelationship'][] = ['@attributes' => ['typeCode' => 'REFR'], providerPriorityPreference::Insert($ProviderPriorityPreference, $CompleteData)]; } } // MAY contain zero or more [0..*] entryRelationship // SHALL contain exactly one [1..1] Patient Priority Preference (NEW) if (count($PortionData['ProviderPriorityPreference']) > 0) { foreach ($PortionData['ProviderPriorityPreference'] as $ProviderPriorityPreference) { $Entry['procedure']['entryRelationship'][] = ['@attributes' => ['typeCode' => 'REFR'], providerPriorityPreference::Insert($ProviderPriorityPreference, $CompleteData)]; } } return $Entry; } catch (Exception $Error) { return $Error; } }