001package org.hl7.fhir.convertors.conv40_50.resources40_50;
002
003import org.hl7.fhir.convertors.context.ConversionContext40_50;
004import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.CodeableConcept40_50;
005import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.Coding40_50;
006import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.Identifier40_50;
007import org.hl7.fhir.convertors.conv40_50.datatypes40_50.metadata40_50.ContactDetail40_50;
008import org.hl7.fhir.convertors.conv40_50.datatypes40_50.metadata40_50.UsageContext40_50;
009import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Boolean40_50;
010import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Canonical40_50;
011import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Code40_50;
012import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Date40_50;
013import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.DateTime40_50;
014import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Integer40_50;
015import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.MarkDown40_50;
016import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.String40_50;
017import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Uri40_50;
018import org.hl7.fhir.exceptions.FHIRException;
019import org.hl7.fhir.r5.model.ValueSet.ConceptPropertyComponent;
020import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionPropertyComponent;
021
022/*
023  Copyright (c) 2011+, HL7, Inc.
024  All rights reserved.
025  
026  Redistribution and use in source and binary forms, with or without modification, 
027  are permitted provided that the following conditions are met:
028  
029   * Redistributions of source code must retain the above copyright notice, this 
030     list of conditions and the following disclaimer.
031   * Redistributions in binary form must reproduce the above copyright notice, 
032     this list of conditions and the following disclaimer in the documentation 
033     and/or other materials provided with the distribution.
034   * Neither the name of HL7 nor the names of its contributors may be used to 
035     endorse or promote products derived from this software without specific 
036     prior written permission.
037  
038  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
039  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
040  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
041  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
042  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
043  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
044  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
045  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
046  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
047  POSSIBILITY OF SUCH DAMAGE.
048  
049*/
050// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0
051public class ValueSet40_50 {
052
053  public static org.hl7.fhir.r5.model.ValueSet convertValueSet(org.hl7.fhir.r4.model.ValueSet src) throws FHIRException {
054    if (src == null)
055      return null;
056    org.hl7.fhir.r5.model.ValueSet tgt = new org.hl7.fhir.r5.model.ValueSet();
057    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt);
058    if (src.hasUrl())
059      tgt.setUrlElement(Uri40_50.convertUri(src.getUrlElement()));
060    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
061      tgt.addIdentifier(Identifier40_50.convertIdentifier(t));
062    if (src.hasVersion())
063      tgt.setVersionElement(String40_50.convertString(src.getVersionElement()));
064    if (src.hasName())
065      tgt.setNameElement(String40_50.convertString(src.getNameElement()));
066    if (src.hasTitle())
067      tgt.setTitleElement(String40_50.convertString(src.getTitleElement()));
068    if (src.hasStatus())
069      tgt.setStatusElement(Enumerations40_50.convertPublicationStatus(src.getStatusElement()));
070    if (src.hasExperimental())
071      tgt.setExperimentalElement(Boolean40_50.convertBoolean(src.getExperimentalElement()));
072    if (src.hasDate())
073      tgt.setDateElement(DateTime40_50.convertDateTime(src.getDateElement()));
074    if (src.hasPublisher())
075      tgt.setPublisherElement(String40_50.convertString(src.getPublisherElement()));
076    for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact())
077      tgt.addContact(ContactDetail40_50.convertContactDetail(t));
078    if (src.hasDescription())
079      tgt.setDescriptionElement(MarkDown40_50.convertMarkdown(src.getDescriptionElement()));
080    for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext())
081      tgt.addUseContext(UsageContext40_50.convertUsageContext(t));
082    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction())
083      tgt.addJurisdiction(CodeableConcept40_50.convertCodeableConcept(t));
084    if (src.hasImmutable())
085      tgt.setImmutableElement(Boolean40_50.convertBoolean(src.getImmutableElement()));
086    if (src.hasPurpose())
087      tgt.setPurposeElement(MarkDown40_50.convertMarkdown(src.getPurposeElement()));
088    if (src.hasCopyright())
089      tgt.setCopyrightElement(MarkDown40_50.convertMarkdown(src.getCopyrightElement()));
090    if (src.hasCompose())
091      tgt.setCompose(convertValueSetComposeComponent(src.getCompose()));
092    if (src.hasExpansion())
093      tgt.setExpansion(convertValueSetExpansionComponent(src.getExpansion()));
094    return tgt;
095  }
096
097  public static org.hl7.fhir.r4.model.ValueSet convertValueSet(org.hl7.fhir.r5.model.ValueSet src) throws FHIRException {
098    if (src == null)
099      return null;
100    org.hl7.fhir.r4.model.ValueSet tgt = new org.hl7.fhir.r4.model.ValueSet();
101    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt);
102    if (src.hasUrl())
103      tgt.setUrlElement(Uri40_50.convertUri(src.getUrlElement()));
104    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
105      tgt.addIdentifier(Identifier40_50.convertIdentifier(t));
106    if (src.hasVersion())
107      tgt.setVersionElement(String40_50.convertString(src.getVersionElement()));
108    if (src.hasName())
109      tgt.setNameElement(String40_50.convertString(src.getNameElement()));
110    if (src.hasTitle())
111      tgt.setTitleElement(String40_50.convertString(src.getTitleElement()));
112    if (src.hasStatus())
113      tgt.setStatusElement(Enumerations40_50.convertPublicationStatus(src.getStatusElement()));
114    if (src.hasExperimental())
115      tgt.setExperimentalElement(Boolean40_50.convertBoolean(src.getExperimentalElement()));
116    if (src.hasDate())
117      tgt.setDateElement(DateTime40_50.convertDateTime(src.getDateElement()));
118    if (src.hasPublisher())
119      tgt.setPublisherElement(String40_50.convertString(src.getPublisherElement()));
120    for (org.hl7.fhir.r5.model.ContactDetail t : src.getContact())
121      tgt.addContact(ContactDetail40_50.convertContactDetail(t));
122    if (src.hasDescription())
123      tgt.setDescriptionElement(MarkDown40_50.convertMarkdown(src.getDescriptionElement()));
124    for (org.hl7.fhir.r5.model.UsageContext t : src.getUseContext())
125      tgt.addUseContext(UsageContext40_50.convertUsageContext(t));
126    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getJurisdiction())
127      tgt.addJurisdiction(CodeableConcept40_50.convertCodeableConcept(t));
128    if (src.hasImmutable())
129      tgt.setImmutableElement(Boolean40_50.convertBoolean(src.getImmutableElement()));
130    if (src.hasPurpose())
131      tgt.setPurposeElement(MarkDown40_50.convertMarkdown(src.getPurposeElement()));
132    if (src.hasCopyright())
133      tgt.setCopyrightElement(MarkDown40_50.convertMarkdown(src.getCopyrightElement()));
134    if (src.hasCompose())
135      tgt.setCompose(convertValueSetComposeComponent(src.getCompose()));
136    if (src.hasExpansion())
137      tgt.setExpansion(convertValueSetExpansionComponent(src.getExpansion()));
138    return tgt;
139  }
140
141  public static org.hl7.fhir.r5.model.ValueSet.ValueSetComposeComponent convertValueSetComposeComponent(org.hl7.fhir.r4.model.ValueSet.ValueSetComposeComponent src) throws FHIRException {
142    if (src == null)
143      return null;
144    org.hl7.fhir.r5.model.ValueSet.ValueSetComposeComponent tgt = new org.hl7.fhir.r5.model.ValueSet.ValueSetComposeComponent();
145    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
146    if (src.hasLockedDate())
147      tgt.setLockedDateElement(Date40_50.convertDate(src.getLockedDateElement()));
148    if (src.hasInactive())
149      tgt.setInactiveElement(Boolean40_50.convertBoolean(src.getInactiveElement()));
150    for (org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent t : src.getInclude())
151      tgt.addInclude(convertConceptSetComponent(t));
152    for (org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent t : src.getExclude())
153      tgt.addExclude(convertConceptSetComponent(t));
154    return tgt;
155  }
156
157  public static org.hl7.fhir.r4.model.ValueSet.ValueSetComposeComponent convertValueSetComposeComponent(org.hl7.fhir.r5.model.ValueSet.ValueSetComposeComponent src) throws FHIRException {
158    if (src == null)
159      return null;
160    org.hl7.fhir.r4.model.ValueSet.ValueSetComposeComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ValueSetComposeComponent();
161    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
162    if (src.hasLockedDate())
163      tgt.setLockedDateElement(Date40_50.convertDate(src.getLockedDateElement()));
164    if (src.hasInactive())
165      tgt.setInactiveElement(Boolean40_50.convertBoolean(src.getInactiveElement()));
166    for (org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent t : src.getInclude())
167      tgt.addInclude(convertConceptSetComponent(t));
168    for (org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent t : src.getExclude())
169      tgt.addExclude(convertConceptSetComponent(t));
170    return tgt;
171  }
172
173  public static org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent convertConceptSetComponent(org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent src) throws FHIRException {
174    if (src == null)
175      return null;
176    org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent tgt = new org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent();
177    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
178    if (src.hasSystem())
179      tgt.setSystemElement(Uri40_50.convertUri(src.getSystemElement()));
180    if (src.hasVersion())
181      tgt.setVersionElement(String40_50.convertString(src.getVersionElement()));
182    for (org.hl7.fhir.r4.model.ValueSet.ConceptReferenceComponent t : src.getConcept())
183      tgt.addConcept(convertConceptReferenceComponent(t));
184    for (org.hl7.fhir.r4.model.ValueSet.ConceptSetFilterComponent t : src.getFilter())
185      tgt.addFilter(convertConceptSetFilterComponent(t));
186    for (org.hl7.fhir.r4.model.CanonicalType t : src.getValueSet())
187      tgt.getValueSet().add(Canonical40_50.convertCanonical(t));
188    return tgt;
189  }
190
191  public static org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent convertConceptSetComponent(org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent src) throws FHIRException {
192    if (src == null)
193      return null;
194    org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent();
195    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
196    if (src.hasSystem())
197      tgt.setSystemElement(Uri40_50.convertUri(src.getSystemElement()));
198    if (src.hasVersion())
199      tgt.setVersionElement(String40_50.convertString(src.getVersionElement()));
200    for (org.hl7.fhir.r5.model.ValueSet.ConceptReferenceComponent t : src.getConcept())
201      tgt.addConcept(convertConceptReferenceComponent(t));
202    for (org.hl7.fhir.r5.model.ValueSet.ConceptSetFilterComponent t : src.getFilter())
203      tgt.addFilter(convertConceptSetFilterComponent(t));
204    for (org.hl7.fhir.r5.model.CanonicalType t : src.getValueSet())
205      tgt.getValueSet().add(Canonical40_50.convertCanonical(t));
206    return tgt;
207  }
208
209  public static org.hl7.fhir.r5.model.ValueSet.ConceptReferenceComponent convertConceptReferenceComponent(org.hl7.fhir.r4.model.ValueSet.ConceptReferenceComponent src) throws FHIRException {
210    if (src == null)
211      return null;
212    org.hl7.fhir.r5.model.ValueSet.ConceptReferenceComponent tgt = new org.hl7.fhir.r5.model.ValueSet.ConceptReferenceComponent();
213    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
214    if (src.hasCode())
215      tgt.setCodeElement(Code40_50.convertCode(src.getCodeElement()));
216    if (src.hasDisplay())
217      tgt.setDisplayElement(String40_50.convertString(src.getDisplayElement()));
218    for (org.hl7.fhir.r4.model.ValueSet.ConceptReferenceDesignationComponent t : src.getDesignation())
219      tgt.addDesignation(convertConceptReferenceDesignationComponent(t));
220    return tgt;
221  }
222
223  public static org.hl7.fhir.r4.model.ValueSet.ConceptReferenceComponent convertConceptReferenceComponent(org.hl7.fhir.r5.model.ValueSet.ConceptReferenceComponent src) throws FHIRException {
224    if (src == null)
225      return null;
226    org.hl7.fhir.r4.model.ValueSet.ConceptReferenceComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ConceptReferenceComponent();
227    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
228    if (src.hasCode())
229      tgt.setCodeElement(Code40_50.convertCode(src.getCodeElement()));
230    if (src.hasDisplay())
231      tgt.setDisplayElement(String40_50.convertString(src.getDisplayElement()));
232    for (org.hl7.fhir.r5.model.ValueSet.ConceptReferenceDesignationComponent t : src.getDesignation())
233      tgt.addDesignation(convertConceptReferenceDesignationComponent(t));
234    return tgt;
235  }
236
237  public static org.hl7.fhir.r5.model.ValueSet.ConceptReferenceDesignationComponent convertConceptReferenceDesignationComponent(org.hl7.fhir.r4.model.ValueSet.ConceptReferenceDesignationComponent src) throws FHIRException {
238    if (src == null)
239      return null;
240    org.hl7.fhir.r5.model.ValueSet.ConceptReferenceDesignationComponent tgt = new org.hl7.fhir.r5.model.ValueSet.ConceptReferenceDesignationComponent();
241    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
242    if (src.hasLanguage())
243      tgt.setLanguageElement(Code40_50.convertCode(src.getLanguageElement()));
244    if (src.hasUse())
245      tgt.setUse(Coding40_50.convertCoding(src.getUse()));
246    if (src.hasValue())
247      tgt.setValueElement(String40_50.convertString(src.getValueElement()));
248    return tgt;
249  }
250
251  public static org.hl7.fhir.r4.model.ValueSet.ConceptReferenceDesignationComponent convertConceptReferenceDesignationComponent(org.hl7.fhir.r5.model.ValueSet.ConceptReferenceDesignationComponent src) throws FHIRException {
252    if (src == null)
253      return null;
254    org.hl7.fhir.r4.model.ValueSet.ConceptReferenceDesignationComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ConceptReferenceDesignationComponent();
255    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
256    if (src.hasLanguage())
257      tgt.setLanguageElement(Code40_50.convertCode(src.getLanguageElement()));
258    if (src.hasUse())
259      tgt.setUse(Coding40_50.convertCoding(src.getUse()));
260    if (src.hasValue())
261      tgt.setValueElement(String40_50.convertString(src.getValueElement()));
262    return tgt;
263  }
264
265  public static org.hl7.fhir.r5.model.ValueSet.ConceptSetFilterComponent convertConceptSetFilterComponent(org.hl7.fhir.r4.model.ValueSet.ConceptSetFilterComponent src) throws FHIRException {
266    if (src == null)
267      return null;
268    org.hl7.fhir.r5.model.ValueSet.ConceptSetFilterComponent tgt = new org.hl7.fhir.r5.model.ValueSet.ConceptSetFilterComponent();
269    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
270    if (src.hasProperty())
271      tgt.setPropertyElement(Code40_50.convertCode(src.getPropertyElement()));
272    if (src.hasOp())
273      tgt.setOpElement(convertFilterOperator(src.getOpElement()));
274    if (src.hasValue())
275      tgt.setValueElement(String40_50.convertString(src.getValueElement()));
276    return tgt;
277  }
278
279  public static org.hl7.fhir.r4.model.ValueSet.ConceptSetFilterComponent convertConceptSetFilterComponent(org.hl7.fhir.r5.model.ValueSet.ConceptSetFilterComponent src) throws FHIRException {
280    if (src == null)
281      return null;
282    org.hl7.fhir.r4.model.ValueSet.ConceptSetFilterComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ConceptSetFilterComponent();
283    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
284    if (src.hasProperty())
285      tgt.setPropertyElement(Code40_50.convertCode(src.getPropertyElement()));
286    if (src.hasOp())
287      tgt.setOpElement(convertFilterOperator(src.getOpElement()));
288    if (src.hasValue())
289      tgt.setValueElement(String40_50.convertString(src.getValueElement()));
290    return tgt;
291  }
292
293  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.FilterOperator> convertFilterOperator(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ValueSet.FilterOperator> src) throws FHIRException {
294    if (src == null || src.isEmpty())
295      return null;
296    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.FilterOperator> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.FilterOperatorEnumFactory());
297    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
298    switch (src.getValue()) {
299      case EQUAL:
300        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FilterOperator.EQUAL);
301        break;
302      case ISA:
303        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FilterOperator.ISA);
304        break;
305      case DESCENDENTOF:
306        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FilterOperator.DESCENDENTOF);
307        break;
308      case ISNOTA:
309        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FilterOperator.ISNOTA);
310        break;
311      case REGEX:
312        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FilterOperator.REGEX);
313        break;
314      case IN:
315        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FilterOperator.IN);
316        break;
317      case NOTIN:
318        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FilterOperator.NOTIN);
319        break;
320      case GENERALIZES:
321        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FilterOperator.GENERALIZES);
322        break;
323      case EXISTS:
324        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FilterOperator.EXISTS);
325        break;
326      default:
327        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FilterOperator.NULL);
328        break;
329    }
330    return tgt;
331  }
332
333  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ValueSet.FilterOperator> convertFilterOperator(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.FilterOperator> src) throws FHIRException {
334    if (src == null || src.isEmpty())
335      return null;
336    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ValueSet.FilterOperator> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ValueSet.FilterOperatorEnumFactory());
337    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
338    switch (src.getValue()) {
339      case EQUAL:
340        tgt.setValue(org.hl7.fhir.r4.model.ValueSet.FilterOperator.EQUAL);
341        break;
342      case ISA:
343        tgt.setValue(org.hl7.fhir.r4.model.ValueSet.FilterOperator.ISA);
344        break;
345      case DESCENDENTOF:
346        tgt.setValue(org.hl7.fhir.r4.model.ValueSet.FilterOperator.DESCENDENTOF);
347        break;
348      case ISNOTA:
349        tgt.setValue(org.hl7.fhir.r4.model.ValueSet.FilterOperator.ISNOTA);
350        break;
351      case REGEX:
352        tgt.setValue(org.hl7.fhir.r4.model.ValueSet.FilterOperator.REGEX);
353        break;
354      case IN:
355        tgt.setValue(org.hl7.fhir.r4.model.ValueSet.FilterOperator.IN);
356        break;
357      case NOTIN:
358        tgt.setValue(org.hl7.fhir.r4.model.ValueSet.FilterOperator.NOTIN);
359        break;
360      case GENERALIZES:
361        tgt.setValue(org.hl7.fhir.r4.model.ValueSet.FilterOperator.GENERALIZES);
362        break;
363      case EXISTS:
364        tgt.setValue(org.hl7.fhir.r4.model.ValueSet.FilterOperator.EXISTS);
365        break;
366      default:
367        tgt.setValue(org.hl7.fhir.r4.model.ValueSet.FilterOperator.NULL);
368        break;
369    }
370    return tgt;
371  }
372
373  public static org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionComponent convertValueSetExpansionComponent(org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionComponent src) throws FHIRException {
374    if (src == null)
375      return null;
376    org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionComponent tgt = new org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionComponent();
377    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt, "http://hl7.org/fhir/5.0/StructureDefinition/extension-ValueSet.expansion.property");
378    if (src.hasIdentifier())
379      tgt.setIdentifierElement(Uri40_50.convertUri(src.getIdentifierElement()));
380    if (src.hasTimestamp())
381      tgt.setTimestampElement(DateTime40_50.convertDateTime(src.getTimestampElement()));
382    if (src.hasTotal())
383      tgt.setTotalElement(Integer40_50.convertInteger(src.getTotalElement()));
384    if (src.hasOffset())
385      tgt.setOffsetElement(Integer40_50.convertInteger(src.getOffsetElement()));
386    for (org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionParameterComponent t : src.getParameter())
387      tgt.addParameter(convertValueSetExpansionParameterComponent(t));
388    for (org.hl7.fhir.r4.model.Extension t : src.getExtension()) {
389      if ("http://hl7.org/fhir/5.0/StructureDefinition/extension-ValueSet.expansion.property".equals(t.getUrl())) {
390        tgt.addProperty().setCode(t.getExtensionString("code")).setUri(t.getExtensionString("uri"));
391      }
392    }
393    for (org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent t : src.getContains())
394      tgt.addContains(convertValueSetExpansionContainsComponent(t));
395    return tgt;
396  }
397
398  public static org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionComponent convertValueSetExpansionComponent(org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionComponent src) throws FHIRException {
399    if (src == null)
400      return null;
401    org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionComponent();
402    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
403    if (src.hasIdentifier())
404      tgt.setIdentifierElement(Uri40_50.convertUri(src.getIdentifierElement()));
405    if (src.hasTimestamp())
406      tgt.setTimestampElement(DateTime40_50.convertDateTime(src.getTimestampElement()));
407    if (src.hasTotal())
408      tgt.setTotalElement(Integer40_50.convertInteger(src.getTotalElement()));
409    if (src.hasOffset())
410      tgt.setOffsetElement(Integer40_50.convertInteger(src.getOffsetElement()));
411    for (org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionParameterComponent t : src.getParameter())
412      tgt.addParameter(convertValueSetExpansionParameterComponent(t));
413    for (ValueSetExpansionPropertyComponent t : src.getProperty()) {
414      org.hl7.fhir.r4.model.Extension ext = tgt.addExtension().setUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ValueSet.expansion.property");
415      ext.addExtension().setUrl("code").setValue(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(t.getCodeElement()));
416      ext.addExtension().setUrl("uri").setValue(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(t.getUriElement()));
417    }
418    for (org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent t : src.getContains())
419      tgt.addContains(convertValueSetExpansionContainsComponent(t));
420    return tgt;
421  }
422
423  public static org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionParameterComponent convertValueSetExpansionParameterComponent(org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionParameterComponent src) throws FHIRException {
424    if (src == null)
425      return null;
426    org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionParameterComponent tgt = new org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionParameterComponent();
427    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
428    if (src.hasName())
429      tgt.setNameElement(String40_50.convertString(src.getNameElement()));
430    if (src.hasValue())
431      tgt.setValue(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getValue()));
432    return tgt;
433  }
434
435  public static org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionParameterComponent convertValueSetExpansionParameterComponent(org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionParameterComponent src) throws FHIRException {
436    if (src == null)
437      return null;
438    org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionParameterComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionParameterComponent();
439    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
440    if (src.hasName())
441      tgt.setNameElement(String40_50.convertString(src.getNameElement()));
442    if (src.hasValue())
443      tgt.setValue(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getValue()));
444    return tgt;
445  }
446
447  public static org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent convertValueSetExpansionContainsComponent(org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent src) throws FHIRException {
448    if (src == null)
449      return null;
450    org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent tgt = new org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent();
451    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt, "http://hl7.org/fhir/5.0/StructureDefinition/extension-ValueSet.expansion.contains.property");
452    if (src.hasSystem())
453      tgt.setSystemElement(Uri40_50.convertUri(src.getSystemElement()));
454    if (src.hasAbstract())
455      tgt.setAbstractElement(Boolean40_50.convertBoolean(src.getAbstractElement()));
456    if (src.hasInactive())
457      tgt.setInactiveElement(Boolean40_50.convertBoolean(src.getInactiveElement()));
458    if (src.hasVersion())
459      tgt.setVersionElement(String40_50.convertString(src.getVersionElement()));
460    if (src.hasCode())
461      tgt.setCodeElement(Code40_50.convertCode(src.getCodeElement()));
462    if (src.hasDisplay())
463      tgt.setDisplayElement(String40_50.convertString(src.getDisplayElement()));
464    for (org.hl7.fhir.r4.model.ValueSet.ConceptReferenceDesignationComponent t : src.getDesignation())
465      tgt.addDesignation(convertConceptReferenceDesignationComponent(t));
466    for (org.hl7.fhir.r4.model.Extension t : src.getExtension()) {
467      if ("http://hl7.org/fhir/5.0/StructureDefinition/extension-ValueSet.expansion.contains.property".equals(t.getUrl())) {
468        ConceptPropertyComponent prop = tgt.addProperty();
469        ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(t, prop, "code", "value");        
470        prop.setCode(t.getExtensionString("code"));
471        prop.setValue(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(t.getExtensionByUrl("value").getValue()));
472          
473      }
474    }
475    for (org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent t : src.getContains())
476      tgt.addContains(convertValueSetExpansionContainsComponent(t));
477    return tgt;
478  }
479
480  public static org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent convertValueSetExpansionContainsComponent(org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent src) throws FHIRException {
481    if (src == null)
482      return null;
483    org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent tgt = new org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent();
484    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
485    if (src.hasSystem())
486      tgt.setSystemElement(Uri40_50.convertUri(src.getSystemElement()));
487    if (src.hasAbstract())
488      tgt.setAbstractElement(Boolean40_50.convertBoolean(src.getAbstractElement()));
489    if (src.hasInactive())
490      tgt.setInactiveElement(Boolean40_50.convertBoolean(src.getInactiveElement()));
491    if (src.hasVersion())
492      tgt.setVersionElement(String40_50.convertString(src.getVersionElement()));
493    if (src.hasCode())
494      tgt.setCodeElement(Code40_50.convertCode(src.getCodeElement()));
495    if (src.hasDisplay())
496      tgt.setDisplayElement(String40_50.convertString(src.getDisplayElement()));
497    for (org.hl7.fhir.r5.model.ValueSet.ConceptReferenceDesignationComponent t : src.getDesignation())
498      tgt.addDesignation(convertConceptReferenceDesignationComponent(t));
499    for (org.hl7.fhir.r5.model.ValueSet.ConceptPropertyComponent t : src.getProperty()) {
500      org.hl7.fhir.r4.model.Extension ext = tgt.addExtension().setUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-ValueSet.expansion.contains.property");
501      ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(t, ext, "code", "value");
502      ext.addExtension().setUrl("code").setValue(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(t.getCodeElement()));
503      ext.addExtension().setUrl("value").setValue(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(t.getValue()));
504    }
505    for (org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent t : src.getContains())
506      tgt.addContains(convertValueSetExpansionContainsComponent(t));
507    return tgt;
508  }
509}