001package org.hl7.fhir.convertors.conv43_50.resources43_50;
002
003import org.hl7.fhir.convertors.context.ConversionContext43_50;
004import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.CodeableConcept43_50;
005import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Duration43_50;
006import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Identifier43_50;
007import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Range43_50;
008import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.SimpleQuantity43_50;
009import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Boolean43_50;
010import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.String43_50;
011import org.hl7.fhir.exceptions.FHIRException;
012
013/*
014  Copyright (c) 2011+, HL7, Inc.
015  All rights reserved.
016  
017  Redistribution and use in source and binary forms, with or without modification, 
018  are permitted provided that the following conditions are met:
019  
020   * Redistributions of source code must retain the above copyright notice, this 
021     list of conditions and the following disclaimer.
022   * Redistributions in binary form must reproduce the above copyright notice, 
023     this list of conditions and the following disclaimer in the documentation 
024     and/or other materials provided with the distribution.
025   * Neither the name of HL7 nor the names of its contributors may be used to 
026     endorse or promote products derived from this software without specific 
027     prior written permission.
028  
029  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
030  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
031  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
032  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
033  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
034  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
035  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
036  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
037  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
038  POSSIBILITY OF SUCH DAMAGE.
039  
040*/
041// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0
042public class SpecimenDefinition43_50 {
043
044  public static org.hl7.fhir.r5.model.SpecimenDefinition convertSpecimenDefinition(org.hl7.fhir.r4b.model.SpecimenDefinition src) throws FHIRException {
045    if (src == null)
046      return null;
047    org.hl7.fhir.r5.model.SpecimenDefinition tgt = new org.hl7.fhir.r5.model.SpecimenDefinition();
048    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt);
049    if (src.hasIdentifier())
050      tgt.setIdentifier(Identifier43_50.convertIdentifier(src.getIdentifier()));
051    if (src.hasTypeCollected())
052      tgt.setTypeCollected(CodeableConcept43_50.convertCodeableConcept(src.getTypeCollected()));
053    for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getPatientPreparation())
054      tgt.addPatientPreparation(CodeableConcept43_50.convertCodeableConcept(t));
055    if (src.hasTimeAspect())
056      tgt.setTimeAspectElement(String43_50.convertString(src.getTimeAspectElement()));
057    for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getCollection())
058      tgt.addCollection(CodeableConcept43_50.convertCodeableConcept(t));
059    for (org.hl7.fhir.r4b.model.SpecimenDefinition.SpecimenDefinitionTypeTestedComponent t : src.getTypeTested())
060      tgt.addTypeTested(convertSpecimenDefinitionTypeTestedComponent(t));
061    return tgt;
062  }
063
064  public static org.hl7.fhir.r4b.model.SpecimenDefinition convertSpecimenDefinition(org.hl7.fhir.r5.model.SpecimenDefinition src) throws FHIRException {
065    if (src == null)
066      return null;
067    org.hl7.fhir.r4b.model.SpecimenDefinition tgt = new org.hl7.fhir.r4b.model.SpecimenDefinition();
068    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt);
069    if (src.hasIdentifier())
070      tgt.setIdentifier(Identifier43_50.convertIdentifier(src.getIdentifier()));
071    if (src.hasTypeCollected())
072      tgt.setTypeCollected(CodeableConcept43_50.convertCodeableConcept(src.getTypeCollected()));
073    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getPatientPreparation())
074      tgt.addPatientPreparation(CodeableConcept43_50.convertCodeableConcept(t));
075    if (src.hasTimeAspect())
076      tgt.setTimeAspectElement(String43_50.convertString(src.getTimeAspectElement()));
077    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getCollection())
078      tgt.addCollection(CodeableConcept43_50.convertCodeableConcept(t));
079    for (org.hl7.fhir.r5.model.SpecimenDefinition.SpecimenDefinitionTypeTestedComponent t : src.getTypeTested())
080      tgt.addTypeTested(convertSpecimenDefinitionTypeTestedComponent(t));
081    return tgt;
082  }
083
084  public static org.hl7.fhir.r5.model.SpecimenDefinition.SpecimenDefinitionTypeTestedComponent convertSpecimenDefinitionTypeTestedComponent(org.hl7.fhir.r4b.model.SpecimenDefinition.SpecimenDefinitionTypeTestedComponent src) throws FHIRException {
085    if (src == null)
086      return null;
087    org.hl7.fhir.r5.model.SpecimenDefinition.SpecimenDefinitionTypeTestedComponent tgt = new org.hl7.fhir.r5.model.SpecimenDefinition.SpecimenDefinitionTypeTestedComponent();
088    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
089    if (src.hasIsDerived())
090      tgt.setIsDerivedElement(Boolean43_50.convertBoolean(src.getIsDerivedElement()));
091    if (src.hasType())
092      tgt.setType(CodeableConcept43_50.convertCodeableConcept(src.getType()));
093    if (src.hasPreference())
094      tgt.setPreferenceElement(convertSpecimenContainedPreference(src.getPreferenceElement()));
095    if (src.hasContainer())
096      tgt.setContainer(convertSpecimenDefinitionTypeTestedContainerComponent(src.getContainer()));
097    if (src.hasRequirement())
098      tgt.setRequirementElement(String43_50.convertStringToMarkdown(src.getRequirementElement()));
099    if (src.hasRetentionTime())
100      tgt.setRetentionTime(Duration43_50.convertDuration(src.getRetentionTime()));
101    for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getRejectionCriterion())
102      tgt.addRejectionCriterion(CodeableConcept43_50.convertCodeableConcept(t));
103    for (org.hl7.fhir.r4b.model.SpecimenDefinition.SpecimenDefinitionTypeTestedHandlingComponent t : src.getHandling())
104      tgt.addHandling(convertSpecimenDefinitionTypeTestedHandlingComponent(t));
105    return tgt;
106  }
107
108  public static org.hl7.fhir.r4b.model.SpecimenDefinition.SpecimenDefinitionTypeTestedComponent convertSpecimenDefinitionTypeTestedComponent(org.hl7.fhir.r5.model.SpecimenDefinition.SpecimenDefinitionTypeTestedComponent src) throws FHIRException {
109    if (src == null)
110      return null;
111    org.hl7.fhir.r4b.model.SpecimenDefinition.SpecimenDefinitionTypeTestedComponent tgt = new org.hl7.fhir.r4b.model.SpecimenDefinition.SpecimenDefinitionTypeTestedComponent();
112    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
113    if (src.hasIsDerived())
114      tgt.setIsDerivedElement(Boolean43_50.convertBoolean(src.getIsDerivedElement()));
115    if (src.hasType())
116      tgt.setType(CodeableConcept43_50.convertCodeableConcept(src.getType()));
117    if (src.hasPreference())
118      tgt.setPreferenceElement(convertSpecimenContainedPreference(src.getPreferenceElement()));
119    if (src.hasContainer())
120      tgt.setContainer(convertSpecimenDefinitionTypeTestedContainerComponent(src.getContainer()));
121    if (src.hasRequirement())
122      tgt.setRequirementElement(String43_50.convertString(src.getRequirementElement()));
123    if (src.hasRetentionTime())
124      tgt.setRetentionTime(Duration43_50.convertDuration(src.getRetentionTime()));
125    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getRejectionCriterion())
126      tgt.addRejectionCriterion(CodeableConcept43_50.convertCodeableConcept(t));
127    for (org.hl7.fhir.r5.model.SpecimenDefinition.SpecimenDefinitionTypeTestedHandlingComponent t : src.getHandling())
128      tgt.addHandling(convertSpecimenDefinitionTypeTestedHandlingComponent(t));
129    return tgt;
130  }
131
132  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.SpecimenDefinition.SpecimenContainedPreference> convertSpecimenContainedPreference(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.SpecimenDefinition.SpecimenContainedPreference> src) throws FHIRException {
133    if (src == null || src.isEmpty())
134      return null;
135    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.SpecimenDefinition.SpecimenContainedPreference> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.SpecimenDefinition.SpecimenContainedPreferenceEnumFactory());
136    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
137    switch (src.getValue()) {
138      case PREFERRED:
139        tgt.setValue(org.hl7.fhir.r5.model.SpecimenDefinition.SpecimenContainedPreference.PREFERRED);
140        break;
141      case ALTERNATE:
142        tgt.setValue(org.hl7.fhir.r5.model.SpecimenDefinition.SpecimenContainedPreference.ALTERNATE);
143        break;
144      default:
145        tgt.setValue(org.hl7.fhir.r5.model.SpecimenDefinition.SpecimenContainedPreference.NULL);
146        break;
147    }
148    return tgt;
149  }
150
151  static public org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.SpecimenDefinition.SpecimenContainedPreference> convertSpecimenContainedPreference(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.SpecimenDefinition.SpecimenContainedPreference> src) throws FHIRException {
152    if (src == null || src.isEmpty())
153      return null;
154    org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.SpecimenDefinition.SpecimenContainedPreference> tgt = new org.hl7.fhir.r4b.model.Enumeration<>(new org.hl7.fhir.r4b.model.SpecimenDefinition.SpecimenContainedPreferenceEnumFactory());
155    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
156    switch (src.getValue()) {
157      case PREFERRED:
158        tgt.setValue(org.hl7.fhir.r4b.model.SpecimenDefinition.SpecimenContainedPreference.PREFERRED);
159        break;
160      case ALTERNATE:
161        tgt.setValue(org.hl7.fhir.r4b.model.SpecimenDefinition.SpecimenContainedPreference.ALTERNATE);
162        break;
163      default:
164        tgt.setValue(org.hl7.fhir.r4b.model.SpecimenDefinition.SpecimenContainedPreference.NULL);
165        break;
166    }
167    return tgt;
168  }
169
170  public static org.hl7.fhir.r5.model.SpecimenDefinition.SpecimenDefinitionTypeTestedContainerComponent convertSpecimenDefinitionTypeTestedContainerComponent(org.hl7.fhir.r4b.model.SpecimenDefinition.SpecimenDefinitionTypeTestedContainerComponent src) throws FHIRException {
171    if (src == null)
172      return null;
173    org.hl7.fhir.r5.model.SpecimenDefinition.SpecimenDefinitionTypeTestedContainerComponent tgt = new org.hl7.fhir.r5.model.SpecimenDefinition.SpecimenDefinitionTypeTestedContainerComponent();
174    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
175    if (src.hasMaterial())
176      tgt.setMaterial(CodeableConcept43_50.convertCodeableConcept(src.getMaterial()));
177    if (src.hasType())
178      tgt.setType(CodeableConcept43_50.convertCodeableConcept(src.getType()));
179    if (src.hasCap())
180      tgt.setCap(CodeableConcept43_50.convertCodeableConcept(src.getCap()));
181    if (src.hasDescription())
182      tgt.setDescriptionElement(String43_50.convertStringToMarkdown(src.getDescriptionElement()));
183    if (src.hasCapacity())
184      tgt.setCapacity(SimpleQuantity43_50.convertSimpleQuantity(src.getCapacity()));
185    if (src.hasMinimumVolume())
186      tgt.setMinimumVolume(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getMinimumVolume()));
187    for (org.hl7.fhir.r4b.model.SpecimenDefinition.SpecimenDefinitionTypeTestedContainerAdditiveComponent t : src.getAdditive())
188      tgt.addAdditive(convertSpecimenDefinitionTypeTestedContainerAdditiveComponent(t));
189    if (src.hasPreparation())
190      tgt.setPreparationElement(String43_50.convertStringToMarkdown(src.getPreparationElement()));
191    return tgt;
192  }
193
194  public static org.hl7.fhir.r4b.model.SpecimenDefinition.SpecimenDefinitionTypeTestedContainerComponent convertSpecimenDefinitionTypeTestedContainerComponent(org.hl7.fhir.r5.model.SpecimenDefinition.SpecimenDefinitionTypeTestedContainerComponent src) throws FHIRException {
195    if (src == null)
196      return null;
197    org.hl7.fhir.r4b.model.SpecimenDefinition.SpecimenDefinitionTypeTestedContainerComponent tgt = new org.hl7.fhir.r4b.model.SpecimenDefinition.SpecimenDefinitionTypeTestedContainerComponent();
198    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
199    if (src.hasMaterial())
200      tgt.setMaterial(CodeableConcept43_50.convertCodeableConcept(src.getMaterial()));
201    if (src.hasType())
202      tgt.setType(CodeableConcept43_50.convertCodeableConcept(src.getType()));
203    if (src.hasCap())
204      tgt.setCap(CodeableConcept43_50.convertCodeableConcept(src.getCap()));
205    if (src.hasDescription())
206      tgt.setDescriptionElement(String43_50.convertString(src.getDescriptionElement()));
207    if (src.hasCapacity())
208      tgt.setCapacity(SimpleQuantity43_50.convertSimpleQuantity(src.getCapacity()));
209    if (src.hasMinimumVolume())
210      tgt.setMinimumVolume(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getMinimumVolume()));
211    for (org.hl7.fhir.r5.model.SpecimenDefinition.SpecimenDefinitionTypeTestedContainerAdditiveComponent t : src.getAdditive())
212      tgt.addAdditive(convertSpecimenDefinitionTypeTestedContainerAdditiveComponent(t));
213    if (src.hasPreparation())
214      tgt.setPreparationElement(String43_50.convertString(src.getPreparationElement()));
215    return tgt;
216  }
217
218  public static org.hl7.fhir.r5.model.SpecimenDefinition.SpecimenDefinitionTypeTestedContainerAdditiveComponent convertSpecimenDefinitionTypeTestedContainerAdditiveComponent(org.hl7.fhir.r4b.model.SpecimenDefinition.SpecimenDefinitionTypeTestedContainerAdditiveComponent src) throws FHIRException {
219    if (src == null)
220      return null;
221    org.hl7.fhir.r5.model.SpecimenDefinition.SpecimenDefinitionTypeTestedContainerAdditiveComponent tgt = new org.hl7.fhir.r5.model.SpecimenDefinition.SpecimenDefinitionTypeTestedContainerAdditiveComponent();
222    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
223    if (src.hasAdditive())
224      tgt.setAdditive(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getAdditive()));
225    return tgt;
226  }
227
228  public static org.hl7.fhir.r4b.model.SpecimenDefinition.SpecimenDefinitionTypeTestedContainerAdditiveComponent convertSpecimenDefinitionTypeTestedContainerAdditiveComponent(org.hl7.fhir.r5.model.SpecimenDefinition.SpecimenDefinitionTypeTestedContainerAdditiveComponent src) throws FHIRException {
229    if (src == null)
230      return null;
231    org.hl7.fhir.r4b.model.SpecimenDefinition.SpecimenDefinitionTypeTestedContainerAdditiveComponent tgt = new org.hl7.fhir.r4b.model.SpecimenDefinition.SpecimenDefinitionTypeTestedContainerAdditiveComponent();
232    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
233    if (src.hasAdditive())
234      tgt.setAdditive(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getAdditive()));
235    return tgt;
236  }
237
238  public static org.hl7.fhir.r5.model.SpecimenDefinition.SpecimenDefinitionTypeTestedHandlingComponent convertSpecimenDefinitionTypeTestedHandlingComponent(org.hl7.fhir.r4b.model.SpecimenDefinition.SpecimenDefinitionTypeTestedHandlingComponent src) throws FHIRException {
239    if (src == null)
240      return null;
241    org.hl7.fhir.r5.model.SpecimenDefinition.SpecimenDefinitionTypeTestedHandlingComponent tgt = new org.hl7.fhir.r5.model.SpecimenDefinition.SpecimenDefinitionTypeTestedHandlingComponent();
242    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
243    if (src.hasTemperatureQualifier())
244      tgt.setTemperatureQualifier(CodeableConcept43_50.convertCodeableConcept(src.getTemperatureQualifier()));
245    if (src.hasTemperatureRange())
246      tgt.setTemperatureRange(Range43_50.convertRange(src.getTemperatureRange()));
247    if (src.hasMaxDuration())
248      tgt.setMaxDuration(Duration43_50.convertDuration(src.getMaxDuration()));
249    if (src.hasInstruction())
250      tgt.setInstructionElement(String43_50.convertStringToMarkdown(src.getInstructionElement()));
251    return tgt;
252  }
253
254  public static org.hl7.fhir.r4b.model.SpecimenDefinition.SpecimenDefinitionTypeTestedHandlingComponent convertSpecimenDefinitionTypeTestedHandlingComponent(org.hl7.fhir.r5.model.SpecimenDefinition.SpecimenDefinitionTypeTestedHandlingComponent src) throws FHIRException {
255    if (src == null)
256      return null;
257    org.hl7.fhir.r4b.model.SpecimenDefinition.SpecimenDefinitionTypeTestedHandlingComponent tgt = new org.hl7.fhir.r4b.model.SpecimenDefinition.SpecimenDefinitionTypeTestedHandlingComponent();
258    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
259    if (src.hasTemperatureQualifier())
260      tgt.setTemperatureQualifier(CodeableConcept43_50.convertCodeableConcept(src.getTemperatureQualifier()));
261    if (src.hasTemperatureRange())
262      tgt.setTemperatureRange(Range43_50.convertRange(src.getTemperatureRange()));
263    if (src.hasMaxDuration())
264      tgt.setMaxDuration(Duration43_50.convertDuration(src.getMaxDuration()));
265    if (src.hasInstruction())
266      tgt.setInstructionElement(String43_50.convertString(src.getInstructionElement()));
267    return tgt;
268  }
269}