001package org.hl7.fhir.convertors.conv40_50.resources40_50;
002
003import org.hl7.fhir.convertors.context.ConversionContext40_50;
004import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.Annotation40_50;
005import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.CodeableConcept40_50;
006import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.Identifier40_50;
007import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.*;
008import org.hl7.fhir.convertors.conv40_50.datatypes40_50.special40_50.Reference40_50;
009import org.hl7.fhir.exceptions.FHIRException;
010import org.hl7.fhir.r5.model.CodeableReference;
011
012/*
013  Copyright (c) 2011+, HL7, Inc.
014  All rights reserved.
015  
016  Redistribution and use in source and binary forms, with or without modification, 
017  are permitted provided that the following conditions are met:
018  
019   * Redistributions of source code must retain the above copyright notice, this 
020     list of conditions and the following disclaimer.
021   * Redistributions in binary form must reproduce the above copyright notice, 
022     this list of conditions and the following disclaimer in the documentation 
023     and/or other materials provided with the distribution.
024   * Neither the name of HL7 nor the names of its contributors may be used to 
025     endorse or promote products derived from this software without specific 
026     prior written permission.
027  
028  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
029  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
030  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
031  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
032  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
033  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
034  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
035  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
036  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
037  POSSIBILITY OF SUCH DAMAGE.
038  
039*/
040// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0
041public class ServiceRequest40_50 {
042
043  public static org.hl7.fhir.r5.model.ServiceRequest convertServiceRequest(org.hl7.fhir.r4.model.ServiceRequest src) throws FHIRException {
044    if (src == null)
045      return null;
046    org.hl7.fhir.r5.model.ServiceRequest tgt = new org.hl7.fhir.r5.model.ServiceRequest();
047    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt);
048    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
049      tgt.addIdentifier(Identifier40_50.convertIdentifier(t));
050    for (org.hl7.fhir.r4.model.CanonicalType t : src.getInstantiatesCanonical())
051      tgt.getInstantiatesCanonical().add(Canonical40_50.convertCanonical(t));
052    for (org.hl7.fhir.r4.model.UriType t : src.getInstantiatesUri())
053      tgt.getInstantiatesUri().add(Uri40_50.convertUri(t));
054    for (org.hl7.fhir.r4.model.Reference t : src.getBasedOn()) tgt.addBasedOn(Reference40_50.convertReference(t));
055    for (org.hl7.fhir.r4.model.Reference t : src.getReplaces()) tgt.addReplaces(Reference40_50.convertReference(t));
056    if (src.hasRequisition())
057      tgt.setRequisition(Identifier40_50.convertIdentifier(src.getRequisition()));
058    if (src.hasStatus())
059      tgt.setStatusElement(convertServiceRequestStatus(src.getStatusElement()));
060    if (src.hasIntent())
061      tgt.setIntentElement(convertServiceRequestIntent(src.getIntentElement()));
062    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCategory())
063      tgt.addCategory(CodeableConcept40_50.convertCodeableConcept(t));
064    if (src.hasPriority())
065      tgt.setPriorityElement(convertServiceRequestPriority(src.getPriorityElement()));
066    if (src.hasDoNotPerform())
067      tgt.setDoNotPerformElement(Boolean40_50.convertBoolean(src.getDoNotPerformElement()));
068    if (src.hasCode())
069      tgt.setCode(CodeableConcept40_50.convertCodeableConcept(src.getCode()));
070    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getOrderDetail())
071      tgt.addOrderDetail(CodeableConcept40_50.convertCodeableConcept(t));
072    if (src.hasQuantity())
073      tgt.setQuantity(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getQuantity()));
074    if (src.hasSubject())
075      tgt.setSubject(Reference40_50.convertReference(src.getSubject()));
076    if (src.hasEncounter())
077      tgt.setEncounter(Reference40_50.convertReference(src.getEncounter()));
078    if (src.hasOccurrence())
079      tgt.setOccurrence(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getOccurrence()));
080    if (src.hasAsNeeded())
081      tgt.setAsNeeded(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getAsNeeded()));
082    if (src.hasAuthoredOn())
083      tgt.setAuthoredOnElement(DateTime40_50.convertDateTime(src.getAuthoredOnElement()));
084    if (src.hasRequester())
085      tgt.setRequester(Reference40_50.convertReference(src.getRequester()));
086    if (src.hasPerformerType())
087      tgt.setPerformerType(CodeableConcept40_50.convertCodeableConcept(src.getPerformerType()));
088    for (org.hl7.fhir.r4.model.Reference t : src.getPerformer()) tgt.addPerformer(Reference40_50.convertReference(t));
089    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getLocationCode())
090      tgt.addLocation(CodeableConcept40_50.convertCodeableConceptToCodeableReference(t));
091    for (org.hl7.fhir.r4.model.Reference t : src.getLocationReference())
092      tgt.addLocation(Reference40_50.convertReferenceToCodeableReference(t));
093    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReasonCode())
094      tgt.addReason(CodeableConcept40_50.convertCodeableConceptToCodeableReference(t));
095    for (org.hl7.fhir.r4.model.Reference t : src.getReasonReference())
096      tgt.addReason(Reference40_50.convertReferenceToCodeableReference(t));
097    for (org.hl7.fhir.r4.model.Reference t : src.getInsurance()) tgt.addInsurance(Reference40_50.convertReference(t));
098    for (org.hl7.fhir.r4.model.Reference t : src.getSupportingInfo())
099      tgt.addSupportingInfo(Reference40_50.convertReference(t));
100    for (org.hl7.fhir.r4.model.Reference t : src.getSpecimen()) tgt.addSpecimen(Reference40_50.convertReference(t));
101    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getBodySite())
102      tgt.addBodySite(CodeableConcept40_50.convertCodeableConcept(t));
103    for (org.hl7.fhir.r4.model.Annotation t : src.getNote()) tgt.addNote(Annotation40_50.convertAnnotation(t));
104    if (src.hasPatientInstruction())
105      tgt.setPatientInstructionElement(String40_50.convertString(src.getPatientInstructionElement()));
106    for (org.hl7.fhir.r4.model.Reference t : src.getRelevantHistory())
107      tgt.addRelevantHistory(Reference40_50.convertReference(t));
108    return tgt;
109  }
110
111  public static org.hl7.fhir.r4.model.ServiceRequest convertServiceRequest(org.hl7.fhir.r5.model.ServiceRequest src) throws FHIRException {
112    if (src == null)
113      return null;
114    org.hl7.fhir.r4.model.ServiceRequest tgt = new org.hl7.fhir.r4.model.ServiceRequest();
115    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt);
116    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
117      tgt.addIdentifier(Identifier40_50.convertIdentifier(t));
118    for (org.hl7.fhir.r5.model.CanonicalType t : src.getInstantiatesCanonical())
119      tgt.getInstantiatesCanonical().add(Canonical40_50.convertCanonical(t));
120    for (org.hl7.fhir.r5.model.UriType t : src.getInstantiatesUri())
121      tgt.getInstantiatesUri().add(Uri40_50.convertUri(t));
122    for (org.hl7.fhir.r5.model.Reference t : src.getBasedOn()) tgt.addBasedOn(Reference40_50.convertReference(t));
123    for (org.hl7.fhir.r5.model.Reference t : src.getReplaces()) tgt.addReplaces(Reference40_50.convertReference(t));
124    if (src.hasRequisition())
125      tgt.setRequisition(Identifier40_50.convertIdentifier(src.getRequisition()));
126    if (src.hasStatus())
127      tgt.setStatusElement(convertServiceRequestStatus(src.getStatusElement()));
128    if (src.hasIntent())
129      tgt.setIntentElement(convertServiceRequestIntent(src.getIntentElement()));
130    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getCategory())
131      tgt.addCategory(CodeableConcept40_50.convertCodeableConcept(t));
132    if (src.hasPriority())
133      tgt.setPriorityElement(convertServiceRequestPriority(src.getPriorityElement()));
134    if (src.hasDoNotPerform())
135      tgt.setDoNotPerformElement(Boolean40_50.convertBoolean(src.getDoNotPerformElement()));
136    if (src.hasCode())
137      tgt.setCode(CodeableConcept40_50.convertCodeableConcept(src.getCode()));
138    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getOrderDetail())
139      tgt.addOrderDetail(CodeableConcept40_50.convertCodeableConcept(t));
140    if (src.hasQuantity())
141      tgt.setQuantity(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getQuantity()));
142    if (src.hasSubject())
143      tgt.setSubject(Reference40_50.convertReference(src.getSubject()));
144    if (src.hasEncounter())
145      tgt.setEncounter(Reference40_50.convertReference(src.getEncounter()));
146    if (src.hasOccurrence())
147      tgt.setOccurrence(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getOccurrence()));
148    if (src.hasAsNeeded())
149      tgt.setAsNeeded(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getAsNeeded()));
150    if (src.hasAuthoredOn())
151      tgt.setAuthoredOnElement(DateTime40_50.convertDateTime(src.getAuthoredOnElement()));
152    if (src.hasRequester())
153      tgt.setRequester(Reference40_50.convertReference(src.getRequester()));
154    if (src.hasPerformerType())
155      tgt.setPerformerType(CodeableConcept40_50.convertCodeableConcept(src.getPerformerType()));
156    for (org.hl7.fhir.r5.model.Reference t : src.getPerformer()) tgt.addPerformer(Reference40_50.convertReference(t));
157    for (CodeableReference t : src.getLocation())
158      if (t.hasConcept())
159        tgt.addLocationCode(CodeableConcept40_50.convertCodeableConcept(t.getConcept()));
160    for (CodeableReference t : src.getLocation())
161      if (t.hasReference())
162        tgt.addLocationReference(Reference40_50.convertReference(t.getReference()));
163    for (CodeableReference t : src.getReason())
164      if (t.hasConcept())
165        tgt.addReasonCode(CodeableConcept40_50.convertCodeableConcept(t.getConcept()));
166    for (CodeableReference t : src.getReason())
167      if (t.hasReference())
168        tgt.addReasonReference(Reference40_50.convertReference(t.getReference()));
169    for (org.hl7.fhir.r5.model.Reference t : src.getInsurance()) tgt.addInsurance(Reference40_50.convertReference(t));
170    for (org.hl7.fhir.r5.model.Reference t : src.getSupportingInfo())
171      tgt.addSupportingInfo(Reference40_50.convertReference(t));
172    for (org.hl7.fhir.r5.model.Reference t : src.getSpecimen()) tgt.addSpecimen(Reference40_50.convertReference(t));
173    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getBodySite())
174      tgt.addBodySite(CodeableConcept40_50.convertCodeableConcept(t));
175    for (org.hl7.fhir.r5.model.Annotation t : src.getNote()) tgt.addNote(Annotation40_50.convertAnnotation(t));
176    if (src.hasPatientInstruction())
177      tgt.setPatientInstructionElement(String40_50.convertString(src.getPatientInstructionElement()));
178    for (org.hl7.fhir.r5.model.Reference t : src.getRelevantHistory())
179      tgt.addRelevantHistory(Reference40_50.convertReference(t));
180    return tgt;
181  }
182
183  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.RequestStatus> convertServiceRequestStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestStatus> src) throws FHIRException {
184    if (src == null || src.isEmpty())
185      return null;
186    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.RequestStatus> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.RequestStatusEnumFactory());
187    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
188    switch (src.getValue()) {
189      case DRAFT:
190        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestStatus.DRAFT);
191        break;
192      case ACTIVE:
193        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestStatus.ACTIVE);
194        break;
195      case ONHOLD:
196        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestStatus.ONHOLD);
197        break;
198      case REVOKED:
199        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestStatus.REVOKED);
200        break;
201      case COMPLETED:
202        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestStatus.COMPLETED);
203        break;
204      case ENTEREDINERROR:
205        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestStatus.ENTEREDINERROR);
206        break;
207      case UNKNOWN:
208        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestStatus.UNKNOWN);
209        break;
210      default:
211        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestStatus.NULL);
212        break;
213    }
214    return tgt;
215  }
216
217  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestStatus> convertServiceRequestStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.RequestStatus> src) throws FHIRException {
218    if (src == null || src.isEmpty())
219      return null;
220    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());
221    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
222    switch (src.getValue()) {
223      case DRAFT:
224        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestStatus.DRAFT);
225        break;
226      case ACTIVE:
227        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestStatus.ACTIVE);
228        break;
229      case ONHOLD:
230        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestStatus.ONHOLD);
231        break;
232      case REVOKED:
233        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestStatus.REVOKED);
234        break;
235      case COMPLETED:
236        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestStatus.COMPLETED);
237        break;
238      case ENTEREDINERROR:
239        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestStatus.ENTEREDINERROR);
240        break;
241      case UNKNOWN:
242        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestStatus.UNKNOWN);
243        break;
244      default:
245        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestStatus.NULL);
246        break;
247    }
248    return tgt;
249  }
250
251  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.RequestIntent> convertServiceRequestIntent(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.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.RequestIntent> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.RequestIntentEnumFactory());
255    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
256    switch (src.getValue()) {
257      case PROPOSAL:
258        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestIntent.PROPOSAL);
259        break;
260      case PLAN:
261        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestIntent.PLAN);
262        break;
263      case DIRECTIVE:
264        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestIntent.DIRECTIVE);
265        break;
266      case ORDER:
267        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestIntent.ORDER);
268        break;
269      case ORIGINALORDER:
270        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestIntent.ORIGINALORDER);
271        break;
272      case REFLEXORDER:
273        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestIntent.REFLEXORDER);
274        break;
275      case FILLERORDER:
276        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestIntent.FILLERORDER);
277        break;
278      case INSTANCEORDER:
279        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestIntent.INSTANCEORDER);
280        break;
281      case OPTION:
282        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestIntent.OPTION);
283        break;
284      default:
285        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestIntent.NULL);
286        break;
287    }
288    return tgt;
289  }
290
291  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestIntent> convertServiceRequestIntent(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.RequestIntent> src) throws FHIRException {
292    if (src == null || src.isEmpty())
293      return null;
294    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());
295    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
296    switch (src.getValue()) {
297      case PROPOSAL:
298        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestIntent.PROPOSAL);
299        break;
300      case PLAN:
301        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestIntent.PLAN);
302        break;
303      case DIRECTIVE:
304        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestIntent.DIRECTIVE);
305        break;
306      case ORDER:
307        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestIntent.ORDER);
308        break;
309      case ORIGINALORDER:
310        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestIntent.ORIGINALORDER);
311        break;
312      case REFLEXORDER:
313        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestIntent.REFLEXORDER);
314        break;
315      case FILLERORDER:
316        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestIntent.FILLERORDER);
317        break;
318      case INSTANCEORDER:
319        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestIntent.INSTANCEORDER);
320        break;
321      case OPTION:
322        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestIntent.OPTION);
323        break;
324      default:
325        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestIntent.NULL);
326        break;
327    }
328    return tgt;
329  }
330
331  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.RequestPriority> convertServiceRequestPriority(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestPriority> src) throws FHIRException {
332    if (src == null || src.isEmpty())
333      return null;
334    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.RequestPriority> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.RequestPriorityEnumFactory());
335    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
336    switch (src.getValue()) {
337      case ROUTINE:
338        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestPriority.ROUTINE);
339        break;
340      case URGENT:
341        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestPriority.URGENT);
342        break;
343      case ASAP:
344        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestPriority.ASAP);
345        break;
346      case STAT:
347        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestPriority.STAT);
348        break;
349      default:
350        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestPriority.NULL);
351        break;
352    }
353    return tgt;
354  }
355
356  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestPriority> convertServiceRequestPriority(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.RequestPriority> src) throws FHIRException {
357    if (src == null || src.isEmpty())
358      return null;
359    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());
360    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
361    switch (src.getValue()) {
362      case ROUTINE:
363        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestPriority.ROUTINE);
364        break;
365      case URGENT:
366        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestPriority.URGENT);
367        break;
368      case ASAP:
369        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestPriority.ASAP);
370        break;
371      case STAT:
372        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestPriority.STAT);
373        break;
374      default:
375        tgt.setValue(org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestPriority.NULL);
376        break;
377    }
378    return tgt;
379  }
380}