001package org.hl7.fhir.convertors.conv30_50.resources30_50;
002
003import org.hl7.fhir.convertors.VersionConvertorConstants;
004import org.hl7.fhir.convertors.context.ConversionContext30_50;
005import org.hl7.fhir.convertors.conv30_50.datatypes30_50.ContactDetail30_50;
006import org.hl7.fhir.convertors.conv30_50.datatypes30_50.UsageContext30_50;
007import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.CodeableConcept30_50;
008import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.Identifier30_50;
009import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.*;
010import org.hl7.fhir.dstu3.model.Enumerations.ConceptMapEquivalence;
011import org.hl7.fhir.exceptions.FHIRException;
012import org.hl7.fhir.r5.model.CanonicalType;
013import org.hl7.fhir.r5.model.Enumeration;
014import org.hl7.fhir.r5.model.Enumerations;
015import org.hl7.fhir.r5.model.Enumerations.ConceptMapRelationship;
016import org.hl7.fhir.r5.utils.ToolingExtensions;
017import org.hl7.fhir.utilities.CanonicalPair;
018
019public class ConceptMap30_50 {
020
021  public static org.hl7.fhir.dstu3.model.ConceptMap convertConceptMap(org.hl7.fhir.r5.model.ConceptMap src) throws FHIRException {
022    if (src == null)
023      return null;
024    org.hl7.fhir.dstu3.model.ConceptMap tgt = new org.hl7.fhir.dstu3.model.ConceptMap();
025    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
026    if (src.hasUrl())
027      tgt.setUrlElement(Uri30_50.convertUri(src.getUrlElement()));
028    if (src.hasIdentifier())
029      tgt.setIdentifier(Identifier30_50.convertIdentifier(src.getIdentifierFirstRep()));
030    if (src.hasVersion())
031      tgt.setVersionElement(String30_50.convertString(src.getVersionElement()));
032    if (src.hasName())
033      tgt.setNameElement(String30_50.convertString(src.getNameElement()));
034    if (src.hasTitle())
035      tgt.setTitleElement(String30_50.convertString(src.getTitleElement()));
036    if (src.hasStatus())
037      tgt.setStatusElement(Enumerations30_50.convertPublicationStatus(src.getStatusElement()));
038    if (src.hasExperimental())
039      tgt.setExperimentalElement(Boolean30_50.convertBoolean(src.getExperimentalElement()));
040    if (src.hasDate())
041      tgt.setDateElement(DateTime30_50.convertDateTime(src.getDateElement()));
042    if (src.hasPublisher())
043      tgt.setPublisherElement(String30_50.convertString(src.getPublisherElement()));
044    for (org.hl7.fhir.r5.model.ContactDetail t : src.getContact())
045      tgt.addContact(ContactDetail30_50.convertContactDetail(t));
046    if (src.hasDescription())
047      tgt.setDescriptionElement(MarkDown30_50.convertMarkdown(src.getDescriptionElement()));
048    for (org.hl7.fhir.r5.model.UsageContext t : src.getUseContext())
049      tgt.addUseContext(UsageContext30_50.convertUsageContext(t));
050    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getJurisdiction())
051      tgt.addJurisdiction(CodeableConcept30_50.convertCodeableConcept(t));
052    if (src.hasPurpose())
053      tgt.setPurposeElement(MarkDown30_50.convertMarkdown(src.getPurposeElement()));
054    if (src.hasCopyright())
055      tgt.setCopyrightElement(MarkDown30_50.convertMarkdown(src.getCopyrightElement()));
056    if (src.hasSource())
057      tgt.setSource(ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getSource()));
058    if (src.hasTarget())
059      tgt.setTarget(ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getTarget()));
060    for (org.hl7.fhir.r5.model.ConceptMap.ConceptMapGroupComponent t : src.getGroup())
061      tgt.addGroup(convertConceptMapGroupComponent(t));
062    return tgt;
063  }
064
065  public static org.hl7.fhir.r5.model.ConceptMap convertConceptMap(org.hl7.fhir.dstu3.model.ConceptMap src) throws FHIRException {
066    if (src == null)
067      return null;
068    org.hl7.fhir.r5.model.ConceptMap tgt = new org.hl7.fhir.r5.model.ConceptMap();
069    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
070    if (src.hasUrl())
071      tgt.setUrlElement(Uri30_50.convertUri(src.getUrlElement()));
072    if (src.hasIdentifier())
073      tgt.addIdentifier(Identifier30_50.convertIdentifier(src.getIdentifier()));
074    if (src.hasVersion())
075      tgt.setVersionElement(String30_50.convertString(src.getVersionElement()));
076    if (src.hasName())
077      tgt.setNameElement(String30_50.convertString(src.getNameElement()));
078    if (src.hasTitle())
079      tgt.setTitleElement(String30_50.convertString(src.getTitleElement()));
080    if (src.hasStatus())
081      tgt.setStatusElement(Enumerations30_50.convertPublicationStatus(src.getStatusElement()));
082    if (src.hasExperimental())
083      tgt.setExperimentalElement(Boolean30_50.convertBoolean(src.getExperimentalElement()));
084    if (src.hasDate())
085      tgt.setDateElement(DateTime30_50.convertDateTime(src.getDateElement()));
086    if (src.hasPublisher())
087      tgt.setPublisherElement(String30_50.convertString(src.getPublisherElement()));
088    for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact())
089      tgt.addContact(ContactDetail30_50.convertContactDetail(t));
090    if (src.hasDescription())
091      tgt.setDescriptionElement(MarkDown30_50.convertMarkdown(src.getDescriptionElement()));
092    for (org.hl7.fhir.dstu3.model.UsageContext t : src.getUseContext())
093      tgt.addUseContext(UsageContext30_50.convertUsageContext(t));
094    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getJurisdiction())
095      tgt.addJurisdiction(CodeableConcept30_50.convertCodeableConcept(t));
096    if (src.hasPurpose())
097      tgt.setPurposeElement(MarkDown30_50.convertMarkdown(src.getPurposeElement()));
098    if (src.hasCopyright())
099      tgt.setCopyrightElement(MarkDown30_50.convertMarkdown(src.getCopyrightElement()));
100    if (src.hasSource()) {
101      org.hl7.fhir.r5.model.DataType t = ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getSource());
102      tgt.setSource(t instanceof org.hl7.fhir.r5.model.Reference ? new org.hl7.fhir.r5.model.CanonicalType(((org.hl7.fhir.r5.model.Reference) t).getReference()) : t);
103    }
104    if (src.hasTarget()) {
105      org.hl7.fhir.r5.model.DataType t = ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getTarget());
106      tgt.setTarget(t instanceof org.hl7.fhir.r5.model.Reference ? new org.hl7.fhir.r5.model.CanonicalType(((org.hl7.fhir.r5.model.Reference) t).getReference()) : t);
107    }
108    for (org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupComponent t : src.getGroup())
109      tgt.addGroup(convertConceptMapGroupComponent(t));
110    return tgt;
111  }
112
113  public static org.hl7.fhir.r5.model.ConceptMap.ConceptMapGroupComponent convertConceptMapGroupComponent(org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupComponent src) throws FHIRException {
114    if (src == null)
115      return null;
116    org.hl7.fhir.r5.model.ConceptMap.ConceptMapGroupComponent tgt = new org.hl7.fhir.r5.model.ConceptMap.ConceptMapGroupComponent();
117    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
118    if (src.hasSource() || src.hasSourceVersion())
119      tgt.setSourceElement(convertUriAndVersionToCanonical(src.getSourceElement(), src.getSourceVersionElement()));
120    if (src.hasTarget() || src.hasTargetVersion())
121      tgt.setSourceElement(convertUriAndVersionToCanonical(src.getTargetElement(), src.getTargetVersionElement()));
122
123    for (org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent t : src.getElement())
124      tgt.addElement(convertSourceElementComponent(t));
125    if (src.hasUnmapped())
126      tgt.setUnmapped(convertConceptMapGroupUnmappedComponent(src.getUnmapped()));
127    return tgt;
128  }
129
130  public static org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupComponent convertConceptMapGroupComponent(org.hl7.fhir.r5.model.ConceptMap.ConceptMapGroupComponent src) throws FHIRException {
131    if (src == null)
132      return null;
133    org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupComponent tgt = new org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupComponent();
134    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
135    if (src.hasSource()) {
136      CanonicalPair cp = new CanonicalPair(src.getSource());
137      tgt.setSource(cp.getUrl());
138      tgt.setSourceVersion(cp.getVersion());
139    }
140    if (src.hasTarget()) {
141      CanonicalPair cp = new CanonicalPair(src.getTarget());
142      tgt.setTarget(cp.getUrl());
143      tgt.setTargetVersion(cp.getVersion());
144    }
145    for (org.hl7.fhir.r5.model.ConceptMap.SourceElementComponent t : src.getElement())
146      tgt.addElement(convertSourceElementComponent(t));
147    if (src.hasUnmapped())
148      tgt.setUnmapped(convertConceptMapGroupUnmappedComponent(src.getUnmapped()));
149    return tgt;
150  }
151
152  private static CanonicalType convertUriAndVersionToCanonical(org.hl7.fhir.dstu3.model.UriType srcUri, org.hl7.fhir.dstu3.model.StringType srcVersion) {
153    if (srcUri == null && srcVersion == null)
154      return null;
155    org.hl7.fhir.r5.model.CanonicalType tgt = new org.hl7.fhir.r5.model.CanonicalType();
156    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(srcUri == null ? srcVersion : srcUri, tgt);
157    if (srcUri.hasValue()) {
158      if (srcVersion.hasValue()) {
159        tgt.setValue(srcUri.getValue() + "|" + srcVersion.getValue());
160      } else {
161        tgt.setValue(srcUri.getValue());
162      }
163    }
164    return tgt;
165  }
166
167
168  public static org.hl7.fhir.r5.model.ConceptMap.ConceptMapGroupUnmappedComponent convertConceptMapGroupUnmappedComponent(org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupUnmappedComponent src) throws FHIRException {
169    if (src == null)
170      return null;
171    org.hl7.fhir.r5.model.ConceptMap.ConceptMapGroupUnmappedComponent tgt = new org.hl7.fhir.r5.model.ConceptMap.ConceptMapGroupUnmappedComponent();
172    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
173    if (src.hasMode())
174      tgt.setModeElement(convertConceptMapGroupUnmappedMode(src.getModeElement()));
175    if (src.hasCode())
176      tgt.setCodeElement(Code30_50.convertCode(src.getCodeElement()));
177    if (src.hasDisplay())
178      tgt.setDisplayElement(String30_50.convertString(src.getDisplayElement()));
179    if (src.hasUrl())
180      tgt.setUrl(src.getUrl());
181    return tgt;
182  }
183
184  public static org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupUnmappedComponent convertConceptMapGroupUnmappedComponent(org.hl7.fhir.r5.model.ConceptMap.ConceptMapGroupUnmappedComponent src) throws FHIRException {
185    if (src == null)
186      return null;
187    org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupUnmappedComponent tgt = new org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupUnmappedComponent();
188    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
189    if (src.hasMode())
190      tgt.setModeElement(convertConceptMapGroupUnmappedMode(src.getModeElement()));
191    if (src.hasCode())
192      tgt.setCodeElement(Code30_50.convertCode(src.getCodeElement()));
193    if (src.hasDisplay())
194      tgt.setDisplayElement(String30_50.convertString(src.getDisplayElement()));
195    if (src.hasUrl())
196      tgt.setUrl(src.getUrl());
197    return tgt;
198  }
199
200  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.ConceptMapGroupUnmappedMode> convertConceptMapGroupUnmappedMode(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupUnmappedMode> src) throws FHIRException {
201    if (src == null || src.isEmpty())
202      return null;
203    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.ConceptMapGroupUnmappedMode> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.ConceptMapGroupUnmappedModeEnumFactory());
204    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
205    switch (src.getValue()) {
206      case PROVIDED:
207        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ConceptMapGroupUnmappedMode.PROVIDED);
208        break;
209      case FIXED:
210        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ConceptMapGroupUnmappedMode.FIXED);
211        break;
212      case OTHERMAP:
213        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ConceptMapGroupUnmappedMode.OTHERMAP);
214        break;
215      default:
216        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ConceptMapGroupUnmappedMode.NULL);
217        break;
218    }
219    return tgt;
220  }
221
222  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupUnmappedMode> convertConceptMapGroupUnmappedMode(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.ConceptMapGroupUnmappedMode> src) throws FHIRException {
223    if (src == null || src.isEmpty())
224      return null;
225    org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupUnmappedMode> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupUnmappedModeEnumFactory());
226    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
227    switch (src.getValue()) {
228      case PROVIDED:
229        tgt.setValue(org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupUnmappedMode.PROVIDED);
230        break;
231      case FIXED:
232        tgt.setValue(org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupUnmappedMode.FIXED);
233        break;
234      case OTHERMAP:
235        tgt.setValue(org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupUnmappedMode.OTHERMAP);
236        break;
237      default:
238        tgt.setValue(org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupUnmappedMode.NULL);
239        break;
240    }
241    return tgt;
242  }
243
244  public static org.hl7.fhir.dstu3.model.Enumeration<ConceptMapEquivalence> convertConceptMapEquivalence(Enumeration<ConceptMapRelationship> src) throws FHIRException {
245    if (src == null || src.isEmpty())
246      return null;
247    org.hl7.fhir.dstu3.model.Enumeration<ConceptMapEquivalence> tgt = new org.hl7.fhir.dstu3.model.Enumeration<ConceptMapEquivalence>(new org.hl7.fhir.dstu3.model.Enumerations.ConceptMapEquivalenceEnumFactory());
248    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt, VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE);
249    if (src.hasExtension(VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE)) {
250      tgt.setValueAsString(src.getExtensionString(VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE));
251    } else {
252      switch (src.getValue()) {
253        case EQUIVALENT:
254          tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.ConceptMapEquivalence.EQUIVALENT);
255          break;
256        case SOURCEISNARROWERTHANTARGET:
257          tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.ConceptMapEquivalence.WIDER);
258          break;
259        case SOURCEISBROADERTHANTARGET:
260          tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.ConceptMapEquivalence.NARROWER);
261          break;
262        case NOTRELATEDTO:
263          tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.ConceptMapEquivalence.DISJOINT);
264          break;
265        default:
266          tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.ConceptMapEquivalence.NULL);
267          break;
268      }
269    }
270    return tgt;
271  }
272
273  public static Enumeration<ConceptMapRelationship> convertConceptMapRelationship(org.hl7.fhir.dstu3.model.Enumeration<ConceptMapEquivalence> src) throws FHIRException {
274    if (src == null || src.isEmpty())
275      return null;
276    Enumeration<ConceptMapRelationship> tgt = new Enumeration<ConceptMapRelationship>(new Enumerations.ConceptMapRelationshipEnumFactory());
277    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
278    ToolingExtensions.setCodeExtension(tgt, VersionConvertorConstants.EXT_OLD_CONCEPTMAP_EQUIVALENCE, src.getValueAsString());
279    switch (src.getValue()) {
280      case EQUIVALENT:
281        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ConceptMapRelationship.EQUIVALENT);
282        break;
283      case EQUAL:
284        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ConceptMapRelationship.EQUIVALENT);
285        break;
286      case WIDER:
287        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ConceptMapRelationship.SOURCEISNARROWERTHANTARGET);
288        break;
289      case SUBSUMES:
290        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ConceptMapRelationship.SOURCEISNARROWERTHANTARGET);
291        break;
292      case NARROWER:
293        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ConceptMapRelationship.SOURCEISBROADERTHANTARGET);
294        break;
295      case SPECIALIZES:
296        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ConceptMapRelationship.SOURCEISBROADERTHANTARGET);
297        break;
298      case INEXACT:
299        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ConceptMapRelationship.RELATEDTO);
300        break;
301      case UNMATCHED:
302        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ConceptMapRelationship.NULL);
303        break;
304      case DISJOINT:
305        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ConceptMapRelationship.NOTRELATEDTO);
306        break;
307      default:
308        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ConceptMapRelationship.NULL);
309        break;
310    }
311    return tgt;
312  }
313
314  public static org.hl7.fhir.r5.model.ConceptMap.OtherElementComponent convertOtherElementComponent(org.hl7.fhir.dstu3.model.ConceptMap.OtherElementComponent src) throws FHIRException {
315    if (src == null)
316      return null;
317    org.hl7.fhir.r5.model.ConceptMap.OtherElementComponent tgt = new org.hl7.fhir.r5.model.ConceptMap.OtherElementComponent();
318    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
319    if (src.hasProperty())
320      tgt.setPropertyElement(Uri30_50.convertUri(src.getPropertyElement()));
321    if (src.hasSystem())
322      tgt.setSystem(src.getSystem());
323    if (src.hasCode())
324      tgt.setValueElement(String30_50.convertString(src.getCodeElement()));
325    if (src.hasDisplay())
326      tgt.setDisplayElement(String30_50.convertString(src.getDisplayElement()));
327    return tgt;
328  }
329
330  public static org.hl7.fhir.dstu3.model.ConceptMap.OtherElementComponent convertOtherElementComponent(org.hl7.fhir.r5.model.ConceptMap.OtherElementComponent src) throws FHIRException {
331    if (src == null)
332      return null;
333    org.hl7.fhir.dstu3.model.ConceptMap.OtherElementComponent tgt = new org.hl7.fhir.dstu3.model.ConceptMap.OtherElementComponent();
334    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
335    if (src.hasProperty())
336      tgt.setPropertyElement(Uri30_50.convertUri(src.getPropertyElement()));
337    if (src.hasSystem())
338      tgt.setSystem(src.getSystem());
339    if (src.hasValue())
340      tgt.setCodeElement(String30_50.convertString(src.getValueElement()));
341    if (src.hasDisplay())
342      tgt.setDisplayElement(String30_50.convertString(src.getDisplayElement()));
343    return tgt;
344  }
345
346  public static org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent convertSourceElementComponent(org.hl7.fhir.r5.model.ConceptMap.SourceElementComponent src) throws FHIRException {
347    if (src == null)
348      return null;
349    org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent tgt = new org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent();
350    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
351    if (src.hasCode())
352      tgt.setCodeElement(Code30_50.convertCode(src.getCodeElement()));
353    if (src.hasDisplay())
354      tgt.setDisplayElement(String30_50.convertString(src.getDisplayElement()));
355    if (src.hasNoMap() && src.getNoMap() == true) {
356      tgt.addTarget(new org.hl7.fhir.dstu3.model.ConceptMap.TargetElementComponent().setEquivalence(org.hl7.fhir.dstu3.model.Enumerations.ConceptMapEquivalence.UNMATCHED));
357    } else {
358      for (org.hl7.fhir.r5.model.ConceptMap.TargetElementComponent t : src.getTarget())
359        tgt.addTarget(convertTargetElementComponent(t));
360    }
361    return tgt;
362  }
363
364  public static org.hl7.fhir.r5.model.ConceptMap.SourceElementComponent convertSourceElementComponent(org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent src) throws FHIRException {
365    if (src == null)
366      return null;
367    org.hl7.fhir.r5.model.ConceptMap.SourceElementComponent tgt = new org.hl7.fhir.r5.model.ConceptMap.SourceElementComponent();
368    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
369    if (src.hasCode())
370      tgt.setCodeElement(Code30_50.convertCode(src.getCodeElement()));
371    if (src.hasDisplay())
372      tgt.setDisplayElement(String30_50.convertString(src.getDisplayElement()));
373    for (org.hl7.fhir.dstu3.model.ConceptMap.TargetElementComponent t : src.getTarget())
374      if (t.getEquivalence() == org.hl7.fhir.dstu3.model.Enumerations.ConceptMapEquivalence.UNMATCHED) {
375        tgt.setNoMap(true);
376      } else {
377        tgt.addTarget(convertTargetElementComponent(t));
378      }
379    return tgt;
380  }
381
382  public static org.hl7.fhir.r5.model.ConceptMap.TargetElementComponent convertTargetElementComponent(org.hl7.fhir.dstu3.model.ConceptMap.TargetElementComponent src) throws FHIRException {
383    if (src == null)
384      return null;
385    org.hl7.fhir.r5.model.ConceptMap.TargetElementComponent tgt = new org.hl7.fhir.r5.model.ConceptMap.TargetElementComponent();
386    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
387    if (src.hasCode())
388      tgt.setCodeElement(Code30_50.convertCode(src.getCodeElement()));
389    if (src.hasDisplay())
390      tgt.setDisplayElement(String30_50.convertString(src.getDisplayElement()));
391    if (src.hasEquivalence())
392      tgt.setRelationshipElement(convertConceptMapRelationship(src.getEquivalenceElement()));
393    if (src.hasComment())
394      tgt.setCommentElement(String30_50.convertString(src.getCommentElement()));
395    for (org.hl7.fhir.dstu3.model.ConceptMap.OtherElementComponent t : src.getDependsOn())
396      tgt.addDependsOn(convertOtherElementComponent(t));
397    for (org.hl7.fhir.dstu3.model.ConceptMap.OtherElementComponent t : src.getProduct())
398      tgt.addProduct(convertOtherElementComponent(t));
399    return tgt;
400  }
401
402  public static org.hl7.fhir.dstu3.model.ConceptMap.TargetElementComponent convertTargetElementComponent(org.hl7.fhir.r5.model.ConceptMap.TargetElementComponent src) throws FHIRException {
403    if (src == null)
404      return null;
405    org.hl7.fhir.dstu3.model.ConceptMap.TargetElementComponent tgt = new org.hl7.fhir.dstu3.model.ConceptMap.TargetElementComponent();
406    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
407    if (src.hasCode())
408      tgt.setCodeElement(Code30_50.convertCode(src.getCodeElement()));
409    if (src.hasDisplay())
410      tgt.setDisplayElement(String30_50.convertString(src.getDisplayElement()));
411    if (src.hasRelationship())
412      tgt.setEquivalenceElement(convertConceptMapEquivalence(src.getRelationshipElement()));
413    if (src.hasComment())
414      tgt.setCommentElement(String30_50.convertString(src.getCommentElement()));
415    for (org.hl7.fhir.r5.model.ConceptMap.OtherElementComponent t : src.getDependsOn())
416      tgt.addDependsOn(convertOtherElementComponent(t));
417    for (org.hl7.fhir.r5.model.ConceptMap.OtherElementComponent t : src.getProduct())
418      tgt.addProduct(convertOtherElementComponent(t));
419    return tgt;
420  }
421}