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