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.Boolean40_50;
008import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.DateTime40_50;
009import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.String40_50;
010import org.hl7.fhir.convertors.conv40_50.datatypes40_50.special40_50.Reference40_50;
011import org.hl7.fhir.exceptions.FHIRException;
012
013/*
014  Copyright (c) 2011+, HL7, Inc.
015  All rights reserved.
016  
017  Redistribution and use in source and binary forms, with or without modification, 
018  are permitted provided that the following conditions are met:
019  
020   * Redistributions of source code must retain the above copyright notice, this 
021     list of conditions and the following disclaimer.
022   * Redistributions in binary form must reproduce the above copyright notice, 
023     this list of conditions and the following disclaimer in the documentation 
024     and/or other materials provided with the distribution.
025   * Neither the name of HL7 nor the names of its contributors may be used to 
026     endorse or promote products derived from this software without specific 
027     prior written permission.
028  
029  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
030  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
031  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
032  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
033  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
034  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
035  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
036  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
037  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
038  POSSIBILITY OF SUCH DAMAGE.
039  
040*/
041// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0
042public class ListResource40_50 {
043
044  public static org.hl7.fhir.r5.model.ListResource convertListResource(org.hl7.fhir.r4.model.ListResource src) throws FHIRException {
045    if (src == null)
046      return null;
047    org.hl7.fhir.r5.model.ListResource tgt = new org.hl7.fhir.r5.model.ListResource();
048    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt);
049    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
050      tgt.addIdentifier(Identifier40_50.convertIdentifier(t));
051    if (src.hasStatus())
052      tgt.setStatusElement(convertListStatus(src.getStatusElement()));
053    if (src.hasMode())
054      tgt.setModeElement(convertListMode(src.getModeElement()));
055    if (src.hasTitle())
056      tgt.setTitleElement(String40_50.convertString(src.getTitleElement()));
057    if (src.hasCode())
058      tgt.setCode(CodeableConcept40_50.convertCodeableConcept(src.getCode()));
059    if (src.hasSubject())
060      tgt.addSubject(Reference40_50.convertReference(src.getSubject()));
061    if (src.hasEncounter())
062      tgt.setEncounter(Reference40_50.convertReference(src.getEncounter()));
063    if (src.hasDate())
064      tgt.setDateElement(DateTime40_50.convertDateTime(src.getDateElement()));
065    if (src.hasSource())
066      tgt.setSource(Reference40_50.convertReference(src.getSource()));
067    if (src.hasOrderedBy())
068      tgt.setOrderedBy(CodeableConcept40_50.convertCodeableConcept(src.getOrderedBy()));
069    for (org.hl7.fhir.r4.model.Annotation t : src.getNote()) tgt.addNote(Annotation40_50.convertAnnotation(t));
070    for (org.hl7.fhir.r4.model.ListResource.ListEntryComponent t : src.getEntry())
071      tgt.addEntry(convertListEntryComponent(t));
072    if (src.hasEmptyReason())
073      tgt.setEmptyReason(CodeableConcept40_50.convertCodeableConcept(src.getEmptyReason()));
074    return tgt;
075  }
076
077  public static org.hl7.fhir.r4.model.ListResource convertListResource(org.hl7.fhir.r5.model.ListResource src) throws FHIRException {
078    if (src == null)
079      return null;
080    org.hl7.fhir.r4.model.ListResource tgt = new org.hl7.fhir.r4.model.ListResource();
081    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt);
082    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
083      tgt.addIdentifier(Identifier40_50.convertIdentifier(t));
084    if (src.hasStatus())
085      tgt.setStatusElement(convertListStatus(src.getStatusElement()));
086    if (src.hasMode())
087      tgt.setModeElement(convertListMode(src.getModeElement()));
088    if (src.hasTitle())
089      tgt.setTitleElement(String40_50.convertString(src.getTitleElement()));
090    if (src.hasCode())
091      tgt.setCode(CodeableConcept40_50.convertCodeableConcept(src.getCode()));
092    if (src.hasSubject())
093      tgt.setSubject(Reference40_50.convertReference(src.getSubjectFirstRep()));
094    if (src.hasEncounter())
095      tgt.setEncounter(Reference40_50.convertReference(src.getEncounter()));
096    if (src.hasDate())
097      tgt.setDateElement(DateTime40_50.convertDateTime(src.getDateElement()));
098    if (src.hasSource())
099      tgt.setSource(Reference40_50.convertReference(src.getSource()));
100    if (src.hasOrderedBy())
101      tgt.setOrderedBy(CodeableConcept40_50.convertCodeableConcept(src.getOrderedBy()));
102    for (org.hl7.fhir.r5.model.Annotation t : src.getNote()) tgt.addNote(Annotation40_50.convertAnnotation(t));
103    for (org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent t : src.getEntry())
104      tgt.addEntry(convertListEntryComponent(t));
105    if (src.hasEmptyReason())
106      tgt.setEmptyReason(CodeableConcept40_50.convertCodeableConcept(src.getEmptyReason()));
107    return tgt;
108  }
109
110  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ListResource.ListStatus> convertListStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ListResource.ListStatus> src) throws FHIRException {
111    if (src == null || src.isEmpty())
112      return null;
113    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ListResource.ListStatus> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ListResource.ListStatusEnumFactory());
114    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
115    switch (src.getValue()) {
116      case CURRENT:
117        tgt.setValue(org.hl7.fhir.r5.model.ListResource.ListStatus.CURRENT);
118        break;
119      case RETIRED:
120        tgt.setValue(org.hl7.fhir.r5.model.ListResource.ListStatus.RETIRED);
121        break;
122      case ENTEREDINERROR:
123        tgt.setValue(org.hl7.fhir.r5.model.ListResource.ListStatus.ENTEREDINERROR);
124        break;
125      default:
126        tgt.setValue(org.hl7.fhir.r5.model.ListResource.ListStatus.NULL);
127        break;
128    }
129    return tgt;
130  }
131
132  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ListResource.ListStatus> convertListStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ListResource.ListStatus> src) throws FHIRException {
133    if (src == null || src.isEmpty())
134      return null;
135    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ListResource.ListStatus> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ListResource.ListStatusEnumFactory());
136    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
137    switch (src.getValue()) {
138      case CURRENT:
139        tgt.setValue(org.hl7.fhir.r4.model.ListResource.ListStatus.CURRENT);
140        break;
141      case RETIRED:
142        tgt.setValue(org.hl7.fhir.r4.model.ListResource.ListStatus.RETIRED);
143        break;
144      case ENTEREDINERROR:
145        tgt.setValue(org.hl7.fhir.r4.model.ListResource.ListStatus.ENTEREDINERROR);
146        break;
147      default:
148        tgt.setValue(org.hl7.fhir.r4.model.ListResource.ListStatus.NULL);
149        break;
150    }
151    return tgt;
152  }
153
154  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.ListMode> convertListMode(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ListResource.ListMode> src) throws FHIRException {
155    if (src == null || src.isEmpty())
156      return null;
157    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.ListMode> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.ListModeEnumFactory());
158    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
159    switch (src.getValue()) {
160      case WORKING:
161        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ListMode.WORKING);
162        break;
163      case SNAPSHOT:
164        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ListMode.SNAPSHOT);
165        break;
166      case CHANGES:
167        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ListMode.CHANGES);
168        break;
169      default:
170        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ListMode.NULL);
171        break;
172    }
173    return tgt;
174  }
175
176  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ListResource.ListMode> convertListMode(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.ListMode> src) throws FHIRException {
177    if (src == null || src.isEmpty())
178      return null;
179    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ListResource.ListMode> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ListResource.ListModeEnumFactory());
180    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
181    switch (src.getValue()) {
182      case WORKING:
183        tgt.setValue(org.hl7.fhir.r4.model.ListResource.ListMode.WORKING);
184        break;
185      case SNAPSHOT:
186        tgt.setValue(org.hl7.fhir.r4.model.ListResource.ListMode.SNAPSHOT);
187        break;
188      case CHANGES:
189        tgt.setValue(org.hl7.fhir.r4.model.ListResource.ListMode.CHANGES);
190        break;
191      default:
192        tgt.setValue(org.hl7.fhir.r4.model.ListResource.ListMode.NULL);
193        break;
194    }
195    return tgt;
196  }
197
198  public static org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent convertListEntryComponent(org.hl7.fhir.r4.model.ListResource.ListEntryComponent src) throws FHIRException {
199    if (src == null)
200      return null;
201    org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent tgt = new org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent();
202    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
203    if (src.hasFlag())
204      tgt.setFlag(CodeableConcept40_50.convertCodeableConcept(src.getFlag()));
205    if (src.hasDeleted())
206      tgt.setDeletedElement(Boolean40_50.convertBoolean(src.getDeletedElement()));
207    if (src.hasDate())
208      tgt.setDateElement(DateTime40_50.convertDateTime(src.getDateElement()));
209    if (src.hasItem())
210      tgt.setItem(Reference40_50.convertReference(src.getItem()));
211    return tgt;
212  }
213
214  public static org.hl7.fhir.r4.model.ListResource.ListEntryComponent convertListEntryComponent(org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent src) throws FHIRException {
215    if (src == null)
216      return null;
217    org.hl7.fhir.r4.model.ListResource.ListEntryComponent tgt = new org.hl7.fhir.r4.model.ListResource.ListEntryComponent();
218    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
219    if (src.hasFlag())
220      tgt.setFlag(CodeableConcept40_50.convertCodeableConcept(src.getFlag()));
221    if (src.hasDeleted())
222      tgt.setDeletedElement(Boolean40_50.convertBoolean(src.getDeletedElement()));
223    if (src.hasDate())
224      tgt.setDateElement(DateTime40_50.convertDateTime(src.getDateElement()));
225    if (src.hasItem())
226      tgt.setItem(Reference40_50.convertReference(src.getItem()));
227    return tgt;
228  }
229}