001package org.hl7.fhir.convertors.conv30_50.resources30_50;
002
003import org.hl7.fhir.convertors.context.ConversionContext30_50;
004import org.hl7.fhir.convertors.conv30_50.datatypes30_50.Reference30_50;
005import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.Annotation30_50;
006import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.CodeableConcept30_50;
007import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.Identifier30_50;
008import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Boolean30_50;
009import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.DateTime30_50;
010import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.String30_50;
011import org.hl7.fhir.exceptions.FHIRException;
012
013public class List30_50 {
014
015  public static org.hl7.fhir.r5.model.ListResource convertList(org.hl7.fhir.dstu3.model.ListResource src) throws FHIRException {
016    if (src == null)
017      return null;
018    org.hl7.fhir.r5.model.ListResource tgt = new org.hl7.fhir.r5.model.ListResource();
019    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
020    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
021      tgt.addIdentifier(Identifier30_50.convertIdentifier(t));
022    if (src.hasStatus())
023      tgt.setStatusElement(convertListStatus(src.getStatusElement()));
024    if (src.hasMode())
025      tgt.setModeElement(convertListMode(src.getModeElement()));
026    if (src.hasTitle())
027      tgt.setTitleElement(String30_50.convertString(src.getTitleElement()));
028    if (src.hasCode())
029      tgt.setCode(CodeableConcept30_50.convertCodeableConcept(src.getCode()));
030    if (src.hasSubject())
031      tgt.setSubject(Reference30_50.convertReference(src.getSubject()));
032    if (src.hasEncounter())
033      tgt.setEncounter(Reference30_50.convertReference(src.getEncounter()));
034    if (src.hasDate())
035      tgt.setDateElement(DateTime30_50.convertDateTime(src.getDateElement()));
036    if (src.hasSource())
037      tgt.setSource(Reference30_50.convertReference(src.getSource()));
038    if (src.hasOrderedBy())
039      tgt.setOrderedBy(CodeableConcept30_50.convertCodeableConcept(src.getOrderedBy()));
040    for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote()) tgt.addNote(Annotation30_50.convertAnnotation(t));
041    for (org.hl7.fhir.dstu3.model.ListResource.ListEntryComponent t : src.getEntry())
042      tgt.addEntry(convertListEntryComponent(t));
043    if (src.hasEmptyReason())
044      tgt.setEmptyReason(CodeableConcept30_50.convertCodeableConcept(src.getEmptyReason()));
045    return tgt;
046  }
047
048  public static org.hl7.fhir.dstu3.model.ListResource convertList(org.hl7.fhir.r5.model.ListResource src) throws FHIRException {
049    if (src == null)
050      return null;
051    org.hl7.fhir.dstu3.model.ListResource tgt = new org.hl7.fhir.dstu3.model.ListResource();
052    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
053    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
054      tgt.addIdentifier(Identifier30_50.convertIdentifier(t));
055    if (src.hasStatus())
056      tgt.setStatusElement(convertListStatus(src.getStatusElement()));
057    if (src.hasMode())
058      tgt.setModeElement(convertListMode(src.getModeElement()));
059    if (src.hasTitle())
060      tgt.setTitleElement(String30_50.convertString(src.getTitleElement()));
061    if (src.hasCode())
062      tgt.setCode(CodeableConcept30_50.convertCodeableConcept(src.getCode()));
063    if (src.hasSubject())
064      tgt.setSubject(Reference30_50.convertReference(src.getSubject()));
065    if (src.hasEncounter())
066      tgt.setEncounter(Reference30_50.convertReference(src.getEncounter()));
067    if (src.hasDate())
068      tgt.setDateElement(DateTime30_50.convertDateTime(src.getDateElement()));
069    if (src.hasSource())
070      tgt.setSource(Reference30_50.convertReference(src.getSource()));
071    if (src.hasOrderedBy())
072      tgt.setOrderedBy(CodeableConcept30_50.convertCodeableConcept(src.getOrderedBy()));
073    for (org.hl7.fhir.r5.model.Annotation t : src.getNote()) tgt.addNote(Annotation30_50.convertAnnotation(t));
074    for (org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent t : src.getEntry())
075      tgt.addEntry(convertListEntryComponent(t));
076    if (src.hasEmptyReason())
077      tgt.setEmptyReason(CodeableConcept30_50.convertCodeableConcept(src.getEmptyReason()));
078    return tgt;
079  }
080
081  public static org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent convertListEntryComponent(org.hl7.fhir.dstu3.model.ListResource.ListEntryComponent src) throws FHIRException {
082    if (src == null)
083      return null;
084    org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent tgt = new org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent();
085    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
086    if (src.hasFlag())
087      tgt.setFlag(CodeableConcept30_50.convertCodeableConcept(src.getFlag()));
088    if (src.hasDeleted())
089      tgt.setDeletedElement(Boolean30_50.convertBoolean(src.getDeletedElement()));
090    if (src.hasDate())
091      tgt.setDateElement(DateTime30_50.convertDateTime(src.getDateElement()));
092    if (src.hasItem())
093      tgt.setItem(Reference30_50.convertReference(src.getItem()));
094    return tgt;
095  }
096
097  public static org.hl7.fhir.dstu3.model.ListResource.ListEntryComponent convertListEntryComponent(org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent src) throws FHIRException {
098    if (src == null)
099      return null;
100    org.hl7.fhir.dstu3.model.ListResource.ListEntryComponent tgt = new org.hl7.fhir.dstu3.model.ListResource.ListEntryComponent();
101    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
102    if (src.hasFlag())
103      tgt.setFlag(CodeableConcept30_50.convertCodeableConcept(src.getFlag()));
104    if (src.hasDeleted())
105      tgt.setDeletedElement(Boolean30_50.convertBoolean(src.getDeletedElement()));
106    if (src.hasDate())
107      tgt.setDateElement(DateTime30_50.convertDateTime(src.getDateElement()));
108    if (src.hasItem())
109      tgt.setItem(Reference30_50.convertReference(src.getItem()));
110    return tgt;
111  }
112
113  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.ListMode> convertListMode(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ListResource.ListMode> src) throws FHIRException {
114    if (src == null || src.isEmpty())
115      return null;
116    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());
117    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
118    switch (src.getValue()) {
119      case WORKING:
120        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ListMode.WORKING);
121        break;
122      case SNAPSHOT:
123        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ListMode.SNAPSHOT);
124        break;
125      case CHANGES:
126        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ListMode.CHANGES);
127        break;
128      default:
129        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ListMode.NULL);
130        break;
131    }
132    return tgt;
133  }
134
135  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ListResource.ListMode> convertListMode(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.ListMode> src) throws FHIRException {
136    if (src == null || src.isEmpty())
137      return null;
138    org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ListResource.ListMode> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ListResource.ListModeEnumFactory());
139    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
140    switch (src.getValue()) {
141      case WORKING:
142        tgt.setValue(org.hl7.fhir.dstu3.model.ListResource.ListMode.WORKING);
143        break;
144      case SNAPSHOT:
145        tgt.setValue(org.hl7.fhir.dstu3.model.ListResource.ListMode.SNAPSHOT);
146        break;
147      case CHANGES:
148        tgt.setValue(org.hl7.fhir.dstu3.model.ListResource.ListMode.CHANGES);
149        break;
150      default:
151        tgt.setValue(org.hl7.fhir.dstu3.model.ListResource.ListMode.NULL);
152        break;
153    }
154    return tgt;
155  }
156
157  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ListResource.ListStatus> convertListStatus(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ListResource.ListStatus> src) throws FHIRException {
158    if (src == null || src.isEmpty())
159      return null;
160    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());
161    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
162    switch (src.getValue()) {
163      case CURRENT:
164        tgt.setValue(org.hl7.fhir.r5.model.ListResource.ListStatus.CURRENT);
165        break;
166      case RETIRED:
167        tgt.setValue(org.hl7.fhir.r5.model.ListResource.ListStatus.RETIRED);
168        break;
169      case ENTEREDINERROR:
170        tgt.setValue(org.hl7.fhir.r5.model.ListResource.ListStatus.ENTEREDINERROR);
171        break;
172      default:
173        tgt.setValue(org.hl7.fhir.r5.model.ListResource.ListStatus.NULL);
174        break;
175    }
176    return tgt;
177  }
178
179  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ListResource.ListStatus> convertListStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ListResource.ListStatus> src) throws FHIRException {
180    if (src == null || src.isEmpty())
181      return null;
182    org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ListResource.ListStatus> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ListResource.ListStatusEnumFactory());
183    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
184    switch (src.getValue()) {
185      case CURRENT:
186        tgt.setValue(org.hl7.fhir.dstu3.model.ListResource.ListStatus.CURRENT);
187        break;
188      case RETIRED:
189        tgt.setValue(org.hl7.fhir.dstu3.model.ListResource.ListStatus.RETIRED);
190        break;
191      case ENTEREDINERROR:
192        tgt.setValue(org.hl7.fhir.dstu3.model.ListResource.ListStatus.ENTEREDINERROR);
193        break;
194      default:
195        tgt.setValue(org.hl7.fhir.dstu3.model.ListResource.ListStatus.NULL);
196        break;
197    }
198    return tgt;
199  }
200}