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.complextypes30_50.SimpleQuantity30_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 Specimen30_50 {
014
015  public static org.hl7.fhir.dstu3.model.Specimen convertSpecimen(org.hl7.fhir.r5.model.Specimen src) throws FHIRException {
016    if (src == null)
017      return null;
018    org.hl7.fhir.dstu3.model.Specimen tgt = new org.hl7.fhir.dstu3.model.Specimen();
019    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
020    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
021      tgt.addIdentifier(Identifier30_50.convertIdentifier(t));
022    if (src.hasAccessionIdentifier())
023      tgt.setAccessionIdentifier(Identifier30_50.convertIdentifier(src.getAccessionIdentifier()));
024    if (src.hasStatus())
025      tgt.setStatusElement(convertSpecimenStatus(src.getStatusElement()));
026    if (src.hasType())
027      tgt.setType(CodeableConcept30_50.convertCodeableConcept(src.getType()));
028    if (src.hasSubject())
029      tgt.setSubject(Reference30_50.convertReference(src.getSubject()));
030    if (src.hasReceivedTime())
031      tgt.setReceivedTimeElement(DateTime30_50.convertDateTime(src.getReceivedTimeElement()));
032    for (org.hl7.fhir.r5.model.Reference t : src.getParent()) tgt.addParent(Reference30_50.convertReference(t));
033    for (org.hl7.fhir.r5.model.Reference t : src.getRequest()) tgt.addRequest(Reference30_50.convertReference(t));
034    if (src.hasCollection())
035      tgt.setCollection(convertSpecimenCollectionComponent(src.getCollection()));
036    for (org.hl7.fhir.r5.model.Specimen.SpecimenProcessingComponent t : src.getProcessing())
037      tgt.addProcessing(convertSpecimenProcessingComponent(t));
038    for (org.hl7.fhir.r5.model.Specimen.SpecimenContainerComponent t : src.getContainer())
039      tgt.addContainer(convertSpecimenContainerComponent(t));
040    for (org.hl7.fhir.r5.model.Annotation t : src.getNote()) tgt.addNote(Annotation30_50.convertAnnotation(t));
041    return tgt;
042  }
043
044  public static org.hl7.fhir.r5.model.Specimen convertSpecimen(org.hl7.fhir.dstu3.model.Specimen src) throws FHIRException {
045    if (src == null)
046      return null;
047    org.hl7.fhir.r5.model.Specimen tgt = new org.hl7.fhir.r5.model.Specimen();
048    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
049    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
050      tgt.addIdentifier(Identifier30_50.convertIdentifier(t));
051    if (src.hasAccessionIdentifier())
052      tgt.setAccessionIdentifier(Identifier30_50.convertIdentifier(src.getAccessionIdentifier()));
053    if (src.hasStatus())
054      tgt.setStatusElement(convertSpecimenStatus(src.getStatusElement()));
055    if (src.hasType())
056      tgt.setType(CodeableConcept30_50.convertCodeableConcept(src.getType()));
057    if (src.hasSubject())
058      tgt.setSubject(Reference30_50.convertReference(src.getSubject()));
059    if (src.hasReceivedTime())
060      tgt.setReceivedTimeElement(DateTime30_50.convertDateTime(src.getReceivedTimeElement()));
061    for (org.hl7.fhir.dstu3.model.Reference t : src.getParent()) tgt.addParent(Reference30_50.convertReference(t));
062    for (org.hl7.fhir.dstu3.model.Reference t : src.getRequest()) tgt.addRequest(Reference30_50.convertReference(t));
063    if (src.hasCollection())
064      tgt.setCollection(convertSpecimenCollectionComponent(src.getCollection()));
065    for (org.hl7.fhir.dstu3.model.Specimen.SpecimenProcessingComponent t : src.getProcessing())
066      tgt.addProcessing(convertSpecimenProcessingComponent(t));
067    for (org.hl7.fhir.dstu3.model.Specimen.SpecimenContainerComponent t : src.getContainer())
068      tgt.addContainer(convertSpecimenContainerComponent(t));
069    for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote()) tgt.addNote(Annotation30_50.convertAnnotation(t));
070    return tgt;
071  }
072
073  public static org.hl7.fhir.r5.model.Specimen.SpecimenCollectionComponent convertSpecimenCollectionComponent(org.hl7.fhir.dstu3.model.Specimen.SpecimenCollectionComponent src) throws FHIRException {
074    if (src == null)
075      return null;
076    org.hl7.fhir.r5.model.Specimen.SpecimenCollectionComponent tgt = new org.hl7.fhir.r5.model.Specimen.SpecimenCollectionComponent();
077    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyBackboneElement(src,tgt);
078    if (src.hasCollector())
079      tgt.setCollector(Reference30_50.convertReference(src.getCollector()));
080    if (src.hasCollected())
081      tgt.setCollected(ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getCollected()));
082    if (src.hasQuantity())
083      tgt.setQuantity(SimpleQuantity30_50.convertSimpleQuantity(src.getQuantity()));
084    if (src.hasMethod())
085      tgt.setMethod(CodeableConcept30_50.convertCodeableConcept(src.getMethod()));
086    if (src.hasBodySite())
087      tgt.getBodySite().setConcept(CodeableConcept30_50.convertCodeableConcept(src.getBodySite()));
088    return tgt;
089  }
090
091  public static org.hl7.fhir.dstu3.model.Specimen.SpecimenCollectionComponent convertSpecimenCollectionComponent(org.hl7.fhir.r5.model.Specimen.SpecimenCollectionComponent src) throws FHIRException {
092    if (src == null)
093      return null;
094    org.hl7.fhir.dstu3.model.Specimen.SpecimenCollectionComponent tgt = new org.hl7.fhir.dstu3.model.Specimen.SpecimenCollectionComponent();
095    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyBackboneElement(src,tgt);
096    if (src.hasCollector())
097      tgt.setCollector(Reference30_50.convertReference(src.getCollector()));
098    if (src.hasCollected())
099      tgt.setCollected(ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getCollected()));
100    if (src.hasQuantity())
101      tgt.setQuantity(SimpleQuantity30_50.convertSimpleQuantity(src.getQuantity()));
102    if (src.hasMethod())
103      tgt.setMethod(CodeableConcept30_50.convertCodeableConcept(src.getMethod()));
104    if (src.getBodySite().hasConcept())
105      tgt.setBodySite(CodeableConcept30_50.convertCodeableConcept(src.getBodySite().getConcept()));
106    return tgt;
107  }
108
109  public static org.hl7.fhir.dstu3.model.Specimen.SpecimenContainerComponent convertSpecimenContainerComponent(org.hl7.fhir.r5.model.Specimen.SpecimenContainerComponent src) throws FHIRException {
110    if (src == null)
111      return null;
112    org.hl7.fhir.dstu3.model.Specimen.SpecimenContainerComponent tgt = new org.hl7.fhir.dstu3.model.Specimen.SpecimenContainerComponent();
113    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyBackboneElement(src,tgt);
114//    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
115//      tgt.addIdentifier(Identifier30_50.convertIdentifier(t));
116//    if (src.hasDescription())
117//      tgt.setDescriptionElement(String30_50.convertString(src.getDescriptionElement()));
118//    if (src.hasType())
119//      tgt.setType(CodeableConcept30_50.convertCodeableConcept(src.getType()));
120//    if (src.hasCapacity())
121//      tgt.setCapacity(SimpleQuantity30_50.convertSimpleQuantity(src.getCapacity()));
122//    if (src.hasSpecimenQuantity())
123//      tgt.setSpecimenQuantity(SimpleQuantity30_50.convertSimpleQuantity(src.getSpecimenQuantity()));
124//    if (src.hasAdditive())
125//      tgt.setAdditive(ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getAdditive()));
126    return tgt;
127  }
128
129  public static org.hl7.fhir.r5.model.Specimen.SpecimenContainerComponent convertSpecimenContainerComponent(org.hl7.fhir.dstu3.model.Specimen.SpecimenContainerComponent src) throws FHIRException {
130    if (src == null)
131      return null;
132    org.hl7.fhir.r5.model.Specimen.SpecimenContainerComponent tgt = new org.hl7.fhir.r5.model.Specimen.SpecimenContainerComponent();
133    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyBackboneElement(src,tgt);
134//    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
135//      tgt.addIdentifier(Identifier30_50.convertIdentifier(t));
136//    if (src.hasDescription())
137//      tgt.setDescriptionElement(String30_50.convertString(src.getDescriptionElement()));
138//    if (src.hasType())
139//      tgt.setType(CodeableConcept30_50.convertCodeableConcept(src.getType()));
140//    if (src.hasCapacity())
141//      tgt.setCapacity(SimpleQuantity30_50.convertSimpleQuantity(src.getCapacity()));
142//    if (src.hasSpecimenQuantity())
143//      tgt.setSpecimenQuantity(SimpleQuantity30_50.convertSimpleQuantity(src.getSpecimenQuantity()));
144//    if (src.hasAdditive())
145//      tgt.setAdditive(ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getAdditive()));
146    return tgt;
147  }
148
149  public static org.hl7.fhir.r5.model.Specimen.SpecimenProcessingComponent convertSpecimenProcessingComponent(org.hl7.fhir.dstu3.model.Specimen.SpecimenProcessingComponent src) throws FHIRException {
150    if (src == null)
151      return null;
152    org.hl7.fhir.r5.model.Specimen.SpecimenProcessingComponent tgt = new org.hl7.fhir.r5.model.Specimen.SpecimenProcessingComponent();
153    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyBackboneElement(src,tgt);
154    if (src.hasDescription())
155      tgt.setDescriptionElement(String30_50.convertString(src.getDescriptionElement()));
156//    if (src.hasProcedure())
157//      tgt.setProcedure(CodeableConcept30_50.convertCodeableConcept(src.getProcedure()));
158    for (org.hl7.fhir.dstu3.model.Reference t : src.getAdditive()) tgt.addAdditive(Reference30_50.convertReference(t));
159    if (src.hasTime())
160      tgt.setTime(ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getTime()));
161    return tgt;
162  }
163
164  public static org.hl7.fhir.dstu3.model.Specimen.SpecimenProcessingComponent convertSpecimenProcessingComponent(org.hl7.fhir.r5.model.Specimen.SpecimenProcessingComponent src) throws FHIRException {
165    if (src == null)
166      return null;
167    org.hl7.fhir.dstu3.model.Specimen.SpecimenProcessingComponent tgt = new org.hl7.fhir.dstu3.model.Specimen.SpecimenProcessingComponent();
168    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyBackboneElement(src,tgt);
169    if (src.hasDescription())
170      tgt.setDescriptionElement(String30_50.convertString(src.getDescriptionElement()));
171//    if (src.hasProcedure())
172//      tgt.setProcedure(CodeableConcept30_50.convertCodeableConcept(src.getProcedure()));
173    for (org.hl7.fhir.r5.model.Reference t : src.getAdditive()) tgt.addAdditive(Reference30_50.convertReference(t));
174    if (src.hasTime())
175      tgt.setTime(ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getTime()));
176    return tgt;
177  }
178
179  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Specimen.SpecimenStatus> convertSpecimenStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Specimen.SpecimenStatus> src) throws FHIRException {
180    if (src == null || src.isEmpty())
181      return null;
182    org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Specimen.SpecimenStatus> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Specimen.SpecimenStatusEnumFactory());
183    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
184    switch (src.getValue()) {
185      case AVAILABLE:
186        tgt.setValue(org.hl7.fhir.dstu3.model.Specimen.SpecimenStatus.AVAILABLE);
187        break;
188      case UNAVAILABLE:
189        tgt.setValue(org.hl7.fhir.dstu3.model.Specimen.SpecimenStatus.UNAVAILABLE);
190        break;
191      case UNSATISFACTORY:
192        tgt.setValue(org.hl7.fhir.dstu3.model.Specimen.SpecimenStatus.UNSATISFACTORY);
193        break;
194      case ENTEREDINERROR:
195        tgt.setValue(org.hl7.fhir.dstu3.model.Specimen.SpecimenStatus.ENTEREDINERROR);
196        break;
197      default:
198        tgt.setValue(org.hl7.fhir.dstu3.model.Specimen.SpecimenStatus.NULL);
199        break;
200    }
201    return tgt;
202  }
203
204  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Specimen.SpecimenStatus> convertSpecimenStatus(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Specimen.SpecimenStatus> src) throws FHIRException {
205    if (src == null || src.isEmpty())
206      return null;
207    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Specimen.SpecimenStatus> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Specimen.SpecimenStatusEnumFactory());
208    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
209    switch (src.getValue()) {
210      case AVAILABLE:
211        tgt.setValue(org.hl7.fhir.r5.model.Specimen.SpecimenStatus.AVAILABLE);
212        break;
213      case UNAVAILABLE:
214        tgt.setValue(org.hl7.fhir.r5.model.Specimen.SpecimenStatus.UNAVAILABLE);
215        break;
216      case UNSATISFACTORY:
217        tgt.setValue(org.hl7.fhir.r5.model.Specimen.SpecimenStatus.UNSATISFACTORY);
218        break;
219      case ENTEREDINERROR:
220        tgt.setValue(org.hl7.fhir.r5.model.Specimen.SpecimenStatus.ENTEREDINERROR);
221        break;
222      default:
223        tgt.setValue(org.hl7.fhir.r5.model.Specimen.SpecimenStatus.NULL);
224        break;
225    }
226    return tgt;
227  }
228}