From 27c38c41d6f069930cab669d902df8d96aedceb6 Mon Sep 17 00:00:00 2001 From: chaseastewart <153762074+chaseastewart@users.noreply.github.com> Date: Mon, 22 Jan 2024 14:46:41 -0600 Subject: [PATCH] Add support for stu3 templates. Included sample data files and updated examples accordingly. --- README.md | 11 +- data/sample/stu3/AllergyIntolerance.json | 103 ++++++++ data/sample/stu3/Condition.json | 93 ++++++++ data/sample/stu3/Encounter.json | 88 +++++++ data/sample/stu3/Immunization.json | 157 +++++++++++++ data/sample/stu3/Medication.json | 97 ++++++++ data/sample/stu3/Observation.json | 67 ++++++ data/sample/stu3/Organization.json | 71 ++++++ data/sample/stu3/Patient.json | 98 ++++++++ data/sample/stu3/Person.json | 88 +++++++ data/sample/stu3/Procedure.json | 71 ++++++ fhir_converter/filters.py | 97 +++++++- fhir_converter/hl7.py | 13 +- fhir_converter/renderers.py | 186 +++++++++++---- fhir_converter/tags.py | 121 ++++++++-- fhir_converter/templates/stu3/Account.liquid | 10 + .../templates/stu3/ActivityDefinition.liquid | 40 ++++ .../_ActivityDefinitionDynamicValue.liquid | 11 + .../_TranslateKindCode.liquid | 8 + fhir_converter/templates/stu3/Address.liquid | 5 + .../templates/stu3/AdverseEvent.liquid | 26 +++ .../_AdverseEventSuspectEntity.liquid | 9 + .../templates/stu3/AllergyIntolerance.liquid | 24 ++ .../templates/stu3/Appointment.liquid | 12 + .../templates/stu3/AppointmentResponse.liquid | 5 + .../templates/stu3/AuditEvent.liquid | 9 + .../stu3/AuditEvent/_AuditEventAgent.liquid | 8 + .../stu3/AuditEvent/_AuditEventEntity.liquid | 9 + .../AuditEvent/_AuditEventEntityDetail.liquid | 6 + .../stu3/AuditEvent/_AuditEventSource.liquid | 6 + fhir_converter/templates/stu3/Basic.liquid | 5 + fhir_converter/templates/stu3/Binary.liquid | 7 + fhir_converter/templates/stu3/BodySite.liquid | 10 + fhir_converter/templates/stu3/Bundle.liquid | 7 + .../templates/stu3/Bundle/_Entry.liquid | 6 + .../templates/stu3/Bundle/_Response.liquid | 5 + .../templates/stu3/CapabilityStatement.liquid | 22 ++ .../stu3/CapabilityStatement/_Document.liquid | 5 + .../CapabilityStatement/_Messaging.liquid | 6 + .../stu3/CapabilityStatement/_Resource.liquid | 5 + .../stu3/CapabilityStatement/_Rest.liquid | 6 + .../stu3/CapabilityStatement/_Security.liquid | 5 + .../_SupportedMessage.liquid | 5 + fhir_converter/templates/stu3/CarePlan.liquid | 11 + .../templates/stu3/CarePlan/_Activity.liquid | 5 + .../templates/stu3/CarePlan/_Detail.liquid | 25 ++ fhir_converter/templates/stu3/CareTeam.liquid | 8 + .../stu3/CareTeam/_Participant.liquid | 5 + .../templates/stu3/ChargeItem.liquid | 11 + .../ChargeItem/_ChargeItemPerformer.liquid | 6 + fhir_converter/templates/stu3/Claim.liquid | 68 ++++++ .../stu3/Claim/_TranslateUseCode.liquid | 8 + .../templates/stu3/ClaimResponse.liquid | 32 +++ .../_ClaimResponseAddItem.liquid | 12 + .../_ClaimResponseAddItemDetail.liquid | 9 + .../ClaimResponse/_ClaimResponseError.liquid | 10 + .../_ClaimResponseInsurance.liquid | 5 + .../ClaimResponse/_ClaimResponseItem.liquid | 8 + .../_ClaimResponseItemAdjudication.liquid | 5 + .../_ClaimResponseItemDetail.liquid | 8 + .../_ClaimResponseItemDetailSubDetail.liquid | 7 + .../_ClaimResponsePayment.liquid | 6 + .../_ClaimResponseProcessNote.liquid | 5 + .../_ClaimResponseTotalBenefit.liquid | 10 + .../_ClaimResponseTotalCost.liquid | 11 + .../templates/stu3/ClinicalImpression.liquid | 20 ++ .../_TranslateStatusCode.liquid | 8 + .../templates/stu3/CodeSystem.liquid | 8 + .../templates/stu3/Communication.liquid | 30 +++ .../stu3/CommunicationRequest.liquid | 21 ++ .../stu3/CompartmentDefinition.liquid | 14 ++ .../_CompartmentDefinitionResource.liquid | 5 + .../templates/stu3/Composition.liquid | 10 + .../stu3/Composition/_Attester.liquid | 5 + .../templates/stu3/ConceptMap.liquid | 8 + .../templates/stu3/ConceptMap/_Element.liquid | 5 + .../stu3/ConceptMap/_Qualifier.liquid | 6 + .../stu3/ConceptMap/_TheGroup.liquid | 5 + .../stu3/ConceptMap/_TheTarget.liquid | 6 + .../templates/stu3/Condition.liquid | 27 +++ fhir_converter/templates/stu3/Consent.liquid | 28 +++ .../templates/stu3/Consent/_Base.liquid | 10 + .../templates/stu3/Consent/_Provision.liquid | 5 + fhir_converter/templates/stu3/Contract.liquid | 16 ++ .../stu3/Contract/_ContractSigner.liquid | 5 + .../stu3/Contract/_ContractTerm.liquid | 21 ++ .../_ContractTermAssetValuedItem.liquid | 6 + fhir_converter/templates/stu3/Coverage.liquid | 27 +++ .../Coverage/_CoverageGroupingClass.liquid | 10 + .../Coverage/_CoverageGroupingGroup.liquid | 10 + .../Coverage/_CoverageGroupingPlan.liquid | 10 + .../Coverage/_CoverageGroupingSubClass.liquid | 10 + .../Coverage/_CoverageGroupingSubGroup.liquid | 10 + .../Coverage/_CoverageGroupingSubPlan.liquid | 11 + .../DataRequirement/_CodeFilter.liquid | 19 ++ .../_CodeableConceptToAttachment.liquid | 5 + .../DataType/_CodeableConceptToCode.liquid | 2 + .../DataType/_CodingToCodeableConcept.liquid | 5 + .../_ContributorToContactDetail.liquid | 3 + .../stu3/DataType/_DataRequirement.liquid | 5 + .../stu3/DataType/_DecimalToQuantity.liquid | 5 + .../templates/stu3/DataType/_Dosage.liquid | 18 ++ .../templates/stu3/DataType/_Extension.liquid | 10 + .../templates/stu3/DataType/_IdToOid.liquid | 1 + .../_IdentifierToCodeableConcept.liquid | 4 + .../DataType/_IdentifierToReference.liquid | 3 + .../templates/stu3/DataType/_Money.liquid | 4 + .../templates/stu3/DataType/_OidToId.liquid | 1 + .../DataType/_ReferenceToCanonical.liquid | 1 + .../stu3/DataType/_RelatedArtifact.liquid | 5 + .../stu3/DataType/_ResourceMapping.liquid | 24 ++ .../templates/stu3/DataType/_Signature.liquid | 33 +++ .../stu3/DataType/_StringToAnnotation.liquid | 3 + .../stu3/DataType/_TriggerDefinition.liquid | 15 ++ .../templates/stu3/DetectedIssue.liquid | 9 + fhir_converter/templates/stu3/Device.liquid | 31 +++ .../templates/stu3/DeviceMetric.liquid | 5 + .../templates/stu3/DeviceRequest.liquid | 10 + .../templates/stu3/DeviceUseStatement.liquid | 19 ++ .../templates/stu3/DiagnosticReport.liquid | 13 ++ .../stu3/DiagnosticReport/_Performer.liquid | 20 ++ .../templates/stu3/DocumentManifest.liquid | 12 + .../templates/stu3/DocumentReference.liquid | 25 ++ .../stu3/DocumentReference/_Context.liquid | 12 + .../templates/stu3/EligibilityRequest.liquid | 23 ++ .../templates/stu3/EligibilityResponse.liquid | 18 ++ .../_EligibilityResponseInsurance.liquid | 9 + .../templates/stu3/Encounter.liquid | 11 + .../stu3/Encounter/_Diagnosis.liquid | 6 + fhir_converter/templates/stu3/Endpoint.liquid | 5 + .../templates/stu3/EnrollmentRequest.liquid | 8 + .../templates/stu3/EnrollmentResponse.liquid | 11 + .../templates/stu3/EpisodeOfCare.liquid | 5 + .../stu3/ExplanationOfBenefit.liquid | 31 +++ .../_ExplanationOfBenefitAddItem.liquid | 11 + .../_ExplanationOfBenefitAddItemDetail.liquid | 9 + ...tionOfBenefitAddItemDetailSubDetail.liquid | 9 + ..._ExplanationOfBenefitBenefitBalance.liquid | 5 + .../_ExplanationOfBenefitItem.liquid | 18 ++ ...xplanationOfBenefitItemAdjudication.liquid | 5 + .../_ExplanationOfBenefitItemDetail.liquid | 10 + ...anationOfBenefitItemDetailSubDetail.liquid | 9 + .../_ExplanationOfBenefitPayee.liquid | 5 + .../_ExplanationOfBenefitPayment.liquid | 6 + .../_ExplanationOfBenefitProcessNote.liquid | 5 + .../_ExplanationOfBenefitTotalBenefit.liquid | 10 + .../_ExplanationOfBenefitTotalCost.liquid | 10 + .../templates/stu3/FamilyMemberHistory.liquid | 32 +++ fhir_converter/templates/stu3/Flag.liquid | 8 + fhir_converter/templates/stu3/Goal.liquid | 53 +++++ .../templates/stu3/GraphDefinition.liquid | 7 + .../stu3/GraphDefinition/_Compartment.liquid | 5 + .../stu3/GraphDefinition/_Link.liquid | 5 + .../stu3/GraphDefinition/_TheTarget.liquid | 6 + fhir_converter/templates/stu3/Group.liquid | 5 + .../templates/stu3/GuidanceResponse.liquid | 19 ++ .../templates/stu3/HealthcareService.liquid | 19 ++ .../templates/stu3/ImagingStudy.liquid | 39 ++++ .../stu3/ImagingStudy/_Instance.liquid | 11 + .../stu3/ImagingStudy/_Performer.liquid | 11 + .../stu3/ImagingStudy/_Series.liquid | 19 ++ .../templates/stu3/Immunization.liquid | 29 +++ .../stu3/Immunization/_Practitioner.liquid | 6 + .../stu3/Immunization/_Protocol.liquid | 34 +++ .../stu3/ImmunizationRecommendation.liquid | 8 + .../_Recommendation.liquid | 12 + .../templates/stu3/ImplementationGuide.liquid | 24 ++ .../ImplementationGuide/_Definition.liquid | 9 + .../stu3/ImplementationGuide/_Global.liquid | 5 + .../stu3/ImplementationGuide/_Grouping.liquid | 4 + .../stu3/ImplementationGuide/_Manifest.liquid | 3 + .../stu3/ImplementationGuide/_Page.liquid | 40 ++++ .../stu3/ImplementationGuide/_Resource.liquid | 37 +++ fhir_converter/templates/stu3/Library.liquid | 36 +++ fhir_converter/templates/stu3/Linkage.liquid | 5 + fhir_converter/templates/stu3/List.liquid | 5 + fhir_converter/templates/stu3/Location.liquid | 6 + fhir_converter/templates/stu3/Measure.liquid | 53 +++++ .../templates/stu3/Measure/_Population.liquid | 26 +++ .../templates/stu3/Measure/_Stratifier.liquid | 21 ++ .../stu3/Measure/_SupplementalData.liquid | 21 ++ .../templates/stu3/Measure/_TheGroup.liquid | 20 ++ .../templates/stu3/MeasureReport.liquid | 17 ++ .../stu3/MeasureReport/_Population.liquid | 18 ++ .../stu3/MeasureReport/_Population2.liquid | 18 ++ .../stu3/MeasureReport/_Stratifier.liquid | 9 + .../stu3/MeasureReport/_Stratum.liquid | 9 + .../stu3/MeasureReport/_TheGroup.liquid | 9 + .../MeasureReport/_TranslateTypeCode.liquid | 8 + fhir_converter/templates/stu3/Media.liquid | 20 ++ .../templates/stu3/Medication.liquid | 60 +++++ .../stu3/Medication/_Ingredient.liquid | 6 + .../stu3/MedicationAdministration.liquid | 34 +++ .../MedicationAdministration/_Actor.liquid | 16 ++ .../templates/stu3/MedicationDispense.liquid | 32 +++ .../stu3/MedicationDispense/_Actor.liquid | 16 ++ .../templates/stu3/MedicationRequest.liquid | 24 ++ .../stu3/MedicationRequest/_Subst.liquid | 6 + .../templates/stu3/MedicationStatement.liquid | 33 +++ .../templates/stu3/MessageDefinition.liquid | 19 ++ .../MessageDefinition/_AllowedResponse.liquid | 5 + .../stu3/MessageDefinition/_Focus.liquid | 5 + .../_TranslateCategoryCode.liquid | 8 + .../templates/stu3/MessageHeader.liquid | 19 ++ .../templates/stu3/NamingSystem.liquid | 6 + .../templates/stu3/NutritionOrder.liquid | 5 + .../templates/stu3/Observation.liquid | 57 +++++ .../templates/stu3/OperationDefinition.liquid | 9 + .../stu3/OperationDefinition/_Binding.liquid | 11 + .../OperationDefinition/_Parameter.liquid | 10 + .../templates/stu3/OperationOutcome.liquid | 5 + .../templates/stu3/Organization.liquid | 5 + .../templates/stu3/Parameters.liquid | 6 + .../stu3/Parameters/_SubParameter.liquid | 7 + fhir_converter/templates/stu3/Patient.liquid | 12 + .../templates/stu3/Patient/_Animal.liquid | 31 +++ .../templates/stu3/PaymentNotice.liquid | 11 + .../stu3/PaymentReconciliation.liquid | 20 ++ .../_PaymentReconciliationDetail.liquid | 5 + .../_PaymentReconciliationProcessNote.liquid | 4 + fhir_converter/templates/stu3/Person.liquid | 5 + .../templates/stu3/PlanDefinition.liquid | 38 +++ .../stu3/PlanDefinition/_Action.liquid | 17 ++ .../stu3/PlanDefinition/_Condition.liquid | 15 ++ .../stu3/PlanDefinition/_DynamicValue.liquid | 12 + .../stu3/PlanDefinition/_Goal.liquid | 5 + .../templates/stu3/Practitioner.liquid | 5 + .../templates/stu3/PractitionerRole.liquid | 5 + .../templates/stu3/Procedure.liquid | 17 ++ .../stu3/Procedure/_ProcedurePerformer.liquid | 6 + .../Procedure/_TranslateStatusCode.liquid | 15 ++ .../templates/stu3/Provenance.liquid | 12 + .../templates/stu3/Provenance/_Agent.liquid | 34 +++ .../templates/stu3/Provenance/_Entity.liquid | 21 ++ .../templates/stu3/Questionnaire.liquid | 6 + .../stu3/Questionnaire/_EnableWhen.liquid | 13 ++ .../stu3/Questionnaire/_Initial.liquid | 16 ++ .../templates/stu3/Questionnaire/_Item.liquid | 14 ++ .../stu3/QuestionnaireResponse.liquid | 11 + .../stu3/QuestionnaireResponse/_Answer.liquid | 5 + .../stu3/QuestionnaireResponse/_Item.liquid | 18 ++ .../templates/stu3/RelatedPerson.liquid | 8 + .../templates/stu3/RequestGroup.liquid | 13 ++ .../stu3/RequestGroup/_Action.liquid | 10 + .../stu3/RequestGroup/_Condition.liquid | 11 + .../templates/stu3/ResearchStudy.liquid | 20 ++ .../templates/stu3/ResearchStudy/_Arm.liquid | 6 + .../ResearchStudy/_TranslateStatusCode.liquid | 14 ++ .../templates/stu3/ResearchSubject.liquid | 6 + fhir_converter/templates/stu3/Resource.liquid | 220 ++++++++++++++++++ .../templates/stu3/RiskAssessment.liquid | 16 ++ fhir_converter/templates/stu3/Schedule.liquid | 6 + .../templates/stu3/SearchParameter.liquid | 13 ++ fhir_converter/templates/stu3/Sequence.liquid | 8 + .../templates/stu3/Sequence/_Quality.liquid | 5 + .../stu3/Sequence/_ReferenceSeq.liquid | 9 + fhir_converter/templates/stu3/Slot.liquid | 6 + fhir_converter/templates/stu3/Specimen.liquid | 5 + .../templates/stu3/StructureDefinition.liquid | 14 ++ .../templates/stu3/StructureMap.liquid | 6 + .../templates/stu3/StructureMap/_Rule.liquid | 6 + .../stu3/StructureMap/_TheGroup.liquid | 5 + .../stu3/StructureMap/_TheSource.liquid | 6 + .../templates/stu3/Subscription.liquid | 6 + .../templates/stu3/Substance.liquid | 5 + .../templates/stu3/SupplyDelivery.liquid | 6 + .../templates/stu3/SupplyRequest.liquid | 25 ++ fhir_converter/templates/stu3/Task.liquid | 13 ++ .../templates/stu3/TestReport.liquid | 5 + .../templates/stu3/TestScript.liquid | 10 + .../templates/stu3/TestScript/_Action.liquid | 5 + .../templates/stu3/TestScript/_Assert.liquid | 6 + .../stu3/TestScript/_Capability.liquid | 5 + .../stu3/TestScript/_Metadata.liquid | 5 + .../templates/stu3/TestScript/_Setup.liquid | 5 + .../templates/stu3/TestScript/_Test.liquid | 5 + fhir_converter/templates/stu3/ValueSet.liquid | 17 ++ .../templates/stu3/VisionPrescription.liquid | 25 ++ .../stu3/VisionPrescription/_Dispense.liquid | 13 ++ fhir_converter/templates/stu3/metadata.json | 3 + fhir_converter/utils.py | 77 ++++-- logo.png | Bin 11869 -> 7794 bytes mypy.ini | 7 + pyproject.toml | 1 + scripts/examples.py | 94 +++++--- tests/data/stu3/Immunization.json | 157 +++++++++++++ tests/data/stu3/Person.json | 88 +++++++ tests/test_filters.py | 210 ++++++++++++++++- tests/test_renderers.py | 127 ++++++++-- tests/test_tags.py | 172 ++++++++++++-- tests/test_utils.py | 122 ++++++++-- 291 files changed, 5810 insertions(+), 181 deletions(-) create mode 100644 data/sample/stu3/AllergyIntolerance.json create mode 100644 data/sample/stu3/Condition.json create mode 100644 data/sample/stu3/Encounter.json create mode 100644 data/sample/stu3/Immunization.json create mode 100644 data/sample/stu3/Medication.json create mode 100644 data/sample/stu3/Observation.json create mode 100644 data/sample/stu3/Organization.json create mode 100644 data/sample/stu3/Patient.json create mode 100644 data/sample/stu3/Person.json create mode 100644 data/sample/stu3/Procedure.json create mode 100644 fhir_converter/templates/stu3/Account.liquid create mode 100644 fhir_converter/templates/stu3/ActivityDefinition.liquid create mode 100644 fhir_converter/templates/stu3/ActivityDefinition/_ActivityDefinitionDynamicValue.liquid create mode 100644 fhir_converter/templates/stu3/ActivityDefinition/_TranslateKindCode.liquid create mode 100644 fhir_converter/templates/stu3/Address.liquid create mode 100644 fhir_converter/templates/stu3/AdverseEvent.liquid create mode 100644 fhir_converter/templates/stu3/AdverseEvent/_AdverseEventSuspectEntity.liquid create mode 100644 fhir_converter/templates/stu3/AllergyIntolerance.liquid create mode 100644 fhir_converter/templates/stu3/Appointment.liquid create mode 100644 fhir_converter/templates/stu3/AppointmentResponse.liquid create mode 100644 fhir_converter/templates/stu3/AuditEvent.liquid create mode 100644 fhir_converter/templates/stu3/AuditEvent/_AuditEventAgent.liquid create mode 100644 fhir_converter/templates/stu3/AuditEvent/_AuditEventEntity.liquid create mode 100644 fhir_converter/templates/stu3/AuditEvent/_AuditEventEntityDetail.liquid create mode 100644 fhir_converter/templates/stu3/AuditEvent/_AuditEventSource.liquid create mode 100644 fhir_converter/templates/stu3/Basic.liquid create mode 100644 fhir_converter/templates/stu3/Binary.liquid create mode 100644 fhir_converter/templates/stu3/BodySite.liquid create mode 100644 fhir_converter/templates/stu3/Bundle.liquid create mode 100644 fhir_converter/templates/stu3/Bundle/_Entry.liquid create mode 100644 fhir_converter/templates/stu3/Bundle/_Response.liquid create mode 100644 fhir_converter/templates/stu3/CapabilityStatement.liquid create mode 100644 fhir_converter/templates/stu3/CapabilityStatement/_Document.liquid create mode 100644 fhir_converter/templates/stu3/CapabilityStatement/_Messaging.liquid create mode 100644 fhir_converter/templates/stu3/CapabilityStatement/_Resource.liquid create mode 100644 fhir_converter/templates/stu3/CapabilityStatement/_Rest.liquid create mode 100644 fhir_converter/templates/stu3/CapabilityStatement/_Security.liquid create mode 100644 fhir_converter/templates/stu3/CapabilityStatement/_SupportedMessage.liquid create mode 100644 fhir_converter/templates/stu3/CarePlan.liquid create mode 100644 fhir_converter/templates/stu3/CarePlan/_Activity.liquid create mode 100644 fhir_converter/templates/stu3/CarePlan/_Detail.liquid create mode 100644 fhir_converter/templates/stu3/CareTeam.liquid create mode 100644 fhir_converter/templates/stu3/CareTeam/_Participant.liquid create mode 100644 fhir_converter/templates/stu3/ChargeItem.liquid create mode 100644 fhir_converter/templates/stu3/ChargeItem/_ChargeItemPerformer.liquid create mode 100644 fhir_converter/templates/stu3/Claim.liquid create mode 100644 fhir_converter/templates/stu3/Claim/_TranslateUseCode.liquid create mode 100644 fhir_converter/templates/stu3/ClaimResponse.liquid create mode 100644 fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseAddItem.liquid create mode 100644 fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseAddItemDetail.liquid create mode 100644 fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseError.liquid create mode 100644 fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseInsurance.liquid create mode 100644 fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseItem.liquid create mode 100644 fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseItemAdjudication.liquid create mode 100644 fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseItemDetail.liquid create mode 100644 fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseItemDetailSubDetail.liquid create mode 100644 fhir_converter/templates/stu3/ClaimResponse/_ClaimResponsePayment.liquid create mode 100644 fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseProcessNote.liquid create mode 100644 fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseTotalBenefit.liquid create mode 100644 fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseTotalCost.liquid create mode 100644 fhir_converter/templates/stu3/ClinicalImpression.liquid create mode 100644 fhir_converter/templates/stu3/ClinicalImpression/_TranslateStatusCode.liquid create mode 100644 fhir_converter/templates/stu3/CodeSystem.liquid create mode 100644 fhir_converter/templates/stu3/Communication.liquid create mode 100644 fhir_converter/templates/stu3/CommunicationRequest.liquid create mode 100644 fhir_converter/templates/stu3/CompartmentDefinition.liquid create mode 100644 fhir_converter/templates/stu3/CompartmentDefinition/_CompartmentDefinitionResource.liquid create mode 100644 fhir_converter/templates/stu3/Composition.liquid create mode 100644 fhir_converter/templates/stu3/Composition/_Attester.liquid create mode 100644 fhir_converter/templates/stu3/ConceptMap.liquid create mode 100644 fhir_converter/templates/stu3/ConceptMap/_Element.liquid create mode 100644 fhir_converter/templates/stu3/ConceptMap/_Qualifier.liquid create mode 100644 fhir_converter/templates/stu3/ConceptMap/_TheGroup.liquid create mode 100644 fhir_converter/templates/stu3/ConceptMap/_TheTarget.liquid create mode 100644 fhir_converter/templates/stu3/Condition.liquid create mode 100644 fhir_converter/templates/stu3/Consent.liquid create mode 100644 fhir_converter/templates/stu3/Consent/_Base.liquid create mode 100644 fhir_converter/templates/stu3/Consent/_Provision.liquid create mode 100644 fhir_converter/templates/stu3/Contract.liquid create mode 100644 fhir_converter/templates/stu3/Contract/_ContractSigner.liquid create mode 100644 fhir_converter/templates/stu3/Contract/_ContractTerm.liquid create mode 100644 fhir_converter/templates/stu3/Contract/_ContractTermAssetValuedItem.liquid create mode 100644 fhir_converter/templates/stu3/Coverage.liquid create mode 100644 fhir_converter/templates/stu3/Coverage/_CoverageGroupingClass.liquid create mode 100644 fhir_converter/templates/stu3/Coverage/_CoverageGroupingGroup.liquid create mode 100644 fhir_converter/templates/stu3/Coverage/_CoverageGroupingPlan.liquid create mode 100644 fhir_converter/templates/stu3/Coverage/_CoverageGroupingSubClass.liquid create mode 100644 fhir_converter/templates/stu3/Coverage/_CoverageGroupingSubGroup.liquid create mode 100644 fhir_converter/templates/stu3/Coverage/_CoverageGroupingSubPlan.liquid create mode 100644 fhir_converter/templates/stu3/DataType/DataRequirement/_CodeFilter.liquid create mode 100644 fhir_converter/templates/stu3/DataType/_CodeableConceptToAttachment.liquid create mode 100644 fhir_converter/templates/stu3/DataType/_CodeableConceptToCode.liquid create mode 100644 fhir_converter/templates/stu3/DataType/_CodingToCodeableConcept.liquid create mode 100644 fhir_converter/templates/stu3/DataType/_ContributorToContactDetail.liquid create mode 100644 fhir_converter/templates/stu3/DataType/_DataRequirement.liquid create mode 100644 fhir_converter/templates/stu3/DataType/_DecimalToQuantity.liquid create mode 100644 fhir_converter/templates/stu3/DataType/_Dosage.liquid create mode 100644 fhir_converter/templates/stu3/DataType/_Extension.liquid create mode 100644 fhir_converter/templates/stu3/DataType/_IdToOid.liquid create mode 100644 fhir_converter/templates/stu3/DataType/_IdentifierToCodeableConcept.liquid create mode 100644 fhir_converter/templates/stu3/DataType/_IdentifierToReference.liquid create mode 100644 fhir_converter/templates/stu3/DataType/_Money.liquid create mode 100644 fhir_converter/templates/stu3/DataType/_OidToId.liquid create mode 100644 fhir_converter/templates/stu3/DataType/_ReferenceToCanonical.liquid create mode 100644 fhir_converter/templates/stu3/DataType/_RelatedArtifact.liquid create mode 100644 fhir_converter/templates/stu3/DataType/_ResourceMapping.liquid create mode 100644 fhir_converter/templates/stu3/DataType/_Signature.liquid create mode 100644 fhir_converter/templates/stu3/DataType/_StringToAnnotation.liquid create mode 100644 fhir_converter/templates/stu3/DataType/_TriggerDefinition.liquid create mode 100644 fhir_converter/templates/stu3/DetectedIssue.liquid create mode 100644 fhir_converter/templates/stu3/Device.liquid create mode 100644 fhir_converter/templates/stu3/DeviceMetric.liquid create mode 100644 fhir_converter/templates/stu3/DeviceRequest.liquid create mode 100644 fhir_converter/templates/stu3/DeviceUseStatement.liquid create mode 100644 fhir_converter/templates/stu3/DiagnosticReport.liquid create mode 100644 fhir_converter/templates/stu3/DiagnosticReport/_Performer.liquid create mode 100644 fhir_converter/templates/stu3/DocumentManifest.liquid create mode 100644 fhir_converter/templates/stu3/DocumentReference.liquid create mode 100644 fhir_converter/templates/stu3/DocumentReference/_Context.liquid create mode 100644 fhir_converter/templates/stu3/EligibilityRequest.liquid create mode 100644 fhir_converter/templates/stu3/EligibilityResponse.liquid create mode 100644 fhir_converter/templates/stu3/EligibilityResponse/_EligibilityResponseInsurance.liquid create mode 100644 fhir_converter/templates/stu3/Encounter.liquid create mode 100644 fhir_converter/templates/stu3/Encounter/_Diagnosis.liquid create mode 100644 fhir_converter/templates/stu3/Endpoint.liquid create mode 100644 fhir_converter/templates/stu3/EnrollmentRequest.liquid create mode 100644 fhir_converter/templates/stu3/EnrollmentResponse.liquid create mode 100644 fhir_converter/templates/stu3/EpisodeOfCare.liquid create mode 100644 fhir_converter/templates/stu3/ExplanationOfBenefit.liquid create mode 100644 fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitAddItem.liquid create mode 100644 fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitAddItemDetail.liquid create mode 100644 fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitAddItemDetailSubDetail.liquid create mode 100644 fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitBenefitBalance.liquid create mode 100644 fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitItem.liquid create mode 100644 fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitItemAdjudication.liquid create mode 100644 fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitItemDetail.liquid create mode 100644 fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitItemDetailSubDetail.liquid create mode 100644 fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitPayee.liquid create mode 100644 fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitPayment.liquid create mode 100644 fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitProcessNote.liquid create mode 100644 fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitTotalBenefit.liquid create mode 100644 fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitTotalCost.liquid create mode 100644 fhir_converter/templates/stu3/FamilyMemberHistory.liquid create mode 100644 fhir_converter/templates/stu3/Flag.liquid create mode 100644 fhir_converter/templates/stu3/Goal.liquid create mode 100644 fhir_converter/templates/stu3/GraphDefinition.liquid create mode 100644 fhir_converter/templates/stu3/GraphDefinition/_Compartment.liquid create mode 100644 fhir_converter/templates/stu3/GraphDefinition/_Link.liquid create mode 100644 fhir_converter/templates/stu3/GraphDefinition/_TheTarget.liquid create mode 100644 fhir_converter/templates/stu3/Group.liquid create mode 100644 fhir_converter/templates/stu3/GuidanceResponse.liquid create mode 100644 fhir_converter/templates/stu3/HealthcareService.liquid create mode 100644 fhir_converter/templates/stu3/ImagingStudy.liquid create mode 100644 fhir_converter/templates/stu3/ImagingStudy/_Instance.liquid create mode 100644 fhir_converter/templates/stu3/ImagingStudy/_Performer.liquid create mode 100644 fhir_converter/templates/stu3/ImagingStudy/_Series.liquid create mode 100644 fhir_converter/templates/stu3/Immunization.liquid create mode 100644 fhir_converter/templates/stu3/Immunization/_Practitioner.liquid create mode 100644 fhir_converter/templates/stu3/Immunization/_Protocol.liquid create mode 100644 fhir_converter/templates/stu3/ImmunizationRecommendation.liquid create mode 100644 fhir_converter/templates/stu3/ImmunizationRecommendation/_Recommendation.liquid create mode 100644 fhir_converter/templates/stu3/ImplementationGuide.liquid create mode 100644 fhir_converter/templates/stu3/ImplementationGuide/_Definition.liquid create mode 100644 fhir_converter/templates/stu3/ImplementationGuide/_Global.liquid create mode 100644 fhir_converter/templates/stu3/ImplementationGuide/_Grouping.liquid create mode 100644 fhir_converter/templates/stu3/ImplementationGuide/_Manifest.liquid create mode 100644 fhir_converter/templates/stu3/ImplementationGuide/_Page.liquid create mode 100644 fhir_converter/templates/stu3/ImplementationGuide/_Resource.liquid create mode 100644 fhir_converter/templates/stu3/Library.liquid create mode 100644 fhir_converter/templates/stu3/Linkage.liquid create mode 100644 fhir_converter/templates/stu3/List.liquid create mode 100644 fhir_converter/templates/stu3/Location.liquid create mode 100644 fhir_converter/templates/stu3/Measure.liquid create mode 100644 fhir_converter/templates/stu3/Measure/_Population.liquid create mode 100644 fhir_converter/templates/stu3/Measure/_Stratifier.liquid create mode 100644 fhir_converter/templates/stu3/Measure/_SupplementalData.liquid create mode 100644 fhir_converter/templates/stu3/Measure/_TheGroup.liquid create mode 100644 fhir_converter/templates/stu3/MeasureReport.liquid create mode 100644 fhir_converter/templates/stu3/MeasureReport/_Population.liquid create mode 100644 fhir_converter/templates/stu3/MeasureReport/_Population2.liquid create mode 100644 fhir_converter/templates/stu3/MeasureReport/_Stratifier.liquid create mode 100644 fhir_converter/templates/stu3/MeasureReport/_Stratum.liquid create mode 100644 fhir_converter/templates/stu3/MeasureReport/_TheGroup.liquid create mode 100644 fhir_converter/templates/stu3/MeasureReport/_TranslateTypeCode.liquid create mode 100644 fhir_converter/templates/stu3/Media.liquid create mode 100644 fhir_converter/templates/stu3/Medication.liquid create mode 100644 fhir_converter/templates/stu3/Medication/_Ingredient.liquid create mode 100644 fhir_converter/templates/stu3/MedicationAdministration.liquid create mode 100644 fhir_converter/templates/stu3/MedicationAdministration/_Actor.liquid create mode 100644 fhir_converter/templates/stu3/MedicationDispense.liquid create mode 100644 fhir_converter/templates/stu3/MedicationDispense/_Actor.liquid create mode 100644 fhir_converter/templates/stu3/MedicationRequest.liquid create mode 100644 fhir_converter/templates/stu3/MedicationRequest/_Subst.liquid create mode 100644 fhir_converter/templates/stu3/MedicationStatement.liquid create mode 100644 fhir_converter/templates/stu3/MessageDefinition.liquid create mode 100644 fhir_converter/templates/stu3/MessageDefinition/_AllowedResponse.liquid create mode 100644 fhir_converter/templates/stu3/MessageDefinition/_Focus.liquid create mode 100644 fhir_converter/templates/stu3/MessageDefinition/_TranslateCategoryCode.liquid create mode 100644 fhir_converter/templates/stu3/MessageHeader.liquid create mode 100644 fhir_converter/templates/stu3/NamingSystem.liquid create mode 100644 fhir_converter/templates/stu3/NutritionOrder.liquid create mode 100644 fhir_converter/templates/stu3/Observation.liquid create mode 100644 fhir_converter/templates/stu3/OperationDefinition.liquid create mode 100644 fhir_converter/templates/stu3/OperationDefinition/_Binding.liquid create mode 100644 fhir_converter/templates/stu3/OperationDefinition/_Parameter.liquid create mode 100644 fhir_converter/templates/stu3/OperationOutcome.liquid create mode 100644 fhir_converter/templates/stu3/Organization.liquid create mode 100644 fhir_converter/templates/stu3/Parameters.liquid create mode 100644 fhir_converter/templates/stu3/Parameters/_SubParameter.liquid create mode 100644 fhir_converter/templates/stu3/Patient.liquid create mode 100644 fhir_converter/templates/stu3/Patient/_Animal.liquid create mode 100644 fhir_converter/templates/stu3/PaymentNotice.liquid create mode 100644 fhir_converter/templates/stu3/PaymentReconciliation.liquid create mode 100644 fhir_converter/templates/stu3/PaymentReconciliation/_PaymentReconciliationDetail.liquid create mode 100644 fhir_converter/templates/stu3/PaymentReconciliation/_PaymentReconciliationProcessNote.liquid create mode 100644 fhir_converter/templates/stu3/Person.liquid create mode 100644 fhir_converter/templates/stu3/PlanDefinition.liquid create mode 100644 fhir_converter/templates/stu3/PlanDefinition/_Action.liquid create mode 100644 fhir_converter/templates/stu3/PlanDefinition/_Condition.liquid create mode 100644 fhir_converter/templates/stu3/PlanDefinition/_DynamicValue.liquid create mode 100644 fhir_converter/templates/stu3/PlanDefinition/_Goal.liquid create mode 100644 fhir_converter/templates/stu3/Practitioner.liquid create mode 100644 fhir_converter/templates/stu3/PractitionerRole.liquid create mode 100644 fhir_converter/templates/stu3/Procedure.liquid create mode 100644 fhir_converter/templates/stu3/Procedure/_ProcedurePerformer.liquid create mode 100644 fhir_converter/templates/stu3/Procedure/_TranslateStatusCode.liquid create mode 100644 fhir_converter/templates/stu3/Provenance.liquid create mode 100644 fhir_converter/templates/stu3/Provenance/_Agent.liquid create mode 100644 fhir_converter/templates/stu3/Provenance/_Entity.liquid create mode 100644 fhir_converter/templates/stu3/Questionnaire.liquid create mode 100644 fhir_converter/templates/stu3/Questionnaire/_EnableWhen.liquid create mode 100644 fhir_converter/templates/stu3/Questionnaire/_Initial.liquid create mode 100644 fhir_converter/templates/stu3/Questionnaire/_Item.liquid create mode 100644 fhir_converter/templates/stu3/QuestionnaireResponse.liquid create mode 100644 fhir_converter/templates/stu3/QuestionnaireResponse/_Answer.liquid create mode 100644 fhir_converter/templates/stu3/QuestionnaireResponse/_Item.liquid create mode 100644 fhir_converter/templates/stu3/RelatedPerson.liquid create mode 100644 fhir_converter/templates/stu3/RequestGroup.liquid create mode 100644 fhir_converter/templates/stu3/RequestGroup/_Action.liquid create mode 100644 fhir_converter/templates/stu3/RequestGroup/_Condition.liquid create mode 100644 fhir_converter/templates/stu3/ResearchStudy.liquid create mode 100644 fhir_converter/templates/stu3/ResearchStudy/_Arm.liquid create mode 100644 fhir_converter/templates/stu3/ResearchStudy/_TranslateStatusCode.liquid create mode 100644 fhir_converter/templates/stu3/ResearchSubject.liquid create mode 100644 fhir_converter/templates/stu3/Resource.liquid create mode 100644 fhir_converter/templates/stu3/RiskAssessment.liquid create mode 100644 fhir_converter/templates/stu3/Schedule.liquid create mode 100644 fhir_converter/templates/stu3/SearchParameter.liquid create mode 100644 fhir_converter/templates/stu3/Sequence.liquid create mode 100644 fhir_converter/templates/stu3/Sequence/_Quality.liquid create mode 100644 fhir_converter/templates/stu3/Sequence/_ReferenceSeq.liquid create mode 100644 fhir_converter/templates/stu3/Slot.liquid create mode 100644 fhir_converter/templates/stu3/Specimen.liquid create mode 100644 fhir_converter/templates/stu3/StructureDefinition.liquid create mode 100644 fhir_converter/templates/stu3/StructureMap.liquid create mode 100644 fhir_converter/templates/stu3/StructureMap/_Rule.liquid create mode 100644 fhir_converter/templates/stu3/StructureMap/_TheGroup.liquid create mode 100644 fhir_converter/templates/stu3/StructureMap/_TheSource.liquid create mode 100644 fhir_converter/templates/stu3/Subscription.liquid create mode 100644 fhir_converter/templates/stu3/Substance.liquid create mode 100644 fhir_converter/templates/stu3/SupplyDelivery.liquid create mode 100644 fhir_converter/templates/stu3/SupplyRequest.liquid create mode 100644 fhir_converter/templates/stu3/Task.liquid create mode 100644 fhir_converter/templates/stu3/TestReport.liquid create mode 100644 fhir_converter/templates/stu3/TestScript.liquid create mode 100644 fhir_converter/templates/stu3/TestScript/_Action.liquid create mode 100644 fhir_converter/templates/stu3/TestScript/_Assert.liquid create mode 100644 fhir_converter/templates/stu3/TestScript/_Capability.liquid create mode 100644 fhir_converter/templates/stu3/TestScript/_Metadata.liquid create mode 100644 fhir_converter/templates/stu3/TestScript/_Setup.liquid create mode 100644 fhir_converter/templates/stu3/TestScript/_Test.liquid create mode 100644 fhir_converter/templates/stu3/ValueSet.liquid create mode 100644 fhir_converter/templates/stu3/VisionPrescription.liquid create mode 100644 fhir_converter/templates/stu3/VisionPrescription/_Dispense.liquid create mode 100644 fhir_converter/templates/stu3/metadata.json create mode 100644 mypy.ini create mode 100644 tests/data/stu3/Immunization.json create mode 100644 tests/data/stu3/Person.json diff --git a/README.md b/README.md index b3872cd..2eef0c0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@

