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