001package org.hl7.fhir.convertors.conv30_50.datatypes30_50; 002 003import org.hl7.fhir.convertors.context.ConversionContext30_50; 004import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.Attachment30_50; 005import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.String30_50; 006import org.hl7.fhir.exceptions.FHIRException; 007 008public class RelatedArtifact30_50 { 009 public static org.hl7.fhir.r5.model.RelatedArtifact convertRelatedArtifact(org.hl7.fhir.dstu3.model.RelatedArtifact src) throws FHIRException { 010 if (src == null) return null; 011 org.hl7.fhir.r5.model.RelatedArtifact tgt = new org.hl7.fhir.r5.model.RelatedArtifact(); 012 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 013 if (src.hasType()) tgt.setTypeElement(convertRelatedArtifactType(src.getTypeElement())); 014 if (src.hasDisplay()) tgt.setDisplayElement(String30_50.convertString(src.getDisplayElement())); 015 if (src.hasCitation()) tgt.setCitation(src.getCitation()); 016 if (src.hasUrl()) tgt.getDocument().setUrl(src.getUrl()); 017 if (src.hasDocument()) tgt.setDocument(Attachment30_50.convertAttachment(src.getDocument())); 018 if (src.hasResource()) tgt.setResourceElement(Reference30_50.convertReferenceToCanonical(src.getResource())); 019 return tgt; 020 } 021 022 public static org.hl7.fhir.dstu3.model.RelatedArtifact convertRelatedArtifact(org.hl7.fhir.r5.model.RelatedArtifact src) throws FHIRException { 023 if (src == null) return null; 024 org.hl7.fhir.dstu3.model.RelatedArtifact tgt = new org.hl7.fhir.dstu3.model.RelatedArtifact(); 025 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 026 if (src.hasType()) tgt.setTypeElement(convertRelatedArtifactType(src.getTypeElement())); 027 if (src.hasDisplay()) tgt.setDisplayElement(String30_50.convertString(src.getDisplayElement())); 028 if (src.hasCitation()) tgt.setCitation(src.getCitation()); 029 if (src.getDocument().hasUrl()) tgt.setUrl(src.getDocument().getUrl()); 030 if (src.hasDocument()) tgt.setDocument(Attachment30_50.convertAttachment(src.getDocument())); 031 if (src.hasResource()) tgt.setResource(Reference30_50.convertCanonicalToReference(src.getResourceElement())); 032 return tgt; 033 } 034 035 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType> convertRelatedArtifactType(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType> src) throws FHIRException { 036 if (src == null || src.isEmpty()) return null; 037 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactTypeEnumFactory()); 038 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 039 if (src.getValue() == null) { 040 tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.NULL); 041 } else { 042 switch (src.getValue()) { 043 case DOCUMENTATION: 044 tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.DOCUMENTATION); 045 break; 046 case JUSTIFICATION: 047 tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.JUSTIFICATION); 048 break; 049 case CITATION: 050 tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.CITATION); 051 break; 052 case PREDECESSOR: 053 tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.PREDECESSOR); 054 break; 055 case SUCCESSOR: 056 tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.SUCCESSOR); 057 break; 058 case DERIVEDFROM: 059 tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.DERIVEDFROM); 060 break; 061 case DEPENDSON: 062 tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.DEPENDSON); 063 break; 064 case COMPOSEDOF: 065 tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.COMPOSEDOF); 066 break; 067 default: 068 tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.NULL); 069 break; 070 } 071 } 072 return tgt; 073 } 074 075 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType> convertRelatedArtifactType(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType> src) throws FHIRException { 076 if (src == null || src.isEmpty()) return null; 077 org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactTypeEnumFactory()); 078 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 079 if (src.getValue() == null) { 080 tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.NULL); 081 } else { 082 switch (src.getValue()) { 083 case DOCUMENTATION: 084 tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.DOCUMENTATION); 085 break; 086 case JUSTIFICATION: 087 tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.JUSTIFICATION); 088 break; 089 case CITATION: 090 tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.CITATION); 091 break; 092 case PREDECESSOR: 093 tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.PREDECESSOR); 094 break; 095 case SUCCESSOR: 096 tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.SUCCESSOR); 097 break; 098 case DERIVEDFROM: 099 tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.DERIVEDFROM); 100 break; 101 case DEPENDSON: 102 tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.DEPENDSON); 103 break; 104 case COMPOSEDOF: 105 tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.COMPOSEDOF); 106 break; 107 default: 108 tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.NULL); 109 break; 110 } 111 } 112 return tgt; 113 } 114}