Skip to content

Commit bfd5574

Browse files
committed
Fixed requirements to handle missing columns
1 parent 7537986 commit bfd5574

1 file changed

Lines changed: 50 additions & 13 deletions

File tree

content/assets/js/requirements-table.js

Lines changed: 50 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,39 @@ $(function () {
33
const $table = $("table.fhir-conformance-list");
44

55
/* Exclude header row (0) and filter row (1) */
6+
const $header = $table.find("tr").first();
67
const $rows = $table.find("tr").slice(2);
78

9+
const colId = 0;
10+
const colExpect = 1;
11+
const colCond = 2;
12+
var colActor = -1;
13+
var colCat = -1;
14+
var colRule = -1;
15+
16+
var i = 0;
17+
var hasIds = false;
18+
$headerCells = $header.children("th,td");
19+
$headerCells.each(function () {
20+
if ($(this).attr("id") === "fcl-actor" || $(this).text() == "Actor(s)") {
21+
colActor = i;
22+
hasIds = true;
23+
} else if ($(this).attr("id") === "fcl-cat" || $(this).text() == "Category(ies)") {
24+
colCat = i;
25+
hasIds = true;
26+
} else if ($(this).attr("id") === "fcl-rule" || $(this).text() == "Rule") {
27+
colRule = i;
28+
hasIds = true;
29+
}
30+
i++;
31+
});
32+
33+
if (!hasIds) {
34+
colActor = 3;
35+
colCat = 4;
36+
colRule = 5;
37+
}
38+
839
function normalize(text) {
940
return text.replace(/\s+/g, " ").trim();
1041
}
@@ -14,6 +45,8 @@ $(function () {
1445
const idFilter = normalize($("input[name='filterid']").val() || "").toLowerCase();
1546
const ruleFilter = normalize($("input[name='filterrule']").val() || "").toLowerCase();
1647

48+
49+
1750
/* Selected expectations (exact tokens) */
1851
const expectations = $("input[name^='expect']:checked")
1952
.map(function () {
@@ -41,32 +74,34 @@ $(function () {
4174

4275
const $cells = $(this).children("th,td");
4376

44-
const idText = $cells.eq(0).text().toLowerCase();
45-
const ruleText = $cells.eq(5).text().toLowerCase();
46-
const condText = $cells.eq(2).text();
77+
const idText = $cells.eq(colId).text().toLowerCase();
78+
const condText = $cells.eq(colCond).text();
79+
const ruleText = $cells.eq(colRule).text().toLowerCase();
4780

4881
const hasConditionalX = /\bX\b/.test(condText);
4982

5083
/* Extract expectation tokens (split on <br/>) */
51-
const rowExpectations = $cells.eq(1)
84+
const rowExpectations = $cells.eq(colExpect)
5285
.html()
5386
.split(/<br\s*\/?>/i)
5487
.map(e => normalize($("<div>").html(e).text()))
5588
.filter(Boolean);
5689

5790
/* Extract actors (exact anchor match) */
58-
const rowActors = $cells.eq(3).find("a")
91+
const rowActors = $cells.eq(colActor).find("a")
5992
.map(function () {
6093
return $(this).text().trim();
6194
})
6295
.get();
6396

6497
/* Extract categories (exact tokens) */
65-
const rowCategories = $cells.eq(4)
66-
.text()
67-
.split(/\s*[\r\n]+\s*/)
68-
.map(c => c.trim())
69-
.filter(Boolean);
98+
if (colCat != -1) {
99+
const rowCategories = $cells.eq(colCat)
100+
.text()
101+
.split(/\s*[\r\n]+\s*/)
102+
.map(c => c.trim())
103+
.filter(Boolean);
104+
}
70105

71106
let visible = true;
72107

@@ -96,9 +131,11 @@ $(function () {
96131
}
97132

98133
/* Category filter */
99-
if (categories.length &&
100-
!categories.some(c => rowCategories.includes(c))) {
101-
visible = false;
134+
if (colCat != -1) {
135+
if (categories.length &&
136+
!categories.some(c => rowCategories.includes(c))) {
137+
visible = false;
138+
}
102139
}
103140

104141
/* Rule filter */

0 commit comments

Comments
 (0)