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.Attachment10_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.Identifier10_30;
008import org.hl7.fhir.convertors.conv10_30.datatypes10_30.primitivetypes10_30.PositiveInt10_30;
009import org.hl7.fhir.convertors.conv10_30.datatypes10_30.primitivetypes10_30.UnsignedInt10_30;
010import org.hl7.fhir.dstu2.model.Enumeration;
011import org.hl7.fhir.dstu2.model.Media;
012import org.hl7.fhir.exceptions.FHIRException;
013
014public class Media10_30 {
015
016  static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Media.DigitalMediaType> convertDigitalMediaType(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Media.DigitalMediaType> src) throws FHIRException {
017      if (src == null || src.isEmpty())
018          return null;
019      Enumeration<Media.DigitalMediaType> tgt = new Enumeration<>(new Media.DigitalMediaTypeEnumFactory());
020      ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt);
021      if (src.getValue() == null) {
022          tgt.setValue(null);
023      } else {
024          switch (src.getValue()) {
025              case PHOTO:
026                  tgt.setValue(Media.DigitalMediaType.PHOTO);
027                  break;
028              case VIDEO:
029                  tgt.setValue(Media.DigitalMediaType.VIDEO);
030                  break;
031              case AUDIO:
032                  tgt.setValue(Media.DigitalMediaType.AUDIO);
033                  break;
034              default:
035                  tgt.setValue(Media.DigitalMediaType.NULL);
036                  break;
037          }
038      }
039      return tgt;
040  }
041
042  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Media.DigitalMediaType> convertDigitalMediaType(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Media.DigitalMediaType> src) throws FHIRException {
043      if (src == null || src.isEmpty())
044          return null;
045      org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Media.DigitalMediaType> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Media.DigitalMediaTypeEnumFactory());
046      ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt);
047      if (src.getValue() == null) {
048          tgt.setValue(null);
049      } else {
050          switch (src.getValue()) {
051              case PHOTO:
052                  tgt.setValue(org.hl7.fhir.dstu3.model.Media.DigitalMediaType.PHOTO);
053                  break;
054              case VIDEO:
055                  tgt.setValue(org.hl7.fhir.dstu3.model.Media.DigitalMediaType.VIDEO);
056                  break;
057              case AUDIO:
058                  tgt.setValue(org.hl7.fhir.dstu3.model.Media.DigitalMediaType.AUDIO);
059                  break;
060              default:
061                  tgt.setValue(org.hl7.fhir.dstu3.model.Media.DigitalMediaType.NULL);
062                  break;
063          }
064      }
065      return tgt;
066  }
067
068  public static org.hl7.fhir.dstu2.model.Media convertMedia(org.hl7.fhir.dstu3.model.Media src) throws FHIRException {
069    if (src == null || src.isEmpty())
070      return null;
071    org.hl7.fhir.dstu2.model.Media tgt = new org.hl7.fhir.dstu2.model.Media();
072    ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyDomainResource(src, tgt);
073    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
074      tgt.addIdentifier(Identifier10_30.convertIdentifier(t));
075    if (src.hasType())
076      tgt.setTypeElement(convertDigitalMediaType(src.getTypeElement()));
077    if (src.hasSubtype())
078      tgt.setSubtype(CodeableConcept10_30.convertCodeableConcept(src.getSubtype()));
079    if (src.hasView())
080      tgt.setView(CodeableConcept10_30.convertCodeableConcept(src.getView()));
081    if (src.hasSubject())
082      tgt.setSubject(Reference10_30.convertReference(src.getSubject()));
083    if (src.hasOperator())
084      tgt.setOperator(Reference10_30.convertReference(src.getOperator()));
085    tgt.setDeviceName(src.getDevice().getDisplay());
086    if (src.hasHeightElement())
087      tgt.setHeightElement(PositiveInt10_30.convertPositiveInt(src.getHeightElement()));
088    if (src.hasWidthElement())
089      tgt.setWidthElement(PositiveInt10_30.convertPositiveInt(src.getWidthElement()));
090    if (src.hasFramesElement())
091      tgt.setFramesElement(PositiveInt10_30.convertPositiveInt(src.getFramesElement()));
092    if (src.hasDurationElement())
093      tgt.setDurationElement(UnsignedInt10_30.convertUnsignedInt(src.getDurationElement()));
094    if (src.hasContent())
095      tgt.setContent(Attachment10_30.convertAttachment(src.getContent()));
096    return tgt;
097  }
098
099  public static org.hl7.fhir.dstu3.model.Media convertMedia(org.hl7.fhir.dstu2.model.Media src) throws FHIRException {
100    if (src == null || src.isEmpty())
101      return null;
102    org.hl7.fhir.dstu3.model.Media tgt = new org.hl7.fhir.dstu3.model.Media();
103    ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyDomainResource(src, tgt);
104    for (org.hl7.fhir.dstu2.model.Identifier t : src.getIdentifier())
105      tgt.addIdentifier(Identifier10_30.convertIdentifier(t));
106    if (src.hasType())
107      tgt.setTypeElement(convertDigitalMediaType(src.getTypeElement()));
108    if (src.hasSubtype())
109      tgt.setSubtype(CodeableConcept10_30.convertCodeableConcept(src.getSubtype()));
110    if (src.hasView())
111      tgt.setView(CodeableConcept10_30.convertCodeableConcept(src.getView()));
112    if (src.hasSubject())
113      tgt.setSubject(Reference10_30.convertReference(src.getSubject()));
114    if (src.hasOperator())
115      tgt.setOperator(Reference10_30.convertReference(src.getOperator()));
116    tgt.getDevice().setDisplay(src.getDeviceName());
117    if (src.hasHeightElement())
118      tgt.setHeightElement(PositiveInt10_30.convertPositiveInt(src.getHeightElement()));
119    if (src.hasWidthElement())
120      tgt.setWidthElement(PositiveInt10_30.convertPositiveInt(src.getWidthElement()));
121    if (src.hasFramesElement())
122      tgt.setFramesElement(PositiveInt10_30.convertPositiveInt(src.getFramesElement()));
123    if (src.hasDurationElement())
124      tgt.setDurationElement(UnsignedInt10_30.convertUnsignedInt(src.getDurationElement()));
125    if (src.hasContent())
126      tgt.setContent(Attachment10_30.convertAttachment(src.getContent()));
127    return tgt;
128  }
129}