001package org.hl7.fhir.convertors.conv30_50.resources30_50;
002
003import java.util.stream.Collectors;
004
005import org.hl7.fhir.convertors.context.ConversionContext30_50;
006import org.hl7.fhir.convertors.conv30_50.datatypes30_50.ContactDetail30_50;
007import org.hl7.fhir.convertors.conv30_50.datatypes30_50.Reference30_50;
008import org.hl7.fhir.convertors.conv30_50.datatypes30_50.UsageContext30_50;
009import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.CodeableConcept30_50;
010import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Boolean30_50;
011import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Code30_50;
012import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.DateTime30_50;
013import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.MarkDown30_50;
014import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.String30_50;
015import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Uri30_50;
016import org.hl7.fhir.exceptions.FHIRException;
017import org.hl7.fhir.r5.model.Enumeration;
018import org.hl7.fhir.r5.model.Enumerations.VersionIndependentResourceTypesAll;
019import org.hl7.fhir.r5.model.Enumerations.VersionIndependentResourceTypesAllEnumFactory;
020
021public class SearchParameter30_50 {
022
023  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.SearchComparator> convertSearchComparator(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator> src) throws FHIRException {
024    if (src == null || src.isEmpty())
025      return null;
026    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.SearchComparator> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.SearchComparatorEnumFactory());
027    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
028    switch (src.getValue()) {
029      case EQ:
030        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchComparator.EQ);
031        break;
032      case NE:
033        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchComparator.NE);
034        break;
035      case GT:
036        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchComparator.GT);
037        break;
038      case LT:
039        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchComparator.LT);
040        break;
041      case GE:
042        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchComparator.GE);
043        break;
044      case LE:
045        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchComparator.LE);
046        break;
047      case SA:
048        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchComparator.SA);
049        break;
050      case EB:
051        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchComparator.EB);
052        break;
053      case AP:
054        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchComparator.AP);
055        break;
056      default:
057        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchComparator.NULL);
058        break;
059    }
060    return tgt;
061  }
062
063  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator> convertSearchComparator(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.SearchComparator> src) throws FHIRException {
064    if (src == null || src.isEmpty())
065      return null;
066    org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.SearchParameter.SearchComparatorEnumFactory());
067    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
068    switch (src.getValue()) {
069      case EQ:
070        tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator.EQ);
071        break;
072      case NE:
073        tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator.NE);
074        break;
075      case GT:
076        tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator.GT);
077        break;
078      case LT:
079        tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator.LT);
080        break;
081      case GE:
082        tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator.GE);
083        break;
084      case LE:
085        tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator.LE);
086        break;
087      case SA:
088        tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator.SA);
089        break;
090      case EB:
091        tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator.EB);
092        break;
093      case AP:
094        tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator.AP);
095        break;
096      default:
097        tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchComparator.NULL);
098        break;
099    }
100    return tgt;
101  }
102
103  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.SearchModifierCode> convertSearchModifierCode(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode> src) throws FHIRException {
104    if (src == null || src.isEmpty())
105      return null;
106    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.SearchModifierCode> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.SearchModifierCodeEnumFactory());
107    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
108    switch (src.getValue()) {
109      case MISSING:
110        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchModifierCode.MISSING);
111        break;
112      case EXACT:
113        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchModifierCode.EXACT);
114        break;
115      case CONTAINS:
116        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchModifierCode.CONTAINS);
117        break;
118      case NOT:
119        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchModifierCode.NOT);
120        break;
121      case TEXT:
122        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchModifierCode.TEXT);
123        break;
124      case IN:
125        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchModifierCode.IN);
126        break;
127      case NOTIN:
128        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchModifierCode.NOTIN);
129        break;
130      case BELOW:
131        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchModifierCode.BELOW);
132        break;
133      case ABOVE:
134        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchModifierCode.ABOVE);
135        break;
136      case TYPE:
137        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchModifierCode.TYPE);
138        break;
139      default:
140        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchModifierCode.NULL);
141        break;
142    }
143    return tgt;
144  }
145
146  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode> convertSearchModifierCode(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.SearchModifierCode> src) throws FHIRException {
147    if (src == null || src.isEmpty())
148      return null;
149    org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCodeEnumFactory());
150    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
151    switch (src.getValue()) {
152      case MISSING:
153        tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode.MISSING);
154        break;
155      case EXACT:
156        tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode.EXACT);
157        break;
158      case CONTAINS:
159        tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode.CONTAINS);
160        break;
161      case NOT:
162        tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode.NOT);
163        break;
164      case TEXT:
165        tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode.TEXT);
166        break;
167      case IN:
168        tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode.IN);
169        break;
170      case NOTIN:
171        tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode.NOTIN);
172        break;
173      case BELOW:
174        tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode.BELOW);
175        break;
176      case ABOVE:
177        tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode.ABOVE);
178        break;
179      case TYPE:
180        tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode.TYPE);
181        break;
182      default:
183        tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.SearchModifierCode.NULL);
184        break;
185    }
186    return tgt;
187  }
188
189  public static org.hl7.fhir.r5.model.SearchParameter convertSearchParameter(org.hl7.fhir.dstu3.model.SearchParameter src) throws FHIRException {
190    if (src == null)
191      return null;
192    org.hl7.fhir.r5.model.SearchParameter tgt = new org.hl7.fhir.r5.model.SearchParameter();
193    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
194    if (src.hasUrl())
195      tgt.setUrlElement(Uri30_50.convertUri(src.getUrlElement()));
196    if (src.hasVersion())
197      tgt.setVersionElement(String30_50.convertString(src.getVersionElement()));
198    if (src.hasName())
199      tgt.setNameElement(String30_50.convertString(src.getNameElement()));
200    if (src.hasStatus())
201      tgt.setStatusElement(Enumerations30_50.convertPublicationStatus(src.getStatusElement()));
202    if (src.hasExperimental())
203      tgt.setExperimentalElement(Boolean30_50.convertBoolean(src.getExperimentalElement()));
204    if (src.hasDate())
205      tgt.setDateElement(DateTime30_50.convertDateTime(src.getDateElement()));
206    if (src.hasPublisher())
207      tgt.setPublisherElement(String30_50.convertString(src.getPublisherElement()));
208    for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact())
209      tgt.addContact(ContactDetail30_50.convertContactDetail(t));
210    for (org.hl7.fhir.dstu3.model.UsageContext t : src.getUseContext())
211      tgt.addUseContext(UsageContext30_50.convertUsageContext(t));
212    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getJurisdiction())
213      tgt.addJurisdiction(CodeableConcept30_50.convertCodeableConcept(t));
214    if (src.hasPurpose())
215      tgt.setPurposeElement(MarkDown30_50.convertMarkdown(src.getPurposeElement()));
216    if (src.hasCode())
217      tgt.setCodeElement(Code30_50.convertCode(src.getCodeElement()));
218    for (org.hl7.fhir.dstu3.model.CodeType t : src.getBase()) tgt.getBase().add(new Enumeration<VersionIndependentResourceTypesAll>(new VersionIndependentResourceTypesAllEnumFactory(), Code30_50.convertCode(t)));
219    if (src.hasType())
220      tgt.setTypeElement(Enumerations30_50.convertSearchParamType(src.getTypeElement()));
221    if (src.hasDerivedFrom())
222      tgt.setDerivedFrom(src.getDerivedFrom());
223    if (src.hasDescription())
224      tgt.setDescriptionElement(MarkDown30_50.convertMarkdown(src.getDescriptionElement()));
225    if (src.hasExpression())
226      tgt.setExpressionElement(String30_50.convertString(src.getExpressionElement()));
227//    if (src.hasXpath())
228//      tgt.setXpathElement(String30_50.convertString(src.getXpathElement()));
229    if (src.hasXpathUsage())
230      tgt.setProcessingModeElement(convertXPathUsageType(src.getXpathUsageElement()));
231    for (org.hl7.fhir.dstu3.model.CodeType t : src.getTarget()) tgt.getTarget().add(new Enumeration<VersionIndependentResourceTypesAll>(new VersionIndependentResourceTypesAllEnumFactory(), t.getValue()));
232    tgt.setComparator(src.getComparator().stream()
233      .map(SearchParameter30_50::convertSearchComparator)
234      .collect(Collectors.toList()));
235    tgt.setModifier(src.getModifier().stream()
236      .map(SearchParameter30_50::convertSearchModifierCode)
237      .collect(Collectors.toList()));
238    for (org.hl7.fhir.dstu3.model.StringType t : src.getChain()) tgt.addChain(t.getValue());
239    for (org.hl7.fhir.dstu3.model.SearchParameter.SearchParameterComponentComponent t : src.getComponent())
240      tgt.addComponent(convertSearchParameterComponentComponent(t));
241    return tgt;
242  }
243
244  public static org.hl7.fhir.dstu3.model.SearchParameter convertSearchParameter(org.hl7.fhir.r5.model.SearchParameter src) throws FHIRException {
245    if (src == null)
246      return null;
247    org.hl7.fhir.dstu3.model.SearchParameter tgt = new org.hl7.fhir.dstu3.model.SearchParameter();
248    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
249    if (src.hasUrl())
250      tgt.setUrlElement(Uri30_50.convertUri(src.getUrlElement()));
251    if (src.hasVersion())
252      tgt.setVersionElement(String30_50.convertString(src.getVersionElement()));
253    if (src.hasName())
254      tgt.setNameElement(String30_50.convertString(src.getNameElement()));
255    if (src.hasStatus())
256      tgt.setStatusElement(Enumerations30_50.convertPublicationStatus(src.getStatusElement()));
257    if (src.hasExperimental())
258      tgt.setExperimentalElement(Boolean30_50.convertBoolean(src.getExperimentalElement()));
259    if (src.hasDate())
260      tgt.setDateElement(DateTime30_50.convertDateTime(src.getDateElement()));
261    if (src.hasPublisher())
262      tgt.setPublisherElement(String30_50.convertString(src.getPublisherElement()));
263    for (org.hl7.fhir.r5.model.ContactDetail t : src.getContact())
264      tgt.addContact(ContactDetail30_50.convertContactDetail(t));
265    for (org.hl7.fhir.r5.model.UsageContext t : src.getUseContext())
266      tgt.addUseContext(UsageContext30_50.convertUsageContext(t));
267    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getJurisdiction())
268      tgt.addJurisdiction(CodeableConcept30_50.convertCodeableConcept(t));
269    if (src.hasPurpose())
270      tgt.setPurposeElement(MarkDown30_50.convertMarkdown(src.getPurposeElement()));
271    if (src.hasCode())
272      tgt.setCodeElement(Code30_50.convertCode(src.getCodeElement()));
273    for (Enumeration<VersionIndependentResourceTypesAll> t : src.getBase()) tgt.getBase().add(Code30_50.convertCode(t.getCodeType()));
274    if (src.hasType())
275      tgt.setTypeElement(Enumerations30_50.convertSearchParamType(src.getTypeElement()));
276    if (src.hasDerivedFrom())
277      tgt.setDerivedFrom(src.getDerivedFrom());
278    if (src.hasDescription())
279      tgt.setDescriptionElement(MarkDown30_50.convertMarkdown(src.getDescriptionElement()));
280    if (src.hasExpression())
281      tgt.setExpressionElement(String30_50.convertString(src.getExpressionElement()));
282//    if (src.hasXpath())
283//      tgt.setXpathElement(String30_50.convertString(src.getXpathElement()));
284    if (src.hasProcessingMode())
285      tgt.setXpathUsageElement(convertXPathUsageType(src.getProcessingModeElement()));
286    for (Enumeration<VersionIndependentResourceTypesAll> t : src.getTarget()) tgt.getTarget().add(Code30_50.convertCode(t.getCodeType()));
287    tgt.setComparator(src.getComparator().stream()
288      .map(SearchParameter30_50::convertSearchComparator)
289      .collect(Collectors.toList()));
290    tgt.setModifier(src.getModifier().stream()
291      .map(SearchParameter30_50::convertSearchModifierCode)
292      .collect(Collectors.toList()));
293    for (org.hl7.fhir.r5.model.StringType t : src.getChain()) tgt.addChain(t.getValue());
294    for (org.hl7.fhir.r5.model.SearchParameter.SearchParameterComponentComponent t : src.getComponent())
295      tgt.addComponent(convertSearchParameterComponentComponent(t));
296    return tgt;
297  }
298
299  public static org.hl7.fhir.r5.model.SearchParameter.SearchParameterComponentComponent convertSearchParameterComponentComponent(org.hl7.fhir.dstu3.model.SearchParameter.SearchParameterComponentComponent src) throws FHIRException {
300    if (src == null)
301      return null;
302    org.hl7.fhir.r5.model.SearchParameter.SearchParameterComponentComponent tgt = new org.hl7.fhir.r5.model.SearchParameter.SearchParameterComponentComponent();
303    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyBackboneElement(src,tgt);
304    if (src.hasDefinition())
305      tgt.setDefinitionElement(Reference30_50.convertReferenceToCanonical(src.getDefinition()));
306    if (src.hasExpression())
307      tgt.setExpressionElement(String30_50.convertString(src.getExpressionElement()));
308    return tgt;
309  }
310
311  public static org.hl7.fhir.dstu3.model.SearchParameter.SearchParameterComponentComponent convertSearchParameterComponentComponent(org.hl7.fhir.r5.model.SearchParameter.SearchParameterComponentComponent src) throws FHIRException {
312    if (src == null)
313      return null;
314    org.hl7.fhir.dstu3.model.SearchParameter.SearchParameterComponentComponent tgt = new org.hl7.fhir.dstu3.model.SearchParameter.SearchParameterComponentComponent();
315    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyBackboneElement(src,tgt);
316    if (src.hasDefinition())
317      tgt.setDefinition(Reference30_50.convertCanonicalToReference(src.getDefinitionElement()));
318    if (src.hasExpression())
319      tgt.setExpressionElement(String30_50.convertString(src.getExpressionElement()));
320    return tgt;
321  }
322
323  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.SearchParameter.SearchProcessingModeType> convertXPathUsageType(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType> src) throws FHIRException {
324    if (src == null || src.isEmpty())
325      return null;
326    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.SearchParameter.SearchProcessingModeType> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.SearchParameter.SearchProcessingModeTypeEnumFactory());
327    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
328    switch (src.getValue()) {
329      case NORMAL:
330        tgt.setValue(org.hl7.fhir.r5.model.SearchParameter.SearchProcessingModeType.NORMAL);
331        break;
332      case PHONETIC:
333        tgt.setValue(org.hl7.fhir.r5.model.SearchParameter.SearchProcessingModeType.PHONETIC);
334        break;
335      case NEARBY:
336        tgt.setValue(org.hl7.fhir.r5.model.SearchParameter.SearchProcessingModeType.OTHER);
337        break;
338      case DISTANCE:
339        tgt.setValue(org.hl7.fhir.r5.model.SearchParameter.SearchProcessingModeType.OTHER);
340        break;
341      case OTHER:
342        tgt.setValue(org.hl7.fhir.r5.model.SearchParameter.SearchProcessingModeType.OTHER);
343        break;
344      default:
345        tgt.setValue(org.hl7.fhir.r5.model.SearchParameter.SearchProcessingModeType.NULL);
346        break;
347    }
348    return tgt;
349  }
350
351  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType> convertXPathUsageType(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.SearchParameter.SearchProcessingModeType> src) throws FHIRException {
352    if (src == null || src.isEmpty())
353      return null;
354    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());
355    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
356    switch (src.getValue()) {
357      case NORMAL:
358        tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType.NORMAL);
359        break;
360      case PHONETIC:
361        tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType.PHONETIC);
362        break;
363      case OTHER:
364        tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType.OTHER);
365        break;
366      default:
367        tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType.NULL);
368        break;
369    }
370    return tgt;
371  }
372}