001package org.hl7.fhir.convertors.conv30_50.resources30_50;
002
003import org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus;
004import org.hl7.fhir.dstu3.model.ExpansionProfile.DesignationIncludeDesignationComponent;
005import org.hl7.fhir.dstu3.model.ExpansionProfile.SystemVersionProcessingMode;
006import org.hl7.fhir.exceptions.FHIRException;
007import org.hl7.fhir.r5.model.DataType;
008
009public class ExpansionProfile30_50 {
010
011  public static org.hl7.fhir.dstu3.model.ExpansionProfile convertExpansionProfile(org.hl7.fhir.r5.model.Parameters src) throws FHIRException {
012    if (src == null)
013      return null;
014    org.hl7.fhir.dstu3.model.ExpansionProfile tgt = new org.hl7.fhir.dstu3.model.ExpansionProfile();
015    if (src.hasParameter("profile-url"))
016      tgt.setUrl(src.getParameter("profile-url").primitiveValue());
017    if (src.hasParameter("profile-version"))
018      tgt.setVersion(src.getParameter("profile-version").primitiveValue());
019    if (src.hasParameter("profile-name"))
020      tgt.setName(src.getParameter("profile-name").primitiveValue());
021    if (src.hasParameter("profile-status"))
022      tgt.setStatus(PublicationStatus.fromCode(src.getParameter("profile-status").primitiveValue()));
023    for (DataType t : src.getParameters("system-version")) {
024      String[] v = t.primitiveValue().split("\\|");
025      tgt.addFixedVersion().setSystem(v[0]).setVersion(v[1]).setMode(SystemVersionProcessingMode.DEFAULT);
026    }
027    for (DataType t : src.getParameters("force-system-version")) {
028      String[] v = t.primitiveValue().split("\\|");
029      tgt.addFixedVersion().setSystem(v[0]).setVersion(v[1]).setMode(SystemVersionProcessingMode.OVERRIDE);
030    }
031    for (DataType t : src.getParameters("check-system-version")) {
032      String[] v = t.primitiveValue().split("\\|");
033      tgt.addFixedVersion().setSystem(v[0]).setVersion(v[1]).setMode(SystemVersionProcessingMode.CHECK);
034    }
035    for (DataType t : src.getParameters("exclude-system")) {
036      String[] v = t.primitiveValue().split("\\|");
037      tgt.getExcludedSystem().setSystem(v[0]).setVersion(v[1]);
038    }
039    if (src.hasParameter("includeDesignations"))
040      tgt.setIncludeDesignations(src.getParameterBool(""));
041    for (DataType t : src.getParameters("designation")) {
042      String[] v = t.primitiveValue().split("\\|");
043      if ("urn:ietf:bcp:47".equals(v[0]))
044        tgt.getDesignation().getInclude().addDesignation().setLanguage(v[1]);
045      else
046        tgt.getDesignation().getInclude().addDesignation().getUse().setSystem(v[0]).setCode(v[1]);
047    }
048    if (src.hasParameter("includeDefinition"))
049      tgt.setIncludeDefinition(src.getParameterBool("includeDefinition"));
050    if (src.hasParameter("activeOnly"))
051      tgt.setActiveOnly(src.getParameterBool("activeOnly"));
052    if (src.hasParameter("excludeNested"))
053      tgt.setExcludeNested(src.getParameterBool("excludeNested"));
054    if (src.hasParameter("excludeNotForUI"))
055      tgt.setExcludeNotForUI(src.getParameterBool("excludeNotForUI"));
056    if (src.hasParameter("excludeNotForUI"))
057      tgt.setExcludePostCoordinated(src.getParameterBool("excludeNotForUI"));
058    if (src.hasParameter("displayLanguage"))
059      tgt.setDisplayLanguage(src.getParameter("displayLanguage").primitiveValue());
060    if (src.hasParameter("limitedExpansion"))
061      tgt.setLimitedExpansion(src.getParameterBool("getParameterBool"));
062    return tgt;
063  }
064
065  public static org.hl7.fhir.r5.model.Parameters convertExpansionProfile(org.hl7.fhir.dstu3.model.ExpansionProfile src) throws FHIRException {
066    if (src == null)
067      return null;
068    org.hl7.fhir.r5.model.Parameters tgt = new org.hl7.fhir.r5.model.Parameters();
069    if (src.hasUrl())
070      tgt.addParameter("profile-url", src.getUrl());
071    if (src.hasVersion())
072      tgt.addParameter("profile-version", src.getVersion());
073    if (src.hasName())
074      tgt.addParameter("profile-name", src.getName());
075    if (src.hasStatus())
076      tgt.addParameter("profile-status", src.getStatus().toCode());
077    for (org.hl7.fhir.dstu3.model.ExpansionProfile.ExpansionProfileFixedVersionComponent t : src.getFixedVersion()) {
078      if (t.getMode() == SystemVersionProcessingMode.DEFAULT)
079        tgt.addParameter("system-version", t.getSystem() + "|" + t.getVersion());
080      else if (t.getMode() == SystemVersionProcessingMode.CHECK)
081        tgt.addParameter("check-system-version", t.getSystem() + "|" + t.getVersion());
082      else if (t.getMode() == SystemVersionProcessingMode.OVERRIDE)
083        tgt.addParameter("force-system-version", t.getSystem() + "|" + t.getVersion());
084    }
085    if (src.hasExcludedSystem()) {
086      tgt.addParameter("exclude-system", src.getExcludedSystem().getSystem() + "|" + src.getExcludedSystem().getVersion());
087    }
088    if (src.hasIncludeDesignations())
089      tgt.addParameter("includeDesignations", src.getIncludeDesignations());
090    for (DesignationIncludeDesignationComponent t : src.getDesignation().getInclude().getDesignation()) {
091      if (t.hasLanguage())
092        tgt.addParameter("designation", "urn:ietf:bcp:47|" + t.getLanguage());
093      if (t.hasUse())
094        tgt.addParameter("designation", t.getUse().getSystem() + "|" + t.getUse().getCode());
095    }
096    if (src.hasIncludeDefinition())
097      tgt.addParameter("includeDefinition", src.getIncludeDefinition());
098    if (src.hasActiveOnly())
099      tgt.addParameter("activeOnly", src.getActiveOnly());
100    if (src.hasExcludeNested())
101      tgt.addParameter("excludeNested", src.getExcludeNested());
102    if (src.hasExcludeNotForUI())
103      tgt.addParameter("excludeNotForUI", src.getExcludeNotForUI());
104    if (src.hasExcludePostCoordinated())
105      tgt.addParameter("excludePostCoordinated", src.getExcludePostCoordinated());
106    if (src.hasDisplayLanguage())
107      tgt.addParameter("excludePostCoordinated", src.getDisplayLanguage());
108    if (src.hasLimitedExpansion())
109      tgt.addParameter("limitedExpansion", src.getLimitedExpansion());
110    return tgt;
111  }
112}