001package org.hl7.fhir.convertors.conv14_40.resources14_40;
002
003import org.hl7.fhir.convertors.context.ConversionContext14_40;
004import org.hl7.fhir.convertors.conv14_40.VersionConvertor_14_40;
005import org.hl7.fhir.convertors.conv14_40.datatypes14_40.Expression14_40;
006import org.hl7.fhir.convertors.conv14_40.datatypes14_40.complextypes14_40.CodeableConcept14_40;
007import org.hl7.fhir.convertors.conv14_40.datatypes14_40.complextypes14_40.ContactPoint14_40;
008import org.hl7.fhir.convertors.conv14_40.datatypes14_40.primitivetypes14_40.Boolean14_40;
009import org.hl7.fhir.convertors.conv14_40.datatypes14_40.primitivetypes14_40.Code14_40;
010import org.hl7.fhir.convertors.conv14_40.datatypes14_40.primitivetypes14_40.DateTime14_40;
011import org.hl7.fhir.convertors.conv14_40.datatypes14_40.primitivetypes14_40.String14_40;
012import org.hl7.fhir.convertors.conv14_40.datatypes14_40.primitivetypes14_40.Uri14_40;
013import org.hl7.fhir.exceptions.FHIRException;
014
015public class SearchParameter14_40 {
016
017  public static org.hl7.fhir.r4.model.SearchParameter convertSearchParameter(org.hl7.fhir.dstu2016may.model.SearchParameter src) throws FHIRException {
018    if (src == null || src.isEmpty())
019      return null;
020    org.hl7.fhir.r4.model.SearchParameter tgt = new org.hl7.fhir.r4.model.SearchParameter();
021    ConversionContext14_40.INSTANCE.getVersionConvertor_14_40().copyDomainResource(src, tgt);
022    if (src.hasUrlElement())
023      tgt.setUrlElement(Uri14_40.convertUri(src.getUrlElement()));
024    if (src.hasNameElement())
025      tgt.setNameElement(String14_40.convertString(src.getNameElement()));
026    if (src.hasStatus())
027      tgt.setStatusElement(Enumerations14_40.convertConformanceResourceStatus(src.getStatusElement()));
028    if (src.hasExperimental())
029      tgt.setExperimentalElement(Boolean14_40.convertBoolean(src.getExperimentalElement()));
030    if (src.hasDate())
031      tgt.setDateElement(DateTime14_40.convertDateTime(src.getDateElement()));
032    if (src.hasPublisher())
033      tgt.setPublisherElement(String14_40.convertString(src.getPublisherElement()));
034    for (org.hl7.fhir.dstu2016may.model.SearchParameter.SearchParameterContactComponent t : src.getContact())
035      tgt.addContact(convertSearchParameterContactComponent(t));
036    for (org.hl7.fhir.dstu2016may.model.CodeableConcept t : src.getUseContext())
037      if (VersionConvertor_14_40.isJurisdiction(t))
038        tgt.addJurisdiction(CodeableConcept14_40.convertCodeableConcept(t));
039      else
040        tgt.addUseContext(CodeableConcept14_40.convertCodeableConceptToUsageContext(t));
041    if (src.hasRequirements())
042      tgt.setPurpose(src.getRequirements());
043    if (src.hasCodeElement())
044      tgt.setCodeElement(Code14_40.convertCode(src.getCodeElement()));
045    tgt.addBase(src.getBase());
046    if (src.hasType())
047      tgt.setTypeElement(Enumerations14_40.convertSearchParamType(src.getTypeElement()));
048    if (src.hasDescription())
049      tgt.setDescription(src.getDescription());
050    if (src.hasExpression())
051      tgt.setExpression(Expression14_40.convertToR4Expression(src.getExpression()));
052    if (src.hasXpath())
053      tgt.setXpathElement(String14_40.convertString(src.getXpathElement()));
054    if (src.hasXpathUsage())
055      tgt.setXpathUsageElement(convertXPathUsageType(src.getXpathUsageElement()));
056    for (org.hl7.fhir.dstu2016may.model.CodeType t : src.getTarget()) tgt.addTarget(t.getValue());
057    return tgt;
058  }
059
060  public static org.hl7.fhir.dstu2016may.model.SearchParameter convertSearchParameter(org.hl7.fhir.r4.model.SearchParameter src) throws FHIRException {
061    if (src == null || src.isEmpty())
062      return null;
063    org.hl7.fhir.dstu2016may.model.SearchParameter tgt = new org.hl7.fhir.dstu2016may.model.SearchParameter();
064    ConversionContext14_40.INSTANCE.getVersionConvertor_14_40().copyDomainResource(src, tgt);
065    if (src.hasUrlElement())
066      tgt.setUrlElement(Uri14_40.convertUri(src.getUrlElement()));
067    if (src.hasNameElement())
068      tgt.setNameElement(String14_40.convertString(src.getNameElement()));
069    if (src.hasStatus())
070      tgt.setStatusElement(Enumerations14_40.convertConformanceResourceStatus(src.getStatusElement()));
071    if (src.hasExperimental())
072      tgt.setExperimentalElement(Boolean14_40.convertBoolean(src.getExperimentalElement()));
073    if (src.hasDate())
074      tgt.setDateElement(DateTime14_40.convertDateTime(src.getDateElement()));
075    if (src.hasPublisher())
076      tgt.setPublisherElement(String14_40.convertString(src.getPublisherElement()));
077    for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact())
078      tgt.addContact(convertSearchParameterContactComponent(t));
079    for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext())
080      if (t.hasValueCodeableConcept())
081        tgt.addUseContext(CodeableConcept14_40.convertCodeableConcept(t.getValueCodeableConcept()));
082    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction())
083      tgt.addUseContext(CodeableConcept14_40.convertCodeableConcept(t));
084    if (src.hasPurpose())
085      tgt.setRequirements(src.getPurpose());
086    if (src.hasCodeElement())
087      tgt.setCodeElement(Code14_40.convertCode(src.getCodeElement()));
088    for (org.hl7.fhir.r4.model.CodeType t : src.getBase()) tgt.setBase(t.asStringValue());
089    if (src.hasType())
090      tgt.setTypeElement(Enumerations14_40.convertSearchParamType(src.getTypeElement()));
091    if (src.hasDescription())
092      tgt.setDescription(src.getDescription());
093    if (src.hasExpression())
094      tgt.setExpression(Expression14_40.convertTo2016MayExpression(src.getExpression()));
095    if (src.hasXpath())
096      tgt.setXpathElement(String14_40.convertString(src.getXpathElement()));
097    if (src.hasXpathUsage())
098      tgt.setXpathUsageElement(convertXPathUsageType(src.getXpathUsageElement()));
099    for (org.hl7.fhir.r4.model.CodeType t : src.getTarget()) tgt.addTarget(t.getValue());
100    return tgt;
101  }
102
103  public static org.hl7.fhir.r4.model.ContactDetail convertSearchParameterContactComponent(org.hl7.fhir.dstu2016may.model.SearchParameter.SearchParameterContactComponent src) throws FHIRException {
104    if (src == null || src.isEmpty())
105      return null;
106    org.hl7.fhir.r4.model.ContactDetail tgt = new org.hl7.fhir.r4.model.ContactDetail();
107    ConversionContext14_40.INSTANCE.getVersionConvertor_14_40().copyElement(src, tgt);
108    if (src.hasName())
109      tgt.setNameElement(String14_40.convertString(src.getNameElement()));
110    for (org.hl7.fhir.dstu2016may.model.ContactPoint t : src.getTelecom())
111      tgt.addTelecom(ContactPoint14_40.convertContactPoint(t));
112    return tgt;
113  }
114
115  public static org.hl7.fhir.dstu2016may.model.SearchParameter.SearchParameterContactComponent convertSearchParameterContactComponent(org.hl7.fhir.r4.model.ContactDetail src) throws FHIRException {
116    if (src == null || src.isEmpty())
117      return null;
118    org.hl7.fhir.dstu2016may.model.SearchParameter.SearchParameterContactComponent tgt = new org.hl7.fhir.dstu2016may.model.SearchParameter.SearchParameterContactComponent();
119    ConversionContext14_40.INSTANCE.getVersionConvertor_14_40().copyElement(src, tgt);
120    if (src.hasName())
121      tgt.setNameElement(String14_40.convertString(src.getNameElement()));
122    for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom())
123      tgt.addTelecom(ContactPoint14_40.convertContactPoint(t));
124    return tgt;
125  }
126
127  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.SearchParameter.XPathUsageType> convertXPathUsageType(org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.SearchParameter.XPathUsageType> src) throws FHIRException {
128    if (src == null || src.isEmpty())
129      return null;
130    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.SearchParameter.XPathUsageType> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.SearchParameter.XPathUsageTypeEnumFactory());
131    ConversionContext14_40.INSTANCE.getVersionConvertor_14_40().copyElement(src, tgt);
132    switch (src.getValue()) {
133      case NORMAL:
134        tgt.setValue(org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.NORMAL);
135        break;
136      case PHONETIC:
137        tgt.setValue(org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.PHONETIC);
138        break;
139      case NEARBY:
140        tgt.setValue(org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.NEARBY);
141        break;
142      case DISTANCE:
143        tgt.setValue(org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.DISTANCE);
144        break;
145      case OTHER:
146        tgt.setValue(org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.OTHER);
147        break;
148      default:
149        tgt.setValue(org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.NULL);
150        break;
151    }
152    return tgt;
153  }
154
155  static public org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.SearchParameter.XPathUsageType> convertXPathUsageType(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.SearchParameter.XPathUsageType> src) throws FHIRException {
156    if (src == null || src.isEmpty())
157      return null;
158    org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.SearchParameter.XPathUsageType> tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.SearchParameter.XPathUsageTypeEnumFactory());
159    ConversionContext14_40.INSTANCE.getVersionConvertor_14_40().copyElement(src, tgt);
160    switch (src.getValue()) {
161      case NORMAL:
162        tgt.setValue(org.hl7.fhir.dstu2016may.model.SearchParameter.XPathUsageType.NORMAL);
163        break;
164      case PHONETIC:
165        tgt.setValue(org.hl7.fhir.dstu2016may.model.SearchParameter.XPathUsageType.PHONETIC);
166        break;
167      case NEARBY:
168        tgt.setValue(org.hl7.fhir.dstu2016may.model.SearchParameter.XPathUsageType.NEARBY);
169        break;
170      case DISTANCE:
171        tgt.setValue(org.hl7.fhir.dstu2016may.model.SearchParameter.XPathUsageType.DISTANCE);
172        break;
173      case OTHER:
174        tgt.setValue(org.hl7.fhir.dstu2016may.model.SearchParameter.XPathUsageType.OTHER);
175        break;
176      default:
177        tgt.setValue(org.hl7.fhir.dstu2016may.model.SearchParameter.XPathUsageType.NULL);
178        break;
179    }
180    return tgt;
181  }
182}