From 5769ba78d9a3bdf121e338343e5c202732d0634e Mon Sep 17 00:00:00 2001 From: Chris Hossenlopp Date: Thu, 31 Oct 2024 15:57:50 -0400 Subject: [PATCH] Added UNHIT results to the HTMLBuilder Tests --- test/unit/HTMLBuilder.test.ts | 47 +++++++++++++------ .../html/simpleCoverageAnnotation.html | 9 +++- .../html/simpleCoverageAnnotation2.html | 9 +++- ...html => simpleHighlightingAnnotation.html} | 8 ++++ 4 files changed, 56 insertions(+), 17 deletions(-) rename test/unit/fixtures/html/{simpleTrueAnnotation.html => simpleHighlightingAnnotation.html} (56%) diff --git a/test/unit/HTMLBuilder.test.ts b/test/unit/HTMLBuilder.test.ts index 1ae91982..8d98cfd1 100644 --- a/test/unit/HTMLBuilder.test.ts +++ b/test/unit/HTMLBuilder.test.ts @@ -20,11 +20,13 @@ import { getELMFixture, getHTMLFixture, getJSONFixture } from './helpers/testHel describe('HTMLBuilder', () => { let elm = {}; - let simpleExpression: ELMStatement | undefined; + let denominatorExpression: ELMStatement | undefined; + let numeratorExpression: ELMStatement | undefined; let statementResults: StatementResult[]; let trueClauseResults: ClauseResult[]; let falseClauseResults: ClauseResult[]; - const defineStatementLocalId = '119'; + const denominatorLocalId = '119'; + const numeratorLocalId = '135'; const trueStyleString = objToCSS(cqlLogicClauseTrueStyle); const falseStyleString = objToCSS(cqlLogicClauseFalseStyle); const coverageStyleString = objToCSS(cqlLogicClauseCoveredStyle); @@ -114,43 +116,51 @@ describe('HTMLBuilder', () => { beforeEach(() => { elm = getELMFixture('elm/CMS723v0.json'); - simpleExpression = elm.library.statements.def.find(d => d.localId === defineStatementLocalId); // Simple expression for Denominator + denominatorExpression = elm.library.statements.def.find(d => d.localId === denominatorLocalId); // Simple expression for Denominator + numeratorExpression = elm.library.statements.def.find(d => d.localId === numeratorLocalId); // Simple expression for Denominator // statementResults = [ { - statementName: simpleExpression?.name ?? '', + statementName: denominatorExpression?.name ?? '', libraryName: elm.library.identifier.id, final: FinalResult.TRUE, relevance: Relevance.TRUE, - localId: defineStatementLocalId + localId: denominatorLocalId + }, + { + statementName: numeratorExpression?.name ?? '', + libraryName: elm.library.identifier.id, + final: FinalResult.UNHIT, + relevance: Relevance.FALSE, + localId: numeratorLocalId } ]; trueClauseResults = [ { - statementName: simpleExpression?.name ?? '', + statementName: denominatorExpression?.name ?? '', libraryName: elm.library.identifier.id, - localId: defineStatementLocalId, + localId: denominatorLocalId, final: FinalResult.TRUE, raw: true }, { - statementName: simpleExpression?.name ?? '', + statementName: denominatorExpression?.name ?? '', libraryName: elm.library.identifier.id, localId: '118', final: FinalResult.TRUE, raw: [{ resourceType: 'foo' }] }, { - statementName: simpleExpression?.name ?? '', + statementName: denominatorExpression?.name ?? '', libraryName: elm.library.identifier.id, localId: '116', final: FinalResult.TRUE, raw: [{ resourceType: 'foo' }] }, { - statementName: simpleExpression?.name ?? '', + statementName: denominatorExpression?.name ?? '', libraryName: elm.library.identifier.id, localId: '115', final: FinalResult.TRUE, @@ -160,19 +170,19 @@ describe('HTMLBuilder', () => { falseClauseResults = [ { - statementName: simpleExpression?.name ?? '', + statementName: denominatorExpression?.name ?? '', libraryName: elm.library.identifier.id, - localId: defineStatementLocalId, + localId: denominatorLocalId, final: FinalResult.FALSE, raw: false }, { - statementName: simpleExpression?.name ?? '', + statementName: denominatorExpression?.name ?? '', libraryName: elm.library.identifier.id, localId: '117', final: FinalResult.FALSE, raw: [] - } + }, // specifically not including this result to make this clause have no coverage styling. // This simulates a clause that only exists in the annotation. // { @@ -182,12 +192,19 @@ describe('HTMLBuilder', () => { // final: FinalResult.FALSE, // raw: [] // } + { + statementName: numeratorExpression?.name ?? '', + libraryName: elm.library.identifier.id, + localId: numeratorLocalId, + final: FinalResult.UNHIT, + raw: false + } ]; }); test('simple HTML with generation with mix of false and true clauses', () => { // Ignore tabs and new lines - const expectedHTML = getHTMLFixture('simpleTrueAnnotation.html').replace(/\s/g, ''); + const expectedHTML = getHTMLFixture('simpleHighlightingAnnotation.html').replace(/\s/g, ''); const res = generateHTML( simpleMeasure, [elm], diff --git a/test/unit/fixtures/html/simpleCoverageAnnotation.html b/test/unit/fixtures/html/simpleCoverageAnnotation.html index 2aee805a..855ae6c1 100644 --- a/test/unit/fixtures/html/simpleCoverageAnnotation.html +++ b/test/unit/fixtures/html/simpleCoverageAnnotation.html @@ -1,5 +1,5 @@
-

test Clause Coverage: 80.0%

+

test Clause Coverage: 66.7%

test Clause Coverage: 80.0%
         
       
     
+
+    
+    define "Numerator": "Denominator" NonElectiveEncounter
+        with "Anticoagulant Therapy at Discharge" Anticoagulant
+            such that Anticoagulant.authorDatetime during NonElectiveEncounter.relevantPeriod
+    
diff --git a/test/unit/fixtures/html/simpleCoverageAnnotation2.html b/test/unit/fixtures/html/simpleCoverageAnnotation2.html index 92caa2fa..c76fb7bb 100644 --- a/test/unit/fixtures/html/simpleCoverageAnnotation2.html +++ b/test/unit/fixtures/html/simpleCoverageAnnotation2.html @@ -1,5 +1,5 @@
-

test2 Clause Coverage: 80.0%

+

test2 Clause Coverage: 66.7%

test2 Clause Coverage: 80.0%
         
       
     
+
+    
+    define "Numerator": "Denominator" NonElectiveEncounter
+        with "Anticoagulant Therapy at Discharge" Anticoagulant
+            such that Anticoagulant.authorDatetime during NonElectiveEncounter.relevantPeriod
+    
diff --git a/test/unit/fixtures/html/simpleTrueAnnotation.html b/test/unit/fixtures/html/simpleHighlightingAnnotation.html similarity index 56% rename from test/unit/fixtures/html/simpleTrueAnnotation.html rename to test/unit/fixtures/html/simpleHighlightingAnnotation.html index dc60f846..034e8806 100644 --- a/test/unit/fixtures/html/simpleTrueAnnotation.html +++ b/test/unit/fixtures/html/simpleHighlightingAnnotation.html @@ -26,4 +26,12 @@

Population Group: test

+ +
+  
+  define "Numerator": "Denominator" NonElectiveEncounter
+      with "Anticoagulant Therapy at Discharge" Anticoagulant
+          such that Anticoagulant.authorDatetime during NonElectiveEncounter.relevantPeriod
+