001package org.hl7.fhir.convertors.conv14_50.resources14_50;
002
003import org.hl7.fhir.convertors.context.ConversionContext14_50;
004import org.hl7.fhir.convertors.conv14_50.datatypes14_50.ElementDefinition14_50;
005import org.hl7.fhir.convertors.conv14_50.datatypes14_50.complextypes14_50.CodeableConcept14_50;
006import org.hl7.fhir.convertors.conv14_50.datatypes14_50.complextypes14_50.Coding14_50;
007import org.hl7.fhir.convertors.conv14_50.datatypes14_50.complextypes14_50.ContactPoint14_50;
008import org.hl7.fhir.convertors.conv14_50.datatypes14_50.complextypes14_50.Identifier14_50;
009import org.hl7.fhir.convertors.conv14_50.datatypes14_50.primitivetypes14_50.Boolean14_50;
010import org.hl7.fhir.convertors.conv14_50.datatypes14_50.primitivetypes14_50.DateTime14_50;
011import org.hl7.fhir.convertors.conv14_50.datatypes14_50.primitivetypes14_50.Id14_50;
012import org.hl7.fhir.convertors.conv14_50.datatypes14_50.primitivetypes14_50.String14_50;
013import org.hl7.fhir.convertors.conv14_50.datatypes14_50.primitivetypes14_50.Uri14_50;
014import org.hl7.fhir.exceptions.FHIRException;
015import org.hl7.fhir.r5.model.ElementDefinition;
016import org.hl7.fhir.r5.model.Enumeration;
017import org.hl7.fhir.r5.model.StructureDefinition;
018import org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule;
019import org.hl7.fhir.utilities.Utilities;
020
021public class StructureDefinition14_50 {
022
023  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureDefinition.ExtensionContextType> convertExtensionContext(org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.StructureDefinition.ExtensionContext> src) throws FHIRException {
024      if (src == null || src.isEmpty())
025          return null;
026      Enumeration<StructureDefinition.ExtensionContextType> tgt = new Enumeration<>(new StructureDefinition.ExtensionContextTypeEnumFactory());
027      ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
028      if (src.getValue() == null) {
029          tgt.setValue(null);
030      } else {
031          switch (src.getValue()) {
032              case RESOURCE:
033                  tgt.setValue(StructureDefinition.ExtensionContextType.ELEMENT);
034                  break;
035              case DATATYPE:
036                  tgt.setValue(StructureDefinition.ExtensionContextType.ELEMENT);
037                  break;
038              case EXTENSION:
039                  tgt.setValue(StructureDefinition.ExtensionContextType.EXTENSION);
040                  break;
041              default:
042                  tgt.setValue(StructureDefinition.ExtensionContextType.NULL);
043                  break;
044          }
045      }
046      return tgt;
047  }
048
049  static public org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.StructureDefinition.ExtensionContext> convertExtensionContext(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureDefinition.ExtensionContextType> src, String expression) throws FHIRException {
050      if (src == null || src.isEmpty())
051          return null;
052      org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.StructureDefinition.ExtensionContext> tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.StructureDefinition.ExtensionContextEnumFactory());
053      ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
054      if (src.getValue() == null) {
055          tgt.setValue(null);
056      } else {
057          switch (src.getValue()) {
058              case FHIRPATH:
059                  tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureDefinition.ExtensionContext.RESOURCE);
060                  break;
061              case ELEMENT:
062                  String tn = expression.contains(".") ? expression.substring(0, expression.indexOf(".")) : expression;
063                  if (isResource140(tn)) {
064                      tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureDefinition.ExtensionContext.RESOURCE);
065                  } else {
066                      tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureDefinition.ExtensionContext.DATATYPE);
067                  }
068                  break;
069              case EXTENSION:
070                  tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureDefinition.ExtensionContext.EXTENSION);
071                  break;
072              default:
073                  tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureDefinition.ExtensionContext.NULL);
074                  break;
075          }
076      }
077      return tgt;
078  }
079
080  public static org.hl7.fhir.dstu2016may.model.StructureDefinition convertStructureDefinition(org.hl7.fhir.r5.model.StructureDefinition src) throws FHIRException {
081    if (src == null || src.isEmpty())
082      return null;
083    org.hl7.fhir.dstu2016may.model.StructureDefinition tgt = new org.hl7.fhir.dstu2016may.model.StructureDefinition();
084    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyDomainResource(src, tgt);
085    if (src.hasUrl())
086      tgt.setUrlElement(Uri14_50.convertUri(src.getUrlElement()));
087    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
088      tgt.addIdentifier(Identifier14_50.convertIdentifier(t));
089    if (src.hasVersion())
090      tgt.setVersionElement(String14_50.convertString(src.getVersionElement()));
091    if (src.hasNameElement())
092      tgt.setNameElement(String14_50.convertString(src.getNameElement()));
093    if (src.hasTitle())
094      tgt.setDisplayElement(String14_50.convertString(src.getTitleElement()));
095    if (src.hasStatus())
096      tgt.setStatusElement(Enumerations14_50.convertConformanceResourceStatus(src.getStatusElement()));
097    if (src.hasExperimental())
098      tgt.setExperimentalElement(Boolean14_50.convertBoolean(src.getExperimentalElement()));
099    if (src.hasPublisher())
100      tgt.setPublisherElement(String14_50.convertString(src.getPublisherElement()));
101    for (org.hl7.fhir.r5.model.ContactDetail t : src.getContact())
102      tgt.addContact(convertStructureDefinitionContactComponent(t));
103    if (src.hasDate())
104      tgt.setDateElement(DateTime14_50.convertDateTime(src.getDateElement()));
105    if (src.hasDescription())
106      tgt.setDescription(src.getDescription());
107    for (org.hl7.fhir.r5.model.UsageContext t : src.getUseContext())
108      if (t.hasValueCodeableConcept())
109        tgt.addUseContext(CodeableConcept14_50.convertCodeableConcept(t.getValueCodeableConcept()));
110    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getJurisdiction())
111      tgt.addUseContext(CodeableConcept14_50.convertCodeableConcept(t));
112    if (src.hasPurpose())
113      tgt.setRequirements(src.getPurpose());
114    if (src.hasCopyright())
115      tgt.setCopyright(src.getCopyright());
116    for (org.hl7.fhir.r5.model.Coding t : src.getKeyword()) tgt.addCode(Coding14_50.convertCoding(t));
117    if (src.hasFhirVersion())
118      tgt.setFhirVersion(src.getFhirVersion().toCode());
119    for (org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionMappingComponent t : src.getMapping())
120      tgt.addMapping(convertStructureDefinitionMappingComponent(t));
121    if (src.hasKind())
122      tgt.setKindElement(convertStructureDefinitionKind(src.getKindElement()));
123    if (src.hasAbstractElement())
124      tgt.setAbstractElement(Boolean14_50.convertBoolean(src.getAbstractElement()));
125    for (org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionContextComponent t : src.getContext()) {
126      if (!tgt.hasContextType())
127        tgt.setContextTypeElement(convertExtensionContext(t.getTypeElement(), t.getExpression()));
128      tgt.addContext("Element".equals(t.getExpression()) ? "*" : t.getExpression());
129    }
130    if (src.hasBaseDefinition())
131      tgt.setBaseDefinition(src.getBaseDefinition());
132    if (src.hasType() && src.getDerivation() == org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule.CONSTRAINT)
133      tgt.setBaseType(src.getType());
134    if (src.hasDerivation())
135      tgt.setDerivationElement(convertTypeDerivationRule(src.getDerivationElement()));
136    if (src.hasSnapshot())
137      tgt.setSnapshot(convertStructureDefinitionSnapshotComponent(src.getSnapshot()));
138    if (src.hasDifferential())
139      tgt.setDifferential(convertStructureDefinitionDifferentialComponent(src.getDifferential()));
140    return tgt;
141  }
142
143  public static org.hl7.fhir.r5.model.StructureDefinition convertStructureDefinition(org.hl7.fhir.dstu2016may.model.StructureDefinition src) throws FHIRException {
144    if (src == null || src.isEmpty())
145      return null;
146    org.hl7.fhir.r5.model.StructureDefinition tgt = new org.hl7.fhir.r5.model.StructureDefinition();
147    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyDomainResource(src, tgt);
148    if (src.hasUrl())
149      tgt.setUrlElement(Uri14_50.convertUri(src.getUrlElement()));
150    for (org.hl7.fhir.dstu2016may.model.Identifier t : src.getIdentifier())
151      tgt.addIdentifier(Identifier14_50.convertIdentifier(t));
152    if (src.hasVersion())
153      tgt.setVersionElement(String14_50.convertString(src.getVersionElement()));
154    if (src.hasNameElement())
155      tgt.setNameElement(String14_50.convertString(src.getNameElement()));
156    if (src.hasDisplay())
157      tgt.setTitleElement(String14_50.convertString(src.getDisplayElement()));
158    if (src.hasStatus())
159      tgt.setStatusElement(Enumerations14_50.convertConformanceResourceStatus(src.getStatusElement()));
160    if (src.hasExperimental())
161      tgt.setExperimentalElement(Boolean14_50.convertBoolean(src.getExperimentalElement()));
162    if (src.hasPublisher())
163      tgt.setPublisherElement(String14_50.convertString(src.getPublisherElement()));
164    for (org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionContactComponent t : src.getContact())
165      tgt.addContact(convertStructureDefinitionContactComponent(t));
166    if (src.hasDate())
167      tgt.setDateElement(DateTime14_50.convertDateTime(src.getDateElement()));
168    if (src.hasDescription())
169      tgt.setDescription(src.getDescription());
170    for (org.hl7.fhir.dstu2016may.model.CodeableConcept t : src.getUseContext())
171      if (CodeableConcept14_50.isJurisdiction(t))
172        tgt.addJurisdiction(CodeableConcept14_50.convertCodeableConcept(t));
173      else
174        tgt.addUseContext(CodeableConcept14_50.convertCodeableConceptToUsageContext(t));
175    if (src.hasRequirements())
176      tgt.setPurpose(src.getRequirements());
177    if (src.hasCopyright())
178      tgt.setCopyright(src.getCopyright());
179    for (org.hl7.fhir.dstu2016may.model.Coding t : src.getCode()) tgt.addKeyword(Coding14_50.convertCoding(t));
180    if (src.hasFhirVersion())
181      tgt.setFhirVersion(org.hl7.fhir.r5.model.Enumerations.FHIRVersion.fromCode(src.getFhirVersion()));
182    for (org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionMappingComponent t : src.getMapping())
183      tgt.addMapping(convertStructureDefinitionMappingComponent(t));
184    if (src.hasKind())
185      tgt.setKindElement(convertStructureDefinitionKind(src.getKindElement(), src.getName()));
186    if (src.hasAbstractElement())
187      tgt.setAbstractElement(Boolean14_50.convertBoolean(src.getAbstractElement()));
188    for (org.hl7.fhir.dstu2016may.model.StringType t : src.getContext()) {
189      org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionContextComponent ec = tgt.addContext();
190      ec.setTypeElement(convertExtensionContext(src.getContextTypeElement()));
191      ec.setExpression("*".equals(t.getValue()) ? "Element" : t.getValue());
192    }
193    if (src.getDerivation() == org.hl7.fhir.dstu2016may.model.StructureDefinition.TypeDerivationRule.CONSTRAINT)
194      tgt.setType(src.getBaseType());
195    else
196      tgt.setType(src.getId());
197    if (src.hasBaseDefinition())
198      tgt.setBaseDefinition(src.getBaseDefinition());
199    if (src.hasDerivation())
200      tgt.setDerivationElement(convertTypeDerivationRule(src.getDerivationElement()));
201    if (src.hasSnapshot()) {
202      if (src.hasSnapshot())
203        tgt.setSnapshot(convertStructureDefinitionSnapshotComponent(src.getSnapshot()));
204      tgt.getSnapshot().getElementFirstRep().getType().clear();
205    }
206    if (src.hasDifferential()) {
207      if (src.hasDifferential())
208        tgt.setDifferential(convertStructureDefinitionDifferentialComponent(src.getDifferential()));
209      if (!tgt.getDifferential().getElementFirstRep().getPath().contains(".")) {
210        tgt.getDifferential().getElementFirstRep().getType().clear();
211      }
212    }
213    if (tgt.getDerivation() == TypeDerivationRule.SPECIALIZATION) {
214      for (ElementDefinition ed : tgt.getSnapshot().getElement()) {
215        if (!ed.hasBase()) {
216          ed.getBase().setPath(ed.getPath()).setMin(ed.getMin()).setMax(ed.getMax());
217        }
218      }
219    }
220    return tgt;
221  }
222
223  public static org.hl7.fhir.r5.model.ContactDetail convertStructureDefinitionContactComponent(org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionContactComponent src) throws FHIRException {
224    if (src == null || src.isEmpty())
225      return null;
226    org.hl7.fhir.r5.model.ContactDetail tgt = new org.hl7.fhir.r5.model.ContactDetail();
227    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
228    if (src.hasName())
229      tgt.setNameElement(String14_50.convertString(src.getNameElement()));
230    for (org.hl7.fhir.dstu2016may.model.ContactPoint t : src.getTelecom())
231      tgt.addTelecom(ContactPoint14_50.convertContactPoint(t));
232    return tgt;
233  }
234
235  public static org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionContactComponent convertStructureDefinitionContactComponent(org.hl7.fhir.r5.model.ContactDetail src) throws FHIRException {
236    if (src == null || src.isEmpty())
237      return null;
238    org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionContactComponent tgt = new org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionContactComponent();
239    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
240    if (src.hasName())
241      tgt.setNameElement(String14_50.convertString(src.getNameElement()));
242    for (org.hl7.fhir.r5.model.ContactPoint t : src.getTelecom())
243      tgt.addTelecom(ContactPoint14_50.convertContactPoint(t));
244    return tgt;
245  }
246
247  public static org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionDifferentialComponent convertStructureDefinitionDifferentialComponent(org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionDifferentialComponent src) throws FHIRException {
248    if (src == null || src.isEmpty())
249      return null;
250    org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionDifferentialComponent tgt = new org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionDifferentialComponent();
251    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyBackboneElement(src,tgt);
252    for (org.hl7.fhir.r5.model.ElementDefinition t : src.getElement())
253      tgt.addElement(ElementDefinition14_50.convertElementDefinition(t));
254    return tgt;
255  }
256
257  public static org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionDifferentialComponent convertStructureDefinitionDifferentialComponent(org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionDifferentialComponent src) throws FHIRException {
258    if (src == null || src.isEmpty())
259      return null;
260    org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionDifferentialComponent tgt = new org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionDifferentialComponent();
261    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyBackboneElement(src,tgt);
262    for (org.hl7.fhir.dstu2016may.model.ElementDefinition t : src.getElement())
263      tgt.addElement(ElementDefinition14_50.convertElementDefinition(t, src.getElement(), src.getElement().indexOf(t)));
264    return tgt;
265  }
266
267  static public org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionKind> convertStructureDefinitionKind(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind> src) throws FHIRException {
268      if (src == null || src.isEmpty())
269          return null;
270      org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionKind> tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionKindEnumFactory());
271      ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
272      if (src.getValue() == null) {
273          tgt.setValue(null);
274      } else {
275          switch (src.getValue()) {
276              case PRIMITIVETYPE:
277                  tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionKind.DATATYPE);
278                  break;
279              case COMPLEXTYPE:
280                  tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionKind.DATATYPE);
281                  break;
282              case RESOURCE:
283                  tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionKind.RESOURCE);
284                  break;
285              case LOGICAL:
286                  tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionKind.LOGICAL);
287                  break;
288              default:
289                  tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionKind.NULL);
290                  break;
291          }
292      }
293      return tgt;
294  }
295
296  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind> convertStructureDefinitionKind(org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionKind> src, String name) throws FHIRException {
297      if (src == null || src.isEmpty())
298          return null;
299      Enumeration<StructureDefinition.StructureDefinitionKind> tgt = new Enumeration<>(new StructureDefinition.StructureDefinitionKindEnumFactory());
300      ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
301      if (src.getValue() == null) {
302          tgt.setValue(null);
303      } else {
304          switch (src.getValue()) {
305              case DATATYPE:
306                  if (name.substring(0, 1).toLowerCase().equals(name.substring(0, 1))) {
307                      tgt.setValue(StructureDefinition.StructureDefinitionKind.PRIMITIVETYPE);
308                  } else {
309                      tgt.setValue(StructureDefinition.StructureDefinitionKind.COMPLEXTYPE);
310                  }
311                  break;
312              case RESOURCE:
313                  tgt.setValue(StructureDefinition.StructureDefinitionKind.RESOURCE);
314                  break;
315              case LOGICAL:
316                  tgt.setValue(StructureDefinition.StructureDefinitionKind.LOGICAL);
317                  break;
318              default:
319                  tgt.setValue(StructureDefinition.StructureDefinitionKind.NULL);
320                  break;
321          }
322      }
323      return tgt;
324  }
325
326  public static org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionMappingComponent convertStructureDefinitionMappingComponent(org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionMappingComponent src) throws FHIRException {
327    if (src == null || src.isEmpty())
328      return null;
329    org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionMappingComponent tgt = new org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionMappingComponent();
330    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyBackboneElement(src,tgt);
331    if (src.hasIdentityElement())
332      tgt.setIdentityElement(Id14_50.convertId(src.getIdentityElement()));
333    if (src.hasUri())
334      tgt.setUriElement(Uri14_50.convertUri(src.getUriElement()));
335    if (src.hasName())
336      tgt.setNameElement(String14_50.convertString(src.getNameElement()));
337    if (src.hasComments())
338      tgt.setCommentElement(String14_50.convertString(src.getCommentsElement()));
339    return tgt;
340  }
341
342  public static org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionMappingComponent convertStructureDefinitionMappingComponent(org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionMappingComponent src) throws FHIRException {
343    if (src == null || src.isEmpty())
344      return null;
345    org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionMappingComponent tgt = new org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionMappingComponent();
346    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyBackboneElement(src,tgt);
347    if (src.hasIdentityElement())
348      tgt.setIdentityElement(Id14_50.convertId(src.getIdentityElement()));
349    if (src.hasUri())
350      tgt.setUriElement(Uri14_50.convertUri(src.getUriElement()));
351    if (src.hasName())
352      tgt.setNameElement(String14_50.convertString(src.getNameElement()));
353    if (src.hasComment())
354      tgt.setCommentsElement(String14_50.convertString(src.getCommentElement()));
355    return tgt;
356  }
357
358  public static org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionSnapshotComponent convertStructureDefinitionSnapshotComponent(org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionSnapshotComponent src) throws FHIRException {
359    if (src == null || src.isEmpty())
360      return null;
361    org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionSnapshotComponent tgt = new org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionSnapshotComponent();
362    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyBackboneElement(src,tgt);
363    for (org.hl7.fhir.dstu2016may.model.ElementDefinition t : src.getElement())
364      tgt.addElement(ElementDefinition14_50.convertElementDefinition(t, src.getElement(), src.getElement().indexOf(t)));
365    return tgt;
366  }
367
368  public static org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionSnapshotComponent convertStructureDefinitionSnapshotComponent(org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionSnapshotComponent src) throws FHIRException {
369    if (src == null || src.isEmpty())
370      return null;
371    org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionSnapshotComponent tgt = new org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionSnapshotComponent();
372    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyBackboneElement(src,tgt);
373    for (org.hl7.fhir.r5.model.ElementDefinition t : src.getElement())
374      tgt.addElement(ElementDefinition14_50.convertElementDefinition(t));
375    return tgt;
376  }
377
378  static public org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.StructureDefinition.TypeDerivationRule> convertTypeDerivationRule(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule> src) throws FHIRException {
379      if (src == null || src.isEmpty())
380          return null;
381      org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.StructureDefinition.TypeDerivationRule> tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.StructureDefinition.TypeDerivationRuleEnumFactory());
382      ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
383      if (src.getValue() == null) {
384          tgt.setValue(null);
385      } else {
386          switch (src.getValue()) {
387              case SPECIALIZATION:
388                  tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureDefinition.TypeDerivationRule.SPECIALIZATION);
389                  break;
390              case CONSTRAINT:
391                  tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureDefinition.TypeDerivationRule.CONSTRAINT);
392                  break;
393              default:
394                  tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureDefinition.TypeDerivationRule.NULL);
395                  break;
396          }
397      }
398      return tgt;
399  }
400
401  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule> convertTypeDerivationRule(org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.StructureDefinition.TypeDerivationRule> src) throws FHIRException {
402      if (src == null || src.isEmpty())
403          return null;
404      Enumeration<TypeDerivationRule> tgt = new Enumeration<>(new StructureDefinition.TypeDerivationRuleEnumFactory());
405      ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
406      if (src.getValue() == null) {
407          tgt.setValue(null);
408      } else {
409          switch (src.getValue()) {
410              case SPECIALIZATION:
411                  tgt.setValue(TypeDerivationRule.SPECIALIZATION);
412                  break;
413              case CONSTRAINT:
414                  tgt.setValue(TypeDerivationRule.CONSTRAINT);
415                  break;
416              default:
417                  tgt.setValue(TypeDerivationRule.NULL);
418                  break;
419          }
420      }
421      return tgt;
422  }
423
424  static public boolean isResource140(String tn) {
425    return Utilities.existsInList(tn, "Account", "AllergyIntolerance", "Appointment", "AppointmentResponse", "AuditEvent", "Basic", "Binary", "BodySite", "Bundle", "CarePlan", "CareTeam", "Claim", "ClaimResponse", "ClinicalImpression", "CodeSystem", "Communication", "CommunicationRequest", "CompartmentDefinition", "Composition", "ConceptMap", "Condition", "Conformance", "Contract", "Coverage", "DataElement", "DecisionSupportRule", "DecisionSupportServiceModule", "DetectedIssue", "Device", "DeviceComponent", "DeviceMetric", "DeviceUseRequest", "DeviceUseStatement", "DiagnosticOrder", "DiagnosticReport", "DocumentManifest", "DocumentReference", "EligibilityRequest", "EligibilityResponse", "Encounter", "EnrollmentRequest", "EnrollmentResponse", "EpisodeOfCare", "ExpansionProfile", "ExplanationOfBenefit", "FamilyMemberHistory", "Flag", "Goal", "Group", "GuidanceResponse", "HealthcareService", "ImagingExcerpt", "ImagingObjectSelection", "ImagingStudy", "Immunization", "ImmunizationRecommendation", "ImplementationGuide", "Library", "Linkage", "List", "Location", "Measure", "MeasureReport", "Media", "Medication", "MedicationAdministration", "MedicationDispense", "MedicationOrder", "MedicationStatement", "MessageHeader", "ModuleDefinition", "NamingSystem", "NutritionOrder", "Observation", "OperationDefinition", "OperationOutcome", "Order", "OrderResponse", "OrderSet", "Organization", "Parameters", "Patient", "PaymentNotice", "PaymentReconciliation", "Person", "Practitioner", "PractitionerRole", "Procedure", "ProcedureRequest", "ProcessRequest", "ProcessResponse", "Protocol", "Provenance", "Questionnaire", "QuestionnaireResponse", "ReferralRequest", "RelatedPerson", "RiskAssessment", "Schedule", "SearchParameter", "Sequence", "Slot", "Sequence", "Specimen", "StructureDefinition", "StructureMap", "Subscription", "Substance", "SupplyDelivery", "SupplyRequest", "Task", "TestScript", "ValueSet", "VisionPrescription");
426  }
427}