001package org.hl7.fhir.convertors.conv10_40.resources10_40;
002
003import org.hl7.fhir.convertors.context.ConversionContext10_40;
004import org.hl7.fhir.convertors.conv10_40.VersionConvertor_10_40;
005import org.hl7.fhir.convertors.conv10_40.datatypes10_40.ElementDefinition10_40;
006import org.hl7.fhir.convertors.conv10_40.datatypes10_40.complextypes10_40.CodeableConcept10_40;
007import org.hl7.fhir.convertors.conv10_40.datatypes10_40.complextypes10_40.Coding10_40;
008import org.hl7.fhir.convertors.conv10_40.datatypes10_40.complextypes10_40.ContactPoint10_40;
009import org.hl7.fhir.convertors.conv10_40.datatypes10_40.complextypes10_40.Identifier10_40;
010import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.*;
011import org.hl7.fhir.exceptions.FHIRException;
012import org.hl7.fhir.r4.model.ElementDefinition;
013import org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind;
014import org.hl7.fhir.r4.model.StructureDefinition.TypeDerivationRule;
015import org.hl7.fhir.utilities.Utilities;
016
017import java.util.ArrayList;
018import java.util.List;
019
020public class StructureDefinition10_40 {
021
022  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.StructureDefinition.ExtensionContextType> convertExtensionContext(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.StructureDefinition.ExtensionContext> src) throws FHIRException {
023    if (src == null || src.isEmpty())
024      return null;
025    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.StructureDefinition.ExtensionContextType> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.StructureDefinition.ExtensionContextTypeEnumFactory());
026    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
027    switch (src.getValue()) {
028      case RESOURCE:
029        tgt.setValue(org.hl7.fhir.r4.model.StructureDefinition.ExtensionContextType.ELEMENT);
030        break;
031      case DATATYPE:
032        tgt.setValue(org.hl7.fhir.r4.model.StructureDefinition.ExtensionContextType.ELEMENT);
033        break;
034      case EXTENSION:
035        tgt.setValue(org.hl7.fhir.r4.model.StructureDefinition.ExtensionContextType.EXTENSION);
036        break;
037      default:
038        tgt.setValue(org.hl7.fhir.r4.model.StructureDefinition.ExtensionContextType.NULL);
039        break;
040    }
041    return tgt;
042  }
043
044  static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.StructureDefinition.ExtensionContext> convertExtensionContext(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.StructureDefinition.ExtensionContextType> src, String expression) throws FHIRException {
045    if (src == null || src.isEmpty())
046      return null;
047    org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.StructureDefinition.ExtensionContext> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.StructureDefinition.ExtensionContextEnumFactory());
048    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
049    switch (src.getValue()) {
050      case FHIRPATH:
051        tgt.setValue(org.hl7.fhir.dstu2.model.StructureDefinition.ExtensionContext.RESOURCE);
052        break;
053      case ELEMENT:
054        String tn = expression.contains(".") ? expression.substring(0, expression.indexOf(".")) : expression;
055        if (isResource102(tn)) {
056          tgt.setValue(org.hl7.fhir.dstu2.model.StructureDefinition.ExtensionContext.RESOURCE);
057        } else {
058          tgt.setValue(org.hl7.fhir.dstu2.model.StructureDefinition.ExtensionContext.DATATYPE);
059        }
060        break;
061      case EXTENSION:
062        tgt.setValue(org.hl7.fhir.dstu2.model.StructureDefinition.ExtensionContext.EXTENSION);
063        break;
064      default:
065        tgt.setValue(org.hl7.fhir.dstu2.model.StructureDefinition.ExtensionContext.NULL);
066        break;
067    }
068    return tgt;
069  }
070
071  public static org.hl7.fhir.r4.model.StructureDefinition convertStructureDefinition(org.hl7.fhir.dstu2.model.StructureDefinition src) throws FHIRException {
072    if (src == null || src.isEmpty())
073      return null;
074    org.hl7.fhir.r4.model.StructureDefinition tgt = new org.hl7.fhir.r4.model.StructureDefinition();
075    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyDomainResource(src, tgt);
076    if (src.hasUrlElement())
077      tgt.setUrlElement(Uri10_40.convertUri(src.getUrlElement()));
078    for (org.hl7.fhir.dstu2.model.Identifier t : src.getIdentifier())
079      tgt.addIdentifier(Identifier10_40.convertIdentifier(t));
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.hasDisplayElement())
085      tgt.setTitleElement(String10_40.convertString(src.getDisplayElement()));
086    if (src.hasStatus())
087      tgt.setStatusElement(Enumerations10_40.convertConformanceResourceStatus(src.getStatusElement()));
088    if (src.hasExperimental())
089      tgt.setExperimentalElement(Boolean10_40.convertBoolean(src.getExperimentalElement()));
090    if (src.hasPublisherElement())
091      tgt.setPublisherElement(String10_40.convertString(src.getPublisherElement()));
092    for (org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionContactComponent t : src.getContact())
093      tgt.addContact(convertStructureDefinitionContactComponent(t));
094    if (src.hasDate())
095      tgt.setDateElement(DateTime10_40.convertDateTime(src.getDateElement()));
096    if (src.hasDescription())
097      tgt.setDescription(src.getDescription());
098    for (org.hl7.fhir.dstu2.model.CodeableConcept t : src.getUseContext())
099      if (VersionConvertor_10_40.isJurisdiction(t))
100        tgt.addJurisdiction(CodeableConcept10_40.convertCodeableConcept(t));
101      else
102        tgt.addUseContext(CodeableConcept10_40.convertCodeableConceptToUsageContext(t));
103    if (src.hasRequirements())
104      tgt.setPurpose(src.getRequirements());
105    if (src.hasCopyright())
106      tgt.setCopyright(src.getCopyright());
107    for (org.hl7.fhir.dstu2.model.Coding t : src.getCode()) tgt.addKeyword(Coding10_40.convertCoding(t));
108    if (src.hasFhirVersion())
109      tgt.setFhirVersion(org.hl7.fhir.r4.model.Enumerations.FHIRVersion.fromCode(src.getFhirVersion()));
110    for (org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionMappingComponent t : src.getMapping())
111      tgt.addMapping(convertStructureDefinitionMappingComponent(t));
112    if (src.hasKind())
113      tgt.setKindElement(convertStructureDefinitionKind(src.getKindElement(), tgt.getId()));
114    if (src.hasAbstractElement())
115      tgt.setAbstractElement(Boolean10_40.convertBoolean(src.getAbstractElement()));
116    for (org.hl7.fhir.dstu2.model.StringType t : src.getContext()) {
117      org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionContextComponent ec = tgt.addContext();
118      ec.setTypeElement(convertExtensionContext(src.getContextTypeElement()));
119      ec.setExpression("*".equals(t.getValue()) ? "Element" : t.getValue());
120    }
121    if (src.hasConstrainedType())
122      tgt.setType(src.getConstrainedType());
123    else if (src.getSnapshot().hasElement())
124      tgt.setType(src.getSnapshot().getElement().get(0).getPath());
125    else if (src.getDifferential().hasElement() && !src.getDifferential().getElement().get(0).getPath().contains("."))
126      tgt.setType(src.getDifferential().getElement().get(0).getPath());
127    else
128      tgt.setType(src.getDifferential().getElement().get(0).getPath().substring(0, src.getDifferential().getElement().get(0).getPath().indexOf(".")));
129    if (src.hasBase())
130      tgt.setBaseDefinition(src.getBase());
131    tgt.setDerivation(src.hasConstrainedType() ? org.hl7.fhir.r4.model.StructureDefinition.TypeDerivationRule.CONSTRAINT : org.hl7.fhir.r4.model.StructureDefinition.TypeDerivationRule.SPECIALIZATION);
132    if (src.hasSnapshot())
133      tgt.setSnapshot(convertStructureDefinitionSnapshotComponent(src.getSnapshot()));
134    if (src.hasDifferential())
135      tgt.setDifferential(convertStructureDefinitionDifferentialComponent(src.getDifferential()));
136    if (tgt.hasSnapshot())
137      tgt.getSnapshot().getElementFirstRep().getType().clear();
138    if (tgt.hasDifferential())
139      tgt.getDifferential().getElementFirstRep().getType().clear();
140    if (tgt.getKind() == StructureDefinitionKind.PRIMITIVETYPE && !tgt.getType().equals(tgt.getId())) {
141      tgt.setDerivation(TypeDerivationRule.SPECIALIZATION);
142      tgt.setBaseDefinition("http://hl7.org/fhir/StructureDefinition/" + tgt.getType());
143      tgt.setType(tgt.getId());
144    }
145    if (tgt.getDerivation() == TypeDerivationRule.SPECIALIZATION) {
146      for (ElementDefinition ed : tgt.getSnapshot().getElement()) {
147        if (!ed.hasBase()) {
148          ed.getBase().setPath(ed.getPath()).setMin(ed.getMin()).setMax(ed.getMax());
149        }
150      }
151    }
152    return tgt;
153  }
154
155  public static org.hl7.fhir.dstu2.model.StructureDefinition convertStructureDefinition(org.hl7.fhir.r4.model.StructureDefinition src) throws FHIRException {
156    if (src == null || src.isEmpty())
157      return null;
158    org.hl7.fhir.dstu2.model.StructureDefinition tgt = new org.hl7.fhir.dstu2.model.StructureDefinition();
159    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyDomainResource(src, tgt);
160    if (src.hasUrlElement())
161      tgt.setUrlElement(Uri10_40.convertUri(src.getUrlElement()));
162    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
163      tgt.addIdentifier(Identifier10_40.convertIdentifier(t));
164    if (src.hasVersionElement())
165      tgt.setVersionElement(String10_40.convertString(src.getVersionElement()));
166    if (src.hasNameElement())
167      tgt.setNameElement(String10_40.convertString(src.getNameElement()));
168    if (src.hasTitleElement())
169      tgt.setDisplayElement(String10_40.convertString(src.getTitleElement()));
170    if (src.hasStatus())
171      tgt.setStatusElement(Enumerations10_40.convertConformanceResourceStatus(src.getStatusElement()));
172    if (src.hasExperimental())
173      tgt.setExperimentalElement(Boolean10_40.convertBoolean(src.getExperimentalElement()));
174    if (src.hasPublisherElement())
175      tgt.setPublisherElement(String10_40.convertString(src.getPublisherElement()));
176    for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact())
177      tgt.addContact(convertStructureDefinitionContactComponent(t));
178    if (src.hasDate())
179      tgt.setDateElement(DateTime10_40.convertDateTime(src.getDateElement()));
180    if (src.hasDescription())
181      tgt.setDescription(src.getDescription());
182    for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext())
183      if (t.hasValueCodeableConcept())
184        tgt.addUseContext(CodeableConcept10_40.convertCodeableConcept(t.getValueCodeableConcept()));
185    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction())
186      tgt.addUseContext(CodeableConcept10_40.convertCodeableConcept(t));
187    if (src.hasPurpose())
188      tgt.setRequirements(src.getPurpose());
189    if (src.hasCopyright())
190      tgt.setCopyright(src.getCopyright());
191    for (org.hl7.fhir.r4.model.Coding t : src.getKeyword()) tgt.addCode(Coding10_40.convertCoding(t));
192    if (src.hasFhirVersion())
193      tgt.setFhirVersion(src.getFhirVersion().toCode());
194    for (org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionMappingComponent t : src.getMapping())
195      tgt.addMapping(convertStructureDefinitionMappingComponent(t));
196    if (src.hasKind())
197      tgt.setKindElement(convertStructureDefinitionKind(src.getKindElement()));
198    if (src.hasAbstractElement())
199      tgt.setAbstractElement(Boolean10_40.convertBoolean(src.getAbstractElement()));
200    for (org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionContextComponent t : src.getContext()) {
201      if (!tgt.hasContextType())
202        tgt.setContextTypeElement(convertExtensionContext(t.getTypeElement(), t.getExpression()));
203      tgt.addContext("Element".equals(t.getExpression()) ? "*" : t.getExpression());
204    }
205    if (src.hasType())
206      tgt.setConstrainedType(src.getType());
207    if (src.hasBaseDefinition())
208      tgt.setBase(src.getBaseDefinition());
209    if (src.hasSnapshot())
210      tgt.setSnapshot(convertStructureDefinitionSnapshotComponent(src.getSnapshot()));
211    if (src.hasDifferential())
212      tgt.setDifferential(convertStructureDefinitionDifferentialComponent(src.getDifferential()));
213    if (tgt.hasBase()) {
214      if (tgt.hasDifferential())
215        tgt.getDifferential().getElement().get(0).addType().setCode(tail(tgt.getBase()));
216      if (tgt.hasSnapshot())
217        tgt.getSnapshot().getElement().get(0).addType().setCode(tail(tgt.getBase()));
218    }
219    return tgt;
220  }
221
222  public static org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionContactComponent convertStructureDefinitionContactComponent(org.hl7.fhir.r4.model.ContactDetail src) throws FHIRException {
223    if (src == null || src.isEmpty())
224      return null;
225    org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionContactComponent tgt = new org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionContactComponent();
226    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
227    if (src.hasNameElement())
228      tgt.setNameElement(String10_40.convertString(src.getNameElement()));
229    for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom())
230      tgt.addTelecom(ContactPoint10_40.convertContactPoint(t));
231    return tgt;
232  }
233
234  public static org.hl7.fhir.r4.model.ContactDetail convertStructureDefinitionContactComponent(org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionContactComponent src) throws FHIRException {
235    if (src == null || src.isEmpty())
236      return null;
237    org.hl7.fhir.r4.model.ContactDetail tgt = new org.hl7.fhir.r4.model.ContactDetail();
238    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
239    if (src.hasNameElement())
240      tgt.setNameElement(String10_40.convertString(src.getNameElement()));
241    for (org.hl7.fhir.dstu2.model.ContactPoint t : src.getTelecom())
242      tgt.addTelecom(ContactPoint10_40.convertContactPoint(t));
243    return tgt;
244  }
245
246  public static org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionDifferentialComponent convertStructureDefinitionDifferentialComponent(org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionDifferentialComponent src) throws FHIRException {
247    if (src == null || src.isEmpty())
248      return null;
249    org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionDifferentialComponent tgt = new org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionDifferentialComponent();
250    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
251    List<String> slicePaths = new ArrayList<String>();
252    for (org.hl7.fhir.dstu2.model.ElementDefinition t : src.getElement()) {
253      if (t.hasSlicing())
254        slicePaths.add(t.getPath());
255      tgt.addElement(ElementDefinition10_40.convertElementDefinition(t, slicePaths, src.getElement(), src.getElement().indexOf(t)));
256    }
257    return tgt;
258  }
259
260  public static org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionDifferentialComponent convertStructureDefinitionDifferentialComponent(org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionDifferentialComponent src) throws FHIRException {
261    if (src == null || src.isEmpty())
262      return null;
263    org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionDifferentialComponent tgt = new org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionDifferentialComponent();
264    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
265    for (org.hl7.fhir.r4.model.ElementDefinition t : src.getElement())
266      tgt.addElement(ElementDefinition10_40.convertElementDefinition(t));
267    return tgt;
268  }
269
270  public static org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind> convertStructureDefinitionKind(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionKind> src, String dtName) throws FHIRException {
271    if (src == null || src.isEmpty())
272      return null;
273    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKindEnumFactory());
274    switch (src.getValue()) {
275      case DATATYPE:
276        if (Utilities.existsInList(dtName, "boolean", "integer", "decimal", "base64Binary", "instant", "string", "uri", "date", "dateTime", "time", "code", "oid", "uuid", "id", "unsignedInt", "positiveInt", "markdown", "xhtml", "url", "canonical"))
277          tgt.setValue(org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind.PRIMITIVETYPE);
278        else
279          tgt.setValue(org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind.COMPLEXTYPE);
280        break;
281      case RESOURCE:
282        tgt.setValue(org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind.RESOURCE);
283        break;
284      case LOGICAL:
285        tgt.setValue(org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind.LOGICAL);
286        break;
287      default:
288        tgt.setValue(org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind.NULL);
289        break;
290    }
291    return tgt;
292  }
293
294  static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionKind> convertStructureDefinitionKind(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind> src) throws FHIRException {
295    if (src == null || src.isEmpty())
296      return null;
297    org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionKind> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionKindEnumFactory());
298    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
299    switch (src.getValue()) {
300      case PRIMITIVETYPE:
301        tgt.setValue(org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionKind.DATATYPE);
302        break;
303      case COMPLEXTYPE:
304        tgt.setValue(org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionKind.DATATYPE);
305        break;
306      case RESOURCE:
307        tgt.setValue(org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionKind.RESOURCE);
308        break;
309      case LOGICAL:
310        tgt.setValue(org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionKind.LOGICAL);
311        break;
312      default:
313        tgt.setValue(org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionKind.NULL);
314        break;
315    }
316    return tgt;
317  }
318
319  public static org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionMappingComponent convertStructureDefinitionMappingComponent(org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionMappingComponent src) throws FHIRException {
320    if (src == null || src.isEmpty())
321      return null;
322    org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionMappingComponent tgt = new org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionMappingComponent();
323    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
324    if (src.hasIdentityElement())
325      tgt.setIdentityElement(Id10_40.convertId(src.getIdentityElement()));
326    if (src.hasUriElement())
327      tgt.setUriElement(Uri10_40.convertUri(src.getUriElement()));
328    if (src.hasNameElement())
329      tgt.setNameElement(String10_40.convertString(src.getNameElement()));
330    if (src.hasCommentElement())
331      tgt.setCommentsElement(String10_40.convertString(src.getCommentElement()));
332    return tgt;
333  }
334
335  public static org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionMappingComponent convertStructureDefinitionMappingComponent(org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionMappingComponent src) throws FHIRException {
336    if (src == null || src.isEmpty())
337      return null;
338    org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionMappingComponent tgt = new org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionMappingComponent();
339    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
340    if (src.hasIdentityElement())
341      tgt.setIdentityElement(Id10_40.convertId(src.getIdentityElement()));
342    if (src.hasUriElement())
343      tgt.setUriElement(Uri10_40.convertUri(src.getUriElement()));
344    if (src.hasNameElement())
345      tgt.setNameElement(String10_40.convertString(src.getNameElement()));
346    if (src.hasCommentsElement())
347      tgt.setCommentElement(String10_40.convertString(src.getCommentsElement()));
348    return tgt;
349  }
350
351  public static org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionSnapshotComponent convertStructureDefinitionSnapshotComponent(org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionSnapshotComponent src) throws FHIRException {
352    if (src == null || src.isEmpty())
353      return null;
354    org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionSnapshotComponent tgt = new org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionSnapshotComponent();
355    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
356    List<String> slicePaths = new ArrayList<String>();
357    for (org.hl7.fhir.dstu2.model.ElementDefinition t : src.getElement()) {
358      if (t.hasSlicing())
359        slicePaths.add(t.getPath());
360      tgt.addElement(ElementDefinition10_40.convertElementDefinition(t, slicePaths, src.getElement(), src.getElement().indexOf(t)));
361    }
362    return tgt;
363  }
364
365  public static org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionSnapshotComponent convertStructureDefinitionSnapshotComponent(org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionSnapshotComponent src) throws FHIRException {
366    if (src == null || src.isEmpty())
367      return null;
368    org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionSnapshotComponent tgt = new org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionSnapshotComponent();
369    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
370    for (org.hl7.fhir.r4.model.ElementDefinition t : src.getElement())
371      tgt.addElement(ElementDefinition10_40.convertElementDefinition(t));
372    return tgt;
373  }
374
375  static public boolean isResource102(String tn) {
376    return Utilities.existsInList(tn, "AllergyIntolerance", "Appointment", "AppointmentResponse", "AuditEvent", "Basic", "Binary", "BodySite", "Bundle", "CarePlan", "Claim", "ClaimResponse", "ClinicalImpression", "Communication", "CommunicationRequest", "Composition", "ConceptMap", "Condition", "Conformance", "Contract", "DetectedIssue", "Coverage", "DataElement", "Device", "DeviceComponent", "DeviceMetric", "DeviceUseRequest", "DeviceUseStatement", "DiagnosticOrder", "DiagnosticReport", "DocumentManifest", "DocumentReference", "EligibilityRequest", "EligibilityResponse", "Encounter", "EnrollmentRequest", "EnrollmentResponse", "EpisodeOfCare", "ExplanationOfBenefit", "FamilyMemberHistory", "Flag", "Goal", "Group", "HealthcareService", "ImagingObjectSelection", "ImagingStudy", "Immunization", "ImmunizationRecommendation", "ImplementationGuide", "List", "Location", "Media", "Medication", "MedicationAdministration", "MedicationDispense", "MedicationOrder", "MedicationStatement", "MessageHeader", "NamingSystem", "NutritionOrder", "Observation", "OperationDefinition", "OperationOutcome", "Order", "OrderResponse", "Organization", "Parameters", "Patient", "PaymentNotice", "PaymentReconciliation", "Person", "Practitioner", "Procedure", "ProcessRequest", "ProcessResponse", "ProcedureRequest", "Provenance", "Questionnaire", "QuestionnaireResponse", "ReferralRequest", "RelatedPerson", "RiskAssessment", "Schedule", "SearchParameter", "Slot", "Specimen", "StructureDefinition", "Subscription", "Substance", "SupplyRequest", "SupplyDelivery", "TestScript", "ValueSet", "VisionPrescription");
377  }
378
379  static public String tail(String base) {
380    return base.substring(base.lastIndexOf("/") + 1);
381  }
382}