- Python FHIR Converter + Python FHIR Converter

Python FHIR converter, fastish, most nuts and bolts included, ready for production @@ -25,6 +25,10 @@ +
+ + +

--- @@ -40,8 +44,9 @@ Key features: Limitations: -* **Only CDA->FHIR** is currently builtin. Additional work is needed to implement the filters, etc to support FHIR->FHIR and HL7v2->FHIR. -* **Python-liquid requires** a comma between parameters. This does not appear to be a restriction with DotLiquid. As a result templates brought to this environment may need commas added. +* **Only CDA->FHIR, STU3->FHIR** are currently builtin. Additional work is needed to implement the filters, etc to support JSON->FHIR, HL7v2->FHIR and FHIR->HL7v2. +* **Comma between parameters**. Python-liquid **requires** a comma between parameters. Templates brought to this environment may need commas added. +* **Variable names when passing variables to a snippet**. Python-liquid **requires** the identifier / variable name. Templates brought to this environment may need changes. See [Resource.liquid](https://github.com/chaseastewart/fhir-converter/blob/main/fhir_converter/templates/stu3/Resource.liquid) as an example of a template that has been updated. Built on the back of: diff --git a/data/sample/stu3/AllergyIntolerance.json b/data/sample/stu3/AllergyIntolerance.json new file mode 100644 index 0000000..49127bf --- /dev/null +++ b/data/sample/stu3/AllergyIntolerance.json @@ -0,0 +1,103 @@ +{ + "resourceType": "AllergyIntolerance", + "id": "example", + "text": { + "status": "generated", + "div": "

Generated Narrative with Details

id: example

identifier: 49476534

clinicalStatus: active

verificationStatus: confirmed

type: allergy

category: food

criticality: high

code: Cashew nuts (Details : {SNOMED CT code '227493005' = 'Cashew nuts', given as 'Cashew nuts'})

patient: Patient/example

onset: 01/01/2004

assertedDate: 09/10/2014 2:58:00 PM

recorder: Practitioner/example

asserter: Patient/example

lastOccurrence: 01/06/2012

note: The criticality is high becasue of the observed anaphylactic reaction when challenged with cashew extract.

reaction

substance: cashew nut allergenic extract Injectable Product (Details : {RxNorm code '1160593' = '1160593', given as 'cashew nut allergenic extract Injectable Product'})

manifestation: Anaphylactic reaction (Details : {SNOMED CT code '39579001' = 'Anaphylaxis', given as 'Anaphylactic reaction'})

description: Challenge Protocol. Severe reaction to subcutaneous cashew extract. Epinephrine administered

onset: 12/06/2012

severity: severe

exposureRoute: Subcutaneous route (Details : {SNOMED CT code '34206005' = 'Subcutaneous route', given as 'Subcutaneous route'})

reaction

manifestation: Urticaria (Details : {SNOMED CT code '64305001' = 'Urticaria', given as 'Urticaria'})

onset: 01/01/2004

severity: moderate

note: The patient reports that the onset of urticaria was within 15 minutes of eating cashews.

" + }, + "identifier": [ + { + "system": "http://acme.com/ids/patients/risks", + "value": "49476534" + } + ], + "clinicalStatus": "active", + "verificationStatus": "confirmed", + "type": "allergy", + "category": [ + "food" + ], + "criticality": "high", + "code": { + "coding": [ + { + "system": "http://snomed.info/sct", + "code": "227493005", + "display": "Cashew nuts" + } + ] + }, + "patient": { + "reference": "Patient/example" + }, + "onsetDateTime": "2004", + "assertedDate": "2014-10-09T11:58:00+08:00", + "recorder": { + "reference": "Practitioner/example" + }, + "asserter": { + "reference": "Patient/example" + }, + "lastOccurrence": "2012-06", + "note": [ + { + "text": "The criticality is high becasue of the observed anaphylactic reaction when challenged with cashew extract." + } + ], + "reaction": [ + { + "substance": { + "coding": [ + { + "system": "http://www.nlm.nih.gov/research/umls/rxnorm", + "code": "1160593", + "display": "cashew nut allergenic extract Injectable Product" + } + ] + }, + "manifestation": [ + { + "coding": [ + { + "system": "http://snomed.info/sct", + "code": "39579001", + "display": "Anaphylactic reaction" + } + ] + } + ], + "description": "Challenge Protocol. Severe reaction to subcutaneous cashew extract. Epinephrine administered", + "onset": "2012-06-12", + "severity": "severe", + "exposureRoute": { + "coding": [ + { + "system": "http://snomed.info/sct", + "code": "34206005", + "display": "Subcutaneous route" + } + ] + } + }, + { + "manifestation": [ + { + "coding": [ + { + "system": "http://snomed.info/sct", + "code": "64305001", + "display": "Urticaria" + } + ] + } + ], + "onset": "2004", + "severity": "moderate", + "note": [ + { + "text": "The patient reports that the onset of urticaria was within 15 minutes of eating cashews." + } + ] + } + ] +} \ No newline at end of file diff --git a/data/sample/stu3/Condition.json b/data/sample/stu3/Condition.json new file mode 100644 index 0000000..adc19c1 --- /dev/null +++ b/data/sample/stu3/Condition.json @@ -0,0 +1,93 @@ +{ + "resourceType": "Condition", + "id": "f201", + "text": { + "status": "generated", + "div": "

Generated Narrative with Details

id: f201

identifier: 12345

clinicalStatus: resolved

verificationStatus: confirmed

category: Problem (Details : {SNOMED CT code '55607006' = 'Problem', given as 'Problem'}; {http://hl7.org/fhir/condition-category code 'problem-list-item' = 'Problem List Item)

severity: Mild (Details : {SNOMED CT code '255604002' = 'Mild', given as 'Mild'})

code: Fever (Details : {SNOMED CT code '386661006' = 'Fever', given as 'Fever'})

bodySite: Entire body as a whole (Details : {SNOMED CT code '38266002' = 'Body as a whole', given as 'Entire body as a whole'})

subject: Roel

context: Encounter/f201

onset: 02/04/2013

abatement: around April 9, 2013

assertedDate: 04/04/2013

asserter: Practitioner/f201

Evidences

-CodeDetail
*degrees C (Details : {SNOMED CT code '258710007' = 'degrees C', given as 'degrees C'})Temperature
" + }, + "identifier": [ + { + "value": "12345" + } + ], + "clinicalStatus": "resolved", + "verificationStatus": "confirmed", + "category": [ + { + "coding": [ + { + "system": "http://snomed.info/sct", + "code": "55607006", + "display": "Problem" + }, + { + "system": "http://hl7.org/fhir/condition-category", + "code": "problem-list-item" + } + ] + } + ], + "severity": { + "coding": [ + { + "system": "http://snomed.info/sct", + "code": "255604002", + "display": "Mild" + } + ] + }, + "code": { + "coding": [ + { + "system": "http://snomed.info/sct", + "code": "386661006", + "display": "Fever" + } + ] + }, + "bodySite": [ + { + "coding": [ + { + "system": "http://snomed.info/sct", + "code": "38266002", + "display": "Entire body as a whole" + } + ] + } + ], + "subject": { + "reference": "Patient/f201", + "display": "Roel" + }, + "context": { + "reference": "Encounter/f201" + }, + "onsetDateTime": "2013-04-02", + "abatementString": "around April 9, 2013", + "assertedDate": "2013-04-04", + "asserter": { + "reference": "Practitioner/f201" + }, + "evidence": [ + { + "code": [ + { + "coding": [ + { + "system": "http://snomed.info/sct", + "code": "258710007", + "display": "degrees C" + } + ] + } + ], + "detail": [ + { + "reference": "Observation/f202", + "display": "Temperature" + } + ] + } + ] +} \ No newline at end of file diff --git a/data/sample/stu3/Encounter.json b/data/sample/stu3/Encounter.json new file mode 100644 index 0000000..3302106 --- /dev/null +++ b/data/sample/stu3/Encounter.json @@ -0,0 +1,88 @@ +{ + "resourceType": "Encounter", + "id": "f202", + "text": { + "status": "generated", + "div": "

Generated Narrative with Details

id: f202

identifier: Encounter_Roel_20130128 (TEMP)

status: finished

class: ambulatory (Details: http://hl7.org/fhir/v3/ActCode code AMB = 'ambulatory', stated as 'ambulatory')

type: Chemotherapy (Details : {SNOMED CT code '367336001' = 'Chemotherapy', given as 'Chemotherapy'})

priority: Urgent (Details : {SNOMED CT code '103391001' = 'Urgency', given as 'Urgent'})

subject: Roel

Participants

-Individual
*Practitioner/f201

length: 56 minutes (Details: UCUM code min = 'min')

reason: The patient is treated for a tumor. (Details )

Diagnoses

-ConditionRoleRank
*Complications from Roel's TPF chemotherapy on January 28th, 2013Admission diagnosis (Details : {http://hl7.org/fhir/diagnosis-role code 'AD' = 'Admission diagnosis', given as 'Admission diagnosis'})1

serviceProvider: Organization/f201

" + }, + "identifier": [ + { + "use": "temp", + "value": "Encounter_Roel_20130128" + } + ], + "status": "finished", + "class": { + "system": "http://hl7.org/fhir/v3/ActCode", + "code": "AMB", + "display": "ambulatory" + }, + "type": [ + { + "coding": [ + { + "system": "http://snomed.info/sct", + "code": "367336001", + "display": "Chemotherapy" + } + ] + } + ], + "priority": { + "coding": [ + { + "system": "http://snomed.info/sct", + "code": "103391001", + "display": "Urgent" + } + ] + }, + "subject": { + "reference": "Patient/f201", + "display": "Roel" + }, + "participant": [ + { + "individual": { + "reference": "Practitioner/f201" + } + } + ], + "length": { + "value": 56, + "unit": "minutes", + "system": "http://unitsofmeasure.org", + "code": "min" + }, + "reason": [ + { + "extension": [ + { + "url": "http://hl7.org/fhir/StructureDefinition/encounter-primaryDiagnosis", + "valuePositiveInt": 2 + } + ], + "text": "The patient is treated for a tumor." + } + ], + "diagnosis": [ + { + "condition": { + "display": "Complications from Roel's TPF chemotherapy on January 28th, 2013" + }, + "role": { + "coding": [ + { + "system": "http://hl7.org/fhir/diagnosis-role", + "code": "AD", + "display": "Admission diagnosis" + } + ] + }, + "rank": 1 + } + ], + "serviceProvider": { + "reference": "Organization/f201" + } +} \ No newline at end of file diff --git a/data/sample/stu3/Immunization.json b/data/sample/stu3/Immunization.json new file mode 100644 index 0000000..5178a62 --- /dev/null +++ b/data/sample/stu3/Immunization.json @@ -0,0 +1,157 @@ +{ + "resourceType": "Immunization", + "id": "example", + "text": { + "status": "generated", + "div": "

Generated Narrative with Details

id: example

identifier: urn:oid:1.3.6.1.4.1.21367.2005.3.7.1234

status: completed

notGiven: false

vaccineCode: Fluvax (Influenza) (Details : {urn:oid:1.2.36.1.2001.1005.17 code 'FLUVAX' = 'Fluvax)

patient: Patient/example

encounter: Encounter/example

date: 10/01/2013

primarySource: true

location: Location/1

manufacturer: Organization/hl7

lotNumber: AAJN11K

expirationDate: 15/02/2015

site: left arm (Details : {http://hl7.org/fhir/v3/ActSite code 'LA' = 'left arm', given as 'left arm'})

route: Injection, intramuscular (Details : {http://hl7.org/fhir/v3/RouteOfAdministration code 'IM' = 'Injection, intramuscular', given as 'Injection, intramuscular'})

doseQuantity: 5 mg (Details: UCUM code mg = 'mg')

practitioner

role: Ordering Provider (Details : {http://hl7.org/fhir/v2/0443 code 'OP' = 'Ordering Provider)

actor: Practitioner/example

practitioner

role: Administering Provider (Details : {http://hl7.org/fhir/v2/0443 code 'AP' = 'Administering Provider)

actor: Practitioner/example

note: Notes on adminstration of vaccine

Explanations

-Reason
*Procedure to meet occupational requirement (Details : {SNOMED CT code '429060002' = 'Procedure to meet occupational requirement)

Reactions

-DateDetailReported
*10/01/2013Observation/exampletrue

VaccinationProtocols

-DoseSequenceDescriptionAuthoritySeriesSeriesDosesTargetDiseaseDoseStatusDoseStatusReason
*1Vaccination Protocol Sequence 1Organization/hl7Vaccination Series 12Gestational rubella syndrome (Details : {SNOMED CT code '1857005' = 'Gestational rubella syndrome)Counts (Details : {http://hl7.org/fhir/vaccination-protocol-dose-status code 'count' = 'Counts', given as 'Counts'})Cold chain break (Details : {http://hl7.org/fhir/vaccination-protocol-dose-status-reason code 'coldchbrk' = 'Cold chain break', given as 'Cold chain break'})
" + }, + "identifier": [ + { + "system": "urn:ietf:rfc:3986", + "value": "urn:oid:1.3.6.1.4.1.21367.2005.3.7.1234" + } + ], + "status": "completed", + "notGiven": false, + "vaccineCode": { + "coding": [ + { + "system": "urn:oid:1.2.36.1.2001.1005.17", + "code": "FLUVAX" + } + ], + "text": "Fluvax (Influenza)" + }, + "patient": { + "reference": "Patient/example" + }, + "encounter": { + "reference": "Encounter/example" + }, + "date": "2017-01-01T00:00:00.000Z", + "primarySource": true, + "location": { + "reference": "Location/1" + }, + "manufacturer": { + "reference": "Organization/hl7" + }, + "lotNumber": "AAJN11K", + "expirationDate": "2015-02-15", + "site": { + "coding": [ + { + "system": "http://hl7.org/fhir/v3/ActSite", + "code": "LA", + "display": "left arm" + } + ] + }, + "route": { + "coding": [ + { + "system": "http://hl7.org/fhir/v3/RouteOfAdministration", + "code": "IM", + "display": "Injection, intramuscular" + } + ] + }, + "doseQuantity": { + "value": 5, + "system": "http://unitsofmeasure.org", + "code": "mg" + }, + "practitioner": [ + { + "role": { + "coding": [ + { + "system": "http://hl7.org/fhir/v2/0443", + "code": "OP" + } + ] + }, + "actor": { + "reference": "Practitioner/example" + } + }, + { + "role": { + "coding": [ + { + "system": "http://hl7.org/fhir/v2/0443", + "code": "AP" + } + ] + }, + "actor": { + "reference": "Practitioner/example" + } + } + ], + "note": [ + { + "text": "Notes on adminstration of vaccine" + } + ], + "explanation": { + "reason": [ + { + "coding": [ + { + "system": "http://snomed.info/sct", + "code": "429060002" + } + ] + } + ] + }, + "reaction": [ + { + "date": "2013-01-10", + "detail": { + "reference": "Observation/example" + }, + "reported": true + } + ], + "vaccinationProtocol": [ + { + "doseSequence": 1, + "description": "Vaccination Protocol Sequence 1", + "authority": { + "reference": "Organization/hl7" + }, + "series": "Vaccination Series 1", + "seriesDoses": 2, + "targetDisease": [ + { + "coding": [ + { + "system": "http://snomed.info/sct", + "code": "1857005" + } + ] + } + ], + "doseStatus": { + "coding": [ + { + "system": "http://hl7.org/fhir/vaccination-protocol-dose-status", + "code": "count", + "display": "Counts" + } + ] + }, + "doseStatusReason": { + "coding": [ + { + "system": "http://hl7.org/fhir/vaccination-protocol-dose-status-reason", + "code": "coldchbrk", + "display": "Cold chain break" + } + ] + } + } + ] +} \ No newline at end of file diff --git a/data/sample/stu3/Medication.json b/data/sample/stu3/Medication.json new file mode 100644 index 0000000..2388bf2 --- /dev/null +++ b/data/sample/stu3/Medication.json @@ -0,0 +1,97 @@ +{ + "resourceType": "Medication", + "id": "med0303", + "text": { + "status": "generated", + "div": "

Generated Narrative with Details

id: med0303

contained:

code: Alemtuzumab 10mg/ml (Lemtrada) (Details : {RxNorm code '1594660' = '1594660', given as 'Alemtuzumab 10mg/ml (Lemtrada)'})

isBrand: true

manufacturer: id: org6; name: Genzyme

form: Injection solution (qualifier vallue) (Details : {SNOMED CT code '385219001' = 'Injection solution', given as 'Injection solution (qualifier vallue)'})

Ingredients

-Item[x]Amount
*Alemtuzamab (substance) (Details : {SNOMED CT code '129472003' = 'Alemtuzumab', given as 'Alemtuzamab (substance)'})12 mg (Details: UCUM code mg = 'mg')/1.2 mL (Details: UCUM code mL = 'mL')

package

container: Vial (Details : {SNOMED CT code '415818006' = 'Vial', given as 'Vial'})

Contents

-Item[x]Amount
*Alemtuzumab 30mg/3mL infusion concentrate (product) (Details : {SNOMED CT code '408596005' = 'Alemtuzumab 30mg/3mL infusion concentrate', given as 'Alemtuzumab 30mg/3mL infusion concentrate (product)'})3 mL (Details: UCUM code mL = 'mL')

Batches

-LotNumberExpirationDate
*949478822/05/2017
" + }, + "contained": [ + { + "resourceType": "Organization", + "id": "org6", + "name": "Genzyme" + } + ], + "code": { + "coding": [ + { + "system": "http://www.nlm.nih.gov/research/umls/rxnorm", + "code": "1594660", + "display": "Alemtuzumab 10mg/ml (Lemtrada)" + } + ] + }, + "isBrand": true, + "manufacturer": { + "reference": "#org6" + }, + "form": { + "coding": [ + { + "system": "http://snomed.info/sct", + "code": "385219001", + "display": "Injection solution (qualifier vallue)" + } + ] + }, + "ingredient": [ + { + "itemCodeableConcept": { + "coding": [ + { + "system": "http://snomed.info/sct", + "code": "129472003", + "display": "Alemtuzamab (substance)" + } + ] + }, + "amount": { + "numerator": { + "value": 12, + "system": "http://unitsofmeasure.org", + "code": "mg" + }, + "denominator": { + "value": 1.2, + "system": "http://unitsofmeasure.org", + "code": "mL" + } + } + } + ], + "package": { + "container": { + "coding": [ + { + "system": "http://snomed.info/sct", + "code": "415818006", + "display": "Vial" + } + ] + }, + "content": [ + { + "itemCodeableConcept": { + "coding": [ + { + "system": "http://snomed.info/sct", + "code": "408596005", + "display": "Alemtuzumab 30mg/3mL infusion concentrate (product)" + } + ] + }, + "amount": { + "value": 3, + "system": "http://unitsofmeasure.org", + "code": "mL" + } + } + ], + "batch": [ + { + "lotNumber": "9494788", + "expirationDate": "2017-05-22" + } + ] + } +} \ No newline at end of file diff --git a/data/sample/stu3/Observation.json b/data/sample/stu3/Observation.json new file mode 100644 index 0000000..2e5c844 --- /dev/null +++ b/data/sample/stu3/Observation.json @@ -0,0 +1,67 @@ +{ + "resourceType": "Observation", + "id": "example-TPMT-haplotype-two", + "text": { + "status": "generated", + "div": "

Generated Narrative with Details

id: example-TPMT-haplotype-two

status: unknown

code: Haplotype Call (Details : {SNOMED CT code '363779003' = '363779003', given as 'Genotype determination'})

subject: E***********

issued: 03/04/2013 3:30:10 PM

value: *4 (Details : {http://pharmakb.org code 'PA166128353' = 'PA166128353', given as '*4'})

Relateds

-TypeTarget
*derived-fromSequence/example-TPMT-two
" + }, + "extension": [ + { + "url": "http://hl7.org/fhir/StructureDefinition/observation-geneticsGene", + "valueCodeableConcept": { + "coding": [ + { + "system": "http://www.genenames.org", + "code": "12014", + "display": "TPMT" + } + ] + } + } + ], + "status": "unknown", + "code": { + "coding": [ + { + "system": "http://snomed.info", + "code": "363779003", + "display": "Genotype determination" + } + ], + "text": "Haplotype Call" + }, + "subject": { + "reference": "Patient/example", + "display": "E***********" + }, + "issued": "2013-04-03T15:30:10+01:00", + "valueCodeableConcept": { + "coding": [ + { + "system": "http://pharmakb.org", + "code": "PA166128353", + "display": "*4" + } + ] + }, + "related": [ + { + "type": "derived-from", + "target": { + "reference": "Sequence/example-TPMT-two" + } + }, + { + "type": "sequel-to", + "target": { + "reference": "Sequence/example-TPMT-two" + } + }, + { + "type": "interfered-by", + "target": { + "reference": "Sequence/example-TPMT-two" + } + } + ] +} \ No newline at end of file diff --git a/data/sample/stu3/Organization.json b/data/sample/stu3/Organization.json new file mode 100644 index 0000000..8a3dacf --- /dev/null +++ b/data/sample/stu3/Organization.json @@ -0,0 +1,71 @@ +{ + "resourceType": "Organization", + "id": "f003", + "text": { + "status": "generated", + "div": "

Generated Narrative with Details

id: f003

active: true

type: Hospital Department (Details : {http://hl7.org/fhir/organization-type code 'dept' = 'Hospital Department', given as 'Hospital Department'})

name: Burgers UMC Ear,Nose,Throat unit

telecom: ph: 022-655 6780

address: West Wing, floor 5

partOf: Organization/f001

Contacts

-PurposeNameTelecomAddress
*Administrative (Details : {http://hl7.org/fhir/contactentity-type code 'ADMIN' = 'Administrative)mr. F. de Hondph: 022-655 7654West Wing, floor 5
" + }, + "active": true, + "type": [ + { + "coding": [ + { + "system": "http://hl7.org/fhir/organization-type", + "code": "dept", + "display": "Hospital Department" + } + ] + } + ], + "name": "Burgers UMC Ear,Nose,Throat unit", + "telecom": [ + { + "system": "phone", + "value": "022-655 6780" + } + ], + "address": [ + { + "line": [ + "West Wing, floor 5" + ] + } + ], + "partOf": { + "reference": "Organization/f001" + }, + "contact": [ + { + "purpose": { + "coding": [ + { + "system": "http://hl7.org/fhir/contactentity-type", + "code": "ADMIN" + } + ] + }, + "name": { + "text": "mr. F. de Hond" + }, + "telecom": [ + { + "system": "phone", + "value": "022-655 7654" + }, + { + "system": "email", + "value": "KNO@burgersumc.nl" + }, + { + "system": "fax", + "value": "022-655 0998" + } + ], + "address": { + "line": [ + "West Wing, floor 5" + ] + } + } + ] +} \ No newline at end of file diff --git a/data/sample/stu3/Patient.json b/data/sample/stu3/Patient.json new file mode 100644 index 0000000..7c502ea --- /dev/null +++ b/data/sample/stu3/Patient.json @@ -0,0 +1,98 @@ +{ + "resourceType": "Patient", + "id": "animal", + "text": { + "status": "generated", + "div": "
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
IdKenzi (Dog: Golden Retriever)
OwnerPeter Chalmers, 534 Erewhon, Pleasantville, Vic, 3999
ContactsWork: (03) 5555 6473
IdDog Tag: 1234123 (Maroondah City Council)
\n \n
" + }, + "identifier": [ + { + "type": { + "text": "Dog Tag" + }, + "system": "http://www.maroondah.vic.gov.au/AnimalRegFees.aspx", + "value": "1234123", + "period": { + "start": "2010-05-31" + }, + "assigner": { + "display": "Maroondah City Council" + } + } + ], + "active": true, + "name": [ + { + "use": "usual", + "given": [ + "Kenzi" + ] + } + ], + "gender": "female", + "birthDate": "2010-03-23", + "contact": [ + { + "relationship": [ + { + "coding": [ + { + "system": "http://hl7.org/fhir/v2/0131", + "code": "C" + } + ] + } + ], + "name": { + "family": "Chalmers", + "given": [ + "Peter", + "James" + ] + }, + "telecom": [ + { + "system": "phone", + "value": "(03) 5555 6473", + "use": "work" + } + ] + } + ], + "animal": { + "species": { + "coding": [ + { + "system": "http://hl7.org/fhir/animal-species", + "code": "canislf", + "display": "Dog" + } + ] + }, + "breed": { + "coding": [ + { + "system": "http://snomed.info/sct", + "code": "58108001", + "display": "Golden retriever" + }, + { + "system": "http://hl7.org/fhir/animal-breed", + "code": "gret", + "display": "Golden Retriever" + } + ] + }, + "genderStatus": { + "coding": [ + { + "system": "http://hl7.org/fhir/animal-genderstatus", + "code": "neutered" + } + ] + } + }, + "managingOrganization": { + "display": "Pete's Vetinary Services" + } +} \ No newline at end of file diff --git a/data/sample/stu3/Person.json b/data/sample/stu3/Person.json new file mode 100644 index 0000000..ccf6e1e --- /dev/null +++ b/data/sample/stu3/Person.json @@ -0,0 +1,88 @@ +{ + "resourceType": "Person", + "id": "example", + "text": { + "status": "generated", + "div": "
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
NamePeter James Chalmers ("Jim")
Address534 Erewhon, Pleasantville, Vic, 3999
ContactsHome: unknown. Work: (03) 5555 6473
IdMRN: 12345 (Acme Healthcare)
\n
" + }, + "identifier": [ + { + "use": "usual", + "type": { + "coding": [ + { + "system": "http://hl7.org/fhir/v2/0203", + "code": "MR" + } + ] + }, + "system": "urn:oid:1.2.36.146.595.217.0.1", + "value": "12345", + "period": { + "start": "2001-05-06" + }, + "assigner": { + "display": "Acme Healthcare" + } + } + ], + "name": [ + { + "use": "official", + "family": "Chalmers", + "given": [ + "Peter", + "James" + ] + }, + { + "use": "usual", + "given": [ + "Jim" + ] + } + ], + "telecom": [ + { + "use": "home" + }, + { + "system": "phone", + "value": "(03) 5555 6473", + "use": "work" + }, + { + "system": "email", + "value": "Jim@example.org", + "use": "home" + } + ], + "gender": "male", + "birthDate": "1974-12-25", + "address": [ + { + "use": "home", + "line": [ + "534 Erewhon St" + ], + "city": "PleasantVille", + "state": "Vic", + "postalCode": "3999" + } + ], + "active": true, + "link": [ + { + "target": { + "reference": "RelatedPerson/peter", + "display": "Peter Chalmers" + } + }, + { + "target": { + "reference": "Patient/example", + "display": "Peter Chalmers" + } + } + ] +} \ No newline at end of file diff --git a/data/sample/stu3/Procedure.json b/data/sample/stu3/Procedure.json new file mode 100644 index 0000000..bf85493 --- /dev/null +++ b/data/sample/stu3/Procedure.json @@ -0,0 +1,71 @@ +{ + "resourceType": "Procedure", + "id": "ambulation", + "text": { + "status": "generated", + "div": "
Ambulation procedure was not done
" + }, + "identifier": [ + { + "value": "12345" + } + ], + "definition": [ + { + "display": "Protocol for hypertension during pregnancy" + } + ], + "basedOn": [ + { + "reference": "CarePlan/preg", + "display": "Maternity care plan" + } + ], + "status": "aborted", + "notDone": false, + "notDoneReason": { + "coding": [ + { + "system": "http://snomed.info/sct", + "code": "398254007", + "display": " Pre-eclampsia (disorder)" + } + ], + "text": "Pre-eclampsia" + }, + "code": { + "coding": [ + { + "system": "http://snomed.info/sct", + "code": "62013009", + "display": "Ambulating patient (procedure)" + } + ], + "text": "Ambulation" + }, + "subject": { + "reference": "Patient/example" + }, + "performer": [ + { + "actor": { + "reference": "Practitioner/f204", + "display": "Carla Espinosa" + }, + "onBehalfOf": { + "reference": "Organization/f001", + "display": "University Medical Hospital" + } + } + ], + "location": { + "reference": "Location/1", + "display": "Burgers University Medical Center, South Wing, second floor" + }, + "reasonReference": [ + { + "reference": "Observation/blood-pressure", + "display": "Blood Pressure" + } + ] +} \ No newline at end of file diff --git a/fhir_converter/filters.py b/fhir_converter/filters.py index 5cc0821..a3b77ea 100644 --- a/fhir_converter/filters.py +++ b/fhir_converter/filters.py @@ -1,13 +1,18 @@ from base64 import b64encode from datetime import datetime, timezone -from functools import wraps +from functools import partial, wraps from hashlib import sha1, sha256 +from re import Match, Pattern +from re import compile as re_compile from re import findall as re_findall -from typing import Any, Callable, Iterable, List, Mapping, Optional, Sequence, Tuple +from typing import Any, Callable, Final, Iterable, List, Mapping, Sequence, Tuple from uuid import UUID from zlib import compress as z_compress +from frozendict import frozendict +from isodate import datetime_isoformat, parse_datetime from liquid import Environment +from liquid.builtin.filters.misc import date as liquid_date from liquid.context import Context from liquid.exceptions import FilterArgumentError from liquid.filter import ( @@ -16,6 +21,7 @@ sequence_filter, string_filter, with_context, + with_environment, ) from pyjson5 import dumps as json_dumps @@ -26,13 +32,55 @@ hl7_to_fhir_dtm, to_fhir_dtm, ) -from fhir_converter.utils import is_none_or_empty, to_list_or_empty +from fhir_converter.utils import is_none_or_empty, tail, to_list_or_empty FilterT = Callable[..., Any] """Callable[..., Any]: A liquid filter function""" +date_format_map: Final[Mapping[str, str]] = frozendict( + { + "yyyy": "%Y", + "MM": "%m", + "dd": "%d", + "HH": "%H", + "mm": "%M", + "ss": "%S", + "%K": "%Z", + "zzz": "%Z", + "zz": "%h", + } +) +"""Mapping[str, str]: C# format mappings""" + +iso_formating_map: Final[Mapping[str, Callable[[datetime], str]]] = frozendict( + { + "ffffff": lambda dt: "%06d" % dt.microsecond, + "fff": lambda dt: "%03d" % (dt.microsecond // 1000), + } +) +"""Mapping[str, Callable[[datetime], str]]: ISO formatting map""" + +format_pattern: Final[Pattern] = re_compile( + "|".join(["y+", "M+", "d+", "H+", "m+", "s+", "%K", "z+"]) +) +"""C# Date Format Regex Pattern""" + +iso_format_pattern: Final[Pattern] = re_compile("f+") +"""ISO format Regex Pattern""" + + +def _repl_format(m: Match) -> str: + return date_format_map.get(m.group(0), m.group(0)) + + +def _repl_iso_format(dt: datetime, m: Match) -> str: + format_f = iso_formating_map.get(m.group(0), None) + if format_f is not None: + return format_f(dt) + return m.group(0) -def str_arg(val: Optional[Any], default: str = "") -> str: + +def str_arg(val: Any, default: str = "") -> str: """Return `val` as an str or `default` if `val` is none or empty""" if is_none_or_empty(val): return default @@ -117,6 +165,35 @@ def now(_: str) -> str: return to_fhir_dtm(datetime.now(timezone.utc)) +@with_environment +@liquid_filter +def date( + input: Any, + format: Any, + *, + environment: Environment, +) -> str: + """Format the given input date with the provided format""" + if is_none_or_empty(input): + return "" + + try: + # attempt to parse the input as an iso8601 string + dt = parse_datetime(input) + + format = str_arg(format) + if not format: + return datetime_isoformat(dt) + format = format_pattern.sub(_repl_format, format) + + return iso_format_pattern.sub( + partial(_repl_iso_format, dt), datetime_isoformat(dt, format) + ) + except Exception: + # attempt to use the default implementation + return liquid_date(input, format, environment=environment) + + @string_filter def generate_uuid(data: str) -> str: """Generate a UUID using the sha256 hash of the given data string""" @@ -233,6 +310,9 @@ def batch_render( for data in batch: with context.extend(namespace={str_arg(arg_name): data}, template=template): template.render_with_context(context, buffer, partial=True) + last_n = tail(buffer).rstrip() + if last_n and not last_n.endswith(","): + buffer.write(",") return buffer.getvalue() @@ -245,6 +325,7 @@ def batch_render( ("add_hyphens_date", add_hyphens_date), ("format_as_date_time", format_as_date_time), ("now", now), + ("date", date), ("generate_uuid", generate_uuid), ("get_property", get_property), ("get_first_ccda_sections_by_template_id", get_first_ccda_sections_by_template_id), @@ -254,13 +335,17 @@ def batch_render( """Sequence[tuple[str, FilterT]]: All of the filters provided by the module""" -def register_filters(env: Environment, filters: Iterable[Tuple[str, FilterT]]) -> None: +def register_filters( + env: Environment, filters: Iterable[Tuple[str, FilterT]], replace: bool = False +) -> None: """register_filters Registers the given filters with the supplied Environment. Will not replace a filter with the same name already registered with the environment. Args: env (Environment): the environment filters (Iterable[tuple[str, FilterT]]): the filters to register + replace (bool, optional): whether to replace existing filters. Defaults to False """ - for name, func in filter(lambda f: f[0] not in env.filters, filters): + it = filters if replace else filter(lambda f: f[0] not in env.filters, filters) + for name, func in it: env.add_filter(name, func) diff --git a/fhir_converter/hl7.py b/fhir_converter/hl7.py index a2daf21..8799ae9 100644 --- a/fhir_converter/hl7.py +++ b/fhir_converter/hl7.py @@ -3,15 +3,19 @@ from datetime import datetime, timedelta, timezone from enum import IntEnum from math import copysign +from re import Pattern from re import compile as re_compile from re import sub as re_sub -from typing import Any, Dict, Mapping, NamedTuple, Optional, Sequence +from typing import Any, Dict, Final, Mapping, NamedTuple, Optional, Sequence from fhir_converter.utils import merge_dict, parse_json, to_list_or_empty -DTM_REGEX = re_compile(r"(\d+(?:\.\d*)?)(?:([+-]\d{2})(\d{2}))?") +dtm_pattern: Final[Pattern] = re_compile(r"(\d+(?:\.\d*)?)(?:([+-]\d{2})(\d{2}))?") """ The HL7 DTM REGEX for parsing date / times """ +zero_time_delta: Final[timedelta] = timedelta(0) +"""Timedelta of zero""" + class FhirDtmPrecision(IntEnum): """FhirDtmPrecision A precision associated with a FHIR DTM""" @@ -111,7 +115,7 @@ def parse_hl7_dtm(hl7_input: str) -> Hl7ParsedDtm: Returns: The parsed ``Hl7ParsedDtm`` """ - dt_match = DTM_REGEX.match(hl7_input.strip()) + dt_match = dtm_pattern.match(hl7_input.strip()) if not dt_match: raise ValueError("Malformed HL7 datetime {0}".format(hl7_input)) @@ -206,8 +210,7 @@ def to_fhir_dtm(dt: datetime, precision: Optional[FhirDtmPrecision] = None) -> s precision = FhirDtmPrecision.SEC iso_dtm = dt.isoformat(timespec=precision.timespec) - off = dt.utcoffset() - if off is not None and int(off.total_seconds()) == 0: + if dt.utcoffset() == zero_time_delta: iso_dtm = iso_dtm[:-6] + "Z" # TODO HOUR, MIN, SEC diff --git a/fhir_converter/renderers.py b/fhir_converter/renderers.py index 51e678e..ef4579f 100644 --- a/fhir_converter/renderers.py +++ b/fhir_converter/renderers.py @@ -1,11 +1,14 @@ from __future__ import annotations +from abc import ABC, abstractmethod from io import StringIO from pathlib import Path from typing import ( IO, Any, + AnyStr, Callable, + Final, Iterable, Mapping, MutableMapping, @@ -31,11 +34,12 @@ del_path_quietly, join_subpath, mkdir, + parse_json, parse_xml, walk_path, ) -DataInput = Union[str, IO] +DataInput = Union[IO, AnyStr] """ Union[str, IO]: The rendering data input types""" DataOutput = TextIO @@ -47,9 +51,16 @@ RenderErrorHandler = Callable[[Exception], None] """Callable[[Exception], None]: Rendering error handling function""" -ccda_default_loader = ResourceLoader(search_package="fhir_converter.templates.ccda") +ccda_default_loader: Final[ResourceLoader] = ResourceLoader( + search_package="fhir_converter.templates.ccda" +) """ResourceLoader: The default loader for the ccda templates""" +stu3_default_loader: Final[ResourceLoader] = ResourceLoader( + search_package="fhir_converter.templates.stu3" +) +"""ResourceLoader: The default loader for the stu3 templates""" + class RenderingError(Exception): """Raised when there is a rendering error""" @@ -60,8 +71,8 @@ def __init__(self, msg: str, cause: Optional[Exception] = None) -> None: self.__cause__ = cause -class CcdaRenderer: - """Consolidated CDA document renderer. Supports rendering the documents to FHIR +class BaseFhirRenderer(ABC): + """Base renderer. Supports rendering data to FHIR Filters: The module provides builtin filters to support the default templates provided @@ -81,93 +92,175 @@ class CcdaRenderer: env (Environment, optional): Optional rendering environment. A rendering environment will be constructed with builtin defaults when env is None. Defaults to None. - template_globals (Mapping, optional): Optional mapping that will be added to - the render context. Code mappings from ValueSet/ValueSet.json will be - loaded from the module when template_globals is None. Defaults to None. + default_loader (BaseLoader): The default loader to use when the environment + is constructed from defaults """ def __init__( self, env: Optional[Environment] = None, - template_globals: Optional[Mapping[str, Any]] = None, ) -> None: if not env: - env = get_environment(loader=ccda_default_loader) - register_filters(env, all_filters) - register_tags(env, all_tags) - + env = get_environment(**self._defaults()) + else: + # register the filters if they haven't already been added + register_filters(env, all_filters) + register_tags(env, all_tags) self.env = env - self.template_globals = self._make_globals(template_globals) - def _make_globals(self, globals: Optional[Mapping[str, Any]]) -> Mapping[str, Any]: - template_globals = dict(globals or {}) - if "code_mapping" not in template_globals: - value_set = json_loads(read_text(self.env, filename="ValueSet/ValueSet.json")) - template_globals["code_mapping"] = frozendict(value_set.get("Mapping", {})) - return frozendict(template_globals) + @staticmethod + @abstractmethod + def _defaults() -> Mapping: + """_defaults The defaults when a rendering environment is not provided + + Returns: + Mapping: The rendering defaults for the renderer + """ + pass def render_fhir_string( - self, template_name: str, xml_in: DataInput, encoding: str = "utf-8" + self, template_name: str, data_in: DataInput, encoding: str = "utf-8" ) -> str: + """render_fhir_string Renders the given data to a FHIR + + Args: + template_name (str): The rendering template + data_in (DataInput): The data input. Either a string or file like object + encoding (str, optional): The encoding to use when parsing the data input. + Defaults to "utf-8". + + Returns: + str: The rendered FHIR as a string + """ with StringIO() as buffer: - self.render_fhir(template_name, xml_in, buffer, encoding) + self.render_fhir(template_name, data_in, buffer, encoding) return buffer.getvalue() def render_fhir( self, template_name: str, - xml_in: DataInput, - fhir_out: DataOutput, + data_in: DataInput, + data_out: DataOutput, encoding: str = "utf-8", ) -> None: - """Renders the XML to FHIR writing the generated output to the supplied file - like object + """render_fhir Renders the given data to FHIR writing the generated output + to the supplied file like object Args: template_name (str): The rendering template - xml_in (DataInput): The XML input. Either a string or file like object - fhir_out (DataOutput): The file like object to write the rendered output - encoding (str, optional): The encoding to use when parsing the XML input. + data_in (DataInput): The data input. Either a string or file like object + data_out (DataOutput): The file like object to write the rendered output + encoding (str, optional): The encoding to use when parsing the data input. Defaults to "utf-8". Raises: - RenderingError: when an error occurs while rendering the input + RenderingError: when an error occurs while rendering the input data """ - fhir = self.render_to_fhir(template_name, xml_in, encoding) + fhir = self.render_to_fhir(template_name, data_in, encoding) try: encode_io( fhir, - fp=fhir_out, # type: ignore + fp=data_out, # type: ignore supply_bytes=False, ) except Exception as e: raise RenderingError("Failed to serialize FHIR", e) def render_to_fhir( - self, template_name: str, xml_input: DataInput, encoding: str = "utf-8" + self, template_name: str, data_in: DataInput, encoding: str = "utf-8" ) -> MutableMapping: - """Renders the XML to FHIR + """render_to_fhir Renders the given data to FHIR Args: template_name (str): The rendering template - xml_in (DataInput): The XML input. Either a string or file like object - encoding (str, optional): The encoding to use when parsing the XML input. + data_in (DataInput): The data input. Either a string or file like object + encoding (str, optional): The encoding to use when parsing the JSON input. Defaults to "utf-8". Returns: - dict: The rendered FHIR bundle + MutableMapping: The rendered FHIR mappings Raises: - RenderingError: when an error occurs while rendering the input + RenderingError: when an error occurs while rendering the input data """ try: - template = self.env.get_template(template_name, globals=self.template_globals) - return parse_fhir( - json_input=template.render({"msg": parse_xml(xml_input, encoding)}), - ) + return self._render_to_fhir_internal(template_name, data_in, encoding) except Exception as e: raise RenderingError("Failed to render FHIR", e) + @abstractmethod + def _render_to_fhir_internal( + self, template_name: str, data_in: DataInput, encoding: str = "utf-8" + ) -> MutableMapping: + """render_to_fhir_internal Renders the given data to FHIR + + Args: + template_name (str): The rendering template + data_in (DataInput): The data input. Either a string or file like object + encoding (str, optional): The encoding to use when parsing the JSON input. + Defaults to "utf-8". + + Returns: + MutableMapping: The rendered FHIR + """ + pass + + +class CcdaRenderer(BaseFhirRenderer): + """Consolidated CDA document renderer""" + + __slots__ = ("env", "template_globals") + + def __init__( + self, + env: Optional[Environment] = None, + template_globals: Optional[Mapping[str, Any]] = None, + ) -> None: + super().__init__(env) + self.template_globals = self._make_globals(template_globals) + + @staticmethod + def _defaults() -> Mapping[str, Any]: + return {"loader": ccda_default_loader} + + def _make_globals(self, globals: Optional[Mapping[str, Any]]) -> Mapping[str, Any]: + template_globals = dict(globals or {}) + if "code_mapping" not in template_globals: + value_set = json_loads(read_text(self.env, filename="ValueSet/ValueSet.json")) + template_globals["code_mapping"] = frozendict(value_set.get("Mapping", {})) + return frozendict(template_globals) + + def _render_to_fhir_internal( + self, template_name: str, data_in: DataInput, encoding: str = "utf-8" + ) -> MutableMapping: + template = self.env.get_template(template_name, globals=self.template_globals) + return parse_fhir( + json_input=template.render({"msg": parse_xml(data_in, encoding)}), + ) + + +class Stu3FhirRenderer(BaseFhirRenderer): + """Stu3 Fhir to Fhir renderer""" + + __slots__ = "env" + + def __init__(self, env: Optional[Environment] = None) -> None: + super().__init__(env) + + @staticmethod + def _defaults() -> Mapping[str, Any]: + return {"loader": stu3_default_loader} + + def _render_to_fhir_internal( + self, template_name: str, data_in: DataInput, encoding: str = "utf-8" + ) -> MutableMapping: + template = self.env.get_template(template_name) + return parse_fhir( + json_input=template.render( + {"msg": parse_json(data_in, encoding, ignore_empty_fields=False)} + ), + ) + def get_environment( loader: BaseLoader, @@ -190,12 +283,12 @@ def get_environment( loaders to use when a template is not found by the loader. Defaults to None Returns: - Environment: the rendering environment + Environment: The rendering environment """ loaders = [loader] if additional_loaders: loaders += additional_loaders - return Environment( + env = Environment( loader=TemplateSystemLoader( loaders, auto_reload=auto_reload, @@ -203,6 +296,9 @@ def get_environment( ), **kwargs, ) + register_filters(env, all_filters, replace=True) + register_tags(env, all_tags) + return env def fail(e: Exception) -> NoReturn: @@ -212,7 +308,7 @@ def fail(e: Exception) -> NoReturn: e (Exception): the exception / failure reason Raises: - Exception: the provided exception + Exception: The provided exception """ raise e @@ -281,7 +377,7 @@ def render_to_dir( onerror (RenderErrorHandler, optional): the error handler. Defaults to fail. Raises: - Exception: when the error handler determines an exception should be raised. By default + Exception: When the error handler determines an exception should be raised. By default all exceptions are raised. See fail """ try: diff --git a/fhir_converter/tags.py b/fhir_converter/tags.py index 43eef3c..ed0c5a3 100644 --- a/fhir_converter/tags.py +++ b/fhir_converter/tags.py @@ -1,9 +1,9 @@ from functools import partial from sys import intern -from typing import Iterable, List, Mapping, Optional, Sequence, TextIO, Tuple, Type +from typing import Any, Iterable, List, Mapping, Optional, Sequence, TextIO, Tuple, Type from liquid import Environment -from liquid.ast import ChildNode, Node +from liquid.ast import BlockNode, ChildNode, Node from liquid.context import Context from liquid.exceptions import LiquidSyntaxError from liquid.expression import Expression @@ -12,9 +12,10 @@ parse_string_or_identifier, parse_unchained_identifier, ) +from liquid.expressions.filtered.lex import tokenize from liquid.expressions.filtered.parse import parse_obj from liquid.lex import _compile_rules, _tokenize, include_expression_rules -from liquid.parse import expect +from liquid.parse import expect, get_parser from liquid.stream import TokenStream from liquid.tag import Tag from liquid.token import ( @@ -28,9 +29,17 @@ TOKEN_IDENTIFIER, TOKEN_NIL, TOKEN_NULL, + TOKEN_TAG, TOKEN_TRUE, Token, ) +from liquid.undefined import is_undefined +from pyjson5 import encode_io +from pyjson5 import loads as json_loads + +TAG_MERGE_DIFF = intern("mergeDiff") +TAG_ENDMERGE_DIFF = intern("endmergeDiff") +ENDMERGE_DIFFBLOCK = frozenset((TAG_ENDMERGE_DIFF, TOKEN_EOF)) TAG_EVALUATE = intern("evaluate") TOKEN_USING = intern("using") @@ -54,6 +63,86 @@ ) +class MergeDiffNode(Node): + """Parse tree node for the "mergeDiff" tag.""" + + __slots__ = ("tok", "identifier", "block") + + def __init__(self, tok: Token, identifier: str, block: BlockNode) -> None: + self.tok = tok + self.identifier = identifier + self.block = block + + def __str__(self) -> str: + return f"mergeDiff {self.identifier} {{ {self.block} }}" + + def __repr__(self) -> str: + return f"MergeDiff(tok={self.tok!r} identifier={self.identifier})" + + @staticmethod + def __merge(a: Any, b: Any) -> Any: + if isinstance(a, dict) and isinstance(b, dict): + for k, v in b.items(): + if isinstance(k, str) and k.endswith("[x]"): + choice_name = k[:-3] + choices = [ak for ak in a.keys() if ak.startswith(choice_name)] + if choices: + a[choices[0]] = v + else: + a[k] = v + return a + + def render_to_output(self, context: Context, buffer: TextIO) -> Optional[bool]: + original = context.resolve(self.identifier) + if not is_undefined(original): + buf = context.get_buffer(buffer) + if self.block.render(context, buf): + val = buf.getvalue() + if val and not val.isspace(): + self.__merge(original, json_loads(val)) + + encode_io( + original, + fp=buffer, # type: ignore + supply_bytes=False, + ) + return True + + def children(self) -> List[ChildNode]: + return self.block.children() + + +class MergeDiffTag(Tag): + """The "mergeDiff" tag.""" + + name = TAG_MERGE_DIFF + end = TAG_ENDMERGE_DIFF + node_class = MergeDiffNode + + def __init__(self, env: Environment) -> None: + super().__init__(env) + self.parser = get_parser(self.env) + + def parse(self, stream: TokenStream) -> Node: + expect(stream, TOKEN_TAG, value=TAG_MERGE_DIFF) + tok = stream.current + stream.next_token() + + expect(stream, TOKEN_EXPRESSION) + identifier = parse_unchained_identifier( + ExprTokenStream(tokenize(stream.current.value)) + ) + stream.next_token() + + block = self.parser.parse_block(stream, ENDMERGE_DIFFBLOCK) + expect(stream, TOKEN_TAG, value=TAG_ENDMERGE_DIFF) + return self.node_class( + tok=tok, + identifier=str(identifier), + block=block, + ) + + class EvaluateNode(Node): """Parse tree node for the built-in "evaluate" tag.""" @@ -125,6 +214,16 @@ class EvaluateTag(Tag): block = False node_class = EvaluateNode + @staticmethod + def __parse_argument(stream: ExprTokenStream) -> Tuple[str, Expression]: + key = str(parse_unchained_identifier(stream)) + stream.next_token() + stream.expect(TOKEN_COLON) + stream.next_token() # Eat colon + val = parse_obj(stream) + stream.next_token() + return key, val + def parse(self, stream: TokenStream) -> Node: """Read an EvaluateNode from the given stream of tokens.""" tok = next(stream) @@ -146,13 +245,13 @@ def parse(self, stream: TokenStream) -> Node: args = {} if expr_stream.current[1] == TOKEN_IDENTIFIER: - key, val = _parse_argument(expr_stream) + key, val = self.__parse_argument(expr_stream) args[key] = val while expr_stream.current[1] != TOKEN_EOF: if expr_stream.current[1] == TOKEN_COMMA: next(expr_stream) # Eat comma - key, val = _parse_argument(expr_stream) + key, val = self.__parse_argument(expr_stream) args[key] = val else: typ = expr_stream.current[1] @@ -164,17 +263,7 @@ def parse(self, stream: TokenStream) -> Node: return self.node_class(tok, name=name, template_name=template_name, args=args) -def _parse_argument(stream: ExprTokenStream) -> Tuple[str, Expression]: - key = str(parse_unchained_identifier(stream)) - stream.next_token() - stream.expect(TOKEN_COLON) - stream.next_token() # Eat colon - val = parse_obj(stream) - stream.next_token() - return key, val - - -all_tags: Sequence[Type[Tag]] = [EvaluateTag] +all_tags: Sequence[Type[Tag]] = [EvaluateTag, MergeDiffTag] """Sequence[type[Tag]]: All of the tags provided by the module""" diff --git a/fhir_converter/templates/stu3/Account.liquid b/fhir_converter/templates/stu3/Account.liquid new file mode 100644 index 0000000..3609a67 --- /dev/null +++ b/fhir_converter/templates/stu3/Account.liquid @@ -0,0 +1,10 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "servicePeriod" : {{msg.period | to_json_string | default : '""'}}, + "subject" : [{{msg.subject | to_json_string | default : '""'}}], + "balance" : "", + "active" : "", + "period" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ActivityDefinition.liquid b/fhir_converter/templates/stu3/ActivityDefinition.liquid new file mode 100644 index 0000000..90d4c05 --- /dev/null +++ b/fhir_converter/templates/stu3/ActivityDefinition.liquid @@ -0,0 +1,40 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "author" :[ + {% for c in msg.contributor %} + {% if c.type == 'author' -%} + {% include 'DataType/ContributorToContactDetail' msg : c -%}, + {% endif %} + {% endfor %} + ], + "editor" :[ + {% for c in msg.contributor %} + {% if c.type == "editor" -%} + {% include 'DataType/ContributorToContactDetail' msg : c -%}, + {% endif %} + {% endfor %} + ], + "reviewer" :[ + {% for c in msg.contributor %} + {% if c.type == "reviewer" -%} + {% include 'DataType/ContributorToContactDetail' msg : c -%}, + {% endif %} + {% endfor %} + ], + "endorser" :[ + {% for c in msg.contributor %} + {% if c.type == "endorser" -%} + {% include 'DataType/ContributorToContactDetail' msg : c -%}, + {% endif %} + {% endfor %} + ], + "kind" : {% include 'ActivityDefinition/TranslateKindCode' msg : msg.kind -%}, + "relatedArtifact" : [ {{ msg.relatedArtifact | to_array | batch_render: 'DataType/RelatedArtifact', 'msg' }} ], + "dosage" : [ {{ msg.dosage | to_array | batch_render: 'DataType/Dosage', 'msg' }} ], + "library" : [ {{ msg.library | to_array | batch_render: 'DataType/ReferenceToCanonical', 'msg' }} ], + "transform" : {% include 'DataType/ReferenceToCanonical' msg: msg.transform -%}, + "dynamicValue" : [ {{ msg.dynamicValue | to_array | batch_render: 'ActivityDefinition/ActivityDefinitionDynamicValue', 'msg' }} ], + "contributor" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ActivityDefinition/_ActivityDefinitionDynamicValue.liquid b/fhir_converter/templates/stu3/ActivityDefinition/_ActivityDefinitionDynamicValue.liquid new file mode 100644 index 0000000..e2af1ae --- /dev/null +++ b/fhir_converter/templates/stu3/ActivityDefinition/_ActivityDefinitionDynamicValue.liquid @@ -0,0 +1,11 @@ +{% mergeDiff msg -%} +{ + "expression" : { + "description" : "{{msg.description}}", + "language" : "{{msg.language}}", + "expression" : "{{msg.expression}}" + }, + "language" : "", + "description" : "" +} +{% endmergeDiff -%} diff --git a/fhir_converter/templates/stu3/ActivityDefinition/_TranslateKindCode.liquid b/fhir_converter/templates/stu3/ActivityDefinition/_TranslateKindCode.liquid new file mode 100644 index 0000000..de8a210 --- /dev/null +++ b/fhir_converter/templates/stu3/ActivityDefinition/_TranslateKindCode.liquid @@ -0,0 +1,8 @@ +{% case msg -%} + {% when "ProcedureRequest" -%} + "ServiceRequest" + {% when "ReferralRequest" -%} + "ServiceRequest" + {% else -%} + "{{msg}}" +{% endcase -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Address.liquid b/fhir_converter/templates/stu3/Address.liquid new file mode 100644 index 0000000..2a94716 --- /dev/null +++ b/fhir_converter/templates/stu3/Address.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/AdverseEvent.liquid b/fhir_converter/templates/stu3/AdverseEvent.liquid new file mode 100644 index 0000000..10e977a --- /dev/null +++ b/fhir_converter/templates/stu3/AdverseEvent.liquid @@ -0,0 +1,26 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "category" : [ + {%if msg.category -%} + { + "coding" : { + "system" : "http://terminology.hl7.org/CodeSystem/adverse-event-category", + "code" : "{{msg.category}}" + } + }, + {% endif -%} + ], + "event" : {{msg.type | to_json_string | default : '""'}}, + {% if msg.type == null -%} + "event" : { + "text" : "{{msg.description}}" + }, + {% endif -%} + "suspectEntity" : [ {{ msg.suspectEntity | to_array | batch_render: 'AdverseEvent/AdverseEventSuspectEntity', 'msg' }} ], + "eventParticipant" : "", + "reaction" : "", + "type" : "", + "description" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/AdverseEvent/_AdverseEventSuspectEntity.liquid b/fhir_converter/templates/stu3/AdverseEvent/_AdverseEventSuspectEntity.liquid new file mode 100644 index 0000000..acc310b --- /dev/null +++ b/fhir_converter/templates/stu3/AdverseEvent/_AdverseEventSuspectEntity.liquid @@ -0,0 +1,9 @@ +{% mergeDiff msg -%} +{ + "causalityResult" : "", + "causalityAuthor" : "", + "causalityMethod" : "", + "causalityProductRelatedness" : "", + "causalityAssessment" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/AllergyIntolerance.liquid b/fhir_converter/templates/stu3/AllergyIntolerance.liquid new file mode 100644 index 0000000..9b5fe35 --- /dev/null +++ b/fhir_converter/templates/stu3/AllergyIntolerance.liquid @@ -0,0 +1,24 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + {%if msg.clinicalStatus -%} + "clinicalStatus" : { + "coding" : { + "system" : "http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical", + "code" : "{{msg.clinicalStatus}}" + } + }, + {% endif -%} + {%if msg.verificationStatus -%} + "verificationStatus" : { + "coding" : { + "system" : "http://terminology.hl7.org/CodeSystem/allergyintolerance-verification", + "code" : "{{msg.verificationStatus}}" + } + }, + {% endif -%} + "recordedDate" : "{{msg.assertedDate | date: "yyyy-MM-ddTHH:mm:ss.fff%K" }}", + "assertedDate" : "" +} +{% endmergeDiff -%} + diff --git a/fhir_converter/templates/stu3/Appointment.liquid b/fhir_converter/templates/stu3/Appointment.liquid new file mode 100644 index 0000000..fb63b72 --- /dev/null +++ b/fhir_converter/templates/stu3/Appointment.liquid @@ -0,0 +1,12 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "serviceCategory" : [{{msg.serviceCategory | to_json_string | default : '""'}}], + "reasonCode" : {{msg.reason | to_json_string | default : '""'}}, + "reasonReference" : {{msg.indication | to_json_string | default : '""'}}, + "basedOn" : {{msg.incomingReferral | to_json_string | default : '""'}}, + "incomingReferral" : "", + "indication" : "", + "reason" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/AppointmentResponse.liquid b/fhir_converter/templates/stu3/AppointmentResponse.liquid new file mode 100644 index 0000000..2a94716 --- /dev/null +++ b/fhir_converter/templates/stu3/AppointmentResponse.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/AuditEvent.liquid b/fhir_converter/templates/stu3/AuditEvent.liquid new file mode 100644 index 0000000..b8b2af0 --- /dev/null +++ b/fhir_converter/templates/stu3/AuditEvent.liquid @@ -0,0 +1,9 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "agent" : [ {{ msg.agent | to_array | batch_render: 'AuditEvent/AuditEventAgent', 'msg' }} ], + "source" : {% include 'AuditEvent/AuditEventSource' msg: msg.source -%}, + "entity" : [ {{ msg.entity | to_array | batch_render: 'AuditEvent/AuditEventEntity', 'msg' }} ] +} +{% endmergeDiff -%} + diff --git a/fhir_converter/templates/stu3/AuditEvent/_AuditEventAgent.liquid b/fhir_converter/templates/stu3/AuditEvent/_AuditEventAgent.liquid new file mode 100644 index 0000000..9c69ec7 --- /dev/null +++ b/fhir_converter/templates/stu3/AuditEvent/_AuditEventAgent.liquid @@ -0,0 +1,8 @@ +{% mergeDiff msg -%} +{ + "who" : {{msg.reference | to_json_string | default : '""'}}, + "who" : {% include 'DataType/IdentifierToReference' msg: msg.userId -%}, + "userId" : "", + "reference" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/AuditEvent/_AuditEventEntity.liquid b/fhir_converter/templates/stu3/AuditEvent/_AuditEventEntity.liquid new file mode 100644 index 0000000..a10edb6 --- /dev/null +++ b/fhir_converter/templates/stu3/AuditEvent/_AuditEventEntity.liquid @@ -0,0 +1,9 @@ +{% mergeDiff msg -%} +{ + "what" : {% include 'DataType/IdentifierToReference' msg: msg.identifier -%}, + "what" : {{msg.reference | to_json_string | default : '""'}}, + "detail" : [ {{ msg.detail | to_array | batch_render: 'AuditEvent/AuditEventEntityDetail', 'msg' }} ], + "reference" : "", + "identifier" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/AuditEvent/_AuditEventEntityDetail.liquid b/fhir_converter/templates/stu3/AuditEvent/_AuditEventEntityDetail.liquid new file mode 100644 index 0000000..cad4324 --- /dev/null +++ b/fhir_converter/templates/stu3/AuditEvent/_AuditEventEntityDetail.liquid @@ -0,0 +1,6 @@ +{% mergeDiff msg -%} +{ + "valueBase64Binary" : "{{msg.value}}", + "value":"" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/AuditEvent/_AuditEventSource.liquid b/fhir_converter/templates/stu3/AuditEvent/_AuditEventSource.liquid new file mode 100644 index 0000000..6f64297 --- /dev/null +++ b/fhir_converter/templates/stu3/AuditEvent/_AuditEventSource.liquid @@ -0,0 +1,6 @@ +{% mergeDiff msg -%} +{ + "observer" : {% include 'DataType/IdentifierToReference' msg: msg.identifier -%}, + "identifier" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Basic.liquid b/fhir_converter/templates/stu3/Basic.liquid new file mode 100644 index 0000000..2a94716 --- /dev/null +++ b/fhir_converter/templates/stu3/Basic.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Binary.liquid b/fhir_converter/templates/stu3/Binary.liquid new file mode 100644 index 0000000..687ff01 --- /dev/null +++ b/fhir_converter/templates/stu3/Binary.liquid @@ -0,0 +1,7 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "data" : "{{msg.content}}", + "content" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/BodySite.liquid b/fhir_converter/templates/stu3/BodySite.liquid new file mode 100644 index 0000000..f55a3ff --- /dev/null +++ b/fhir_converter/templates/stu3/BodySite.liquid @@ -0,0 +1,10 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "resourceType":"BodyStructure", + "location" : {{msg.code | to_json_string | default : '""'}}, + "locationQualifier" : {{msg.qualifier | to_json_string | default : '""'}}, + "qualifier" : "", + "code" : "" +} +{% endmergeDiff -%} diff --git a/fhir_converter/templates/stu3/Bundle.liquid b/fhir_converter/templates/stu3/Bundle.liquid new file mode 100644 index 0000000..896e068 --- /dev/null +++ b/fhir_converter/templates/stu3/Bundle.liquid @@ -0,0 +1,7 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "entry" : [ {{ msg.entry | to_array | batch_render: 'Bundle/Entry', 'msg' }} ], + "signature" : {% include 'DataType/Signature' msg : msg.signature -%} +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Bundle/_Entry.liquid b/fhir_converter/templates/stu3/Bundle/_Entry.liquid new file mode 100644 index 0000000..6354c2d --- /dev/null +++ b/fhir_converter/templates/stu3/Bundle/_Entry.liquid @@ -0,0 +1,6 @@ +{% mergeDiff msg -%} +{ + "resource": {% include 'Resource' msg : msg.resource -%}, + "response": {% include 'Bundle/Response' msg: msg.response -%} +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Bundle/_Response.liquid b/fhir_converter/templates/stu3/Bundle/_Response.liquid new file mode 100644 index 0000000..2cdf682 --- /dev/null +++ b/fhir_converter/templates/stu3/Bundle/_Response.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "outcome": {% include 'Resource' msg : msg.resource -%} +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/CapabilityStatement.liquid b/fhir_converter/templates/stu3/CapabilityStatement.liquid new file mode 100644 index 0000000..3f05f9a --- /dev/null +++ b/fhir_converter/templates/stu3/CapabilityStatement.liquid @@ -0,0 +1,22 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "extension" : [ + {% for e in msg.extension -%} + {{ e | to_json_string | default : '""'}}, + {% endfor -%} + {%if msg.acceptUnknown -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-CapabilityStatement.acceptUnknown", + "valueCode" : "{{msg.acceptUnknown}}" + }, + {% endif -%} + ], + "fhirVersion": "4.0.1", + "profile" : "", + "rest" : [ {{ msg.rest | to_array | batch_render: 'CapabilityStatement/Rest', 'msg' }} ], + "messaging" : [ {{ msg.messaging | to_array | batch_render: 'CapabilityStatement/Messaging', 'msg' }} ], + "document" : [ {{ msg.document | to_array | batch_render: 'CapabilityStatement/Document', 'msg' }} ], + "acceptUnknown" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/CapabilityStatement/_Document.liquid b/fhir_converter/templates/stu3/CapabilityStatement/_Document.liquid new file mode 100644 index 0000000..9caf4f2 --- /dev/null +++ b/fhir_converter/templates/stu3/CapabilityStatement/_Document.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "profile" : {% include 'DataType/ReferenceToCanonical' msg: msg.profile -%} +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/CapabilityStatement/_Messaging.liquid b/fhir_converter/templates/stu3/CapabilityStatement/_Messaging.liquid new file mode 100644 index 0000000..55f7af9 --- /dev/null +++ b/fhir_converter/templates/stu3/CapabilityStatement/_Messaging.liquid @@ -0,0 +1,6 @@ +{% mergeDiff msg -%} +{ + "supportedMessage" : [ {{ msg.supportedMessage | to_array | batch_render: 'CapabilityStatement/SupportedMessage', 'msg' }} ], + "event" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/CapabilityStatement/_Resource.liquid b/fhir_converter/templates/stu3/CapabilityStatement/_Resource.liquid new file mode 100644 index 0000000..9caf4f2 --- /dev/null +++ b/fhir_converter/templates/stu3/CapabilityStatement/_Resource.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "profile" : {% include 'DataType/ReferenceToCanonical' msg: msg.profile -%} +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/CapabilityStatement/_Rest.liquid b/fhir_converter/templates/stu3/CapabilityStatement/_Rest.liquid new file mode 100644 index 0000000..6dedca6 --- /dev/null +++ b/fhir_converter/templates/stu3/CapabilityStatement/_Rest.liquid @@ -0,0 +1,6 @@ +{% mergeDiff msg -%} +{ + "security" : {% include 'CapabilityStatement/Security' msg: msg.security -%}, + "resource" : [ {{ msg.resource | to_array | batch_render: 'CapabilityStatement/Resource', 'msg' }} ] +} +{% endmergeDiff -%} diff --git a/fhir_converter/templates/stu3/CapabilityStatement/_Security.liquid b/fhir_converter/templates/stu3/CapabilityStatement/_Security.liquid new file mode 100644 index 0000000..48be81e --- /dev/null +++ b/fhir_converter/templates/stu3/CapabilityStatement/_Security.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "certificate" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/CapabilityStatement/_SupportedMessage.liquid b/fhir_converter/templates/stu3/CapabilityStatement/_SupportedMessage.liquid new file mode 100644 index 0000000..5817963 --- /dev/null +++ b/fhir_converter/templates/stu3/CapabilityStatement/_SupportedMessage.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "definition" : {% include 'DataType/ReferenceToCanonical' msg: msg.definition -%} +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/CarePlan.liquid b/fhir_converter/templates/stu3/CarePlan.liquid new file mode 100644 index 0000000..8b3ffe3 --- /dev/null +++ b/fhir_converter/templates/stu3/CarePlan.liquid @@ -0,0 +1,11 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "instantiatesCanonical" : {% include 'DataType/ReferenceToCanonical' msg: msg.definition -%}, + "encounter" : {{msg.context | to_json_string | default : '""'}}, + "author" : {{msg.author[0] | to_json_string | default : '""'}}, + "activity" : [ {{ msg.activity | to_array | batch_render: 'CarePlan/Activity', 'msg' }} ], + "context" : "", + "definition" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/CarePlan/_Activity.liquid b/fhir_converter/templates/stu3/CarePlan/_Activity.liquid new file mode 100644 index 0000000..6ef7600 --- /dev/null +++ b/fhir_converter/templates/stu3/CarePlan/_Activity.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "detail" : {% include 'CarePlan/Detail' msg: msg.detail -%} +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/CarePlan/_Detail.liquid b/fhir_converter/templates/stu3/CarePlan/_Detail.liquid new file mode 100644 index 0000000..623d5cc --- /dev/null +++ b/fhir_converter/templates/stu3/CarePlan/_Detail.liquid @@ -0,0 +1,25 @@ +{% mergeDiff msg -%} +{ + "extension" : [ + {% for e in msg.extension -%} + {{ e | to_json_string | default : '""'}}, + {% endfor -%} + {%if msg.category -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-CarePlan.activity.detail.category", + "valueCodeableConcept" : {{msg.category | to_json_string | default : '""' }} + }, + {% endif -%} + ], + "instantiatesCanonical" : [ + {{msg.definition | to_json_string | default : '""'}} + ], + "statusReason" : { + "text" : "{{msg.statusReason}}" + }, + "doNotPerform" : "{{msg.prohibited}}", + "prohibited" : "", + "definition" : "", + "category" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/CareTeam.liquid b/fhir_converter/templates/stu3/CareTeam.liquid new file mode 100644 index 0000000..332a4a2 --- /dev/null +++ b/fhir_converter/templates/stu3/CareTeam.liquid @@ -0,0 +1,8 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "encounter" : {{msg.context | to_json_string | default : '""'}}, + "participant" : [ {{ msg.participant | to_array | batch_render: 'CareTeam/Participant', 'msg' }} ], + "context" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/CareTeam/_Participant.liquid b/fhir_converter/templates/stu3/CareTeam/_Participant.liquid new file mode 100644 index 0000000..d993a58 --- /dev/null +++ b/fhir_converter/templates/stu3/CareTeam/_Participant.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "role" : [{{msg.role | to_json_string | default:'""' }}] +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ChargeItem.liquid b/fhir_converter/templates/stu3/ChargeItem.liquid new file mode 100644 index 0000000..1c203c0 --- /dev/null +++ b/fhir_converter/templates/stu3/ChargeItem.liquid @@ -0,0 +1,11 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "definitionUri" : {{msg.definition | to_json_string | default : '""'}}, + "performer" : [ {{ msg.participant | to_array | batch_render: 'ChargeItem/ChargeItemPerformer', 'msg' }} ], + "priceOverride" : {% include 'DataType/Money' msg: msg.priceOverride -%}, + "participant" : "", + "definition" : "" +} +{% endmergeDiff -%} + diff --git a/fhir_converter/templates/stu3/ChargeItem/_ChargeItemPerformer.liquid b/fhir_converter/templates/stu3/ChargeItem/_ChargeItemPerformer.liquid new file mode 100644 index 0000000..aa9e1b7 --- /dev/null +++ b/fhir_converter/templates/stu3/ChargeItem/_ChargeItemPerformer.liquid @@ -0,0 +1,6 @@ +{% mergeDiff msg -%} +{ + "function" : {{msg.role | to_json_string | default : '""'}}, + "role" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Claim.liquid b/fhir_converter/templates/stu3/Claim.liquid new file mode 100644 index 0000000..a1856ed --- /dev/null +++ b/fhir_converter/templates/stu3/Claim.liquid @@ -0,0 +1,68 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "use" : {% include 'Claim/TranslateUseCode' msg : msg.use -%}, + {% if msg.provider == null -%} + "provider" : {{msg.organization | to_json_string | default : '""'}}, + {% endif -%} + "payee" : + {% mergeDiff msg.payee %} + { + "resourceType" : "" + } + {% endmergeDiff %}, + "supportingInfo" : {{msg.information | to_json_string | default : '""'}}, + "item" : [ + {% for i in msg.item %} + {% mergeDiff i %} + { + "careTeamSequence" : {{i.careTeamLinkId | to_json_string | default : '""'}}, + "diagnosisSequence" : {{i.diagnosisLinkId | to_json_string | default : '""'}}, + "procedureSequence" : {{i.procedureLinkId | to_json_string | default : '""'}}, + "informationSequence" : {{i.informationLinkId | to_json_string | default : '""'}}, + "productOrService" : {{i.service | to_json_string | default : '""'}}, + "diagnosisCodeableConcept" : {{i.locationCodeableConcept | to_json_string | default : '""'}}, + "careTeamLinkId" : "", + "diagnosisLinkId" : "", + "procedureLinkId" : "", + "informationLinkId" : "", + "service": "", + "locationCodeableConcept" : "", + "unitPrice" : {% include 'DataType/Money' msg: i.unitPrice -%}, + "net" : {% include 'DataType/Money' msg: i.net -%}, + "detail" : [ + {% for d in i.detail %} + {% mergeDiff d %} + { + "productOrService" : {{d.service | to_json_string | default : '""'}}, + "unitPrice" : {% include 'DataType/Money' msg: d.unitPrice -%}, + "net" : {% include 'DataType/Money' msg: d.net -%}, + "service": "", + "subDetail" : [ + {% for s in d.subDetail %} + {% mergeDiff s %} + { + "productOrService" : {{s.service | to_json_string | default : '""'}}, + "unitPrice" : {% include 'DataType/Money' msg: s.unitPrice -%}, + "net" : {% include 'DataType/Money' msg: s.net -%}, + "service": "" + } + {% endmergeDiff %}, + {% endfor %} + ] + } + {% endmergeDiff %}, + {% endfor %} + ] + } + {% endmergeDiff %}, + {% endfor %} + ], + "total" : {% include 'DataType/Money' msg: msg.total -%}, + "hospitalization" : "", + "employmentImpacted" : "", + "information" : "", + "organization" : "" +} +{% endmergeDiff -%} + diff --git a/fhir_converter/templates/stu3/Claim/_TranslateUseCode.liquid b/fhir_converter/templates/stu3/Claim/_TranslateUseCode.liquid new file mode 100644 index 0000000..aa04efc --- /dev/null +++ b/fhir_converter/templates/stu3/Claim/_TranslateUseCode.liquid @@ -0,0 +1,8 @@ +{% case msg -%} + {% when "complete" -%} + "claim" + {% when "proposed" -%} + "preauthorization" + {% when "exploratory" -%} + "predetermination" +{% endcase -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ClaimResponse.liquid b/fhir_converter/templates/stu3/ClaimResponse.liquid new file mode 100644 index 0000000..c9796b7 --- /dev/null +++ b/fhir_converter/templates/stu3/ClaimResponse.liquid @@ -0,0 +1,32 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "requestor" : {{msg.requestProvider | to_json_string | default : '""'}}, + {% assign value = msg.outcome.coding[0].code %} + {% if value == 'queued' or value =='complete' or value =='error' or value == 'partial' -%} + "outcome" : "{{value}}", + {% else %} + "outcome" : "", + {% endif -%} + "item" : [ {{ msg.item | to_array | batch_render: 'ClaimResponse/ClaimResponseItem', 'msg' }} ], + "addItem" : [ {{ msg.addItem | to_array | batch_render: 'ClaimResponse/ClaimResponseAddItem', 'msg' }} ], + "error" : [ {{ msg.error | to_array | batch_render: 'ClaimResponse/ClaimResponseError', 'msg' }} ], + "total" : [ + {% include 'ClaimResponse/ClaimResponseTotalCost' msg: msg.totalCost -%}, + {% include 'ClaimResponse/ClaimResponseTotalBenefit' msg: msg.totalBenefit -%} + ], + "payment" : {% include 'ClaimResponse/ClaimResponsePayment' msg: msg.payment -%}, + "fundsReserve" : { + "coding" : {{msg.reserved | to_json_string | default : '""' }} + }, + "form" : {% include 'DataType/CodeableConceptToAttachment' msg: msg.form -%}, + "processNote" : [ {{ msg.processNote | to_array | batch_render: 'ClaimResponse/ClaimResponseProcessNote', 'msg' }} ], + "insurance" : [ {{ msg.insurance | to_array | batch_render: 'ClaimResponse/ClaimResponseInsurance', 'msg' }} ], + "totalBenefit" : "", + "unallocDeductable" : "", + "totalCost" : "", + "requestOrganization" : "", + "requestProvider" : "", + "reserved" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseAddItem.liquid b/fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseAddItem.liquid new file mode 100644 index 0000000..52b5b80 --- /dev/null +++ b/fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseAddItem.liquid @@ -0,0 +1,12 @@ +{% mergeDiff msg -%} +{ + "itemSequence" : "{{msg.sequenceLinkId}}", + "adjudication" : [ {{ msg.adjudication | to_array | batch_render: '_ClaimResponseItemAdjudication', 'msg' }} ], + "detail" : [ {{ msg.detail | to_array | batch_render: 'ClaimResponse/ClaimResponseAddItemDetail', 'msg' }} ], + "fee" : "", + "service" : "", + "category" : "", + "revenue" : "", + "sequenceLinkId" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseAddItemDetail.liquid b/fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseAddItemDetail.liquid new file mode 100644 index 0000000..a86c6e0 --- /dev/null +++ b/fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseAddItemDetail.liquid @@ -0,0 +1,9 @@ +{% mergeDiff msg -%} +{ + "adjudication" : [ {{ msg.adjudication | to_array | batch_render: '_ClaimResponseItemAdjudication', 'msg' }} ], + "fee" : "", + "service" : "", + "category" : "", + "revenue" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseError.liquid b/fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseError.liquid new file mode 100644 index 0000000..7803859 --- /dev/null +++ b/fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseError.liquid @@ -0,0 +1,10 @@ +{% mergeDiff msg -%} +{ + "itemSequence" : "{{msg.sequenceLinkId}}", + "detailSequence" : "{{msg.detailSequenceLinkId}}", + "subDetailSequence" : "{{msg.subdetailSequenceLinkId}}", + "subdetailSequenceLinkId" : "", + "detailSequenceLinkId" : "", + "sequenceLinkId" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseInsurance.liquid b/fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseInsurance.liquid new file mode 100644 index 0000000..34e955d --- /dev/null +++ b/fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseInsurance.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "preAuthRef" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseItem.liquid b/fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseItem.liquid new file mode 100644 index 0000000..e26496a --- /dev/null +++ b/fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseItem.liquid @@ -0,0 +1,8 @@ +{% mergeDiff msg -%} +{ + "itemSequence" : "{{msg.sequenceLinkId}}", + "adjudication" : [ {{ msg.adjudication | to_array | batch_render: 'ClaimResponse/ClaimResponseItemAdjudication', 'msg' }} ], + "detail" : [ {{ msg.detail | to_array | batch_render: 'ClaimResponse/ClaimResponseItemDetail', 'msg' }} ], + "sequenceLinkId" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseItemAdjudication.liquid b/fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseItemAdjudication.liquid new file mode 100644 index 0000000..58ce319 --- /dev/null +++ b/fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseItemAdjudication.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "amount" : {% include 'DataType/Money' msg: msg.amount -%} +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseItemDetail.liquid b/fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseItemDetail.liquid new file mode 100644 index 0000000..26fda85 --- /dev/null +++ b/fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseItemDetail.liquid @@ -0,0 +1,8 @@ +{% mergeDiff msg -%} +{ + "detailSequence" : "{{msg.sequenceLinkId}}", + "adjudication" : [ {{ msg.adjudication | to_array | batch_render: '_ClaimResponseItemAdjudication', 'msg' }} ], + "subDetail" : [ {{ msg.subDetail | to_array | batch_render: 'ClaimResponse/ClaimResponseItemDetailSubDetail', 'msg' }} ], + "sequenceLinkId" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseItemDetailSubDetail.liquid b/fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseItemDetailSubDetail.liquid new file mode 100644 index 0000000..17c4c52 --- /dev/null +++ b/fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseItemDetailSubDetail.liquid @@ -0,0 +1,7 @@ +{% mergeDiff msg -%} +{ + "subDetailSequence" : "{{msg.sequenceLinkId}}", + "adjudication" : [ {{ msg.adjudication | to_array | batch_render: '_ClaimResponseItemAdjudication', 'msg' }} ], + "sequenceLinkId" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ClaimResponse/_ClaimResponsePayment.liquid b/fhir_converter/templates/stu3/ClaimResponse/_ClaimResponsePayment.liquid new file mode 100644 index 0000000..e89086e --- /dev/null +++ b/fhir_converter/templates/stu3/ClaimResponse/_ClaimResponsePayment.liquid @@ -0,0 +1,6 @@ +{% mergeDiff msg -%} +{ + "adjustment" : {% include 'DataType/Money' msg: msg.adjustment -%}, + "amount" : {% include 'DataType/Money' msg: msg.amount -%} +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseProcessNote.liquid b/fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseProcessNote.liquid new file mode 100644 index 0000000..5c111b5 --- /dev/null +++ b/fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseProcessNote.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "type" : {% include 'DataType/CodeableConceptToCode' msg: msg.type -%} +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseTotalBenefit.liquid b/fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseTotalBenefit.liquid new file mode 100644 index 0000000..34e4670 --- /dev/null +++ b/fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseTotalBenefit.liquid @@ -0,0 +1,10 @@ +{ + "category" : { + "text" : "Benefit Amount", + "coding" : { + "code" : "benefit", + "system" : "http://terminology.hl7.org/CodeSystem/adjudication" + } + }, + "amount" : {% include 'DataType/Money' msg: msg -%} +} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseTotalCost.liquid b/fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseTotalCost.liquid new file mode 100644 index 0000000..5a52986 --- /dev/null +++ b/fhir_converter/templates/stu3/ClaimResponse/_ClaimResponseTotalCost.liquid @@ -0,0 +1,11 @@ +{ + "category" : { + "text" : "Submitted Amount", + "coding" : { + "code" : "submitted", + "system" : "http://terminology.hl7.org/CodeSystem/adjudication" + } + }, + "amount" : {% include 'DataType/Money' msg: msg -%} +} + diff --git a/fhir_converter/templates/stu3/ClinicalImpression.liquid b/fhir_converter/templates/stu3/ClinicalImpression.liquid new file mode 100644 index 0000000..ff33363 --- /dev/null +++ b/fhir_converter/templates/stu3/ClinicalImpression.liquid @@ -0,0 +1,20 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "status" : {% include 'ClinicalImpression/TranslateStatusCode' msg : msg.status -%}, + "encounter" : {{msg.context | to_json_string | default : '""'}}, + "context" : "", + "extension":[ + {% for e in msg.extension -%} + {{ e | to_json_string | default : '""'}}, + {% endfor -%} + {% if msg.action -%} + { + "url" : "http://hl7.org/fhir/3.0/StructureDefinition/extension-ClinicalImpression.action", + "valueReference" : {{msg.action | to_json_string | default : '""' }} + } + {% endif -%} + ], + "action" : "" +} +{% endmergeDiff -%} diff --git a/fhir_converter/templates/stu3/ClinicalImpression/_TranslateStatusCode.liquid b/fhir_converter/templates/stu3/ClinicalImpression/_TranslateStatusCode.liquid new file mode 100644 index 0000000..f67a296 --- /dev/null +++ b/fhir_converter/templates/stu3/ClinicalImpression/_TranslateStatusCode.liquid @@ -0,0 +1,8 @@ +{% case msg -%} + {% when "draft" -%} + "in-progress" + {% when "completed" -%} + "completed" + {% when "entered-in-error" -%} + "entered-in-error" +{% endcase -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/CodeSystem.liquid b/fhir_converter/templates/stu3/CodeSystem.liquid new file mode 100644 index 0000000..6ef6ab0 --- /dev/null +++ b/fhir_converter/templates/stu3/CodeSystem.liquid @@ -0,0 +1,8 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "identifier" : [ + {{msg.identifier | to_json_string | default : '""'}} + ] +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Communication.liquid b/fhir_converter/templates/stu3/Communication.liquid new file mode 100644 index 0000000..2065fd0 --- /dev/null +++ b/fhir_converter/templates/stu3/Communication.liquid @@ -0,0 +1,30 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "instantiatesCanonical" : {{msg.definition | to_json_string | default : '""'}}, + {% if msg.notDone -%} + "status" : "not-done", + {% else %} + "status" : "{{msg.status}}", + {% endif -%} + "statusReason" : {{msg.notDoneReason | to_json_string | default : '""'}}, + "extension" : [ + {% for e in msg.extension -%} + {{ e | to_json_string | default : '""'}}, + {% endfor -%} + {% for t in msg.topic -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-Communication.topic", + "valueReference" : {{ t | to_json_string | default : '""' }} + }, + {% endfor -%} + ], + "notDoneReason" : "", + "encounter" : {{msg.context | to_json_string | default : '""'}}, + "notDone" : "", + "definition" : "", + "topic" : "", + "context" : "" +} +{% endmergeDiff -%} + diff --git a/fhir_converter/templates/stu3/CommunicationRequest.liquid b/fhir_converter/templates/stu3/CommunicationRequest.liquid new file mode 100644 index 0000000..d2fc0f1 --- /dev/null +++ b/fhir_converter/templates/stu3/CommunicationRequest.liquid @@ -0,0 +1,21 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "about" : {{msg.topic | to_json_string | default : '""'}}, + "encounter" : {{msg.context | to_json_string | default : '""'}}, + "extension" : [ + {% for e in msg.extension -%} + {{ e | to_json_string | default : '""'}}, + {% endfor -%} + {%if msg.requester.onBehalfOf -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-CommunicationRequest.requester.onBehalfOf", + "valueReference" : {{msg.requester.onBehalfOf | to_json_string | default : '""' }} + }, + {% endif -%} + ], + "requester" : {{msg.requester.agent | to_json_string | default : '""'}}, + "context" : "", + "topic" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/CompartmentDefinition.liquid b/fhir_converter/templates/stu3/CompartmentDefinition.liquid new file mode 100644 index 0000000..5aea19d --- /dev/null +++ b/fhir_converter/templates/stu3/CompartmentDefinition.liquid @@ -0,0 +1,14 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "jurisdiction" : "", + "title" : "", + "resource" : [ + {% for r in mag.resource -%} + {% if r.code != "DeviceComponent" and r.code != "ImagingManifest" and r.code != "ServiceDefinition" -%} + {% include 'CompartmentDefinition/_CompartmentDefinitionResource' msg : r -%}, + {% endif -%} + {% endfor -%} + ] +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/CompartmentDefinition/_CompartmentDefinitionResource.liquid b/fhir_converter/templates/stu3/CompartmentDefinition/_CompartmentDefinitionResource.liquid new file mode 100644 index 0000000..7b412cb --- /dev/null +++ b/fhir_converter/templates/stu3/CompartmentDefinition/_CompartmentDefinitionResource.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "code" : {% include 'DataType/ResourceMapping' msg : msg.code -%} +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Composition.liquid b/fhir_converter/templates/stu3/Composition.liquid new file mode 100644 index 0000000..f544f84 --- /dev/null +++ b/fhir_converter/templates/stu3/Composition.liquid @@ -0,0 +1,10 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "category" : [ + {{msg.class | to_json_string | default : '""'}} + ], + "class" : "", + "attester": [{{msg.attester | to_array | batch_render : 'Composition/Attester', 'msg'}}] +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Composition/_Attester.liquid b/fhir_converter/templates/stu3/Composition/_Attester.liquid new file mode 100644 index 0000000..0b1855e --- /dev/null +++ b/fhir_converter/templates/stu3/Composition/_Attester.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "mode" : "{{msg.mode[0]}}" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ConceptMap.liquid b/fhir_converter/templates/stu3/ConceptMap.liquid new file mode 100644 index 0000000..0d5ebad --- /dev/null +++ b/fhir_converter/templates/stu3/ConceptMap.liquid @@ -0,0 +1,8 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "sourceCanonical" : {% include 'DataType/ReferenceToCanonical' msg: msg.sourceReference -%}, + "targetCanonical" : {% include 'DataType/ReferenceToCanonical' msg: msg.targetReference -%}, + "group" : [ {{ msg.group | to_array | batch_render: 'ConceptMap/TheGroup', 'msg' }} ] +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ConceptMap/_Element.liquid b/fhir_converter/templates/stu3/ConceptMap/_Element.liquid new file mode 100644 index 0000000..026753c --- /dev/null +++ b/fhir_converter/templates/stu3/ConceptMap/_Element.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "target" : [ {{ msg.target | to_array | batch_render: 'ConceptMap/TheTarget', 'msg' }} ] +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ConceptMap/_Qualifier.liquid b/fhir_converter/templates/stu3/ConceptMap/_Qualifier.liquid new file mode 100644 index 0000000..979365d --- /dev/null +++ b/fhir_converter/templates/stu3/ConceptMap/_Qualifier.liquid @@ -0,0 +1,6 @@ +{% mergeDiff msg -%} +{ + "value" : "{{msg.code}}", + "code" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ConceptMap/_TheGroup.liquid b/fhir_converter/templates/stu3/ConceptMap/_TheGroup.liquid new file mode 100644 index 0000000..b45351b --- /dev/null +++ b/fhir_converter/templates/stu3/ConceptMap/_TheGroup.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "element" : [ {{ msg.element | to_array | batch_render: 'ConceptMap/Element', 'msg' }} ] +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ConceptMap/_TheTarget.liquid b/fhir_converter/templates/stu3/ConceptMap/_TheTarget.liquid new file mode 100644 index 0000000..5b70699 --- /dev/null +++ b/fhir_converter/templates/stu3/ConceptMap/_TheTarget.liquid @@ -0,0 +1,6 @@ +{% mergeDiff msg -%} +{ + "dependsOn" : [ {{ msg.dependsOn | to_array | batch_render: 'ConceptMap/Qualifier', 'msg' }} ], + "product" : [ {{ msg.product | to_array | batch_render: 'ConceptMap/Qualifier', 'msg' }} ] +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Condition.liquid b/fhir_converter/templates/stu3/Condition.liquid new file mode 100644 index 0000000..863eac1 --- /dev/null +++ b/fhir_converter/templates/stu3/Condition.liquid @@ -0,0 +1,27 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + {%if msg.clinicalStatus -%} + "clinicalStatus" : { + "coding" : { + "system" : "http://terminology.hl7.org/CodeSystem/condition-clinical", + "code" : "{{msg.clinicalStatus}}" + } + }, + {% endif -%} + {%if msg.verificationStatus -%} + "verificationStatus" : { + "coding" : { + "system" : "http://terminology.hl7.org/CodeSystem/condition-ver-status", + "code" : "{{msg.verificationStatus}}" + } + }, + {% endif -%} + "abatementBoolean" : "", + "stage" : [{{msg.stage | to_json_string | default : '""'}}], + "encounter" : {{msg.context | to_json_string | default : '""'}}, + "recordedDate" : "{{msg.assertedDate | date: "yyyy-MM-dd"}}", + "assertedDate" : "", + "context" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Consent.liquid b/fhir_converter/templates/stu3/Consent.liquid new file mode 100644 index 0000000..46631c7 --- /dev/null +++ b/fhir_converter/templates/stu3/Consent.liquid @@ -0,0 +1,28 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "identifier" : [{{msg.identifier | to_json_string | default : '""'}}], + "performer" : {{msg.consentingParty | to_json_string | default : '""'}}, + {%if msg.policyRule -%} + "policyRule" : { + "coding" : { + "system" : "urn:ietf:rfc:3986", + "code" : "{{msg.policyRule}}" + } + }, + {% endif -%} + {% if msg.securityLabel or msg.period or msg.actor or msg.action or msg.purpose or msg.dataPeriod or msg.data or msg.except -%} + "provision" : {% include 'Consent/Base' msg: msg %}, + {% endif -%} + "sourceIdentifier" : "", + "except" : "", + "data" : "", + "dataPeriod" : "", + "purpose" : "", + "securityLabel" : "", + "action" : "", + "actor" : "", + "consentingParty" : "", + "period" : "" +} +{% endmergeDiff -%} diff --git a/fhir_converter/templates/stu3/Consent/_Base.liquid b/fhir_converter/templates/stu3/Consent/_Base.liquid new file mode 100644 index 0000000..0d0c95b --- /dev/null +++ b/fhir_converter/templates/stu3/Consent/_Base.liquid @@ -0,0 +1,10 @@ +{ + "period" : {{msg.period | to_json_string | default : '""' }}, + "actor" : {{msg.actor | to_json_string | default : '""'}}, + "action" : {{msg.action | to_json_string | default : '""'}}, + "securityLabel" : {{msg.securityLabel | to_json_string | default : '""'}}, + "purpose" : {{msg.purpose | to_json_string | default : '""'}}, + "dataPeriod" : {{msg.dataPeriod | to_json_string | default : '""'}}, + "data" : {{msg.data | to_json_string | default : '""'}}, + "provision" : [ {{ msg.except | to_array | batch_render: 'Consent/Provision', 'msg' }} ] +} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Consent/_Provision.liquid b/fhir_converter/templates/stu3/Consent/_Provision.liquid new file mode 100644 index 0000000..b2f3046 --- /dev/null +++ b/fhir_converter/templates/stu3/Consent/_Provision.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg %} +{ + "code" : {% include 'DataType/CodingToCodeableConcept' msg:msg.code %} +} +{% endmergeDiff %} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Contract.liquid b/fhir_converter/templates/stu3/Contract.liquid new file mode 100644 index 0000000..1ad6f5c --- /dev/null +++ b/fhir_converter/templates/stu3/Contract.liquid @@ -0,0 +1,16 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "identifier" : [{{msg.identifier | to_json_string | default : '""'}}], + "term" : [ {{ msg.term | to_array | batch_render: 'Contract/ContractTerm', 'msg' }} ], + "signer" : [ {{ msg.signer | to_array | batch_render: 'Contract/ContractSigner', 'msg' }} ], + "binding[x]" : "", + "valuedItem" : "", + "agent" : "", + "securityLabel" : "", + "decisionType" : "", + "action" : "", + "actionReason" : "", + "topic" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Contract/_ContractSigner.liquid b/fhir_converter/templates/stu3/Contract/_ContractSigner.liquid new file mode 100644 index 0000000..b50c435 --- /dev/null +++ b/fhir_converter/templates/stu3/Contract/_ContractSigner.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "signature" : [ {{ msg.signature | to_array | batch_render: 'DataType/Signature', 'msg' }} ] +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Contract/_ContractTerm.liquid b/fhir_converter/templates/stu3/Contract/_ContractTerm.liquid new file mode 100644 index 0000000..12380e5 --- /dev/null +++ b/fhir_converter/templates/stu3/Contract/_ContractTerm.liquid @@ -0,0 +1,21 @@ +{% mergeDiff msg -%} +{ + "asset" : [ + { + "valuedItem" : [ {{ msg.valuedItem | to_array | batch_render: 'Contract/ContractTermAssetValuedItem', 'msg' }} ] + } + ], + "securityLable":[ + {% for s in msg.securityLabel -%} + { + "classification" : {{ s | to_json_string | default : '""'}}, + }, + {% endfor -%} + ], + "group" : [ {{ msg.group | to_array | batch_render: 'Contract/ContractTerm', 'msg' }} ], + "actionReason" : "", + "topic" : "", + "action" : "", + "agent" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Contract/_ContractTermAssetValuedItem.liquid b/fhir_converter/templates/stu3/Contract/_ContractTermAssetValuedItem.liquid new file mode 100644 index 0000000..ab49d67 --- /dev/null +++ b/fhir_converter/templates/stu3/Contract/_ContractTermAssetValuedItem.liquid @@ -0,0 +1,6 @@ +{% mergeDiff msg -%} +{ + "unitPrice" : {% include 'DataType/Money' msg: msg.unitPrice -%}, + "net" : {% include 'DataType/Money' msg: msg.net -%} +} +{% endmergeDiff -%} diff --git a/fhir_converter/templates/stu3/Coverage.liquid b/fhir_converter/templates/stu3/Coverage.liquid new file mode 100644 index 0000000..0234828 --- /dev/null +++ b/fhir_converter/templates/stu3/Coverage.liquid @@ -0,0 +1,27 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "class" : [ + {% if msg.grouping.group -%} + {% include 'Coverage/CoverageGroupingGroup' msg: msg.grouping -%}, + {% endif -%} + {% if msg.grouping.subGroup -%} + {% include 'Coverage/CoverageGroupingSubGroup' msg: msg.grouping -%}, + {% endif -%} + {% if msg.grouping.plan -%} + {% include 'Coverage/CoverageGroupingPlan' msg: msg.grouping -%}, + {% endif -%} + {% if msg.grouping.subPlan -%} + {% include 'Coverage/CoverageGroupingSubPlan' msg: msg.grouping -%}, + {% endif -%} + {% if msg.grouping.class -%} + {% include 'Coverage/CoverageGroupingClass' msg: msg.grouping -%}, + {% endif -%} + {% if msg.grouping.subClass -%} + {% include 'Coverage/CoverageGroupingSubClass' msg: msg.grouping -%}, + {% endif -%} + ], + "sequence" : "", + "grouping" : "" +} +{% endmergeDiff -%} diff --git a/fhir_converter/templates/stu3/Coverage/_CoverageGroupingClass.liquid b/fhir_converter/templates/stu3/Coverage/_CoverageGroupingClass.liquid new file mode 100644 index 0000000..6215d80 --- /dev/null +++ b/fhir_converter/templates/stu3/Coverage/_CoverageGroupingClass.liquid @@ -0,0 +1,10 @@ +{ + "type" : { + "coding" : { + "system" : "http://terminology.hl7.org/CodeSystem/coverage-class", + "code" : "class" + } + }, + "value" : "{{msg.class}}", + "name" : "{{msg.classDisplay}}" +} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Coverage/_CoverageGroupingGroup.liquid b/fhir_converter/templates/stu3/Coverage/_CoverageGroupingGroup.liquid new file mode 100644 index 0000000..5053060 --- /dev/null +++ b/fhir_converter/templates/stu3/Coverage/_CoverageGroupingGroup.liquid @@ -0,0 +1,10 @@ +{ + "type" : { + "coding" : { + "system" : "http://terminology.hl7.org/CodeSystem/coverage-class", + "code" : "group" + } + }, + "value" : "{{msg.group}}", + "name" : "{{msg.groupDisplay}}" +} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Coverage/_CoverageGroupingPlan.liquid b/fhir_converter/templates/stu3/Coverage/_CoverageGroupingPlan.liquid new file mode 100644 index 0000000..24828bf --- /dev/null +++ b/fhir_converter/templates/stu3/Coverage/_CoverageGroupingPlan.liquid @@ -0,0 +1,10 @@ +{ + "type" : { + "coding" : { + "system" : "http://terminology.hl7.org/CodeSystem/coverage-class", + "code" : "plan" + } + }, + "value" : "{{msg.plan}}", + "name" : "{{msg.planDisplay}}" +} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Coverage/_CoverageGroupingSubClass.liquid b/fhir_converter/templates/stu3/Coverage/_CoverageGroupingSubClass.liquid new file mode 100644 index 0000000..db3958e --- /dev/null +++ b/fhir_converter/templates/stu3/Coverage/_CoverageGroupingSubClass.liquid @@ -0,0 +1,10 @@ +{ + "type" : { + "coding" : { + "system" : "http://terminology.hl7.org/CodeSystem/coverage-class", + "code" : "subclass" + } + }, + "value" : "{{msg.subClass}}", + "name" : "{{msg.subClassDisplay}}" +} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Coverage/_CoverageGroupingSubGroup.liquid b/fhir_converter/templates/stu3/Coverage/_CoverageGroupingSubGroup.liquid new file mode 100644 index 0000000..25f4620 --- /dev/null +++ b/fhir_converter/templates/stu3/Coverage/_CoverageGroupingSubGroup.liquid @@ -0,0 +1,10 @@ +{ + "type" : { + "coding" : { + "system" : "http://terminology.hl7.org/CodeSystem/coverage-class", + "code" : "subgroup" + } + }, + "value" : "{{msg.subGroup}}", + "name" : "{{msg.subGroupDisplay}}" +} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Coverage/_CoverageGroupingSubPlan.liquid b/fhir_converter/templates/stu3/Coverage/_CoverageGroupingSubPlan.liquid new file mode 100644 index 0000000..5c6ffc7 --- /dev/null +++ b/fhir_converter/templates/stu3/Coverage/_CoverageGroupingSubPlan.liquid @@ -0,0 +1,11 @@ +{ + "type" : { + "coding" : + { + "system" : "http://terminology.hl7.org/CodeSystem/coverage-class", + "code" : "subplan" + } + }, + "value" : "{{msg.subPlan}}", + "name" : "{{msg.subPlanDisplay}}", +} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/DataType/DataRequirement/_CodeFilter.liquid b/fhir_converter/templates/stu3/DataType/DataRequirement/_CodeFilter.liquid new file mode 100644 index 0000000..7aa1b47 --- /dev/null +++ b/fhir_converter/templates/stu3/DataType/DataRequirement/_CodeFilter.liquid @@ -0,0 +1,19 @@ +{% mergeDiff msg -%} +{ + "valueSet[x]" : "", + "valueSet" : "{{msg.valueSetReference.reference}}", + "code" : [ + { + "code" : "{{msg.valueCode}}" + }, + {{msg.valueCoding | to_json_string | default : '""'}}, + {% for c in msg.valueCodeableConcept.coding -%} + {{c | to_json_string | default : '""'}}, + {% endfor -%} + ], + "code" : {{msg.valueCoding | to_json_string | default : '""'}}, + "valueCoding" : "", + "valueCode" : "", + "valueCodeableConcept" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/DataType/_CodeableConceptToAttachment.liquid b/fhir_converter/templates/stu3/DataType/_CodeableConceptToAttachment.liquid new file mode 100644 index 0000000..dc00d0d --- /dev/null +++ b/fhir_converter/templates/stu3/DataType/_CodeableConceptToAttachment.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg %} +{ + +} +{% endmergeDiff %} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/DataType/_CodeableConceptToCode.liquid b/fhir_converter/templates/stu3/DataType/_CodeableConceptToCode.liquid new file mode 100644 index 0000000..3c4ee58 --- /dev/null +++ b/fhir_converter/templates/stu3/DataType/_CodeableConceptToCode.liquid @@ -0,0 +1,2 @@ +{% assign coding = msg.coding | first -%} +"{{coding.code}}" \ No newline at end of file diff --git a/fhir_converter/templates/stu3/DataType/_CodingToCodeableConcept.liquid b/fhir_converter/templates/stu3/DataType/_CodingToCodeableConcept.liquid new file mode 100644 index 0000000..a005bad --- /dev/null +++ b/fhir_converter/templates/stu3/DataType/_CodingToCodeableConcept.liquid @@ -0,0 +1,5 @@ +[ + { + "coding" : {{msg | to_json_string | default : '""'}} + } +] \ No newline at end of file diff --git a/fhir_converter/templates/stu3/DataType/_ContributorToContactDetail.liquid b/fhir_converter/templates/stu3/DataType/_ContributorToContactDetail.liquid new file mode 100644 index 0000000..c5dc297 --- /dev/null +++ b/fhir_converter/templates/stu3/DataType/_ContributorToContactDetail.liquid @@ -0,0 +1,3 @@ +{% for c in msg.contact -%} + {{ c |to_json_string | default : '""'}}, +{% endfor -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/DataType/_DataRequirement.liquid b/fhir_converter/templates/stu3/DataType/_DataRequirement.liquid new file mode 100644 index 0000000..7bb6751 --- /dev/null +++ b/fhir_converter/templates/stu3/DataType/_DataRequirement.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "codeFilter" : [ {{ msg.codeFilter | to_array | batch_render: 'DataType/DataRequirement/CodeFilter', 'msg' }} ] +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/DataType/_DecimalToQuantity.liquid b/fhir_converter/templates/stu3/DataType/_DecimalToQuantity.liquid new file mode 100644 index 0000000..1bd175b --- /dev/null +++ b/fhir_converter/templates/stu3/DataType/_DecimalToQuantity.liquid @@ -0,0 +1,5 @@ +{ + {% if msg -%} + "value" : {{msg}} + {% endif -%} +} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/DataType/_Dosage.liquid b/fhir_converter/templates/stu3/DataType/_Dosage.liquid new file mode 100644 index 0000000..80680ea --- /dev/null +++ b/fhir_converter/templates/stu3/DataType/_Dosage.liquid @@ -0,0 +1,18 @@ +{% mergeDiff msg -%} +{ + "doseAndRate" : [ + { + "doseRange":{{msg.doseRange | to_json_string | default : '""'}}, + "doseQuantity":{{msg.doseQuantity | to_json_string | default : '""'}}, + "rateRatio":{{msg.rateRatio | to_json_string | default : '""'}}, + "rateRange":{{msg.rateRange | to_json_string | default : '""'}}, + "rateQuantity":{{msg.rateQuantity | to_json_string | default : '""'}}, + } + ], + "doseRange" : "", + "doseQuantity" : "", + "rateRatio" : "", + "rateRange" : "", + "rateQuantity" : "" +} +{% endmergeDiff -%} diff --git a/fhir_converter/templates/stu3/DataType/_Extension.liquid b/fhir_converter/templates/stu3/DataType/_Extension.liquid new file mode 100644 index 0000000..4632b3c --- /dev/null +++ b/fhir_converter/templates/stu3/DataType/_Extension.liquid @@ -0,0 +1,10 @@ +{% mergeDiff msg -%} +{ + "valueMoney" : {% include 'DataType/Money' msg : msg.valueMoney -%}, + "valueSignature" : {% include 'DataType/Money' msg : msg.valueSignature -%}, + "valueDataRequirement" : {% include 'DataType/DataRequirement' msg : msg.valueDataRequirement -%}, + "valueDosage" : {% include 'DataType/Dosage' msg : msg.valueDosage -%}, + "valueRelatedArtifact" : {% include 'DataType/RelatedArtifact' msg : msg.valueRelatedArtifact -%}, + "valueTriggerDefinition" : {% include 'DataType/TriggerDefinition' msg : msg.valueTriggerDefinition -%} +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/DataType/_IdToOid.liquid b/fhir_converter/templates/stu3/DataType/_IdToOid.liquid new file mode 100644 index 0000000..a062e2f --- /dev/null +++ b/fhir_converter/templates/stu3/DataType/_IdToOid.liquid @@ -0,0 +1 @@ +"{{'urn:oid:' | appand : msg}}" \ No newline at end of file diff --git a/fhir_converter/templates/stu3/DataType/_IdentifierToCodeableConcept.liquid b/fhir_converter/templates/stu3/DataType/_IdentifierToCodeableConcept.liquid new file mode 100644 index 0000000..9cf35f4 --- /dev/null +++ b/fhir_converter/templates/stu3/DataType/_IdentifierToCodeableConcept.liquid @@ -0,0 +1,4 @@ +{ + "coding" : [{{msg.type | to_json_string | default : '""'}}], + "text" : "{{msg.value}}" +} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/DataType/_IdentifierToReference.liquid b/fhir_converter/templates/stu3/DataType/_IdentifierToReference.liquid new file mode 100644 index 0000000..775b173 --- /dev/null +++ b/fhir_converter/templates/stu3/DataType/_IdentifierToReference.liquid @@ -0,0 +1,3 @@ +{ + "identifier":{{msg | to_json_string | default : '""'}}, +} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/DataType/_Money.liquid b/fhir_converter/templates/stu3/DataType/_Money.liquid new file mode 100644 index 0000000..cecd62d --- /dev/null +++ b/fhir_converter/templates/stu3/DataType/_Money.liquid @@ -0,0 +1,4 @@ +{ + "value": "{{msg.value}}", + "currency" : "{{msg.code}}", +} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/DataType/_OidToId.liquid b/fhir_converter/templates/stu3/DataType/_OidToId.liquid new file mode 100644 index 0000000..b3c1d59 --- /dev/null +++ b/fhir_converter/templates/stu3/DataType/_OidToId.liquid @@ -0,0 +1 @@ +"{{msg | remove : 'urn:oid:'}}" \ No newline at end of file diff --git a/fhir_converter/templates/stu3/DataType/_ReferenceToCanonical.liquid b/fhir_converter/templates/stu3/DataType/_ReferenceToCanonical.liquid new file mode 100644 index 0000000..79b724d --- /dev/null +++ b/fhir_converter/templates/stu3/DataType/_ReferenceToCanonical.liquid @@ -0,0 +1 @@ +"{{msg.reference}}" \ No newline at end of file diff --git a/fhir_converter/templates/stu3/DataType/_RelatedArtifact.liquid b/fhir_converter/templates/stu3/DataType/_RelatedArtifact.liquid new file mode 100644 index 0000000..377f70b --- /dev/null +++ b/fhir_converter/templates/stu3/DataType/_RelatedArtifact.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "resource" : {% include 'DataType/ReferenceToCanonical' msg: msg.resource -%} +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/DataType/_ResourceMapping.liquid b/fhir_converter/templates/stu3/DataType/_ResourceMapping.liquid new file mode 100644 index 0000000..76cc6a8 --- /dev/null +++ b/fhir_converter/templates/stu3/DataType/_ResourceMapping.liquid @@ -0,0 +1,24 @@ +{% case msg -%} + {% when "BodySite" %} + "BodyStructure" + {% when "DataElement" %} + "StructureDefinition" + {% when "EligibilityRequest" %} + "CoverageEligibilityRequest" + {% when "EligibilityResponse" %} + "CoverageEligibilityResponse" + {% when "ExpansionProfile" %} + "Parameters" + {% when "Sequence" %} + "MolecularSequence" + {% when "ProcessRequest" %} + "Task" + {% when "ProcessResponse" %} + "Task" + {% when "ReferralRequest" %} + "ServiceRequest" + {% when "ProcedureRequest" %} + "ServiceRequest" + {% else -%} + "{{msg}}" +{% endcase -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/DataType/_Signature.liquid b/fhir_converter/templates/stu3/DataType/_Signature.liquid new file mode 100644 index 0000000..15e29cb --- /dev/null +++ b/fhir_converter/templates/stu3/DataType/_Signature.liquid @@ -0,0 +1,33 @@ +{% mergeDiff msg -%} +{ + "onBehalfOf[x]" : "", + "who[x]" : "", + {%if msg.whoUri -%} + "who" : { + "reference" : "{{msg.whoUri}}", + "extension" : { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/BaseType", + "valueString" : "uri" + } + }, + {% else if msg.whoReference -%} + "who" : {{msg.whoReference | to_json_string | default : '""'}}, + {% endif -%} + {%if msg.onBehalfOfUri -%} + "onBehalfOf" : { + "reference" : "{{msg.onBehalfOfUri}}", + "extension" : { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/BaseType", + "valueString" : "uri" + } + }, + {% else if msg.onBehalfOfReference -%} + "onBehalfOf" : {{msg.onBehalfOfReference | to_json_string | default : '""'}}, + {% endif -%} + "sigFormat" : "{{msg.contentType}}", + "data" : "{{msg.blob}}", + "blob" : "", + "contentType" : "", +} +{% endmergeDiff -%} + diff --git a/fhir_converter/templates/stu3/DataType/_StringToAnnotation.liquid b/fhir_converter/templates/stu3/DataType/_StringToAnnotation.liquid new file mode 100644 index 0000000..f894e9d --- /dev/null +++ b/fhir_converter/templates/stu3/DataType/_StringToAnnotation.liquid @@ -0,0 +1,3 @@ +{ + "text":"{{msg}}" +} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/DataType/_TriggerDefinition.liquid b/fhir_converter/templates/stu3/DataType/_TriggerDefinition.liquid new file mode 100644 index 0000000..4648347 --- /dev/null +++ b/fhir_converter/templates/stu3/DataType/_TriggerDefinition.liquid @@ -0,0 +1,15 @@ +{% mergeDiff msg -%} +{ + "name" : "{{msg.eventName}}", + "timingTiming" : {{msg.eventTimingTiming | to_json_string | default : '""'}}, + "timingReference" : {{msg.eventTimingReference | to_json_string | default : '""'}}, + "timingDate" : "{{msg.eventTimingDate}}", + "timingDateTime" : "{{msg.eventTimingDateTime}}", + "data" : [ + {% include 'DataType/DataRequirement' msg: msg.eventData -%} + ], + "eventData" : "", + "eventTiming[x]" : "", + "eventName" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/DetectedIssue.liquid b/fhir_converter/templates/stu3/DetectedIssue.liquid new file mode 100644 index 0000000..e1ce66a --- /dev/null +++ b/fhir_converter/templates/stu3/DetectedIssue.liquid @@ -0,0 +1,9 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "code" : {{msg.category | to_json_string | default : '""'}}, + "identifiedDateTime" : "{{ msg.date | date: "yyyy-MM-ddTHH:mm:ss.fff%K" }}", + "date" : "", + "category" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Device.liquid b/fhir_converter/templates/stu3/Device.liquid new file mode 100644 index 0000000..6494053 --- /dev/null +++ b/fhir_converter/templates/stu3/Device.liquid @@ -0,0 +1,31 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "udiCarrier" : [ + { + "deviceIdentifier" : "{{msg.udi.deviceIdentifier}}", + "jurisdiction" : "{{msg.udi.jurisdiction}}", + "carrierHRF" : "{{msg.udi.carrierHRF}}", + "carrierAIDC" : "{{msg.udi.carrierAIDC}}", + "issuer" : "{{msg.udi.issuer}}", + "entryType" : "{{msg.udi.entryType}}" + } + ], + "deviceName" : [ + {%if msg.udi.name -%} + { + "name" : "{{msg.udi.name}}", + "type" : "udi-label-name" + }, + {% endif -%} + ], + "modelNumber" : "{{msg.model}}", + "version" : [ + { + "value" : "{{msg.version}}" + } + ], + "model" : "", + "udi" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/DeviceMetric.liquid b/fhir_converter/templates/stu3/DeviceMetric.liquid new file mode 100644 index 0000000..2a94716 --- /dev/null +++ b/fhir_converter/templates/stu3/DeviceMetric.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/DeviceRequest.liquid b/fhir_converter/templates/stu3/DeviceRequest.liquid new file mode 100644 index 0000000..7c38895 --- /dev/null +++ b/fhir_converter/templates/stu3/DeviceRequest.liquid @@ -0,0 +1,10 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "intent" : {{msg.intent.coding[0].code | to_json_string | default : '""'}}, + "encounter" : {{msg.context | to_json_string | default : '""'}}, + "requester" : {{msg.requester.agent | to_json_string | default : '""'}}, + "context" : "", + "definition" : "" +} +{% endmergeDiff -%} diff --git a/fhir_converter/templates/stu3/DeviceUseStatement.liquid b/fhir_converter/templates/stu3/DeviceUseStatement.liquid new file mode 100644 index 0000000..b828330 --- /dev/null +++ b/fhir_converter/templates/stu3/DeviceUseStatement.liquid @@ -0,0 +1,19 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "extension" : [ + {% for e in msg.extension -%} + {{ e | to_json_string | default : '""'}}, + {% endfor -%} + {%if msg.whenUsed -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-DeviceUseStatement.whenUsed", + "valuePeriod" : {{msg.whenUsed | to_json_string | default : '""' }} + }, + {% endif -%} + ], + "reasonCode" : {{msg.indication | to_json_string | default : '""'}}, + "indication" : "", + "whenUsed" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/DiagnosticReport.liquid b/fhir_converter/templates/stu3/DiagnosticReport.liquid new file mode 100644 index 0000000..78830b9 --- /dev/null +++ b/fhir_converter/templates/stu3/DiagnosticReport.liquid @@ -0,0 +1,13 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "category" : [{{msg.category | to_json_string | default : '""'}}], + "encounter" : {{msg.context | to_json_string | default : '""'}}, + "performer" : [ {{ msg.performer | to_array | batch_render: 'DiagnosticReport/Performer', 'msg' }} ], + "media" : {{msg.image | to_json_string | default : '""' }}, + "conclusionCode" : {{msg.codedDiagnosis | to_json_string | default : '""'}}, + "codedDiagnosis" : "", + "image" : "", + "context" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/DiagnosticReport/_Performer.liquid b/fhir_converter/templates/stu3/DiagnosticReport/_Performer.liquid new file mode 100644 index 0000000..60882ba --- /dev/null +++ b/fhir_converter/templates/stu3/DiagnosticReport/_Performer.liquid @@ -0,0 +1,20 @@ +{% mergeDiff msg -%} +{ + "extension" : [ + {% for e in msg.extension -%} + {{ e | to_json_string | default : '""'}}, + {% endfor -%} + {%if msg.role -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-DiagnosticReport.performer.role", + "valueCodeableConcept" : {{msg.role | to_json_string | default : '""' }} + }, + {% endif -%} + ], + "actor" : "", + "role" : "", + "reference" : "{{msg.actor.reference}}", + "identifier" : {{msg.actor.identifier | to_json_string | default:'""'}}, + "display" : "{{msg.actor.display}}" +} +{% endmergeDiff -%} diff --git a/fhir_converter/templates/stu3/DocumentManifest.liquid b/fhir_converter/templates/stu3/DocumentManifest.liquid new file mode 100644 index 0000000..3581255 --- /dev/null +++ b/fhir_converter/templates/stu3/DocumentManifest.liquid @@ -0,0 +1,12 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "content" : [ + {% for c in msg.content %} + {% if c.pReference %} + {{c.pReference | to_json_string | default : '""'}}, + {% endif %} + {% endfor %} + ] +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/DocumentReference.liquid b/fhir_converter/templates/stu3/DocumentReference.liquid new file mode 100644 index 0000000..6c5136b --- /dev/null +++ b/fhir_converter/templates/stu3/DocumentReference.liquid @@ -0,0 +1,25 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "category" : [ + {{msg.class | to_json_string | default : '""'}} + ], + "date" : "{{msg.indexed | date: "yyyy-MM-ddTHH:mm:ss.fff%K" }}", + "created" : "", + "extension" : [ + {% for e in msg.extension -%} + {{ e | to_json_string | default : '""'}}, + {% endfor -%} + {%if msg.created -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-DocumentReference.created", + "valuedateTime" : "{{msg.created | date: "yyyy-MM-ddTHH:mm:ss.fff%K" }}" + }, + {% endif -%} + ], + "indexed" : "", + "class" : "", + "context" : {% include 'DocumentReference/Context' msg: msg.context -%} +} +{% endmergeDiff -%} + diff --git a/fhir_converter/templates/stu3/DocumentReference/_Context.liquid b/fhir_converter/templates/stu3/DocumentReference/_Context.liquid new file mode 100644 index 0000000..4892c7d --- /dev/null +++ b/fhir_converter/templates/stu3/DocumentReference/_Context.liquid @@ -0,0 +1,12 @@ +{% mergeDiff msg -%} +{ + "encounter" : [{{msg.encounter | to_json_string | default : '""'}}], + "related" : [ + {% for r in msg.related %} + {% if r.ref %} + {{ r.ref | to_json_string | default : '""' }} + {% endif %} + {% endfor %} + ] +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/EligibilityRequest.liquid b/fhir_converter/templates/stu3/EligibilityRequest.liquid new file mode 100644 index 0000000..ea7a105 --- /dev/null +++ b/fhir_converter/templates/stu3/EligibilityRequest.liquid @@ -0,0 +1,23 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "resourceType" : "CoverageEligibilityRequest", + "insurance" : [ + { + "focal" : true, + "coverage" : {{msg.coverage | to_json_string | default : '""' }}, + "businessArrangement" : "{{msg.businessArrangement}}" + } + ], + "item" : [ + { + "category" : {{msg.benefitCategory | to_json_string | default : '""' }} + } + ], + "benefitSubCategory" : "", + "benefitCategory" : "", + "businessArrangement" : "", + "coverage" : "", + "organization" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/EligibilityResponse.liquid b/fhir_converter/templates/stu3/EligibilityResponse.liquid new file mode 100644 index 0000000..df2421e --- /dev/null +++ b/fhir_converter/templates/stu3/EligibilityResponse.liquid @@ -0,0 +1,18 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "resourceType" : "CoverageEligibilityResponse", + "requestor" : {{msg.requestProvider | to_json_string | default : '""'}}, + "inforce" : "", + {% assign value = msg.outcome.coding[0].code -%} + {% if value == 'complete' or value == 'error' or value == 'partial' -%} + "outcome" : "{{value}}", + {% else %} + "outcome":"", + {% endif -%} + "requestOrganization" : "", + "insurance" : [ {{ msg.insurance | to_array | batch_render: 'EligibilityResponse/EligibilityResponseInsurance', 'insurance' }} ], + "requestProvider" : "" +} +{% endmergeDiff -%} + diff --git a/fhir_converter/templates/stu3/EligibilityResponse/_EligibilityResponseInsurance.liquid b/fhir_converter/templates/stu3/EligibilityResponse/_EligibilityResponseInsurance.liquid new file mode 100644 index 0000000..0f75faa --- /dev/null +++ b/fhir_converter/templates/stu3/EligibilityResponse/_EligibilityResponseInsurance.liquid @@ -0,0 +1,9 @@ +{% mergeDiff insurance -%} +{ + {% if msg.inforce == true -%} + "inforce" : true, + {% endif -%} + "benefitBalance" : "", + "contract" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Encounter.liquid b/fhir_converter/templates/stu3/Encounter.liquid new file mode 100644 index 0000000..5b6bbe9 --- /dev/null +++ b/fhir_converter/templates/stu3/Encounter.liquid @@ -0,0 +1,11 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "basedOn" : {{msg.incomingReferral | to_json_string | default : '""'}}, + "reasonCode" : {{msg.reason | to_json_string | default : '""'}}, + "appointment" : [{{msg.appointment | to_json_string | default : '""'}}], + "diagnosis" : [ {{ msg.diagnosis | to_array | batch_render: 'Encounter/Diagnosis', 'msg' }} ], + "reason" : "", + "incomingReferral" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Encounter/_Diagnosis.liquid b/fhir_converter/templates/stu3/Encounter/_Diagnosis.liquid new file mode 100644 index 0000000..14bf0e2 --- /dev/null +++ b/fhir_converter/templates/stu3/Encounter/_Diagnosis.liquid @@ -0,0 +1,6 @@ +{% mergeDiff msg -%} +{ + "use" : {{msg.role | to_json_string | default : '""'}}, + "role" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Endpoint.liquid b/fhir_converter/templates/stu3/Endpoint.liquid new file mode 100644 index 0000000..2a94716 --- /dev/null +++ b/fhir_converter/templates/stu3/Endpoint.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/EnrollmentRequest.liquid b/fhir_converter/templates/stu3/EnrollmentRequest.liquid new file mode 100644 index 0000000..94d79cf --- /dev/null +++ b/fhir_converter/templates/stu3/EnrollmentRequest.liquid @@ -0,0 +1,8 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "candidate" : {{msg.subject | to_json_string | default : '""'}}, + "subject" : "", + "organization" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/EnrollmentResponse.liquid b/fhir_converter/templates/stu3/EnrollmentResponse.liquid new file mode 100644 index 0000000..b42968f --- /dev/null +++ b/fhir_converter/templates/stu3/EnrollmentResponse.liquid @@ -0,0 +1,11 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "outcome" : "", + {% assign value = msg.outcome.coding[0].code %} + {% if value == 'complete' or value == 'error' or value == 'partial' -%} + "outcome" : "{{value}}", + {% endif -%} + "requestOrganization" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/EpisodeOfCare.liquid b/fhir_converter/templates/stu3/EpisodeOfCare.liquid new file mode 100644 index 0000000..2a94716 --- /dev/null +++ b/fhir_converter/templates/stu3/EpisodeOfCare.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ExplanationOfBenefit.liquid b/fhir_converter/templates/stu3/ExplanationOfBenefit.liquid new file mode 100644 index 0000000..303e824 --- /dev/null +++ b/fhir_converter/templates/stu3/ExplanationOfBenefit.liquid @@ -0,0 +1,31 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "subtype" : {{msg.subtype[0] | to_json_string | default:'""'}}, + "outcome" : "", + {% assign value = msg.outcome.coding[0].code %} + {% if value == 'complete' or value == 'error' or value == 'partial' -%} + "outcome" : "{{value}}", + {% endif -%} + "payee" : {% include 'ExplanationOfBenefit/ExplanationOfBenefitPayee' msg: msg.payee -%}, + "supportingInfo" : {{msg.information | to_json_string | default : '""' }}, + "insurance" : [{{msg.insurance | to_json_string | default:'""'}}], + "item" : [ {{ msg.item | to_array | batch_render: 'ExplanationOfBenefit/ExplanationOfBenefitItem', 'msg' }} ], + "addItem" : [ {{ msg.addItem | to_array | batch_render: 'ExplanationOfBenefit/ExplanationOfBenefitAddItem', 'msg' }} ], + "total" : [ + {% include 'ExplanationOfBenefit/ExplanationOfBenefitTotalCost' msg: msg.totalCost -%}, + {% include 'ExplanationOfBenefit/ExplanationOfBenefitTotalBenefit' msg: msg.totalBenefit -%} + ], + "payment" : {% include 'ExplanationOfBenefit/ExplanationOfBenefitPayment' msg: msg.payment -%}, + "form" : {% include 'DataType/CodeableConceptToAttachment' msg: msg.form -%}, + "processNote" : [ {{ msg.processNote | to_array | batch_render: 'ExplanationOfBenefit/ExplanationOfBenefitProcessNote', 'msg' }} ], + "benefitBalance" : [ {{ msg.benefitBalance | to_array | batch_render: 'ExplanationOfBenefit/ExplanationOfBenefitBenefitBalance', 'msg' }} ], + "totalBenefit" : "", + "unallocDeductable" : "", + "totalCost" : "", + "hospitalization" : "", + "employmentImpacted" : "", + "information" : "", + "organization" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitAddItem.liquid b/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitAddItem.liquid new file mode 100644 index 0000000..a14d57b --- /dev/null +++ b/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitAddItem.liquid @@ -0,0 +1,11 @@ +{% mergeDiff msg -%} +{ + "adjudication" : [ {{ msg.adjudication | to_array | batch_render: '_ExplanationOfBenefitItemAdjudication', 'msg' }} ], + "detail" : [ {{ msg.detail | to_array | batch_render: 'ExplanationOfBenefit/ExplanationOfBenefitAddItemDetail', 'msg' }} ], + "fee" : "", + "service" : "", + "category" : "", + "revenue" : "", + "sequenceLinkId" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitAddItemDetail.liquid b/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitAddItemDetail.liquid new file mode 100644 index 0000000..042bdcb --- /dev/null +++ b/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitAddItemDetail.liquid @@ -0,0 +1,9 @@ +{% mergeDiff msg -%} +{ + "adjudication" : [ {{ msg.adjudication | to_array | batch_render: '_ExplanationOfBenefitItemAdjudication', 'msg' }} ], + "fee" : "", + "service" : "", + "category" : "", + "revenue" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitAddItemDetailSubDetail.liquid b/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitAddItemDetailSubDetail.liquid new file mode 100644 index 0000000..34cd97a --- /dev/null +++ b/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitAddItemDetailSubDetail.liquid @@ -0,0 +1,9 @@ +{% mergeDiff msg -%} +{ + "unitPrice" : {% include 'DataType/Money' msg: msg.unitPrice -%}, + "net" : {% include 'DataType/Money' msg: msg.net -%}, + "adjudication" : [ {{ msg.adjudication | to_array | batch_render: '_ExplanationOfBenefitItemAdjudication', 'msg' }} ], + "service" : "", + "type" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitBenefitBalance.liquid b/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitBenefitBalance.liquid new file mode 100644 index 0000000..e2415b2 --- /dev/null +++ b/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitBenefitBalance.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "subCategory" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitItem.liquid b/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitItem.liquid new file mode 100644 index 0000000..703271a --- /dev/null +++ b/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitItem.liquid @@ -0,0 +1,18 @@ +{% mergeDiff msg -%} +{ + "careTeamSequence" : {{msg.careTeamLinkId | to_json_string | default : '""'}}, + "diagnosisSequence" : {{msg.diagnosisLinkId | to_json_string | default : '""'}}, + "procedureSequence" : {{msg.procedureLinkId | to_json_string | default : '""'}}, + "informationSequence" : {{msg.informationLinkId | to_json_string | default : '""'}}, + "productOrService" : {{msg.service | to_json_string | default : '""'}}, + "unitPrice" : {% include 'DataType/Money' msg: msg.unitPrice -%}, + "net" : {% include 'DataType/Money' msg: msg.net -%}, + "adjudication" : [ {{ msg.adjudication | to_array | batch_render: 'ExplanationOfBenefit/ExplanationOfBenefitItemAdjudication', 'msg' }} ], + "detail" : [ {{ msg.detail | to_array | batch_render: 'ExplanationOfBenefit/ExplanationOfBenefitItemDetail', 'msg' }} ], + "service" : "", + "informationLinkId" : "", + "procedureLinkId" : "", + "diagnosisLinkId" : "", + "careTeamLinkId" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitItemAdjudication.liquid b/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitItemAdjudication.liquid new file mode 100644 index 0000000..58ce319 --- /dev/null +++ b/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitItemAdjudication.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "amount" : {% include 'DataType/Money' msg: msg.amount -%} +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitItemDetail.liquid b/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitItemDetail.liquid new file mode 100644 index 0000000..6c4f20b --- /dev/null +++ b/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitItemDetail.liquid @@ -0,0 +1,10 @@ +{% mergeDiff msg -%} +{ + "unitPrice" : {% include 'DataType/Money' msg: msg.unitPrice -%}, + "net" : {% include 'DataType/Money' msg: msg.net -%}, + "adjudication" : [ {{ msg.adjudication | to_array | batch_render: '_ExplanationOfBenefitItemAdjudication', 'msg' }} ], + "subDetail" : [ {{ msg.subDetail | to_array | batch_render: 'ExplanationOfBenefit/ExplanationOfBenefitItemDetailSubDetail', 'msg' }} ], + "service" : "", + "type" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitItemDetailSubDetail.liquid b/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitItemDetailSubDetail.liquid new file mode 100644 index 0000000..34cd97a --- /dev/null +++ b/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitItemDetailSubDetail.liquid @@ -0,0 +1,9 @@ +{% mergeDiff msg -%} +{ + "unitPrice" : {% include 'DataType/Money' msg: msg.unitPrice -%}, + "net" : {% include 'DataType/Money' msg: msg.net -%}, + "adjudication" : [ {{ msg.adjudication | to_array | batch_render: '_ExplanationOfBenefitItemAdjudication', 'msg' }} ], + "service" : "", + "type" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitPayee.liquid b/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitPayee.liquid new file mode 100644 index 0000000..66fb172 --- /dev/null +++ b/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitPayee.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "resourceType" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitPayment.liquid b/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitPayment.liquid new file mode 100644 index 0000000..e89086e --- /dev/null +++ b/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitPayment.liquid @@ -0,0 +1,6 @@ +{% mergeDiff msg -%} +{ + "adjustment" : {% include 'DataType/Money' msg: msg.adjustment -%}, + "amount" : {% include 'DataType/Money' msg: msg.amount -%} +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitProcessNote.liquid b/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitProcessNote.liquid new file mode 100644 index 0000000..5c111b5 --- /dev/null +++ b/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitProcessNote.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "type" : {% include 'DataType/CodeableConceptToCode' msg: msg.type -%} +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitTotalBenefit.liquid b/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitTotalBenefit.liquid new file mode 100644 index 0000000..34e4670 --- /dev/null +++ b/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitTotalBenefit.liquid @@ -0,0 +1,10 @@ +{ + "category" : { + "text" : "Benefit Amount", + "coding" : { + "code" : "benefit", + "system" : "http://terminology.hl7.org/CodeSystem/adjudication" + } + }, + "amount" : {% include 'DataType/Money' msg: msg -%} +} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitTotalCost.liquid b/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitTotalCost.liquid new file mode 100644 index 0000000..69d6811 --- /dev/null +++ b/fhir_converter/templates/stu3/ExplanationOfBenefit/_ExplanationOfBenefitTotalCost.liquid @@ -0,0 +1,10 @@ +{ + "category" : { + "text" : "Submitted Amount", + "coding" : { + "code" : "submitted", + "system" : "http://terminology.hl7.org/CodeSystem/adjudication" + } + }, + "amount" : {% include 'DataType/Money' msg: msg -%} +} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/FamilyMemberHistory.liquid b/fhir_converter/templates/stu3/FamilyMemberHistory.liquid new file mode 100644 index 0000000..692bfc5 --- /dev/null +++ b/fhir_converter/templates/stu3/FamilyMemberHistory.liquid @@ -0,0 +1,32 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "instantiatesCanonical" : [ {{ msg.definition | to_array | batch_render: 'DataType/ReferenceToCanonical', 'msg' }} ], + {%if msg.notDone -%} + "extension" : [ + {% for e in msg.extension -%} + {{ e | to_json_string | default : '""'}}, + {% endfor -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-FamilyMemberHistory.notDone", + "valueBoolean" : "{{msg.notDone}}" + }, + ], + {% endif -%} + "dataAbsentReason" : {{msg.notDoneReason | to_json_string | default : '""'}}, + {%if msg.gender -%} + "sex" : { + "coding" : [ + { + "system" : "http://hl7.org/fhir/administrative-gender", + "code" : "{{msg.gender}}" + } + ] + }, + {% endif -%} + "definition" : "", + "gender" : "", + "notDone" : "", + "notDoneReason" : "", +} +{% endmergeDiff -%} diff --git a/fhir_converter/templates/stu3/Flag.liquid b/fhir_converter/templates/stu3/Flag.liquid new file mode 100644 index 0000000..10e3f56 --- /dev/null +++ b/fhir_converter/templates/stu3/Flag.liquid @@ -0,0 +1,8 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "category" : [ + {{msg.category | to_json_string | default : '""' }}, + ] +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Goal.liquid b/fhir_converter/templates/stu3/Goal.liquid new file mode 100644 index 0000000..102a96b --- /dev/null +++ b/fhir_converter/templates/stu3/Goal.liquid @@ -0,0 +1,53 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + {% assign value = msg.status %} + {% if value == 'proposed' or value == 'planned' or value == 'accepted' or value == 'on-hold' or value == 'cancelled' or value == 'entered-in-error' or value == 'rejected' -%} + "lifecycleStatus" : "{{value}}", + {% elseif value == 'achieved' -%} + "lifecycleStatus" : "completed", + {% elseif value == 'in-progress' or value == 'sustaining' -%} + "lifecycleStatus" : "active", + "achievementStatus" : { + "coding" : [ + { + "system" : "http://terminology.hl7.org/CodeSystem/goal-achievement", + "code" : "{{value}}" + } + ] + }, + {% elseif value == 'on-target' -%} + "lifecycleStatus" : "active", + "achievementStatus" : { + "coding" : [ + { + "system" : "http://terminology.hl7.org/CodeSystem/goal-achievement", + "code" : "sustaining" + } + ] + }, + {% elseif value == 'ahead-of-target' -%} + "lifecycleStatus" : "active", + "achievementStatus" : { + "coding" : [ + { + "system" : "http://terminology.hl7.org/CodeSystem/goal-achievement", + "code" : "improving" + } + ] + }, + {% elseif value == 'behind-target' -%} + "lifecycleStatus" : "active", + "achievementStatus" : { + "coding" : [ + { + "system" : "http://terminology.hl7.org/CodeSystem/goal-achievement", + "code" : "worsening" + } + ] + }, + {% endif -%} + "target" : [{{msg.target | to_json_string | default : '""'}}], + "status" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/GraphDefinition.liquid b/fhir_converter/templates/stu3/GraphDefinition.liquid new file mode 100644 index 0000000..db53f52 --- /dev/null +++ b/fhir_converter/templates/stu3/GraphDefinition.liquid @@ -0,0 +1,7 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "link" : [ {{ msg.link | to_array | batch_render: 'GraphDefinition/Link', 'msg' }} ] +} +{% endmergeDiff -%} + diff --git a/fhir_converter/templates/stu3/GraphDefinition/_Compartment.liquid b/fhir_converter/templates/stu3/GraphDefinition/_Compartment.liquid new file mode 100644 index 0000000..ee7c6ac --- /dev/null +++ b/fhir_converter/templates/stu3/GraphDefinition/_Compartment.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "use" : "requirement" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/GraphDefinition/_Link.liquid b/fhir_converter/templates/stu3/GraphDefinition/_Link.liquid new file mode 100644 index 0000000..02b2de1 --- /dev/null +++ b/fhir_converter/templates/stu3/GraphDefinition/_Link.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "target" : [ {{ msg.target | to_array | batch_render: 'GraphDefinition/TheTarget', 'msg' }} ] +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/GraphDefinition/_TheTarget.liquid b/fhir_converter/templates/stu3/GraphDefinition/_TheTarget.liquid new file mode 100644 index 0000000..114b5b9 --- /dev/null +++ b/fhir_converter/templates/stu3/GraphDefinition/_TheTarget.liquid @@ -0,0 +1,6 @@ +{% mergeDiff msg -%} +{ + "compartment" : [ {{ msg.compartment | to_array | batch_render: 'GraphDefinition/Compartment', 'msg' }} ], + "link" : [ {{ msg.link | to_array | batch_render: 'GraphDefinition/Link', 'msg' }} ] +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Group.liquid b/fhir_converter/templates/stu3/Group.liquid new file mode 100644 index 0000000..2a94716 --- /dev/null +++ b/fhir_converter/templates/stu3/Group.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/GuidanceResponse.liquid b/fhir_converter/templates/stu3/GuidanceResponse.liquid new file mode 100644 index 0000000..8f36810 --- /dev/null +++ b/fhir_converter/templates/stu3/GuidanceResponse.liquid @@ -0,0 +1,19 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "identifier" : [{{msg.identifier | to_json_string | default : '""'}}], + "requestIdentifier" : { + "value" : "{{msg.requestId}}" + }, + "moduleCanonical" : {% include 'DataType/ReferenceToCanonical' msg: msg.module -%}, + "encounter" : {{msg.context | to_json_string | default : '""'}}, + "reasonCode" : [{{msg.reasonCodeableConcept | to_json_string | default : '""'}}], + "reasonReference" : [{{msg.reasonReference | to_json_string | default : '""'}}], + "dataRequirement" : [ {{ msg.dataRequirement | to_array | batch_render: 'DataType/DataRequirement', 'msg' }} ], + "context" : "", + "requestId" : "", + "module" : "", + "reasonCodeableConcept": "" +} +{% endmergeDiff -%} + diff --git a/fhir_converter/templates/stu3/HealthcareService.liquid b/fhir_converter/templates/stu3/HealthcareService.liquid new file mode 100644 index 0000000..8eec155 --- /dev/null +++ b/fhir_converter/templates/stu3/HealthcareService.liquid @@ -0,0 +1,19 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "category" : [{{ msg.category | to_json_string | default : '""' }}], + "eligibility" :[ + { + "code" : {{msg.eligibility | to_json_string | default : '""' }}, + "comment" : "{{msg.eligibilityNote}}" + } + ], + "program" : [ + { + "text": "{{msg.programName}}" + } + ], + "eligibilityNote" : "", + "programName" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ImagingStudy.liquid b/fhir_converter/templates/stu3/ImagingStudy.liquid new file mode 100644 index 0000000..ba7ea23 --- /dev/null +++ b/fhir_converter/templates/stu3/ImagingStudy.liquid @@ -0,0 +1,39 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "identifier" : [ + {%if msg.uid -%} + { + "system" : "urn:dicom:uid", + "value" : "{{msg.uid}}" + }, + {% endif -%} + {% for i in msg.identifier -%} + {{ i | to_json_string | default : '""'}}, + {% endfor -%} + {{msg.accession | to_json_string | default : '""'}} + ], + {% if msg.availability == 'OFFLINE' or msg.availability == 'UNAVAILABLE' -%} + "status" : "registered", + {% elseif msg.availability == 'ONLINE' or msg.availability == 'NEARLINE' -%} + "status" : "available", + {% elseif msg.availability == null -%} + "status" : "unknown", + {% endif -%} + "modality" : {{msg.modalityList | to_json_string | default : '""'}}, + "subject" : {{msg.patient | to_json_string | default : '""'}}, + "encounter" : {{msg.context | to_json_string | default : '""'}}, + "procedureReference": {{msg.procedureReference[0] | to_json_string | default : '""'}}, + "reasonCode" : [ + {{msg.reason | to_json_string | default : '""'}} + ], + "series" : [ {{ msg.series | to_array | batch_render: 'ImagingStudy/Series', 'msg' }} ], + "reason" : "", + "context" : "", + "patient" : "", + "modalityList" : "", + "availability" : "", + "accession" : "", + "uid" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ImagingStudy/_Instance.liquid b/fhir_converter/templates/stu3/ImagingStudy/_Instance.liquid new file mode 100644 index 0000000..effd707 --- /dev/null +++ b/fhir_converter/templates/stu3/ImagingStudy/_Instance.liquid @@ -0,0 +1,11 @@ +{% mergeDiff msg -%} +{ + "uid" : {% include 'DataType/OidToId' msg: msg.uid -%}, + {%if msg.sopClass -%} + "sopClass" : { + "system" : "urn:ietf:rfc:3986", + "code" : "{{msg.sopClass}}" + }, + {% endif -%} +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ImagingStudy/_Performer.liquid b/fhir_converter/templates/stu3/ImagingStudy/_Performer.liquid new file mode 100644 index 0000000..3feceb7 --- /dev/null +++ b/fhir_converter/templates/stu3/ImagingStudy/_Performer.liquid @@ -0,0 +1,11 @@ +{ + "function" : { + "coding" : [ + { + "system" : "http://terminology.hl7.org/CodeSystem/v3-ParticipationType", + "code" : "PRF" + } + ] + }, + "actor" : {{msg | to_json_string | default : '""'}}, +} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ImagingStudy/_Series.liquid b/fhir_converter/templates/stu3/ImagingStudy/_Series.liquid new file mode 100644 index 0000000..4bd9d5d --- /dev/null +++ b/fhir_converter/templates/stu3/ImagingStudy/_Series.liquid @@ -0,0 +1,19 @@ +{% mergeDiff msg -%} +{ + "uid" : {% include 'DataType/OidToId' msg: msg.uid -%}, + "extension" : [ + {% for e in msg.extension -%} + {{ e | to_json_string | default : '""'}}, + {% endfor -%} + {%if msg.availability -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-ImagingStudy.series.availability", + "valueCode" : "{{msg.availability}}" + }, + {% endif -%} + ], + "performer" : [ {{ msg.performer | to_array | batch_render: 'ImagingStudy/Performer', 'msg' }} ], + "instance" : [ {{ msg.instance | to_array | batch_render: 'ImagingStudy/Instance', 'msg' }} ], + "availability" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Immunization.liquid b/fhir_converter/templates/stu3/Immunization.liquid new file mode 100644 index 0000000..1478af9 --- /dev/null +++ b/fhir_converter/templates/stu3/Immunization.liquid @@ -0,0 +1,29 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + {% if msg.notGiven == true -%} + "status" : "not-done", + {% endif -%} + "extension" : [ + {% for e in msg.extension -%} + {{ e | to_json_string | default : '""'}}, + {% endfor -%} + {%if msg.notGiven -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-Immunization.notGiven", + "valueBoolean" : "{{msg.notGiven}}" + }, + {% endif -%} + ], + "occurrenceDateTime" : "{{ msg.date | date: "yyyy-MM-ddTHH:mm:ss.fff%K" }}", + "performer" : [ {{ msg.practitioner | to_array | batch_render: 'Immunization/Practitioner', 'msg' }} ], + "reasonCode" : {{msg.explanation.reason | to_json_string | default : '""'}}, + "reasonCode" : {{msg.explanation.reasonNotGiven | to_json_string | default : '""'}}, + "protocolApplied" : [ {{ msg.vaccinationProtocol | to_array | batch_render: 'Immunization/Protocol', 'msg' }} ], + "vaccinationProtocol" : "", + "explanation" : "", + "practitioner" : "", + "date" : "", + "notGiven" : "" +} +{% endmergeDiff -%} diff --git a/fhir_converter/templates/stu3/Immunization/_Practitioner.liquid b/fhir_converter/templates/stu3/Immunization/_Practitioner.liquid new file mode 100644 index 0000000..aa9e1b7 --- /dev/null +++ b/fhir_converter/templates/stu3/Immunization/_Practitioner.liquid @@ -0,0 +1,6 @@ +{% mergeDiff msg -%} +{ + "function" : {{msg.role | to_json_string | default : '""'}}, + "role" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Immunization/_Protocol.liquid b/fhir_converter/templates/stu3/Immunization/_Protocol.liquid new file mode 100644 index 0000000..123bb81 --- /dev/null +++ b/fhir_converter/templates/stu3/Immunization/_Protocol.liquid @@ -0,0 +1,34 @@ +{% mergeDiff msg -%} +{ + "doseNumberPositiveInt" : {{msg.doseSequence}}, + "seriesDosesPositiveInt" : {{msg.seriesDoses}}, + "extension" : [ + {% for e in msg.extension -%} + {{ e | to_json_string | default : '""'}}, + {% endfor -%} + {%if msg.description -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-Immunization.vaccinationProtocol.description", + "valueString" : "{{msg.description}}" + }, + {% endif -%} + {%if msg.doseStatus -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-Immunization.vaccinationProtocol.doseStatus", + "valueCodeableConcept" : {{msg.doseStatus | to_json_string | default : '""' }} + }, + {% endif -%} + {%if msg.doseStatusReason -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-Immunization.vaccinationProtocol.doseStatusReason", + "valueCodeableConcept" : {{msg.doseStatusReason | to_json_string | default : '""' }} + }, + {% endif -%} + ], + "description" : "", + "doseStatus" : "", + "doseStatusReason" : "", + "doseSequence" : "", + "seriesDoses" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ImmunizationRecommendation.liquid b/fhir_converter/templates/stu3/ImmunizationRecommendation.liquid new file mode 100644 index 0000000..6dc3608 --- /dev/null +++ b/fhir_converter/templates/stu3/ImmunizationRecommendation.liquid @@ -0,0 +1,8 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "recommendation" : [{{msg.recommendation | to_array | batch_render : 'ImmunizationRecommendation/Recommendation', 'msg' }}], + "date" : "{{msg.recommendation[0].date | date: "yyyy-MM-ddTHH:mm:ss.fff%K" }}", + "authority" : {{msg.recommendation[0].protocol.authority | to_json_string | default : '""'}}, +} +{% endmergeDiff -%} diff --git a/fhir_converter/templates/stu3/ImmunizationRecommendation/_Recommendation.liquid b/fhir_converter/templates/stu3/ImmunizationRecommendation/_Recommendation.liquid new file mode 100644 index 0000000..fc88fc8 --- /dev/null +++ b/fhir_converter/templates/stu3/ImmunizationRecommendation/_Recommendation.liquid @@ -0,0 +1,12 @@ +{% mergeDiff msg -%} +{ + "vaccineCode" : [{{msg.vaccineCode | to_json_string | default : '""'}}], + "doseNumberPositiveInt" : {{msg.doseNumber}}, + "doseNumber" : "", + "description" : "{{msg.protocol.description}}", + "series" : "{{msg.protocol.series}}", + "protocol" : "", + "seriesDosesPositiveInt" : {{msg.protocol.doseSequence}}, + "date" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ImplementationGuide.liquid b/fhir_converter/templates/stu3/ImplementationGuide.liquid new file mode 100644 index 0000000..e53858c --- /dev/null +++ b/fhir_converter/templates/stu3/ImplementationGuide.liquid @@ -0,0 +1,24 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "dependsOn" :[ + {% for d in msg.dependency -%} + {% if d.type == 'reference' -%} + { + "uri":"{{d.uri}}" + }, + {% endif -%} + {% endfor %} + ], + "global" : [ {{ msg.global | to_array | batch_render: 'ImplementationGuide/Global', 'msg' }} ], + "definition" : {% include 'ImplementationGuide/Definition' msg: msg -%}, + {% if msg.binary -%} + "manifest" : {% include 'ImplementationGuide/Manifest' msg: msg -%}, + {% endif -%} + "page" : "", + "binary" : "", + "package" : "", + "dependency" : "" +} +{% endmergeDiff -%} + diff --git a/fhir_converter/templates/stu3/ImplementationGuide/_Definition.liquid b/fhir_converter/templates/stu3/ImplementationGuide/_Definition.liquid new file mode 100644 index 0000000..aaf0140 --- /dev/null +++ b/fhir_converter/templates/stu3/ImplementationGuide/_Definition.liquid @@ -0,0 +1,9 @@ +{ + "grouping" : [ {{ msg.package | to_array | batch_render: 'ImplementationGuide/Grouping', 'msg' }} ], + "page" : {% include 'ImplementationGuide/Page' msg: msg.page -%}, + "resource": [ + {% for p in msg.package -%} + {{ p.resource | to_array | batch_render : 'ImplementationGuide/Resource', 'msg'}} + {% endfor -%} + ] +} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ImplementationGuide/_Global.liquid b/fhir_converter/templates/stu3/ImplementationGuide/_Global.liquid new file mode 100644 index 0000000..9caf4f2 --- /dev/null +++ b/fhir_converter/templates/stu3/ImplementationGuide/_Global.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "profile" : {% include 'DataType/ReferenceToCanonical' msg: msg.profile -%} +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ImplementationGuide/_Grouping.liquid b/fhir_converter/templates/stu3/ImplementationGuide/_Grouping.liquid new file mode 100644 index 0000000..37ad173 --- /dev/null +++ b/fhir_converter/templates/stu3/ImplementationGuide/_Grouping.liquid @@ -0,0 +1,4 @@ +{ + "name" : "{{msg.name}}", + "description" : "{{msg.description}}", +} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ImplementationGuide/_Manifest.liquid b/fhir_converter/templates/stu3/ImplementationGuide/_Manifest.liquid new file mode 100644 index 0000000..7e9abb2 --- /dev/null +++ b/fhir_converter/templates/stu3/ImplementationGuide/_Manifest.liquid @@ -0,0 +1,3 @@ +{ + "other" : {{msg.binary | to_json_string | default : '""'}}, +} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ImplementationGuide/_Page.liquid b/fhir_converter/templates/stu3/ImplementationGuide/_Page.liquid new file mode 100644 index 0000000..784debd --- /dev/null +++ b/fhir_converter/templates/stu3/ImplementationGuide/_Page.liquid @@ -0,0 +1,40 @@ +{% mergeDiff msg -%} +{ + "nameUrl" : "{{msg.source}}", + "extension" : [ + {% for e in msg.extension -%} + {{ e | to_json_string | default : '""'}}, + {% endfor -%} + {%if msg.kind -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-ImplementationGuide.page.kind", + "valueCode" : "{{msg.kind}}" + }, + {% endif -%} + {% for t in mag.type -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-ImplementationGuide.page.type", + "valueCode" : "{{t}}" + }, + {% endfor -%} + {% for p in mag.package -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-ImplementationGuide.page.package", + "valueString" : "{{p}}" + }, + {% endfor -%} + {%if msg.format -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-ImplementationGuide.page.format", + "valueCode" : "{{msg.format}}" + }, + {% endif -%} + ], + "page" : [ {{ msg.page | to_array | batch_render: 'ImplementationGuide/Page', 'msg' }} ], + "kind" : "", + "type" : "", + "package" : "", + "format" : "", + "source" : "" +} +{% endmergeDiff -%} diff --git a/fhir_converter/templates/stu3/ImplementationGuide/_Resource.liquid b/fhir_converter/templates/stu3/ImplementationGuide/_Resource.liquid new file mode 100644 index 0000000..20ef17a --- /dev/null +++ b/fhir_converter/templates/stu3/ImplementationGuide/_Resource.liquid @@ -0,0 +1,37 @@ +{% mergeDiff msg -%} +{ + {% if msg.exampleFor == null -%} + "exampleBoolean" : {{msg.example}}, + {% else -%} + "exampleCanonical" : {% include 'DataType/ReferenceToCanonical' msg: msg.exampleFor -%}, + {% endif -%} + "extension" : [ + {% for e in msg.extension -%} + {{ e | to_json_string | default : '""'}}, + {% endfor -%} + {%if msg.acronym -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-ImplementationGuide.package.resource.acronym", + "valueString" : "{{msg.acronym}}" + }, + {% endif -%} + ], + {%if msg.sourceUri -%} + "reference" : { + "reference" : "{{msg.sourceUri}}", + "extension" : { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/BaseType", + "valueUri" : "uri" + } + }, + {% endif -%} + {%if msg.sourceReference -%} + "reference" : {{msg.sourceReference | to_json_string | default : '""'}}, + {% endif -%} + "exampleFor" : "", + "example" : "", + "acronym" : "", + "sourceUri" : "", + "sourceReference" :"" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Library.liquid b/fhir_converter/templates/stu3/Library.liquid new file mode 100644 index 0000000..02f598e --- /dev/null +++ b/fhir_converter/templates/stu3/Library.liquid @@ -0,0 +1,36 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "author" :[ + {% for c in msg.contributor %} + {% if c.type == 'author' -%} + {% include 'DataType/ContributorToContactDetail' msg : c -%}, + {% endif %} + {% endfor %} + ], + "editor" :[ + {% for c in msg.contributor %} + {% if c.type == "editor" -%} + {% include 'DataType/ContributorToContactDetail' msg : c -%}, + {% endif %} + {% endfor %} + ], + "reviewer" :[ + {% for c in msg.contributor %} + {% if c.type == "reviewer" -%} + {% include 'DataType/ContributorToContactDetail' msg : c -%}, + {% endif %} + {% endfor %} + ], + "endorser" :[ + {% for c in msg.contributor %} + {% if c.type == "endorser" -%} + {% include 'DataType/ContributorToContactDetail' msg : c -%}, + {% endif %} + {% endfor %} + ], + "relatedArtifact" : [ {{ msg.relatedArtifact | to_array | batch_render: 'DataType/RelatedArtifact', 'msg' }} ], + "dataRequirement" : [ {{ msg.dataRequirement | to_array | batch_render: 'DataType/DataRequirement', 'msg' }} ], + "contributor" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Linkage.liquid b/fhir_converter/templates/stu3/Linkage.liquid new file mode 100644 index 0000000..2a94716 --- /dev/null +++ b/fhir_converter/templates/stu3/Linkage.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/List.liquid b/fhir_converter/templates/stu3/List.liquid new file mode 100644 index 0000000..2a94716 --- /dev/null +++ b/fhir_converter/templates/stu3/List.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Location.liquid b/fhir_converter/templates/stu3/Location.liquid new file mode 100644 index 0000000..488ec2f --- /dev/null +++ b/fhir_converter/templates/stu3/Location.liquid @@ -0,0 +1,6 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "type" : [{{msg.type | to_json_string | default : '""'}}] +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Measure.liquid b/fhir_converter/templates/stu3/Measure.liquid new file mode 100644 index 0000000..3ecf419 --- /dev/null +++ b/fhir_converter/templates/stu3/Measure.liquid @@ -0,0 +1,53 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "author" :[ + {% for c in msg.contributor %} + {% if c.type == 'author' -%} + {% include 'DataType/ContributorToContactDetail' msg : c -%}, + {% endif %} + {% endfor %} + ], + "editor" :[ + {% for c in msg.contributor %} + {% if c.type == "editor" -%} + {% include 'DataType/ContributorToContactDetail' msg : c -%}, + {% endif %} + {% endfor %} + ], + "reviewer" :[ + {% for c in msg.contributor %} + {% if c.type == "reviewer" -%} + {% include 'DataType/ContributorToContactDetail' msg : c -%}, + {% endif %} + {% endfor %} + ], + "endorser" :[ + {% for c in msg.contributor %} + {% if c.type == "endorser" -%} + {% include 'DataType/ContributorToContactDetail' msg : c -%}, + {% endif %} + {% endfor %} + ], + "relatedArtifact" : [ {{ msg.relatedArtifact | to_array | batch_render: 'DataType/RelatedArtifact', 'msg' }} ], + "library" : [ {{ msg.library | to_array | batch_render: 'DataType/ReferenceToCanonical', 'msg' }} ], + "improvementNotation" : { + "text" : "{{msg.improvementNotation}}" + }, + "extension" : [ + {% for e in msg.extension -%} + {{ e | to_json_string | default : '""'}}, + {% endfor -%} + {%if msg.set -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-Measure.set", + "valueString" : "{{msg.set}}" + }, + {% endif -%} + ], + "group" : [ {{ msg.group | to_array | batch_render: 'Measure/TheGroup', 'msg' }} ], + "supplementalData" : [ {{ msg.supplementalData | to_array | batch_render: 'Measure/SupplementalData', 'msg' }} ], + "contributor" : "", + "set" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Measure/_Population.liquid b/fhir_converter/templates/stu3/Measure/_Population.liquid new file mode 100644 index 0000000..45f7640 --- /dev/null +++ b/fhir_converter/templates/stu3/Measure/_Population.liquid @@ -0,0 +1,26 @@ +{% mergeDiff msg -%} +{ + "extension" : [ + {% for e in msg.extension -%} + {{ e | to_json_string | default : '""'}}, + {% endfor -%} + {%if msg.identifier -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-Measure.group.population.identifier", + "valueIdentifier" : {{msg.identifier | to_json_string | default : '""' }} + }, + {% endif -%} + {%if msg.name -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-Measure.group.population.name", + "valueString" : "{{msg.name}}" + }, + {% endif -%} + ], + "criteria" : { + "expression" : "{{msg.criteria}}" + }, + "name" : "", + "identifier" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Measure/_Stratifier.liquid b/fhir_converter/templates/stu3/Measure/_Stratifier.liquid new file mode 100644 index 0000000..fb0e5ab --- /dev/null +++ b/fhir_converter/templates/stu3/Measure/_Stratifier.liquid @@ -0,0 +1,21 @@ +{% mergeDiff msg -%} +{ + "code" : {% include 'DataType/IdentifierToCodeableConcept' msg: msg.identifier -%}, + "criteria" : { + "expression" : "{{msg.criteria}}" + }, + "extension" : [ + {% for e in msg.extension -%} + {{ e | to_json_string | default : '""'}}, + {% endfor -%} + {%if msg.path -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-Measure.group.stratifier.path", + "valueString" : "{{msg.path}}" + }, + {% endif -%} + ], + "identifier" : "", + "path" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Measure/_SupplementalData.liquid b/fhir_converter/templates/stu3/Measure/_SupplementalData.liquid new file mode 100644 index 0000000..c92a1f4 --- /dev/null +++ b/fhir_converter/templates/stu3/Measure/_SupplementalData.liquid @@ -0,0 +1,21 @@ +{% mergeDiff msg -%} +{ + "code" : {% include 'DataType/IdentifierToCodeableConcept' msg: msg.identifier -%}, + "criteria" : { + "expression" : "{{msg.criteria}}" + }, + "extension" : [ + {% for e in msg.extension -%} + {{ e | to_json_string | default : '""'}}, + {% endfor -%} + {%if msg.path -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-Measure.supplementalData.path", + "valueString" : "{{msg.path}}" + }, + {% endif -%} + ], + "identifier" : "", + "path" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Measure/_TheGroup.liquid b/fhir_converter/templates/stu3/Measure/_TheGroup.liquid new file mode 100644 index 0000000..20e6771 --- /dev/null +++ b/fhir_converter/templates/stu3/Measure/_TheGroup.liquid @@ -0,0 +1,20 @@ +{% mergeDiff msg -%} +{ + "code" : {% include 'DataType/IdentifierToCodeableConcept' msg: msg.identifier -%}, + "extension" : [ + {% for e in msg.extension -%} + {{ e | to_json_string | default : '""'}}, + {% endfor -%} + {%if msg.name -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-Measure.group.name", + "valueString" : "{{msg.name}}" + }, + {% endif -%} + ], + "population" : [ {{ msg.population | to_array | batch_render: 'Measure/Population', 'msg' }} ], + "stratifier" : [ {{ msg.stratifier | to_array | batch_render: 'Measure/Stratifier', 'msg' }} ], + "identifier" : "", + "name" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/MeasureReport.liquid b/fhir_converter/templates/stu3/MeasureReport.liquid new file mode 100644 index 0000000..6a6f3e0 --- /dev/null +++ b/fhir_converter/templates/stu3/MeasureReport.liquid @@ -0,0 +1,17 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "type" : {% include 'MeasureReport/TranslateTypeCode' msg : msg.type -%}, + "identifier" : [{{msg.identifier | to_json_string | default : '""' }}], + "measure" : {% include 'DataType/ReferenceToCanonical' msg: msg.measure -%}, + "subject" : {{msg.patient | to_json_string | default : '""'}}, + "reporter" : {{msg.reportingOrganization | to_json_string | default : '""'}}, + "group" : [ {{ msg.group | to_array | batch_render: 'MeasureReport/TheGroup', 'msg' }} ], + "evaluatedResource" : [ + {{msg.evaluatedResources | to_json_string | default : '""'}} + ], + "evaluatedResources" : "", + "reportingOrganization" : "", + "patient" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/MeasureReport/_Population.liquid b/fhir_converter/templates/stu3/MeasureReport/_Population.liquid new file mode 100644 index 0000000..dba2295 --- /dev/null +++ b/fhir_converter/templates/stu3/MeasureReport/_Population.liquid @@ -0,0 +1,18 @@ +{% mergeDiff msg -%} +{ + {%if msg.identifier -%} + "extension" : [ + {% for e in msg.extension -%} + {{ e | to_json_string | default : '""'}}, + {% endfor -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-MeasureReport.group.identifier", + "valueIdentifier" : {{msg.identifier | to_json_string | default : '""' }} + }, + ], + {% endif -%} + "subjectResults" : {{msg.patients | to_json_string | default : '""'}}, + "patients" : "", + "identifier" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/MeasureReport/_Population2.liquid b/fhir_converter/templates/stu3/MeasureReport/_Population2.liquid new file mode 100644 index 0000000..321be34 --- /dev/null +++ b/fhir_converter/templates/stu3/MeasureReport/_Population2.liquid @@ -0,0 +1,18 @@ +{% mergeDiff msg -%} +{ + {%if msg.identifier -%} + "extension" : [ + {% for e in msg.extension -%} + {{ e | to_json_string | default : '""'}}, + {% endfor -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-MeasureReport.group.stratifier.stratum.population.identifier", + "valueIdentifier" : {{msg.identifier | to_json_string | default : '""' }} + }, + ], + {% endif -%} + "subjectResults" : {{msg.patients | to_json_string | default : '""'}}, + "patients" : "", + "identifier" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/MeasureReport/_Stratifier.liquid b/fhir_converter/templates/stu3/MeasureReport/_Stratifier.liquid new file mode 100644 index 0000000..d792535 --- /dev/null +++ b/fhir_converter/templates/stu3/MeasureReport/_Stratifier.liquid @@ -0,0 +1,9 @@ +{% mergeDiff msg -%} +{ + "code" : [ + {% include 'DataType/IdentifierToCodeableConcept' msg: msg.identifier -%} + ], + "stratum" : [ {{ msg.stratum | to_array | batch_render: 'MeasureReport/Stratum', 'msg' }} ], + "identifier" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/MeasureReport/_Stratum.liquid b/fhir_converter/templates/stu3/MeasureReport/_Stratum.liquid new file mode 100644 index 0000000..f96166a --- /dev/null +++ b/fhir_converter/templates/stu3/MeasureReport/_Stratum.liquid @@ -0,0 +1,9 @@ +{% mergeDiff msg -%} +{ + "value" : { + "text" : "{{msg.value}}" + }, + "population" : [ {{ msg.population | to_array | batch_render: 'MeasureReport/Population2', 'msg' }} ], + "measureScore" : {% include 'DataType/DecimalToQuantity' msg: msg.measureScore -%} +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/MeasureReport/_TheGroup.liquid b/fhir_converter/templates/stu3/MeasureReport/_TheGroup.liquid new file mode 100644 index 0000000..4b45914 --- /dev/null +++ b/fhir_converter/templates/stu3/MeasureReport/_TheGroup.liquid @@ -0,0 +1,9 @@ +{% mergeDiff msg -%} +{ + "code" : {% include 'DataType/IdentifierToCodeableConcept' msg: msg.identifier -%}, + "population" : [ {{ msg.population | to_array | batch_render: 'MeasureReport/Population', 'msg' }} ], + "measureScore" : {% include 'DataType/DecimalToQuantity' msg: msg.measureScore -%}, + "stratifier" : [ {{ msg.stratifier | to_array | batch_render: 'MeasureReport/Stratifier', 'msg' }} ], + "identifier" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/MeasureReport/_TranslateTypeCode.liquid b/fhir_converter/templates/stu3/MeasureReport/_TranslateTypeCode.liquid new file mode 100644 index 0000000..dc86458 --- /dev/null +++ b/fhir_converter/templates/stu3/MeasureReport/_TranslateTypeCode.liquid @@ -0,0 +1,8 @@ +{% case msg -%} + {% when "patient-list" -%} + "subject-list" + {% when "individual" -%} + "individual" + {% when "summary" -%} + "summary" +{% endcase -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Media.liquid b/fhir_converter/templates/stu3/Media.liquid new file mode 100644 index 0000000..1fe8a20 --- /dev/null +++ b/fhir_converter/templates/stu3/Media.liquid @@ -0,0 +1,20 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + {%if msg.type -%} + "type" : { + "coding" : { + "system" : "http://terminology.hl7.org/CodeSystem/media-type", + "code" : "{{msg.type}}" + } + }, + {% endif -%} + "modality" : {{msg.subtype | to_json_string | default : '""'}}, + "encounter" : {{msg.context | to_json_string | default : '""'}}, + "createdDateTime" : "{{msg.occurrenceDateTime}}", + "createdPeriod" : {{msg.occurrencePeriod | to_json_string | default : '""'}}, + "occurrence[x]" : "", + "context" : "", + "subtype" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Medication.liquid b/fhir_converter/templates/stu3/Medication.liquid new file mode 100644 index 0000000..8ca67d2 --- /dev/null +++ b/fhir_converter/templates/stu3/Medication.liquid @@ -0,0 +1,60 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "extension" : [ + {% for e in msg.extension -%} + {{ e | to_json_string | default : '""'}}, + {% endfor -%} + {%if msg.status -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-Medication.status", + "valueCode" : "{{msg.status}}" + }, + {% endif -%} + {%if msg.isBrand -%} + { + "url" : "hhttp://hl7.org/fhir/r3/StructureDefinition/extension-Medication.isBrand", + "valueBoolean" : "{{msg.isBrand}}" + }, + {% endif -%} + {%if msg.isOverTheCounter -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-MedicationOTC", + "valueBoolean" : "{{msg.isOverTheCounter}}" + }, + {% endif -%} + {%if msg.package.container -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-Medication.package.container", + "valueCodeableConcept" : {{msg.package.container | to_json_string | default : '""' }} + }, + {% endif -%} + {% for c in msg.package.content -%} + {% if c.itemCodableConcept -%} + { + "url" : "http://hl7.org/fhir/3.0/StructureDefinition/extension-Medication.package.content", + "valueCodableConcept": {{c.itemCodableConcept |to_json_string | default : '""'}} + }, + {% endif -%} + {% if c.itemReference -%} + { + "url" : "http://hl7.org/fhir/3.0/StructureDefinition/extension-Medication.package.content", + "valueReference": {{c.itemReference |to_json_string | default : '""'}} + }, + {% endif -%} + {% endfor -%} + {% for i in msg.image -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-MedicationImage", + "valueAttachment" : {{i | to_json_string | default : '""' }} + }, + {% endfor -%} + ], + "ingredient" : [ {{ msg.ingredient | to_array | batch_render: 'Medication/Ingredient', 'msg' }} ], + "batch" : {{msg.package.batch | to_json_string | default : '""' }}, + "image" : "", + "isOverTheCounter" : "", + "isBrand" : "", + "package" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Medication/_Ingredient.liquid b/fhir_converter/templates/stu3/Medication/_Ingredient.liquid new file mode 100644 index 0000000..793f0f1 --- /dev/null +++ b/fhir_converter/templates/stu3/Medication/_Ingredient.liquid @@ -0,0 +1,6 @@ +{% mergeDiff msg -%} +{ + "strength" : {{msg.amount | to_json_string | default : '""'}}, + "amount" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/MedicationAdministration.liquid b/fhir_converter/templates/stu3/MedicationAdministration.liquid new file mode 100644 index 0000000..6ee62e8 --- /dev/null +++ b/fhir_converter/templates/stu3/MedicationAdministration.liquid @@ -0,0 +1,34 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "instantiates" : {{msg.definition | to_json_string | default : '""'}}, + "extension" : [ + {% for e in msg.extension -%} + {{ e | to_json_string | default : '""'}}, + {% endfor -%} + {%if msg.status -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-MedicationAdministration.status", + "valueCode" : "{{msg.status}}" + }, + {% endif -%} + {%if msg.notGiven -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-MedicationAdministration.notGiven", + "valueBoolean" : "{{msg.notGiven}}" + }, + {% endif -%} + ], + {% if msg.notGiven -%} + "status" : "not-done", + {% endif -%} + "performer" : [ {{ msg.performer | to_array | batch_render: 'MedicationAdministration/Actor', 'msg' }} ], + "reasonCode" : {{msg.reasonNotGiven | to_json_string | default : '""'}}, + "request" : {{msg.prescription | to_json_string | default : '""'}}, + "dosage" : {% include 'DataType/Dosage' msg: msg.dosage -%}, + "prescription" : "", + "reasonNotGiven" : "", + "definition" : "", + "notGiven" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/MedicationAdministration/_Actor.liquid b/fhir_converter/templates/stu3/MedicationAdministration/_Actor.liquid new file mode 100644 index 0000000..0e9bfb5 --- /dev/null +++ b/fhir_converter/templates/stu3/MedicationAdministration/_Actor.liquid @@ -0,0 +1,16 @@ +{% mergeDiff msg -%} +{ + "extension" : [ + {% for e in msg.extension -%} + {{ e | to_json_string | default : '""'}}, + {% endfor -%} + {%if msg.onBehalfOf -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-MedicationAdministration.performer.onBehalfOf", + "valueReference" : {{msg.onBehalfOf | to_json_string | default : '""' }} + }, + {% endif -%} + ], + "onBehalfOf" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/MedicationDispense.liquid b/fhir_converter/templates/stu3/MedicationDispense.liquid new file mode 100644 index 0000000..56ea766 --- /dev/null +++ b/fhir_converter/templates/stu3/MedicationDispense.liquid @@ -0,0 +1,32 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "performer" : [ {{ msg.performer | to_array | batch_render: 'MedicationDispense/Actor', 'msg' }} ], + "dosageInstruction" : [ {{ msg.dosageInstruction | to_array | batch_render: 'DataType/Dosage', 'msg' }} ], + "extension" : [ + {% for e in msg.extension -%} + {{ e | to_json_string | default : '""'}}, + {% endfor -%} + {%if msg.notDone -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-MedicationDispense.notDone", + "valueBoolean" : "{{msg.notDone}}" + }, + {% endif -%} + {%if msg.notDoneReasonCodeableConcept -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-MedicationDispense.notDoneReason", + "valueCodeableConcept" : {{msg.notDoneReasonCodeableConcept | to_json_string | default : '""' }} + }, + {% endif -%} + {%if msg.notDoneReasonReference -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-MedicationDispense.notDoneReason", + "valueReference" : {{msg.notDoneReasonReference | to_json_string | default : '""' }} + }, + {% endif -%} + ], + "notDone" : "", + "notDoneReason[x]" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/MedicationDispense/_Actor.liquid b/fhir_converter/templates/stu3/MedicationDispense/_Actor.liquid new file mode 100644 index 0000000..e850d63 --- /dev/null +++ b/fhir_converter/templates/stu3/MedicationDispense/_Actor.liquid @@ -0,0 +1,16 @@ +{% mergeDiff msg -%} +{ + "extension" : [ + {% for e in msg.extension -%} + {{ e | to_json_string | default : '""'}}, + {% endfor -%} + {%if msg.onBehalfOf -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-MedicationDispense.performer.onBehalfOf", + "valueReference" : {{msg.onBehalfOf | to_json_string | default : '""' }} + }, + {% endif -%} + ], + "onBehalfOf" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/MedicationRequest.liquid b/fhir_converter/templates/stu3/MedicationRequest.liquid new file mode 100644 index 0000000..c5979de --- /dev/null +++ b/fhir_converter/templates/stu3/MedicationRequest.liquid @@ -0,0 +1,24 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "category" : [{{msg.category | to_json_string | default : '""'}}], + "instantiatesCanonical" : {{msg.definition | to_json_string | default : '""'}}, + "encounter" : {{msg.context | to_json_string | default : '""'}}, + "extension" : [ + {% for e in msg.extension -%} + {{ e | to_json_string | default : '""'}}, + {% endfor -%} + {%if msg.requester.onBehalfOf -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-MedicationRequest.requester.onBehalfOf", + "valueReference" : {{msg.requester.onBehalfOf | to_json_string | default : '""' }} + }, + {% endif -%} + ], + "requester" : {{msg.requester.agent | to_json_string | default : '""'}}, + "dosageInstruction" : [ {{ msg.dosageInstruction | to_array | batch_render: 'DataType/Dosage', 'msg' }} ], + "substitution" : {% include 'MedicationRequest/Subst' msg: msg.substitution -%}, + "context" : "", + "definition" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/MedicationRequest/_Subst.liquid b/fhir_converter/templates/stu3/MedicationRequest/_Subst.liquid new file mode 100644 index 0000000..223c817 --- /dev/null +++ b/fhir_converter/templates/stu3/MedicationRequest/_Subst.liquid @@ -0,0 +1,6 @@ +{% mergeDiff msg -%} +{ + "allowedBoolean" : {{msg.allowed}}, + "allowed" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/MedicationStatement.liquid b/fhir_converter/templates/stu3/MedicationStatement.liquid new file mode 100644 index 0000000..92d43c7 --- /dev/null +++ b/fhir_converter/templates/stu3/MedicationStatement.liquid @@ -0,0 +1,33 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "extension" : [ + {% for e in msg.extension -%} + {{ e | to_json_string | default : '""'}}, + {% endfor -%} + {%if msg.status -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-MedicationStatement.status", + "valueCode" : "{{msg.status}}" + }, + {% endif -%} + {%if msg.taken -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-MedicationStatement.taken", + "valueCode" : "{{msg.taken}}" + }, + {% endif -%} + ], + {% if msg.taken == 'n' -%} + "status" : "not-taken", + {% else if msg.taken == 'unk' -%} + "status" : "unknown", + {% endif -%} + {% if msg.reasonNotTaken -%} + "reasonCode" : {{msg.reasonNotTaken | to_json_string | default : '""'}}, + {% endif -%} + "dosage" : [ {{ msg.dosage | to_array | batch_render: 'DataType/Dosage', 'msg' }} ], + "reasonNotTaken" : "", + "taken" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/MessageDefinition.liquid b/fhir_converter/templates/stu3/MessageDefinition.liquid new file mode 100644 index 0000000..87bcd99 --- /dev/null +++ b/fhir_converter/templates/stu3/MessageDefinition.liquid @@ -0,0 +1,19 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "identifier" : [{{msg.identifier | to_json_string | default : '""' }}], + "eventCoding" : {{msg.event | to_json_string | default : '""'}}, + "base" : {% include 'DataType/ReferenceToCanonical' msg : msg.parent -%}, + "parent" : {% include 'DataType/ReferenceToCanonical' msg : msg.parent -%}, + "replaces" : [{{msg.replaces | to_array | batch_render : 'DataType/ReferenceToCanonical', 'msg' }}], + "focus" : [{{msg.focus | to_array | batch_render : 'MessageDefinition/Focus', 'msg' }}], + "category" : {% include 'MessageDefinition/TranslateCategoryCode' msg : msg.category -%}, + "allowedResponse" : [{{msg.allowedResponse | to_array | batch_render : 'MessageDefinition/AllowedResponse', 'msg' }}], + {% if msg.responseRequired == true -%} + "responseRequired" : "always", + {% else -%} + "responseRequired" : "never", + {% endif -%} + "event" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/MessageDefinition/_AllowedResponse.liquid b/fhir_converter/templates/stu3/MessageDefinition/_AllowedResponse.liquid new file mode 100644 index 0000000..b4509a8 --- /dev/null +++ b/fhir_converter/templates/stu3/MessageDefinition/_AllowedResponse.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "message" : {% include 'DataType/ReferenceToCanonical' msg : msg.message -%}, +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/MessageDefinition/_Focus.liquid b/fhir_converter/templates/stu3/MessageDefinition/_Focus.liquid new file mode 100644 index 0000000..d0167ad --- /dev/null +++ b/fhir_converter/templates/stu3/MessageDefinition/_Focus.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "profile" : {% include 'DataType/ReferenceToCanonical' msg : msg.profile -%}, +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/MessageDefinition/_TranslateCategoryCode.liquid b/fhir_converter/templates/stu3/MessageDefinition/_TranslateCategoryCode.liquid new file mode 100644 index 0000000..e0cee94 --- /dev/null +++ b/fhir_converter/templates/stu3/MessageDefinition/_TranslateCategoryCode.liquid @@ -0,0 +1,8 @@ +{% case msg -%} + {% when "Consequence" -%} + "consequence" + {% when "Currency" -%} + "currency" + {% when "Notification" -%} + "notification" +{% endcase -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/MessageHeader.liquid b/fhir_converter/templates/stu3/MessageHeader.liquid new file mode 100644 index 0000000..807526a --- /dev/null +++ b/fhir_converter/templates/stu3/MessageHeader.liquid @@ -0,0 +1,19 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "eventCoding" : {{msg.event | to_json_string | default : '""'}}, + "destination" : [ + {% for d in msg.destination -%} + { + "name" : "{{d.name}}", + "target" : {{d.target | to_json_string | default : '""'}}, + "endpoint" : "{{d.endpoint}}", + "receiver" : {{msg.receiver | to_json_string | default : '""'}} + }, + {% endfor -%} + ], + "event" : "", + "timestamp" : "", + "receiver" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/NamingSystem.liquid b/fhir_converter/templates/stu3/NamingSystem.liquid new file mode 100644 index 0000000..3147bd8 --- /dev/null +++ b/fhir_converter/templates/stu3/NamingSystem.liquid @@ -0,0 +1,6 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "replacedBy" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/NutritionOrder.liquid b/fhir_converter/templates/stu3/NutritionOrder.liquid new file mode 100644 index 0000000..2a94716 --- /dev/null +++ b/fhir_converter/templates/stu3/NutritionOrder.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Observation.liquid b/fhir_converter/templates/stu3/Observation.liquid new file mode 100644 index 0000000..b64464a --- /dev/null +++ b/fhir_converter/templates/stu3/Observation.liquid @@ -0,0 +1,57 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "encounter" : {{msg.context | to_json_string | default : '""'}}, + "related" : "", + "interpretation" : [ {{msg.interpretation | to_json_string | default : '""'}}], + "note" : [ + {% include 'DataType/StringToAnnotation' msg: msg.comment -%} + ], + "comment" : "", + "hasMember" : [ + {% for r in msg.related %} + {% if r.type == "has-member" -%} + {{r.target | to_json_string | default : '""' }}, + {% endif -%} + {% endfor -%} + ], + "derivedFrom" : [ + {% for r in msg.related %} + {% if r.type == "derived-from" -%} + {{r.target | to_json_string | default : '""' }}, + {% endif -%} + {% endfor -%} + ], + "extension":[ + {% for e in msg.extension -%} + {{ e | to_json_string | default : '""'}}, + {% endfor -%} + {% for r in msg.related %} + {% case r.type %} + {% when "sequel-to" %} + { + "url":"http://hl7.org/fhir/3.0/StructureDefinition/Observation.sequelTo", + "valueReference": {{r.target | to_json_string | default : '""' }} + }, + {% when "replaces" %} + { + "url":"http://hl7.org/fhir/3.0/StructureDefinition/Observation.replaces", + "valueReference": {{r.target | to_json_string | default : '""' }} + }, + {% when "qualified-by" %} + { + "url":"http://hl7.org/fhir/3.0/StructureDefinition/Observation.qualifiedBy", + "valueReference": {{r.target | to_json_string | default : '""' }} + }, + {% when "interfered-by" %} + { + "url":"http://hl7.org/fhir/3.0/StructureDefinition/Observation.interferedBy", + "valueReference": {{r.target | to_json_string | default : '""' }} + }, + {% endcase %} + {% endfor %} + ], + "context" : "" +} +{% endmergeDiff -%} + diff --git a/fhir_converter/templates/stu3/OperationDefinition.liquid b/fhir_converter/templates/stu3/OperationDefinition.liquid new file mode 100644 index 0000000..cc7572b --- /dev/null +++ b/fhir_converter/templates/stu3/OperationDefinition.liquid @@ -0,0 +1,9 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "affectsState" : "{{msg.idempotent}}", + "idempotent" : "", + "base" : {% include 'DataType/ReferenceToCanonical' msg: msg.base -%}, + "parameter" : [ {{ msg.parameter | to_array | batch_render: 'OperationDefinition/Parameter', 'msg' }} ] +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/OperationDefinition/_Binding.liquid b/fhir_converter/templates/stu3/OperationDefinition/_Binding.liquid new file mode 100644 index 0000000..ad0fc7a --- /dev/null +++ b/fhir_converter/templates/stu3/OperationDefinition/_Binding.liquid @@ -0,0 +1,11 @@ +{% mergeDiff msg -%} +{ + {% if msg.valueSetReference -%} + "valueSet" : {% include 'DataType/ReferenceToCanonical' msg: msg.valueSetReference -%}, + {% else if msg.valueSetUri -%} + "valueSet" : "{{msg.valueSetUri}}", + {% endif -%} + "valueSetUri" : "", + "valueSetReference" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/OperationDefinition/_Parameter.liquid b/fhir_converter/templates/stu3/OperationDefinition/_Parameter.liquid new file mode 100644 index 0000000..ed4fb3c --- /dev/null +++ b/fhir_converter/templates/stu3/OperationDefinition/_Parameter.liquid @@ -0,0 +1,10 @@ +{% mergeDiff msg -%} +{ + "targetProfile" : [ + {% include 'DataType/ReferenceToCanonical' msg: msg.profile -%} + ], + "profile" : "", + "binding" : {% include 'OperationDefinition/Binding' msg: msg.binding -%}, + "part" : [ {{ msg.part | to_array | batch_render: 'OperationDefinition/Parameter', 'msg' }} ] +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/OperationOutcome.liquid b/fhir_converter/templates/stu3/OperationOutcome.liquid new file mode 100644 index 0000000..2a94716 --- /dev/null +++ b/fhir_converter/templates/stu3/OperationOutcome.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Organization.liquid b/fhir_converter/templates/stu3/Organization.liquid new file mode 100644 index 0000000..2a94716 --- /dev/null +++ b/fhir_converter/templates/stu3/Organization.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Parameters.liquid b/fhir_converter/templates/stu3/Parameters.liquid new file mode 100644 index 0000000..4af5b78 --- /dev/null +++ b/fhir_converter/templates/stu3/Parameters.liquid @@ -0,0 +1,6 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "parameter" : [ {{ msg.parameter | to_array | batch_render: 'Parameters/SubParameter', 'msg' }} ] +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Parameters/_SubParameter.liquid b/fhir_converter/templates/stu3/Parameters/_SubParameter.liquid new file mode 100644 index 0000000..3bb0b12 --- /dev/null +++ b/fhir_converter/templates/stu3/Parameters/_SubParameter.liquid @@ -0,0 +1,7 @@ +{% mergeDiff msg -%} +{ + "valueMoney" : {% include 'DataType/Money' msg: msg.valueMoney -%}, + "resource" : {% include 'Resource' msg: msg.resource -%}, + "part" : [{{msg.part | to_array | batch_render : 'Parameters/SubParameter', 'msg' }}] +} +{% endmergeDiff -%} diff --git a/fhir_converter/templates/stu3/Patient.liquid b/fhir_converter/templates/stu3/Patient.liquid new file mode 100644 index 0000000..c483565 --- /dev/null +++ b/fhir_converter/templates/stu3/Patient.liquid @@ -0,0 +1,12 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "extension" : [ + {% for e in msg.extension -%} + {{ e | to_json_string | default : '""'}}, + {% endfor -%} + {% include 'Patient/Animal' msg: msg.animal -%} + ], + "animal" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Patient/_Animal.liquid b/fhir_converter/templates/stu3/Patient/_Animal.liquid new file mode 100644 index 0000000..6569a87 --- /dev/null +++ b/fhir_converter/templates/stu3/Patient/_Animal.liquid @@ -0,0 +1,31 @@ +{% mergeDiff msg -%} +{ + "url" : "http://hl7.org/fhir/r4/StructureDefinition/patient-animal", + "extension" : [ + {% for e in msg.extension -%} + {{ e | to_json_string | default : '""'}}, + {% endfor -%} + {%if msg.species -%} + { + "url" : "species", + "valueCodeableConcept" : {{msg.species | to_json_string | default : '""' }} + }, + {% endif -%} + {%if msg.breed -%} + { + "url" : "breed", + "valueCodeableConcept" : {{msg.breed | to_json_string | default : '""' }} + }, + {% endif -%} + {%if msg.genderStatus -%} + { + "url" : "genderStatus", + "valueCodeableConcept" : {{msg.genderStatus | to_json_string | default : '""' }} + }, + {% endif -%} + ], + "genderStatus" : "", + "breed" : "", + "species" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/PaymentNotice.liquid b/fhir_converter/templates/stu3/PaymentNotice.liquid new file mode 100644 index 0000000..66ab969 --- /dev/null +++ b/fhir_converter/templates/stu3/PaymentNotice.liquid @@ -0,0 +1,11 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "paymentDate" : "{{msg.statusDate}}", + "recipient" : {{msg.target | to_json_string | default : '""'}}, + "organization" : "", + "target" : "", + "statusDate" : "", + "provider" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/PaymentReconciliation.liquid b/fhir_converter/templates/stu3/PaymentReconciliation.liquid new file mode 100644 index 0000000..882c17c --- /dev/null +++ b/fhir_converter/templates/stu3/PaymentReconciliation.liquid @@ -0,0 +1,20 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "paymentIssuer" : {{msg.organization | to_json_string | default : '""'}}, + {% assign value = msg.outcome.coding[0].code -%} + {% if value == 'complete' or value == 'error' or value == 'partial' -%} + "outcome" : "{{value}}", + {% endif -%} + "requestor" : {{msg.requestProvider | to_json_string | default : '""'}}, + "detail" : [ {{ msg.detail | to_array | batch_render: 'PaymentReconciliation/PaymentReconciliationDetail', 'msg' }} ], + "formCode" : {{msg.form | to_json_string | default : '""'}}, + "paymentAmount" : {% include 'DataType/Money' msg: msg.total -%}, + "processNote" : [ {{ msg.processNote | to_array | batch_render: 'PaymentReconciliation/PaymentReconciliationProcessNote', 'msg' }} ], + "total" : "", + "form" : "", + "requestOrganization" : "", + "requestProvider" : "", + "organization" : "" +} +{% endmergeDiff -%} diff --git a/fhir_converter/templates/stu3/PaymentReconciliation/_PaymentReconciliationDetail.liquid b/fhir_converter/templates/stu3/PaymentReconciliation/_PaymentReconciliationDetail.liquid new file mode 100644 index 0000000..58ce319 --- /dev/null +++ b/fhir_converter/templates/stu3/PaymentReconciliation/_PaymentReconciliationDetail.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "amount" : {% include 'DataType/Money' msg: msg.amount -%} +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/PaymentReconciliation/_PaymentReconciliationProcessNote.liquid b/fhir_converter/templates/stu3/PaymentReconciliation/_PaymentReconciliationProcessNote.liquid new file mode 100644 index 0000000..8640ca4 --- /dev/null +++ b/fhir_converter/templates/stu3/PaymentReconciliation/_PaymentReconciliationProcessNote.liquid @@ -0,0 +1,4 @@ +{ + "type" : "{{msg.type.coding[0].code}}", + "text" : "{{msg.text}}" +} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Person.liquid b/fhir_converter/templates/stu3/Person.liquid new file mode 100644 index 0000000..2a94716 --- /dev/null +++ b/fhir_converter/templates/stu3/Person.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/PlanDefinition.liquid b/fhir_converter/templates/stu3/PlanDefinition.liquid new file mode 100644 index 0000000..bde2455 --- /dev/null +++ b/fhir_converter/templates/stu3/PlanDefinition.liquid @@ -0,0 +1,38 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "author" :[ + {% for c in msg.contributor %} + {% if c.type == 'author' -%} + {% include 'DataType/ContributorToContactDetail' msg : c -%}, + {% endif %} + {% endfor %} + ], + "editor" :[ + {% for c in msg.contributor %} + {% if c.type == "editor" -%} + {% include 'DataType/ContributorToContactDetail' msg : c -%}, + {% endif %} + {% endfor %} + ], + "reviewer" :[ + {% for c in msg.contributor %} + {% if c.type == "reviewer" -%} + {% include 'DataType/ContributorToContactDetail' msg : c -%}, + {% endif %} + {% endfor %} + ], + "endorser" :[ + {% for c in msg.contributor %} + {% if c.type == "endorser" -%} + {% include 'DataType/ContributorToContactDetail' msg : c -%}, + {% endif %} + {% endfor %} + ], + "relatedArtifact" : [ {{ msg.relatedArtifact | to_array | batch_render: 'DataType/RelatedArtifact', 'msg' }} ], + "library" : [ {{ msg.library | to_array | batch_render: 'DataType/ReferenceToCanonical', 'msg' }} ], + "goal" : [ {{ msg.goal | to_array | batch_render: 'PlanDefinition/Goal', 'msg' }} ], + "action" : [ {{ msg.action | to_array | batch_render: 'PlanDefinition/Action', 'msg' }} ], + "contributor" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/PlanDefinition/_Action.liquid b/fhir_converter/templates/stu3/PlanDefinition/_Action.liquid new file mode 100644 index 0000000..2c46241 --- /dev/null +++ b/fhir_converter/templates/stu3/PlanDefinition/_Action.liquid @@ -0,0 +1,17 @@ +{% mergeDiff msg -%} +{ + "prefix" : "{{msg.label}}", + "documentation" : [ {{ msg.documentation | to_array | batch_render: 'DataType/RelatedArtifact', 'msg' }} ], + "trigger" : {{msg.triggerDefinition | to_json_string | default : '""'}}, + "condition" : [ {{ msg.condition | to_array | batch_render: 'PlanDefinition/Condition', 'msg' }} ], + "input" : [ {{ msg.input | to_array | batch_render: 'DataType/DataRequirement', 'msg' }} ], + "output" : [ {{ msg.output | to_array | batch_render: 'DataType/DataRequirement', 'msg' }} ], + "type" : {% include 'DataType/CodingToCodeableConcept' msg: msg.type -%}, + "transform" : {% include 'DataType/ReferenceToCanonical' msg: msg.transform -%}, + "dynamicValue" : [ {{ msg.dynamicValue | to_array | batch_render: 'PlanDefinition/DynamicValue', 'msg' }} ], + "action" : [ {{ msg.action | to_array | batch_render: 'PlanDefinition/Action', 'msg' }} ], + "definition" : "", + "triggerDefinition" : "", + "label" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/PlanDefinition/_Condition.liquid b/fhir_converter/templates/stu3/PlanDefinition/_Condition.liquid new file mode 100644 index 0000000..7191fde --- /dev/null +++ b/fhir_converter/templates/stu3/PlanDefinition/_Condition.liquid @@ -0,0 +1,15 @@ +{% mergeDiff msg -%} +{ + "expression" : { + "description" : "{{msg.description}}" + }, + "expression" : { + "language" : "{{msg.language}}" + }, + "expression" : { + "expression" : "{{msg.expression}}" + }, + "language" : "", + "description" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/PlanDefinition/_DynamicValue.liquid b/fhir_converter/templates/stu3/PlanDefinition/_DynamicValue.liquid new file mode 100644 index 0000000..f16fb52 --- /dev/null +++ b/fhir_converter/templates/stu3/PlanDefinition/_DynamicValue.liquid @@ -0,0 +1,12 @@ +{% mergeDiff msg -%} +{ + "expression" : { + "description" : "{{msg.description}}", + "language" : "{{msg.language}}", + "expression" : "{{msg.expression}}" + }, + "language" : "", + "description" : "" +} +{% endmergeDiff -%} + diff --git a/fhir_converter/templates/stu3/PlanDefinition/_Goal.liquid b/fhir_converter/templates/stu3/PlanDefinition/_Goal.liquid new file mode 100644 index 0000000..2d3c8d2 --- /dev/null +++ b/fhir_converter/templates/stu3/PlanDefinition/_Goal.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "documentation" : [ {{ msg.documentation | to_array | batch_render: 'DataType/RelatedArtifact', 'msg' }} ] +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Practitioner.liquid b/fhir_converter/templates/stu3/Practitioner.liquid new file mode 100644 index 0000000..2a94716 --- /dev/null +++ b/fhir_converter/templates/stu3/Practitioner.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/PractitionerRole.liquid b/fhir_converter/templates/stu3/PractitionerRole.liquid new file mode 100644 index 0000000..2a94716 --- /dev/null +++ b/fhir_converter/templates/stu3/PractitionerRole.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Procedure.liquid b/fhir_converter/templates/stu3/Procedure.liquid new file mode 100644 index 0000000..a2938ad --- /dev/null +++ b/fhir_converter/templates/stu3/Procedure.liquid @@ -0,0 +1,17 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + {% if msg.notDone == true -%} + "status" : "not-done", + {% else -%} + "status" : {% include 'Procedure/TranslateStatusCode' msg: msg.status -%}, + {% endif -%} + "statusReason" : {{msg.notDoneReason | to_json_string | default : '""'}}, + "encounter" : {{msg.context | to_json_string | default : '""'}}, + "performer" : [ {{ msg.performer | to_array | batch_render: 'Procedure/ProcedurePerformer', 'msg' }} ], + "context" : "", + "notDone" : "", + "notDoneReason" : "", + "definition" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Procedure/_ProcedurePerformer.liquid b/fhir_converter/templates/stu3/Procedure/_ProcedurePerformer.liquid new file mode 100644 index 0000000..aa9e1b7 --- /dev/null +++ b/fhir_converter/templates/stu3/Procedure/_ProcedurePerformer.liquid @@ -0,0 +1,6 @@ +{% mergeDiff msg -%} +{ + "function" : {{msg.role | to_json_string | default : '""'}}, + "role" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Procedure/_TranslateStatusCode.liquid b/fhir_converter/templates/stu3/Procedure/_TranslateStatusCode.liquid new file mode 100644 index 0000000..394df04 --- /dev/null +++ b/fhir_converter/templates/stu3/Procedure/_TranslateStatusCode.liquid @@ -0,0 +1,15 @@ +{% case msg -%} + {% when "unknown" -%} + "unknown" + {% when "in-progress" -%} + "in-progress" + {% when "suspended" -%} + "suspended" + {% when "aborted" -%} + "stopped" + {% when "completed" -%} + "completed" + {% when "entered-in-error" -%} + "entered-in-error" +{% endcase -%} + diff --git a/fhir_converter/templates/stu3/Provenance.liquid b/fhir_converter/templates/stu3/Provenance.liquid new file mode 100644 index 0000000..c3465f5 --- /dev/null +++ b/fhir_converter/templates/stu3/Provenance.liquid @@ -0,0 +1,12 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "occurredPeriod" : {{msg.period | to_json_string | default : '""'}}, + "reason" : [ {{ msg.reason | to_array | batch_render: 'DataType/CodingToCodeableConcept', 'msg' }} ], + "activity" : {% include 'DataType/CodingToCodeableConcept' msg: msg.activity -%}, + "agent" : [ {{ msg.agent | to_array | batch_render: 'Provenance/Agent', 'msg' }} ], + "entity" : [ {{ msg.entity | to_array | batch_render: 'Provenance/Entity', 'msg' }} ], + "signature" : [ {{ msg.signature | to_array | batch_render: 'DataType/Signature', 'msg' }} ], + "period" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Provenance/_Agent.liquid b/fhir_converter/templates/stu3/Provenance/_Agent.liquid new file mode 100644 index 0000000..1553b4e --- /dev/null +++ b/fhir_converter/templates/stu3/Provenance/_Agent.liquid @@ -0,0 +1,34 @@ +{% mergeDiff msg -%} +{ + "onBehalfOf[x]" : "", + "who[x]" : "", + {%if msg.whoUri -%} + "who" : { + "reference" : "{{msg.whoUri}}", + "extension" : [ + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/BaseType", + "valueString" : "uri" + } + ] + }, + {% else if msg.whoReference -%} + "who" : {{msg.whoReference |to_json_string | default : '""'}}, + {% endif -%} + {%if msg.onBehalfOfUri -%} + "onBehalfOf" : { + "reference" : "{{msg.onBehalfOfUri}}", + "extension" : [ + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/BaseType", + "valueString" : "uri" + } + ] + }, + {% else if msg.onBehalfOfReference -%} + "onBehalfOf" : {{msg.onBehalfOfReference |to_json_string | default : '""'}}, + {% endif -%} + "type" : {{msg.relatedAgentType | to_json_string | default : '""'}}, + "relatedAgentType" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Provenance/_Entity.liquid b/fhir_converter/templates/stu3/Provenance/_Entity.liquid new file mode 100644 index 0000000..da312e7 --- /dev/null +++ b/fhir_converter/templates/stu3/Provenance/_Entity.liquid @@ -0,0 +1,21 @@ +{% mergeDiff msg -%} +{ + "what[x]" : "", + {%if msg.whatUri -%} + "what" : { + "reference" : "{{msg.whatUri}}", + "extension" : [ + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/BaseType", + "valueString" : "uri" + } + ] + }, + {% else if msg.whatReference -%} + "what" : {{msg.whatReference |to_json_string | default : '""'}}, + {% else if msg.whatIdentifier -%} + "what" : {% include 'DataType/IdentifierToReference' msg : msg.whatIdentifier -%}, + {% endif -%} + "agent" : [ {{ msg.agent | to_array | batch_render: 'Provenance/Agent', 'msg' }} ] +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Questionnaire.liquid b/fhir_converter/templates/stu3/Questionnaire.liquid new file mode 100644 index 0000000..061c440 --- /dev/null +++ b/fhir_converter/templates/stu3/Questionnaire.liquid @@ -0,0 +1,6 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "item" : [ {{ msg.item | to_array | batch_render: 'Questionnaire/Item', 'msg' }} ] +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Questionnaire/_EnableWhen.liquid b/fhir_converter/templates/stu3/Questionnaire/_EnableWhen.liquid new file mode 100644 index 0000000..a164133 --- /dev/null +++ b/fhir_converter/templates/stu3/Questionnaire/_EnableWhen.liquid @@ -0,0 +1,13 @@ +{% mergeDiff msg -%} +{ + {% if msg.answer == null -%} + "answerBoolean" : {{msg.hasAnswer}}, + "operator" : "exists", + {% else -%} + "operator" : "=", + {% endif -%} + "hasAnswer" : "", + "answerAttachment" : "", + "answerUri" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Questionnaire/_Initial.liquid b/fhir_converter/templates/stu3/Questionnaire/_Initial.liquid new file mode 100644 index 0000000..4fb6e42 --- /dev/null +++ b/fhir_converter/templates/stu3/Questionnaire/_Initial.liquid @@ -0,0 +1,16 @@ +{ + "valueBoolean" : {{msg.initialBoolean}}, + "valueDecimal" : {{msg.initialDecimal}}, + "valueInteger" : {{msg.initialInteger}}, + "valueDate" : "{{msg.initialDate}}", + "valueDateTime" : "{{msg.initialDateTime}}", + "valueTime" : "{{msg.initialTime}}", + "valueString" : "{{msg.initialString}}", + "valueUri" : "{{msg.initialUri}}", + "valueAttachment" : {{msg.initialAttachment | to_json_string | default : '""'}}, + "valueCoding" : {{msg.initialCoding | to_json_string | default : '""'}}, + "valueQuantity" : {{msg.initialQuantity | to_json_string | default : '""'}}, + "valueReference" : {{msg.initialReference | to_json_string | default : '""'}}, + "initial[x]" : "", +} + diff --git a/fhir_converter/templates/stu3/Questionnaire/_Item.liquid b/fhir_converter/templates/stu3/Questionnaire/_Item.liquid new file mode 100644 index 0000000..acc0351 --- /dev/null +++ b/fhir_converter/templates/stu3/Questionnaire/_Item.liquid @@ -0,0 +1,14 @@ +{% mergeDiff msg -%} +{ + "enableWhen" : [ {{ msg.enableWhen | to_array | batch_render: 'Questionnaire/EnableWhen', 'msg' }} ], + "answerValueSet" : {% include 'DataType/ReferenceToCanonical' msg : msg.options -%}, + "answerOption" : {{msg.option | to_json_string | default : '""' }}, + "initial" : [ + {% include 'Questionnaire/Initial' msg: msg -%} + ], + "item" : [ {{ msg.item | to_array | batch_render: 'Questionnaire/Item', 'msg' }} ], + "initial[x]" : "", + "option" : "", + "options" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/QuestionnaireResponse.liquid b/fhir_converter/templates/stu3/QuestionnaireResponse.liquid new file mode 100644 index 0000000..293194d --- /dev/null +++ b/fhir_converter/templates/stu3/QuestionnaireResponse.liquid @@ -0,0 +1,11 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "partOf" : {{msg.parent | to_json_string | default : '""'}}, + "questionnaire" : {% include 'DataType/ReferenceToCanonical' msg: msg.questionnaire -%}, + "encounter" : {{msg.context | to_json_string | default : '""'}}, + "item" : [ {{ msg.item | to_array | batch_render: 'QuestionnaireResponse/Item', 'msg' }} ], + "context" : "", + "parent" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/QuestionnaireResponse/_Answer.liquid b/fhir_converter/templates/stu3/QuestionnaireResponse/_Answer.liquid new file mode 100644 index 0000000..6c986fd --- /dev/null +++ b/fhir_converter/templates/stu3/QuestionnaireResponse/_Answer.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "item" : [ {{ msg.item | to_array | batch_render: 'QuestionnaireResponse/Item', 'msg' }} ] +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/QuestionnaireResponse/_Item.liquid b/fhir_converter/templates/stu3/QuestionnaireResponse/_Item.liquid new file mode 100644 index 0000000..2860e62 --- /dev/null +++ b/fhir_converter/templates/stu3/QuestionnaireResponse/_Item.liquid @@ -0,0 +1,18 @@ +{% mergeDiff msg -%} +{ + "extension" : [ + {% for e in msg.extension -%} + {{ e | to_json_string | default : '""'}}, + {% endfor -%} + {%if msg.subject -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-QuestionnaireResponse.item.subject", + "valueReference" : {{msg.subject | to_json_string | default : '""' }} + }, + {% endif -%} + ], + "answer" : [ {{ msg.answer | to_array | batch_render: 'QuestionnaireResponse/Answer', 'msg' }} ], + "item" : [ {{ msg.item | to_array | batch_render: 'QuestionnaireResponse/Item', 'msg' }} ], + "subject" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/RelatedPerson.liquid b/fhir_converter/templates/stu3/RelatedPerson.liquid new file mode 100644 index 0000000..f943a80 --- /dev/null +++ b/fhir_converter/templates/stu3/RelatedPerson.liquid @@ -0,0 +1,8 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "relationship" : [ + {{msg.relationship | to_json_string | default : '""'}} + ], +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/RequestGroup.liquid b/fhir_converter/templates/stu3/RequestGroup.liquid new file mode 100644 index 0000000..0c98e4b --- /dev/null +++ b/fhir_converter/templates/stu3/RequestGroup.liquid @@ -0,0 +1,13 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "instantiatesCanonical" : [{{msg.definition | to_array | batch_render : 'DataType/ReferenceToCanonical', 'msg'}} ], + "encounter" : {{msg.context | to_json_string | default : '""'}}, + "reasonCode" : [{{msg.reasonCodeableConcept | to_json_string | default : '""' }}], + "reasonReference" : [{{msg.reasonReference | to_json_string | default : '""' }}], + "action" : [ {{ msg.action | to_array | batch_render: 'RequestGroup/Action', 'msg' }} ], + "reasonCodeableConcept" : "", + "context" : "", + "definition" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/RequestGroup/_Action.liquid b/fhir_converter/templates/stu3/RequestGroup/_Action.liquid new file mode 100644 index 0000000..bcdde0a --- /dev/null +++ b/fhir_converter/templates/stu3/RequestGroup/_Action.liquid @@ -0,0 +1,10 @@ +{% mergeDiff msg -%} +{ + "prefix" : "{{msg.label}}", + "documentation" : [ {{ msg.documentation | to_array | batch_render: 'DataType/RelatedArtifact', 'msg' }} ], + "condition" : [ {{ msg.condition | to_array | batch_render: 'RequestGroup/Condition', 'msg' }} ], + "type" : {% include 'DataType/CodingToCodeableConcept' msg: msg.type -%}, + "action" : [ {{ msg.action | to_array | batch_render: 'RequestGroup/Action', 'msg' }} ], + "label" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/RequestGroup/_Condition.liquid b/fhir_converter/templates/stu3/RequestGroup/_Condition.liquid new file mode 100644 index 0000000..12a57d0 --- /dev/null +++ b/fhir_converter/templates/stu3/RequestGroup/_Condition.liquid @@ -0,0 +1,11 @@ +{% mergeDiff msg -%} +{ + "expression" : { + "description" : "{{msg.description}}", + "language" : "{{msg.language}}", + "expression" : "{{msg.expression}}" + }, + "language" : "", + "description" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ResearchStudy.liquid b/fhir_converter/templates/stu3/ResearchStudy.liquid new file mode 100644 index 0000000..f8ab81e --- /dev/null +++ b/fhir_converter/templates/stu3/ResearchStudy.liquid @@ -0,0 +1,20 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "status" : {% include 'ResearchStudy/TranslateStatusCode' msg : msg.status -%}, + "relatedArtifact" : [ {{ msg.relatedArtifact | to_array | batch_render: 'DataType/RelatedArtifact', 'msg' }} ], + "extension" : [ + {% for e in msg.extension -%} + {{ e | to_json_string | default : '""'}}, + {% endfor -%} + {% for j in msg.jurisdiction -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-ResearchStudy.jurisdiction", + "valueCodeableConcept" : {{msg.j | to_json_string | default : '""' }} + }, + {% endfor -%} + ], + "arm" : [ {{ msg.arm | to_array | batch_render: 'ResearchStudy/Arm', 'msg' }} ], + "jurisdiction" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ResearchStudy/_Arm.liquid b/fhir_converter/templates/stu3/ResearchStudy/_Arm.liquid new file mode 100644 index 0000000..f89f0dc --- /dev/null +++ b/fhir_converter/templates/stu3/ResearchStudy/_Arm.liquid @@ -0,0 +1,6 @@ +{% mergeDiff msg -%} +{ + "type" : {{msg.code | to_json_string | default : '""'}}, + "code" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ResearchStudy/_TranslateStatusCode.liquid b/fhir_converter/templates/stu3/ResearchStudy/_TranslateStatusCode.liquid new file mode 100644 index 0000000..aa92dad --- /dev/null +++ b/fhir_converter/templates/stu3/ResearchStudy/_TranslateStatusCode.liquid @@ -0,0 +1,14 @@ +{% case msg -%} + {% when "draft" -%} + "in-review" + {% when "in-progress" -%} + "active" + {% when "suspended" -%} + "disapproved" + {% when "stopped" -%} + "withdrawn" + {% when "completed" -%} + "administratively-completed" + {% when "entered-in-error" -%} + "withdrawn" +{% endcase -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ResearchSubject.liquid b/fhir_converter/templates/stu3/ResearchSubject.liquid new file mode 100644 index 0000000..697359f --- /dev/null +++ b/fhir_converter/templates/stu3/ResearchSubject.liquid @@ -0,0 +1,6 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "identifier" : [ {{msg.identifier | to_json_string | default : '""'}} ] +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Resource.liquid b/fhir_converter/templates/stu3/Resource.liquid new file mode 100644 index 0000000..047b62c --- /dev/null +++ b/fhir_converter/templates/stu3/Resource.liquid @@ -0,0 +1,220 @@ +{% case msg.resourceType -%} + {% when "Account" %} + {% include 'Account' msg: msg %} + {% when "ActivityDefinition" %} + {% include 'ActivityDefinition' msg: msg %} + {% when "Address" %} + {% include 'Address' msg: msg %} + {% when "AdverseEvent" %} + {% include 'AdverseEvent' msg: msg %} + {% when "AllergyIntolerance" %} + {% include 'AllergyIntolerance' msg: msg %} + {% when "Appointment" %} + {% include 'Appointment' msg: msg %} + {% when "AppointmentResponse" %} + {% include 'AppointmentResponse' msg: msg %} + {% when "AuditEvent" %} + {% include 'AuditEvent' msg: msg %} + {% when "Basic" %} + {% include 'Basic' msg: msg %} + {% when "Binary" %} + {% include 'Binary' msg: msg %} + {% when "BodySite" %} + {% include 'BodySite' msg: msg %} + {% when "Bundle" %} + {% include 'Bundle' msg: msg %} + {% when "CapabilityStatement" %} + {% include 'CapabilityStatement' msg: msg %} + {% when "CarePlan" %} + {% include 'CarePlan' msg: msg %} + {% when "CareTeam" %} + {% include 'CareTeam' msg: msg %} + {% when "ChargeItem" %} + {% include 'ChargeItem' msg: msg %} + {% when "Claim" %} + {% include 'Claim' msg: msg %} + {% when "ClaimResponse" %} + {% include 'ClaimResponse' msg: msg %} + {% when "ClinicalImpression" %} + {% include 'ClinicalImpression' msg: msg %} + {% when "CodeSystem" %} + {% include 'CodeSystem' msg: msg %} + {% when "Communication" %} + {% include 'Communication' msg: msg %} + {% when "CommunicationRequest" %} + {% include 'CommunicationRequest' msg: msg %} + {% when "CompartmentDefinition" %} + {% include 'CompartmentDefinition' msg: msg %} + {% when "Composition" %} + {% include 'Composition' msg: msg %} + {% when "ConceptMap" %} + {% include 'ConceptMap' msg: msg %} + {% when "Condition" %} + {% include 'Condition' msg: msg %} + {% when "Consent" %} + {% include 'Consent' msg: msg %} + {% when "Contract" %} + {% include 'Contract' msg: msg %} + {% when "Coverage" %} + {% include 'Coverage' msg: msg %} + {% when "DetectedIssue" %} + {% include 'DetectedIssue' msg: msg %} + {% when "Device" %} + {% include 'Device' msg: msg %} + {% when "DeviceMetric" %} + {% include 'DeviceMetric' msg: msg %} + {% when "DeviceRequest" %} + {% include 'DeviceRequest' msg: msg %} + {% when "DeviceUseStatement" %} + {% include 'DeviceUseStatement' msg: msg %} + {% when "DiagnosticReport" %} + {% include 'DiagnosticReport' msg: msg %} + {% when "DocumentManifest" %} + {% include 'DocumentManifest' msg: msg %} + {% when "DocumentReference" %} + {% include 'DocumentReference' msg: msg %} + {% when "EligibilityRequest" %} + {% include 'EligibilityRequest' msg: msg %} + {% when "EligibilityResponse" %} + {% include 'EligibilityResponse' msg: msg %} + {% when "Encounter" %} + {% include 'Encounter' msg: msg %} + {% when "Endpoint" %} + {% include 'Endpoint' msg: msg %} + {% when "EnrollmentRequest" %} + {% include 'EnrollmentRequest' msg: msg %} + {% when "EnrollmentResponse" %} + {% include 'EnrollmentResponse' msg: msg %} + {% when "EpisodeOfCare" %} + {% include 'EpisodeOfCare' msg: msg %} + {% when "ExplanationOfBenefit" %} + {% include 'ExplanationOfBenefit' msg: msg %} + {% when "FamilyMemberHistory" %} + {% include 'FamilyMemberHistory' msg: msg %} + {% when "Flag" %} + {% include 'Flag' msg: msg %} + {% when "Goal" %} + {% include 'Goal' msg: msg %} + {% when "GraphDefinition" %} + {% include 'GraphDefinition' msg: msg %} + {% when "Group" %} + {% include 'Group' msg: msg %} + {% when "GuidanceResponse" %} + {% include 'GuidanceResponse' msg: msg %} + {% when "HealthcareService" %} + {% include 'HealthcareService' msg: msg %} + {% when "ImagingStudy" %} + {% include 'ImagingStudy' msg: msg %} + {% when "Immunization" %} + {% include 'Immunization' msg: msg %} + {% when "ImmunizationRecommendation" %} + {% include 'ImmunizationRecommendation' msg: msg %} + {% when "ImplementationGuide" %} + {% include 'ImplementationGuide' msg: msg %} + {% when "Library" %} + {% include 'Library' msg: msg %} + {% when "Linkage" %} + {% include 'Linkage' msg: msg %} + {% when "List" %} + {% include 'List' msg: msg %} + {% when "Location" %} + {% include 'Location' msg: msg %} + {% when "Measure" %} + {% include 'Measure' msg: msg %} + {% when "MeasureReport" %} + {% include 'MeasureReport' msg: msg %} + {% when "Media" %} + {% include 'Media' msg: msg %} + {% when "Medication" %} + {% include 'Medication' msg: msg %} + {% when "MedicationAdministration" %} + {% include 'MedicationAdministration' msg: msg %} + {% when "MedicationDispense" %} + {% include 'MedicationDispense' msg: msg %} + {% when "MedicationRequest" %} + {% include 'MedicationRequest' msg: msg %} + {% when "MedicationStatement" %} + {% include 'MedicationStatement' msg: msg %} + {% when "MessageDefinition" %} + {% include 'MessageDefinition' msg: msg %} + {% when "MessageHeader" %} + {% include 'MessageHeader' msg: msg %} + {% when "NamingSystem" %} + {% include 'NamingSystem' msg: msg %} + {% when "NutritionOrder" %} + {% include 'NutritionOrder' msg: msg %} + {% when "Observation" %} + {% include 'Observation' msg: msg %} + {% when "OperationDefinition" %} + {% include 'OperationDefinition' msg: msg %} + {% when "OperationOutcome" %} + {% include 'OperationOutcome' msg: msg %} + {% when "Organization" %} + {% include 'Organization' msg: msg %} + {% when "Parameters" %} + {% include 'Parameters' msg: msg %} + {% when "Patient" %} + {% include 'Patient' msg: msg %} + {% when "PaymentNotice" %} + {% include 'PaymentNotice' msg: msg %} + {% when "PaymentReconciliation" %} + {% include 'PaymentReconciliation' msg: msg %} + {% when "Person" %} + {% include 'Person' msg: msg %} + {% when "PlanDefinition" %} + {% include 'PlanDefinition' msg: msg %} + {% when "Practitioner" %} + {% include 'Practitioner' msg: msg %} + {% when "PractitionerRole" %} + {% include 'PractitionerRole' msg: msg %} + {% when "Procedure" %} + {% include 'Procedure' msg: msg %} + {% when "Provenance" %} + {% include 'Provenance' msg: msg %} + {% when "Questionnaire" %} + {% include 'Questionnaire' msg: msg %} + {% when "QuestionnaireResponse" %} + {% include 'QuestionnaireResponse' msg: msg %} + {% when "RelatedPerson" %} + {% include 'RelatedPerson' msg: msg %} + {% when "RequestGroup" %} + {% include 'RequestGroup' msg: msg %} + {% when "ResearchStudy" %} + {% include 'ResearchStudy' msg: msg %} + {% when "ResearchSubject" %} + {% include 'ResearchSubject' msg: msg %} + {% when "RiskAssessment" %} + {% include 'RiskAssessment' msg: msg %} + {% when "Schedule" %} + {% include 'Schedule' msg: msg %} + {% when "SearchParameter" %} + {% include 'SearchParameter' msg: msg %} + {% when "Sequence" %} + {% include 'Sequence' msg: msg %} + {% when "Slot" %} + {% include 'Slot' msg: msg %} + {% when "Specimen" %} + {% include 'Specimen' msg: msg %} + {% when "StructureDefinition" %} + {% include 'StructureDefinition' msg: msg %} + {% when "StructureMap" %} + {% include 'StructureMap' msg: msg %} + {% when "Subscription" %} + {% include 'Subscription' msg: msg %} + {% when "Substance" %} + {% include 'Substance' msg: msg %} + {% when "SupplyDelivery" %} + {% include 'SupplyDelivery' msg: msg %} + {% when "SupplyRequest" %} + {% include 'SupplyRequest' msg: msg %} + {% when "Task" %} + {% include 'Task' msg: msg %} + {% when "TestReport" %} + {% include 'TestReport' msg: msg %} + {% when "TestScript" %} + {% include 'TestScript' msg: msg %} + {% when "ValueSet" %} + {% include 'ValueSet' msg: msg %} + {% when "VisionPrescription" %} + {% include 'VisionPrescription' msg: msg %} +{% endcase -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/RiskAssessment.liquid b/fhir_converter/templates/stu3/RiskAssessment.liquid new file mode 100644 index 0000000..3abe643 --- /dev/null +++ b/fhir_converter/templates/stu3/RiskAssessment.liquid @@ -0,0 +1,16 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "encounter" : {{msg.context | to_json_string | default : '""'}}, + "reasonCode" : [{{msg.reasonCodeableConcept | to_json_string | default : '""'}}], + "reasonReference" : [{{msg.reasonReference | to_json_string | default : '""'}}], + "note" : [ + { + "text" : "{{msg.comment}}" + } + ], + "reasonCodeableConcept" : "", + "context" : "", + "comment" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Schedule.liquid b/fhir_converter/templates/stu3/Schedule.liquid new file mode 100644 index 0000000..67d342a --- /dev/null +++ b/fhir_converter/templates/stu3/Schedule.liquid @@ -0,0 +1,6 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "serviceCategory" : [{{ msg.serviceCategory | to_json_string | default : '""'}}] +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/SearchParameter.liquid b/fhir_converter/templates/stu3/SearchParameter.liquid new file mode 100644 index 0000000..9efab41 --- /dev/null +++ b/fhir_converter/templates/stu3/SearchParameter.liquid @@ -0,0 +1,13 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "component" : [ + {%for item in msg.component -%} + { + "definition" : {% include 'DataType/ReferenceToCanonical' msg: item.definition -%}, + "expression" : "{{item.expression}}" + }, + {% endfor -%} + ] +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Sequence.liquid b/fhir_converter/templates/stu3/Sequence.liquid new file mode 100644 index 0000000..74d6e10 --- /dev/null +++ b/fhir_converter/templates/stu3/Sequence.liquid @@ -0,0 +1,8 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "resourceType" : "MolecularSequence", + "referenceSeq" : {% include 'Sequence/ReferenceSeq' msg:msg.referenceSeq -%}, + "quality" : [ {{ msg.quality | to_array | batch_render: 'Sequence/Quality', 'msg' }} ] +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Sequence/_Quality.liquid b/fhir_converter/templates/stu3/Sequence/_Quality.liquid new file mode 100644 index 0000000..80391a8 --- /dev/null +++ b/fhir_converter/templates/stu3/Sequence/_Quality.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "standardSequence" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Sequence/_ReferenceSeq.liquid b/fhir_converter/templates/stu3/Sequence/_ReferenceSeq.liquid new file mode 100644 index 0000000..935c013 --- /dev/null +++ b/fhir_converter/templates/stu3/Sequence/_ReferenceSeq.liquid @@ -0,0 +1,9 @@ +{% mergeDiff msg -%} +{ + {% if msg.strand == 1 -%} + "strand" : "watson", + {% else -%} + "strand" : "crick", + {% endif -%} +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Slot.liquid b/fhir_converter/templates/stu3/Slot.liquid new file mode 100644 index 0000000..283b18d --- /dev/null +++ b/fhir_converter/templates/stu3/Slot.liquid @@ -0,0 +1,6 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "serviceCategory" : [{{msg.serviceCategory | to_json_string | default : '""'}}] +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Specimen.liquid b/fhir_converter/templates/stu3/Specimen.liquid new file mode 100644 index 0000000..2a94716 --- /dev/null +++ b/fhir_converter/templates/stu3/Specimen.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/StructureDefinition.liquid b/fhir_converter/templates/stu3/StructureDefinition.liquid new file mode 100644 index 0000000..12de843 --- /dev/null +++ b/fhir_converter/templates/stu3/StructureDefinition.liquid @@ -0,0 +1,14 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "fhirVersion" : "4.0.1", + "context":[ + {% for c in msg.context -%} + { + "expression" : {{c}} + }, + {% endfor -%} + ], + "contextType" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/StructureMap.liquid b/fhir_converter/templates/stu3/StructureMap.liquid new file mode 100644 index 0000000..edec8eb --- /dev/null +++ b/fhir_converter/templates/stu3/StructureMap.liquid @@ -0,0 +1,6 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "group" : [ {{ msg.group | to_array | batch_render: 'StructureMap/TheGroup', 'msg' }} ] +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/StructureMap/_Rule.liquid b/fhir_converter/templates/stu3/StructureMap/_Rule.liquid new file mode 100644 index 0000000..9da43b4 --- /dev/null +++ b/fhir_converter/templates/stu3/StructureMap/_Rule.liquid @@ -0,0 +1,6 @@ +{% mergeDiff msg -%} +{ + "source" : [ {{ msg.source | to_array | batch_render: 'StructureMap/TheSource', 'msg' }} ], + "rule" : [ {{ msg.rule | to_array | batch_render: 'StructureMap/Rule', 'msg' }} ] +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/StructureMap/_TheGroup.liquid b/fhir_converter/templates/stu3/StructureMap/_TheGroup.liquid new file mode 100644 index 0000000..1f86b9b --- /dev/null +++ b/fhir_converter/templates/stu3/StructureMap/_TheGroup.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "rule" : [ {{ msg.rule | to_array | batch_render: 'StructureMap/Rule', 'msg' }} ] +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/StructureMap/_TheSource.liquid b/fhir_converter/templates/stu3/StructureMap/_TheSource.liquid new file mode 100644 index 0000000..5f4c447 --- /dev/null +++ b/fhir_converter/templates/stu3/StructureMap/_TheSource.liquid @@ -0,0 +1,6 @@ +{% mergeDiff msg -%} +{ + "defaultValueMoney" : {% include 'DataType/Money' msg: msg.defaultValueMoney -%}, + "defaultValueSignature" : {% include 'DataType/Signature' msg: msg.defaultValueSignature -%} +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Subscription.liquid b/fhir_converter/templates/stu3/Subscription.liquid new file mode 100644 index 0000000..4029e1e --- /dev/null +++ b/fhir_converter/templates/stu3/Subscription.liquid @@ -0,0 +1,6 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "tag" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Substance.liquid b/fhir_converter/templates/stu3/Substance.liquid new file mode 100644 index 0000000..2a94716 --- /dev/null +++ b/fhir_converter/templates/stu3/Substance.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/SupplyDelivery.liquid b/fhir_converter/templates/stu3/SupplyDelivery.liquid new file mode 100644 index 0000000..980a1f2 --- /dev/null +++ b/fhir_converter/templates/stu3/SupplyDelivery.liquid @@ -0,0 +1,6 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "identifier" : [ {{msg.identifier | to_json_string | default : '""'}} ] +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/SupplyRequest.liquid b/fhir_converter/templates/stu3/SupplyRequest.liquid new file mode 100644 index 0000000..1ab17a2 --- /dev/null +++ b/fhir_converter/templates/stu3/SupplyRequest.liquid @@ -0,0 +1,25 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "identifier" : [ {{msg.identifier | to_json_string | default : '""'}} ], + "itemCodeableConcept" : {{msg.orderedItem.itemCodeableConcept | to_json_string | default : '""'}}, + "itemReference" : {{msg.orderedItem.itemReference | to_json_string | default : '""'}}, + "quantity" : {{msg.orderedItem.quantity | to_json_string | default : '""'}}, + "extension" : [ + {% for e in msg.extension -%} + {{ e | to_json_string | default : '""'}}, + {% endfor -%} + {%if msg.requester.onBehalfOf -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-SupplyRequest.requester.onBehalfOf", + "valueReference" : {{msg.requester.onBehalfOf | to_json_string | default : '""' }} + }, + {% endif -%} + ], + "requester" : {{msg.requester.agent | to_json_string | default : '""'}}, + "reasonCode" : [{{msg.reasonCodeableConcept | to_json_string | default : '""' }}], + "reasonReference" : [{{msg.reasonReference | to_json_string | default : '""' }}], + "reasonCodeableConcept" : "", + "orderedItem" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/Task.liquid b/fhir_converter/templates/stu3/Task.liquid new file mode 100644 index 0000000..165468f --- /dev/null +++ b/fhir_converter/templates/stu3/Task.liquid @@ -0,0 +1,13 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "instantiatesUri" : "{{msg.definitionUri}}", + "instantiatesCanonical" : {% include 'DataType/ReferenceToCanonical' msg : msg.definitionReference -%}, + "encounter" : {{msg.context | to_json_string | default : '""'}}, + "requester" : {{msg.requester.agent | to_json_string | default : '""'}}, + "reasonCode" : {{msg.reason | to_json_string | default : '""'}}, + "reason" : "", + "context" : "", + "definition[x]" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/TestReport.liquid b/fhir_converter/templates/stu3/TestReport.liquid new file mode 100644 index 0000000..2a94716 --- /dev/null +++ b/fhir_converter/templates/stu3/TestReport.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/TestScript.liquid b/fhir_converter/templates/stu3/TestScript.liquid new file mode 100644 index 0000000..94b43d2 --- /dev/null +++ b/fhir_converter/templates/stu3/TestScript.liquid @@ -0,0 +1,10 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "metadata" : {% include 'TestScript/Metadata' msg: msg.metadata -%}, + "setup" : {% include 'TestScript/Setup' msg: msg.setup -%}, + "test" : [ {{ msg.test | to_array | batch_render: 'TestScript/Test', 'msg' }} ], + "rule" : "", + "ruleset" : "", +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/TestScript/_Action.liquid b/fhir_converter/templates/stu3/TestScript/_Action.liquid new file mode 100644 index 0000000..d7ae79d --- /dev/null +++ b/fhir_converter/templates/stu3/TestScript/_Action.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "assert" : {% include 'TestScript/Assert' msg: msg.assert -%} +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/TestScript/_Assert.liquid b/fhir_converter/templates/stu3/TestScript/_Assert.liquid new file mode 100644 index 0000000..9924ff4 --- /dev/null +++ b/fhir_converter/templates/stu3/TestScript/_Assert.liquid @@ -0,0 +1,6 @@ +{% mergeDiff msg -%} +{ + "rule" : "", + "ruleset" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/TestScript/_Capability.liquid b/fhir_converter/templates/stu3/TestScript/_Capability.liquid new file mode 100644 index 0000000..79bd426 --- /dev/null +++ b/fhir_converter/templates/stu3/TestScript/_Capability.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "capabilities" : {% include 'DataType/ReferenceToCanonical' msg: msg.capabilities -%} +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/TestScript/_Metadata.liquid b/fhir_converter/templates/stu3/TestScript/_Metadata.liquid new file mode 100644 index 0000000..853386b --- /dev/null +++ b/fhir_converter/templates/stu3/TestScript/_Metadata.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "capability" : [ {{ msg.capability | to_array | batch_render: 'TestScript/Capability', 'msg' }} ] +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/TestScript/_Setup.liquid b/fhir_converter/templates/stu3/TestScript/_Setup.liquid new file mode 100644 index 0000000..ec6ec46 --- /dev/null +++ b/fhir_converter/templates/stu3/TestScript/_Setup.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "action" : [ {{ msg.action | to_array | batch_render: 'TestScript/Action', 'msg' }} ] +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/TestScript/_Test.liquid b/fhir_converter/templates/stu3/TestScript/_Test.liquid new file mode 100644 index 0000000..ec6ec46 --- /dev/null +++ b/fhir_converter/templates/stu3/TestScript/_Test.liquid @@ -0,0 +1,5 @@ +{% mergeDiff msg -%} +{ + "action" : [ {{ msg.action | to_array | batch_render: 'TestScript/Action', 'msg' }} ] +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/ValueSet.liquid b/fhir_converter/templates/stu3/ValueSet.liquid new file mode 100644 index 0000000..a364f35 --- /dev/null +++ b/fhir_converter/templates/stu3/ValueSet.liquid @@ -0,0 +1,17 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "extension" : [ + {% for e in msg.extension -%} + {{ e | to_json_string | default : '""'}}, + {% endfor -%} + {%if msg.extensible -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-ValueSet.extensible", + "valueBoolean" : "{{msg.extensible}}" + }, + {% endif -%} + ], + "extensible" : "", +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/VisionPrescription.liquid b/fhir_converter/templates/stu3/VisionPrescription.liquid new file mode 100644 index 0000000..492ea10 --- /dev/null +++ b/fhir_converter/templates/stu3/VisionPrescription.liquid @@ -0,0 +1,25 @@ +{% mergeDiff msg -%} +{ + "contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ], + "extension" : [ + {% for e in msg.extension -%} + {{ e | to_json_string | default : '""'}}, + {% endfor -%} + {%if msg.reasonCodeableConcept -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-VisionPrescription.Reason", + "valueCodeableConcept" : {{msg.reasonCodeableConcept | to_json_string | default : '""' }} + }, + {% endif -%} + {%if msg.reasonReference -%} + { + "url" : "http://hl7.org/fhir/r3/StructureDefinition/extension-VisionPrescription.Reason", + "valueReference" : {{msg.reasonReference | to_json_string | default : '""' }} + }, + {% endif -%} + ], + "lensSpecification" : [ {{ msg.dispense | to_array | batch_render: 'VisionPrescription/Dispense', 'msg' }} ], + "dispense" : "", + "reason[x]" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/VisionPrescription/_Dispense.liquid b/fhir_converter/templates/stu3/VisionPrescription/_Dispense.liquid new file mode 100644 index 0000000..d30ca22 --- /dev/null +++ b/fhir_converter/templates/stu3/VisionPrescription/_Dispense.liquid @@ -0,0 +1,13 @@ +{% mergeDiff msg -%} +{ + "prism" : [ + {% if msg.prism or msg.base -%} + { + "amount" : "{{msg.prism}}", + "base" : "{{msg.base}}" + }, + {% endif -%} + ], + "base" : "" +} +{% endmergeDiff -%} \ No newline at end of file diff --git a/fhir_converter/templates/stu3/metadata.json b/fhir_converter/templates/stu3/metadata.json new file mode 100644 index 0000000..1d5a54d --- /dev/null +++ b/fhir_converter/templates/stu3/metadata.json @@ -0,0 +1,3 @@ +{ + "type": "fhir" +} \ No newline at end of file diff --git a/fhir_converter/utils.py b/fhir_converter/utils.py index 6c4f837..5bb67d3 100644 --- a/fhir_converter/utils.py +++ b/fhir_converter/utils.py @@ -1,13 +1,16 @@ from os import remove as os_remove from os import walk as os_walk from pathlib import Path +from re import Pattern from re import compile as re_compile -from typing import IO, Any, Dict, Generator, List, Tuple, Union +from typing import IO, Any, AnyStr, Dict, Final, Generator, List, Tuple, Union from pyjson5 import loads as json_loads from xmltodict import parse as xmltodict_parse -line_endings_regex = re_compile(r"\r\n?|\n") +DataIn = Union[IO, AnyStr] + +line_endings_pattern: Final[Pattern] = re_compile(r"\r\n?|\n") def is_none_or_empty(obj: Any) -> bool: @@ -164,21 +167,49 @@ def _remove_empty_json(obj: Any) -> Any: return obj -def parse_json(json_input: str) -> Any: - """parse_json parses the JSON string using a JSON 5 compliant decoder +def _read_text(data: DataIn, encoding: str = "utf-8") -> str: + """read_text Reads the given data using the supplied encoding if the data + is not already a string + + Args: + data (DataIn): the data to read + encoding (str, optional): The character encoding to use. Defaults to "utf-8" + + Returns: + str: the text content + """ + if isinstance(data, str): + return data + + content = data + if not isinstance(content, bytes): + content = content.read() + if isinstance(content, str): + return content + return str(content, encoding=encoding) + + +def parse_json( + json_in: DataIn, encoding: str = "utf-8", ignore_empty_fields: bool = True +) -> Any: + """parse_json Parses the JSON string using a JSON 5 compliant decoder Any empty JSON will be removed from decoded output. See remove_empty_json Args: - json_input (str): the json to decode + json_in (DataIn): the json to decode + encoding (str, optional): The character encoding to use. Defaults to "utf-8" + ignore_empty_fields (bool): Whether to ignore empty fields. Defaults to True Returns: Any: the decoded output """ - return _remove_empty_json(json_loads(json_input)) + json = json_loads(_read_text(json_in, encoding)) + return _remove_empty_json(json) if ignore_empty_fields else json -def parse_xml(xml_input: Union[str, IO], encoding: str = "utf-8") -> Dict[str, Any]: + +def parse_xml(xml_in: DataIn, encoding: str = "utf-8") -> Dict[str, Any]: """parse_xml Parses the xml imput string or text/binary IO Wraps xmltodict customizing the output as follows:: @@ -188,20 +219,13 @@ def parse_xml(xml_input: Union[str, IO], encoding: str = "utf-8") -> Dict[str, A - Replaces any : characters in keys with _ Args: - xml_input (Union[str, IO]): the xml input + xml_in (DataIn): the xml input encoding (str, optional): The character encoding to use. Defaults to "utf-8" Returns: Dict[str, Any]: the parsed xml """ - if isinstance(xml_input, str): - xml = xml_input - else: - xml = xml_input.read() - if not isinstance(xml, str): - xml = xml.decode(encoding) - xml = line_endings_regex.sub("", xml.strip()) - + xml = line_endings_pattern.sub("", _read_text(xml_in)) data = xmltodict_parse( xml, encoding=encoding, @@ -217,7 +241,7 @@ def parse_xml(xml_input: Union[str, IO], encoding: str = "utf-8") -> Dict[str, A def join_subpath(path: Path, parent: Path, child: Path) -> Path: - """join_subpath joins the parts from the child relative to the parent + """join_subpath Joins the parts from the child relative to the parent path to the supplied path. The final file part from child will be excluded if child is a file @@ -305,3 +329,22 @@ def walk_path( """ for dir, dirs, filenames in os_walk(path): yield (Path(dir), dirs, filenames) + + +def tail(buffer: IO, last_n: int = 25, encoding: str = "utf-8") -> str: + """tail Reads the tail from the given file like object + + Args: + buffer (IO): the file like object to read from + last_n (int, optional): The last n to read up to. Defaults to 25. + encoding (str, optional): The character encoding to use. Defaults to "utf-8" + + Returns: + str: up to the last n from the file like object or empty string if + the object is empty + """ + pos = buffer.tell() + if pos <= 0: + return "" + buffer.seek(pos - min(pos, last_n)) + return _read_text(buffer, encoding) diff --git a/logo.png b/logo.png index b8531cd7cabe2bde8296f5982eca34b5d5515ee0..7faa8d1b53b95461bfec216f27cc793c30e745d6 100644 GIT binary patch literal 7794 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 literal 11869 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 Mt146W+T`>90H2ZdtpET3 diff --git a/mypy.ini b/mypy.ini new file mode 100644 index 0000000..25caf79 --- /dev/null +++ b/mypy.ini @@ -0,0 +1,7 @@ +[mypy] +warn_redundant_casts = True +warn_unreachable = True +warn_return_any = False + +[mypy-isodate] +ignore_missing_imports = True \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 1fc30e0..9cc8b9d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,6 +40,7 @@ pyjson5 = "^1.6.5" frozendict = "^2.3.10" importlib_resources = "^6.1.1" psutil = "^5.9.7" +isodate = "^0.6.1" [tool.poetry.group.dev.dependencies] pytest = "^7.4.4" diff --git a/scripts/examples.py b/scripts/examples.py index 3d5190a..845e823 100644 --- a/scripts/examples.py +++ b/scripts/examples.py @@ -5,7 +5,9 @@ from liquid.loaders import DictLoader from fhir_converter.renderers import ( + BaseFhirRenderer, CcdaRenderer, + Stu3FhirRenderer, ccda_default_loader, get_environment, render_files_to_dir, @@ -14,42 +16,27 @@ from fhir_converter.utils import mkdir templates_dir, sample_data_dir, data_out_dir = ( - Path("data/templates/ccda"), - Path("data/sample/ccda"), + Path("data/templates"), + Path("data/sample"), Path("data/out"), ) - -from_file = sample_data_dir.joinpath("CCD.ccda") mkdir(data_out_dir) -# Render the file to string using the rendering defaults -with from_file.open() as xml_in: - print(CcdaRenderer().render_fhir_string("CCD", xml_in)) +ccda_templates_dir = templates_dir.joinpath("ccda") +ccda_sample_dir = sample_data_dir.joinpath("ccda") +ccda_data_out_dir = data_out_dir.joinpath("ccda") +mkdir(ccda_data_out_dir) -# Create a renderer that will load the user defined templates into the rendering env -renderer = CcdaRenderer( - # Since a default loader is not provided, the default location will be the module - env=get_environment( - loader=FileExtensionLoader(search_path=templates_dir), - additional_loaders=[ccda_default_loader], - ) -) +stu3_sample_dir = sample_data_dir.joinpath("stu3") +stu3_data_out_dir = data_out_dir.joinpath("stu3") +mkdir(stu3_data_out_dir) -# Render the file to the output directory using the default CCD template -render_to_dir( - render=partial(renderer.render_fhir, "CCD"), - from_file=from_file, - to_dir=data_out_dir, -) +renderer: BaseFhirRenderer = CcdaRenderer() -# Render all of the sample files to the output directory using the user defined -# pampi (problems, allergies, meds, procedures, immunizations) template -render_files_to_dir( - render=partial(renderer.render_fhir, "Pampi"), - from_dir=sample_data_dir, - to_dir=data_out_dir, - path_filter=lambda p: p.suffix in (".ccda", ".xml"), -) +print("Render the ccda file to string using the rendering defaults") +from_file = ccda_sample_dir.joinpath("CCD.ccda") +with from_file.open() as xml_in: + print(renderer.render_fhir_string("CCD", xml_in)) # Static / Dictonary loader @@ -66,6 +53,53 @@ additional_loaders=[ccda_default_loader], ) ) + +print("\nRender the results section with no patient / header information") with from_file.open() as xml_in: - # Render the results section with no patient / header information print(renderer.render_fhir_string("RESULTS", xml_in)) + + +# Create a renderer that will load the user defined templates into the rendering env +renderer = CcdaRenderer( + env=get_environment( + loader=FileExtensionLoader(search_path=ccda_templates_dir), + additional_loaders=[ccda_default_loader], + ) +) + +print("\nRender the ccda file to the output directory using the CCD template") +render_to_dir( + render=partial(renderer.render_fhir, "CCD"), + from_file=from_file, + to_dir=ccda_data_out_dir, +) + +print("\nRender all sample ccda files to the output directory using the Pampi template") +render_files_to_dir( + render=partial(renderer.render_fhir, "Pampi"), + from_dir=ccda_sample_dir, + to_dir=ccda_data_out_dir, + path_filter=lambda p: p.suffix in (".ccda", ".xml"), +) + + +renderer = Stu3FhirRenderer() + +print("\nRender the stu3 file to string") +from_file = stu3_sample_dir.joinpath("Patient.json") +with from_file.open() as fhir_in: + print(renderer.render_fhir_string("Patient", fhir_in)) + +print("\nRender the stu3 files to the output directory") +render_to_dir( + render=partial(renderer.render_fhir, "Patient"), + from_file=from_file, + to_dir=stu3_data_out_dir, +) + +from_file = stu3_sample_dir.joinpath("AllergyIntolerance.json") +render_to_dir( + render=partial(renderer.render_fhir, "AllergyIntolerance"), + from_file=from_file, + to_dir=stu3_data_out_dir, +) diff --git a/tests/data/stu3/Immunization.json b/tests/data/stu3/Immunization.json new file mode 100644 index 0000000..5178a62 --- /dev/null +++ b/tests/data/stu3/Immunization.json @@ -0,0 +1,157 @@ +{ + "resourceType": "Immunization", + "id": "example", + "text": { + "status": "generated", + "div": "

Generated Narrative with Details

id: example

identifier: urn:oid:1.3.6.1.4.1.21367.2005.3.7.1234

status: completed

notGiven: false

vaccineCode: Fluvax (Influenza) (Details : {urn:oid:1.2.36.1.2001.1005.17 code 'FLUVAX' = 'Fluvax)

patient: Patient/example

encounter: Encounter/example

date: 10/01/2013

primarySource: true

location: Location/1

manufacturer: Organization/hl7

lotNumber: AAJN11K

expirationDate: 15/02/2015

site: left arm (Details : {http://hl7.org/fhir/v3/ActSite code 'LA' = 'left arm', given as 'left arm'})

route: Injection, intramuscular (Details : {http://hl7.org/fhir/v3/RouteOfAdministration code 'IM' = 'Injection, intramuscular', given as 'Injection, intramuscular'})

doseQuantity: 5 mg (Details: UCUM code mg = 'mg')

practitioner

role: Ordering Provider (Details : {http://hl7.org/fhir/v2/0443 code 'OP' = 'Ordering Provider)

actor: Practitioner/example

practitioner

role: Administering Provider (Details : {http://hl7.org/fhir/v2/0443 code 'AP' = 'Administering Provider)

actor: Practitioner/example

note: Notes on adminstration of vaccine

Explanations

-Reason
*Procedure to meet occupational requirement (Details : {SNOMED CT code '429060002' = 'Procedure to meet occupational requirement)

Reactions

-DateDetailReported
*10/01/2013Observation/exampletrue

VaccinationProtocols

-DoseSequenceDescriptionAuthoritySeriesSeriesDosesTargetDiseaseDoseStatusDoseStatusReason
*1Vaccination Protocol Sequence 1Organization/hl7Vaccination Series 12Gestational rubella syndrome (Details : {SNOMED CT code '1857005' = 'Gestational rubella syndrome)Counts (Details : {http://hl7.org/fhir/vaccination-protocol-dose-status code 'count' = 'Counts', given as 'Counts'})Cold chain break (Details : {http://hl7.org/fhir/vaccination-protocol-dose-status-reason code 'coldchbrk' = 'Cold chain break', given as 'Cold chain break'})
" + }, + "identifier": [ + { + "system": "urn:ietf:rfc:3986", + "value": "urn:oid:1.3.6.1.4.1.21367.2005.3.7.1234" + } + ], + "status": "completed", + "notGiven": false, + "vaccineCode": { + "coding": [ + { + "system": "urn:oid:1.2.36.1.2001.1005.17", + "code": "FLUVAX" + } + ], + "text": "Fluvax (Influenza)" + }, + "patient": { + "reference": "Patient/example" + }, + "encounter": { + "reference": "Encounter/example" + }, + "date": "2017-01-01T00:00:00.000Z", + "primarySource": true, + "location": { + "reference": "Location/1" + }, + "manufacturer": { + "reference": "Organization/hl7" + }, + "lotNumber": "AAJN11K", + "expirationDate": "2015-02-15", + "site": { + "coding": [ + { + "system": "http://hl7.org/fhir/v3/ActSite", + "code": "LA", + "display": "left arm" + } + ] + }, + "route": { + "coding": [ + { + "system": "http://hl7.org/fhir/v3/RouteOfAdministration", + "code": "IM", + "display": "Injection, intramuscular" + } + ] + }, + "doseQuantity": { + "value": 5, + "system": "http://unitsofmeasure.org", + "code": "mg" + }, + "practitioner": [ + { + "role": { + "coding": [ + { + "system": "http://hl7.org/fhir/v2/0443", + "code": "OP" + } + ] + }, + "actor": { + "reference": "Practitioner/example" + } + }, + { + "role": { + "coding": [ + { + "system": "http://hl7.org/fhir/v2/0443", + "code": "AP" + } + ] + }, + "actor": { + "reference": "Practitioner/example" + } + } + ], + "note": [ + { + "text": "Notes on adminstration of vaccine" + } + ], + "explanation": { + "reason": [ + { + "coding": [ + { + "system": "http://snomed.info/sct", + "code": "429060002" + } + ] + } + ] + }, + "reaction": [ + { + "date": "2013-01-10", + "detail": { + "reference": "Observation/example" + }, + "reported": true + } + ], + "vaccinationProtocol": [ + { + "doseSequence": 1, + "description": "Vaccination Protocol Sequence 1", + "authority": { + "reference": "Organization/hl7" + }, + "series": "Vaccination Series 1", + "seriesDoses": 2, + "targetDisease": [ + { + "coding": [ + { + "system": "http://snomed.info/sct", + "code": "1857005" + } + ] + } + ], + "doseStatus": { + "coding": [ + { + "system": "http://hl7.org/fhir/vaccination-protocol-dose-status", + "code": "count", + "display": "Counts" + } + ] + }, + "doseStatusReason": { + "coding": [ + { + "system": "http://hl7.org/fhir/vaccination-protocol-dose-status-reason", + "code": "coldchbrk", + "display": "Cold chain break" + } + ] + } + } + ] +} \ No newline at end of file diff --git a/tests/data/stu3/Person.json b/tests/data/stu3/Person.json new file mode 100644 index 0000000..ccf6e1e --- /dev/null +++ b/tests/data/stu3/Person.json @@ -0,0 +1,88 @@ +{ + "resourceType": "Person", + "id": "example", + "text": { + "status": "generated", + "div": "
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
NamePeter James Chalmers ("Jim")
Address534 Erewhon, Pleasantville, Vic, 3999
ContactsHome: unknown. Work: (03) 5555 6473
IdMRN: 12345 (Acme Healthcare)
\n
" + }, + "identifier": [ + { + "use": "usual", + "type": { + "coding": [ + { + "system": "http://hl7.org/fhir/v2/0203", + "code": "MR" + } + ] + }, + "system": "urn:oid:1.2.36.146.595.217.0.1", + "value": "12345", + "period": { + "start": "2001-05-06" + }, + "assigner": { + "display": "Acme Healthcare" + } + } + ], + "name": [ + { + "use": "official", + "family": "Chalmers", + "given": [ + "Peter", + "James" + ] + }, + { + "use": "usual", + "given": [ + "Jim" + ] + } + ], + "telecom": [ + { + "use": "home" + }, + { + "system": "phone", + "value": "(03) 5555 6473", + "use": "work" + }, + { + "system": "email", + "value": "Jim@example.org", + "use": "home" + } + ], + "gender": "male", + "birthDate": "1974-12-25", + "address": [ + { + "use": "home", + "line": [ + "534 Erewhon St" + ], + "city": "PleasantVille", + "state": "Vic", + "postalCode": "3999" + } + ], + "active": true, + "link": [ + { + "target": { + "reference": "RelatedPerson/peter", + "display": "Peter Chalmers" + } + }, + { + "target": { + "reference": "Patient/example", + "display": "Peter Chalmers" + } + } + ] +} \ No newline at end of file diff --git a/tests/test_filters.py b/tests/test_filters.py index 26d853a..c65d59a 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -1,5 +1,5 @@ from base64 import b64decode -from datetime import timezone +from datetime import datetime, timezone from unittest import TestCase from zlib import decompress @@ -25,15 +25,15 @@ class FilterTest: def setup_template(self, **kwargs) -> None: Environment.output_stream_limit = None - env = Environment(strict_filters=True, **kwargs) - register_filters(env, all_filters) - - self.template = self.template.strip() + env = Environment(**kwargs) + register_filters(env, all_filters, replace=True) self.bound_template = env.from_string(self.template) def test_unregistered(self) -> None: with raises(NoSuchFilterFunc): - Environment().from_string(self.template).render() + env = Environment() + env.filters.clear() + env.from_string(self.template).render() class ToJsonStringTest(TestCase, FilterTest): @@ -62,7 +62,7 @@ class ToArrayTest(TestCase, FilterTest): template = """ {% assign keys = el.key | to_array -%} {% for key in keys -%}{{key}},{% endfor -%} - """ + """.strip() def setUp(self) -> None: self.setup_template() @@ -200,6 +200,188 @@ def test(self) -> None: self.assertEqual(result, "2024-01-10T06:35:57.920Z") +class DateTest(TestCase, FilterTest): + template = """{{ dt | date: format }}""" + datetime_with_us = "2014-10-09T11:58:10.001981+08:00" + + def setUp(self) -> None: + self.setup_template() + + def test_undefined(self) -> None: + result = self.bound_template.render() + self.assertEqual(result, "") + + def test_liquid_date_str(self) -> None: + result = self.bound_template.render(dt="March 14, 2016", format="%b %d, %y") + self.assertEqual(result, "Mar 14, 16") + + def test_liquid_datetime(self) -> None: + result = self.bound_template.render( + dt=datetime(2002, 1, 1, 11, 45, 13), format="%a, %b %d, %y" + ) + self.assertEqual(result, "Tue, Jan 01, 02") + + def test_liquid_now(self) -> None: + result = self.bound_template.render(dt="now", format="%Y") + self.assertEqual(result, datetime.now().strftime("%Y")) + + def test_liquid_today(self) -> None: + result = self.bound_template.render(dt="today", format="%Y") + self.assertEqual(result, datetime.now().strftime("%Y")) + + def test_default(self) -> None: + result = self.bound_template.render(dt=self.datetime_with_us) + self.assertEqual(result, "2014-10-09T11:58:10+08:00") + + def test_year(self) -> None: + result = self.bound_template.render(dt=self.datetime_with_us, format="yyyy") + self.assertEqual(result, "2014") + + def test_year_python(self) -> None: + result = self.bound_template.render(dt=self.datetime_with_us, format="%Y") + self.assertEqual(result, "2014") + + def test_month(self) -> None: + result = self.bound_template.render(dt=self.datetime_with_us, format="MM") + self.assertEqual(result, "10") + + def test_month_python(self) -> None: + result = self.bound_template.render(dt=self.datetime_with_us, format="%m") + self.assertEqual(result, "10") + + def test_day(self) -> None: + result = self.bound_template.render(dt=self.datetime_with_us, format="dd") + self.assertEqual(result, "09") + + def test_day_python(self) -> None: + result = self.bound_template.render(dt=self.datetime_with_us, format="%d") + self.assertEqual(result, "09") + + def test_hour(self) -> None: + result = self.bound_template.render(dt=self.datetime_with_us, format="HH") + self.assertEqual(result, "11") + + def test_hour_python(self) -> None: + result = self.bound_template.render(dt=self.datetime_with_us, format="%H") + self.assertEqual(result, "11") + + def test_minute(self) -> None: + result = self.bound_template.render(dt=self.datetime_with_us, format="mm") + self.assertEqual(result, "58") + + def test_minute_python(self) -> None: + result = self.bound_template.render(dt=self.datetime_with_us, format="%M") + self.assertEqual(result, "58") + + def test_second(self) -> None: + result = self.bound_template.render(dt=self.datetime_with_us, format="ss") + self.assertEqual(result, "10") + + def test_second_python(self) -> None: + result = self.bound_template.render(dt=self.datetime_with_us, format="%S") + self.assertEqual(result, "10") + + def test_milli(self) -> None: + result = self.bound_template.render(dt=self.datetime_with_us, format="fff") + self.assertEqual(result, "001") + + def test_micro(self) -> None: + result = self.bound_template.render(dt=self.datetime_with_us, format="ffffff") + self.assertEqual(result, "001981") + + def test_micro_python(self) -> None: + result = self.bound_template.render(dt=self.datetime_with_us, format="%f") + self.assertEqual(result, "001981") + + def test_k_specifier_tz_undefined(self) -> None: + result = self.bound_template.render(dt="2014-10-09T11:58:10", format="%K") + self.assertEqual(result, "") + + def test_k_specifier_tz_offset(self) -> None: + result = self.bound_template.render(dt=self.datetime_with_us, format="%K") + self.assertEqual(result, "+08:00") + + def test_k_specifier_tz_offset_zero(self) -> None: + result = self.bound_template.render(dt="2014-10-09T11:58:10+00:00", format="%K") + self.assertEqual(result, "Z") + + def test_k_specifier_tz_utc(self) -> None: + result = self.bound_template.render(dt="2014-10-09T11:58:10Z", format="%K") + self.assertEqual(result, "Z") + + def test_tz_hour_min_offset(self) -> None: + result = self.bound_template.render(dt=self.datetime_with_us, format="zzz") + self.assertEqual(result, "+08:00") + + def test_tz_hour_min_offset_python(self) -> None: + result = self.bound_template.render(dt=self.datetime_with_us, format="%Z") + self.assertEqual(result, "+08:00") + + def test_tz_hour_offset(self) -> None: + result = self.bound_template.render(dt=self.datetime_with_us, format="zz") + self.assertEqual(result, "+08") + + def test_tz_hour_offset_python(self) -> None: + result = self.bound_template.render(dt=self.datetime_with_us, format="%h") + self.assertEqual(result, "+08") + + def test_year_month(self) -> None: + result = self.bound_template.render(dt=self.datetime_with_us, format="yyyy-MM") + self.assertEqual(result, "2014-10") + + def test_year_month_day(self) -> None: + result = self.bound_template.render(dt=self.datetime_with_us, format="yyyy-MM-dd") + self.assertEqual(result, "2014-10-09") + + def test_year_month_day_hour(self) -> None: + result = self.bound_template.render( + dt=self.datetime_with_us, format="yyyy-MM-ddTHH" + ) + self.assertEqual(result, "2014-10-09T11") + + def test_year_month_day_hour_minute(self) -> None: + result = self.bound_template.render( + dt=self.datetime_with_us, format="yyyy-MM-ddTHH:mm" + ) + self.assertEqual(result, "2014-10-09T11:58") + + def test_year_month_day_hour_minute_second(self) -> None: + result = self.bound_template.render( + dt=self.datetime_with_us, format="yyyy-MM-ddTHH:mm:ss" + ) + self.assertEqual(result, "2014-10-09T11:58:10") + + def test_year_month_day_hour_minute_second_tz(self) -> None: + result = self.bound_template.render( + dt=self.datetime_with_us, format="yyyy-MM-ddTHH:mm:ss%K" + ) + self.assertEqual(result, "2014-10-09T11:58:10+08:00") + + def test_year_month_day_hour_minute_second_milli(self) -> None: + result = self.bound_template.render( + dt=self.datetime_with_us, format="yyyy-MM-ddTHH:mm:ss.fff" + ) + self.assertEqual(result, "2014-10-09T11:58:10.001") + + def test_year_month_day_hour_minute_second_milli_tz(self) -> None: + result = self.bound_template.render( + dt=self.datetime_with_us, format="yyyy-MM-ddTHH:mm:ss.fff%K" + ) + self.assertEqual(result, "2014-10-09T11:58:10.001+08:00") + + def test_year_month_day_hour_minute_second_milli_micro(self) -> None: + result = self.bound_template.render( + dt=self.datetime_with_us, format="yyyy-MM-ddTHH:mm:ss.ffffff" + ) + self.assertEqual(result, "2014-10-09T11:58:10.001981") + + def test_year_month_day_hour_minute_second_milli_micro_tz(self) -> None: + result = self.bound_template.render( + dt=self.datetime_with_us, format="yyyy-MM-ddTHH:mm:ss.ffffff%K" + ) + self.assertEqual(result, "2014-10-09T11:58:10.001981+08:00") + + class NowTest(TestCase, FilterTest): template = """{{ "" | now }}""" @@ -472,7 +654,7 @@ def test_found_flatten_ids(self) -> None: class BatchRenderTest(TestCase, FilterTest): template = """{{ batch | batch_render: template, 'data' }}""" - inner_template = """{{ data }},""" + inner_template = """{{ data }}""" def setUp(self) -> None: self.setup_template(loader=DictLoader({"__template__": self.inner_template})) @@ -495,6 +677,18 @@ def test_batch(self) -> None: ) self.assertEqual(result, "one,two,three,") + def test_batch_with_trailing_comma(self) -> None: + result = self.bound_template.render( + batch=["one,", "two,", "three,"], template="__template__" + ) + self.assertEqual(result, "one,two,three,") + + def test_batch_with_trailing_comma_blank_space_line_endings(self) -> None: + result = self.bound_template.render( + batch=["one, \n", "two, \n\n", "three, \n\n\n"], template="__template__" + ) + self.assertEqual(result, "one, \ntwo, \n\nthree, \n\n\n") + def test_template_not_found(self) -> None: with raises(TemplateNotFound): self.bound_template.render(batch=["one"], template="undefined") diff --git a/tests/test_renderers.py b/tests/test_renderers.py index dd35016..da485c7 100644 --- a/tests/test_renderers.py +++ b/tests/test_renderers.py @@ -1,17 +1,20 @@ from collections.abc import Mapping from io import StringIO from json import loads +from pathlib import Path from unittest import TestCase from liquid import FileExtensionLoader from liquid.utils import LRUCache from pyexpat import ExpatError +from pyjson5 import Json5EOF from pytest import raises from fhir_converter.loaders import TemplateSystemLoader from fhir_converter.renderers import ( CcdaRenderer, RenderingError, + Stu3FhirRenderer, ccda_default_loader, get_environment, ) @@ -64,7 +67,89 @@ def test_additional_loaders(self) -> None: self.assertEqual([loader, ccda_default_loader], env.loader.loaders) # type: ignore +class Stu3FhirRendererTest(TestCase): + stu3_file = Path("tests/data/stu3/Immunization.json") + + def validate_str(self, fhir_str: str) -> None: + self.validate(loads(fhir_str)) + + def validate(self, fhir: Mapping) -> None: + self.assertEqual(fhir["resourceType"], "Immunization") + self.assertEqual(fhir["status"], "completed") + self.assertNotIn("notGiven", fhir) + # TODO validation! + + def test_render_fhir_string_json_error(self) -> None: + with raises(RenderingError, match="Failed to render FHIR") as exc_info: + Stu3FhirRenderer().render_fhir_string("Immunization", "") + self.assertIsInstance(exc_info.value.__cause__, Json5EOF) + + def test_render_fhir_string_text(self) -> None: + self.validate_str( + Stu3FhirRenderer().render_fhir_string( + "Immunization", self.stu3_file.read_text() + ) + ) + + def test_render_fhir_string_bytes(self) -> None: + self.validate_str( + Stu3FhirRenderer().render_fhir_string( + "Immunization", self.stu3_file.read_bytes() + ) + ) + + def test_render_fhir_string_text_io(self) -> None: + with self.stu3_file.open() as fhir_in: + self.validate_str( + Stu3FhirRenderer().render_fhir_string("Immunization", fhir_in) + ) + + def test_render_fhir_string_binary_io(self) -> None: + with self.stu3_file.open("rb") as fhir_in: + self.validate_str( + Stu3FhirRenderer().render_fhir_string("Immunization", fhir_in) + ) + + def test_render_to_fhir_json_error(self) -> None: + with raises(RenderingError, match="Failed to render FHIR") as exc_info: + Stu3FhirRenderer().render_to_fhir("Immunization", "") + self.assertIsInstance(exc_info.value.__cause__, Json5EOF) + + def test_render_to_fhir_text(self) -> None: + self.validate( + Stu3FhirRenderer().render_to_fhir("Immunization", self.stu3_file.read_text()) + ) + + def test_render_to_fhir_bytes(self) -> None: + self.validate( + Stu3FhirRenderer().render_to_fhir("Immunization", self.stu3_file.read_bytes()) + ) + + def test_render_to_fhir_text_io(self) -> None: + with self.stu3_file.open() as fhir_in: + self.validate(Stu3FhirRenderer().render_to_fhir("Immunization", fhir_in)) + + def test_render_to_fhir_binary_io(self) -> None: + with self.stu3_file.open("rb") as fhir_in: + self.validate(Stu3FhirRenderer().render_to_fhir("Immunization", fhir_in)) + + def test_render_fhir_serialize_error(self) -> None: + buffer = StringIO() + buffer.close() + + with raises(RenderingError, match="Failed to serialize FHIR") as exc_info: + with self.stu3_file.open() as fhir_in: + Stu3FhirRenderer().render_fhir("Immunization", fhir_in, buffer) + self.assertIsInstance(exc_info.value.__cause__, ValueError) + self.assertEqual(str(exc_info.value.__cause__), "I/O operation on closed file") + + class CcdaRendererTest(TestCase): + ccda_file = Path("tests/data/ccda/CCD.ccda") + + def validate_str(self, fhir_str: str) -> None: + self.validate(loads(fhir_str)) + def validate(self, fhir: Mapping) -> None: self.assertEqual(fhir["resourceType"], "Bundle") self.assertEqual(fhir["type"], "batch") @@ -76,17 +161,23 @@ def test_render_fhir_string_xml_error(self) -> None: CcdaRenderer().render_fhir_string("CCD", "") self.assertIsInstance(exc_info.value.__cause__, ExpatError) - def test_render_fhir_string_text_str(self) -> None: - with open("tests/data/ccda/CCD.ccda") as xml_in: - self.validate(loads(CcdaRenderer().render_fhir_string("CCD", xml_in.read()))) - def test_render_fhir_string_text(self) -> None: - with open("tests/data/ccda/CCD.ccda") as xml_in: - self.validate(loads(CcdaRenderer().render_fhir_string("CCD", xml_in))) + self.validate_str( + CcdaRenderer().render_fhir_string("CCD", self.ccda_file.read_text()) + ) + + def test_render_fhir_string_bytes(self) -> None: + self.validate_str( + CcdaRenderer().render_fhir_string("CCD", self.ccda_file.read_bytes()) + ) + + def test_render_fhir_string_text_io(self) -> None: + with self.ccda_file.open() as xml_in: + self.validate_str(CcdaRenderer().render_fhir_string("CCD", xml_in)) - def test_render_fhir_string_binary(self) -> None: - with open("tests/data/ccda/CCD.ccda", "rb") as xml_in: - self.validate(loads(CcdaRenderer().render_fhir_string("CCD", xml_in))) + def test_render_fhir_string_binary_io(self) -> None: + with self.ccda_file.open("rb") as xml_in: + self.validate_str(CcdaRenderer().render_fhir_string("CCD", xml_in)) def test_render_to_fhir_xml_error(self) -> None: with raises(RenderingError, match="Failed to render FHIR") as exc_info: @@ -96,16 +187,18 @@ def test_render_to_fhir_xml_error(self) -> None: str(exc_info.value.__cause__), "no element found: line 1, column 0" ) - def test_render_to_fhir_text_str(self) -> None: - with open("tests/data/ccda/CCD.ccda") as xml_in: - self.validate(CcdaRenderer().render_to_fhir("CCD", xml_in.read())) - def test_render_to_fhir_text(self) -> None: - with open("tests/data/ccda/CCD.ccda") as xml_in: + self.validate(CcdaRenderer().render_to_fhir("CCD", self.ccda_file.read_text())) + + def test_render_to_fhir_bytes(self) -> None: + self.validate(CcdaRenderer().render_to_fhir("CCD", self.ccda_file.read_bytes())) + + def test_render_to_fhir_text_io(self) -> None: + with self.ccda_file.open() as xml_in: self.validate(CcdaRenderer().render_to_fhir("CCD", xml_in)) - def test_render_to_fhir_binary(self) -> None: - with open("tests/data/ccda/CCD.ccda", "rb") as xml_in: + def test_render_to_fhir_binary_io(self) -> None: + with self.ccda_file.open("rb") as xml_in: self.validate(CcdaRenderer().render_to_fhir("CCD", xml_in)) def test_render_fhir_serialize_error(self) -> None: @@ -113,7 +206,7 @@ def test_render_fhir_serialize_error(self) -> None: buffer.close() with raises(RenderingError, match="Failed to serialize FHIR") as exc_info: - with open("tests/data/ccda/CCD.ccda") as xml_in: + with self.ccda_file.open() as xml_in: CcdaRenderer().render_fhir("CCD", xml_in, buffer) self.assertIsInstance(exc_info.value.__cause__, ValueError) self.assertEqual(str(exc_info.value.__cause__), "I/O operation on closed file") diff --git a/tests/test_tags.py b/tests/test_tags.py index c706938..8ab817c 100644 --- a/tests/test_tags.py +++ b/tests/test_tags.py @@ -1,12 +1,162 @@ +from typing import Optional from unittest import TestCase from liquid import BoundTemplate, DictLoader, Environment from liquid.ast import ChildNode from liquid.exceptions import LiquidSyntaxError, TemplateNotFound from liquid.expression import Identifier, IdentifierPathElement, StringLiteral +from liquid.loaders import BaseLoader +from pyjson5 import Json5Exception from pytest import raises -from fhir_converter.tags import EvaluateNode, all_tags, register_tags +from fhir_converter.tags import EvaluateNode, MergeDiffNode, all_tags, register_tags + + +def get_template( + source: str, + register: bool = True, + loader: Optional[BaseLoader] = None, +) -> BoundTemplate: + env = Environment(loader=loader) + if register: + register_tags(env, all_tags) + return env.from_string(source) + + +class MergeDiffTest(TestCase): + missing_endmerge = "{% mergeDiff var -%}" + missing_identifier = "{% mergeDiff -%}{% endmergeDiff -%}" + block = "{% mergeDiff var -%}{{block}}{% endmergeDiff -%}" + + def test_unregistered(self) -> None: + with raises(LiquidSyntaxError, match="unexpected tag 'mergeDiff'"): + get_template(source=self.block, register=False).render() + + def test_missing_endmerge(self) -> None: + with raises(LiquidSyntaxError, match="expected tag with value 'endmergeDiff'"): + get_template(source=self.missing_endmerge).render() + + def test_missing_identifier(self) -> None: + with raises(LiquidSyntaxError, match="expected 'expression', found 'tag'"): + get_template(source=self.missing_identifier).render() + + def test_invalid(self) -> None: + with raises(Json5Exception): + template = get_template(source=self.block) + template.render(var={"test": "ok"}, block="{test:ok}") + + def test_empty(self) -> None: + template = get_template(source=self.block) + self.assertEqual(template.render(var={"test": "ok"}, block=""), '{"test":"ok"}') + + def test_space(self) -> None: + template = get_template(source=self.block) + self.assertEqual(template.render(var={"test": "ok"}, block=" "), '{"test":"ok"}') + + def test_empty_quote(self) -> None: + template = get_template(source=self.block) + self.assertEqual(template.render(var={"test": "ok"}, block='""'), '{"test":"ok"}') + + def test_str(self) -> None: + template = get_template(source=self.block) + self.assertEqual( + template.render(var={"test": "ok"}, block='"failed"'), + '{"test":"ok"}', + ) + + def test_variable_undefined(self) -> None: + template = get_template(source=self.block) + self.assertEqual(template.render(block={"test": "ok"}), "{}") + + def test_variable_str(self) -> None: + template = get_template(source=self.block) + self.assertEqual(template.render(var="ok", block={"test": "ok"}), '"ok"') + + def test_add(self) -> None: + template = get_template(source=self.block) + self.assertEqual(len(template.tree.statements), 1) + + node = template.tree.statements[0] + self.assertIsInstance(node, MergeDiffNode) + + self.assertEqual( + repr(node), + "MergeDiff(tok=Token(linenum=1, type='tag', value='mergeDiff') identifier=var)", + ) + self.assertEqual(str(node), "mergeDiff var { `block` }") + self.assertTrue(len(node.children()) > 0) + self.assertEqual(template.render(var={}, block={"test": "add"}), '{"test":"add"}') + + def test_update(self) -> None: + template = get_template(source=self.block) + self.assertEqual( + template.render(var={"test": "ok"}, block={"test": "update"}), + '{"test":"update"}', + ) + + def test_remove(self) -> None: + template = get_template(source=self.block) + self.assertEqual( + template.render(var={"test": "ok"}, block={"test": ""}), '{"test":""}' + ) + + def test_empty_dict(self) -> None: + template = get_template(source=self.block) + self.assertEqual(template.render(var={"test": "ok"}, block={}), '{"test":"ok"}') + + def test_empty_dicts(self) -> None: + template = get_template(source=self.block) + self.assertEqual(template.render(var={}, block={}), "{}") + + def test_choice_update(self) -> None: + template = get_template(source=self.block) + self.assertEqual( + template.render(var={"test_first": "ok"}, block={"test[x]": "update"}), + '{"test_first":"update"}', + ) + + def test_choice_update_first(self) -> None: + template = get_template(source=self.block) + self.assertEqual( + template.render( + var={"test_first": "ok", "test_second": "failed"}, + block={"test[x]": "update"}, + ), + '{"test_first":"update","test_second":"failed"}', + ) + + def test_choice_remove(self) -> None: + template = get_template(source=self.block) + self.assertEqual( + template.render(var={"test_first": "ok"}, block={"test[x]": ""}), + '{"test_first":""}', + ) + + def test_choice_remove_first(self) -> None: + template = get_template(source=self.block) + self.assertEqual( + template.render( + var={"test_first": "ok", "test_second": "failed"}, block={"test[x]": ""} + ), + '{"test_first":"","test_second":"failed"}', + ) + + def test_choice_remove_multiple(self) -> None: + template = get_template(source=self.block) + self.assertEqual( + template.render( + var={"test_first": "ok", "test_second": "failed"}, + block={"test_f[x]": "", "test_s[x]": ""}, + ), + '{"test_first":"","test_second":""}', + ) + + def test_choice_ignore(self) -> None: + template = get_template(source=self.block) + self.assertEqual( + template.render(var={"other": "unknown"}, block={"test[x]": "ok"}), + '{"other":"unknown"}', + ) class EvaluateTest(TestCase): @@ -25,30 +175,24 @@ class EvaluateTest(TestCase): } ) - def get_template(self, source: str, register: bool = True) -> BoundTemplate: - env = Environment(loader=self.loader) - if register: - register_tags(env, all_tags) - return env.from_string(source) - def test_unregistered(self) -> None: with raises(LiquidSyntaxError): - self.get_template(source=self.no_arg, register=False).render() + get_template(source=self.no_arg, register=False).render() def test_template_not_found(self) -> None: with raises(TemplateNotFound): - self.get_template(source=self.not_found).render() + get_template(source=self.not_found).render() def test_missing_keyword(self) -> None: with raises(LiquidSyntaxError): - self.get_template(source=self.missing_keyword).render() + get_template(source=self.missing_keyword).render() def test_missing_comma(self) -> None: with raises(LiquidSyntaxError): - self.get_template(source=self.missing_comma).render(val1="test", val2="ok") + get_template(source=self.missing_comma).render(val1="test", val2="ok") def test_no_arg(self) -> None: - template = self.get_template(source=self.no_arg) + template = get_template(source=self.no_arg, loader=self.loader) self.assertEqual(len(template.tree.statements), 2) node = template.tree.statements[0] @@ -75,7 +219,7 @@ def test_no_arg(self) -> None: self.assertEqual(template.render(), "ok") def test_single_arg(self) -> None: - template = self.get_template(source=self.single_arg) + template = get_template(source=self.single_arg, loader=self.loader) self.assertEqual(len(template.tree.statements), 2) node = template.tree.statements[0] @@ -102,7 +246,7 @@ def test_single_arg(self) -> None: self.assertEqual(template.render(val="test"), "test") def test_multiple_args(self) -> None: - template = self.get_template(source=self.multi_arg) + template = get_template(source=self.multi_arg, loader=self.loader) self.assertEqual(len(template.tree.statements), 2) node = template.tree.statements[0] diff --git a/tests/test_utils.py b/tests/test_utils.py index f97545a..8ddac9d 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,4 +1,6 @@ +from io import BytesIO, StringIO from pathlib import Path +from typing import Mapping from unittest import TestCase from unittest.mock import patch @@ -17,6 +19,7 @@ mkdir, parse_json, parse_xml, + tail, to_list_or_empty, walk_path, ) @@ -187,6 +190,12 @@ def test_ignore_empty_list(self) -> None: class ParseJsonTest(TestCase): + stu3_file = Path("tests/data/stu3/Person.json") + + def validate_fhir(self, fhir: Mapping) -> None: + self.assertIn("gender", fhir) + self.assertEqual("male", fhir["gender"]) + def test_empty(self) -> None: with raises(Json5EOF): parse_json("") @@ -256,41 +265,74 @@ def test_dict_ignore_lead_trail_spaces(self) -> None: parse_json(' {"name": [{"family": "Relative","given": ["Ralph"]}]} '), ) + def test_include_empty_fields(self) -> None: + self.assertEqual( + {"name": [{"family": "", "given": [""]}]}, + parse_json( + '{"name": [{"family": "","given": [""]}]}', ignore_empty_fields=False + ), + ) + + def test_text(self) -> None: + self.validate_fhir(parse_json(self.stu3_file.read_text())) + + def test_bytes(self) -> None: + self.validate_fhir(parse_json(self.stu3_file.read_bytes())) + + def test_text_io(self) -> None: + with self.stu3_file.open() as stu3_in: + self.validate_fhir(parse_json(stu3_in)) + + def test_binary_io(self) -> None: + with self.stu3_file.open("rb") as stu3_in: + self.validate_fhir(parse_json(stu3_in)) + class ParseXmlTest(TestCase): - def test_empty_str(self) -> None: + ccda_file = Path("tests/data/ccda/CCD.ccda") + empty_file = Path("tests/data/bad_data/empty.ccda") + + def validate_ccda(self, xml: Mapping) -> None: + self.assertIn("ClinicalDocument", xml) + self.assertIsNotNone( + get_ccda_section(xml, search_template_ids="2.16.840.1.113883.10.20.22.2.6.1") + ) + + def test_empty_text(self) -> None: with raises(ExpatError): parse_xml("") - def test_blank_str(self) -> None: + def test_blank_text(self) -> None: with raises(ExpatError): parse_xml(" ") - def test_empty_file(self) -> None: + def test_empty_bytes(self) -> None: with raises(ExpatError): - with Path("tests/data/bad_data/empty.ccda").open() as xml_in: + parse_xml(bytes()) + + def test_empty_text_io(self) -> None: + with raises(ExpatError): + with self.empty_file.open() as xml_in: parse_xml(xml_in) - def test_empty_file_binary(self) -> None: + def test_empty_binary_io(self) -> None: with raises(ExpatError): - with Path("tests/data/bad_data/empty.ccda").open("rb") as xml_in: + with self.empty_file.open("rb") as xml_in: parse_xml(xml_in) - def test_file(self) -> None: - with Path("tests/data/ccda/CCD.ccda").open() as xml_in: - xml = parse_xml(xml_in) - self.assertIn("ClinicalDocument", xml) - self.assertIsNotNone( - get_ccda_section(xml, search_template_ids="2.16.840.1.113883.10.20.22.2.6.1") - ) + def test_text(self) -> None: + self.validate_ccda(parse_xml(self.ccda_file.read_text())) - def test_file_binary(self) -> None: - with Path("tests/data/ccda/CCD.ccda").open("rb") as xml_in: - xml = parse_xml(xml_in) - self.assertIn("ClinicalDocument", xml) - self.assertIsNotNone( - get_ccda_section(xml, search_template_ids="2.16.840.1.113883.10.20.22.2.6.1") - ) + def test_bytes(self) -> None: + self.validate_ccda(parse_xml(self.ccda_file.read_bytes())) + + def test_text_io(self) -> None: + with self.ccda_file.open() as xml_in: + self.validate_ccda(parse_xml(xml_in)) + + def test_binary_io(self) -> None: + with self.ccda_file.open("rb") as xml_in: + self.validate_ccda(parse_xml(xml_in)) class JoinSubpathTest(TestCase): @@ -483,3 +525,43 @@ def test_walk_path(self) -> None: with raises(StopIteration): next(walk) + + +class TailTest(TestCase): + def test_empty_text(self) -> None: + buffer = StringIO() + self.assertEqual("", tail(buffer)) + + def test_empty_bytes(self) -> None: + buffer = BytesIO() + self.assertEqual("", tail(buffer)) + + def test_read_all_text(self) -> None: + buffer = StringIO() + buffer.write("This is a test.") + self.assertEqual("This is a test.", tail(buffer)) + + def test_read_last_n_text(self) -> None: + buffer = StringIO() + buffer.write("This is a test.") + self.assertEqual("st.", tail(buffer, last_n=3)) + + def test_read_last_n_is_negative(self) -> None: + buffer = StringIO() + buffer.write("This is a test.") + self.assertEqual("", tail(buffer, last_n=-3)) + + def test_read_last_n_is_zero(self) -> None: + buffer = StringIO() + buffer.write("This is a test.") + self.assertEqual("", tail(buffer, last_n=0)) + + def test_read_all_bytes(self) -> None: + buffer = BytesIO() + buffer.write(b"This is a test.") + self.assertEqual("This is a test.", tail(buffer)) + + def test_read_last_n_bytes(self) -> None: + buffer = BytesIO() + buffer.write(b"This is a test.") + self.assertEqual("st.", tail(buffer, last_n=3))