001package org.hl7.fhir.convertors.conv30_50.resources30_50; 002 003import org.hl7.fhir.convertors.context.ConversionContext30_50; 004import org.hl7.fhir.convertors.conv30_50.datatypes30_50.Reference30_50; 005import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.Annotation30_50; 006import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.CodeableConcept30_50; 007import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.Identifier30_50; 008import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.DateTime30_50; 009import org.hl7.fhir.exceptions.FHIRException; 010import org.hl7.fhir.r5.model.CodeableReference; 011 012public class DeviceUseStatement30_50 { 013 014 public static org.hl7.fhir.dstu3.model.DeviceUseStatement convertDeviceUseStatement(org.hl7.fhir.r5.model.DeviceUsage src) throws FHIRException { 015 if (src == null) 016 return null; 017 org.hl7.fhir.dstu3.model.DeviceUseStatement tgt = new org.hl7.fhir.dstu3.model.DeviceUseStatement(); 018 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt); 019 for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) 020 tgt.addIdentifier(Identifier30_50.convertIdentifier(t)); 021 if (src.hasStatus()) 022 tgt.setStatusElement(convertDeviceUseStatementStatus(src.getStatusElement())); 023 if (src.hasPatient()) 024 tgt.setSubject(Reference30_50.convertReference(src.getPatient())); 025 if (src.hasTiming()) 026 tgt.setTiming(ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getTiming())); 027 if (src.hasDateAsserted()) 028 tgt.setRecordedOnElement(DateTime30_50.convertDateTime(src.getDateAssertedElement())); 029 if (src.hasInformationSource()) 030 tgt.setSource(Reference30_50.convertReference(src.getInformationSource())); 031 if (src.getDevice().hasReference()) 032 tgt.setDevice(Reference30_50.convertReference(src.getDevice().getReference())); 033 for (CodeableReference t : src.getReason()) 034 if (t.hasConcept()) 035 tgt.addIndication(CodeableConcept30_50.convertCodeableConcept(t.getConcept())); 036 if (src.getBodySite().hasConcept()) 037 tgt.setBodySite(CodeableConcept30_50.convertCodeableConcept(src.getBodySite().getConcept())); 038 for (org.hl7.fhir.r5.model.Annotation t : src.getNote()) tgt.addNote(Annotation30_50.convertAnnotation(t)); 039 return tgt; 040 } 041 042 public static org.hl7.fhir.r5.model.DeviceUsage convertDeviceUseStatement(org.hl7.fhir.dstu3.model.DeviceUseStatement src) throws FHIRException { 043 if (src == null) 044 return null; 045 org.hl7.fhir.r5.model.DeviceUsage tgt = new org.hl7.fhir.r5.model.DeviceUsage(); 046 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt); 047 for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier()) 048 tgt.addIdentifier(Identifier30_50.convertIdentifier(t)); 049 if (src.hasStatus()) 050 tgt.setStatusElement(convertDeviceUseStatementStatus(src.getStatusElement())); 051 if (src.hasSubject()) 052 tgt.setPatient(Reference30_50.convertReference(src.getSubject())); 053 if (src.hasTiming()) 054 tgt.setTiming(ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getTiming())); 055 if (src.hasRecordedOn()) 056 tgt.setDateAssertedElement(DateTime30_50.convertDateTime(src.getRecordedOnElement())); 057 if (src.hasSource()) 058 tgt.setInformationSource(Reference30_50.convertReference(src.getSource())); 059 if (src.hasDevice()) 060 tgt.getDevice().setReference(Reference30_50.convertReference(src.getDevice())); 061 for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getIndication()) 062 tgt.addReason(Reference30_50.convertCodeableConceptToCodableReference(t)); 063 if (src.hasBodySite()) 064 tgt.getBodySite().setConcept(CodeableConcept30_50.convertCodeableConcept(src.getBodySite())); 065 for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote()) tgt.addNote(Annotation30_50.convertAnnotation(t)); 066 return tgt; 067 } 068 069 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.DeviceUseStatement.DeviceUseStatementStatus> convertDeviceUseStatementStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.DeviceUsage.DeviceUsageStatus> src) throws FHIRException { 070 if (src == null || src.isEmpty()) 071 return null; 072 org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.DeviceUseStatement.DeviceUseStatementStatus> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.DeviceUseStatement.DeviceUseStatementStatusEnumFactory()); 073 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 074 switch (src.getValue()) { 075 case ACTIVE: 076 tgt.setValue(org.hl7.fhir.dstu3.model.DeviceUseStatement.DeviceUseStatementStatus.ACTIVE); 077 break; 078 case COMPLETED: 079 tgt.setValue(org.hl7.fhir.dstu3.model.DeviceUseStatement.DeviceUseStatementStatus.COMPLETED); 080 break; 081 case ENTEREDINERROR: 082 tgt.setValue(org.hl7.fhir.dstu3.model.DeviceUseStatement.DeviceUseStatementStatus.ENTEREDINERROR); 083 break; 084 case INTENDED: 085 tgt.setValue(org.hl7.fhir.dstu3.model.DeviceUseStatement.DeviceUseStatementStatus.INTENDED); 086 break; 087 case STOPPED: 088 tgt.setValue(org.hl7.fhir.dstu3.model.DeviceUseStatement.DeviceUseStatementStatus.STOPPED); 089 break; 090 case ONHOLD: 091 tgt.setValue(org.hl7.fhir.dstu3.model.DeviceUseStatement.DeviceUseStatementStatus.ONHOLD); 092 break; 093 default: 094 tgt.setValue(org.hl7.fhir.dstu3.model.DeviceUseStatement.DeviceUseStatementStatus.NULL); 095 break; 096 } 097 return tgt; 098 } 099 100 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.DeviceUsage.DeviceUsageStatus> convertDeviceUseStatementStatus(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.DeviceUseStatement.DeviceUseStatementStatus> src) throws FHIRException { 101 if (src == null || src.isEmpty()) 102 return null; 103 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.DeviceUsage.DeviceUsageStatus> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.DeviceUsage.DeviceUsageStatusEnumFactory()); 104 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 105 switch (src.getValue()) { 106 case ACTIVE: 107 tgt.setValue(org.hl7.fhir.r5.model.DeviceUsage.DeviceUsageStatus.ACTIVE); 108 break; 109 case COMPLETED: 110 tgt.setValue(org.hl7.fhir.r5.model.DeviceUsage.DeviceUsageStatus.COMPLETED); 111 break; 112 case ENTEREDINERROR: 113 tgt.setValue(org.hl7.fhir.r5.model.DeviceUsage.DeviceUsageStatus.ENTEREDINERROR); 114 break; 115 case INTENDED: 116 tgt.setValue(org.hl7.fhir.r5.model.DeviceUsage.DeviceUsageStatus.INTENDED); 117 break; 118 case STOPPED: 119 tgt.setValue(org.hl7.fhir.r5.model.DeviceUsage.DeviceUsageStatus.STOPPED); 120 break; 121 case ONHOLD: 122 tgt.setValue(org.hl7.fhir.r5.model.DeviceUsage.DeviceUsageStatus.ONHOLD); 123 break; 124 default: 125 tgt.setValue(org.hl7.fhir.r5.model.DeviceUsage.DeviceUsageStatus.NULL); 126 break; 127 } 128 return tgt; 129 } 130}