diff --git a/src/main/resources/hl7/resource/Encounter.yml b/src/main/resources/hl7/resource/Encounter.yml index 27c02db4..3281896c 100644 --- a/src/main/resources/hl7/resource/Encounter.yml +++ b/src/main/resources/hl7/resource/Encounter.yml @@ -108,14 +108,28 @@ subject: valueOf: datatype/Reference expressionType: resource specs: $Patient +diagnosis: + expressionType: nested + evaluateLater: true + generateList: true + specs: DG1 + expressionsMap: + condition: + valueOf: datatype/Reference + expressionType: resource + specs: $Condition + -# Uncomment until we figure out to reference condition from encounter -# diagnosis.condition is required -# -# diagnosis: -# valueOf: datatype/Diagnosis -# generateList: true -# expressionType: resource -# specs: DG1 -# vars: -# Condition: $Condition \ No newline at end of file + use: + valueOf: datatype/CodeableConcept + expressionType: resource + specs: DG1.6 + vars: + coding: DIAGNOSIS_USE, DG1.6 + + rank: + type: STRING + valueOf: DG1.15 + expressionType: HL7Spec + + diff --git a/src/test/java/io/github/linuxforhealth/hl7/segments/HL7ConditionFHIRConversionTest.java b/src/test/java/io/github/linuxforhealth/hl7/segments/HL7ConditionFHIRConversionTest.java index 8fa7877b..03baa54d 100644 --- a/src/test/java/io/github/linuxforhealth/hl7/segments/HL7ConditionFHIRConversionTest.java +++ b/src/test/java/io/github/linuxforhealth/hl7/segments/HL7ConditionFHIRConversionTest.java @@ -120,36 +120,32 @@ public void validateDiagnosis(String msh) { .map(BundleEntryComponent::getResource).collect(Collectors.toList()); assertThat(encounterResource).hasSize(1); - // --- COMMENTED OUT THE REST UNTIL WE CAN REFERENCE CONDITION FROM ENCOUNTER --- - - // // Get the encounter resource - // Base encounter = encounterResource.get(0); - - // // Verify asserter reference to Practitioner exists - // assertThat(ResourceUtils.getValueAsString(encounter, - // "reasonReference").substring(0, 11)).isEqualTo("Condition/"); - - // // Verify encounter diagnosis use is set correctly - // Base diagnosis = ResourceUtils.getValue(encounter, "diagnosis"); - // Base use = ResourceUtils.getValue(diagnosis, "use"); - // assertThat(ResourceUtils.getValueAsString(use, "text")).isEqualTo("A"); - // Base diagCoding = ResourceUtils.getValue(use, "coding"); - // assertThat(ResourceUtils.getValueAsString(diagCoding, "system")) - // .isEqualTo("UriType[http://terminology.hl7.org/CodeSystem/diagnosis-role]"); - // assertThat(ResourceUtils.getValueAsString(diagCoding, - // "code")).isEqualTo("AD"); - // assertThat(ResourceUtils.getValueAsString(diagCoding, - // "display")).isEqualTo("Admission diagnosis"); - - // // Verify encounter diagnosis rank is set correctly. - // assertThat(ResourceUtils.getValueAsString(diagnosis, - // "rank")).isEqualTo("PositiveIntType[1]"); - - // // Diagnosis requires a reference to condition. - // assertThat(ResourceUtils.getValueAsString(diagnosis, - // "condition").substring(0, 11)).isEqualTo("Condition/"); - - // -------------------------------------------------------------------------------- + // Get the encounter resource + Base encounter = encounterResource.get(0); + + // Verify reasonReference to condition exists + Base reasonReference = ResourceUtils.getValue(encounter, "reasonReference"); + assertThat(ResourceUtils.getValueAsString(reasonReference,"reference").substring(0, 10)).isEqualTo("Condition/"); + + // Verify encounter diagnosis use is set correctly + Base diagnosis = ResourceUtils.getValue(encounter, "diagnosis"); + Base use = ResourceUtils.getValue(diagnosis, "use"); + assertThat(ResourceUtils.getValueAsString(use, "text")).isEqualTo("A"); + Base diagCoding = ResourceUtils.getValue(use, "coding"); + assertThat(ResourceUtils.getValueAsString(diagCoding, "system")) + .isEqualTo("UriType[http://terminology.hl7.org/CodeSystem/diagnosis-role]"); + assertThat(ResourceUtils.getValueAsString(diagCoding, + "code")).isEqualTo("AD"); + assertThat(ResourceUtils.getValueAsString(diagCoding, + "display")).isEqualTo("Admission diagnosis"); + + // Verify encounter diagnosis rank is set correctly. + assertThat(ResourceUtils.getValueAsString(diagnosis, + "rank")).isEqualTo("PositiveIntType[1]"); + + // Diagnosis requires a reference to condition. + Base conditionRef = ResourceUtils.getValue(encounter, "reasonReference"); + assertThat(ResourceUtils.getValueAsString(conditionRef,"reference").substring(0, 10)).isEqualTo("Condition/"); // --- PRACTIONER TESTS --- @@ -260,9 +256,6 @@ public void validateEncounterMultipleDiagnoses() { assertThat(condCoding.getDisplay()).isEqualTo("Tachycardia, unspecified"); assertThat(condCoding.hasVersion()).isFalse(); - // TODO: Each condition should have condition.reasonReference and condition.diagnosis values (use and rank) - // including a reference to the condition. We can not add these now because of a defect that will be addressed soon (see internal bug 665) - } // --------------------- PROBLEM UNIT TESTS (PRB) ---------------------