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