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