001package org.hl7.fhir.convertors.conv30_40.resources30_40;
002
003import org.hl7.fhir.convertors.context.ConversionContext30_40;
004import org.hl7.fhir.convertors.conv30_40.datatypes30_40.Reference30_40;
005import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.Annotation30_40;
006import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.CodeableConcept30_40;
007import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.Identifier30_40;
008import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.DateTime30_40;
009import org.hl7.fhir.exceptions.FHIRException;
010
011public class DeviceUseStatement30_40 {
012
013  public static org.hl7.fhir.r4.model.DeviceUseStatement convertDeviceUseStatement(org.hl7.fhir.dstu3.model.DeviceUseStatement src) throws FHIRException {
014    if (src == null)
015      return null;
016    org.hl7.fhir.r4.model.DeviceUseStatement tgt = new org.hl7.fhir.r4.model.DeviceUseStatement();
017    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyDomainResource(src, tgt);
018    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
019      tgt.addIdentifier(Identifier30_40.convertIdentifier(t));
020    if (src.hasStatus())
021      tgt.setStatusElement(convertDeviceUseStatementStatus(src.getStatusElement()));
022    if (src.hasSubject())
023      tgt.setSubject(Reference30_40.convertReference(src.getSubject()));
024    if (src.hasTiming())
025      tgt.setTiming(ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().convertType(src.getTiming()));
026    if (src.hasRecordedOn())
027      tgt.setRecordedOnElement(DateTime30_40.convertDateTime(src.getRecordedOnElement()));
028    if (src.hasSource())
029      tgt.setSource(Reference30_40.convertReference(src.getSource()));
030    if (src.hasDevice())
031      tgt.setDevice(Reference30_40.convertReference(src.getDevice()));
032    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getIndication())
033      tgt.addReasonCode(CodeableConcept30_40.convertCodeableConcept(t));
034    if (src.hasBodySite())
035      tgt.setBodySite(CodeableConcept30_40.convertCodeableConcept(src.getBodySite()));
036    for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote()) tgt.addNote(Annotation30_40.convertAnnotation(t));
037    return tgt;
038  }
039
040  public static org.hl7.fhir.dstu3.model.DeviceUseStatement convertDeviceUseStatement(org.hl7.fhir.r4.model.DeviceUseStatement src) throws FHIRException {
041    if (src == null)
042      return null;
043    org.hl7.fhir.dstu3.model.DeviceUseStatement tgt = new org.hl7.fhir.dstu3.model.DeviceUseStatement();
044    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyDomainResource(src, tgt);
045    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
046      tgt.addIdentifier(Identifier30_40.convertIdentifier(t));
047    if (src.hasStatus())
048      tgt.setStatusElement(convertDeviceUseStatementStatus(src.getStatusElement()));
049    if (src.hasSubject())
050      tgt.setSubject(Reference30_40.convertReference(src.getSubject()));
051    if (src.hasTiming())
052      tgt.setTiming(ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().convertType(src.getTiming()));
053    if (src.hasRecordedOn())
054      tgt.setRecordedOnElement(DateTime30_40.convertDateTime(src.getRecordedOnElement()));
055    if (src.hasSource())
056      tgt.setSource(Reference30_40.convertReference(src.getSource()));
057    if (src.hasDevice())
058      tgt.setDevice(Reference30_40.convertReference(src.getDevice()));
059    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReasonCode())
060      tgt.addIndication(CodeableConcept30_40.convertCodeableConcept(t));
061    if (src.hasBodySite())
062      tgt.setBodySite(CodeableConcept30_40.convertCodeableConcept(src.getBodySite()));
063    for (org.hl7.fhir.r4.model.Annotation t : src.getNote()) tgt.addNote(Annotation30_40.convertAnnotation(t));
064    return tgt;
065  }
066
067  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.DeviceUseStatement.DeviceUseStatementStatus> convertDeviceUseStatementStatus(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.DeviceUseStatement.DeviceUseStatementStatus> src) throws FHIRException {
068    if (src == null || src.isEmpty())
069      return null;
070    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.DeviceUseStatement.DeviceUseStatementStatus> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.DeviceUseStatement.DeviceUseStatementStatusEnumFactory());
071    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
072    switch (src.getValue()) {
073      case ACTIVE:
074        tgt.setValue(org.hl7.fhir.r4.model.DeviceUseStatement.DeviceUseStatementStatus.ACTIVE);
075        break;
076      case COMPLETED:
077        tgt.setValue(org.hl7.fhir.r4.model.DeviceUseStatement.DeviceUseStatementStatus.COMPLETED);
078        break;
079      case ENTEREDINERROR:
080        tgt.setValue(org.hl7.fhir.r4.model.DeviceUseStatement.DeviceUseStatementStatus.ENTEREDINERROR);
081        break;
082      case INTENDED:
083        tgt.setValue(org.hl7.fhir.r4.model.DeviceUseStatement.DeviceUseStatementStatus.INTENDED);
084        break;
085      case STOPPED:
086        tgt.setValue(org.hl7.fhir.r4.model.DeviceUseStatement.DeviceUseStatementStatus.STOPPED);
087        break;
088      case ONHOLD:
089        tgt.setValue(org.hl7.fhir.r4.model.DeviceUseStatement.DeviceUseStatementStatus.ONHOLD);
090        break;
091      default:
092        tgt.setValue(org.hl7.fhir.r4.model.DeviceUseStatement.DeviceUseStatementStatus.NULL);
093        break;
094    }
095    return tgt;
096  }
097
098  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.DeviceUseStatement.DeviceUseStatementStatus> convertDeviceUseStatementStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.DeviceUseStatement.DeviceUseStatementStatus> src) throws FHIRException {
099    if (src == null || src.isEmpty())
100      return null;
101    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());
102    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
103    switch (src.getValue()) {
104      case ACTIVE:
105        tgt.setValue(org.hl7.fhir.dstu3.model.DeviceUseStatement.DeviceUseStatementStatus.ACTIVE);
106        break;
107      case COMPLETED:
108        tgt.setValue(org.hl7.fhir.dstu3.model.DeviceUseStatement.DeviceUseStatementStatus.COMPLETED);
109        break;
110      case ENTEREDINERROR:
111        tgt.setValue(org.hl7.fhir.dstu3.model.DeviceUseStatement.DeviceUseStatementStatus.ENTEREDINERROR);
112        break;
113      case INTENDED:
114        tgt.setValue(org.hl7.fhir.dstu3.model.DeviceUseStatement.DeviceUseStatementStatus.INTENDED);
115        break;
116      case STOPPED:
117        tgt.setValue(org.hl7.fhir.dstu3.model.DeviceUseStatement.DeviceUseStatementStatus.STOPPED);
118        break;
119      case ONHOLD:
120        tgt.setValue(org.hl7.fhir.dstu3.model.DeviceUseStatement.DeviceUseStatementStatus.ONHOLD);
121        break;
122      default:
123        tgt.setValue(org.hl7.fhir.dstu3.model.DeviceUseStatement.DeviceUseStatementStatus.NULL);
124        break;
125    }
126    return tgt;
127  }
128}