Exemple #1
0
 /**
  * @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' => 'EVN'], 'templateId' => Component::templateId('2.16.840.1.113883.10.20.22.4.18.2'), 'id' => Component::id(Utilities::UUIDv4()), 'statusCode' => ['@attributes' => ['code' => $PortionData['statusCode']]], 'effectiveTime' => Component::time($PortionData['effectiveTime']), 'repeatNumber' => $PortionData['repeatNumber'], 'quantity' => ['@attributes' => ['value' => $PortionData['quantity']]]]];
         // SHOULD contain zero or one [0..1] quantity
         // SHALL contain exactly one [1..1] Medication Information (V2)
         if (count($PortionData['MedicationInformation']) > 0) {
             $Entry['supply']['product'] = medicationInformation::Insert($PortionData['MedicationInformation'][0], $CompleteData);
         }
         // SHOULD contain zero or one [0..1] quantity
         // SHALL contain exactly one [1..1] Immunization Medication Information (V2)
         if (count($PortionData['ImmunizationMedicationInformation']) > 0) {
             $Entry['supply']['product'] = immunizationMedicationInformation::Insert($PortionData['ImmunizationMedicationInformation'][0], $CompleteData);
         }
         // MAY contain zero or more [0..*] entryRelationship
         // SHALL contain exactly one [1..1] Medication Supply Order (V2)
         if (count($PortionData['MedicationSupplyOrder']) > 0) {
             foreach ($PortionData['MedicationSupplyOrder'] as $MedicationSupplyOrder) {
                 $Entry['supply']['entryRelationship']['entry'][] = ['@attributes' => ['typeCode' => 'REFR'], medicationSupplyOrder::Insert($MedicationSupplyOrder, $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;
     }
 }