001package org.hl7.fhir.convertors.conv10_30.resources10_30;
002
003import org.hl7.fhir.convertors.context.ConversionContext10_30;
004import org.hl7.fhir.convertors.conv10_30.datatypes10_30.Reference10_30;
005import org.hl7.fhir.convertors.conv10_30.datatypes10_30.complextypes10_30.CodeableConcept10_30;
006import org.hl7.fhir.convertors.conv10_30.datatypes10_30.complextypes10_30.SimpleQuantity10_30;
007import org.hl7.fhir.convertors.conv10_30.datatypes10_30.primitivetypes10_30.Boolean10_30;
008import org.hl7.fhir.exceptions.FHIRException;
009
010public class Medication10_30 {
011
012  public static org.hl7.fhir.dstu2.model.Medication convertMedication(org.hl7.fhir.dstu3.model.Medication src) throws FHIRException {
013    if (src == null || src.isEmpty())
014      return null;
015    org.hl7.fhir.dstu2.model.Medication tgt = new org.hl7.fhir.dstu2.model.Medication();
016    ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyDomainResource(src, tgt);
017    if (src.hasCode())
018      tgt.setCode(CodeableConcept10_30.convertCodeableConcept(src.getCode()));
019    if (src.hasIsBrandElement())
020      tgt.setIsBrandElement(Boolean10_30.convertBoolean(src.getIsBrandElement()));
021    if (src.hasManufacturer())
022      tgt.setManufacturer(Reference10_30.convertReference(src.getManufacturer()));
023    if (src.hasPackage())
024      tgt.setPackage(convertMedicationPackageComponent(src.getPackage()));
025    return tgt;
026  }
027
028  public static org.hl7.fhir.dstu3.model.Medication convertMedication(org.hl7.fhir.dstu2.model.Medication src) throws FHIRException {
029    if (src == null || src.isEmpty())
030      return null;
031    org.hl7.fhir.dstu3.model.Medication tgt = new org.hl7.fhir.dstu3.model.Medication();
032    ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyDomainResource(src, tgt);
033    if (src.hasCode())
034      tgt.setCode(CodeableConcept10_30.convertCodeableConcept(src.getCode()));
035    if (src.hasIsBrandElement())
036      tgt.setIsBrandElement(Boolean10_30.convertBoolean(src.getIsBrandElement()));
037    if (src.hasManufacturer())
038      tgt.setManufacturer(Reference10_30.convertReference(src.getManufacturer()));
039    if (src.hasPackage())
040      tgt.setPackage(convertMedicationPackageComponent(src.getPackage()));
041    return tgt;
042  }
043
044  public static org.hl7.fhir.dstu2.model.Medication.MedicationPackageComponent convertMedicationPackageComponent(org.hl7.fhir.dstu3.model.Medication.MedicationPackageComponent src) throws FHIRException {
045    if (src == null || src.isEmpty())
046      return null;
047    org.hl7.fhir.dstu2.model.Medication.MedicationPackageComponent tgt = new org.hl7.fhir.dstu2.model.Medication.MedicationPackageComponent();
048    ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyBackboneElement(src,tgt);
049    if (src.hasContainer())
050      tgt.setContainer(CodeableConcept10_30.convertCodeableConcept(src.getContainer()));
051    for (org.hl7.fhir.dstu3.model.Medication.MedicationPackageContentComponent t : src.getContent())
052      tgt.addContent(convertMedicationPackageContentComponent(t));
053    return tgt;
054  }
055
056  public static org.hl7.fhir.dstu3.model.Medication.MedicationPackageComponent convertMedicationPackageComponent(org.hl7.fhir.dstu2.model.Medication.MedicationPackageComponent src) throws FHIRException {
057    if (src == null || src.isEmpty())
058      return null;
059    org.hl7.fhir.dstu3.model.Medication.MedicationPackageComponent tgt = new org.hl7.fhir.dstu3.model.Medication.MedicationPackageComponent();
060    ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyBackboneElement(src,tgt);
061    if (src.hasContainer())
062      tgt.setContainer(CodeableConcept10_30.convertCodeableConcept(src.getContainer()));
063    for (org.hl7.fhir.dstu2.model.Medication.MedicationPackageContentComponent t : src.getContent())
064      tgt.addContent(convertMedicationPackageContentComponent(t));
065    return tgt;
066  }
067
068  public static org.hl7.fhir.dstu2.model.Medication.MedicationPackageContentComponent convertMedicationPackageContentComponent(org.hl7.fhir.dstu3.model.Medication.MedicationPackageContentComponent src) throws FHIRException {
069    if (src == null || src.isEmpty())
070      return null;
071    org.hl7.fhir.dstu2.model.Medication.MedicationPackageContentComponent tgt = new org.hl7.fhir.dstu2.model.Medication.MedicationPackageContentComponent();
072    ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyBackboneElement(src,tgt);
073    if (src.hasItemReference())
074      tgt.setItem((org.hl7.fhir.dstu2.model.Reference) ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().convertType(src.getItem()));
075    if (src.hasAmount())
076      tgt.setAmount(SimpleQuantity10_30.convertSimpleQuantity(src.getAmount()));
077    return tgt;
078  }
079
080  public static org.hl7.fhir.dstu3.model.Medication.MedicationPackageContentComponent convertMedicationPackageContentComponent(org.hl7.fhir.dstu2.model.Medication.MedicationPackageContentComponent src) throws FHIRException {
081    if (src == null || src.isEmpty())
082      return null;
083    org.hl7.fhir.dstu3.model.Medication.MedicationPackageContentComponent tgt = new org.hl7.fhir.dstu3.model.Medication.MedicationPackageContentComponent();
084    ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyBackboneElement(src,tgt);
085    if (src.hasItem())
086      tgt.setItem(ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().convertType(src.getItem()));
087    if (src.hasAmount())
088      tgt.setAmount(SimpleQuantity10_30.convertSimpleQuantity(src.getAmount()));
089    return tgt;
090  }
091}