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.DateTime30_50; 009import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.String30_50; 010import org.hl7.fhir.exceptions.FHIRException; 011 012public class ClinicalImpression30_50 { 013 014 public static org.hl7.fhir.dstu3.model.ClinicalImpression convertClinicalImpression(org.hl7.fhir.r5.model.ClinicalImpression src) throws FHIRException { 015 if (src == null) 016 return null; 017 org.hl7.fhir.dstu3.model.ClinicalImpression tgt = new org.hl7.fhir.dstu3.model.ClinicalImpression(); 018 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt); 019 for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) 020 tgt.addIdentifier(Identifier30_50.convertIdentifier(t)); 021 if (src.hasStatus()) 022 tgt.setStatusElement(convertClinicalImpressionStatus(src.getStatusElement())); 023 if (src.hasDescription()) 024 tgt.setDescriptionElement(String30_50.convertString(src.getDescriptionElement())); 025 if (src.hasSubject()) 026 tgt.setSubject(Reference30_50.convertReference(src.getSubject())); 027 if (src.hasEncounter()) 028 tgt.setContext(Reference30_50.convertReference(src.getEncounter())); 029 if (src.hasEffective()) 030 tgt.setEffective(ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getEffective())); 031 if (src.hasDate()) 032 tgt.setDateElement(DateTime30_50.convertDateTime(src.getDateElement())); 033 if (src.hasPerformer()) 034 tgt.setAssessor(Reference30_50.convertReference(src.getPerformer())); 035 if (src.hasPrevious()) 036 tgt.setPrevious(Reference30_50.convertReference(src.getPrevious())); 037 for (org.hl7.fhir.r5.model.Reference t : src.getProblem()) tgt.addProblem(Reference30_50.convertReference(t)); 038 for (org.hl7.fhir.r5.model.UriType t : src.getProtocol()) tgt.addProtocol(t.getValue()); 039 if (src.hasSummary()) 040 tgt.setSummaryElement(String30_50.convertString(src.getSummaryElement())); 041 for (org.hl7.fhir.r5.model.ClinicalImpression.ClinicalImpressionFindingComponent t : src.getFinding()) 042 tgt.addFinding(convertClinicalImpressionFindingComponent(t)); 043 for (org.hl7.fhir.r5.model.CodeableConcept t : src.getPrognosisCodeableConcept()) 044 tgt.addPrognosisCodeableConcept(CodeableConcept30_50.convertCodeableConcept(t)); 045 for (org.hl7.fhir.r5.model.Reference t : src.getPrognosisReference()) 046 tgt.addPrognosisReference(Reference30_50.convertReference(t)); 047 for (org.hl7.fhir.r5.model.Annotation t : src.getNote()) tgt.addNote(Annotation30_50.convertAnnotation(t)); 048 return tgt; 049 } 050 051 public static org.hl7.fhir.r5.model.ClinicalImpression convertClinicalImpression(org.hl7.fhir.dstu3.model.ClinicalImpression src) throws FHIRException { 052 if (src == null) 053 return null; 054 org.hl7.fhir.r5.model.ClinicalImpression tgt = new org.hl7.fhir.r5.model.ClinicalImpression(); 055 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt); 056 for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier()) 057 tgt.addIdentifier(Identifier30_50.convertIdentifier(t)); 058 if (src.hasStatus()) 059 tgt.setStatusElement(convertClinicalImpressionStatus(src.getStatusElement())); 060 if (src.hasDescription()) 061 tgt.setDescriptionElement(String30_50.convertString(src.getDescriptionElement())); 062 if (src.hasSubject()) 063 tgt.setSubject(Reference30_50.convertReference(src.getSubject())); 064 if (src.hasContext()) 065 tgt.setEncounter(Reference30_50.convertReference(src.getContext())); 066 if (src.hasEffective()) 067 tgt.setEffective(ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getEffective())); 068 if (src.hasDate()) 069 tgt.setDateElement(DateTime30_50.convertDateTime(src.getDateElement())); 070 if (src.hasAssessor()) 071 tgt.setPerformer(Reference30_50.convertReference(src.getAssessor())); 072 if (src.hasPrevious()) 073 tgt.setPrevious(Reference30_50.convertReference(src.getPrevious())); 074 for (org.hl7.fhir.dstu3.model.Reference t : src.getProblem()) tgt.addProblem(Reference30_50.convertReference(t)); 075 for (org.hl7.fhir.dstu3.model.UriType t : src.getProtocol()) tgt.addProtocol(t.getValue()); 076 if (src.hasSummary()) 077 tgt.setSummaryElement(String30_50.convertString(src.getSummaryElement())); 078 for (org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionFindingComponent t : src.getFinding()) 079 tgt.addFinding(convertClinicalImpressionFindingComponent(t)); 080 for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getPrognosisCodeableConcept()) 081 tgt.addPrognosisCodeableConcept(CodeableConcept30_50.convertCodeableConcept(t)); 082 for (org.hl7.fhir.dstu3.model.Reference t : src.getPrognosisReference()) 083 tgt.addPrognosisReference(Reference30_50.convertReference(t)); 084 for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote()) tgt.addNote(Annotation30_50.convertAnnotation(t)); 085 return tgt; 086 } 087 088 public static org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionFindingComponent convertClinicalImpressionFindingComponent(org.hl7.fhir.r5.model.ClinicalImpression.ClinicalImpressionFindingComponent src) throws FHIRException { 089 if (src == null) 090 return null; 091 org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionFindingComponent tgt = new org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionFindingComponent(); 092 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyBackboneElement(src,tgt); 093 if (src.hasItem() && src.getItem().hasConcept()) 094 tgt.setItem(ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getItem().getConcept())); 095 else if (src.hasItem() && src.getItem().hasReference()) 096 tgt.setItem(ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getItem().getReference())); 097 if (src.hasBasis()) 098 tgt.setBasisElement(String30_50.convertString(src.getBasisElement())); 099 return tgt; 100 } 101 102 public static org.hl7.fhir.r5.model.ClinicalImpression.ClinicalImpressionFindingComponent convertClinicalImpressionFindingComponent(org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionFindingComponent src) throws FHIRException { 103 if (src == null) 104 return null; 105 org.hl7.fhir.r5.model.ClinicalImpression.ClinicalImpressionFindingComponent tgt = new org.hl7.fhir.r5.model.ClinicalImpression.ClinicalImpressionFindingComponent(); 106 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyBackboneElement(src,tgt); 107 if (src.hasItemCodeableConcept()) 108 tgt.setItem(Reference30_50.convertCodeableConceptToCodableReference(src.getItemCodeableConcept())); 109 if (src.hasItemReference()) 110 tgt.setItem(Reference30_50.convertReferenceToCodableReference(src.getItemReference())); 111 if (src.hasBasis()) 112 tgt.setBasisElement(String30_50.convertString(src.getBasisElement())); 113 return tgt; 114 } 115 116 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionStatus> convertClinicalImpressionStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.EventStatus> src) throws FHIRException { 117 if (src == null || src.isEmpty()) 118 return null; 119 org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionStatus> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionStatusEnumFactory()); 120 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 121 switch (src.getValue()) { 122 case INPROGRESS: 123 tgt.setValue(org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionStatus.DRAFT); 124 break; 125 case COMPLETED: 126 tgt.setValue(org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionStatus.COMPLETED); 127 break; 128 case ENTEREDINERROR: 129 tgt.setValue(org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionStatus.ENTEREDINERROR); 130 break; 131 default: 132 tgt.setValue(org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionStatus.NULL); 133 break; 134 } 135 return tgt; 136 } 137 138 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.EventStatus> convertClinicalImpressionStatus(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionStatus> src) throws FHIRException { 139 if (src == null || src.isEmpty()) 140 return null; 141 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.EventStatus> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.EventStatusEnumFactory()); 142 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 143 switch (src.getValue()) { 144 case DRAFT: 145 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.EventStatus.INPROGRESS); 146 break; 147 case COMPLETED: 148 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.EventStatus.COMPLETED); 149 break; 150 case ENTEREDINERROR: 151 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.EventStatus.ENTEREDINERROR); 152 break; 153 default: 154 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.EventStatus.NULL); 155 break; 156 } 157 return tgt; 158 } 159}