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