
001package org.hl7.fhir.convertors.conv10_30.resources10_30; 002 003import org.hl7.fhir.convertors.context.ConversionContext10_30; 004import org.hl7.fhir.convertors.conv10_30.datatypes10_30.Reference10_30; 005import org.hl7.fhir.convertors.conv10_30.datatypes10_30.complextypes10_30.Annotation10_30; 006import org.hl7.fhir.convertors.conv10_30.datatypes10_30.complextypes10_30.CodeableConcept10_30; 007import org.hl7.fhir.convertors.conv10_30.datatypes10_30.complextypes10_30.ContactPoint10_30; 008import org.hl7.fhir.convertors.conv10_30.datatypes10_30.complextypes10_30.Identifier10_30; 009import org.hl7.fhir.convertors.conv10_30.datatypes10_30.primitivetypes10_30.DateTime10_30; 010import org.hl7.fhir.convertors.conv10_30.datatypes10_30.primitivetypes10_30.String10_30; 011import org.hl7.fhir.convertors.conv10_30.datatypes10_30.primitivetypes10_30.Uri10_30; 012import org.hl7.fhir.dstu3.model.Device; 013import org.hl7.fhir.dstu3.model.Enumeration; 014import org.hl7.fhir.exceptions.FHIRException; 015 016public class Device10_30 { 017 018 public static org.hl7.fhir.dstu2.model.Device convertDevice(org.hl7.fhir.dstu3.model.Device src) throws FHIRException { 019 if (src == null || src.isEmpty()) 020 return null; 021 org.hl7.fhir.dstu2.model.Device tgt = new org.hl7.fhir.dstu2.model.Device(); 022 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyDomainResource(src, tgt); 023 for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier()) 024 tgt.addIdentifier(Identifier10_30.convertIdentifier(t)); 025 if (src.hasUdi()) 026 tgt.setUdi(src.getUdi().getDeviceIdentifier()); 027 if (src.hasStatus()) 028 tgt.setStatusElement(convertDeviceStatus(src.getStatusElement())); 029 if (src.hasType()) 030 tgt.setType(CodeableConcept10_30.convertCodeableConcept(src.getType())); 031 if (src.hasLotNumberElement()) 032 tgt.setLotNumberElement(String10_30.convertString(src.getLotNumberElement())); 033 if (src.hasManufacturerElement()) 034 tgt.setManufacturerElement(String10_30.convertString(src.getManufacturerElement())); 035 if (src.hasManufactureDateElement()) 036 tgt.setManufactureDateElement(DateTime10_30.convertDateTime(src.getManufactureDateElement())); 037 if (src.hasExpirationDateElement()) 038 tgt.setExpiryElement(DateTime10_30.convertDateTime(src.getExpirationDateElement())); 039 if (src.hasModelElement()) 040 tgt.setModelElement(String10_30.convertString(src.getModelElement())); 041 if (src.hasVersionElement()) 042 tgt.setVersionElement(String10_30.convertString(src.getVersionElement())); 043 if (src.hasPatient()) 044 tgt.setPatient(Reference10_30.convertReference(src.getPatient())); 045 if (src.hasOwner()) 046 tgt.setOwner(Reference10_30.convertReference(src.getOwner())); 047 for (org.hl7.fhir.dstu3.model.ContactPoint t : src.getContact()) 048 tgt.addContact(ContactPoint10_30.convertContactPoint(t)); 049 if (src.hasLocation()) 050 tgt.setLocation(Reference10_30.convertReference(src.getLocation())); 051 if (src.hasUrlElement()) 052 tgt.setUrlElement(Uri10_30.convertUri(src.getUrlElement())); 053 for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote()) tgt.addNote(Annotation10_30.convertAnnotation(t)); 054 return tgt; 055 } 056 057 public static org.hl7.fhir.dstu3.model.Device convertDevice(org.hl7.fhir.dstu2.model.Device src) throws FHIRException { 058 if (src == null || src.isEmpty()) 059 return null; 060 org.hl7.fhir.dstu3.model.Device tgt = new org.hl7.fhir.dstu3.model.Device(); 061 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyDomainResource(src, tgt); 062 for (org.hl7.fhir.dstu2.model.Identifier t : src.getIdentifier()) 063 tgt.addIdentifier(Identifier10_30.convertIdentifier(t)); 064 if (src.hasUdi()) 065 tgt.setUdi((new org.hl7.fhir.dstu3.model.Device.DeviceUdiComponent()).setDeviceIdentifier(src.getUdi())); 066 if (src.hasStatus()) 067 tgt.setStatusElement(convertDeviceStatus(src.getStatusElement())); 068 if (src.hasType()) 069 tgt.setType(CodeableConcept10_30.convertCodeableConcept(src.getType())); 070 if (src.hasLotNumberElement()) 071 tgt.setLotNumberElement(String10_30.convertString(src.getLotNumberElement())); 072 if (src.hasManufacturerElement()) 073 tgt.setManufacturerElement(String10_30.convertString(src.getManufacturerElement())); 074 if (src.hasManufactureDateElement()) 075 tgt.setManufactureDateElement(DateTime10_30.convertDateTime(src.getManufactureDateElement())); 076 if (src.hasExpiryElement()) 077 tgt.setExpirationDateElement(DateTime10_30.convertDateTime(src.getExpiryElement())); 078 if (src.hasModelElement()) 079 tgt.setModelElement(String10_30.convertString(src.getModelElement())); 080 if (src.hasVersionElement()) 081 tgt.setVersionElement(String10_30.convertString(src.getVersionElement())); 082 if (src.hasPatient()) 083 tgt.setPatient(Reference10_30.convertReference(src.getPatient())); 084 if (src.hasOwner()) 085 tgt.setOwner(Reference10_30.convertReference(src.getOwner())); 086 for (org.hl7.fhir.dstu2.model.ContactPoint t : src.getContact()) 087 tgt.addContact(ContactPoint10_30.convertContactPoint(t)); 088 if (src.hasLocation()) 089 tgt.setLocation(Reference10_30.convertReference(src.getLocation())); 090 if (src.hasUrlElement()) 091 tgt.setUrlElement(Uri10_30.convertUri(src.getUrlElement())); 092 for (org.hl7.fhir.dstu2.model.Annotation t : src.getNote()) tgt.addNote(Annotation10_30.convertAnnotation(t)); 093 return tgt; 094 } 095 096 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Device.FHIRDeviceStatus> convertDeviceStatus(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Device.DeviceStatus> src) throws FHIRException { 097 if (src == null || src.isEmpty()) 098 return null; 099 Enumeration<Device.FHIRDeviceStatus> tgt = new Enumeration<>(new Device.FHIRDeviceStatusEnumFactory()); 100 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 101 if (src.getValue() == null) { 102 tgt.setValue(null); 103 } else { 104 switch (src.getValue()) { 105 case AVAILABLE: 106 tgt.setValue(Device.FHIRDeviceStatus.ACTIVE); 107 break; 108 case NOTAVAILABLE: 109 tgt.setValue(Device.FHIRDeviceStatus.INACTIVE); 110 break; 111 case ENTEREDINERROR: 112 tgt.setValue(Device.FHIRDeviceStatus.ENTEREDINERROR); 113 break; 114 default: 115 tgt.setValue(Device.FHIRDeviceStatus.NULL); 116 break; 117 } 118 } 119 return tgt; 120 } 121 122 static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Device.DeviceStatus> convertDeviceStatus(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Device.FHIRDeviceStatus> src) throws FHIRException { 123 if (src == null || src.isEmpty()) 124 return null; 125 org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Device.DeviceStatus> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Device.DeviceStatusEnumFactory()); 126 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 127 if (src.getValue() == null) { 128 tgt.setValue(null); 129 } else { 130 switch (src.getValue()) { 131 case ACTIVE: 132 tgt.setValue(org.hl7.fhir.dstu2.model.Device.DeviceStatus.AVAILABLE); 133 break; 134 case INACTIVE: 135 tgt.setValue(org.hl7.fhir.dstu2.model.Device.DeviceStatus.NOTAVAILABLE); 136 break; 137 case ENTEREDINERROR: 138 tgt.setValue(org.hl7.fhir.dstu2.model.Device.DeviceStatus.ENTEREDINERROR); 139 break; 140 default: 141 tgt.setValue(org.hl7.fhir.dstu2.model.Device.DeviceStatus.NULL); 142 break; 143 } 144 } 145 return tgt; 146 } 147}