001package org.hl7.fhir.convertors.conv40_50.datatypes40_50.metadata40_50;
002
003import org.hl7.fhir.convertors.context.ConversionContext40_50;
004import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Canonical40_50;
005import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Code40_50;
006import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Integer40_50;
007import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.String40_50;
008import org.hl7.fhir.exceptions.FHIRException;
009
010public class ParameterDefinition40_50 {
011  public static org.hl7.fhir.r5.model.ParameterDefinition convertParameterDefinition(org.hl7.fhir.r4.model.ParameterDefinition src) throws FHIRException {
012    if (src == null) return null;
013    org.hl7.fhir.r5.model.ParameterDefinition tgt = new org.hl7.fhir.r5.model.ParameterDefinition();
014    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
015    if (src.hasName()) tgt.setNameElement(Code40_50.convertCode(src.getNameElement()));
016    if (src.hasUse()) tgt.setUseElement(convertParameterUse(src.getUseElement()));
017    if (src.hasMin()) tgt.setMinElement(Integer40_50.convertInteger(src.getMinElement()));
018    if (src.hasMax()) tgt.setMaxElement(String40_50.convertString(src.getMaxElement()));
019    if (src.hasDocumentation()) tgt.setDocumentationElement(String40_50.convertString(src.getDocumentationElement()));
020    if (src.hasType()) tgt.setType(org.hl7.fhir.r5.model.Enumerations.FHIRAllTypes.fromCode(src.getType()));
021    if (src.hasProfile()) tgt.setProfileElement(Canonical40_50.convertCanonical(src.getProfileElement()));
022    return tgt;
023  }
024
025  public static org.hl7.fhir.r4.model.ParameterDefinition convertParameterDefinition(org.hl7.fhir.r5.model.ParameterDefinition src) throws FHIRException {
026    if (src == null) return null;
027    org.hl7.fhir.r4.model.ParameterDefinition tgt = new org.hl7.fhir.r4.model.ParameterDefinition();
028    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
029    if (src.hasName()) tgt.setNameElement(Code40_50.convertCode(src.getNameElement()));
030    if (src.hasUse()) tgt.setUseElement(convertParameterUse(src.getUseElement()));
031    if (src.hasMin()) tgt.setMinElement(Integer40_50.convertInteger(src.getMinElement()));
032    if (src.hasMax()) tgt.setMaxElement(String40_50.convertString(src.getMaxElement()));
033    if (src.hasDocumentation()) tgt.setDocumentationElement(String40_50.convertString(src.getDocumentationElement()));
034    if (src.hasType()) tgt.setType(src.getType().toCode());
035    if (src.hasProfile()) tgt.setProfileElement(Canonical40_50.convertCanonical(src.getProfileElement()));
036    return tgt;
037  }
038
039  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.OperationParameterUse> convertParameterUse(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ParameterDefinition.ParameterUse> src) throws FHIRException {
040    if (src == null || src.isEmpty()) return null;
041    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());
042    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
043    if (src.getValue() == null) {
044      tgt.setValue(org.hl7.fhir.r5.model.Enumerations.OperationParameterUse.NULL);
045    } else {
046      switch (src.getValue()) {
047        case IN:
048          tgt.setValue(org.hl7.fhir.r5.model.Enumerations.OperationParameterUse.IN);
049          break;
050        case OUT:
051          tgt.setValue(org.hl7.fhir.r5.model.Enumerations.OperationParameterUse.OUT);
052          break;
053        default:
054          tgt.setValue(org.hl7.fhir.r5.model.Enumerations.OperationParameterUse.NULL);
055          break;
056      }
057    }
058    return tgt;
059  }
060
061  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ParameterDefinition.ParameterUse> convertParameterUse(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.OperationParameterUse> src) throws FHIRException {
062    if (src == null || src.isEmpty()) return null;
063    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ParameterDefinition.ParameterUse> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ParameterDefinition.ParameterUseEnumFactory());
064    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
065    if (src.getValue() == null) {
066      tgt.setValue(org.hl7.fhir.r4.model.ParameterDefinition.ParameterUse.NULL);
067    } else {
068      switch (src.getValue()) {
069        case IN:
070          tgt.setValue(org.hl7.fhir.r4.model.ParameterDefinition.ParameterUse.IN);
071          break;
072        case OUT:
073          tgt.setValue(org.hl7.fhir.r4.model.ParameterDefinition.ParameterUse.OUT);
074          break;
075        default:
076          tgt.setValue(org.hl7.fhir.r4.model.ParameterDefinition.ParameterUse.NULL);
077          break;
078      }
079    }
080    return tgt;
081  }
082}