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.Identifier10_30; 007import org.hl7.fhir.convertors.conv10_30.datatypes10_30.complextypes10_30.Ratio10_30; 008import org.hl7.fhir.convertors.conv10_30.datatypes10_30.complextypes10_30.Timing10_30; 009import org.hl7.fhir.convertors.conv10_30.datatypes10_30.primitivetypes10_30.DateTime10_30; 010import org.hl7.fhir.convertors.conv10_30.datatypes10_30.primitivetypes10_30.String10_30; 011import org.hl7.fhir.exceptions.FHIRException; 012 013public class MedicationStatement10_30 { 014 015 public static org.hl7.fhir.dstu3.model.MedicationStatement convertMedicationStatement(org.hl7.fhir.dstu2.model.MedicationStatement src) throws FHIRException { 016 if (src == null || src.isEmpty()) 017 return null; 018 org.hl7.fhir.dstu3.model.MedicationStatement tgt = new org.hl7.fhir.dstu3.model.MedicationStatement(); 019 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyDomainResource(src, tgt); 020 for (org.hl7.fhir.dstu2.model.Identifier t : src.getIdentifier()) 021 tgt.addIdentifier(Identifier10_30.convertIdentifier(t)); 022 if (src.hasStatus()) 023 tgt.setStatusElement(convertMedicationStatementStatus(src.getStatusElement())); 024 if (src.hasMedication()) 025 tgt.setMedication(ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().convertType(src.getMedication())); 026 if (src.hasPatient()) 027 tgt.setSubject(Reference10_30.convertReference(src.getPatient())); 028 if (src.hasEffective()) 029 tgt.setEffective(ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().convertType(src.getEffective())); 030 if (src.hasInformationSource()) 031 tgt.setInformationSource(Reference10_30.convertReference(src.getInformationSource())); 032 for (org.hl7.fhir.dstu2.model.Reference t : src.getSupportingInformation()) 033 tgt.addDerivedFrom(Reference10_30.convertReference(t)); 034 if (src.hasDateAsserted()) 035 tgt.setDateAssertedElement(DateTime10_30.convertDateTime(src.getDateAssertedElement())); 036 for (org.hl7.fhir.dstu2.model.CodeableConcept t : src.getReasonNotTaken()) 037 tgt.addReasonNotTaken(CodeableConcept10_30.convertCodeableConcept(t)); 038 if (src.hasNote()) 039 tgt.addNote().setText(src.getNote()); 040 for (org.hl7.fhir.dstu2.model.MedicationStatement.MedicationStatementDosageComponent t : src.getDosage()) 041 tgt.addDosage(convertMedicationStatementDosageComponent(t)); 042 return tgt; 043 } 044 045 public static org.hl7.fhir.dstu2.model.MedicationStatement convertMedicationStatement(org.hl7.fhir.dstu3.model.MedicationStatement src) throws FHIRException { 046 if (src == null || src.isEmpty()) 047 return null; 048 org.hl7.fhir.dstu2.model.MedicationStatement tgt = new org.hl7.fhir.dstu2.model.MedicationStatement(); 049 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyDomainResource(src, tgt); 050 for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier()) 051 tgt.addIdentifier(Identifier10_30.convertIdentifier(t)); 052 if (src.hasStatus()) 053 tgt.setStatusElement(convertMedicationStatementStatus(src.getStatusElement())); 054 if (src.hasMedication()) 055 tgt.setMedication(ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().convertType(src.getMedication())); 056 if (src.hasSubject()) 057 tgt.setPatient(Reference10_30.convertReference(src.getSubject())); 058 if (src.hasEffective()) 059 tgt.setEffective(ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().convertType(src.getEffective())); 060 if (src.hasInformationSource()) 061 tgt.setInformationSource(Reference10_30.convertReference(src.getInformationSource())); 062 for (org.hl7.fhir.dstu3.model.Reference t : src.getDerivedFrom()) 063 tgt.addSupportingInformation(Reference10_30.convertReference(t)); 064 if (src.hasDateAsserted()) 065 tgt.setDateAssertedElement(DateTime10_30.convertDateTime(src.getDateAssertedElement())); 066 for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getReasonNotTaken()) 067 tgt.addReasonNotTaken(CodeableConcept10_30.convertCodeableConcept(t)); 068 for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote()) tgt.setNote(t.getText()); 069 for (org.hl7.fhir.dstu3.model.Dosage t : src.getDosage()) 070 tgt.addDosage(convertMedicationStatementDosageComponent(t)); 071 return tgt; 072 } 073 074 public static org.hl7.fhir.dstu3.model.Dosage convertMedicationStatementDosageComponent(org.hl7.fhir.dstu2.model.MedicationStatement.MedicationStatementDosageComponent src) throws FHIRException { 075 if (src == null || src.isEmpty()) 076 return null; 077 org.hl7.fhir.dstu3.model.Dosage tgt = new org.hl7.fhir.dstu3.model.Dosage(); 078 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 079 if (src.hasTextElement()) 080 tgt.setTextElement(String10_30.convertString(src.getTextElement())); 081 if (src.hasTiming()) 082 tgt.setTiming(Timing10_30.convertTiming(src.getTiming())); 083 if (src.hasAsNeeded()) 084 tgt.setAsNeeded(ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().convertType(src.getAsNeeded())); 085 if (src.hasSiteCodeableConcept()) 086 tgt.setSite(CodeableConcept10_30.convertCodeableConcept(src.getSiteCodeableConcept())); 087 if (src.hasRoute()) 088 tgt.setRoute(CodeableConcept10_30.convertCodeableConcept(src.getRoute())); 089 if (src.hasMethod()) 090 tgt.setMethod(CodeableConcept10_30.convertCodeableConcept(src.getMethod())); 091 if (src.hasRate()) 092 tgt.setRate(ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().convertType(src.getRate())); 093 if (src.hasMaxDosePerPeriod()) 094 tgt.setMaxDosePerPeriod(Ratio10_30.convertRatio(src.getMaxDosePerPeriod())); 095 return tgt; 096 } 097 098 public static org.hl7.fhir.dstu2.model.MedicationStatement.MedicationStatementDosageComponent convertMedicationStatementDosageComponent(org.hl7.fhir.dstu3.model.Dosage src) throws FHIRException { 099 if (src == null || src.isEmpty()) 100 return null; 101 org.hl7.fhir.dstu2.model.MedicationStatement.MedicationStatementDosageComponent tgt = new org.hl7.fhir.dstu2.model.MedicationStatement.MedicationStatementDosageComponent(); 102 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 103 if (src.hasTextElement()) 104 tgt.setTextElement(String10_30.convertString(src.getTextElement())); 105 if (src.hasTiming()) 106 tgt.setTiming(Timing10_30.convertTiming(src.getTiming())); 107 if (src.hasAsNeeded()) 108 tgt.setAsNeeded(ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().convertType(src.getAsNeeded())); 109 if (src.hasSite()) 110 tgt.setSite(ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().convertType(src.getSite())); 111 if (src.hasRoute()) 112 tgt.setRoute(CodeableConcept10_30.convertCodeableConcept(src.getRoute())); 113 if (src.hasMethod()) 114 tgt.setMethod(CodeableConcept10_30.convertCodeableConcept(src.getMethod())); 115 if (src.hasRate()) 116 tgt.setRate(ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().convertType(src.getRate())); 117 if (src.hasMaxDosePerPeriod()) 118 tgt.setMaxDosePerPeriod(Ratio10_30.convertRatio(src.getMaxDosePerPeriod())); 119 return tgt; 120 } 121 122 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.MedicationStatement.MedicationStatementStatus> convertMedicationStatementStatus(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.MedicationStatement.MedicationStatementStatus> src) throws FHIRException { 123 if (src == null || src.isEmpty()) 124 return null; 125 org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.MedicationStatement.MedicationStatementStatus> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.MedicationStatement.MedicationStatementStatusEnumFactory()); 126 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 127 switch (src.getValue()) { 128 case ACTIVE: 129 tgt.setValue(org.hl7.fhir.dstu3.model.MedicationStatement.MedicationStatementStatus.ACTIVE); 130 break; 131 case COMPLETED: 132 tgt.setValue(org.hl7.fhir.dstu3.model.MedicationStatement.MedicationStatementStatus.COMPLETED); 133 break; 134 case ENTEREDINERROR: 135 tgt.setValue(org.hl7.fhir.dstu3.model.MedicationStatement.MedicationStatementStatus.ENTEREDINERROR); 136 break; 137 case INTENDED: 138 tgt.setValue(org.hl7.fhir.dstu3.model.MedicationStatement.MedicationStatementStatus.INTENDED); 139 break; 140 default: 141 tgt.setValue(org.hl7.fhir.dstu3.model.MedicationStatement.MedicationStatementStatus.NULL); 142 break; 143 } 144 return tgt; 145 } 146 147 static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.MedicationStatement.MedicationStatementStatus> convertMedicationStatementStatus(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.MedicationStatement.MedicationStatementStatus> src) throws FHIRException { 148 if (src == null || src.isEmpty()) 149 return null; 150 org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.MedicationStatement.MedicationStatementStatus> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.MedicationStatement.MedicationStatementStatusEnumFactory()); 151 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 152 switch (src.getValue()) { 153 case ACTIVE: 154 tgt.setValue(org.hl7.fhir.dstu2.model.MedicationStatement.MedicationStatementStatus.ACTIVE); 155 break; 156 case COMPLETED: 157 tgt.setValue(org.hl7.fhir.dstu2.model.MedicationStatement.MedicationStatementStatus.COMPLETED); 158 break; 159 case ENTEREDINERROR: 160 tgt.setValue(org.hl7.fhir.dstu2.model.MedicationStatement.MedicationStatementStatus.ENTEREDINERROR); 161 break; 162 case INTENDED: 163 tgt.setValue(org.hl7.fhir.dstu2.model.MedicationStatement.MedicationStatementStatus.INTENDED); 164 break; 165 default: 166 tgt.setValue(org.hl7.fhir.dstu2.model.MedicationStatement.MedicationStatementStatus.NULL); 167 break; 168 } 169 return tgt; 170 } 171}