001package org.hl7.fhir.convertors.conv30_40.resources30_40;
002
003import org.hl7.fhir.convertors.context.ConversionContext30_40;
004import org.hl7.fhir.convertors.conv30_40.datatypes30_40.Reference30_40;
005import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.Annotation30_40;
006import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.CodeableConcept30_40;
007import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.Identifier30_40;
008import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.Boolean30_40;
009import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.DateTime30_40;
010import org.hl7.fhir.exceptions.FHIRException;
011import org.hl7.fhir.r4.model.Reference;
012
013import java.util.List;
014
015public class ProcedureRequest30_40 {
016
017  static public org.hl7.fhir.r4.model.ServiceRequest convertProcedureRequest(org.hl7.fhir.dstu3.model.ProcedureRequest src) throws FHIRException {
018    if (src == null)
019      return null;
020    org.hl7.fhir.r4.model.ServiceRequest tgt = new org.hl7.fhir.r4.model.ServiceRequest();
021    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyDomainResource(src, tgt);
022    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier()) {
023      tgt.addIdentifier(Identifier30_40.convertIdentifier(t));
024    }
025    for (org.hl7.fhir.dstu3.model.Reference t : src.getBasedOn()) {
026      tgt.addBasedOn(Reference30_40.convertReference(t));
027    }
028    for (org.hl7.fhir.dstu3.model.Reference t : src.getReplaces()) {
029      tgt.addReplaces(Reference30_40.convertReference(t));
030    }
031    if (src.hasRequisition()) {
032      if (src.hasRequisition())
033        tgt.setRequisition(Identifier30_40.convertIdentifier(src.getRequisition()));
034    }
035    if (src.hasStatus()) {
036      if (src.hasStatus())
037        tgt.setStatusElement(convertProcedureRequestStatus(src.getStatusElement()));
038    }
039    if (src.hasIntent()) {
040      if (src.hasIntent())
041        tgt.setIntentElement(convertProcedureRequestIntent(src.getIntentElement()));
042    }
043    if (src.hasPriority()) {
044      if (src.hasPriority())
045        tgt.setPriorityElement(convertProcedureRequestPriority(src.getPriorityElement()));
046    }
047    if (src.hasDoNotPerform()) {
048      if (src.hasDoNotPerformElement())
049        tgt.setDoNotPerformElement(Boolean30_40.convertBoolean(src.getDoNotPerformElement()));
050    }
051    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getCategory()) {
052      tgt.addCategory(CodeableConcept30_40.convertCodeableConcept(t));
053    }
054    if (src.hasCode()) {
055      if (src.hasCode())
056        tgt.setCode(CodeableConcept30_40.convertCodeableConcept(src.getCode()));
057    }
058    if (src.hasSubject()) {
059      if (src.hasSubject())
060        tgt.setSubject(Reference30_40.convertReference(src.getSubject()));
061    }
062    if (src.hasContext()) {
063      if (src.hasContext())
064        tgt.setEncounter(Reference30_40.convertReference(src.getContext()));
065    }
066    if (src.hasOccurrence()) {
067      if (src.hasOccurrence())
068        tgt.setOccurrence(ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().convertType(src.getOccurrence()));
069    }
070    if (src.hasAsNeeded()) {
071      if (src.hasAsNeeded())
072        tgt.setAsNeeded(ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().convertType(src.getAsNeeded()));
073    }
074    if (src.hasAuthoredOn()) {
075      if (src.hasAuthoredOnElement())
076        tgt.setAuthoredOnElement(DateTime30_40.convertDateTime(src.getAuthoredOnElement()));
077    }
078    if (src.hasRequester()) {
079      org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestRequesterComponent requester = src.getRequester();
080      if (requester.hasAgent()) {
081        tgt.setRequester(Reference30_40.convertReference(requester.getAgent()));
082      }
083    }
084    if (src.hasPerformerType()) {
085      if (src.hasPerformerType())
086        tgt.setPerformerType(CodeableConcept30_40.convertCodeableConcept(src.getPerformerType()));
087    }
088    if (src.hasPerformer()) {
089      if (src.hasPerformer())
090        tgt.addPerformer(Reference30_40.convertReference(src.getPerformer()));
091    }
092    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getReasonCode()) {
093      tgt.addReasonCode(CodeableConcept30_40.convertCodeableConcept(t));
094    }
095    for (org.hl7.fhir.dstu3.model.Reference t : src.getReasonReference()) {
096      tgt.addReasonReference(Reference30_40.convertReference(t));
097    }
098    for (org.hl7.fhir.dstu3.model.Reference t : src.getSupportingInfo()) {
099      tgt.addSupportingInfo(Reference30_40.convertReference(t));
100    }
101    for (org.hl7.fhir.dstu3.model.Reference t : src.getSpecimen()) {
102      tgt.addSpecimen(Reference30_40.convertReference(t));
103    }
104    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getBodySite()) {
105      tgt.addBodySite(CodeableConcept30_40.convertCodeableConcept(t));
106    }
107    for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote()) {
108      tgt.addNote(Annotation30_40.convertAnnotation(t));
109    }
110    for (org.hl7.fhir.dstu3.model.Reference t : src.getRelevantHistory()) {
111      tgt.addRelevantHistory(Reference30_40.convertReference(t));
112    }
113    return tgt;
114  }
115
116  static public org.hl7.fhir.dstu3.model.ProcedureRequest convertProcedureRequest(org.hl7.fhir.r4.model.ServiceRequest src) throws FHIRException {
117    if (src == null)
118      return null;
119    org.hl7.fhir.dstu3.model.ProcedureRequest tgt = new org.hl7.fhir.dstu3.model.ProcedureRequest();
120    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyDomainResource(src, tgt);
121    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) {
122      tgt.addIdentifier(Identifier30_40.convertIdentifier(t));
123    }
124    for (org.hl7.fhir.r4.model.Reference t : src.getBasedOn()) {
125      tgt.addBasedOn(Reference30_40.convertReference(t));
126    }
127    for (org.hl7.fhir.r4.model.Reference t : src.getReplaces()) {
128      tgt.addReplaces(Reference30_40.convertReference(t));
129    }
130    if (src.hasRequisition()) {
131      if (src.hasRequisition())
132        tgt.setRequisition(Identifier30_40.convertIdentifier(src.getRequisition()));
133    }
134    if (src.hasStatus()) {
135      if (src.hasStatus())
136        tgt.setStatusElement(convertProcedureRequestStatus(src.getStatusElement()));
137    }
138    if (src.hasIntent()) {
139      if (src.hasIntent())
140        tgt.setIntentElement(convertProcedureRequestIntent(src.getIntentElement()));
141    }
142    if (src.hasPriority()) {
143      if (src.hasPriority())
144        tgt.setPriorityElement(convertProcedureRequestPriority(src.getPriorityElement()));
145    }
146    if (src.hasDoNotPerform()) {
147      if (src.hasDoNotPerformElement())
148        tgt.setDoNotPerformElement(Boolean30_40.convertBoolean(src.getDoNotPerformElement()));
149    }
150    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCategory()) {
151      tgt.addCategory(CodeableConcept30_40.convertCodeableConcept(t));
152    }
153    if (src.hasCode()) {
154      if (src.hasCode())
155        tgt.setCode(CodeableConcept30_40.convertCodeableConcept(src.getCode()));
156    }
157    if (src.hasSubject()) {
158      if (src.hasSubject())
159        tgt.setSubject(Reference30_40.convertReference(src.getSubject()));
160    }
161    if (src.hasEncounter()) {
162      if (src.hasEncounter())
163        tgt.setContext(Reference30_40.convertReference(src.getEncounter()));
164    }
165    if (src.hasOccurrence()) {
166      if (src.hasOccurrence())
167        tgt.setOccurrence(ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().convertType(src.getOccurrence()));
168    }
169    if (src.hasAsNeeded()) {
170      if (src.hasAsNeeded())
171        tgt.setAsNeeded(ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().convertType(src.getAsNeeded()));
172    }
173    if (src.hasAuthoredOn()) {
174      if (src.hasAuthoredOnElement())
175        tgt.setAuthoredOnElement(DateTime30_40.convertDateTime(src.getAuthoredOnElement()));
176    }
177    if (src.hasRequester()) {
178      tgt.setRequester(new org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestRequesterComponent(Reference30_40.convertReference(src.getRequester())));
179    }
180    if (src.hasPerformerType()) {
181      if (src.hasPerformerType())
182        tgt.setPerformerType(CodeableConcept30_40.convertCodeableConcept(src.getPerformerType()));
183    }
184    List<Reference> performers = src.getPerformer();
185    if (performers.size() > 0) {
186      tgt.setPerformer(Reference30_40.convertReference(performers.get(0)));
187      if (performers.size() > 1) {
188      }
189    }
190    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReasonCode()) {
191      tgt.addReasonCode(CodeableConcept30_40.convertCodeableConcept(t));
192    }
193    for (org.hl7.fhir.r4.model.Reference t : src.getReasonReference()) {
194      tgt.addReasonReference(Reference30_40.convertReference(t));
195    }
196    for (org.hl7.fhir.r4.model.Reference t : src.getSupportingInfo()) {
197      tgt.addSupportingInfo(Reference30_40.convertReference(t));
198    }
199    for (org.hl7.fhir.r4.model.Reference t : src.getSpecimen()) {
200      tgt.addSpecimen(Reference30_40.convertReference(t));
201    }
202    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getBodySite()) {
203      tgt.addBodySite(CodeableConcept30_40.convertCodeableConcept(t));
204    }
205    for (org.hl7.fhir.r4.model.Annotation t : src.getNote()) {
206      tgt.addNote(Annotation30_40.convertAnnotation(t));
207    }
208    for (org.hl7.fhir.r4.model.Reference t : src.getRelevantHistory()) {
209      tgt.addRelevantHistory(Reference30_40.convertReference(t));
210    }
211    return tgt;
212  }
213
214  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestIntent> convertProcedureRequestIntent(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestIntent> src) throws FHIRException {
215    if (src == null || src.isEmpty())
216      return null;
217    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestIntent> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestIntentEnumFactory());
218    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
219    switch (src.getValue()) {
220      case FILLERORDER:
221        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestIntent.FILLERORDER);
222        break;
223      case INSTANCEORDER:
224        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestIntent.INSTANCEORDER);
225        break;
226      case OPTION:
227        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestIntent.OPTION);
228        break;
229      case ORDER:
230        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestIntent.ORDER);
231        break;
232      case ORIGINALORDER:
233        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestIntent.ORIGINALORDER);
234        break;
235      case PLAN:
236        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestIntent.PLAN);
237        break;
238      case PROPOSAL:
239        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestIntent.PROPOSAL);
240        break;
241      case REFLEXORDER:
242        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestIntent.REFLEXORDER);
243        break;
244      default:
245        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestIntent.NULL);
246        break;
247    }
248    return tgt;
249  }
250
251  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestIntent> convertProcedureRequestIntent(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestIntent> src) throws FHIRException {
252    if (src == null || src.isEmpty())
253      return null;
254    org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestIntent> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestIntentEnumFactory());
255    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
256    switch (src.getValue()) {
257      case DIRECTIVE:
258        tgt.setValue(org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestIntent.NULL);
259        break;
260      case FILLERORDER:
261        tgt.setValue(org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestIntent.FILLERORDER);
262        break;
263      case INSTANCEORDER:
264        tgt.setValue(org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestIntent.INSTANCEORDER);
265        break;
266      case OPTION:
267        tgt.setValue(org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestIntent.OPTION);
268        break;
269      case ORDER:
270        tgt.setValue(org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestIntent.ORDER);
271        break;
272      case ORIGINALORDER:
273        tgt.setValue(org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestIntent.ORIGINALORDER);
274        break;
275      case PLAN:
276        tgt.setValue(org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestIntent.PLAN);
277        break;
278      case PROPOSAL:
279        tgt.setValue(org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestIntent.PROPOSAL);
280        break;
281      case REFLEXORDER:
282        tgt.setValue(org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestIntent.REFLEXORDER);
283        break;
284      default:
285        tgt.setValue(org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestIntent.NULL);
286        break;
287    }
288    return tgt;
289  }
290
291  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestPriority> convertProcedureRequestPriority(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestPriority> src) throws FHIRException {
292    if (src == null || src.isEmpty())
293      return null;
294    org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestPriority> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestPriorityEnumFactory());
295    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
296    switch (src.getValue()) {
297      case ASAP:
298        tgt.setValue(org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestPriority.ASAP);
299        break;
300      case ROUTINE:
301        tgt.setValue(org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestPriority.ROUTINE);
302        break;
303      case STAT:
304        tgt.setValue(org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestPriority.STAT);
305        break;
306      case URGENT:
307        tgt.setValue(org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestPriority.URGENT);
308        break;
309      default:
310        tgt.setValue(org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestPriority.NULL);
311        break;
312    }
313    return tgt;
314  }
315
316  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestPriority> convertProcedureRequestPriority(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestPriority> src) throws FHIRException {
317    if (src == null || src.isEmpty())
318      return null;
319    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestPriority> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestPriorityEnumFactory());
320    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
321    switch (src.getValue()) {
322      case ASAP:
323        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestPriority.ASAP);
324        break;
325      case ROUTINE:
326        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestPriority.ROUTINE);
327        break;
328      case STAT:
329        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestPriority.STAT);
330        break;
331      case URGENT:
332        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestPriority.URGENT);
333        break;
334      default:
335        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestPriority.NULL);
336        break;
337    }
338    return tgt;
339  }
340
341  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestStatus> convertProcedureRequestStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestStatus> src) throws FHIRException {
342    if (src == null || src.isEmpty())
343      return null;
344    org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestStatus> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestStatusEnumFactory());
345    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
346    switch (src.getValue()) {
347      case ACTIVE:
348        tgt.setValue(org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestStatus.ACTIVE);
349        break;
350      case COMPLETED:
351        tgt.setValue(org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestStatus.COMPLETED);
352        break;
353      case DRAFT:
354        tgt.setValue(org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestStatus.DRAFT);
355        break;
356      case ENTEREDINERROR:
357        tgt.setValue(org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestStatus.ENTEREDINERROR);
358        break;
359      case ONHOLD:
360        tgt.setValue(org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestStatus.SUSPENDED);
361        break;
362      case REVOKED:
363        tgt.setValue(org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestStatus.CANCELLED);
364        break;
365      case UNKNOWN:
366        tgt.setValue(org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestStatus.UNKNOWN);
367        break;
368      default:
369        tgt.setValue(org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestStatus.NULL);
370        break;
371    }
372    return tgt;
373  }
374
375  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestStatus> convertProcedureRequestStatus(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ProcedureRequest.ProcedureRequestStatus> src) throws FHIRException {
376    if (src == null || src.isEmpty())
377      return null;
378    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestStatus> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestStatusEnumFactory());
379    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
380    switch (src.getValue()) {
381      case ACTIVE:
382        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestStatus.ACTIVE);
383        break;
384      case CANCELLED:
385        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestStatus.REVOKED);
386        break;
387      case COMPLETED:
388        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestStatus.COMPLETED);
389        break;
390      case DRAFT:
391        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestStatus.DRAFT);
392        break;
393      case ENTEREDINERROR:
394        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestStatus.ENTEREDINERROR);
395        break;
396      case SUSPENDED:
397        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestStatus.ONHOLD);
398        break;
399      case UNKNOWN:
400        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestStatus.UNKNOWN);
401        break;
402      default:
403        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestStatus.NULL);
404        break;
405    }
406    return tgt;
407  }
408}