Skip to content

Commit

Permalink
Added UNHIT results to the HTMLBuilder Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hossenlopp committed Oct 31, 2024
1 parent cf8fbda commit 5769ba7
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 17 deletions.
47 changes: 32 additions & 15 deletions test/unit/HTMLBuilder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ import { getELMFixture, getHTMLFixture, getJSONFixture } from './helpers/testHel

describe('HTMLBuilder', () => {
let elm = <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);
Expand Down Expand Up @@ -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,
Expand All @@ -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.
// {
Expand All @@ -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],
Expand Down
9 changes: 8 additions & 1 deletion test/unit/fixtures/html/simpleCoverageAnnotation.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div>
<h2>test Clause Coverage: 80.0%</h2>
<h2>test Clause Coverage: 66.7%</h2>
<pre
style="tab-size: 2"
data-library-name="AnticoagulationTherapyforAtrialFibrillationFlutter"
Expand All @@ -26,4 +26,11 @@ <h2>test Clause Coverage: 80.0%</h2>
</span>
</code>
</pre>
<pre style="tab-size: 2"
data-library-name="AnticoagulationTherapyforAtrialFibrillationFlutter" data-statement-name="Numerator">
<code>
<span data-ref-id="135" style="background-color:white;color:black"><span>define &quot;Numerator&quot;: </span><span data-ref-id="134" style=""><span><span data-ref-id="125" style=""><span data-ref-id="124" style=""><span><span>&quot;Denominator&quot;</span></span></span><span> NonElectiveEncounter</span></span></span><span>
</span><span data-ref-id="133" style=""><span>with </span><span data-ref-id="127" style=""><span data-ref-id="126" style=""><span><span>&quot;Anticoagulant Therapy at Discharge&quot;</span></span></span><span> Anticoagulant</span></span><span>
such that </span><span data-ref-id="132" style=""><span data-ref-id="129" style=""><span data-ref-id="128" style=""><span>Anticoagulant</span></span><span>.</span><span data-ref-id="129" style=""><span>authorDatetime</span></span></span><span> during </span><span data-ref-id="131" style=""><span data-ref-id="130" style=""><span>NonElectiveEncounter</span></span><span>.</span><span data-ref-id="131" style=""><span>relevantPeriod</span></span></span></span></span></span></span></code>
</pre>
</div>
9 changes: 8 additions & 1 deletion test/unit/fixtures/html/simpleCoverageAnnotation2.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div>
<h2>test2 Clause Coverage: 80.0%</h2>
<h2>test2 Clause Coverage: 66.7%</h2>
<pre
style="tab-size: 2"
data-library-name="AnticoagulationTherapyforAtrialFibrillationFlutter"
Expand All @@ -26,4 +26,11 @@ <h2>test2 Clause Coverage: 80.0%</h2>
</span>
</code>
</pre>
<pre style="tab-size: 2"
data-library-name="AnticoagulationTherapyforAtrialFibrillationFlutter" data-statement-name="Numerator">
<code>
<span data-ref-id="135" style="background-color:white;color:black"><span>define &quot;Numerator&quot;: </span><span data-ref-id="134" style=""><span><span data-ref-id="125" style=""><span data-ref-id="124" style=""><span><span>&quot;Denominator&quot;</span></span></span><span> NonElectiveEncounter</span></span></span><span>
</span><span data-ref-id="133" style=""><span>with </span><span data-ref-id="127" style=""><span data-ref-id="126" style=""><span><span>&quot;Anticoagulant Therapy at Discharge&quot;</span></span></span><span> Anticoagulant</span></span><span>
such that </span><span data-ref-id="132" style=""><span data-ref-id="129" style=""><span data-ref-id="128" style=""><span>Anticoagulant</span></span><span>.</span><span data-ref-id="129" style=""><span>authorDatetime</span></span></span><span> during </span><span data-ref-id="131" style=""><span data-ref-id="130" style=""><span>NonElectiveEncounter</span></span><span>.</span><span data-ref-id="131" style=""><span>relevantPeriod</span></span></span></span></span></span></span></code>
</pre>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,12 @@ <h2>Population Group: test</h2>
</span>
</code>
</pre>

<pre style="tab-size: 2; line-height: 1.51em"
data-library-name="AnticoagulationTherapyforAtrialFibrillationFlutter" data-statement-name="Numerator">
<code>
<span data-ref-id="135" style=""><span>define &quot;Numerator&quot;: </span><span data-ref-id="134" style=""><span><span data-ref-id="125" style=""><span data-ref-id="124" style=""><span><span>&quot;Denominator&quot;</span></span></span><span> NonElectiveEncounter</span></span></span><span>
</span><span data-ref-id="133" style=""><span>with </span><span data-ref-id="127" style=""><span data-ref-id="126" style=""><span><span>&quot;Anticoagulant Therapy at Discharge&quot;</span></span></span><span> Anticoagulant</span></span><span>
such that </span><span data-ref-id="132" style=""><span data-ref-id="129" style=""><span data-ref-id="128" style=""><span>Anticoagulant</span></span><span>.</span><span data-ref-id="129" style=""><span>authorDatetime</span></span></span><span> during </span><span data-ref-id="131" style=""><span data-ref-id="130" style=""><span>NonElectiveEncounter</span></span><span>.</span><span data-ref-id="131" style=""><span>relevantPeriod</span></span></span></span></span></span></span></code>
</pre>
</div>

0 comments on commit 5769ba7

Please sign in to comment.