001package org.hl7.fhir.convertors.conv10_40.resources10_40;
002
003import org.hl7.fhir.convertors.VersionConvertorConstants;
004import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40;
005import org.hl7.fhir.convertors.context.ConversionContext10_40;
006import org.hl7.fhir.convertors.conv10_40.datatypes10_40.Reference10_40;
007import org.hl7.fhir.convertors.conv10_40.datatypes10_40.complextypes10_40.CodeableConcept10_40;
008import org.hl7.fhir.convertors.conv10_40.datatypes10_40.complextypes10_40.Coding10_40;
009import org.hl7.fhir.convertors.conv10_40.datatypes10_40.complextypes10_40.ContactPoint10_40;
010import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.Boolean10_40;
011import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.Canonical10_40;
012import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.Code10_40;
013import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.DateTime10_40;
014import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.String10_40;
015import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.UnsignedInt10_40;
016import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.Uri10_40;
017import org.hl7.fhir.exceptions.FHIRException;
018import org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestComponent;
019import org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceComponent;
020import org.hl7.fhir.r4.model.CapabilityStatement.SystemRestfulInteraction;
021
022public class Conformance10_40 {
023
024  public static final String ACCEPT_UNKNOWN_EXTENSION_URL = "http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown";
025
026  private static final String[] IGNORED_EXTENSION_URLS = new String[]{
027    ACCEPT_UNKNOWN_EXTENSION_URL
028  };
029  static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Conformance.ConditionalDeleteStatus> convertConditionalDeleteStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CapabilityStatement.ConditionalDeleteStatus> src) throws FHIRException {
030    if (src == null || src.isEmpty())
031      return null;
032    org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Conformance.ConditionalDeleteStatus> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Conformance.ConditionalDeleteStatusEnumFactory());
033    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
034    switch (src.getValue()) {
035      case NOTSUPPORTED:
036        tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.ConditionalDeleteStatus.NOTSUPPORTED);
037        break;
038      case SINGLE:
039        tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.ConditionalDeleteStatus.SINGLE);
040        break;
041      case MULTIPLE:
042        tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.ConditionalDeleteStatus.MULTIPLE);
043        break;
044      default:
045        tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.ConditionalDeleteStatus.NULL);
046        break;
047    }
048    return tgt;
049  }
050
051  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CapabilityStatement.ConditionalDeleteStatus> convertConditionalDeleteStatus(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Conformance.ConditionalDeleteStatus> src) throws FHIRException {
052    if (src == null || src.isEmpty())
053      return null;
054    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CapabilityStatement.ConditionalDeleteStatus> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.CapabilityStatement.ConditionalDeleteStatusEnumFactory());
055    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
056    switch (src.getValue()) {
057      case NOTSUPPORTED:
058        tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.ConditionalDeleteStatus.NOTSUPPORTED);
059        break;
060      case SINGLE:
061        tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.ConditionalDeleteStatus.SINGLE);
062        break;
063      case MULTIPLE:
064        tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.ConditionalDeleteStatus.MULTIPLE);
065        break;
066      default:
067        tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.ConditionalDeleteStatus.NULL);
068        break;
069    }
070    return tgt;
071  }
072
073  public static org.hl7.fhir.dstu2.model.Conformance convertConformance(org.hl7.fhir.r4.model.CapabilityStatement src, BaseAdvisor_10_40 advisor) throws FHIRException {
074    if (src == null || src.isEmpty())
075      return null;
076    org.hl7.fhir.dstu2.model.Conformance tgt = new org.hl7.fhir.dstu2.model.Conformance();
077    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyDomainResource(src, tgt, IGNORED_EXTENSION_URLS);
078    if (src.hasUrlElement())
079      tgt.setUrlElement(Uri10_40.convertUri(src.getUrlElement()));
080    if (src.hasVersionElement())
081      tgt.setVersionElement(String10_40.convertString(src.getVersionElement()));
082    if (src.hasNameElement())
083      tgt.setNameElement(String10_40.convertString(src.getNameElement()));
084    if (src.hasStatus())
085      tgt.setStatusElement(Enumerations10_40.convertConformanceResourceStatus(src.getStatusElement()));
086    if (src.hasExperimental())
087      tgt.setExperimentalElement(Boolean10_40.convertBoolean(src.getExperimentalElement()));
088    if (src.hasDate())
089      tgt.setDateElement(DateTime10_40.convertDateTime(src.getDateElement()));
090    if (src.hasPublisherElement())
091      tgt.setPublisherElement(String10_40.convertString(src.getPublisherElement()));
092    for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact())
093      tgt.addContact(convertConformanceContactComponent(t));
094    if (src.hasDescription())
095      tgt.setDescription(src.getDescription());
096    if (src.hasPurpose())
097      tgt.setRequirements(src.getPurpose());
098    if (src.hasCopyright())
099      tgt.setCopyright(src.getCopyright());
100    if (src.hasKind())
101      tgt.setKindElement(convertConformanceStatementKind(src.getKindElement()));
102    if (src.hasSoftware())
103      tgt.setSoftware(convertConformanceSoftwareComponent(src.getSoftware()));
104    if (src.hasImplementation())
105      tgt.setImplementation(convertConformanceImplementationComponent(src.getImplementation()));
106    if (src.hasFhirVersion())
107      tgt.setFhirVersion(src.getFhirVersion().toCode());
108    if (src.hasExtension(ACCEPT_UNKNOWN_EXTENSION_URL))
109      tgt.setAcceptUnknown(org.hl7.fhir.dstu2.model.Conformance.UnknownContentCode.fromCode(src.getExtensionByUrl(ACCEPT_UNKNOWN_EXTENSION_URL).getValue().primitiveValue()));
110    for (org.hl7.fhir.r4.model.CodeType t : src.getFormat()) tgt.addFormat(t.getValue());
111    for (CapabilityStatementRestComponent r : src.getRest())
112      for (CapabilityStatementRestResourceComponent rr : r.getResource())
113        for (org.hl7.fhir.r4.model.CanonicalType t : rr.getSupportedProfile())
114          tgt.addProfile(Canonical10_40.convertCanonicalToReference(t));
115    for (org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestComponent t : src.getRest())
116      tgt.addRest(convertConformanceRestComponent(t));
117    for (org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementMessagingComponent t : src.getMessaging())
118      tgt.addMessaging(convertConformanceMessagingComponent(t));
119    for (org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementDocumentComponent t : src.getDocument())
120      tgt.addDocument(convertConformanceDocumentComponent(t));
121    return tgt;
122  }
123
124  public static org.hl7.fhir.r4.model.CapabilityStatement convertConformance(org.hl7.fhir.dstu2.model.Conformance src) throws FHIRException {
125    if (src == null || src.isEmpty())
126      return null;
127    org.hl7.fhir.r4.model.CapabilityStatement tgt = new org.hl7.fhir.r4.model.CapabilityStatement();
128    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyDomainResource(src, tgt);
129    if (src.hasUrlElement())
130      tgt.setUrlElement(Uri10_40.convertUri(src.getUrlElement()));
131    if (src.hasVersionElement())
132      tgt.setVersionElement(String10_40.convertString(src.getVersionElement()));
133    if (src.hasNameElement())
134      tgt.setNameElement(String10_40.convertString(src.getNameElement()));
135    if (src.hasStatus())
136      tgt.setStatusElement(Enumerations10_40.convertConformanceResourceStatus(src.getStatusElement()));
137    if (src.hasExperimental())
138      tgt.setExperimentalElement(Boolean10_40.convertBoolean(src.getExperimentalElement()));
139    if (src.hasDate())
140      tgt.setDateElement(DateTime10_40.convertDateTime(src.getDateElement()));
141    if (src.hasPublisherElement())
142      tgt.setPublisherElement(String10_40.convertString(src.getPublisherElement()));
143    for (org.hl7.fhir.dstu2.model.Conformance.ConformanceContactComponent t : src.getContact())
144      tgt.addContact(convertConformanceContactComponent(t));
145    if (src.hasDescription())
146      tgt.setDescription(src.getDescription());
147    if (src.hasRequirements())
148      tgt.setPurpose(src.getRequirements());
149    if (src.hasCopyright())
150      tgt.setCopyright(src.getCopyright());
151    if (src.hasKind())
152      tgt.setKindElement(convertConformanceStatementKind(src.getKindElement()));
153    if (src.hasSoftware())
154      tgt.setSoftware(convertConformanceSoftwareComponent(src.getSoftware()));
155    if (src.hasImplementation())
156      tgt.setImplementation(convertConformanceImplementationComponent(src.getImplementation()));
157    if (src.hasFhirVersion())
158      tgt.setFhirVersion(org.hl7.fhir.r4.model.Enumerations.FHIRVersion.fromCode(src.getFhirVersion()));
159    if (src.hasAcceptUnknown())
160      tgt.addExtension().setUrl(ACCEPT_UNKNOWN_EXTENSION_URL).setValue(new org.hl7.fhir.r4.model.CodeType(src.getAcceptUnknownElement().asStringValue()));
161    for (org.hl7.fhir.dstu2.model.CodeType t : src.getFormat()) tgt.addFormat(t.getValue());
162    for (org.hl7.fhir.dstu2.model.Conformance.ConformanceRestComponent t : src.getRest())
163      tgt.addRest(convertConformanceRestComponent(t));
164    for (org.hl7.fhir.dstu2.model.Conformance.ConformanceMessagingComponent t : src.getMessaging())
165      tgt.addMessaging(convertConformanceMessagingComponent(t));
166    for (org.hl7.fhir.dstu2.model.Conformance.ConformanceDocumentComponent t : src.getDocument())
167      tgt.addDocument(convertConformanceDocumentComponent(t));
168    return tgt;
169  }
170
171  public static org.hl7.fhir.dstu2.model.Conformance.ConformanceContactComponent convertConformanceContactComponent(org.hl7.fhir.r4.model.ContactDetail src) throws FHIRException {
172    if (src == null || src.isEmpty())
173      return null;
174    org.hl7.fhir.dstu2.model.Conformance.ConformanceContactComponent tgt = new org.hl7.fhir.dstu2.model.Conformance.ConformanceContactComponent();
175    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
176    if (src.hasNameElement())
177      tgt.setNameElement(String10_40.convertString(src.getNameElement()));
178    for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom())
179      tgt.addTelecom(ContactPoint10_40.convertContactPoint(t));
180    return tgt;
181  }
182
183  public static org.hl7.fhir.r4.model.ContactDetail convertConformanceContactComponent(org.hl7.fhir.dstu2.model.Conformance.ConformanceContactComponent src) throws FHIRException {
184    if (src == null || src.isEmpty())
185      return null;
186    org.hl7.fhir.r4.model.ContactDetail tgt = new org.hl7.fhir.r4.model.ContactDetail();
187    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
188    if (src.hasNameElement())
189      tgt.setNameElement(String10_40.convertString(src.getNameElement()));
190    for (org.hl7.fhir.dstu2.model.ContactPoint t : src.getTelecom())
191      tgt.addTelecom(ContactPoint10_40.convertContactPoint(t));
192    return tgt;
193  }
194
195  public static org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementDocumentComponent convertConformanceDocumentComponent(org.hl7.fhir.dstu2.model.Conformance.ConformanceDocumentComponent src) throws FHIRException {
196    if (src == null || src.isEmpty())
197      return null;
198    org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementDocumentComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementDocumentComponent();
199    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
200    if (src.hasMode())
201      tgt.setModeElement(convertDocumentMode(src.getModeElement()));
202    if (src.hasDocumentation())
203      tgt.setDocumentation(src.getDocumentation());
204    if (src.hasProfile())
205      tgt.setProfileElement(Canonical10_40.convertReferenceToCanonical(src.getProfile()));
206    return tgt;
207  }
208
209  public static org.hl7.fhir.dstu2.model.Conformance.ConformanceDocumentComponent convertConformanceDocumentComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementDocumentComponent src) throws FHIRException {
210    if (src == null || src.isEmpty())
211      return null;
212    org.hl7.fhir.dstu2.model.Conformance.ConformanceDocumentComponent tgt = new org.hl7.fhir.dstu2.model.Conformance.ConformanceDocumentComponent();
213    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
214    if (src.hasMode())
215      tgt.setModeElement(convertDocumentMode(src.getModeElement()));
216    if (src.hasDocumentation())
217      tgt.setDocumentation(src.getDocumentation());
218    if (src.hasProfileElement())
219      tgt.setProfile(Canonical10_40.convertCanonicalToReference(src.getProfileElement()));
220    return tgt;
221  }
222
223  public static org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementImplementationComponent convertConformanceImplementationComponent(org.hl7.fhir.dstu2.model.Conformance.ConformanceImplementationComponent src) throws FHIRException {
224    if (src == null || src.isEmpty())
225      return null;
226    org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementImplementationComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementImplementationComponent();
227    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
228    if (src.hasDescriptionElement())
229      tgt.setDescriptionElement(String10_40.convertString(src.getDescriptionElement()));
230    if (src.hasUrl())
231      tgt.setUrl(src.getUrl());
232    return tgt;
233  }
234
235  public static org.hl7.fhir.dstu2.model.Conformance.ConformanceImplementationComponent convertConformanceImplementationComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementImplementationComponent src) throws FHIRException {
236    if (src == null || src.isEmpty())
237      return null;
238    org.hl7.fhir.dstu2.model.Conformance.ConformanceImplementationComponent tgt = new org.hl7.fhir.dstu2.model.Conformance.ConformanceImplementationComponent();
239    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
240    if (src.hasDescriptionElement())
241      tgt.setDescriptionElement(String10_40.convertString(src.getDescriptionElement()));
242    if (src.hasUrl())
243      tgt.setUrl(src.getUrl());
244    return tgt;
245  }
246
247  public static org.hl7.fhir.dstu2.model.Conformance.ConformanceMessagingComponent convertConformanceMessagingComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementMessagingComponent src) throws FHIRException {
248    if (src == null || src.isEmpty())
249      return null;
250    org.hl7.fhir.dstu2.model.Conformance.ConformanceMessagingComponent tgt = new org.hl7.fhir.dstu2.model.Conformance.ConformanceMessagingComponent();
251    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
252    for (org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementMessagingEndpointComponent t : src.getEndpoint())
253      tgt.addEndpoint(convertConformanceMessagingEndpointComponent(t));
254    if (src.hasReliableCacheElement())
255      tgt.setReliableCacheElement(UnsignedInt10_40.convertUnsignedInt(src.getReliableCacheElement()));
256    if (src.hasDocumentation())
257      tgt.setDocumentation(src.getDocumentation());
258    for (org.hl7.fhir.r4.model.Extension e : src.getExtensionsByUrl(VersionConvertorConstants.IG_CONFORMANCE_MESSAGE_EVENT)) {
259      org.hl7.fhir.dstu2.model.Conformance.ConformanceMessagingEventComponent event = new org.hl7.fhir.dstu2.model.Conformance.ConformanceMessagingEventComponent();
260      tgt.addEvent(event);
261      event.setCode(Coding10_40.convertCoding((org.hl7.fhir.r4.model.Coding) e.getExtensionByUrl("code").getValue()));
262      if (e.hasExtension("category"))
263        event.setCategory(org.hl7.fhir.dstu2.model.Conformance.MessageSignificanceCategory.fromCode(e.getExtensionByUrl("category").getValue().toString()));
264      event.setMode(org.hl7.fhir.dstu2.model.Conformance.ConformanceEventMode.fromCode(e.getExtensionByUrl("mode").getValue().toString()));
265      org.hl7.fhir.r4.model.Extension focusE = e.getExtensionByUrl("focus");
266      if (focusE.getValue().hasPrimitiveValue())
267        event.setFocus(focusE.getValue().toString());
268      else {
269        event.setFocusElement(new org.hl7.fhir.dstu2.model.CodeType());
270        ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(focusE.getValue(), event.getFocusElement());
271      }
272      event.setRequest(Reference10_40.convertReference((org.hl7.fhir.r4.model.Reference) e.getExtensionByUrl("request").getValue()));
273      event.setResponse(Reference10_40.convertReference((org.hl7.fhir.r4.model.Reference) e.getExtensionByUrl("response").getValue()));
274      if (e.hasExtension("documentation"))
275        event.setDocumentation(e.getExtensionByUrl("documentation").getValue().toString());
276    }
277    return tgt;
278  }
279
280  public static org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementMessagingComponent convertConformanceMessagingComponent(org.hl7.fhir.dstu2.model.Conformance.ConformanceMessagingComponent src) throws FHIRException {
281    if (src == null || src.isEmpty())
282      return null;
283    org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementMessagingComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementMessagingComponent();
284    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
285    for (org.hl7.fhir.dstu2.model.Conformance.ConformanceMessagingEndpointComponent t : src.getEndpoint())
286      tgt.addEndpoint(convertConformanceMessagingEndpointComponent(t));
287    if (src.hasReliableCacheElement())
288      tgt.setReliableCacheElement(UnsignedInt10_40.convertUnsignedInt(src.getReliableCacheElement()));
289    if (src.hasDocumentation())
290      tgt.setDocumentation(src.getDocumentation());
291    for (org.hl7.fhir.dstu2.model.Conformance.ConformanceMessagingEventComponent t : src.getEvent()) {
292      org.hl7.fhir.r4.model.Extension e = new org.hl7.fhir.r4.model.Extension(VersionConvertorConstants.IG_CONFORMANCE_MESSAGE_EVENT);
293      e.addExtension(new org.hl7.fhir.r4.model.Extension("code", Coding10_40.convertCoding(t.getCode())));
294      if (t.hasCategory())
295        e.addExtension(new org.hl7.fhir.r4.model.Extension("category", new org.hl7.fhir.r4.model.CodeType(t.getCategory().toCode())));
296      e.addExtension(new org.hl7.fhir.r4.model.Extension("mode", new org.hl7.fhir.r4.model.CodeType(t.getMode().toCode())));
297      if (t.getFocusElement().hasValue())
298        e.addExtension(new org.hl7.fhir.r4.model.Extension("focus", new org.hl7.fhir.r4.model.StringType(t.getFocus())));
299      else {
300        org.hl7.fhir.r4.model.CodeType focus = new org.hl7.fhir.r4.model.CodeType();
301        org.hl7.fhir.r4.model.Extension focusE = new org.hl7.fhir.r4.model.Extension("focus", focus);
302        ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(t.getFocusElement(), focus);
303        e.addExtension(focusE);
304      }
305      e.addExtension(new org.hl7.fhir.r4.model.Extension("request", Reference10_40.convertReference(t.getRequest())));
306      e.addExtension(new org.hl7.fhir.r4.model.Extension("response", Reference10_40.convertReference(t.getResponse())));
307      if (t.hasDocumentation())
308        e.addExtension(new org.hl7.fhir.r4.model.Extension("documentation", new org.hl7.fhir.r4.model.StringType(t.getDocumentation())));
309      tgt.addExtension(e);
310    }
311    return tgt;
312  }
313
314  public static org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementMessagingEndpointComponent convertConformanceMessagingEndpointComponent(org.hl7.fhir.dstu2.model.Conformance.ConformanceMessagingEndpointComponent src) throws FHIRException {
315    if (src == null || src.isEmpty())
316      return null;
317    org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementMessagingEndpointComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementMessagingEndpointComponent();
318    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
319    if (src.hasProtocol())
320      tgt.setProtocol(Coding10_40.convertCoding(src.getProtocol()));
321    if (src.hasAddress())
322      tgt.setAddress(src.getAddress());
323    return tgt;
324  }
325
326  public static org.hl7.fhir.dstu2.model.Conformance.ConformanceMessagingEndpointComponent convertConformanceMessagingEndpointComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementMessagingEndpointComponent src) throws FHIRException {
327    if (src == null || src.isEmpty())
328      return null;
329    org.hl7.fhir.dstu2.model.Conformance.ConformanceMessagingEndpointComponent tgt = new org.hl7.fhir.dstu2.model.Conformance.ConformanceMessagingEndpointComponent();
330    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
331    if (src.hasProtocol())
332      tgt.setProtocol(Coding10_40.convertCoding(src.getProtocol()));
333    if (src.hasAddress())
334      tgt.setAddress(src.getAddress());
335    return tgt;
336  }
337
338  public static org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestComponent convertConformanceRestComponent(org.hl7.fhir.dstu2.model.Conformance.ConformanceRestComponent src) throws FHIRException {
339    if (src == null || src.isEmpty())
340      return null;
341    org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestComponent();
342    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
343    if (src.hasMode())
344      tgt.setModeElement(convertRestfulConformanceMode(src.getModeElement()));
345    if (src.hasDocumentation())
346      tgt.setDocumentation(src.getDocumentation());
347    if (src.hasSecurity())
348      tgt.setSecurity(convertConformanceRestSecurityComponent(src.getSecurity()));
349    for (org.hl7.fhir.dstu2.model.Conformance.ConformanceRestResourceComponent t : src.getResource())
350      tgt.addResource(convertConformanceRestResourceComponent(t));
351    for (org.hl7.fhir.dstu2.model.Conformance.SystemInteractionComponent t : src.getInteraction())
352      tgt.addInteraction(convertSystemInteractionComponent(t));
353    if (src.getTransactionMode() == org.hl7.fhir.dstu2.model.Conformance.TransactionMode.BATCH || src.getTransactionMode() == org.hl7.fhir.dstu2.model.Conformance.TransactionMode.BOTH)
354      tgt.addInteraction().setCode(SystemRestfulInteraction.BATCH);
355    for (org.hl7.fhir.dstu2.model.Conformance.ConformanceRestResourceSearchParamComponent t : src.getSearchParam())
356      tgt.addSearchParam(convertConformanceRestResourceSearchParamComponent(t));
357    for (org.hl7.fhir.dstu2.model.Conformance.ConformanceRestOperationComponent t : src.getOperation())
358      tgt.addOperation(convertConformanceRestOperationComponent(t));
359    for (org.hl7.fhir.dstu2.model.UriType t : src.getCompartment()) tgt.addCompartment(t.getValue());
360    return tgt;
361  }
362
363  public static org.hl7.fhir.dstu2.model.Conformance.ConformanceRestComponent convertConformanceRestComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestComponent src) throws FHIRException {
364    if (src == null || src.isEmpty())
365      return null;
366    org.hl7.fhir.dstu2.model.Conformance.ConformanceRestComponent tgt = new org.hl7.fhir.dstu2.model.Conformance.ConformanceRestComponent();
367    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
368    if (src.hasMode())
369      tgt.setModeElement(convertRestfulConformanceMode(src.getModeElement()));
370    if (src.hasDocumentation())
371      tgt.setDocumentation(src.getDocumentation());
372    if (src.hasSecurity())
373      tgt.setSecurity(convertConformanceRestSecurityComponent(src.getSecurity()));
374    for (org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceComponent t : src.getResource())
375      tgt.addResource(convertConformanceRestResourceComponent(t));
376    boolean batch = false;
377    boolean transaction = false;
378    for (org.hl7.fhir.r4.model.CapabilityStatement.SystemInteractionComponent t : src.getInteraction()) {
379      if (t.getCode().equals(SystemRestfulInteraction.BATCH))
380        batch = true;
381      else
382        tgt.addInteraction(convertSystemInteractionComponent(t));
383      if (t.getCode().equals(SystemRestfulInteraction.TRANSACTION))
384        transaction = true;
385    }
386    if (batch)
387      tgt.setTransactionMode(transaction ? org.hl7.fhir.dstu2.model.Conformance.TransactionMode.BOTH : org.hl7.fhir.dstu2.model.Conformance.TransactionMode.BATCH);
388    else
389      tgt.setTransactionMode(transaction ? org.hl7.fhir.dstu2.model.Conformance.TransactionMode.TRANSACTION : org.hl7.fhir.dstu2.model.Conformance.TransactionMode.NOTSUPPORTED);
390    for (org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent t : src.getSearchParam())
391      tgt.addSearchParam(convertConformanceRestResourceSearchParamComponent(t));
392    for (org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceOperationComponent t : src.getOperation())
393      tgt.addOperation(convertConformanceRestOperationComponent(t));
394    for (org.hl7.fhir.r4.model.UriType t : src.getCompartment()) tgt.addCompartment(t.getValue());
395    return tgt;
396  }
397
398  public static org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceOperationComponent convertConformanceRestOperationComponent(org.hl7.fhir.dstu2.model.Conformance.ConformanceRestOperationComponent src) throws FHIRException {
399    if (src == null || src.isEmpty())
400      return null;
401    org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceOperationComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceOperationComponent();
402    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
403    if (src.hasNameElement())
404      tgt.setNameElement(String10_40.convertString(src.getNameElement()));
405    if (src.hasDefinition())
406      tgt.setDefinitionElement(Canonical10_40.convertReferenceToCanonical(src.getDefinition()));
407    return tgt;
408  }
409
410  public static org.hl7.fhir.dstu2.model.Conformance.ConformanceRestOperationComponent convertConformanceRestOperationComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceOperationComponent src) throws FHIRException {
411    if (src == null || src.isEmpty())
412      return null;
413    org.hl7.fhir.dstu2.model.Conformance.ConformanceRestOperationComponent tgt = new org.hl7.fhir.dstu2.model.Conformance.ConformanceRestOperationComponent();
414    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
415    if (src.hasNameElement())
416      tgt.setNameElement(String10_40.convertString(src.getNameElement()));
417    if (src.hasDefinitionElement())
418      tgt.setDefinition(Canonical10_40.convertCanonicalToReference(src.getDefinitionElement()));
419    return tgt;
420  }
421
422  public static org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceComponent convertConformanceRestResourceComponent(org.hl7.fhir.dstu2.model.Conformance.ConformanceRestResourceComponent src) throws FHIRException {
423    if (src == null || src.isEmpty())
424      return null;
425    org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceComponent();
426    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
427    if (src.hasTypeElement())
428      tgt.setTypeElement(Code10_40.convertCode(src.getTypeElement()));
429    if (src.hasProfile())
430      tgt.setProfileElement(Canonical10_40.convertReferenceToCanonical(src.getProfile()));
431    for (org.hl7.fhir.dstu2.model.Conformance.ResourceInteractionComponent t : src.getInteraction())
432      tgt.addInteraction(convertResourceInteractionComponent(t));
433    if (src.hasVersioning())
434      tgt.setVersioningElement(convertResourceVersionPolicy(src.getVersioningElement()));
435    if (src.hasReadHistoryElement())
436      tgt.setReadHistoryElement(Boolean10_40.convertBoolean(src.getReadHistoryElement()));
437    if (src.hasUpdateCreateElement())
438      tgt.setUpdateCreateElement(Boolean10_40.convertBoolean(src.getUpdateCreateElement()));
439    if (src.hasConditionalCreateElement())
440      tgt.setConditionalCreateElement(Boolean10_40.convertBoolean(src.getConditionalCreateElement()));
441    if (src.hasConditionalUpdateElement())
442      tgt.setConditionalUpdateElement(Boolean10_40.convertBoolean(src.getConditionalUpdateElement()));
443    if (src.hasConditionalDelete())
444      tgt.setConditionalDeleteElement(convertConditionalDeleteStatus(src.getConditionalDeleteElement()));
445    for (org.hl7.fhir.dstu2.model.StringType t : src.getSearchInclude()) tgt.addSearchInclude(t.getValue());
446    for (org.hl7.fhir.dstu2.model.StringType t : src.getSearchRevInclude()) tgt.addSearchRevInclude(t.getValue());
447    for (org.hl7.fhir.dstu2.model.Conformance.ConformanceRestResourceSearchParamComponent t : src.getSearchParam())
448      tgt.addSearchParam(convertConformanceRestResourceSearchParamComponent(t));
449    return tgt;
450  }
451
452  public static org.hl7.fhir.dstu2.model.Conformance.ConformanceRestResourceComponent convertConformanceRestResourceComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceComponent src) throws FHIRException {
453    if (src == null || src.isEmpty())
454      return null;
455    org.hl7.fhir.dstu2.model.Conformance.ConformanceRestResourceComponent tgt = new org.hl7.fhir.dstu2.model.Conformance.ConformanceRestResourceComponent();
456    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
457    if (src.hasTypeElement())
458      tgt.setTypeElement(Code10_40.convertCode(src.getTypeElement()));
459    if (src.hasProfile())
460      tgt.setProfile(Canonical10_40.convertCanonicalToReference(src.getProfileElement()));
461    for (org.hl7.fhir.r4.model.CapabilityStatement.ResourceInteractionComponent t : src.getInteraction())
462      tgt.addInteraction(convertResourceInteractionComponent(t));
463    if (src.hasVersioning())
464      tgt.setVersioningElement(convertResourceVersionPolicy(src.getVersioningElement()));
465    if (src.hasReadHistoryElement())
466      tgt.setReadHistoryElement(Boolean10_40.convertBoolean(src.getReadHistoryElement()));
467    if (src.hasUpdateCreateElement())
468      tgt.setUpdateCreateElement(Boolean10_40.convertBoolean(src.getUpdateCreateElement()));
469    if (src.hasConditionalCreateElement())
470      tgt.setConditionalCreateElement(Boolean10_40.convertBoolean(src.getConditionalCreateElement()));
471    if (src.hasConditionalUpdateElement())
472      tgt.setConditionalUpdateElement(Boolean10_40.convertBoolean(src.getConditionalUpdateElement()));
473    if (src.hasConditionalDelete())
474      tgt.setConditionalDeleteElement(convertConditionalDeleteStatus(src.getConditionalDeleteElement()));
475    for (org.hl7.fhir.r4.model.StringType t : src.getSearchInclude()) tgt.addSearchInclude(t.getValue());
476    for (org.hl7.fhir.r4.model.StringType t : src.getSearchRevInclude()) tgt.addSearchRevInclude(t.getValue());
477    for (org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent t : src.getSearchParam())
478      tgt.addSearchParam(convertConformanceRestResourceSearchParamComponent(t));
479    return tgt;
480  }
481
482  public static org.hl7.fhir.dstu2.model.Conformance.ConformanceRestResourceSearchParamComponent convertConformanceRestResourceSearchParamComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent src) throws FHIRException {
483    if (src == null || src.isEmpty())
484      return null;
485    org.hl7.fhir.dstu2.model.Conformance.ConformanceRestResourceSearchParamComponent tgt = new org.hl7.fhir.dstu2.model.Conformance.ConformanceRestResourceSearchParamComponent();
486    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
487    if (src.hasNameElement())
488      tgt.setNameElement(String10_40.convertString(src.getNameElement()));
489    if (src.hasDefinition())
490      tgt.setDefinition(src.getDefinition());
491    if (src.hasType())
492      tgt.setTypeElement(Enumerations10_40.convertSearchParamType(src.getTypeElement()));
493    if (src.hasDocumentation())
494      tgt.setDocumentation(src.getDocumentation());
495    return tgt;
496  }
497
498  public static org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent convertConformanceRestResourceSearchParamComponent(org.hl7.fhir.dstu2.model.Conformance.ConformanceRestResourceSearchParamComponent src) throws FHIRException {
499    if (src == null || src.isEmpty())
500      return null;
501    org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent();
502    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
503    if (src.hasNameElement())
504      tgt.setNameElement(String10_40.convertString(src.getNameElement()));
505    if (src.hasDefinition())
506      tgt.setDefinition(src.getDefinition());
507    if (src.hasType())
508      tgt.setTypeElement(Enumerations10_40.convertSearchParamType(src.getTypeElement()));
509    if (src.hasDocumentation())
510      tgt.setDocumentation(src.getDocumentation());
511    return tgt;
512  }
513
514  public static org.hl7.fhir.dstu2.model.Conformance.ConformanceRestSecurityComponent convertConformanceRestSecurityComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestSecurityComponent src) throws FHIRException {
515    if (src == null || src.isEmpty())
516      return null;
517    org.hl7.fhir.dstu2.model.Conformance.ConformanceRestSecurityComponent tgt = new org.hl7.fhir.dstu2.model.Conformance.ConformanceRestSecurityComponent();
518    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
519    if (src.hasCorsElement())
520      tgt.setCorsElement(Boolean10_40.convertBoolean(src.getCorsElement()));
521    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getService())
522      tgt.addService(CodeableConcept10_40.convertCodeableConcept(t));
523    if (src.hasDescription())
524      tgt.setDescription(src.getDescription());
525    return tgt;
526  }
527
528  public static org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestSecurityComponent convertConformanceRestSecurityComponent(org.hl7.fhir.dstu2.model.Conformance.ConformanceRestSecurityComponent src) throws FHIRException {
529    if (src == null || src.isEmpty())
530      return null;
531    org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestSecurityComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestSecurityComponent();
532    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
533    if (src.hasCorsElement())
534      tgt.setCorsElement(Boolean10_40.convertBoolean(src.getCorsElement()));
535    for (org.hl7.fhir.dstu2.model.CodeableConcept t : src.getService())
536      tgt.addService(CodeableConcept10_40.convertCodeableConcept(t));
537    if (src.hasDescription())
538      tgt.setDescription(src.getDescription());
539    return tgt;
540  }
541
542  public static org.hl7.fhir.dstu2.model.Conformance.ConformanceSoftwareComponent convertConformanceSoftwareComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementSoftwareComponent src) throws FHIRException {
543    if (src == null || src.isEmpty())
544      return null;
545    org.hl7.fhir.dstu2.model.Conformance.ConformanceSoftwareComponent tgt = new org.hl7.fhir.dstu2.model.Conformance.ConformanceSoftwareComponent();
546    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
547    if (src.hasNameElement())
548      tgt.setNameElement(String10_40.convertString(src.getNameElement()));
549    if (src.hasVersionElement())
550      tgt.setVersionElement(String10_40.convertString(src.getVersionElement()));
551    if (src.hasReleaseDateElement())
552      tgt.setReleaseDateElement(DateTime10_40.convertDateTime(src.getReleaseDateElement()));
553    return tgt;
554  }
555
556  public static org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementSoftwareComponent convertConformanceSoftwareComponent(org.hl7.fhir.dstu2.model.Conformance.ConformanceSoftwareComponent src) throws FHIRException {
557    if (src == null || src.isEmpty())
558      return null;
559    org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementSoftwareComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementSoftwareComponent();
560    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
561    if (src.hasNameElement())
562      tgt.setNameElement(String10_40.convertString(src.getNameElement()));
563    if (src.hasVersionElement())
564      tgt.setVersionElement(String10_40.convertString(src.getVersionElement()));
565    if (src.hasReleaseDateElement())
566      tgt.setReleaseDateElement(DateTime10_40.convertDateTime(src.getReleaseDateElement()));
567    return tgt;
568  }
569
570  static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Conformance.ConformanceStatementKind> convertConformanceStatementKind(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementKind> src) throws FHIRException {
571    if (src == null || src.isEmpty())
572      return null;
573    org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Conformance.ConformanceStatementKind> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Conformance.ConformanceStatementKindEnumFactory());
574    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
575    switch (src.getValue()) {
576      case INSTANCE:
577        tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.ConformanceStatementKind.INSTANCE);
578        break;
579      case CAPABILITY:
580        tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.ConformanceStatementKind.CAPABILITY);
581        break;
582      case REQUIREMENTS:
583        tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.ConformanceStatementKind.REQUIREMENTS);
584        break;
585      default:
586        tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.ConformanceStatementKind.NULL);
587        break;
588    }
589    return tgt;
590  }
591
592  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementKind> convertConformanceStatementKind(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Conformance.ConformanceStatementKind> src) throws FHIRException {
593    if (src == null || src.isEmpty())
594      return null;
595    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementKind> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementKindEnumFactory());
596    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
597    switch (src.getValue()) {
598      case INSTANCE:
599        tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementKind.INSTANCE);
600        break;
601      case CAPABILITY:
602        tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementKind.CAPABILITY);
603        break;
604      case REQUIREMENTS:
605        tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementKind.REQUIREMENTS);
606        break;
607      default:
608        tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementKind.NULL);
609        break;
610    }
611    return tgt;
612  }
613
614  static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Conformance.DocumentMode> convertDocumentMode(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CapabilityStatement.DocumentMode> src) throws FHIRException {
615    if (src == null || src.isEmpty())
616      return null;
617    org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Conformance.DocumentMode> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Conformance.DocumentModeEnumFactory());
618    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
619    switch (src.getValue()) {
620      case PRODUCER:
621        tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.DocumentMode.PRODUCER);
622        break;
623      case CONSUMER:
624        tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.DocumentMode.CONSUMER);
625        break;
626      default:
627        tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.DocumentMode.NULL);
628        break;
629    }
630    return tgt;
631  }
632
633  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CapabilityStatement.DocumentMode> convertDocumentMode(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Conformance.DocumentMode> src) throws FHIRException {
634    if (src == null || src.isEmpty())
635      return null;
636    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CapabilityStatement.DocumentMode> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.CapabilityStatement.DocumentModeEnumFactory());
637    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
638    switch (src.getValue()) {
639      case PRODUCER:
640        tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.DocumentMode.PRODUCER);
641        break;
642      case CONSUMER:
643        tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.DocumentMode.CONSUMER);
644        break;
645      default:
646        tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.DocumentMode.NULL);
647        break;
648    }
649    return tgt;
650  }
651
652  public static org.hl7.fhir.r4.model.CapabilityStatement.ResourceInteractionComponent convertResourceInteractionComponent(org.hl7.fhir.dstu2.model.Conformance.ResourceInteractionComponent src) throws FHIRException {
653    if (src == null || src.isEmpty())
654      return null;
655    org.hl7.fhir.r4.model.CapabilityStatement.ResourceInteractionComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.ResourceInteractionComponent();
656    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
657    if (src.hasCode())
658      tgt.setCodeElement(convertTypeRestfulInteraction(src.getCodeElement()));
659    if (src.hasDocumentation())
660      tgt.setDocumentation(src.getDocumentation());
661    return tgt;
662  }
663
664  public static org.hl7.fhir.dstu2.model.Conformance.ResourceInteractionComponent convertResourceInteractionComponent(org.hl7.fhir.r4.model.CapabilityStatement.ResourceInteractionComponent src) throws FHIRException {
665    if (src == null || src.isEmpty())
666      return null;
667    org.hl7.fhir.dstu2.model.Conformance.ResourceInteractionComponent tgt = new org.hl7.fhir.dstu2.model.Conformance.ResourceInteractionComponent();
668    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
669    if (src.hasCode())
670      tgt.setCodeElement(convertTypeRestfulInteraction(src.getCodeElement()));
671    if (src.hasDocumentation())
672      tgt.setDocumentation(src.getDocumentation());
673    return tgt;
674  }
675
676  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CapabilityStatement.ResourceVersionPolicy> convertResourceVersionPolicy(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Conformance.ResourceVersionPolicy> src) throws FHIRException {
677    if (src == null || src.isEmpty())
678      return null;
679    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CapabilityStatement.ResourceVersionPolicy> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.CapabilityStatement.ResourceVersionPolicyEnumFactory());
680    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
681    switch (src.getValue()) {
682      case NOVERSION:
683        tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.ResourceVersionPolicy.NOVERSION);
684        break;
685      case VERSIONED:
686        tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.ResourceVersionPolicy.VERSIONED);
687        break;
688      case VERSIONEDUPDATE:
689        tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.ResourceVersionPolicy.VERSIONEDUPDATE);
690        break;
691      default:
692        tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.ResourceVersionPolicy.NULL);
693        break;
694    }
695    return tgt;
696  }
697
698  static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Conformance.ResourceVersionPolicy> convertResourceVersionPolicy(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CapabilityStatement.ResourceVersionPolicy> src) throws FHIRException {
699    if (src == null || src.isEmpty())
700      return null;
701    org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Conformance.ResourceVersionPolicy> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Conformance.ResourceVersionPolicyEnumFactory());
702    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
703    switch (src.getValue()) {
704      case NOVERSION:
705        tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.ResourceVersionPolicy.NOVERSION);
706        break;
707      case VERSIONED:
708        tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.ResourceVersionPolicy.VERSIONED);
709        break;
710      case VERSIONEDUPDATE:
711        tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.ResourceVersionPolicy.VERSIONEDUPDATE);
712        break;
713      default:
714        tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.ResourceVersionPolicy.NULL);
715        break;
716    }
717    return tgt;
718  }
719
720  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CapabilityStatement.RestfulCapabilityMode> convertRestfulConformanceMode(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Conformance.RestfulConformanceMode> src) throws FHIRException {
721    if (src == null || src.isEmpty())
722      return null;
723    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CapabilityStatement.RestfulCapabilityMode> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.CapabilityStatement.RestfulCapabilityModeEnumFactory());
724    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
725    switch (src.getValue()) {
726      case CLIENT:
727        tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.RestfulCapabilityMode.CLIENT);
728        break;
729      case SERVER:
730        tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.RestfulCapabilityMode.SERVER);
731        break;
732      default:
733        tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.RestfulCapabilityMode.NULL);
734        break;
735    }
736    return tgt;
737  }
738
739  static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Conformance.RestfulConformanceMode> convertRestfulConformanceMode(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CapabilityStatement.RestfulCapabilityMode> src) throws FHIRException {
740    if (src == null || src.isEmpty())
741      return null;
742    org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Conformance.RestfulConformanceMode> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Conformance.RestfulConformanceModeEnumFactory());
743    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
744    switch (src.getValue()) {
745      case CLIENT:
746        tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.RestfulConformanceMode.CLIENT);
747        break;
748      case SERVER:
749        tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.RestfulConformanceMode.SERVER);
750        break;
751      default:
752        tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.RestfulConformanceMode.NULL);
753        break;
754    }
755    return tgt;
756  }
757
758  public static org.hl7.fhir.dstu2.model.Conformance.SystemInteractionComponent convertSystemInteractionComponent(org.hl7.fhir.r4.model.CapabilityStatement.SystemInteractionComponent src) throws FHIRException {
759    if (src == null || src.isEmpty())
760      return null;
761    org.hl7.fhir.dstu2.model.Conformance.SystemInteractionComponent tgt = new org.hl7.fhir.dstu2.model.Conformance.SystemInteractionComponent();
762    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
763    if (src.hasCode())
764      tgt.setCodeElement(convertSystemRestfulInteraction(src.getCodeElement()));
765    if (src.hasDocumentation())
766      tgt.setDocumentation(src.getDocumentation());
767    return tgt;
768  }
769
770  public static org.hl7.fhir.r4.model.CapabilityStatement.SystemInteractionComponent convertSystemInteractionComponent(org.hl7.fhir.dstu2.model.Conformance.SystemInteractionComponent src) throws FHIRException {
771    if (src == null || src.isEmpty())
772      return null;
773    org.hl7.fhir.r4.model.CapabilityStatement.SystemInteractionComponent tgt = new org.hl7.fhir.r4.model.CapabilityStatement.SystemInteractionComponent();
774    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
775    if (src.hasCode())
776      tgt.setCodeElement(convertSystemRestfulInteraction(src.getCodeElement()));
777    if (src.hasDocumentation())
778      tgt.setDocumentation(src.getDocumentation());
779    return tgt;
780  }
781
782  static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Conformance.SystemRestfulInteraction> convertSystemRestfulInteraction(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CapabilityStatement.SystemRestfulInteraction> src) throws FHIRException {
783    if (src == null || src.isEmpty())
784      return null;
785    org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Conformance.SystemRestfulInteraction> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Conformance.SystemRestfulInteractionEnumFactory());
786    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
787    switch (src.getValue()) {
788      case TRANSACTION:
789        tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.SystemRestfulInteraction.TRANSACTION);
790        break;
791      case SEARCHSYSTEM:
792        tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.SystemRestfulInteraction.SEARCHSYSTEM);
793        break;
794      case HISTORYSYSTEM:
795        tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.SystemRestfulInteraction.HISTORYSYSTEM);
796        break;
797      default:
798        tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.SystemRestfulInteraction.NULL);
799        break;
800    }
801    return tgt;
802  }
803
804  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CapabilityStatement.SystemRestfulInteraction> convertSystemRestfulInteraction(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Conformance.SystemRestfulInteraction> src) throws FHIRException {
805    if (src == null || src.isEmpty())
806      return null;
807    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CapabilityStatement.SystemRestfulInteraction> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.CapabilityStatement.SystemRestfulInteractionEnumFactory());
808    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
809    switch (src.getValue()) {
810      case TRANSACTION:
811        tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.SystemRestfulInteraction.TRANSACTION);
812        break;
813      case SEARCHSYSTEM:
814        tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.SystemRestfulInteraction.SEARCHSYSTEM);
815        break;
816      case HISTORYSYSTEM:
817        tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.SystemRestfulInteraction.HISTORYSYSTEM);
818        break;
819      default:
820        tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.SystemRestfulInteraction.NULL);
821        break;
822    }
823    return tgt;
824  }
825
826  static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Conformance.TypeRestfulInteraction> convertTypeRestfulInteraction(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction> src) throws FHIRException {
827    if (src == null || src.isEmpty())
828      return null;
829    org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Conformance.TypeRestfulInteraction> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Conformance.TypeRestfulInteractionEnumFactory());
830    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
831    switch (src.getValue()) {
832      case READ:
833        tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.TypeRestfulInteraction.READ);
834        break;
835      case VREAD:
836        tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.TypeRestfulInteraction.VREAD);
837        break;
838      case UPDATE:
839        tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.TypeRestfulInteraction.UPDATE);
840        break;
841      case DELETE:
842        tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.TypeRestfulInteraction.DELETE);
843        break;
844      case HISTORYINSTANCE:
845        tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.TypeRestfulInteraction.HISTORYINSTANCE);
846        break;
847      case HISTORYTYPE:
848        tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.TypeRestfulInteraction.HISTORYTYPE);
849        break;
850      case CREATE:
851        tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.TypeRestfulInteraction.CREATE);
852        break;
853      case SEARCHTYPE:
854        tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.TypeRestfulInteraction.SEARCHTYPE);
855        break;
856      default:
857        tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.TypeRestfulInteraction.NULL);
858        break;
859    }
860    return tgt;
861  }
862
863  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction> convertTypeRestfulInteraction(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Conformance.TypeRestfulInteraction> src) throws FHIRException {
864    if (src == null || src.isEmpty())
865      return null;
866    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteractionEnumFactory());
867    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
868    switch (src.getValue()) {
869      case READ:
870        tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction.READ);
871        break;
872      case VREAD:
873        tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction.VREAD);
874        break;
875      case UPDATE:
876        tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction.UPDATE);
877        break;
878      case DELETE:
879        tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction.DELETE);
880        break;
881      case HISTORYINSTANCE:
882        tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction.HISTORYINSTANCE);
883        break;
884      case HISTORYTYPE:
885        tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction.HISTORYTYPE);
886        break;
887      case CREATE:
888        tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction.CREATE);
889        break;
890      case SEARCHTYPE:
891        tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction.SEARCHTYPE);
892        break;
893      default:
894        tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.TypeRestfulInteraction.NULL);
895        break;
896    }
897    return tgt;
898  }
899
900  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityMode> convertConformanceEventMode(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Conformance.ConformanceEventMode> src) throws FHIRException {
901    if (src == null || src.isEmpty()) return null;
902    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityMode> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityModeEnumFactory());
903    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
904    if (src.getValue() == null) {
905      tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityMode.NULL);
906    } else {
907      switch (src.getValue()) {
908        case SENDER:
909          tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityMode.SENDER);
910          break;
911        case RECEIVER:
912          tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityMode.RECEIVER);
913          break;
914        default:
915          tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityMode.NULL);
916          break;
917      }
918    }
919    return tgt;
920  }
921
922  static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Conformance.ConformanceEventMode> convertConformanceEventMode(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityMode> src) throws FHIRException {
923    if (src == null || src.isEmpty()) return null;
924    org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Conformance.ConformanceEventMode> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Conformance.ConformanceEventModeEnumFactory());
925    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
926    if (src.getValue() == null) {
927      tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.ConformanceEventMode.NULL);
928    } else {
929      switch (src.getValue()) {
930        case SENDER:
931          tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.ConformanceEventMode.SENDER);
932          break;
933        case RECEIVER:
934          tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.ConformanceEventMode.RECEIVER);
935          break;
936        default:
937          tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.ConformanceEventMode.NULL);
938          break;
939      }
940    }
941    return tgt;
942  }
943}