001package org.hl7.fhir.convertors.conv10_50.resources10_50; 002 003import java.util.Arrays; 004 005import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_50; 006import org.hl7.fhir.convertors.context.ConversionContext10_50; 007import org.hl7.fhir.convertors.conv10_50.datatypes10_50.Extension10_50; 008import org.hl7.fhir.convertors.conv10_50.datatypes10_50.Meta10_50; 009import org.hl7.fhir.convertors.conv10_50.datatypes10_50.Narrative10_50; 010import org.hl7.fhir.dstu2.model.Extension; 011import org.hl7.fhir.exceptions.FHIRException; 012 013public class Resource10_50 { 014 015 public final BaseAdvisor_10_50 advisor; 016 017 public Resource10_50(BaseAdvisor_10_50 advisor) { 018 this.advisor = advisor; 019 } 020 021 public void copyResource(org.hl7.fhir.dstu2.model.Resource src, org.hl7.fhir.r5.model.Resource tgt) throws FHIRException { 022 if (src.hasId()) tgt.setId(src.getId()); 023 if (src.hasMeta()) tgt.setMeta(Meta10_50.convertMeta(src.getMeta())); 024 if (src.hasImplicitRules()) tgt.setImplicitRules(src.getImplicitRules()); 025 if (src.hasLanguage()) tgt.setLanguage(src.getLanguage()); 026 } 027 028 public void copyResource(org.hl7.fhir.r5.model.Resource src, org.hl7.fhir.dstu2.model.Resource tgt) throws FHIRException { 029 tgt.setId(src.getId()); 030 if (src.hasMeta()) tgt.setMeta(Meta10_50.convertMeta(src.getMeta())); 031 if (src.hasImplicitRules()) tgt.setImplicitRules(src.getImplicitRules()); 032 if (src.hasLanguage()) tgt.setLanguage(src.getLanguage()); 033 } 034 035 public org.hl7.fhir.r5.model.Resource convertResource(org.hl7.fhir.dstu2.model.Resource src) throws FHIRException { 036 if (src == null || src.isEmpty()) return null; 037 if (src instanceof org.hl7.fhir.dstu2.model.Parameters) 038 return Parameters10_50.convertParameters((org.hl7.fhir.dstu2.model.Parameters) src); 039 if (src instanceof org.hl7.fhir.dstu2.model.Appointment) 040 return Appointment10_50.convertAppointment((org.hl7.fhir.dstu2.model.Appointment) src); 041 if (src instanceof org.hl7.fhir.dstu2.model.AppointmentResponse) 042 return AppointmentResponse10_50.convertAppointmentResponse((org.hl7.fhir.dstu2.model.AppointmentResponse) src); 043 if (src instanceof org.hl7.fhir.dstu2.model.AuditEvent) 044 return AuditEvent10_50.convertAuditEvent((org.hl7.fhir.dstu2.model.AuditEvent) src); 045 if (src instanceof org.hl7.fhir.dstu2.model.Basic) 046 return Basic10_50.convertBasic((org.hl7.fhir.dstu2.model.Basic) src); 047 if (src instanceof org.hl7.fhir.dstu2.model.Binary) 048 return Binary10_50.convertBinary((org.hl7.fhir.dstu2.model.Binary) src); 049 if (src instanceof org.hl7.fhir.dstu2.model.Bundle) 050 return Bundle10_50.convertBundle((org.hl7.fhir.dstu2.model.Bundle) src); 051 if (src instanceof org.hl7.fhir.dstu2.model.CarePlan) 052 return CarePlan10_50.convertCarePlan((org.hl7.fhir.dstu2.model.CarePlan) src); 053 if (src instanceof org.hl7.fhir.dstu2.model.Communication) 054 return Communication10_50.convertCommunication((org.hl7.fhir.dstu2.model.Communication) src); 055 if (src instanceof org.hl7.fhir.dstu2.model.CommunicationRequest) 056 return CommunicationRequest10_50.convertCommunicationRequest((org.hl7.fhir.dstu2.model.CommunicationRequest) src); 057 if (src instanceof org.hl7.fhir.dstu2.model.Composition) 058 return Composition10_50.convertComposition((org.hl7.fhir.dstu2.model.Composition) src); 059 if (src instanceof org.hl7.fhir.dstu2.model.ConceptMap) 060 return ConceptMap10_50.convertConceptMap((org.hl7.fhir.dstu2.model.ConceptMap) src); 061 if (src instanceof org.hl7.fhir.dstu2.model.Condition) 062 return Condition10_50.convertCondition((org.hl7.fhir.dstu2.model.Condition) src); 063 if (src instanceof org.hl7.fhir.dstu2.model.Conformance) 064 return Conformance10_50.convertConformance((org.hl7.fhir.dstu2.model.Conformance) src); 065 if (src instanceof org.hl7.fhir.dstu2.model.DataElement) 066 return DataElement10_50.convertDataElement((org.hl7.fhir.dstu2.model.DataElement) src); 067 if (src instanceof org.hl7.fhir.dstu2.model.DetectedIssue) 068 return DetectedIssue10_50.convertDetectedIssue((org.hl7.fhir.dstu2.model.DetectedIssue) src); 069 if (src instanceof org.hl7.fhir.dstu2.model.DeviceMetric) 070 return DeviceMetric10_50.convertDeviceMetric((org.hl7.fhir.dstu2.model.DeviceMetric) src); 071 if (src instanceof org.hl7.fhir.dstu2.model.DeviceUseStatement) 072 return DeviceUseStatement10_50.convertDeviceUseStatement((org.hl7.fhir.dstu2.model.DeviceUseStatement) src); 073 if (src instanceof org.hl7.fhir.dstu2.model.DiagnosticReport) 074 return DiagnosticReport10_50.convertDiagnosticReport((org.hl7.fhir.dstu2.model.DiagnosticReport) src); 075 if (src instanceof org.hl7.fhir.dstu2.model.DocumentReference) 076 return DocumentReference10_50.convertDocumentReference((org.hl7.fhir.dstu2.model.DocumentReference) src); 077 if (src instanceof org.hl7.fhir.dstu2.model.Encounter) 078 return Encounter10_50.convertEncounter((org.hl7.fhir.dstu2.model.Encounter) src); 079 if (src instanceof org.hl7.fhir.dstu2.model.EnrollmentRequest) 080 return EnrollmentRequest10_50.convertEnrollmentRequest((org.hl7.fhir.dstu2.model.EnrollmentRequest) src); 081 if (src instanceof org.hl7.fhir.dstu2.model.EnrollmentResponse) 082 return EnrollmentResponse10_50.convertEnrollmentResponse((org.hl7.fhir.dstu2.model.EnrollmentResponse) src); 083 if (src instanceof org.hl7.fhir.dstu2.model.EpisodeOfCare) 084 return EpisodeOfCare10_50.convertEpisodeOfCare((org.hl7.fhir.dstu2.model.EpisodeOfCare) src); 085 if (src instanceof org.hl7.fhir.dstu2.model.FamilyMemberHistory) 086 return FamilyMemberHistory10_50.convertFamilyMemberHistory((org.hl7.fhir.dstu2.model.FamilyMemberHistory) src); 087 if (src instanceof org.hl7.fhir.dstu2.model.Flag) 088 return Flag10_50.convertFlag((org.hl7.fhir.dstu2.model.Flag) src); 089 if (src instanceof org.hl7.fhir.dstu2.model.Group) 090 return Group10_50.convertGroup((org.hl7.fhir.dstu2.model.Group) src); 091 if (src instanceof org.hl7.fhir.dstu2.model.HealthcareService) 092 return HealthcareService10_50.convertHealthcareService((org.hl7.fhir.dstu2.model.HealthcareService) src); 093 if (src instanceof org.hl7.fhir.dstu2.model.ImplementationGuide) 094 return ImplementationGuide10_50.convertImplementationGuide((org.hl7.fhir.dstu2.model.ImplementationGuide) src); 095 if (src instanceof org.hl7.fhir.dstu2.model.List_) 096 return List10_50.convertList((org.hl7.fhir.dstu2.model.List_) src); 097 if (src instanceof org.hl7.fhir.dstu2.model.Location) 098 return Location10_50.convertLocation((org.hl7.fhir.dstu2.model.Location) src); 099 if (src instanceof org.hl7.fhir.dstu2.model.MedicationDispense) 100 return MedicationDispense10_50.convertMedicationDispense((org.hl7.fhir.dstu2.model.MedicationDispense) src); 101 if (src instanceof org.hl7.fhir.dstu2.model.MedicationStatement) 102 return MedicationStatement10_50.convertMedicationStatement((org.hl7.fhir.dstu2.model.MedicationStatement) src); 103 if (src instanceof org.hl7.fhir.dstu2.model.MessageHeader) 104 return MessageHeader10_50.convertMessageHeader((org.hl7.fhir.dstu2.model.MessageHeader) src); 105 if (src instanceof org.hl7.fhir.dstu2.model.NamingSystem) 106 return NamingSystem10_50.convertNamingSystem((org.hl7.fhir.dstu2.model.NamingSystem) src); 107 if (src instanceof org.hl7.fhir.dstu2.model.Observation) 108 return Observation10_50.convertObservation((org.hl7.fhir.dstu2.model.Observation) src); 109 if (src instanceof org.hl7.fhir.dstu2.model.OperationDefinition) 110 return OperationDefinition10_50.convertOperationDefinition((org.hl7.fhir.dstu2.model.OperationDefinition) src); 111 if (src instanceof org.hl7.fhir.dstu2.model.OperationOutcome) 112 return OperationOutcome10_50.convertOperationOutcome((org.hl7.fhir.dstu2.model.OperationOutcome) src); 113 if (src instanceof org.hl7.fhir.dstu2.model.Organization) 114 return Organization10_50.convertOrganization((org.hl7.fhir.dstu2.model.Organization) src); 115 if (src instanceof org.hl7.fhir.dstu2.model.Patient) 116 return Patient10_50.convertPatient((org.hl7.fhir.dstu2.model.Patient) src); 117 if (src instanceof org.hl7.fhir.dstu2.model.Person) 118 return Person10_50.convertPerson((org.hl7.fhir.dstu2.model.Person) src); 119 if (src instanceof org.hl7.fhir.dstu2.model.Practitioner) 120 return Practitioner10_50.convertPractitioner((org.hl7.fhir.dstu2.model.Practitioner) src); 121 if (src instanceof org.hl7.fhir.dstu2.model.Provenance) 122 return Provenance10_50.convertProvenance((org.hl7.fhir.dstu2.model.Provenance) src); 123 if (src instanceof org.hl7.fhir.dstu2.model.Questionnaire) 124 return Questionnaire10_50.convertQuestionnaire((org.hl7.fhir.dstu2.model.Questionnaire) src); 125 if (src instanceof org.hl7.fhir.dstu2.model.QuestionnaireResponse) 126 return QuestionnaireResponse10_50.convertQuestionnaireResponse((org.hl7.fhir.dstu2.model.QuestionnaireResponse) src); 127 if (src instanceof org.hl7.fhir.dstu2.model.RiskAssessment) 128 return RiskAssessment10_50.convertRiskAssessment((org.hl7.fhir.dstu2.model.RiskAssessment) src); 129 if (src instanceof org.hl7.fhir.dstu2.model.Schedule) 130 return Schedule10_50.convertSchedule((org.hl7.fhir.dstu2.model.Schedule) src); 131 if (src instanceof org.hl7.fhir.dstu2.model.SearchParameter) 132 return SearchParameter10_50.convertSearchParameter((org.hl7.fhir.dstu2.model.SearchParameter) src); 133 if (src instanceof org.hl7.fhir.dstu2.model.Slot) 134 return Slot10_50.convertSlot((org.hl7.fhir.dstu2.model.Slot) src); 135 if (src instanceof org.hl7.fhir.dstu2.model.StructureDefinition) 136 return StructureDefinition10_50.convertStructureDefinition((org.hl7.fhir.dstu2.model.StructureDefinition) src); 137 if (src instanceof org.hl7.fhir.dstu2.model.Substance) 138 return Substance10_50.convertSubstance((org.hl7.fhir.dstu2.model.Substance) src); 139 if (src instanceof org.hl7.fhir.dstu2.model.SupplyDelivery) 140 return SupplyDelivery10_50.convertSupplyDelivery((org.hl7.fhir.dstu2.model.SupplyDelivery) src); 141 if (src instanceof org.hl7.fhir.dstu2.model.SupplyRequest) 142 return SupplyRequest10_50.convertSupplyRequest((org.hl7.fhir.dstu2.model.SupplyRequest) src); 143 if (src instanceof org.hl7.fhir.dstu2.model.TestScript) 144 return TestScript10_50.convertTestScript((org.hl7.fhir.dstu2.model.TestScript) src); 145 if (src instanceof org.hl7.fhir.dstu2.model.ValueSet) 146 return ValueSet10_50.convertValueSet((org.hl7.fhir.dstu2.model.ValueSet) src, advisor); 147 if (advisor.failFastOnNullOrUnknownEntry()) { 148 throw new FHIRException("The resource " + src.fhirType()+" cannot be converted from R2 to R5"); 149 } else { 150 return null; 151 } 152 } 153 154 public org.hl7.fhir.dstu2.model.Resource convertResource(org.hl7.fhir.r5.model.Resource src) throws FHIRException { 155 if (src == null || src.isEmpty()) return null; 156 if (src instanceof org.hl7.fhir.r5.model.Parameters) 157 return Parameters10_50.convertParameters((org.hl7.fhir.r5.model.Parameters) src); 158 if (src instanceof org.hl7.fhir.r5.model.Appointment) 159 return Appointment10_50.convertAppointment((org.hl7.fhir.r5.model.Appointment) src); 160 if (src instanceof org.hl7.fhir.r5.model.AppointmentResponse) 161 return AppointmentResponse10_50.convertAppointmentResponse((org.hl7.fhir.r5.model.AppointmentResponse) src); 162 if (src instanceof org.hl7.fhir.r5.model.AuditEvent) 163 return AuditEvent10_50.convertAuditEvent((org.hl7.fhir.r5.model.AuditEvent) src); 164 if (src instanceof org.hl7.fhir.r5.model.Basic) 165 return Basic10_50.convertBasic((org.hl7.fhir.r5.model.Basic) src); 166 if (src instanceof org.hl7.fhir.r5.model.Binary) 167 return Binary10_50.convertBinary((org.hl7.fhir.r5.model.Binary) src); 168 if (src instanceof org.hl7.fhir.r5.model.Bundle) 169 return Bundle10_50.convertBundle((org.hl7.fhir.r5.model.Bundle) src, advisor); 170 if (src instanceof org.hl7.fhir.r5.model.CarePlan) 171 return CarePlan10_50.convertCarePlan((org.hl7.fhir.r5.model.CarePlan) src); 172 if (src instanceof org.hl7.fhir.r5.model.Communication) 173 return Communication10_50.convertCommunication((org.hl7.fhir.r5.model.Communication) src); 174 if (src instanceof org.hl7.fhir.r5.model.CommunicationRequest) 175 return CommunicationRequest10_50.convertCommunicationRequest((org.hl7.fhir.r5.model.CommunicationRequest) src); 176 if (src instanceof org.hl7.fhir.r5.model.Composition) 177 return Composition10_50.convertComposition((org.hl7.fhir.r5.model.Composition) src); 178 if (src instanceof org.hl7.fhir.r5.model.ConceptMap) 179 return ConceptMap10_50.convertConceptMap((org.hl7.fhir.r5.model.ConceptMap) src); 180 if (src instanceof org.hl7.fhir.r5.model.Condition) 181 return Condition10_50.convertCondition((org.hl7.fhir.r5.model.Condition) src); 182 if (src instanceof org.hl7.fhir.r5.model.CapabilityStatement) 183 return Conformance10_50.convertConformance((org.hl7.fhir.r5.model.CapabilityStatement) src); 184 if (src instanceof org.hl7.fhir.r5.model.DetectedIssue) 185 return DetectedIssue10_50.convertDetectedIssue((org.hl7.fhir.r5.model.DetectedIssue) src); 186 if (src instanceof org.hl7.fhir.r5.model.DeviceMetric) 187 return DeviceMetric10_50.convertDeviceMetric((org.hl7.fhir.r5.model.DeviceMetric) src); 188 if (src instanceof org.hl7.fhir.r5.model.DeviceUsage) 189 return DeviceUseStatement10_50.convertDeviceUseStatement((org.hl7.fhir.r5.model.DeviceUsage) src); 190 if (src instanceof org.hl7.fhir.r5.model.DiagnosticReport) 191 return DiagnosticReport10_50.convertDiagnosticReport((org.hl7.fhir.r5.model.DiagnosticReport) src); 192 if (src instanceof org.hl7.fhir.r5.model.DocumentReference) 193 return DocumentReference10_50.convertDocumentReference((org.hl7.fhir.r5.model.DocumentReference) src); 194 if (src instanceof org.hl7.fhir.r5.model.Encounter) 195 return Encounter10_50.convertEncounter((org.hl7.fhir.r5.model.Encounter) src); 196 if (src instanceof org.hl7.fhir.r5.model.EnrollmentRequest) 197 return EnrollmentRequest10_50.convertEnrollmentRequest((org.hl7.fhir.r5.model.EnrollmentRequest) src); 198 if (src instanceof org.hl7.fhir.r5.model.EnrollmentResponse) 199 return EnrollmentResponse10_50.convertEnrollmentResponse((org.hl7.fhir.r5.model.EnrollmentResponse) src); 200 if (src instanceof org.hl7.fhir.r5.model.EpisodeOfCare) 201 return EpisodeOfCare10_50.convertEpisodeOfCare((org.hl7.fhir.r5.model.EpisodeOfCare) src); 202 if (src instanceof org.hl7.fhir.r5.model.FamilyMemberHistory) 203 return FamilyMemberHistory10_50.convertFamilyMemberHistory((org.hl7.fhir.r5.model.FamilyMemberHistory) src); 204 if (src instanceof org.hl7.fhir.r5.model.Flag) return Flag10_50.convertFlag((org.hl7.fhir.r5.model.Flag) src); 205 if (src instanceof org.hl7.fhir.r5.model.Group) 206 return Group10_50.convertGroup((org.hl7.fhir.r5.model.Group) src); 207 if (src instanceof org.hl7.fhir.r5.model.HealthcareService) 208 return HealthcareService10_50.convertHealthcareService((org.hl7.fhir.r5.model.HealthcareService) src); 209 if (src instanceof org.hl7.fhir.r5.model.ImplementationGuide) 210 return ImplementationGuide10_50.convertImplementationGuide((org.hl7.fhir.r5.model.ImplementationGuide) src); 211 if (src instanceof org.hl7.fhir.r5.model.ListResource) 212 return List10_50.convertList((org.hl7.fhir.r5.model.ListResource) src); 213 if (src instanceof org.hl7.fhir.r5.model.Location) 214 return Location10_50.convertLocation((org.hl7.fhir.r5.model.Location) src); 215 if (src instanceof org.hl7.fhir.r5.model.MedicationDispense) 216 return MedicationDispense10_50.convertMedicationDispense((org.hl7.fhir.r5.model.MedicationDispense) src); 217 if (src instanceof org.hl7.fhir.r5.model.MedicationStatement) 218 return MedicationStatement10_50.convertMedicationStatement((org.hl7.fhir.r5.model.MedicationStatement) src); 219 if (src instanceof org.hl7.fhir.r5.model.MessageHeader) 220 return MessageHeader10_50.convertMessageHeader((org.hl7.fhir.r5.model.MessageHeader) src); 221 if (src instanceof org.hl7.fhir.r5.model.NamingSystem) 222 return NamingSystem10_50.convertNamingSystem((org.hl7.fhir.r5.model.NamingSystem) src); 223 if (src instanceof org.hl7.fhir.r5.model.Observation) 224 return Observation10_50.convertObservation((org.hl7.fhir.r5.model.Observation) src); 225 if (src instanceof org.hl7.fhir.r5.model.OperationDefinition) 226 return OperationDefinition10_50.convertOperationDefinition((org.hl7.fhir.r5.model.OperationDefinition) src); 227 if (src instanceof org.hl7.fhir.r5.model.OperationOutcome) 228 return OperationOutcome10_50.convertOperationOutcome((org.hl7.fhir.r5.model.OperationOutcome) src); 229 if (src instanceof org.hl7.fhir.r5.model.Organization) 230 return Organization10_50.convertOrganization((org.hl7.fhir.r5.model.Organization) src); 231 if (src instanceof org.hl7.fhir.r5.model.Patient) 232 return Patient10_50.convertPatient((org.hl7.fhir.r5.model.Patient) src); 233 if (src instanceof org.hl7.fhir.r5.model.Person) 234 return Person10_50.convertPerson((org.hl7.fhir.r5.model.Person) src); 235 if (src instanceof org.hl7.fhir.r5.model.Practitioner) 236 return Practitioner10_50.convertPractitioner((org.hl7.fhir.r5.model.Practitioner) src); 237 if (src instanceof org.hl7.fhir.r5.model.Provenance) 238 return Provenance10_50.convertProvenance((org.hl7.fhir.r5.model.Provenance) src); 239 if (src instanceof org.hl7.fhir.r5.model.Questionnaire) 240 return Questionnaire10_50.convertQuestionnaire((org.hl7.fhir.r5.model.Questionnaire) src); 241 if (src instanceof org.hl7.fhir.r5.model.QuestionnaireResponse) 242 return QuestionnaireResponse10_50.convertQuestionnaireResponse((org.hl7.fhir.r5.model.QuestionnaireResponse) src); 243 if (src instanceof org.hl7.fhir.r5.model.RiskAssessment) 244 return RiskAssessment10_50.convertRiskAssessment((org.hl7.fhir.r5.model.RiskAssessment) src); 245 if (src instanceof org.hl7.fhir.r5.model.Schedule) 246 return Schedule10_50.convertSchedule((org.hl7.fhir.r5.model.Schedule) src); 247 if (src instanceof org.hl7.fhir.r5.model.SearchParameter) 248 return SearchParameter10_50.convertSearchParameter((org.hl7.fhir.r5.model.SearchParameter) src); 249 if (src instanceof org.hl7.fhir.r5.model.Slot) return Slot10_50.convertSlot((org.hl7.fhir.r5.model.Slot) src); 250 if (src instanceof org.hl7.fhir.r5.model.StructureDefinition) 251 return StructureDefinition10_50.convertStructureDefinition((org.hl7.fhir.r5.model.StructureDefinition) src); 252 if (src instanceof org.hl7.fhir.r5.model.Substance) 253 return Substance10_50.convertSubstance((org.hl7.fhir.r5.model.Substance) src); 254 if (src instanceof org.hl7.fhir.r5.model.SupplyDelivery) 255 return SupplyDelivery10_50.convertSupplyDelivery((org.hl7.fhir.r5.model.SupplyDelivery) src); 256 if (src instanceof org.hl7.fhir.r5.model.SupplyRequest) 257 return SupplyRequest10_50.convertSupplyRequest((org.hl7.fhir.r5.model.SupplyRequest) src); 258 if (src instanceof org.hl7.fhir.r5.model.TestScript) 259 return TestScript10_50.convertTestScript((org.hl7.fhir.r5.model.TestScript) src); 260 if (src instanceof org.hl7.fhir.r5.model.ValueSet) 261 return ValueSet10_50.convertValueSet((org.hl7.fhir.r5.model.ValueSet) src, advisor); 262 if (advisor.failFastOnNullOrUnknownEntry()) { 263 throw new FHIRException("The resource " + src.fhirType()+" cannot be converted from R5 to R2"); 264 } else { 265 return null; 266 } 267 } 268 269 public void copyDomainResource( 270 org.hl7.fhir.dstu2.model.DomainResource src, 271 org.hl7.fhir.r5.model.DomainResource tgt, 272 String ... extensionUrlsToIgnore) throws FHIRException { 273 copyResource(src, tgt); 274 if (src.hasText()) tgt.setText(Narrative10_50.convertNarrative(src.getText())); 275 src.getContained().stream() 276 .map(this::convertResource) 277 .forEach(tgt::addContained); 278 src.getExtension().forEach(extension -> { 279 if (advisor.useAdvisorForExtension(ConversionContext10_50.INSTANCE.path(), extension)) { 280 org.hl7.fhir.r5.model.Extension convertExtension = new org.hl7.fhir.r5.model.Extension(); 281 advisor.handleExtension(ConversionContext10_50.INSTANCE.path(), extension, convertExtension); 282 tgt.addExtension(convertExtension); 283 } else if (!advisor.ignoreExtension(ConversionContext10_50.INSTANCE.path(), extension) && !Arrays.asList(extensionUrlsToIgnore).contains(extension.getUrl())) { 284 tgt.addExtension(Extension10_50.convertExtension(extension)); 285 } 286 }); 287 src.getModifierExtension().stream() 288 .filter(extension -> !advisor.ignoreExtension(ConversionContext10_50.INSTANCE.path(), extension)) 289 .map(Extension10_50::convertExtension) 290 .forEach(tgt::addModifierExtension); 291 } 292 293 public void copyDomainResource( 294 org.hl7.fhir.r5.model.DomainResource src, 295 org.hl7.fhir.dstu2.model.DomainResource tgt, 296 String ... extensionUrlsToIgnore) throws FHIRException { 297 copyResource(src, tgt); 298 if (src.hasText()) tgt.setText(Narrative10_50.convertNarrative(src.getText())); 299 src.getContained().stream() 300 .map(this::convertResource) 301 .forEach(tgt::addContained); 302 src.getExtension().forEach(extension -> { 303 if (advisor.useAdvisorForExtension(ConversionContext10_50.INSTANCE.path(), extension)) { 304 Extension convertExtension = new Extension(); 305 advisor.handleExtension(ConversionContext10_50.INSTANCE.path(), extension, convertExtension); 306 tgt.addExtension(convertExtension); 307 } else if (!advisor.ignoreExtension(ConversionContext10_50.INSTANCE.path(), extension) && !Arrays.asList(extensionUrlsToIgnore).contains(extension.getUrl())) { 308 tgt.addExtension(Extension10_50.convertExtension(extension)); 309 } 310 }); 311 src.getModifierExtension().stream() 312 .filter(extension -> !advisor.ignoreExtension(ConversionContext10_50.INSTANCE.path(), extension)) 313 .map(Extension10_50::convertExtension) 314 .forEach(tgt::addModifierExtension); 315 } 316}