001package org.hl7.fhir.convertors.conv30_50.resources30_50;
002
003import org.hl7.fhir.convertors.context.ConversionContext30_50;
004import org.hl7.fhir.convertors.conv30_50.datatypes30_50.ContactDetail30_50;
005import org.hl7.fhir.convertors.conv30_50.datatypes30_50.UsageContext30_50;
006import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.CodeableConcept30_50;
007import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.*;
008import org.hl7.fhir.exceptions.FHIRException;
009
010public class CompartmentDefinition30_50 {
011
012  public static org.hl7.fhir.r5.model.CompartmentDefinition convertCompartmentDefinition(org.hl7.fhir.dstu3.model.CompartmentDefinition src) throws FHIRException {
013    if (src == null)
014      return null;
015    org.hl7.fhir.r5.model.CompartmentDefinition tgt = new org.hl7.fhir.r5.model.CompartmentDefinition();
016    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
017    if (src.hasUrl())
018      tgt.setUrlElement(Uri30_50.convertUri(src.getUrlElement()));
019    if (src.hasName())
020      tgt.setNameElement(String30_50.convertString(src.getNameElement()));
021    if (src.hasTitle())
022      tgt.setTitleElement(String30_50.convertString(src.getTitleElement()));
023    if (src.hasStatus())
024      tgt.setStatusElement(Enumerations30_50.convertPublicationStatus(src.getStatusElement()));
025    if (src.hasExperimental())
026      tgt.setExperimentalElement(Boolean30_50.convertBoolean(src.getExperimentalElement()));
027    if (src.hasDate())
028      tgt.setDateElement(DateTime30_50.convertDateTime(src.getDateElement()));
029    if (src.hasPublisher())
030      tgt.setPublisherElement(String30_50.convertString(src.getPublisherElement()));
031    for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact())
032      tgt.addContact(ContactDetail30_50.convertContactDetail(t));
033    if (src.hasDescription())
034      tgt.setDescriptionElement(MarkDown30_50.convertMarkdown(src.getDescriptionElement()));
035    if (src.hasPurpose())
036      tgt.setPurposeElement(MarkDown30_50.convertMarkdown(src.getPurposeElement()));
037    for (org.hl7.fhir.dstu3.model.UsageContext t : src.getUseContext())
038      tgt.addUseContext(UsageContext30_50.convertUsageContext(t));
039    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getJurisdiction())
040      tgt.addJurisdiction(CodeableConcept30_50.convertCodeableConcept(t));
041    if (src.hasCode())
042      tgt.setCodeElement(convertCompartmentType(src.getCodeElement()));
043    if (src.hasSearch())
044      tgt.setSearchElement(Boolean30_50.convertBoolean(src.getSearchElement()));
045    for (org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentDefinitionResourceComponent t : src.getResource())
046      tgt.addResource(convertCompartmentDefinitionResourceComponent(t));
047    return tgt;
048  }
049
050  public static org.hl7.fhir.dstu3.model.CompartmentDefinition convertCompartmentDefinition(org.hl7.fhir.r5.model.CompartmentDefinition src) throws FHIRException {
051    if (src == null)
052      return null;
053    org.hl7.fhir.dstu3.model.CompartmentDefinition tgt = new org.hl7.fhir.dstu3.model.CompartmentDefinition();
054    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
055    if (src.hasUrl())
056      tgt.setUrlElement(Uri30_50.convertUri(src.getUrlElement()));
057    if (src.hasName())
058      tgt.setNameElement(String30_50.convertString(src.getNameElement()));
059    if (src.hasTitle())
060      tgt.setTitleElement(String30_50.convertString(src.getTitleElement()));
061    if (src.hasStatus())
062      tgt.setStatusElement(Enumerations30_50.convertPublicationStatus(src.getStatusElement()));
063    if (src.hasExperimental())
064      tgt.setExperimentalElement(Boolean30_50.convertBoolean(src.getExperimentalElement()));
065    if (src.hasDate())
066      tgt.setDateElement(DateTime30_50.convertDateTime(src.getDateElement()));
067    if (src.hasPublisher())
068      tgt.setPublisherElement(String30_50.convertString(src.getPublisherElement()));
069    for (org.hl7.fhir.r5.model.ContactDetail t : src.getContact())
070      tgt.addContact(ContactDetail30_50.convertContactDetail(t));
071    if (src.hasDescription())
072      tgt.setDescriptionElement(MarkDown30_50.convertMarkdown(src.getDescriptionElement()));
073    if (src.hasPurpose())
074      tgt.setPurposeElement(MarkDown30_50.convertMarkdown(src.getPurposeElement()));
075    for (org.hl7.fhir.r5.model.UsageContext t : src.getUseContext())
076      tgt.addUseContext(UsageContext30_50.convertUsageContext(t));
077    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getJurisdiction())
078      tgt.addJurisdiction(CodeableConcept30_50.convertCodeableConcept(t));
079    if (src.hasCode())
080      tgt.setCodeElement(convertCompartmentType(src.getCodeElement()));
081    if (src.hasSearch())
082      tgt.setSearchElement(Boolean30_50.convertBoolean(src.getSearchElement()));
083    for (org.hl7.fhir.r5.model.CompartmentDefinition.CompartmentDefinitionResourceComponent t : src.getResource())
084      tgt.addResource(convertCompartmentDefinitionResourceComponent(t));
085    return tgt;
086  }
087
088  public static org.hl7.fhir.r5.model.CompartmentDefinition.CompartmentDefinitionResourceComponent convertCompartmentDefinitionResourceComponent(org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentDefinitionResourceComponent src) throws FHIRException {
089    if (src == null)
090      return null;
091    org.hl7.fhir.r5.model.CompartmentDefinition.CompartmentDefinitionResourceComponent tgt = new org.hl7.fhir.r5.model.CompartmentDefinition.CompartmentDefinitionResourceComponent();
092    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
093    if (src.hasCode())
094      tgt.setCodeElement(Code30_50.convertCode(src.getCodeElement()));
095    for (org.hl7.fhir.dstu3.model.StringType t : src.getParam()) tgt.addParam(t.getValue());
096    if (src.hasDocumentation())
097      tgt.setDocumentationElement(String30_50.convertString(src.getDocumentationElement()));
098    return tgt;
099  }
100
101  public static org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentDefinitionResourceComponent convertCompartmentDefinitionResourceComponent(org.hl7.fhir.r5.model.CompartmentDefinition.CompartmentDefinitionResourceComponent src) throws FHIRException {
102    if (src == null)
103      return null;
104    org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentDefinitionResourceComponent tgt = new org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentDefinitionResourceComponent();
105    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
106    if (src.hasCode())
107      tgt.setCodeElement(Code30_50.convertCode(src.getCodeElement()));
108    for (org.hl7.fhir.r5.model.StringType t : src.getParam()) tgt.addParam(t.getValue());
109    if (src.hasDocumentation())
110      tgt.setDocumentationElement(String30_50.convertString(src.getDocumentationElement()));
111    return tgt;
112  }
113
114  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentType> convertCompartmentType(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.CompartmentType> src) throws FHIRException {
115    if (src == null || src.isEmpty())
116      return null;
117    org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentType> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentTypeEnumFactory());
118    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
119    switch (src.getValue()) {
120      case PATIENT:
121        tgt.setValue(org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentType.PATIENT);
122        break;
123      case ENCOUNTER:
124        tgt.setValue(org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentType.ENCOUNTER);
125        break;
126      case RELATEDPERSON:
127        tgt.setValue(org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentType.RELATEDPERSON);
128        break;
129      case PRACTITIONER:
130        tgt.setValue(org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentType.PRACTITIONER);
131        break;
132      case DEVICE:
133        tgt.setValue(org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentType.DEVICE);
134        break;
135      default:
136        tgt.setValue(org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentType.NULL);
137        break;
138    }
139    return tgt;
140  }
141
142  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.CompartmentType> convertCompartmentType(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentType> src) throws FHIRException {
143    if (src == null || src.isEmpty())
144      return null;
145    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.CompartmentType> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.CompartmentTypeEnumFactory());
146    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
147    switch (src.getValue()) {
148      case PATIENT:
149        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.CompartmentType.PATIENT);
150        break;
151      case ENCOUNTER:
152        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.CompartmentType.ENCOUNTER);
153        break;
154      case RELATEDPERSON:
155        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.CompartmentType.RELATEDPERSON);
156        break;
157      case PRACTITIONER:
158        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.CompartmentType.PRACTITIONER);
159        break;
160      case DEVICE:
161        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.CompartmentType.DEVICE);
162        break;
163      default:
164        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.CompartmentType.NULL);
165        break;
166    }
167    return tgt;
168  }
169}