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