Skip to content

Commit

Permalink
Merge pull request #211 from LinuxForHealth/Encounter-diagnosis
Browse files Browse the repository at this point in the history
Encounter diagnosis
  • Loading branch information
pbhallam authored Sep 9, 2021
2 parents f773d97 + d279c61 commit ff6f4c8
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 43 deletions.
34 changes: 24 additions & 10 deletions src/main/resources/hl7/resource/Encounter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
use:
valueOf: datatype/CodeableConcept
expressionType: resource
specs: DG1.6
vars:
coding: DIAGNOSIS_USE, DG1.6

rank:
type: STRING
valueOf: DG1.15
expressionType: HL7Spec


Original file line number Diff line number Diff line change
Expand Up @@ -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 ---

Expand Down Expand Up @@ -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) ---------------------
Expand Down

0 comments on commit ff6f4c8

Please sign in to comment.