001package org.hl7.fhir.convertors.conv30_50;
002
003import java.util.Arrays;
004
005import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_50;
006import org.hl7.fhir.convertors.context.ConversionContext30_50;
007import org.hl7.fhir.convertors.conv30_50.datatypes30_50.Extension30_50;
008import org.hl7.fhir.convertors.conv30_50.datatypes30_50.Meta30_50;
009import org.hl7.fhir.convertors.conv30_50.datatypes30_50.Narrative30_50;
010import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Code30_50;
011import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Id30_50;
012import org.hl7.fhir.convertors.conv30_50.resources30_50.ActivityDefinition30_50;
013import org.hl7.fhir.convertors.conv30_50.resources30_50.ActorDefinition30_50;
014import org.hl7.fhir.convertors.conv30_50.resources30_50.AllergyIntolerance30_50;
015import org.hl7.fhir.convertors.conv30_50.resources30_50.Appointment30_50;
016import org.hl7.fhir.convertors.conv30_50.resources30_50.AppointmentResponse30_50;
017import org.hl7.fhir.convertors.conv30_50.resources30_50.AuditEvent30_50;
018import org.hl7.fhir.convertors.conv30_50.resources30_50.Basic30_50;
019import org.hl7.fhir.convertors.conv30_50.resources30_50.Binary30_50;
020import org.hl7.fhir.convertors.conv30_50.resources30_50.BodySite30_50;
021import org.hl7.fhir.convertors.conv30_50.resources30_50.Bundle30_50;
022import org.hl7.fhir.convertors.conv30_50.resources30_50.CapabilityStatement30_50;
023import org.hl7.fhir.convertors.conv30_50.resources30_50.CarePlan30_50;
024import org.hl7.fhir.convertors.conv30_50.resources30_50.CareTeam30_50;
025import org.hl7.fhir.convertors.conv30_50.resources30_50.ClinicalImpression30_50;
026import org.hl7.fhir.convertors.conv30_50.resources30_50.CodeSystem30_50;
027import org.hl7.fhir.convertors.conv30_50.resources30_50.Communication30_50;
028import org.hl7.fhir.convertors.conv30_50.resources30_50.CompartmentDefinition30_50;
029import org.hl7.fhir.convertors.conv30_50.resources30_50.Composition30_50;
030import org.hl7.fhir.convertors.conv30_50.resources30_50.ConceptMap30_50;
031import org.hl7.fhir.convertors.conv30_50.resources30_50.Condition30_50;
032import org.hl7.fhir.convertors.conv30_50.resources30_50.Consent30_50;
033import org.hl7.fhir.convertors.conv30_50.resources30_50.DataElement30_50;
034import org.hl7.fhir.convertors.conv30_50.resources30_50.DetectedIssue30_50;
035import org.hl7.fhir.convertors.conv30_50.resources30_50.DeviceUseStatement30_50;
036import org.hl7.fhir.convertors.conv30_50.resources30_50.DiagnosticReport30_50;
037import org.hl7.fhir.convertors.conv30_50.resources30_50.DocumentReference30_50;
038import org.hl7.fhir.convertors.conv30_50.resources30_50.Encounter30_50;
039import org.hl7.fhir.convertors.conv30_50.resources30_50.Endpoint30_50;
040import org.hl7.fhir.convertors.conv30_50.resources30_50.EpisodeOfCare30_50;
041import org.hl7.fhir.convertors.conv30_50.resources30_50.ExpansionProfile30_50;
042import org.hl7.fhir.convertors.conv30_50.resources30_50.FamilyMemberHistory30_50;
043import org.hl7.fhir.convertors.conv30_50.resources30_50.Flag30_50;
044import org.hl7.fhir.convertors.conv30_50.resources30_50.Goal30_50;
045import org.hl7.fhir.convertors.conv30_50.resources30_50.GraphDefinition30_50;
046import org.hl7.fhir.convertors.conv30_50.resources30_50.Group30_50;
047import org.hl7.fhir.convertors.conv30_50.resources30_50.HealthcareService30_50;
048import org.hl7.fhir.convertors.conv30_50.resources30_50.ImagingStudy30_50;
049import org.hl7.fhir.convertors.conv30_50.resources30_50.Immunization30_50;
050import org.hl7.fhir.convertors.conv30_50.resources30_50.ImplementationGuide30_50;
051import org.hl7.fhir.convertors.conv30_50.resources30_50.Library30_50;
052import org.hl7.fhir.convertors.conv30_50.resources30_50.Linkage30_50;
053import org.hl7.fhir.convertors.conv30_50.resources30_50.List30_50;
054import org.hl7.fhir.convertors.conv30_50.resources30_50.Location30_50;
055import org.hl7.fhir.convertors.conv30_50.resources30_50.Measure30_50;
056import org.hl7.fhir.convertors.conv30_50.resources30_50.Media30_50;
057import org.hl7.fhir.convertors.conv30_50.resources30_50.Medication30_50;
058import org.hl7.fhir.convertors.conv30_50.resources30_50.MedicationAdministration30_50;
059import org.hl7.fhir.convertors.conv30_50.resources30_50.MedicationDispense30_50;
060import org.hl7.fhir.convertors.conv30_50.resources30_50.MedicationRequest30_50;
061import org.hl7.fhir.convertors.conv30_50.resources30_50.MedicationStatement30_50;
062import org.hl7.fhir.convertors.conv30_50.resources30_50.MessageDefinition30_50;
063import org.hl7.fhir.convertors.conv30_50.resources30_50.MessageHeader30_50;
064import org.hl7.fhir.convertors.conv30_50.resources30_50.NamingSystem30_50;
065import org.hl7.fhir.convertors.conv30_50.resources30_50.Observation30_50;
066import org.hl7.fhir.convertors.conv30_50.resources30_50.OperationDefinition30_50;
067import org.hl7.fhir.convertors.conv30_50.resources30_50.OperationOutcome30_50;
068import org.hl7.fhir.convertors.conv30_50.resources30_50.Organization30_50;
069import org.hl7.fhir.convertors.conv30_50.resources30_50.Parameters30_50;
070import org.hl7.fhir.convertors.conv30_50.resources30_50.Patient30_50;
071import org.hl7.fhir.convertors.conv30_50.resources30_50.PaymentNotice30_50;
072import org.hl7.fhir.convertors.conv30_50.resources30_50.Person30_50;
073import org.hl7.fhir.convertors.conv30_50.resources30_50.PlanDefinition30_50;
074import org.hl7.fhir.convertors.conv30_50.resources30_50.Practitioner30_50;
075import org.hl7.fhir.convertors.conv30_50.resources30_50.PractitionerRole30_50;
076import org.hl7.fhir.convertors.conv30_50.resources30_50.Provenance30_50;
077import org.hl7.fhir.convertors.conv30_50.resources30_50.Questionnaire30_50;
078import org.hl7.fhir.convertors.conv30_50.resources30_50.QuestionnaireResponse30_50;
079import org.hl7.fhir.convertors.conv30_50.resources30_50.RelatedPerson30_50;
080import org.hl7.fhir.convertors.conv30_50.resources30_50.Requirements30_50;
081import org.hl7.fhir.convertors.conv30_50.resources30_50.RiskAssessment30_50;
082import org.hl7.fhir.convertors.conv30_50.resources30_50.Schedule30_50;
083import org.hl7.fhir.convertors.conv30_50.resources30_50.SearchParameter30_50;
084import org.hl7.fhir.convertors.conv30_50.resources30_50.Slot30_50;
085import org.hl7.fhir.convertors.conv30_50.resources30_50.Specimen30_50;
086import org.hl7.fhir.convertors.conv30_50.resources30_50.StructureDefinition30_50;
087import org.hl7.fhir.convertors.conv30_50.resources30_50.StructureMap30_50;
088import org.hl7.fhir.convertors.conv30_50.resources30_50.Substance30_50;
089import org.hl7.fhir.convertors.conv30_50.resources30_50.SupplyDelivery30_50;
090import org.hl7.fhir.convertors.conv30_50.resources30_50.TestPlan30_50;
091import org.hl7.fhir.convertors.conv30_50.resources30_50.TestReport30_50;
092import org.hl7.fhir.convertors.conv30_50.resources30_50.TestScript30_50;
093import org.hl7.fhir.convertors.conv30_50.resources30_50.ValueSet30_50;
094import org.hl7.fhir.dstu3.model.Basic;
095import org.hl7.fhir.exceptions.FHIRException;
096
097public class Resource30_50 {
098
099  public final BaseAdvisor_30_50 advisor;
100
101  public Resource30_50(BaseAdvisor_30_50 advisor) {
102    this.advisor = advisor;
103  }
104
105  public void copyResource(org.hl7.fhir.dstu3.model.Resource src, org.hl7.fhir.r5.model.Resource tgt) throws FHIRException {
106    if (src.hasId()) tgt.setIdElement(Id30_50.convertId(src.getIdElement()));
107    if (src.hasMeta()) tgt.setMeta(Meta30_50.convertMeta(src.getMeta()));
108    if (src.hasImplicitRules()) tgt.setImplicitRules(src.getImplicitRules());
109    if (src.hasLanguage()) tgt.setLanguageElement(Code30_50.convertCode(src.getLanguageElement()));
110  }
111
112  public void copyResource(org.hl7.fhir.r5.model.Resource src, org.hl7.fhir.dstu3.model.Resource tgt) throws FHIRException {
113    if (src.hasId()) tgt.setIdElement(Id30_50.convertId(src.getIdElement()));
114    if (src.hasMeta()) tgt.setMeta(Meta30_50.convertMeta(src.getMeta()));
115    if (src.hasImplicitRules()) tgt.setImplicitRules(src.getImplicitRules());
116    if (src.hasLanguage()) tgt.setLanguageElement(Code30_50.convertCode(src.getLanguageElement()));
117  }
118
119  public org.hl7.fhir.r5.model.Resource convertResource(org.hl7.fhir.dstu3.model.Resource src) throws FHIRException {
120    if (src == null) return null;
121    if (src instanceof org.hl7.fhir.dstu3.model.Parameters)
122      return Parameters30_50.convertParameters((org.hl7.fhir.dstu3.model.Parameters) src);
123    if (src instanceof org.hl7.fhir.dstu3.model.ActivityDefinition)
124      return ActivityDefinition30_50.convertActivityDefinition((org.hl7.fhir.dstu3.model.ActivityDefinition) src);
125    if (src instanceof org.hl7.fhir.dstu3.model.AllergyIntolerance)
126      return AllergyIntolerance30_50.convertAllergyIntolerance((org.hl7.fhir.dstu3.model.AllergyIntolerance) src);
127    if (src instanceof org.hl7.fhir.dstu3.model.Appointment)
128      return Appointment30_50.convertAppointment((org.hl7.fhir.dstu3.model.Appointment) src);
129    if (src instanceof org.hl7.fhir.dstu3.model.AppointmentResponse)
130      return AppointmentResponse30_50.convertAppointmentResponse((org.hl7.fhir.dstu3.model.AppointmentResponse) src);
131    if (src instanceof org.hl7.fhir.dstu3.model.AuditEvent)
132      return AuditEvent30_50.convertAuditEvent((org.hl7.fhir.dstu3.model.AuditEvent) src);
133    if (src instanceof org.hl7.fhir.dstu3.model.Basic) {
134      org.hl7.fhir.dstu3.model.Basic basic = (Basic) src;
135      if (basic.getCode().hasCoding("http://hl7.org/fhir/fhir-types", "ActorDefinition")) {
136        return ActorDefinition30_50.convertActorDefinition((org.hl7.fhir.dstu3.model.Basic) src);
137      } else if (basic.getCode().hasCoding("http://hl7.org/fhir/fhir-types", "Requirements")) {
138        return Requirements30_50.convertRequirements((org.hl7.fhir.dstu3.model.Basic) src);
139      } else if (basic.getCode().hasCoding("http://hl7.org/fhir/fhir-types", "TestPlan")) {
140        return TestPlan30_50.convertTestPlan((org.hl7.fhir.dstu3.model.Basic) src);
141      } else {
142        return Basic30_50.convertBasic((org.hl7.fhir.dstu3.model.Basic) src);
143      }
144    }
145    if (src instanceof org.hl7.fhir.dstu3.model.Binary)
146      return Binary30_50.convertBinary((org.hl7.fhir.dstu3.model.Binary) src);
147    if (src instanceof org.hl7.fhir.dstu3.model.BodySite)
148      return BodySite30_50.convertBodySite((org.hl7.fhir.dstu3.model.BodySite) src);
149    if (src instanceof org.hl7.fhir.dstu3.model.Bundle)
150      return Bundle30_50.convertBundle((org.hl7.fhir.dstu3.model.Bundle) src);
151    if (src instanceof org.hl7.fhir.dstu3.model.CapabilityStatement)
152      return CapabilityStatement30_50.convertCapabilityStatement((org.hl7.fhir.dstu3.model.CapabilityStatement) src);
153    if (src instanceof org.hl7.fhir.dstu3.model.CarePlan)
154      return CarePlan30_50.convertCarePlan((org.hl7.fhir.dstu3.model.CarePlan) src);
155    if (src instanceof org.hl7.fhir.dstu3.model.CareTeam)
156      return CareTeam30_50.convertCareTeam((org.hl7.fhir.dstu3.model.CareTeam) src);
157    if (src instanceof org.hl7.fhir.dstu3.model.ClinicalImpression)
158      return ClinicalImpression30_50.convertClinicalImpression((org.hl7.fhir.dstu3.model.ClinicalImpression) src);
159    if (src instanceof org.hl7.fhir.dstu3.model.CodeSystem)
160      return CodeSystem30_50.convertCodeSystem((org.hl7.fhir.dstu3.model.CodeSystem) src);
161    if (src instanceof org.hl7.fhir.dstu3.model.Communication)
162      return Communication30_50.convertCommunication((org.hl7.fhir.dstu3.model.Communication) src);
163    if (src instanceof org.hl7.fhir.dstu3.model.CompartmentDefinition)
164      return CompartmentDefinition30_50.convertCompartmentDefinition((org.hl7.fhir.dstu3.model.CompartmentDefinition) src);
165    if (src instanceof org.hl7.fhir.dstu3.model.Composition)
166      return Composition30_50.convertComposition((org.hl7.fhir.dstu3.model.Composition) src);
167    if (src instanceof org.hl7.fhir.dstu3.model.ConceptMap)
168      return ConceptMap30_50.convertConceptMap((org.hl7.fhir.dstu3.model.ConceptMap) src);
169    if (src instanceof org.hl7.fhir.dstu3.model.Condition)
170      return Condition30_50.convertCondition((org.hl7.fhir.dstu3.model.Condition) src);
171    if (src instanceof org.hl7.fhir.dstu3.model.Consent)
172      return Consent30_50.convertConsent((org.hl7.fhir.dstu3.model.Consent) src);
173    if (src instanceof org.hl7.fhir.dstu3.model.DataElement)
174      return DataElement30_50.convertDataElement((org.hl7.fhir.dstu3.model.DataElement) src);
175    if (src instanceof org.hl7.fhir.dstu3.model.DetectedIssue)
176      return DetectedIssue30_50.convertDetectedIssue((org.hl7.fhir.dstu3.model.DetectedIssue) src);
177    if (src instanceof org.hl7.fhir.dstu3.model.DeviceUseStatement)
178      return DeviceUseStatement30_50.convertDeviceUseStatement((org.hl7.fhir.dstu3.model.DeviceUseStatement) src);
179    if (src instanceof org.hl7.fhir.dstu3.model.DiagnosticReport)
180      return DiagnosticReport30_50.convertDiagnosticReport((org.hl7.fhir.dstu3.model.DiagnosticReport) src);
181    if (src instanceof org.hl7.fhir.dstu3.model.DocumentReference)
182      return DocumentReference30_50.convertDocumentReference((org.hl7.fhir.dstu3.model.DocumentReference) src);
183    if (src instanceof org.hl7.fhir.dstu3.model.Encounter)
184      return Encounter30_50.convertEncounter((org.hl7.fhir.dstu3.model.Encounter) src);
185    if (src instanceof org.hl7.fhir.dstu3.model.Endpoint)
186      return Endpoint30_50.convertEndpoint((org.hl7.fhir.dstu3.model.Endpoint) src);
187    if (src instanceof org.hl7.fhir.dstu3.model.EpisodeOfCare)
188      return EpisodeOfCare30_50.convertEpisodeOfCare((org.hl7.fhir.dstu3.model.EpisodeOfCare) src);
189    if (src instanceof org.hl7.fhir.dstu3.model.ExpansionProfile)
190      return ExpansionProfile30_50.convertExpansionProfile((org.hl7.fhir.dstu3.model.ExpansionProfile) src);
191    if (src instanceof org.hl7.fhir.dstu3.model.FamilyMemberHistory)
192      return FamilyMemberHistory30_50.convertFamilyMemberHistory((org.hl7.fhir.dstu3.model.FamilyMemberHistory) src);
193    if (src instanceof org.hl7.fhir.dstu3.model.Flag) return Flag30_50.convertFlag((org.hl7.fhir.dstu3.model.Flag) src);
194    if (src instanceof org.hl7.fhir.dstu3.model.Goal) return Goal30_50.convertGoal((org.hl7.fhir.dstu3.model.Goal) src);
195    if (src instanceof org.hl7.fhir.dstu3.model.GraphDefinition)
196      return GraphDefinition30_50.convertGraphDefinition((org.hl7.fhir.dstu3.model.GraphDefinition) src);
197    if (src instanceof org.hl7.fhir.dstu3.model.Group)
198      return Group30_50.convertGroup((org.hl7.fhir.dstu3.model.Group) src);
199    if (src instanceof org.hl7.fhir.dstu3.model.HealthcareService)
200      return HealthcareService30_50.convertHealthcareService((org.hl7.fhir.dstu3.model.HealthcareService) src);
201    if (src instanceof org.hl7.fhir.dstu3.model.ImagingStudy)
202      return ImagingStudy30_50.convertImagingStudy((org.hl7.fhir.dstu3.model.ImagingStudy) src);
203    if (src instanceof org.hl7.fhir.dstu3.model.Immunization)
204      return Immunization30_50.convertImmunization((org.hl7.fhir.dstu3.model.Immunization) src);
205    if (src instanceof org.hl7.fhir.dstu3.model.ImplementationGuide)
206      return ImplementationGuide30_50.convertImplementationGuide((org.hl7.fhir.dstu3.model.ImplementationGuide) src);
207    if (src instanceof org.hl7.fhir.dstu3.model.Library)
208      return Library30_50.convertLibrary((org.hl7.fhir.dstu3.model.Library) src);
209    if (src instanceof org.hl7.fhir.dstu3.model.Linkage)
210      return Linkage30_50.convertLinkage((org.hl7.fhir.dstu3.model.Linkage) src);
211    if (src instanceof org.hl7.fhir.dstu3.model.ListResource)
212      return List30_50.convertList((org.hl7.fhir.dstu3.model.ListResource) src);
213    if (src instanceof org.hl7.fhir.dstu3.model.Location)
214      return Location30_50.convertLocation((org.hl7.fhir.dstu3.model.Location) src);
215    if (src instanceof org.hl7.fhir.dstu3.model.Measure)
216      return Measure30_50.convertMeasure((org.hl7.fhir.dstu3.model.Measure) src);
217    if (src instanceof org.hl7.fhir.dstu3.model.Media)
218      return Media30_50.convertMedia((org.hl7.fhir.dstu3.model.Media) src);
219    if (src instanceof org.hl7.fhir.dstu3.model.Medication)
220      return Medication30_50.convertMedication((org.hl7.fhir.dstu3.model.Medication) src);
221    if (src instanceof org.hl7.fhir.dstu3.model.MedicationAdministration)
222      return MedicationAdministration30_50.convertMedicationAdministration((org.hl7.fhir.dstu3.model.MedicationAdministration) src);
223    if (src instanceof org.hl7.fhir.dstu3.model.MedicationDispense)
224      return MedicationDispense30_50.convertMedicationDispense((org.hl7.fhir.dstu3.model.MedicationDispense) src);
225    if (src instanceof org.hl7.fhir.dstu3.model.MedicationRequest)
226      return MedicationRequest30_50.convertMedicationRequest((org.hl7.fhir.dstu3.model.MedicationRequest) src);
227    if (src instanceof org.hl7.fhir.dstu3.model.MedicationStatement)
228      return MedicationStatement30_50.convertMedicationStatement((org.hl7.fhir.dstu3.model.MedicationStatement) src);
229    if (src instanceof org.hl7.fhir.dstu3.model.MessageDefinition)
230      return MessageDefinition30_50.convertMessageDefinition((org.hl7.fhir.dstu3.model.MessageDefinition) src);
231    if (src instanceof org.hl7.fhir.dstu3.model.MessageHeader)
232      return MessageHeader30_50.convertMessageHeader((org.hl7.fhir.dstu3.model.MessageHeader) src);
233    if (src instanceof org.hl7.fhir.dstu3.model.NamingSystem)
234      return NamingSystem30_50.convertNamingSystem((org.hl7.fhir.dstu3.model.NamingSystem) src);
235    if (src instanceof org.hl7.fhir.dstu3.model.Observation)
236      return Observation30_50.convertObservation((org.hl7.fhir.dstu3.model.Observation) src);
237    if (src instanceof org.hl7.fhir.dstu3.model.OperationDefinition)
238      return OperationDefinition30_50.convertOperationDefinition((org.hl7.fhir.dstu3.model.OperationDefinition) src);
239    if (src instanceof org.hl7.fhir.dstu3.model.OperationOutcome)
240      return OperationOutcome30_50.convertOperationOutcome((org.hl7.fhir.dstu3.model.OperationOutcome) src);
241    if (src instanceof org.hl7.fhir.dstu3.model.Organization)
242      return Organization30_50.convertOrganization((org.hl7.fhir.dstu3.model.Organization) src);
243    if (src instanceof org.hl7.fhir.dstu3.model.Patient)
244      return Patient30_50.convertPatient((org.hl7.fhir.dstu3.model.Patient) src);
245    if (src instanceof org.hl7.fhir.dstu3.model.PaymentNotice)
246      return PaymentNotice30_50.convertPaymentNotice((org.hl7.fhir.dstu3.model.PaymentNotice) src);
247    if (src instanceof org.hl7.fhir.dstu3.model.Person)
248      return Person30_50.convertPerson((org.hl7.fhir.dstu3.model.Person) src);
249    if (src instanceof org.hl7.fhir.dstu3.model.PlanDefinition)
250      return PlanDefinition30_50.convertPlanDefinition((org.hl7.fhir.dstu3.model.PlanDefinition) src);
251    if (src instanceof org.hl7.fhir.dstu3.model.Practitioner)
252      return Practitioner30_50.convertPractitioner((org.hl7.fhir.dstu3.model.Practitioner) src);
253    if (src instanceof org.hl7.fhir.dstu3.model.PractitionerRole)
254      return PractitionerRole30_50.convertPractitionerRole((org.hl7.fhir.dstu3.model.PractitionerRole) src);
255    if (src instanceof org.hl7.fhir.dstu3.model.Provenance)
256      return Provenance30_50.convertProvenance((org.hl7.fhir.dstu3.model.Provenance) src);
257    if (src instanceof org.hl7.fhir.dstu3.model.Questionnaire)
258      return Questionnaire30_50.convertQuestionnaire((org.hl7.fhir.dstu3.model.Questionnaire) src);
259    if (src instanceof org.hl7.fhir.dstu3.model.QuestionnaireResponse)
260      return QuestionnaireResponse30_50.convertQuestionnaireResponse((org.hl7.fhir.dstu3.model.QuestionnaireResponse) src);
261    if (src instanceof org.hl7.fhir.dstu3.model.RelatedPerson)
262      return RelatedPerson30_50.convertRelatedPerson((org.hl7.fhir.dstu3.model.RelatedPerson) src);
263    if (src instanceof org.hl7.fhir.dstu3.model.RiskAssessment)
264      return RiskAssessment30_50.convertRiskAssessment((org.hl7.fhir.dstu3.model.RiskAssessment) src);
265    if (src instanceof org.hl7.fhir.dstu3.model.Schedule)
266      return Schedule30_50.convertSchedule((org.hl7.fhir.dstu3.model.Schedule) src);
267    if (src instanceof org.hl7.fhir.dstu3.model.SearchParameter)
268      return SearchParameter30_50.convertSearchParameter((org.hl7.fhir.dstu3.model.SearchParameter) src);
269    if (src instanceof org.hl7.fhir.dstu3.model.Slot) return Slot30_50.convertSlot((org.hl7.fhir.dstu3.model.Slot) src);
270    if (src instanceof org.hl7.fhir.dstu3.model.Specimen)
271      return Specimen30_50.convertSpecimen((org.hl7.fhir.dstu3.model.Specimen) src);
272    if (src instanceof org.hl7.fhir.dstu3.model.StructureDefinition)
273      return StructureDefinition30_50.convertStructureDefinition((org.hl7.fhir.dstu3.model.StructureDefinition) src);
274    if (src instanceof org.hl7.fhir.dstu3.model.StructureMap)
275      return StructureMap30_50.convertStructureMap((org.hl7.fhir.dstu3.model.StructureMap) src);
276    if (src instanceof org.hl7.fhir.dstu3.model.Substance)
277      return Substance30_50.convertSubstance((org.hl7.fhir.dstu3.model.Substance) src);
278    if (src instanceof org.hl7.fhir.dstu3.model.SupplyDelivery)
279      return SupplyDelivery30_50.convertSupplyDelivery((org.hl7.fhir.dstu3.model.SupplyDelivery) src);
280    if (src instanceof org.hl7.fhir.dstu3.model.TestReport)
281      return TestReport30_50.convertTestReport((org.hl7.fhir.dstu3.model.TestReport) src);
282    if (src instanceof org.hl7.fhir.dstu3.model.TestScript)
283      return TestScript30_50.convertTestScript((org.hl7.fhir.dstu3.model.TestScript) src);
284    if (src instanceof org.hl7.fhir.dstu3.model.ValueSet)
285      return ValueSet30_50.convertValueSet((org.hl7.fhir.dstu3.model.ValueSet) src);
286    if (advisor.failFastOnNullOrUnknownEntry()) {
287      throw new FHIRException("The resource " + src.fhirType()+" cannot be converted from R3 to R5");
288    }
289    else return null;
290  }
291
292  public org.hl7.fhir.dstu3.model.Resource convertResource(org.hl7.fhir.r5.model.Resource src) throws FHIRException {
293    if (src == null) return null;
294    if (src instanceof org.hl7.fhir.r5.model.Parameters) {
295//      if (((org.hl7.fhir.r5.model.Parameters) src).hasParameterValue("profile-url"))
296//        return ExpansionProfile30_50.convertExpansionProfile((org.hl7.fhir.r5.model.Parameters) src);
297//      else
298        return Parameters30_50.convertParameters((org.hl7.fhir.r5.model.Parameters) src);
299    }
300    if (src instanceof org.hl7.fhir.r5.model.ActivityDefinition)
301      return ActivityDefinition30_50.convertActivityDefinition((org.hl7.fhir.r5.model.ActivityDefinition) src);
302    if (src instanceof org.hl7.fhir.r5.model.ActorDefinition)
303      return ActorDefinition30_50.convertActorDefinition((org.hl7.fhir.r5.model.ActorDefinition) src);
304    if (src instanceof org.hl7.fhir.r5.model.AllergyIntolerance)
305      return AllergyIntolerance30_50.convertAllergyIntolerance((org.hl7.fhir.r5.model.AllergyIntolerance) src);
306    if (src instanceof org.hl7.fhir.r5.model.Appointment)
307      return Appointment30_50.convertAppointment((org.hl7.fhir.r5.model.Appointment) src);
308    if (src instanceof org.hl7.fhir.r5.model.AppointmentResponse)
309      return AppointmentResponse30_50.convertAppointmentResponse((org.hl7.fhir.r5.model.AppointmentResponse) src);
310    if (src instanceof org.hl7.fhir.r5.model.AuditEvent)
311      return AuditEvent30_50.convertAuditEvent((org.hl7.fhir.r5.model.AuditEvent) src);
312    if (src instanceof org.hl7.fhir.r5.model.Basic)
313      return Basic30_50.convertBasic((org.hl7.fhir.r5.model.Basic) src);
314    if (src instanceof org.hl7.fhir.r5.model.Binary)
315      return Binary30_50.convertBinary((org.hl7.fhir.r5.model.Binary) src);
316    if (src instanceof org.hl7.fhir.r5.model.BodyStructure)
317      return BodySite30_50.convertBodySite((org.hl7.fhir.r5.model.BodyStructure) src);
318    if (src instanceof org.hl7.fhir.r5.model.Bundle)
319      return Bundle30_50.convertBundle((org.hl7.fhir.r5.model.Bundle) src);
320    if (src instanceof org.hl7.fhir.r5.model.CapabilityStatement)
321      return CapabilityStatement30_50.convertCapabilityStatement((org.hl7.fhir.r5.model.CapabilityStatement) src);
322    if (src instanceof org.hl7.fhir.r5.model.CarePlan)
323      return CarePlan30_50.convertCarePlan((org.hl7.fhir.r5.model.CarePlan) src);
324    if (src instanceof org.hl7.fhir.r5.model.CareTeam)
325      return CareTeam30_50.convertCareTeam((org.hl7.fhir.r5.model.CareTeam) src);
326    if (src instanceof org.hl7.fhir.r5.model.ClinicalImpression)
327      return ClinicalImpression30_50.convertClinicalImpression((org.hl7.fhir.r5.model.ClinicalImpression) src);
328    if (src instanceof org.hl7.fhir.r5.model.CodeSystem)
329      return CodeSystem30_50.convertCodeSystem((org.hl7.fhir.r5.model.CodeSystem) src);
330    if (src instanceof org.hl7.fhir.r5.model.Communication)
331      return Communication30_50.convertCommunication((org.hl7.fhir.r5.model.Communication) src);
332    if (src instanceof org.hl7.fhir.r5.model.CompartmentDefinition)
333      return CompartmentDefinition30_50.convertCompartmentDefinition((org.hl7.fhir.r5.model.CompartmentDefinition) src);
334    if (src instanceof org.hl7.fhir.r5.model.Composition)
335      return Composition30_50.convertComposition((org.hl7.fhir.r5.model.Composition) src);
336    if (src instanceof org.hl7.fhir.r5.model.ConceptMap)
337      return ConceptMap30_50.convertConceptMap((org.hl7.fhir.r5.model.ConceptMap) src);
338    if (src instanceof org.hl7.fhir.r5.model.Condition)
339      return Condition30_50.convertCondition((org.hl7.fhir.r5.model.Condition) src);
340    if (src instanceof org.hl7.fhir.r5.model.Consent)
341      return Consent30_50.convertConsent((org.hl7.fhir.r5.model.Consent) src);
342    if (src instanceof org.hl7.fhir.r5.model.DetectedIssue)
343      return DetectedIssue30_50.convertDetectedIssue((org.hl7.fhir.r5.model.DetectedIssue) src);
344    if (src instanceof org.hl7.fhir.r5.model.DeviceUsage)
345      return DeviceUseStatement30_50.convertDeviceUseStatement((org.hl7.fhir.r5.model.DeviceUsage) src);
346    if (src instanceof org.hl7.fhir.r5.model.DiagnosticReport)
347      return DiagnosticReport30_50.convertDiagnosticReport((org.hl7.fhir.r5.model.DiagnosticReport) src);
348    if (src instanceof org.hl7.fhir.r5.model.DocumentReference)
349      return DocumentReference30_50.convertDocumentReference((org.hl7.fhir.r5.model.DocumentReference) src);
350    if (src instanceof org.hl7.fhir.r5.model.Encounter)
351      return Encounter30_50.convertEncounter((org.hl7.fhir.r5.model.Encounter) src);
352    if (src instanceof org.hl7.fhir.r5.model.Endpoint)
353      return Endpoint30_50.convertEndpoint((org.hl7.fhir.r5.model.Endpoint) src);
354    if (src instanceof org.hl7.fhir.r5.model.EpisodeOfCare)
355      return EpisodeOfCare30_50.convertEpisodeOfCare((org.hl7.fhir.r5.model.EpisodeOfCare) src);
356    if (src instanceof org.hl7.fhir.r5.model.FamilyMemberHistory)
357      return FamilyMemberHistory30_50.convertFamilyMemberHistory((org.hl7.fhir.r5.model.FamilyMemberHistory) src);
358    if (src instanceof org.hl7.fhir.r5.model.Flag) return Flag30_50.convertFlag((org.hl7.fhir.r5.model.Flag) src);
359    if (src instanceof org.hl7.fhir.r5.model.Goal) return Goal30_50.convertGoal((org.hl7.fhir.r5.model.Goal) src);
360    if (src instanceof org.hl7.fhir.r5.model.GraphDefinition)
361      return GraphDefinition30_50.convertGraphDefinition((org.hl7.fhir.r5.model.GraphDefinition) src);
362    if (src instanceof org.hl7.fhir.r5.model.Group) return Group30_50.convertGroup((org.hl7.fhir.r5.model.Group) src);
363    if (src instanceof org.hl7.fhir.r5.model.HealthcareService)
364      return HealthcareService30_50.convertHealthcareService((org.hl7.fhir.r5.model.HealthcareService) src);
365    if (src instanceof org.hl7.fhir.r5.model.ImagingStudy)
366      return ImagingStudy30_50.convertImagingStudy((org.hl7.fhir.r5.model.ImagingStudy) src);
367    if (src instanceof org.hl7.fhir.r5.model.Immunization)
368      return Immunization30_50.convertImmunization((org.hl7.fhir.r5.model.Immunization) src);
369    if (src instanceof org.hl7.fhir.r5.model.ImplementationGuide)
370      return ImplementationGuide30_50.convertImplementationGuide((org.hl7.fhir.r5.model.ImplementationGuide) src);
371    if (src instanceof org.hl7.fhir.r5.model.Library)
372      return Library30_50.convertLibrary((org.hl7.fhir.r5.model.Library) src);
373    if (src instanceof org.hl7.fhir.r5.model.Linkage)
374      return Linkage30_50.convertLinkage((org.hl7.fhir.r5.model.Linkage) src);
375    if (src instanceof org.hl7.fhir.r5.model.ListResource)
376      return List30_50.convertList((org.hl7.fhir.r5.model.ListResource) src);
377    if (src instanceof org.hl7.fhir.r5.model.Location)
378      return Location30_50.convertLocation((org.hl7.fhir.r5.model.Location) src);
379    if (src instanceof org.hl7.fhir.r5.model.Measure)
380      return Measure30_50.convertMeasure((org.hl7.fhir.r5.model.Measure) src);
381    if (src instanceof org.hl7.fhir.r5.model.DocumentReference)
382      return Media30_50.convertMedia((org.hl7.fhir.r5.model.DocumentReference) src);
383    if (src instanceof org.hl7.fhir.r5.model.Medication)
384      return Medication30_50.convertMedication((org.hl7.fhir.r5.model.Medication) src);
385    if (src instanceof org.hl7.fhir.r5.model.MedicationAdministration)
386      return MedicationAdministration30_50.convertMedicationAdministration((org.hl7.fhir.r5.model.MedicationAdministration) src);
387    if (src instanceof org.hl7.fhir.r5.model.MedicationDispense)
388      return MedicationDispense30_50.convertMedicationDispense((org.hl7.fhir.r5.model.MedicationDispense) src);
389    if (src instanceof org.hl7.fhir.r5.model.MedicationRequest)
390      return MedicationRequest30_50.convertMedicationRequest((org.hl7.fhir.r5.model.MedicationRequest) src);
391    if (src instanceof org.hl7.fhir.r5.model.MedicationStatement)
392      return MedicationStatement30_50.convertMedicationStatement((org.hl7.fhir.r5.model.MedicationStatement) src);
393    if (src instanceof org.hl7.fhir.r5.model.MessageDefinition)
394      return MessageDefinition30_50.convertMessageDefinition((org.hl7.fhir.r5.model.MessageDefinition) src);
395    if (src instanceof org.hl7.fhir.r5.model.MessageHeader)
396      return MessageHeader30_50.convertMessageHeader((org.hl7.fhir.r5.model.MessageHeader) src);
397    if (src instanceof org.hl7.fhir.r5.model.NamingSystem)
398      return NamingSystem30_50.convertNamingSystem((org.hl7.fhir.r5.model.NamingSystem) src);
399    if (src instanceof org.hl7.fhir.r5.model.Observation)
400      return Observation30_50.convertObservation((org.hl7.fhir.r5.model.Observation) src);
401    if (src instanceof org.hl7.fhir.r5.model.OperationDefinition)
402      return OperationDefinition30_50.convertOperationDefinition((org.hl7.fhir.r5.model.OperationDefinition) src);
403    if (src instanceof org.hl7.fhir.r5.model.OperationOutcome)
404      return OperationOutcome30_50.convertOperationOutcome((org.hl7.fhir.r5.model.OperationOutcome) src);
405    if (src instanceof org.hl7.fhir.r5.model.Organization)
406      return Organization30_50.convertOrganization((org.hl7.fhir.r5.model.Organization) src);
407    if (src instanceof org.hl7.fhir.r5.model.Patient)
408      return Patient30_50.convertPatient((org.hl7.fhir.r5.model.Patient) src);
409    if (src instanceof org.hl7.fhir.r5.model.PaymentNotice)
410      return PaymentNotice30_50.convertPaymentNotice((org.hl7.fhir.r5.model.PaymentNotice) src);
411    if (src instanceof org.hl7.fhir.r5.model.Person)
412      return Person30_50.convertPerson((org.hl7.fhir.r5.model.Person) src);
413    if (src instanceof org.hl7.fhir.r5.model.PlanDefinition)
414      return PlanDefinition30_50.convertPlanDefinition((org.hl7.fhir.r5.model.PlanDefinition) src);
415    if (src instanceof org.hl7.fhir.r5.model.Practitioner)
416      return Practitioner30_50.convertPractitioner((org.hl7.fhir.r5.model.Practitioner) src);
417    if (src instanceof org.hl7.fhir.r5.model.PractitionerRole)
418      return PractitionerRole30_50.convertPractitionerRole((org.hl7.fhir.r5.model.PractitionerRole) src);
419    if (src instanceof org.hl7.fhir.r5.model.Provenance)
420      return Provenance30_50.convertProvenance((org.hl7.fhir.r5.model.Provenance) src);
421    if (src instanceof org.hl7.fhir.r5.model.Questionnaire)
422      return Questionnaire30_50.convertQuestionnaire((org.hl7.fhir.r5.model.Questionnaire) src);
423    if (src instanceof org.hl7.fhir.r5.model.QuestionnaireResponse)
424      return QuestionnaireResponse30_50.convertQuestionnaireResponse((org.hl7.fhir.r5.model.QuestionnaireResponse) src);
425    if (src instanceof org.hl7.fhir.r5.model.RelatedPerson)
426      return RelatedPerson30_50.convertRelatedPerson((org.hl7.fhir.r5.model.RelatedPerson) src);
427    if (src instanceof org.hl7.fhir.r5.model.Requirements)
428      return Requirements30_50.convertRequirements((org.hl7.fhir.r5.model.Requirements) src);
429    if (src instanceof org.hl7.fhir.r5.model.RiskAssessment)
430      return RiskAssessment30_50.convertRiskAssessment((org.hl7.fhir.r5.model.RiskAssessment) src);
431    if (src instanceof org.hl7.fhir.r5.model.Schedule)
432      return Schedule30_50.convertSchedule((org.hl7.fhir.r5.model.Schedule) src);
433    if (src instanceof org.hl7.fhir.r5.model.SearchParameter)
434      return SearchParameter30_50.convertSearchParameter((org.hl7.fhir.r5.model.SearchParameter) src);
435    if (src instanceof org.hl7.fhir.r5.model.Slot) return Slot30_50.convertSlot((org.hl7.fhir.r5.model.Slot) src);
436    if (src instanceof org.hl7.fhir.r5.model.Specimen)
437      return Specimen30_50.convertSpecimen((org.hl7.fhir.r5.model.Specimen) src);
438    if (src instanceof org.hl7.fhir.r5.model.StructureDefinition)
439      return StructureDefinition30_50.convertStructureDefinition((org.hl7.fhir.r5.model.StructureDefinition) src);
440    if (src instanceof org.hl7.fhir.r5.model.StructureMap)
441      return StructureMap30_50.convertStructureMap((org.hl7.fhir.r5.model.StructureMap) src);
442    if (src instanceof org.hl7.fhir.r5.model.Substance)
443      return Substance30_50.convertSubstance((org.hl7.fhir.r5.model.Substance) src);
444    if (src instanceof org.hl7.fhir.r5.model.SupplyDelivery)
445      return SupplyDelivery30_50.convertSupplyDelivery((org.hl7.fhir.r5.model.SupplyDelivery) src);
446    if (src instanceof org.hl7.fhir.r5.model.TestPlan)
447      return TestPlan30_50.convertTestPlan((org.hl7.fhir.r5.model.TestPlan) src);
448    if (src instanceof org.hl7.fhir.r5.model.TestReport)
449      return TestReport30_50.convertTestReport((org.hl7.fhir.r5.model.TestReport) src);
450    if (src instanceof org.hl7.fhir.r5.model.TestScript)
451      return TestScript30_50.convertTestScript((org.hl7.fhir.r5.model.TestScript) src);
452    if (src instanceof org.hl7.fhir.r5.model.ValueSet)
453      return ValueSet30_50.convertValueSet((org.hl7.fhir.r5.model.ValueSet) src);
454    if (advisor.failFastOnNullOrUnknownEntry()) {
455      throw new FHIRException("The resource " + src.fhirType()+" cannot be converted from R5 to R3");
456    } else {
457      return null;
458    }
459  }
460
461  public void copyDomainResource(org.hl7.fhir.dstu3.model.DomainResource src,
462                                 org.hl7.fhir.r5.model.DomainResource tgt, String... extensionUrlsToIgnore) throws FHIRException {
463    copyResource(src, tgt);
464    if (src.hasText()) tgt.setText(Narrative30_50.convertNarrative(src.getText()));
465    src.getContained().stream()
466      .map(this::convertResource)
467      .forEach(tgt::addContained);
468    src.getExtension().forEach(extension -> {
469      if (advisor.useAdvisorForExtension(ConversionContext30_50.INSTANCE.path(), extension)) {
470        org.hl7.fhir.r5.model.Extension convertExtension = new org.hl7.fhir.r5.model.Extension();
471        advisor.handleExtension(ConversionContext30_50.INSTANCE.path(), extension, convertExtension);
472        tgt.addExtension(convertExtension);
473      } else if (!advisor.ignoreExtension(ConversionContext30_50.INSTANCE.path(), extension) && !Arrays.asList(extensionUrlsToIgnore).contains(extension.getUrl())) {
474        tgt.addExtension(Extension30_50.convertExtension(extension));
475      }
476    });
477    src.getModifierExtension().stream()
478      .filter(extension -> !advisor.ignoreExtension(ConversionContext30_50.INSTANCE.path(), extension))
479      .map(Extension30_50::convertExtension)
480      .forEach(tgt::addModifierExtension);
481  }
482
483  public void copyDomainResource(org.hl7.fhir.r5.model.DomainResource src,
484                                 org.hl7.fhir.dstu3.model.DomainResource tgt, String... extensionUrlsToIgnore) throws FHIRException {
485    copyResource(src, tgt);
486    if (src.hasText()) tgt.setText(Narrative30_50.convertNarrative(src.getText()));
487    src.getContained().stream()
488      .map(this::convertResource)
489      .forEach(tgt::addContained);
490    src.getExtension().forEach(extension -> {
491      if (advisor.useAdvisorForExtension(ConversionContext30_50.INSTANCE.path(), extension)) {
492        org.hl7.fhir.dstu3.model.Extension convertExtension = new org.hl7.fhir.dstu3.model.Extension();
493        advisor.handleExtension(ConversionContext30_50.INSTANCE.path(), extension, convertExtension);
494        tgt.addExtension(convertExtension);
495      } else if (!advisor.ignoreExtension(ConversionContext30_50.INSTANCE.path(), extension) && !Arrays.asList(extensionUrlsToIgnore).contains(extension.getUrl())) {
496        tgt.addExtension(Extension30_50.convertExtension(extension));
497      }
498    });
499    src.getModifierExtension().stream()
500      .filter(extension -> !advisor.ignoreExtension(ConversionContext30_50.INSTANCE.path(), extension))
501      .map(Extension30_50::convertExtension)
502      .forEach(tgt::addModifierExtension);
503  }
504}