001package org.hl7.fhir.convertors.conv10_30.resources10_30;
002
003import org.hl7.fhir.convertors.context.ConversionContext10_30;
004import org.hl7.fhir.convertors.conv10_30.datatypes10_30.complextypes10_30.ContactPoint10_30;
005import org.hl7.fhir.convertors.conv10_30.datatypes10_30.primitivetypes10_30.Boolean10_30;
006import org.hl7.fhir.convertors.conv10_30.datatypes10_30.primitivetypes10_30.Code10_30;
007import org.hl7.fhir.convertors.conv10_30.datatypes10_30.primitivetypes10_30.DateTime10_30;
008import org.hl7.fhir.convertors.conv10_30.datatypes10_30.primitivetypes10_30.String10_30;
009import org.hl7.fhir.convertors.conv10_30.datatypes10_30.primitivetypes10_30.Uri10_30;
010import org.hl7.fhir.dstu2.utils.ToolingExtensions;
011import org.hl7.fhir.exceptions.FHIRException;
012
013public class SearchParameter10_30 {
014
015  public static org.hl7.fhir.dstu2.model.SearchParameter convertSearchParameter(org.hl7.fhir.dstu3.model.SearchParameter src) throws FHIRException {
016    if (src == null || src.isEmpty())
017      return null;
018    org.hl7.fhir.dstu2.model.SearchParameter tgt = new org.hl7.fhir.dstu2.model.SearchParameter();
019    ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyDomainResource(src, tgt);
020    if (src.hasUrlElement())
021      tgt.setUrlElement(Uri10_30.convertUri(src.getUrlElement()));
022    if (src.hasNameElement())
023      tgt.setNameElement(String10_30.convertString(src.getNameElement()));
024    if (src.hasStatus())
025      tgt.setStatusElement(Enumerations10_30.convertConformanceResourceStatus(src.getStatusElement()));
026    if (src.hasExperimental())
027      tgt.setExperimentalElement(Boolean10_30.convertBoolean(src.getExperimentalElement()));
028    if (src.hasDate())
029      tgt.setDateElement(DateTime10_30.convertDateTime(src.getDateElement()));
030    if (src.hasPublisherElement())
031      tgt.setPublisherElement(String10_30.convertString(src.getPublisherElement()));
032    for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact())
033      tgt.addContact(convertSearchParameterContactComponent(t));
034    if (src.hasPurpose())
035      tgt.setRequirements(src.getPurpose());
036    if (src.hasCodeElement())
037      tgt.setCodeElement(Code10_30.convertCode(src.getCodeElement()));
038    for (org.hl7.fhir.dstu3.model.CodeType t : src.getBase()) tgt.setBase(t.asStringValue());
039    if (src.hasType())
040      tgt.setTypeElement(convertSearchParamType(src.getTypeElement()));
041    if (src.hasDescription())
042      tgt.setDescription(src.getDescription());
043    org.hl7.fhir.dstu2.utils.ToolingExtensions.setStringExtension(tgt, ToolingExtensions.EXT_EXPRESSION, src.getExpression());
044    if (src.hasXpathElement())
045      tgt.setXpathElement(String10_30.convertString(src.getXpathElement()));
046    if (src.hasXpathUsage())
047      tgt.setXpathUsageElement(convertXPathUsageType(src.getXpathUsageElement()));
048    for (org.hl7.fhir.dstu3.model.CodeType t : src.getTarget()) tgt.addTarget(t.getValue());
049    return tgt;
050  }
051
052  public static org.hl7.fhir.dstu3.model.SearchParameter convertSearchParameter(org.hl7.fhir.dstu2.model.SearchParameter src) throws FHIRException {
053    if (src == null || src.isEmpty())
054      return null;
055    org.hl7.fhir.dstu3.model.SearchParameter tgt = new org.hl7.fhir.dstu3.model.SearchParameter();
056    ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyDomainResource(src, tgt);
057    if (src.hasUrlElement())
058      tgt.setUrlElement(Uri10_30.convertUri(src.getUrlElement()));
059    if (src.hasNameElement())
060      tgt.setNameElement(String10_30.convertString(src.getNameElement()));
061    if (src.hasStatus())
062      tgt.setStatusElement(Enumerations10_30.convertConformanceResourceStatus(src.getStatusElement()));
063    if (src.hasExperimental())
064      tgt.setExperimentalElement(Boolean10_30.convertBoolean(src.getExperimentalElement()));
065    if (src.hasDate())
066      tgt.setDateElement(DateTime10_30.convertDateTime(src.getDateElement()));
067    if (src.hasPublisherElement())
068      tgt.setPublisherElement(String10_30.convertString(src.getPublisherElement()));
069    for (org.hl7.fhir.dstu2.model.SearchParameter.SearchParameterContactComponent t : src.getContact())
070      tgt.addContact(convertSearchParameterContactComponent(t));
071    if (src.hasRequirements())
072      tgt.setPurpose(src.getRequirements());
073    if (src.hasCodeElement())
074      tgt.setCodeElement(Code10_30.convertCode(src.getCodeElement()));
075    tgt.addBase(src.getBase());
076    if (src.hasType())
077      tgt.setTypeElement(convertSearchParamType(src.getTypeElement()));
078    if (src.hasDescription())
079      tgt.setDescription(src.getDescription());
080    tgt.setExpression(ToolingExtensions.readStringExtension(src, ToolingExtensions.EXT_EXPRESSION));
081    if (src.hasXpathElement())
082      tgt.setXpathElement(String10_30.convertString(src.getXpathElement()));
083    if (src.hasXpathUsage())
084      tgt.setXpathUsageElement(convertXPathUsageType(src.getXpathUsageElement()));
085    for (org.hl7.fhir.dstu2.model.CodeType t : src.getTarget()) tgt.addTarget(t.getValue());
086    return tgt;
087  }
088
089  public static org.hl7.fhir.dstu2.model.SearchParameter.SearchParameterContactComponent convertSearchParameterContactComponent(org.hl7.fhir.dstu3.model.ContactDetail src) throws FHIRException {
090    if (src == null || src.isEmpty())
091      return null;
092    org.hl7.fhir.dstu2.model.SearchParameter.SearchParameterContactComponent tgt = new org.hl7.fhir.dstu2.model.SearchParameter.SearchParameterContactComponent();
093    ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt);
094    if (src.hasNameElement())
095      tgt.setNameElement(String10_30.convertString(src.getNameElement()));
096    for (org.hl7.fhir.dstu3.model.ContactPoint t : src.getTelecom())
097      tgt.addTelecom(ContactPoint10_30.convertContactPoint(t));
098    return tgt;
099  }
100
101  public static org.hl7.fhir.dstu3.model.ContactDetail convertSearchParameterContactComponent(org.hl7.fhir.dstu2.model.SearchParameter.SearchParameterContactComponent src) throws FHIRException {
102    if (src == null || src.isEmpty())
103      return null;
104    org.hl7.fhir.dstu3.model.ContactDetail tgt = new org.hl7.fhir.dstu3.model.ContactDetail();
105    ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt);
106    if (src.hasNameElement())
107      tgt.setNameElement(String10_30.convertString(src.getNameElement()));
108    for (org.hl7.fhir.dstu2.model.ContactPoint t : src.getTelecom())
109      tgt.addTelecom(ContactPoint10_30.convertContactPoint(t));
110    return tgt;
111  }
112
113  static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.SearchParameter.XPathUsageType> convertXPathUsageType(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType> src) throws FHIRException {
114    if (src == null || src.isEmpty())
115      return null;
116    org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.SearchParameter.XPathUsageType> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.SearchParameter.XPathUsageTypeEnumFactory());
117    ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt);
118    tgt.setValue(convertXPathUsageType(src.getValue()));
119    return tgt;
120  }
121
122  static public org.hl7.fhir.dstu2.model.SearchParameter.XPathUsageType convertXPathUsageType(org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType src) throws FHIRException {
123    switch (src) {
124      case NORMAL:
125        return org.hl7.fhir.dstu2.model.SearchParameter.XPathUsageType.NORMAL;
126      case PHONETIC:
127        return org.hl7.fhir.dstu2.model.SearchParameter.XPathUsageType.PHONETIC;
128      case NEARBY:
129        return org.hl7.fhir.dstu2.model.SearchParameter.XPathUsageType.NEARBY;
130      case DISTANCE:
131        return org.hl7.fhir.dstu2.model.SearchParameter.XPathUsageType.DISTANCE;
132      case OTHER:
133        return org.hl7.fhir.dstu2.model.SearchParameter.XPathUsageType.OTHER;
134      default:
135        return org.hl7.fhir.dstu2.model.SearchParameter.XPathUsageType.NULL;
136    }
137  }
138
139  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType> convertXPathUsageType(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.SearchParameter.XPathUsageType> src) throws FHIRException {
140    if (src == null || src.isEmpty())
141      return null;
142    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());
143    ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt);
144    switch (src.getValue()) {
145      case NORMAL:
146        tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType.NORMAL);
147        break;
148      case PHONETIC:
149        tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType.PHONETIC);
150        break;
151      case NEARBY:
152        tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType.NEARBY);
153        break;
154      case DISTANCE:
155        tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType.DISTANCE);
156        break;
157      case OTHER:
158        tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType.OTHER);
159        break;
160      default:
161        tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType.NULL);
162        break;
163    }
164    return tgt;
165  }
166
167  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Enumerations.SearchParamType> convertSearchParamType(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Enumerations.SearchParamType> src) throws FHIRException {
168    if (src == null || src.isEmpty()) return null;
169    org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Enumerations.SearchParamType> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.SearchParamTypeEnumFactory());
170    ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt);
171    tgt.setValue(convertSearchParamType(src.getValue()));
172    return tgt;
173  }
174
175  static public org.hl7.fhir.dstu3.model.Enumerations.SearchParamType convertSearchParamType(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType src) throws FHIRException {
176    switch (src) {
177      case NUMBER:
178        return org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.NUMBER;
179      case DATE:
180        return org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.DATE;
181      case STRING:
182        return org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.STRING;
183      case TOKEN:
184        return org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.TOKEN;
185      case REFERENCE:
186        return org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.REFERENCE;
187      case COMPOSITE:
188        return org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.COMPOSITE;
189      case QUANTITY:
190        return org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.QUANTITY;
191      case URI:
192        return org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.URI;
193      default:
194        return org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.NULL;
195    }
196  }
197
198  static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Enumerations.SearchParamType> convertSearchParamType(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Enumerations.SearchParamType> src) throws FHIRException {
199    if (src == null || src.isEmpty()) return null;
200    org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Enumerations.SearchParamType> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Enumerations.SearchParamTypeEnumFactory());
201    ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt);
202    if (src.getValue() == null) {
203      tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.NULL);
204    } else {
205      switch (src.getValue()) {
206        case NUMBER:
207          tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.NUMBER);
208          break;
209        case DATE:
210          tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.DATE);
211          break;
212        case STRING:
213          tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.STRING);
214          break;
215        case TOKEN:
216          tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.TOKEN);
217          break;
218        case REFERENCE:
219          tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.REFERENCE);
220          break;
221        case COMPOSITE:
222          tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.COMPOSITE);
223          break;
224        case QUANTITY:
225          tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.QUANTITY);
226          break;
227        case URI:
228          tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.URI);
229          break;
230        default:
231          tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.NULL);
232          break;
233      }
234    }
235    return tgt;
236  }
237}