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