/** * @param $PortionData * @param $CompleteData * @return array|Exception */ public static function Insert($PortionData, $CompleteData) { try { // Validate first self::Validate($PortionData); $Entry = ['supply' => ['@attributes' => ['classCode' => 'SPLY', 'moodCode' => 'INT'], 'templateId' => Component::templateId('2.16.840.1.113883.10.20.22.4.17.2'), 'id' => Component::id(Utilities::UUIDv4()), 'statusCode' => Component::statusCode('completed'), 'repeatNumber' => ['@attributes' => ['value' => $PortionData['repeatNumber']]], 'quantity' => ['@attributes' => ['value' => $PortionData['quantity']]]]]; // MAY contain zero or one [0..1] author if (count($PortionData['Author']) > 0) { $Entry['supply']['author'] = LevelOther\authorParticipation::Insert($PortionData['Author'][0], $CompleteData); } // MAY contain zero or one [0..1] entryRelationship // SHALL contain exactly one [1..1] Instruction (V2) if (count($PortionData['Instruction']) > 0) { $Entry['supply']['entryRelationship'] = ['@attributes' => ['typeCode' => 'SUBJ', 'moodCode' => 'INT'], 'act' => instruction::Insert($PortionData['Instruction'][0], $CompleteData)]; } // MAY contain zero or one [0..1] product // SHALL contain exactly one [1..1] Medication Information (V2) if (count($PortionData['ProductMedicationInformation']) > 0) { $Entry['supply']['product'][] = medicationInformation::Insert($PortionData['ProductMedicationInformation'][0], $CompleteData); } // MAY contain zero or one [0..1] product // SHALL contain exactly one [1..1] Immunization Medication Information (V2) if (count($PortionData['ProductImmunizationMedicationInformation']) > 0) { $Entry['supply']['product'][] = immunizationMedicationInformation::Insert($PortionData['ProductImmunizationMedicationInformation'][0], $CompleteData); } // SHOULD contain zero or one [0..1] effectiveTime // SHALL contain exactly one [1..1] high if (isset($PortionData['effectiveTime_low'])) { $Entry['supply']['effectiveTime'] = ['@attributes' => ['xsi:type' => 'IVL_TS'], 'low' => ['@attributes' => ['value' => $PortionData['effectiveTime_low']]], 'high' => ['@attributes' => ['nullFlavor' => 'UNK']]]; } 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); $Section = ['component' => ['section' => ['templateId' => ['@attributes' => ['root' => '2.16.840.1.113883.10.20.21.2.45.2', 'extension' => $PortionData['Instructions']['date']]], 'code' => ['@attributes' => ['code' => '69730-0', 'codeSystem' => '2.16.840.1.113883.6.1', 'codeSystemName' => 'LOINC', 'displayName' => 'INSTRUCTIONS']], 'title' => 'Instructions', 'text' => self::Narrative($PortionData)]]]; // SHOULD contain zero or more [0..*] entry // SHALL contain exactly one [1..1] Instruction (V2) if (count($PortionData['Instruction']) > 0) { foreach ($PortionData['Instruction'] as $Instruction) { $Section['component']['section']['entry'][] = LevelEntry\instruction::Insert($Instruction, $CompleteData); } } return $Section; } 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 = ['supply' => ['@attributes' => ['classCode' => 'SPLY', 'moodCode' => 'RQO'], 'templateId' => Component::templateId('2.16.840.1.113883.10.20.22.4.50'), 'id' => Component::id(Utilities::UUIDv4()), 'statusCode' => Component::statusCode('completed'), 'effectiveTime' => ['@attributes' => ['xsi:type' => 'IVL TS'], 'high' => ['@attributes' => ['value' => $PortionData['effectiveTime']]]], 'quantity' => ['@attributes' => ['value' => $PortionData['quantity']]]]]; // MAY contain zero or one [0..1] participant // SHALL contain exactly one [1..1] Product Instance if (count($PortionData['ProductInstance']) > 0) { $Entry['supply']['participant'] = ['participantRole' => productInstance::Insert($PortionData['ProductInstance'][0], $CompleteData)]; } // MAY contain zero or more [0..1] entryRelationship // SHALL contain exactly one [1..1] Instruction (V2) if (count($PortionData['Instruction']) > 0) { $Entry['supply']['entryRelationship'][] = ['@attributes' => ['typeCode' => 'SUBJ'], 'act' => instruction::Insert($PortionData['Instruction'][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 = ['substanceAdministration' => ['@attributes' => ['classCode' => 'SBADM', 'moodCode' => 'EVN'], 'templateId' => Component::templateId('2.16.840.1.113883.10.20.22.4.52.2'), 'id' => Component::id(Utilities::UUIDv4()), 'statusCode' => Component::statusCode('completed'), 'effectiveTime' => Component::time($PortionData['effectiveTime']), 'routeCode' => ['@attributes' => ['code' => $PortionData['routeCode'], 'codeSystem' => Utilities::CodingSystemId($PortionData['routeCodeSystemName']), 'codeSystemName' => $PortionData['routeCodeSystemName'], 'displayName' => $PortionData['routeDisplayName']]], 'doseQuantity' => ['@attributes' => ['value' => $PortionData['doseQuantityValue'], 'unit' => $PortionData['doseQuantityUnit']]], 'consumable' => ['manufacturedProduct' => immunizationMedicationInformation::Insert($PortionData, $CompleteData)], 'performer' => LevelDocument\performer::Insert($PortionData)]]; // MAY contain zero or more [0..*] entryRelationship // SHALL contain exactly one [1..1] Indication (V2) if (count($PortionData['Indication']) > 0) { foreach ($PortionData['Indication'] as $Indication) { $Entry['substanceAdministration']['entryRelationship'][] = ['@attributes' => ['typeCode' => 'RSON'], indication::Insert($Indication, $CompleteData)]; } } // MAY contain zero or more [0..1] entryRelationship // SHALL contain exactly one [1..1] Instruction (V2) if (count($PortionData['Instruction']) > 0) { $Entry['substanceAdministration']['entryRelationship'][] = ['@attributes' => ['typeCode' => 'SUBJ'], instruction::Insert($PortionData['Instruction'][0], $CompleteData)]; } // MAY contain zero or more [0..1] entryRelationship // SHALL contain exactly one [1..1] Medication Supply Order (V2) if (count($PortionData['MedicationSupplyOrder']) > 0) { $Entry['substanceAdministration']['entryRelationship'][] = ['@attributes' => ['typeCode' => 'REFR'], medicationSupplyOrder::Insert($PortionData['MedicationSupplyOrder'][0], $CompleteData)]; } // MAY contain zero or more [0..1] entryRelationship // SHALL contain exactly one [1..1] Medication Dispense (V2) if (count($PortionData['MedicationDispense']) > 0) { $Entry['substanceAdministration']['supply'][] = ['@attributes' => ['typeCode' => 'REFR'], medicationDispense::Insert($PortionData['MedicationDispense'][0], $CompleteData)]; } // MAY contain zero or more [0..1] entryRelationship // SHALL contain exactly one [1..1] Reaction Observation (V2) if (count($PortionData['ReactionObservation']) > 0) { $Entry['substanceAdministration']['supply'][] = ['@attributes' => ['typeCode' => 'CAUS'], reactionObservation::Insert($PortionData['ReactionObservation'][0], $CompleteData)]; } // MAY contain zero or more [0..1] entryRelationship // SHALL contain exactly one [1..1] Immunization Refusal Reason if (count($PortionData['ImmunizationRefusalReason']) > 0) { $Entry['substanceAdministration']['supply'][] = ['@attributes' => ['typeCode' => 'RSON'], immunizationRefusalReason::Insert($PortionData['ImmunizationRefusalReason'][0], $CompleteData)]; } // MAY contain zero or more [0..*] entryRelationship // SHALL contain exactly one [1..1] Substance Administered Act (NEW) if (count($PortionData['SubstanceAdministeredAct']) > 0) { foreach ($PortionData['SubstanceAdministeredAct'] as $SubstanceAdministeredAct) { $Entry['substanceAdministration']['entryRelationship'][] = ['@attributes' => ['typeCode' => 'COMP', 'inversionInd' => 'true'], substanceAdministeredAct::Insert($SubstanceAdministeredAct, $CompleteData)]; } } // MAY contain zero or more [0..*] entryRelationship // SHALL contain exactly one [1..1] Substance Administered Act (NEW) if (count($PortionData['PreconditionForSubstanceAdministration']) > 0) { foreach ($PortionData['PreconditionForSubstanceAdministration'] as $PreconditionForSubstanceAdministration) { $Entry['substanceAdministration']['precondition'][] = ['@attributes' => ['typeCode' => 'PRCN'], preconditionForSubstanceAdministration::Insert($PreconditionForSubstanceAdministration, $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); $Section = ['component' => ['section' => Component::templateId('2.16.840.1.113883.10.20.22.2.10.1.2'), 'code' => ['@attributes' => ['code' => '18776-5', 'displayName' => 'Treatment Plan', 'codeSystem' => '2.16.840.1.113883.6.1', 'codeSystemName' => 'LOINC']], 'title' => 'Treatment Plan', 'text' => self::Narrative($PortionData)]]; // MAY contain zero or more [0..*] entry // SHALL contain exactly one [1..1] Planned Observation (V2) if (count($PortionData['PlannedObservation']) > 0) { foreach ($PortionData['PlannedObservation'] as $PlannedObservation) { $Section['component']['section']['entry'][] = LevelEntry\plannedObservation::Insert($PlannedObservation, $CompleteData); } } // MAY contain zero or more [0..*] entry // SHALL contain exactly one [1..1] Planned Encounter (V2) if (count($PortionData['PlannedEncounter']) > 0) { foreach ($PortionData['PlannedEncounter'] as $PlannedEncounter) { $Section['component']['section']['entry'][] = LevelEntry\plannedEncounter::Insert($PlannedEncounter, $CompleteData); } } // MAY contain zero or more [0..*] entry // SHALL contain exactly one [1..1] Planned Act (V2) if (count($PortionData['PlannedAct']) > 0) { foreach ($PortionData['PlannedAct'] as $PlannedAct) { $Section['component']['section']['entry'][] = LevelEntry\plannedAct::Insert($PlannedAct, $CompleteData); } } // MAY contain zero or more [0..*] entry // SHALL contain exactly one [1..1] Planned Procedure (V2) if (count($PortionData['PlannedProcedure']) > 0) { foreach ($PortionData['PlannedProcedure'] as $PlannedProcedure) { $Section['component']['section']['entry'][] = LevelEntry\plannedProcedure::Insert($PlannedProcedure, $CompleteData); } } // MAY contain zero or more [0..*] entry // SHALL contain exactly one [1..1] Planned Substance Administration (V2) if (count($PortionData['PlannedSubstanceAdministration']) > 0) { foreach ($PortionData['PlannedSubstanceAdministration'] as $PlannedSubstanceAdministration) { $Section['component']['section']['entry'][] = LevelEntry\plannedSubstanceAdministration::Insert($PlannedSubstanceAdministration, $CompleteData); } } // MAY contain zero or more [0..*] entry // SHALL contain exactly one [1..1] Planned Supply (V2) if (count($PortionData['PlannedSupply']) > 0) { foreach ($PortionData['PlannedSupply'] as $PlannedSupply) { $Section['component']['section']['entry'][] = LevelEntry\plannedSupply::Insert($PlannedSupply, $CompleteData); } } // MAY contain zero or more [0..*] entry // SHALL contain exactly one [1..1] Instruction (V2) if (count($PortionData['Instruction']) > 0) { foreach ($PortionData['Instruction'] as $Instruction) { $Section['component']['section']['entry'][] = LevelEntry\instruction::Insert($Instruction, $CompleteData); } } // MAY contain zero or more [0..*] entry // SHALL contain exactly one [1..1] Handoff Communication (NEW) if (count($PortionData['HandoffCommunication']) > 0) { foreach ($PortionData['HandoffCommunication'] as $HandoffCommunication) { $Section['component']['section']['entry'][] = LevelEntry\handoffCommunication::Insert($HandoffCommunication, $CompleteData); } } // MAY contain zero or more [0..*] entry // SHALL contain exactly one [1..1] Nutrition Recommendations (NEW) if (count($PortionData['NutritionRecommendations']) > 0) { foreach ($PortionData['NutritionRecommendations'] as $NutritionRecommendations) { $Section['component']['section']['entry'][] = LevelEntry\nutritionRecommendations::Insert($NutritionRecommendations, $CompleteData); } } return $Section; } 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 = ['act' => ['@attributes' => ['classCode' => 'ACT', 'moodCode' => $PortionData['moodCode']], 'templateId' => Component::templateId('2.16.840.1.113883.10.20.22.4.131'), 'id' => Component::id(Utilities::UUIDv4()), 'code' => ['@attributes' => ['code' => $PortionData['code'], 'codeSystem' => Utilities::CodingSystemId($PortionData['codeSystemName']), 'codeSystemName' => $PortionData['codeSystemName'], 'displayName' => $PortionData['displayName']]], 'statusCode' => Component::statusCode('active')]]; // SHOULD contain zero or more [0..*] Author Participation (NEW) if (count($PortionData['Author']) > 0) { foreach ($PortionData['Author'] as $Author) { $Entry['act']['author'][] = LevelOther\authorParticipation::Insert($Author, $CompleteData); } } // MAY contain zero or more [0..*] entryRelationship // SHALL contain exactly one [1..1] Advance Directive Observation (V2) if (count($PortionData['AdvanceDirectiveObservation']) > 0) { foreach ($PortionData['AdvanceDirectiveObservation'] as $AdvanceDirectiveObservation) { $Entry['act']['entryRelationship']['entry'][] = ['@attributes' => ['typeCode' => 'REFR'], advanceDirectiveObservation::Insert($AdvanceDirectiveObservation, $CompleteData)]; } } // MAY contain zero or more [0..*] entryRelationship // SHALL contain exactly one [1..1] Medication Activity (V2) if (count($PortionData['MedicationActivity']) > 0) { foreach ($PortionData['MedicationActivity'] as $MedicationActivity) { $Entry['act']['entryRelationship']['entry'][] = ['@attributes' => ['typeCode' => 'REFR'], medicationActivity::Insert($MedicationActivity, $CompleteData)]; } } // MAY contain zero or more [0..*] entryRelationship // SHALL contain exactly one [1..1] Medication Activity (V2) if (count($PortionData['ProcedureActivityAct']) > 0) { foreach ($PortionData['ProcedureActivityAct'] as $ProcedureActivityAct) { $Entry['act']['entryRelationship']['entry'][] = ['@attributes' => ['typeCode' => 'REFR'], procedureActivityAct::Insert($ProcedureActivityAct, $CompleteData)]; } } // MAY contain zero or more [0..*] entryRelationship // SHALL contain exactly one [1..1] Goal Observation (NEW) if (count($PortionData['GoalObservation']) > 0) { foreach ($PortionData['GoalObservationAct'] as $GoalObservation) { $Entry['act']['entryRelationship']['entry'][] = ['@attributes' => ['typeCode' => 'RSON'], goalObservation::Insert($GoalObservation, $CompleteData)]; } } // MAY contain zero or more [0..*] entryRelationship // SHALL contain exactly one [1..1] Procedure Activity Observation (V2) if (count($PortionData['ProcedureActivityObservation']) > 0) { foreach ($PortionData['ProcedureActivityObservation'] as $ProcedureActivityObservation) { $Entry['act']['entryRelationship']['entry'][] = ['@attributes' => ['typeCode' => 'REFR'], procedureActivityObservation::Insert($ProcedureActivityObservation, $CompleteData)]; } } // MAY contain zero or more [0..*] entryRelationship // SHALL contain exactly one [1..1] Procedure Activity Procedure (V2) if (count($PortionData['ProcedureActivityProcedure']) > 0) { foreach ($PortionData['ProcedureActivityProcedure'] as $ProcedureActivityProcedure) { $Entry['act']['entryRelationship']['entry'][] = ['@attributes' => ['typeCode' => 'REFR'], procedureActivityProcedure::Insert($ProcedureActivityProcedure, $CompleteData)]; } } // MAY contain zero or more [0..*] entryRelationship // SHALL contain exactly one [1..1] Encounter Activity (V2) if (count($PortionData['EncounterActivity']) > 0) { foreach ($PortionData['EncounterActivity'] as $EncounterActivity) { $Entry['act']['entryRelationship']['entry'][] = ['@attributes' => ['typeCode' => 'REFR'], encounterActivity::Insert($EncounterActivity, $CompleteData)]; } } // MAY contain zero or more [0..*] entryRelationship // SHALL contain exactly one [1..1] Instruction (V2) if (count($PortionData['Instruction']) > 0) { foreach ($PortionData['Instruction'] as $Instruction) { $Entry['act']['entryRelationship']['entry'][] = ['@attributes' => ['typeCode' => 'REFR'], instruction::Insert($Instruction, $CompleteData)]; } } // MAY contain zero or more [0..*] entryRelationship // SHALL contain exactly one [1..1] Instruction (V2) if (count($PortionData['NonMedicinalSupplyActivity']) > 0) { foreach ($PortionData['NonMedicinalSupplyActivity'] as $NonMedicinalSupplyActivity) { $Entry['act']['entryRelationship']['entry'][] = ['@attributes' => ['typeCode' => 'REFR'], nonMedicinalSupplyActivity::Insert($NonMedicinalSupplyActivity, $CompleteData)]; } } // MAY contain zero or more [0..*] entryRelationship // SHALL contain exactly one [1..1] Planned Act (V2) if (count($PortionData['PlannedAct']) > 0) { foreach ($PortionData['PlannedAct'] as $PlannedAct) { $Entry['act']['entryRelationship']['entry'][] = ['@attributes' => ['typeCode' => 'REFR'], plannedAct::Insert($PlannedAct, $CompleteData)]; } } // MAY contain zero or more [0..*] entryRelationship // SHALL contain exactly one [1..1] Planned Encounter (V2) if (count($PortionData['PlannedEncounter']) > 0) { foreach ($PortionData['PlannedEncounter'] as $PlannedEncounter) { $Entry['act']['entryRelationship']['entry'][] = ['@attributes' => ['typeCode' => 'REFR'], plannedEncounter::Insert($PlannedEncounter, $CompleteData)]; } } // MAY contain zero or more [0..*] entryRelationship // SHALL contain exactly one [1..1] Planned Encounter (V2) if (count($PortionData['PlannedObservation']) > 0) { foreach ($PortionData['PlannedObservation'] as $PlannedObservation) { $Entry['act']['entryRelationship']['entry'][] = ['@attributes' => ['typeCode' => 'REFR'], plannedObservation::Insert($PlannedObservation, $CompleteData)]; } } // MAY contain zero or more [0..*] entryRelationship // SHALL contain exactly one [1..1] Planned Procedure (V2) if (count($PortionData['PlannedProcedure']) > 0) { foreach ($PortionData['PlannedProcedure'] as $PlannedProcedure) { $Entry['act']['entryRelationship']['entry'][] = ['@attributes' => ['typeCode' => 'REFR'], plannedProcedure::Insert($PlannedProcedure, $CompleteData)]; } } // MAY contain zero or more [0..*] entryRelationship // SHALL contain exactly one [1..1] Planned Procedure (V2) if (count($PortionData['PlannedSubstanceAdministration']) > 0) { foreach ($PortionData['PlannedSubstanceAdministration'] as $PlannedSubstanceAdministration) { $Entry['act']['entryRelationship']['entry'][] = ['@attributes' => ['typeCode' => 'REFR'], plannedSubstanceAdministration::Insert($PlannedSubstanceAdministration, $CompleteData)]; } } // MAY contain zero or more [0..*] entryRelationship // SHALL contain exactly one [1..1] Planned Supply (V2) if (count($PortionData['PlannedSupply']) > 0) { foreach ($PortionData['PlannedSupply'] as $PlannedSupply) { $Entry['act']['entryRelationship']['entry'][] = ['@attributes' => ['typeCode' => 'REFR'], plannedSupply::Insert($PlannedSupply, $CompleteData)]; } } // MAY contain zero or more [0..*] entryRelationship // SHALL contain exactly one [1..1] Nutrition Recommendations (NEW) if (count($PortionData['NutritionRecommendations']) > 0) { foreach ($PortionData['NutritionRecommendations'] as $NutritionRecommendations) { $Entry['act']['entryRelationship']['entry'][] = ['@attributes' => ['typeCode' => 'REFR'], nutritionRecommendations::Insert($NutritionRecommendations, $CompleteData)]; } } // MAY contain zero or more [0..*] entryRelationship // SHALL contain exactly one [1..1] Act Reference (NEW) if (count($PortionData['ActReference']) > 0) { foreach ($PortionData['ActReference'] as $ActReference) { $Entry['act']['entryRelationship']['entry'][] = ['@attributes' => ['typeCode' => 'REFR'], actReference::Insert($ActReference, $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 = ['procedure' => ['@attributes' => ['moodCode' => 'EVN', 'classCode' => 'PROC'], 'templateId' => Component::templateId('2.16.840.1.113883.10.20.22.4.14.2'), 'id' => Component::id(Utilities::UUIDv4()), 'code' => ['code' => $PortionData['activityCode'], 'codeSystem' => Utilities::CodingSystemId($PortionData['activityCodeSystemName']), 'displayName' => $PortionData['activityDisplayName'], 'codeSystemName' => $PortionData['activityCodeSystemName']], 'statusCode' => Component::statusCode($PortionData['statusCode']), 'effectiveTime' => Component::effectiveTime($PortionData['effectiveTime']), 'priorityCode' => ['@attributes' => ['code' => $PortionData['priorityCode'], 'codeSystem' => Utilities::CodingSystemId($PortionData['priorityCodeSystemName']), 'codeSystemName' => $PortionData['priorityCodeSystemName'], 'displayName' => $PortionData['priorityDisplayName']]], 'value' => ['@attributes' => ['xsi:type' => 'CD']]]]; // SHOULD contain zero or more [0..*] targetSiteCode // SHALL be selected from ValueSet Body Site Value Set if (count($PortionData['targetSiteCode']) > 0) { foreach ($PortionData['targetSiteCode'] as $targetSiteCode) { $Entry['procedure']['targetSiteCode'][] = ['@attributes' => ['code' => $targetSiteCode['targetSiteCode'], 'codeSystem' => Utilities::CodingSystemId($targetSiteCode['targetSiteCodeName']), 'codeSystemName' => $targetSiteCode['targetSiteCodeName'], 'displayName' => $targetSiteCode['targetSiteDisplayName']]]; } } // MAY contain zero or more [0..*] specimen // This specimen is for representing specimens obtained from a procedure if (count($PortionData['Specimen']) > 0) { foreach ($PortionData['Specimen'] as $Specimen) { $Entry['procedure']['specimen'][] = ['@attributes' => ['typeCode' => 'SPC'], 'specimenRole' => ['@attributes' => ['classCode' => 'SPEC'], 'id' => Component::id(Utilities::UUIDv4()), 'specimenPlayingEntity' => ['code' => ['@attributes' => ['code' => $Specimen['specimenCode'], 'codeSystem' => Utilities::CodingSystemId($Specimen['specimenCodeSystemName']), 'codeSystemName' => $Specimen['specimenCodeSystemName'], 'displayName' => $Specimen['specimenDisplayName']]]]]]; } } // SHOULD contain zero or one [0..1] text if (isset($PortionData['Narrated'])) { $Entry['procedure']['code']['originalText']['reference'] = ['@attributes' => ['value' => self::Narrative($PortionData['Narrated'])]]; } // SHOULD 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 $Participant) { $Entry['procedure']['participant'][] = LevelDocument\participant::Insert($Participant, $CompleteData); } } // MAY contain zero or one [0..1] entryRelationship // SHALL contain exactly one [1..1] Instruction (V2) if (count($PortionData['Instruction']) > 0) { foreach ($PortionData['Instruction'] as $Instruction) { $Entry['procedure']['entryRelationship'][] = ['@attributes' => ['typeCode' => 'SUBJ'], instruction::Insert($Instruction, $CompleteData)]; } } // MAY contain zero or one [0..1] entryRelationship // SHALL contain exactly one [1..1] Indication (V2) if (count($PortionData['Indication']) > 0) { foreach ($PortionData['Indication'] as $Indication) { $Entry['procedure']['entryRelationship'][] = ['@attributes' => ['typeCode' => 'RSON'], indication::Insert($Indication, $CompleteData)]; } } // MAY contain zero or one [0..1] entryRelationship // SHALL contain exactly one [1..1] Medication Activity (V2) if (count($PortionData['MedicationActivity']) > 0) { foreach ($PortionData['MedicationActivity'] as $MedicationActivity) { $Entry['procedure']['entryRelationship'][] = ['@attributes' => ['typeCode' => 'COMP'], medicationActivity::Insert($MedicationActivity, $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 = ['act' => ['@attributes' => ['moodCode' => 'INT', 'classCode' => 'ACT'], 'templateId' => Component::templateId('2.16.840.1.113883.10.20.22.4.12.2'), 'id' => Component::id(Utilities::UUIDv4()), 'code' => ['code' => $PortionData['activityCode'], 'codeSystem' => Utilities::CodingSystemId($PortionData['activityCodeSystemName']), 'displayName' => $PortionData['activityDisplayName'], 'codeSystemName' => $PortionData['activityCodeSystemName']], 'statusCode' => Component::statusCode($PortionData['statusCode']), 'effectiveTime' => Component::effectiveTime($PortionData['effectiveTime']), 'priorityCode' => ['@attributes' => ['code' => $PortionData['priorityCode'], 'codeSystem' => Utilities::CodingSystemId($PortionData['priorityCodeSystemName']), 'codeSystemName' => $PortionData['priorityCodeSystemName'], 'displayName' => $PortionData['priorityDisplayName']]]]]; // SHOULD contain zero or one [0..1] text if (isset($PortionData['Narrated'])) { $Entry['act']['code']['originalText']['reference'] = ['@attributes' => ['value' => self::Narrative($PortionData['Narrated'])]]; } // SHOULD contain zero or more [0..*] performer if (count($PortionData['Performer']) > 0) { foreach ($PortionData['Performer'] as $Performer) { $Entry['act']['performer'][] = LevelDocument\performer::Insert($Performer, $CompleteData); } } // MAY contain zero or more [0..*] participant if (count($PortionData['Participant']) > 0) { foreach ($PortionData['Participant'] as $Participant) { $Entry['act']['participant'][] = LevelDocument\participant::Insert($Participant, $CompleteData); } } // MAY contain zero or one [0..1] entryRelationship // SHALL contain exactly one [1..1] Instruction (V2) if (count($PortionData['Instruction']) > 0) { foreach ($PortionData['Instruction'] as $Instruction) { $Entry['act']['entryRelationship'][] = ['@attributes' => ['typeCode' => 'SUBJ'], instruction::Insert($Instruction, $CompleteData)]; } } // MAY contain zero or one [0..1] entryRelationship // SHALL contain exactly one [1..1] Indication (V2) if (count($PortionData['Indication']) > 0) { foreach ($PortionData['Indication'] as $Indication) { $Entry['act']['entryRelationship'][] = ['@attributes' => ['typeCode' => 'RSON'], indication::Insert($Indication, $CompleteData)]; } } // MAY contain zero or one [0..1] entryRelationship // SHALL contain exactly one [1..1] Medication Activity (V2) if (count($PortionData['MedicationActivity']) > 0) { foreach ($PortionData['MedicationActivity'] as $MedicationActivity) { $Entry['act']['entryRelationship'][] = ['@attributes' => ['typeCode' => 'COMP'], medicationActivity::Insert($MedicationActivity, $CompleteData)]; } } return $Entry; } catch (Exception $Error) { return $Error; } }