001package org.hl7.fhir.convertors.conv43_50.datatypes43_50.metadata43_50; 002 003import org.hl7.fhir.convertors.context.ConversionContext43_50; 004import org.hl7.fhir.convertors.conv43_50.Utilities43_50; 005import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Canonical43_50; 006import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Code43_50; 007import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Integer43_50; 008import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.String43_50; 009import org.hl7.fhir.exceptions.FHIRException; 010 011public class ParameterDefinition43_50 { 012 public static org.hl7.fhir.r5.model.ParameterDefinition convertParameterDefinition(org.hl7.fhir.r4b.model.ParameterDefinition src) throws FHIRException { 013 if (src == null) return null; 014 org.hl7.fhir.r5.model.ParameterDefinition tgt = new org.hl7.fhir.r5.model.ParameterDefinition(); 015 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); 016 if (src.hasName()) tgt.setNameElement(Code43_50.convertCode(src.getNameElement())); 017 if (src.hasUse()) tgt.setUseElement(convertParameterUse(src.getUseElement())); 018 if (src.hasMin()) tgt.setMinElement(Integer43_50.convertInteger(src.getMinElement())); 019 if (src.hasMax()) tgt.setMaxElement(String43_50.convertString(src.getMaxElement())); 020 if (src.hasDocumentation()) tgt.setDocumentationElement(String43_50.convertString(src.getDocumentationElement())); 021 if (src.hasType()) { 022 Utilities43_50.convertType(src.getTypeElement(), tgt.getTypeElement()); 023 } 024 if (src.hasProfile()) tgt.setProfileElement(Canonical43_50.convertCanonical(src.getProfileElement())); 025 return tgt; 026 } 027 028 public static org.hl7.fhir.r4b.model.ParameterDefinition convertParameterDefinition(org.hl7.fhir.r5.model.ParameterDefinition src) throws FHIRException { 029 if (src == null) return null; 030 org.hl7.fhir.r4b.model.ParameterDefinition tgt = new org.hl7.fhir.r4b.model.ParameterDefinition(); 031 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); 032 if (src.hasName()) tgt.setNameElement(Code43_50.convertCode(src.getNameElement())); 033 if (src.hasUse()) tgt.setUseElement(convertParameterUse(src.getUseElement())); 034 if (src.hasMin()) tgt.setMinElement(Integer43_50.convertInteger(src.getMinElement())); 035 if (src.hasMax()) tgt.setMaxElement(String43_50.convertString(src.getMaxElement())); 036 if (src.hasDocumentation()) tgt.setDocumentationElement(String43_50.convertString(src.getDocumentationElement())); 037 if (src.hasType()) { 038 Utilities43_50.convertType(src.getTypeElement(), tgt.getTypeElement()); 039 } 040 if (src.hasProfile()) tgt.setProfileElement(Canonical43_50.convertCanonical(src.getProfileElement())); 041 return tgt; 042 } 043 044 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.OperationParameterUse> convertParameterUse(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Enumerations.OperationParameterUse> src) throws FHIRException { 045 if (src == null || src.isEmpty()) return null; 046 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.OperationParameterUse> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.OperationParameterUseEnumFactory()); 047 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); 048 if (src.getValue() == null) { 049 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.OperationParameterUse.NULL); 050 } else { 051 switch (src.getValue()) { 052 case IN: 053 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.OperationParameterUse.IN); 054 break; 055 case OUT: 056 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.OperationParameterUse.OUT); 057 break; 058 default: 059 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.OperationParameterUse.NULL); 060 break; 061 } 062 } 063 return tgt; 064 } 065 066 static public org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Enumerations.OperationParameterUse> convertParameterUse(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.OperationParameterUse> src) throws FHIRException { 067 if (src == null || src.isEmpty()) return null; 068 org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Enumerations.OperationParameterUse> tgt = new org.hl7.fhir.r4b.model.Enumeration<>(new org.hl7.fhir.r4b.model.Enumerations.OperationParameterUseEnumFactory()); 069 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); 070 if (src.getValue() == null) { 071 tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.OperationParameterUse.NULL); 072 } else { 073 switch (src.getValue()) { 074 case IN: 075 tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.OperationParameterUse.IN); 076 break; 077 case OUT: 078 tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.OperationParameterUse.OUT); 079 break; 080 default: 081 tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.OperationParameterUse.NULL); 082 break; 083 } 084 } 085 return tgt; 086 } 087}