001package org.hl7.fhir.convertors.conv30_40.resources30_40; 002 003import java.util.Arrays; 004 005import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_40; 006import org.hl7.fhir.convertors.context.ConversionContext30_40; 007import org.hl7.fhir.convertors.conv30_40.datatypes30_40.Extension30_40; 008import org.hl7.fhir.convertors.conv30_40.datatypes30_40.Meta30_40; 009import org.hl7.fhir.convertors.conv30_40.datatypes30_40.Narrative30_40; 010import org.hl7.fhir.exceptions.FHIRException; 011 012public class Resource30_40 { 013 014 public final BaseAdvisor_30_40 advisor; 015 016 public Resource30_40(BaseAdvisor_30_40 advisor) { 017 this.advisor = advisor; 018 } 019 020 public void copyResource(org.hl7.fhir.dstu3.model.Resource src, org.hl7.fhir.r4.model.Resource tgt) throws FHIRException { 021 if (src.hasId()) tgt.setId(src.getId()); 022 if (src.hasMeta()) tgt.setMeta(Meta30_40.convertMeta(src.getMeta())); 023 if (src.hasImplicitRules()) tgt.setImplicitRules(src.getImplicitRules()); 024 if (src.hasLanguage()) tgt.setLanguage(src.getLanguage()); 025 } 026 027 public void copyResource(org.hl7.fhir.r4.model.Resource src, org.hl7.fhir.dstu3.model.Resource tgt) throws FHIRException { 028 if (src.hasId()) tgt.setId(src.getId()); 029 if (src.hasMeta()) tgt.setMeta(Meta30_40.convertMeta(src.getMeta())); 030 if (src.hasImplicitRules()) tgt.setImplicitRules(src.getImplicitRules()); 031 if (src.hasLanguage()) tgt.setLanguage(src.getLanguage()); 032 } 033 034 public org.hl7.fhir.r4.model.Resource convertResource(org.hl7.fhir.dstu3.model.Resource src) throws FHIRException { 035 return convertResource(src, new BaseAdvisor_30_40()); 036 } 037 038 public org.hl7.fhir.r4.model.Resource convertResource(org.hl7.fhir.dstu3.model.Resource src, BaseAdvisor_30_40 advisor) throws FHIRException { 039 if (src == null) return null; 040 if (src instanceof org.hl7.fhir.dstu3.model.Parameters) 041 return Parameters30_40.convertParameters((org.hl7.fhir.dstu3.model.Parameters) src); 042 if (src instanceof org.hl7.fhir.dstu3.model.Account) 043 return Account30_40.convertAccount((org.hl7.fhir.dstu3.model.Account) src); 044 if (src instanceof org.hl7.fhir.dstu3.model.ActivityDefinition) 045 return ActivityDefinition30_40.convertActivityDefinition((org.hl7.fhir.dstu3.model.ActivityDefinition) src); 046 if (src instanceof org.hl7.fhir.dstu3.model.AllergyIntolerance) 047 return AllergyIntolerance30_40.convertAllergyIntolerance((org.hl7.fhir.dstu3.model.AllergyIntolerance) src); 048 if (src instanceof org.hl7.fhir.dstu3.model.Appointment) 049 return Appointment30_40.convertAppointment((org.hl7.fhir.dstu3.model.Appointment) src); 050 if (src instanceof org.hl7.fhir.dstu3.model.AppointmentResponse) 051 return AppointmentResponse30_40.convertAppointmentResponse((org.hl7.fhir.dstu3.model.AppointmentResponse) src); 052 if (src instanceof org.hl7.fhir.dstu3.model.AuditEvent) 053 return AuditEvent30_40.convertAuditEvent((org.hl7.fhir.dstu3.model.AuditEvent) src); 054 if (src instanceof org.hl7.fhir.dstu3.model.Basic) 055 return Basic30_40.convertBasic((org.hl7.fhir.dstu3.model.Basic) src); 056 if (src instanceof org.hl7.fhir.dstu3.model.Binary) 057 return Binary30_40.convertBinary((org.hl7.fhir.dstu3.model.Binary) src); 058 if (src instanceof org.hl7.fhir.dstu3.model.BodySite) 059 return BodySite30_40.convertBodySite((org.hl7.fhir.dstu3.model.BodySite) src); 060 if (src instanceof org.hl7.fhir.dstu3.model.Bundle) 061 return Bundle30_40.convertBundle((org.hl7.fhir.dstu3.model.Bundle) src); 062 if (src instanceof org.hl7.fhir.dstu3.model.CapabilityStatement) 063 return CapabilityStatement30_40.convertCapabilityStatement((org.hl7.fhir.dstu3.model.CapabilityStatement) src); 064 if (src instanceof org.hl7.fhir.dstu3.model.CarePlan) 065 return CarePlan30_40.convertCarePlan((org.hl7.fhir.dstu3.model.CarePlan) src); 066 if (src instanceof org.hl7.fhir.dstu3.model.CareTeam) 067 return CareTeam30_40.convertCareTeam((org.hl7.fhir.dstu3.model.CareTeam) src); 068 if (src instanceof org.hl7.fhir.dstu3.model.ClinicalImpression) 069 return ClinicalImpression30_40.convertClinicalImpression((org.hl7.fhir.dstu3.model.ClinicalImpression) src); 070 if (src instanceof org.hl7.fhir.dstu3.model.CodeSystem) 071 return CodeSystem30_40.convertCodeSystem((org.hl7.fhir.dstu3.model.CodeSystem) src); 072 if (src instanceof org.hl7.fhir.dstu3.model.Communication) 073 return Communication30_40.convertCommunication((org.hl7.fhir.dstu3.model.Communication) src); 074 if (src instanceof org.hl7.fhir.dstu3.model.CompartmentDefinition) 075 return CompartmentDefinition30_40.convertCompartmentDefinition((org.hl7.fhir.dstu3.model.CompartmentDefinition) src); 076 if (src instanceof org.hl7.fhir.dstu3.model.Composition) 077 return Composition30_40.convertComposition((org.hl7.fhir.dstu3.model.Composition) src); 078 if (src instanceof org.hl7.fhir.dstu3.model.ConceptMap) 079 return ConceptMap30_40.convertConceptMap((org.hl7.fhir.dstu3.model.ConceptMap) src); 080 if (src instanceof org.hl7.fhir.dstu3.model.Condition) 081 return Condition30_40.convertCondition((org.hl7.fhir.dstu3.model.Condition) src); 082 if (src instanceof org.hl7.fhir.dstu3.model.Consent) 083 return Consent30_40.convertConsent((org.hl7.fhir.dstu3.model.Consent) src); 084 if (src instanceof org.hl7.fhir.dstu3.model.Coverage) 085 return Coverage30_40.convertCoverage((org.hl7.fhir.dstu3.model.Coverage) src); 086 if (src instanceof org.hl7.fhir.dstu3.model.DataElement) 087 return DataElement30_40.convertDataElement((org.hl7.fhir.dstu3.model.DataElement) src); 088 if (src instanceof org.hl7.fhir.dstu3.model.DetectedIssue) 089 return DetectedIssue30_40.convertDetectedIssue((org.hl7.fhir.dstu3.model.DetectedIssue) src); 090 if (src instanceof org.hl7.fhir.dstu3.model.DeviceUseStatement) 091 return DeviceUseStatement30_40.convertDeviceUseStatement((org.hl7.fhir.dstu3.model.DeviceUseStatement) src); 092 if (src instanceof org.hl7.fhir.dstu3.model.DiagnosticReport) 093 return DiagnosticReport30_40.convertDiagnosticReport((org.hl7.fhir.dstu3.model.DiagnosticReport) src); 094 if (src instanceof org.hl7.fhir.dstu3.model.DocumentReference) 095 return DocumentReference30_40.convertDocumentReference((org.hl7.fhir.dstu3.model.DocumentReference) src); 096 if (src instanceof org.hl7.fhir.dstu3.model.Encounter) 097 return Encounter30_40.convertEncounter((org.hl7.fhir.dstu3.model.Encounter) src); 098 if (src instanceof org.hl7.fhir.dstu3.model.Endpoint) 099 return Endpoint30_40.convertEndpoint((org.hl7.fhir.dstu3.model.Endpoint) src); 100 if (src instanceof org.hl7.fhir.dstu3.model.EpisodeOfCare) 101 return EpisodeOfCare30_40.convertEpisodeOfCare((org.hl7.fhir.dstu3.model.EpisodeOfCare) src); 102 if (src instanceof org.hl7.fhir.dstu3.model.ExpansionProfile) 103 return ExpansionProfile30_40.convertExpansionProfile((org.hl7.fhir.dstu3.model.ExpansionProfile) src); 104 if (src instanceof org.hl7.fhir.dstu3.model.FamilyMemberHistory) 105 return FamilyMemberHistory30_40.convertFamilyMemberHistory((org.hl7.fhir.dstu3.model.FamilyMemberHistory) src); 106 if (src instanceof org.hl7.fhir.dstu3.model.Flag) return Flag30_40.convertFlag((org.hl7.fhir.dstu3.model.Flag) src); 107 if (src instanceof org.hl7.fhir.dstu3.model.Goal) return Goal30_40.convertGoal((org.hl7.fhir.dstu3.model.Goal) src); 108 if (src instanceof org.hl7.fhir.dstu3.model.GraphDefinition) 109 return GraphDefinition30_40.convertGraphDefinition((org.hl7.fhir.dstu3.model.GraphDefinition) src); 110 if (src instanceof org.hl7.fhir.dstu3.model.Group) 111 return Group30_40.convertGroup((org.hl7.fhir.dstu3.model.Group) src); 112 if (src instanceof org.hl7.fhir.dstu3.model.HealthcareService) 113 return HealthcareService30_40.convertHealthcareService((org.hl7.fhir.dstu3.model.HealthcareService) src); 114 if (src instanceof org.hl7.fhir.dstu3.model.ImagingStudy) 115 return ImagingStudy30_40.convertImagingStudy((org.hl7.fhir.dstu3.model.ImagingStudy) src); 116 if (src instanceof org.hl7.fhir.dstu3.model.Immunization) 117 return Immunization30_40.convertImmunization((org.hl7.fhir.dstu3.model.Immunization) src); 118 if (src instanceof org.hl7.fhir.dstu3.model.ImplementationGuide) 119 return ImplementationGuide30_40.convertImplementationGuide((org.hl7.fhir.dstu3.model.ImplementationGuide) src); 120 if (src instanceof org.hl7.fhir.dstu3.model.Library) 121 return Library30_40.convertLibrary((org.hl7.fhir.dstu3.model.Library) src); 122 if (src instanceof org.hl7.fhir.dstu3.model.Linkage) 123 return Linkage30_40.convertLinkage((org.hl7.fhir.dstu3.model.Linkage) src); 124 if (src instanceof org.hl7.fhir.dstu3.model.ListResource) 125 return List30_40.convertList((org.hl7.fhir.dstu3.model.ListResource) src); 126 if (src instanceof org.hl7.fhir.dstu3.model.Location) 127 return Location30_40.convertLocation((org.hl7.fhir.dstu3.model.Location) src); 128 if (src instanceof org.hl7.fhir.dstu3.model.Media) 129 return Media30_40.convertMedia((org.hl7.fhir.dstu3.model.Media) src); 130 if (src instanceof org.hl7.fhir.dstu3.model.Medication) 131 return Medication30_40.convertMedication((org.hl7.fhir.dstu3.model.Medication) src); 132 if (src instanceof org.hl7.fhir.dstu3.model.MedicationAdministration) 133 return MedicationAdministration30_40.convertMedicationAdministration((org.hl7.fhir.dstu3.model.MedicationAdministration) src); 134 if (src instanceof org.hl7.fhir.dstu3.model.MedicationDispense) 135 return MedicationDispense30_40.convertMedicationDispense((org.hl7.fhir.dstu3.model.MedicationDispense) src); 136 if (src instanceof org.hl7.fhir.dstu3.model.MedicationRequest) 137 return MedicationRequest30_40.convertMedicationRequest((org.hl7.fhir.dstu3.model.MedicationRequest) src); 138 if (src instanceof org.hl7.fhir.dstu3.model.MedicationStatement) 139 return MedicationStatement30_40.convertMedicationStatement((org.hl7.fhir.dstu3.model.MedicationStatement) src); 140 if (src instanceof org.hl7.fhir.dstu3.model.MessageDefinition) 141 return MessageDefinition30_40.convertMessageDefinition((org.hl7.fhir.dstu3.model.MessageDefinition) src); 142 if (src instanceof org.hl7.fhir.dstu3.model.MessageHeader) 143 return MessageHeader30_40.convertMessageHeader((org.hl7.fhir.dstu3.model.MessageHeader) src); 144 if (src instanceof org.hl7.fhir.dstu3.model.NamingSystem) 145 return NamingSystem30_40.convertNamingSystem((org.hl7.fhir.dstu3.model.NamingSystem) src); 146 if (src instanceof org.hl7.fhir.dstu3.model.Observation) 147 return Observation30_40.convertObservation((org.hl7.fhir.dstu3.model.Observation) src); 148 if (src instanceof org.hl7.fhir.dstu3.model.OperationDefinition) 149 return OperationDefinition30_40.convertOperationDefinition((org.hl7.fhir.dstu3.model.OperationDefinition) src); 150 if (src instanceof org.hl7.fhir.dstu3.model.OperationOutcome) 151 return OperationOutcome30_40.convertOperationOutcome((org.hl7.fhir.dstu3.model.OperationOutcome) src); 152 if (src instanceof org.hl7.fhir.dstu3.model.Organization) 153 return Organization30_40.convertOrganization((org.hl7.fhir.dstu3.model.Organization) src); 154 if (src instanceof org.hl7.fhir.dstu3.model.Patient) 155 return Patient30_40.convertPatient((org.hl7.fhir.dstu3.model.Patient) src); 156 if (src instanceof org.hl7.fhir.dstu3.model.PaymentNotice) 157 return PaymentNotice30_40.convertPaymentNotice((org.hl7.fhir.dstu3.model.PaymentNotice) src); 158 if (src instanceof org.hl7.fhir.dstu3.model.Person) 159 return Person30_40.convertPerson((org.hl7.fhir.dstu3.model.Person) src); 160 if (src instanceof org.hl7.fhir.dstu3.model.PlanDefinition) 161 return PlanDefinition30_40.convertPlanDefinition((org.hl7.fhir.dstu3.model.PlanDefinition) src); 162 if (src instanceof org.hl7.fhir.dstu3.model.Practitioner) 163 return Practitioner30_40.convertPractitioner((org.hl7.fhir.dstu3.model.Practitioner) src); 164 if (src instanceof org.hl7.fhir.dstu3.model.PractitionerRole) 165 return PractitionerRole30_40.convertPractitionerRole((org.hl7.fhir.dstu3.model.PractitionerRole) src); 166 if (src instanceof org.hl7.fhir.dstu3.model.Procedure) 167 return Procedure30_40.convertProcedure((org.hl7.fhir.dstu3.model.Procedure) src); 168 if (src instanceof org.hl7.fhir.dstu3.model.ProcedureRequest) 169 return ProcedureRequest30_40.convertProcedureRequest((org.hl7.fhir.dstu3.model.ProcedureRequest) src); 170 if (src instanceof org.hl7.fhir.dstu3.model.Provenance) 171 return Provenance30_40.convertProvenance((org.hl7.fhir.dstu3.model.Provenance) src); 172 if (src instanceof org.hl7.fhir.dstu3.model.Questionnaire) 173 return Questionnaire30_40.convertQuestionnaire((org.hl7.fhir.dstu3.model.Questionnaire) src); 174 if (src instanceof org.hl7.fhir.dstu3.model.QuestionnaireResponse) 175 return QuestionnaireResponse30_40.convertQuestionnaireResponse((org.hl7.fhir.dstu3.model.QuestionnaireResponse) src); 176 if (src instanceof org.hl7.fhir.dstu3.model.RelatedPerson) 177 return RelatedPerson30_40.convertRelatedPerson((org.hl7.fhir.dstu3.model.RelatedPerson) src); 178 if (src instanceof org.hl7.fhir.dstu3.model.RiskAssessment) 179 return RiskAssessment30_40.convertRiskAssessment((org.hl7.fhir.dstu3.model.RiskAssessment) src); 180 if (src instanceof org.hl7.fhir.dstu3.model.Schedule) 181 return Schedule30_40.convertSchedule((org.hl7.fhir.dstu3.model.Schedule) src); 182 if (src instanceof org.hl7.fhir.dstu3.model.SearchParameter) 183 return SearchParameter30_40.convertSearchParameter((org.hl7.fhir.dstu3.model.SearchParameter) src); 184 if (src instanceof org.hl7.fhir.dstu3.model.Sequence) 185 return Sequence30_40.convertSequence((org.hl7.fhir.dstu3.model.Sequence) src); 186 if (src instanceof org.hl7.fhir.dstu3.model.Slot) return Slot30_40.convertSlot((org.hl7.fhir.dstu3.model.Slot) src); 187 if (src instanceof org.hl7.fhir.dstu3.model.Specimen) 188 return Specimen30_40.convertSpecimen((org.hl7.fhir.dstu3.model.Specimen) src); 189 if (src instanceof org.hl7.fhir.dstu3.model.StructureDefinition) 190 return StructureDefinition30_40.convertStructureDefinition((org.hl7.fhir.dstu3.model.StructureDefinition) src); 191 if (src instanceof org.hl7.fhir.dstu3.model.StructureMap) 192 return StructureMap30_40.convertStructureMap((org.hl7.fhir.dstu3.model.StructureMap) src); 193 if (src instanceof org.hl7.fhir.dstu3.model.Subscription) 194 return Subscription30_40.convertSubscription((org.hl7.fhir.dstu3.model.Subscription) src); 195 if (src instanceof org.hl7.fhir.dstu3.model.Substance) 196 return Substance30_40.convertSubstance((org.hl7.fhir.dstu3.model.Substance) src); 197 if (src instanceof org.hl7.fhir.dstu3.model.SupplyDelivery) 198 return SupplyDelivery30_40.convertSupplyDelivery((org.hl7.fhir.dstu3.model.SupplyDelivery) src); 199 if (src instanceof org.hl7.fhir.dstu3.model.TestReport) 200 return TestReport30_40.convertTestReport((org.hl7.fhir.dstu3.model.TestReport) src); 201 if (src instanceof org.hl7.fhir.dstu3.model.TestScript) 202 return TestScript30_40.convertTestScript((org.hl7.fhir.dstu3.model.TestScript) src); 203 if (src instanceof org.hl7.fhir.dstu3.model.ValueSet) 204 return ValueSet30_40.convertValueSet((org.hl7.fhir.dstu3.model.ValueSet) src); 205 if (advisor.failFastOnNullOrUnknownEntry()) { 206 throw new FHIRException("The resource " + src.fhirType()+" cannot be converted from R3 to R4"); 207 } else { 208 return null; 209 } 210 } 211 212 public org.hl7.fhir.dstu3.model.Resource convertResource(org.hl7.fhir.r4.model.Resource src) throws FHIRException { 213 return convertResource(src, new BaseAdvisor_30_40()); 214 } 215 216 public org.hl7.fhir.dstu3.model.Resource convertResource(org.hl7.fhir.r4.model.Resource src, BaseAdvisor_30_40 advisor) throws FHIRException { 217 if (src == null) return null; 218 if (src instanceof org.hl7.fhir.r4.model.Parameters) { 219// if (((org.hl7.fhir.r4.model.Parameters) src).hasParameterValue("profile-url")) 220// return ExpansionProfile30_40.convertExpansionProfile((org.hl7.fhir.r4.model.Parameters) src); 221// else 222 return Parameters30_40.convertParameters((org.hl7.fhir.r4.model.Parameters) src); 223 } 224 if (src instanceof org.hl7.fhir.r4.model.Account) 225 return Account30_40.convertAccount((org.hl7.fhir.r4.model.Account) src); 226 if (src instanceof org.hl7.fhir.r4.model.ActivityDefinition) 227 return ActivityDefinition30_40.convertActivityDefinition((org.hl7.fhir.r4.model.ActivityDefinition) src); 228 if (src instanceof org.hl7.fhir.r4.model.AllergyIntolerance) 229 return AllergyIntolerance30_40.convertAllergyIntolerance((org.hl7.fhir.r4.model.AllergyIntolerance) src); 230 if (src instanceof org.hl7.fhir.r4.model.Appointment) 231 return Appointment30_40.convertAppointment((org.hl7.fhir.r4.model.Appointment) src); 232 if (src instanceof org.hl7.fhir.r4.model.AppointmentResponse) 233 return AppointmentResponse30_40.convertAppointmentResponse((org.hl7.fhir.r4.model.AppointmentResponse) src); 234 if (src instanceof org.hl7.fhir.r4.model.AuditEvent) 235 return AuditEvent30_40.convertAuditEvent((org.hl7.fhir.r4.model.AuditEvent) src); 236 if (src instanceof org.hl7.fhir.r4.model.Basic) return Basic30_40.convertBasic((org.hl7.fhir.r4.model.Basic) src); 237 if (src instanceof org.hl7.fhir.r4.model.Binary) 238 return Binary30_40.convertBinary((org.hl7.fhir.r4.model.Binary) src); 239 if (src instanceof org.hl7.fhir.r4.model.BodyStructure) 240 return BodySite30_40.convertBodySite((org.hl7.fhir.r4.model.BodyStructure) src); 241 if (src instanceof org.hl7.fhir.r4.model.Bundle) 242 return Bundle30_40.convertBundle((org.hl7.fhir.r4.model.Bundle) src); 243 if (src instanceof org.hl7.fhir.r4.model.CapabilityStatement) 244 return CapabilityStatement30_40.convertCapabilityStatement((org.hl7.fhir.r4.model.CapabilityStatement) src); 245 if (src instanceof org.hl7.fhir.r4.model.CarePlan) 246 return CarePlan30_40.convertCarePlan((org.hl7.fhir.r4.model.CarePlan) src); 247 if (src instanceof org.hl7.fhir.r4.model.CareTeam) 248 return CareTeam30_40.convertCareTeam((org.hl7.fhir.r4.model.CareTeam) src); 249 if (src instanceof org.hl7.fhir.r4.model.ClinicalImpression) 250 return ClinicalImpression30_40.convertClinicalImpression((org.hl7.fhir.r4.model.ClinicalImpression) src); 251 if (src instanceof org.hl7.fhir.r4.model.CodeSystem) 252 return CodeSystem30_40.convertCodeSystem((org.hl7.fhir.r4.model.CodeSystem) src); 253 if (src instanceof org.hl7.fhir.r4.model.Communication) 254 return Communication30_40.convertCommunication((org.hl7.fhir.r4.model.Communication) src); 255 if (src instanceof org.hl7.fhir.r4.model.CompartmentDefinition) 256 return CompartmentDefinition30_40.convertCompartmentDefinition((org.hl7.fhir.r4.model.CompartmentDefinition) src); 257 if (src instanceof org.hl7.fhir.r4.model.Composition) 258 return Composition30_40.convertComposition((org.hl7.fhir.r4.model.Composition) src); 259 if (src instanceof org.hl7.fhir.r4.model.ConceptMap) 260 return ConceptMap30_40.convertConceptMap((org.hl7.fhir.r4.model.ConceptMap) src); 261 if (src instanceof org.hl7.fhir.r4.model.Condition) 262 return Condition30_40.convertCondition((org.hl7.fhir.r4.model.Condition) src); 263 if (src instanceof org.hl7.fhir.r4.model.Consent) 264 return Consent30_40.convertConsent((org.hl7.fhir.r4.model.Consent) src); 265 if (src instanceof org.hl7.fhir.r4.model.Coverage) 266 return Coverage30_40.convertCoverage((org.hl7.fhir.r4.model.Coverage) src); 267 if (src instanceof org.hl7.fhir.r4.model.DetectedIssue) 268 return DetectedIssue30_40.convertDetectedIssue((org.hl7.fhir.r4.model.DetectedIssue) src); 269 if (src instanceof org.hl7.fhir.r4.model.Device) 270 return Device30_40.convertDevice((org.hl7.fhir.r4.model.Device) src); 271 if (src instanceof org.hl7.fhir.r4.model.DeviceUseStatement) 272 return DeviceUseStatement30_40.convertDeviceUseStatement((org.hl7.fhir.r4.model.DeviceUseStatement) src); 273 if (src instanceof org.hl7.fhir.r4.model.DiagnosticReport) 274 return DiagnosticReport30_40.convertDiagnosticReport((org.hl7.fhir.r4.model.DiagnosticReport) src); 275 if (src instanceof org.hl7.fhir.r4.model.DocumentReference) 276 return DocumentReference30_40.convertDocumentReference((org.hl7.fhir.r4.model.DocumentReference) src); 277 if (src instanceof org.hl7.fhir.r4.model.Encounter) 278 return Encounter30_40.convertEncounter((org.hl7.fhir.r4.model.Encounter) src); 279 if (src instanceof org.hl7.fhir.r4.model.Endpoint) 280 return Endpoint30_40.convertEndpoint((org.hl7.fhir.r4.model.Endpoint) src); 281 if (src instanceof org.hl7.fhir.r4.model.EpisodeOfCare) 282 return EpisodeOfCare30_40.convertEpisodeOfCare((org.hl7.fhir.r4.model.EpisodeOfCare) src); 283 if (src instanceof org.hl7.fhir.r4.model.FamilyMemberHistory) 284 return FamilyMemberHistory30_40.convertFamilyMemberHistory((org.hl7.fhir.r4.model.FamilyMemberHistory) src); 285 if (src instanceof org.hl7.fhir.r4.model.Flag) return Flag30_40.convertFlag((org.hl7.fhir.r4.model.Flag) src); 286 if (src instanceof org.hl7.fhir.r4.model.Goal) return Goal30_40.convertGoal((org.hl7.fhir.r4.model.Goal) src); 287 if (src instanceof org.hl7.fhir.r4.model.GraphDefinition) 288 return GraphDefinition30_40.convertGraphDefinition((org.hl7.fhir.r4.model.GraphDefinition) src); 289 if (src instanceof org.hl7.fhir.r4.model.Group) return Group30_40.convertGroup((org.hl7.fhir.r4.model.Group) src); 290 if (src instanceof org.hl7.fhir.r4.model.HealthcareService) 291 return HealthcareService30_40.convertHealthcareService((org.hl7.fhir.r4.model.HealthcareService) src); 292 if (src instanceof org.hl7.fhir.r4.model.ImagingStudy) 293 return ImagingStudy30_40.convertImagingStudy((org.hl7.fhir.r4.model.ImagingStudy) src); 294 if (src instanceof org.hl7.fhir.r4.model.Immunization) 295 return Immunization30_40.convertImmunization((org.hl7.fhir.r4.model.Immunization) src); 296 if (src instanceof org.hl7.fhir.r4.model.ImplementationGuide) 297 return ImplementationGuide30_40.convertImplementationGuide((org.hl7.fhir.r4.model.ImplementationGuide) src); 298 if (src instanceof org.hl7.fhir.r4.model.Library) 299 return Library30_40.convertLibrary((org.hl7.fhir.r4.model.Library) src); 300 if (src instanceof org.hl7.fhir.r4.model.Linkage) 301 return Linkage30_40.convertLinkage((org.hl7.fhir.r4.model.Linkage) src); 302 if (src instanceof org.hl7.fhir.r4.model.ListResource) 303 return List30_40.convertList((org.hl7.fhir.r4.model.ListResource) src); 304 if (src instanceof org.hl7.fhir.r4.model.Location) 305 return Location30_40.convertLocation((org.hl7.fhir.r4.model.Location) src); 306 if (src instanceof org.hl7.fhir.r4.model.Media) return Media30_40.convertMedia((org.hl7.fhir.r4.model.Media) src); 307 if (src instanceof org.hl7.fhir.r4.model.Medication) 308 return Medication30_40.convertMedication((org.hl7.fhir.r4.model.Medication) src); 309 if (src instanceof org.hl7.fhir.r4.model.MedicationAdministration) 310 return MedicationAdministration30_40.convertMedicationAdministration((org.hl7.fhir.r4.model.MedicationAdministration) src); 311 if (src instanceof org.hl7.fhir.r4.model.MedicationDispense) 312 return MedicationDispense30_40.convertMedicationDispense((org.hl7.fhir.r4.model.MedicationDispense) src); 313 if (src instanceof org.hl7.fhir.r4.model.MedicationRequest) 314 return MedicationRequest30_40.convertMedicationRequest((org.hl7.fhir.r4.model.MedicationRequest) src); 315 if (src instanceof org.hl7.fhir.r4.model.MedicationStatement) 316 return MedicationStatement30_40.convertMedicationStatement((org.hl7.fhir.r4.model.MedicationStatement) src); 317 if (src instanceof org.hl7.fhir.r4.model.MessageDefinition) 318 return MessageDefinition30_40.convertMessageDefinition((org.hl7.fhir.r4.model.MessageDefinition) src); 319 if (src instanceof org.hl7.fhir.r4.model.MessageHeader) 320 return MessageHeader30_40.convertMessageHeader((org.hl7.fhir.r4.model.MessageHeader) src); 321 if (src instanceof org.hl7.fhir.r4.model.NamingSystem) 322 return NamingSystem30_40.convertNamingSystem((org.hl7.fhir.r4.model.NamingSystem) src); 323 if (src instanceof org.hl7.fhir.r4.model.Observation) 324 return Observation30_40.convertObservation((org.hl7.fhir.r4.model.Observation) src); 325 if (src instanceof org.hl7.fhir.r4.model.OperationDefinition) 326 return OperationDefinition30_40.convertOperationDefinition((org.hl7.fhir.r4.model.OperationDefinition) src); 327 if (src instanceof org.hl7.fhir.r4.model.OperationOutcome) 328 return OperationOutcome30_40.convertOperationOutcome((org.hl7.fhir.r4.model.OperationOutcome) src); 329 if (src instanceof org.hl7.fhir.r4.model.Organization) 330 return Organization30_40.convertOrganization((org.hl7.fhir.r4.model.Organization) src); 331 if (src instanceof org.hl7.fhir.r4.model.Patient) 332 return Patient30_40.convertPatient((org.hl7.fhir.r4.model.Patient) src); 333 if (src instanceof org.hl7.fhir.r4.model.PaymentNotice) 334 return PaymentNotice30_40.convertPaymentNotice((org.hl7.fhir.r4.model.PaymentNotice) src); 335 if (src instanceof org.hl7.fhir.r4.model.Person) 336 return Person30_40.convertPerson((org.hl7.fhir.r4.model.Person) src); 337 if (src instanceof org.hl7.fhir.r4.model.PlanDefinition) 338 return PlanDefinition30_40.convertPlanDefinition((org.hl7.fhir.r4.model.PlanDefinition) src); 339 if (src instanceof org.hl7.fhir.r4.model.Practitioner) 340 return Practitioner30_40.convertPractitioner((org.hl7.fhir.r4.model.Practitioner) src); 341 if (src instanceof org.hl7.fhir.r4.model.PractitionerRole) 342 return PractitionerRole30_40.convertPractitionerRole((org.hl7.fhir.r4.model.PractitionerRole) src); 343 if (src instanceof org.hl7.fhir.r4.model.Procedure) 344 return Procedure30_40.convertProcedure((org.hl7.fhir.r4.model.Procedure) src); 345 if (src instanceof org.hl7.fhir.r4.model.ServiceRequest) 346 return ProcedureRequest30_40.convertProcedureRequest((org.hl7.fhir.r4.model.ServiceRequest) src); 347 if (src instanceof org.hl7.fhir.r4.model.Provenance) 348 return Provenance30_40.convertProvenance((org.hl7.fhir.r4.model.Provenance) src); 349 if (src instanceof org.hl7.fhir.r4.model.Questionnaire) 350 return Questionnaire30_40.convertQuestionnaire((org.hl7.fhir.r4.model.Questionnaire) src); 351 if (src instanceof org.hl7.fhir.r4.model.QuestionnaireResponse) 352 return QuestionnaireResponse30_40.convertQuestionnaireResponse((org.hl7.fhir.r4.model.QuestionnaireResponse) src); 353 if (src instanceof org.hl7.fhir.r4.model.RelatedPerson) 354 return RelatedPerson30_40.convertRelatedPerson((org.hl7.fhir.r4.model.RelatedPerson) src); 355 if (src instanceof org.hl7.fhir.r4.model.RiskAssessment) 356 return RiskAssessment30_40.convertRiskAssessment((org.hl7.fhir.r4.model.RiskAssessment) src); 357 if (src instanceof org.hl7.fhir.r4.model.Schedule) 358 return Schedule30_40.convertSchedule((org.hl7.fhir.r4.model.Schedule) src); 359 if (src instanceof org.hl7.fhir.r4.model.SearchParameter) 360 return SearchParameter30_40.convertSearchParameter((org.hl7.fhir.r4.model.SearchParameter) src); 361 if (src instanceof org.hl7.fhir.r4.model.MolecularSequence) 362 return Sequence30_40.convertSequence((org.hl7.fhir.r4.model.MolecularSequence) src); 363 if (src instanceof org.hl7.fhir.r4.model.Slot) return Slot30_40.convertSlot((org.hl7.fhir.r4.model.Slot) src); 364 if (src instanceof org.hl7.fhir.r4.model.Specimen) 365 return Specimen30_40.convertSpecimen((org.hl7.fhir.r4.model.Specimen) src); 366 if (src instanceof org.hl7.fhir.r4.model.StructureDefinition) 367 return StructureDefinition30_40.convertStructureDefinition((org.hl7.fhir.r4.model.StructureDefinition) src); 368 if (src instanceof org.hl7.fhir.r4.model.StructureMap) 369 return StructureMap30_40.convertStructureMap((org.hl7.fhir.r4.model.StructureMap) src); 370 if (src instanceof org.hl7.fhir.r4.model.Subscription) 371 return Subscription30_40.convertSubscription((org.hl7.fhir.r4.model.Subscription) src); 372 if (src instanceof org.hl7.fhir.r4.model.Substance) 373 return Substance30_40.convertSubstance((org.hl7.fhir.r4.model.Substance) src); 374 if (src instanceof org.hl7.fhir.r4.model.SupplyDelivery) 375 return SupplyDelivery30_40.convertSupplyDelivery((org.hl7.fhir.r4.model.SupplyDelivery) src); 376 if (src instanceof org.hl7.fhir.r4.model.TestReport) 377 return TestReport30_40.convertTestReport((org.hl7.fhir.r4.model.TestReport) src); 378 if (src instanceof org.hl7.fhir.r4.model.TestScript) 379 return TestScript30_40.convertTestScript((org.hl7.fhir.r4.model.TestScript) src); 380 if (src instanceof org.hl7.fhir.r4.model.ValueSet) 381 return ValueSet30_40.convertValueSet((org.hl7.fhir.r4.model.ValueSet) src); 382 if (advisor.failFastOnNullOrUnknownEntry()) { 383 throw new FHIRException("The resource " + src.fhirType()+" cannot be converted from R4 to R3"); 384 } else { 385 return null; 386 } 387 } 388 389 public void copyDomainResource(org.hl7.fhir.dstu3.model.DomainResource src, 390 org.hl7.fhir.r4.model.DomainResource tgt, 391 String... extensionUrlsToIgnore) throws FHIRException { 392 copyResource(src, tgt); 393 if (src.hasText()) tgt.setText(Narrative30_40.convertNarrative(src.getText())); 394 src.getContained().stream() 395 .map(resource -> convertResource(resource, advisor)) 396 .forEach(tgt::addContained); 397 src.getExtension().forEach(extension -> { 398 399 if (advisor.useAdvisorForExtension(ConversionContext30_40.INSTANCE.path(), extension)) { 400 org.hl7.fhir.r4.model.Extension convertExtension = new org.hl7.fhir.r4.model.Extension(); 401 advisor.handleExtension(ConversionContext30_40.INSTANCE.path(), extension, convertExtension); 402 tgt.addExtension(convertExtension); 403 } else if (!advisor.ignoreExtension(ConversionContext30_40.INSTANCE.path(), extension)&& !Arrays.asList(extensionUrlsToIgnore).contains(extension.getUrl())) { 404 tgt.addExtension(Extension30_40.convertExtension(extension)); 405 } 406 }); 407 src.getModifierExtension().stream() 408 .filter(extension -> !advisor.ignoreExtension(ConversionContext30_40.INSTANCE.path(), extension)) 409 .map(Extension30_40::convertExtension) 410 .forEach(tgt::addModifierExtension); 411 } 412 413 public void copyDomainResource(org.hl7.fhir.r4.model.DomainResource src, 414 org.hl7.fhir.dstu3.model.DomainResource tgt, 415 String... extensionUrlsToIgnore) throws FHIRException { 416 copyResource(src, tgt); 417 if (src.hasText()) tgt.setText(Narrative30_40.convertNarrative(src.getText())); 418 src.getContained().stream() 419 .map(resource -> convertResource(resource, advisor)) 420 .forEach(tgt::addContained); 421 src.getExtension().forEach(extension -> { 422 if (advisor.useAdvisorForExtension(ConversionContext30_40.INSTANCE.path(), extension)) { 423 org.hl7.fhir.dstu3.model.Extension convertExtension = new org.hl7.fhir.dstu3.model.Extension(); 424 advisor.handleExtension(ConversionContext30_40.INSTANCE.path(), extension, convertExtension); 425 tgt.addExtension(convertExtension); 426 } else if (!advisor.ignoreExtension(ConversionContext30_40.INSTANCE.path(), extension) && !Arrays.asList(extensionUrlsToIgnore).contains(extension.getUrl())) { 427 tgt.addExtension(Extension30_40.convertExtension(extension)); 428 } 429 }); 430 src.getModifierExtension().stream() 431 .filter(extension -> !advisor.ignoreExtension("", extension))//TODO add path 432 .map(Extension30_40::convertExtension) 433 .forEach(tgt::addModifierExtension); 434 } 435}