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.Annotation43_50;
005import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.CodeableConcept43_50;
006import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.ContactPoint43_50;
007import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Identifier43_50;
008import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Quantity43_50;
009import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Base64Binary43_50;
010import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.DateTime43_50;
011import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.String43_50;
012import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Uri43_50;
013import org.hl7.fhir.convertors.conv43_50.datatypes43_50.special43_50.Reference43_50;
014import org.hl7.fhir.exceptions.FHIRException;
015
016/*
017  Copyright (c) 2011+, HL7, Inc.
018  All rights reserved.
019  
020  Redistribution and use in source and binary forms, with or without modification, 
021  are permitted provided that the following conditions are met:
022  
023   * Redistributions of source code must retain the above copyright notice, this 
024     list of conditions and the following disclaimer.
025   * Redistributions in binary form must reproduce the above copyright notice, 
026     this list of conditions and the following disclaimer in the documentation 
027     and/or other materials provided with the distribution.
028   * Neither the name of HL7 nor the names of its contributors may be used to 
029     endorse or promote products derived from this software without specific 
030     prior written permission.
031  
032  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
033  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
034  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
035  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
036  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
037  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
038  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
039  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
040  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
041  POSSIBILITY OF SUCH DAMAGE.
042  
043*/
044// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0
045public class Device43_50 {
046
047  public static org.hl7.fhir.r5.model.Device convertDevice(org.hl7.fhir.r4b.model.Device src) throws FHIRException {
048    if (src == null)
049      return null;
050    org.hl7.fhir.r5.model.Device tgt = new org.hl7.fhir.r5.model.Device();
051    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt);
052    for (org.hl7.fhir.r4b.model.Identifier t : src.getIdentifier())
053      tgt.addIdentifier(Identifier43_50.convertIdentifier(t));
054    if (src.hasDefinition())
055      tgt.getDefinition().setReference(Reference43_50.convertReference(src.getDefinition()));
056    for (org.hl7.fhir.r4b.model.Device.DeviceUdiCarrierComponent t : src.getUdiCarrier())
057      tgt.addUdiCarrier(convertDeviceUdiCarrierComponent(t));
058    if (src.hasStatus())
059      tgt.setStatusElement(convertFHIRDeviceStatus(src.getStatusElement()));
060//    for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getStatusReason())
061//      tgt.addStatusReason(CodeableConcept43_50.convertCodeableConcept(t));
062    if (src.hasDistinctIdentifier())
063      tgt.getBiologicalSourceEvent().setValueElement(String43_50.convertString(src.getDistinctIdentifierElement()));
064    if (src.hasManufacturer())
065      tgt.setManufacturerElement(String43_50.convertString(src.getManufacturerElement()));
066    if (src.hasManufactureDate())
067      tgt.setManufactureDateElement(DateTime43_50.convertDateTime(src.getManufactureDateElement()));
068    if (src.hasExpirationDate())
069      tgt.setExpirationDateElement(DateTime43_50.convertDateTime(src.getExpirationDateElement()));
070    if (src.hasLotNumber())
071      tgt.setLotNumberElement(String43_50.convertString(src.getLotNumberElement()));
072    if (src.hasSerialNumber())
073      tgt.setSerialNumberElement(String43_50.convertString(src.getSerialNumberElement()));
074    for (org.hl7.fhir.r4b.model.Device.DeviceDeviceNameComponent t : src.getDeviceName())
075      tgt.addName(convertDeviceDeviceNameComponent(t));
076    if (src.hasModelNumber())
077      tgt.setModelNumberElement(String43_50.convertString(src.getModelNumberElement()));
078    if (src.hasPartNumber())
079      tgt.setPartNumberElement(String43_50.convertString(src.getPartNumberElement()));
080    if (src.hasType())
081      tgt.addType(CodeableConcept43_50.convertCodeableConcept(src.getType()));
082//    for (org.hl7.fhir.r4b.model.Device.DeviceSpecializationComponent t : src.getSpecialization())
083//      tgt.addSpecialization(convertDeviceSpecializationComponent(t));
084    for (org.hl7.fhir.r4b.model.Device.DeviceVersionComponent t : src.getVersion())
085      tgt.addVersion(convertDeviceVersionComponent(t));
086    for (org.hl7.fhir.r4b.model.Device.DevicePropertyComponent t : src.getProperty())
087      tgt.addProperty(convertDevicePropertyComponent(t));
088//    if (src.hasPatient())
089//      tgt.getAssociationFirstRep().setHumanSubject(Reference43_50.convertReference(src.getPatient()));
090    if (src.hasOwner())
091      tgt.setOwner(Reference43_50.convertReference(src.getOwner()));
092    for (org.hl7.fhir.r4b.model.ContactPoint t : src.getContact())
093      tgt.addContact(ContactPoint43_50.convertContactPoint(t));
094    if (src.hasLocation())
095      tgt.setLocation(Reference43_50.convertReference(src.getLocation()));
096    if (src.hasUrl())
097      tgt.setUrlElement(Uri43_50.convertUri(src.getUrlElement()));
098    for (org.hl7.fhir.r4b.model.Annotation t : src.getNote()) tgt.addNote(Annotation43_50.convertAnnotation(t));
099    for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getSafety())
100      tgt.addSafety(CodeableConcept43_50.convertCodeableConcept(t));
101    if (src.hasParent())
102      tgt.setParent(Reference43_50.convertReference(src.getParent()));
103    return tgt;
104  }
105
106  public static org.hl7.fhir.r4b.model.Device convertDevice(org.hl7.fhir.r5.model.Device src) throws FHIRException {
107    if (src == null)
108      return null;
109    org.hl7.fhir.r4b.model.Device tgt = new org.hl7.fhir.r4b.model.Device();
110    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt);
111    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
112      tgt.addIdentifier(Identifier43_50.convertIdentifier(t));
113    if (src.getDefinition().hasReference())
114      tgt.setDefinition(Reference43_50.convertReference(src.getDefinition().getReference()));
115    for (org.hl7.fhir.r5.model.Device.DeviceUdiCarrierComponent t : src.getUdiCarrier())
116      tgt.addUdiCarrier(convertDeviceUdiCarrierComponent(t));
117    if (src.hasStatus())
118      tgt.setStatusElement(convertFHIRDeviceStatus(src.getStatusElement()));
119//    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getStatusReason())
120//      tgt.addStatusReason(CodeableConcept43_50.convertCodeableConcept(t));
121    if (src.hasBiologicalSourceEvent())
122      tgt.setDistinctIdentifierElement(String43_50.convertString(src.getBiologicalSourceEvent().getValueElement()));
123    if (src.hasManufacturer())
124      tgt.setManufacturerElement(String43_50.convertString(src.getManufacturerElement()));
125    if (src.hasManufactureDate())
126      tgt.setManufactureDateElement(DateTime43_50.convertDateTime(src.getManufactureDateElement()));
127    if (src.hasExpirationDate())
128      tgt.setExpirationDateElement(DateTime43_50.convertDateTime(src.getExpirationDateElement()));
129    if (src.hasLotNumber())
130      tgt.setLotNumberElement(String43_50.convertString(src.getLotNumberElement()));
131    if (src.hasSerialNumber())
132      tgt.setSerialNumberElement(String43_50.convertString(src.getSerialNumberElement()));
133    for (org.hl7.fhir.r5.model.Device.DeviceNameComponent t : src.getName())
134      tgt.addDeviceName(convertDeviceDeviceNameComponent(t));
135    if (src.hasModelNumber())
136      tgt.setModelNumberElement(String43_50.convertString(src.getModelNumberElement()));
137    if (src.hasPartNumber())
138      tgt.setPartNumberElement(String43_50.convertString(src.getPartNumberElement()));
139    if (src.hasType())
140      tgt.setType(CodeableConcept43_50.convertCodeableConcept(src.getTypeFirstRep()));
141//    for (org.hl7.fhir.r5.model.Device.DeviceSpecializationComponent t : src.getSpecialization())
142//      tgt.addSpecialization(convertDeviceSpecializationComponent(t));
143    for (org.hl7.fhir.r5.model.Device.DeviceVersionComponent t : src.getVersion())
144      tgt.addVersion(convertDeviceVersionComponent(t));
145    for (org.hl7.fhir.r5.model.Device.DevicePropertyComponent t : src.getProperty())
146      tgt.addProperty(convertDevicePropertyComponent(t));
147//    if (src.getAssociationFirstRep().hasHumanSubject())
148//      tgt.setPatient(Reference43_50.convertReference(src.getAssociationFirstRep().getHumanSubject()));
149    if (src.hasOwner())
150      tgt.setOwner(Reference43_50.convertReference(src.getOwner()));
151    for (org.hl7.fhir.r5.model.ContactPoint t : src.getContact())
152      tgt.addContact(ContactPoint43_50.convertContactPoint(t));
153    if (src.hasLocation())
154      tgt.setLocation(Reference43_50.convertReference(src.getLocation()));
155    if (src.hasUrl())
156      tgt.setUrlElement(Uri43_50.convertUri(src.getUrlElement()));
157    for (org.hl7.fhir.r5.model.Annotation t : src.getNote()) tgt.addNote(Annotation43_50.convertAnnotation(t));
158    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getSafety())
159      tgt.addSafety(CodeableConcept43_50.convertCodeableConcept(t));
160    if (src.hasParent())
161      tgt.setParent(Reference43_50.convertReference(src.getParent()));
162    return tgt;
163  }
164
165  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Device.FHIRDeviceStatus> convertFHIRDeviceStatus(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Device.FHIRDeviceStatus> src) throws FHIRException {
166    if (src == null || src.isEmpty())
167      return null;
168    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Device.FHIRDeviceStatus> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Device.FHIRDeviceStatusEnumFactory());
169    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
170    switch (src.getValue()) {
171      case ACTIVE:
172        tgt.setValue(org.hl7.fhir.r5.model.Device.FHIRDeviceStatus.ACTIVE);
173        break;
174      case INACTIVE:
175        tgt.setValue(org.hl7.fhir.r5.model.Device.FHIRDeviceStatus.INACTIVE);
176        break;
177      case ENTEREDINERROR:
178        tgt.setValue(org.hl7.fhir.r5.model.Device.FHIRDeviceStatus.ENTEREDINERROR);
179        break;
180      case UNKNOWN:
181        tgt.setValue(org.hl7.fhir.r5.model.Device.FHIRDeviceStatus.NULL);
182        break;
183      default:
184        tgt.setValue(org.hl7.fhir.r5.model.Device.FHIRDeviceStatus.NULL);
185        break;
186    }
187    return tgt;
188  }
189
190  static public org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Device.FHIRDeviceStatus> convertFHIRDeviceStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Device.FHIRDeviceStatus> src) throws FHIRException {
191    if (src == null || src.isEmpty())
192      return null;
193    org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Device.FHIRDeviceStatus> tgt = new org.hl7.fhir.r4b.model.Enumeration<>(new org.hl7.fhir.r4b.model.Device.FHIRDeviceStatusEnumFactory());
194    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
195    switch (src.getValue()) {
196      case ACTIVE:
197        tgt.setValue(org.hl7.fhir.r4b.model.Device.FHIRDeviceStatus.ACTIVE);
198        break;
199      case INACTIVE:
200        tgt.setValue(org.hl7.fhir.r4b.model.Device.FHIRDeviceStatus.INACTIVE);
201        break;
202      case ENTEREDINERROR:
203        tgt.setValue(org.hl7.fhir.r4b.model.Device.FHIRDeviceStatus.ENTEREDINERROR);
204        break;
205      default:
206        tgt.setValue(org.hl7.fhir.r4b.model.Device.FHIRDeviceStatus.NULL);
207        break;
208    }
209    return tgt;
210  }
211
212  public static org.hl7.fhir.r5.model.Device.DeviceUdiCarrierComponent convertDeviceUdiCarrierComponent(org.hl7.fhir.r4b.model.Device.DeviceUdiCarrierComponent src) throws FHIRException {
213    if (src == null)
214      return null;
215    org.hl7.fhir.r5.model.Device.DeviceUdiCarrierComponent tgt = new org.hl7.fhir.r5.model.Device.DeviceUdiCarrierComponent();
216    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
217    if (src.hasDeviceIdentifier())
218      tgt.setDeviceIdentifierElement(String43_50.convertString(src.getDeviceIdentifierElement()));
219    if (src.hasIssuer())
220      tgt.setIssuerElement(Uri43_50.convertUri(src.getIssuerElement()));
221    if (src.hasJurisdiction())
222      tgt.setJurisdictionElement(Uri43_50.convertUri(src.getJurisdictionElement()));
223    if (src.hasCarrierAIDC())
224      tgt.setCarrierAIDCElement(Base64Binary43_50.convertBase64Binary(src.getCarrierAIDCElement()));
225    if (src.hasCarrierHRF())
226      tgt.setCarrierHRFElement(String43_50.convertString(src.getCarrierHRFElement()));
227    if (src.hasEntryType())
228      tgt.setEntryTypeElement(convertUDIEntryType(src.getEntryTypeElement()));
229    return tgt;
230  }
231
232  public static org.hl7.fhir.r4b.model.Device.DeviceUdiCarrierComponent convertDeviceUdiCarrierComponent(org.hl7.fhir.r5.model.Device.DeviceUdiCarrierComponent src) throws FHIRException {
233    if (src == null)
234      return null;
235    org.hl7.fhir.r4b.model.Device.DeviceUdiCarrierComponent tgt = new org.hl7.fhir.r4b.model.Device.DeviceUdiCarrierComponent();
236    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
237    if (src.hasDeviceIdentifier())
238      tgt.setDeviceIdentifierElement(String43_50.convertString(src.getDeviceIdentifierElement()));
239    if (src.hasIssuer())
240      tgt.setIssuerElement(Uri43_50.convertUri(src.getIssuerElement()));
241    if (src.hasJurisdiction())
242      tgt.setJurisdictionElement(Uri43_50.convertUri(src.getJurisdictionElement()));
243    if (src.hasCarrierAIDC())
244      tgt.setCarrierAIDCElement(Base64Binary43_50.convertBase64Binary(src.getCarrierAIDCElement()));
245    if (src.hasCarrierHRF())
246      tgt.setCarrierHRFElement(String43_50.convertString(src.getCarrierHRFElement()));
247    if (src.hasEntryType())
248      tgt.setEntryTypeElement(convertUDIEntryType(src.getEntryTypeElement()));
249    return tgt;
250  }
251
252  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Device.UDIEntryType> convertUDIEntryType(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Device.UDIEntryType> src) throws FHIRException {
253    if (src == null || src.isEmpty())
254      return null;
255    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Device.UDIEntryType> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Device.UDIEntryTypeEnumFactory());
256    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
257    switch (src.getValue()) {
258      case BARCODE:
259        tgt.setValue(org.hl7.fhir.r5.model.Device.UDIEntryType.BARCODE);
260        break;
261      case RFID:
262        tgt.setValue(org.hl7.fhir.r5.model.Device.UDIEntryType.RFID);
263        break;
264      case MANUAL:
265        tgt.setValue(org.hl7.fhir.r5.model.Device.UDIEntryType.MANUAL);
266        break;
267      case CARD:
268        tgt.setValue(org.hl7.fhir.r5.model.Device.UDIEntryType.CARD);
269        break;
270      case SELFREPORTED:
271        tgt.setValue(org.hl7.fhir.r5.model.Device.UDIEntryType.SELFREPORTED);
272        break;
273      case UNKNOWN:
274        tgt.setValue(org.hl7.fhir.r5.model.Device.UDIEntryType.UNKNOWN);
275        break;
276      default:
277        tgt.setValue(org.hl7.fhir.r5.model.Device.UDIEntryType.NULL);
278        break;
279    }
280    return tgt;
281  }
282
283  static public org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Device.UDIEntryType> convertUDIEntryType(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Device.UDIEntryType> src) throws FHIRException {
284    if (src == null || src.isEmpty())
285      return null;
286    org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Device.UDIEntryType> tgt = new org.hl7.fhir.r4b.model.Enumeration<>(new org.hl7.fhir.r4b.model.Device.UDIEntryTypeEnumFactory());
287    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
288    switch (src.getValue()) {
289      case BARCODE:
290        tgt.setValue(org.hl7.fhir.r4b.model.Device.UDIEntryType.BARCODE);
291        break;
292      case RFID:
293        tgt.setValue(org.hl7.fhir.r4b.model.Device.UDIEntryType.RFID);
294        break;
295      case MANUAL:
296        tgt.setValue(org.hl7.fhir.r4b.model.Device.UDIEntryType.MANUAL);
297        break;
298      case CARD:
299        tgt.setValue(org.hl7.fhir.r4b.model.Device.UDIEntryType.CARD);
300        break;
301      case SELFREPORTED:
302        tgt.setValue(org.hl7.fhir.r4b.model.Device.UDIEntryType.SELFREPORTED);
303        break;
304      case UNKNOWN:
305        tgt.setValue(org.hl7.fhir.r4b.model.Device.UDIEntryType.UNKNOWN);
306        break;
307      default:
308        tgt.setValue(org.hl7.fhir.r4b.model.Device.UDIEntryType.NULL);
309        break;
310    }
311    return tgt;
312  }
313
314  public static org.hl7.fhir.r5.model.Device.DeviceNameComponent convertDeviceDeviceNameComponent(org.hl7.fhir.r4b.model.Device.DeviceDeviceNameComponent src) throws FHIRException {
315    if (src == null)
316      return null;
317    org.hl7.fhir.r5.model.Device.DeviceNameComponent tgt = new org.hl7.fhir.r5.model.Device.DeviceNameComponent();
318    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
319    if (src.hasName())
320      tgt.setValueElement(String43_50.convertString(src.getNameElement()));
321    if (src.hasType())
322      tgt.setTypeElement(convertDeviceNameType(src.getTypeElement()));
323    return tgt;
324  }
325
326  public static org.hl7.fhir.r4b.model.Device.DeviceDeviceNameComponent convertDeviceDeviceNameComponent(org.hl7.fhir.r5.model.Device.DeviceNameComponent src) throws FHIRException {
327    if (src == null)
328      return null;
329    org.hl7.fhir.r4b.model.Device.DeviceDeviceNameComponent tgt = new org.hl7.fhir.r4b.model.Device.DeviceDeviceNameComponent();
330    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
331    if (src.hasValue())
332      tgt.setNameElement(String43_50.convertString(src.getValueElement()));
333    if (src.hasType())
334      tgt.setTypeElement(convertDeviceNameType(src.getTypeElement()));
335    return tgt;
336  }
337
338  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.DeviceNameType> convertDeviceNameType(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Enumerations.DeviceNameType> src) throws FHIRException {
339    if (src == null || src.isEmpty())
340      return null;
341    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.DeviceNameType> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.DeviceNameTypeEnumFactory());
342    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
343    switch (src.getValue()) {
344      case USERFRIENDLYNAME:
345        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DeviceNameType.USERFRIENDLYNAME);
346        break;
347      case PATIENTREPORTEDNAME:
348        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DeviceNameType.PATIENTREPORTEDNAME);
349        break;
350      case MANUFACTURERNAME:
351        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DeviceNameType.REGISTEREDNAME);
352        break;
353      case MODELNAME:
354        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DeviceNameType.USERFRIENDLYNAME);
355        break;
356      case OTHER:
357        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DeviceNameType.NULL);
358        break;
359      default:
360        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DeviceNameType.NULL);
361        break;
362    }
363    return tgt;
364  }
365
366  static public org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Enumerations.DeviceNameType> convertDeviceNameType(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.DeviceNameType> src) throws FHIRException {
367    if (src == null || src.isEmpty())
368      return null;
369    org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Enumerations.DeviceNameType> tgt = new org.hl7.fhir.r4b.model.Enumeration<>(new org.hl7.fhir.r4b.model.Enumerations.DeviceNameTypeEnumFactory());
370    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
371    switch (src.getValue()) {
372      case USERFRIENDLYNAME:
373        tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.DeviceNameType.USERFRIENDLYNAME);
374        break;
375      case PATIENTREPORTEDNAME:
376        tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.DeviceNameType.PATIENTREPORTEDNAME);
377        break;
378      case REGISTEREDNAME:
379        tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.DeviceNameType.MANUFACTURERNAME);
380        break;
381      default:
382        tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.DeviceNameType.NULL);
383        break;
384    }
385    return tgt;
386  }
387
388//  public static org.hl7.fhir.r5.model.Device.DeviceSpecializationComponent convertDeviceSpecializationComponent(org.hl7.fhir.r4b.model.Device.DeviceSpecializationComponent src) throws FHIRException {
389//    if (src == null)
390//      return null;
391//    org.hl7.fhir.r5.model.Device.DeviceSpecializationComponent tgt = new org.hl7.fhir.r5.model.Device.DeviceSpecializationComponent();
392//    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
393//    if (src.hasSystemType())
394//      tgt.setSystemType(CodeableConcept43_50.convertCodeableConcept(src.getSystemType()));
395//    if (src.hasVersion())
396//      tgt.setVersionElement(String43_50.convertString(src.getVersionElement()));
397//    return tgt;
398//  }
399//
400//  public static org.hl7.fhir.r4b.model.Device.DeviceSpecializationComponent convertDeviceSpecializationComponent(org.hl7.fhir.r5.model.Device.DeviceSpecializationComponent src) throws FHIRException {
401//    if (src == null)
402//      return null;
403//    org.hl7.fhir.r4b.model.Device.DeviceSpecializationComponent tgt = new org.hl7.fhir.r4b.model.Device.DeviceSpecializationComponent();
404//    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
405//    if (src.hasSystemType())
406//      tgt.setSystemType(CodeableConcept43_50.convertCodeableConcept(src.getSystemType()));
407//    if (src.hasVersion())
408//      tgt.setVersionElement(String43_50.convertString(src.getVersionElement()));
409//    return tgt;
410//  }
411
412  public static org.hl7.fhir.r5.model.Device.DeviceVersionComponent convertDeviceVersionComponent(org.hl7.fhir.r4b.model.Device.DeviceVersionComponent src) throws FHIRException {
413    if (src == null)
414      return null;
415    org.hl7.fhir.r5.model.Device.DeviceVersionComponent tgt = new org.hl7.fhir.r5.model.Device.DeviceVersionComponent();
416    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
417    if (src.hasType())
418      tgt.setType(CodeableConcept43_50.convertCodeableConcept(src.getType()));
419    if (src.hasComponent())
420      tgt.setComponent(Identifier43_50.convertIdentifier(src.getComponent()));
421    if (src.hasValue())
422      tgt.setValueElement(String43_50.convertString(src.getValueElement()));
423    return tgt;
424  }
425
426  public static org.hl7.fhir.r4b.model.Device.DeviceVersionComponent convertDeviceVersionComponent(org.hl7.fhir.r5.model.Device.DeviceVersionComponent src) throws FHIRException {
427    if (src == null)
428      return null;
429    org.hl7.fhir.r4b.model.Device.DeviceVersionComponent tgt = new org.hl7.fhir.r4b.model.Device.DeviceVersionComponent();
430    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
431    if (src.hasType())
432      tgt.setType(CodeableConcept43_50.convertCodeableConcept(src.getType()));
433    if (src.hasComponent())
434      tgt.setComponent(Identifier43_50.convertIdentifier(src.getComponent()));
435    if (src.hasValue())
436      tgt.setValueElement(String43_50.convertString(src.getValueElement()));
437    return tgt;
438  }
439
440  public static org.hl7.fhir.r5.model.Device.DevicePropertyComponent convertDevicePropertyComponent(org.hl7.fhir.r4b.model.Device.DevicePropertyComponent src) throws FHIRException {
441    if (src == null)
442      return null;
443    org.hl7.fhir.r5.model.Device.DevicePropertyComponent tgt = new org.hl7.fhir.r5.model.Device.DevicePropertyComponent();
444    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
445    if (src.hasType())
446      tgt.setType(CodeableConcept43_50.convertCodeableConcept(src.getType()));
447    for (org.hl7.fhir.r4b.model.Quantity t : src.getValueQuantity()) tgt.setValue(Quantity43_50.convertQuantity(t));
448    for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getValueCode())
449      tgt.setValue(CodeableConcept43_50.convertCodeableConcept(t));
450    return tgt;
451  }
452
453  public static org.hl7.fhir.r4b.model.Device.DevicePropertyComponent convertDevicePropertyComponent(org.hl7.fhir.r5.model.Device.DevicePropertyComponent src) throws FHIRException {
454    if (src == null)
455      return null;
456    org.hl7.fhir.r4b.model.Device.DevicePropertyComponent tgt = new org.hl7.fhir.r4b.model.Device.DevicePropertyComponent();
457    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
458    if (src.hasType())
459      tgt.setType(CodeableConcept43_50.convertCodeableConcept(src.getType()));
460    if (src.hasValueQuantity()) tgt.addValueQuantity(Quantity43_50.convertQuantity(src.getValueQuantity()));
461    if (src.hasValueCodeableConcept())
462      tgt.addValueCode(CodeableConcept43_50.convertCodeableConcept(src.getValueCodeableConcept()));
463    return tgt;
464  }
465}