Skip to content

Commit 7e892da

Browse files
Merge pull request #1264 from HL7/Branch_RequirementsGenerationFixes2
Updated rendering of conformance statement table
2 parents 20ba2d2 + 3a595f5 commit 7e892da

2 files changed

Lines changed: 30 additions & 11 deletions

File tree

org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/publisher/ConformanceClause.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ else if (categories.contains(category))
126126
}
127127
}
128128
}
129+
handler.processConditional(conditional);
129130
}
130131

131132
private void fixRefs(XhtmlNode node, String fileName) {

org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/publisher/ConformanceStatementHandler.java

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ private HomeInfo(LoadedFile source, XhtmlNode node) {
7474
private HTMLInspector inspector;
7575
private Map<String, ActorDefinition> usedActors = new HashMap<>();
7676
private Map<String, Coding> usedCategories = new HashMap<>();
77+
private boolean hasConditionalTrue = false;
78+
private boolean hasConditionalFalse = false;
7779
private List<String> foundExpectations = new ArrayList<>();
7880
private String termShallNot;
7981
private String termShall;
@@ -416,6 +418,9 @@ private void renderConformanceHome(String lang) throws IOException {
416418
HomeInfo info = confHomes.get(lang);
417419
XhtmlNode confHome = info.node;
418420
if (confHome != null) {
421+
if (!confHome.hasClass("grid")) {
422+
confHome.clss("grid");
423+
}
419424
XhtmlNode thead = confHome.addTag("thead");
420425
XhtmlNode tbody = confHome.addTag("tbody");
421426
XhtmlNode header = thead.tr().style("background-color: WhiteSmoke;");
@@ -424,11 +429,13 @@ private void renderConformanceHome(String lang) throws IOException {
424429

425430
header.th().style("text-align: center;").tx(rc.formatPhrase(RenderingContext.CSTABLE_HEAD_ID));
426431
header.th().style("text-align: center;").tx(rc.formatPhrase(RenderingContext.CSTABLE_HEAD_EXPECT));
427-
header.th().style("text-align: center;").tx(rc.formatPhrase(RenderingContext.CSTABLE_HEAD_COND));
432+
if (hasConditionalTrue && hasConditionalFalse) {
433+
header.th().style("text-align: center;").tx(rc.formatPhrase(RenderingContext.CSTABLE_HEAD_COND));
434+
}
428435
if (!usedActors.isEmpty())
429-
header.th().style("text-align: center;").tx(rc.formatPhrase(RenderingContext.CSTABLE_HEAD_ACTOR));
436+
header.th().style("text-align: center;").tx(rc.formatPhrasePlural(usedActors.size(), RenderingContext.CSTABLE_HEAD_ACTOR, ""));
430437
if (!usedCategories.isEmpty())
431-
header.th().style("text-align: center;").tx(rc.formatPhrase(RenderingContext.CSTABLE_HEAD_CAT));
438+
header.th().style("text-align: center;").tx(rc.formatPhrasePlural(usedCategories.size(), RenderingContext.CSTABLE_HEAD_CAT, ""));
432439
header.th().style("text-align: center;").tx(rc.formatPhrase(RenderingContext.CSTABLE_HEAD_RULE));
433440

434441
XhtmlNode filters = thead.tr().style("background-color: WhiteSmoke;");
@@ -441,13 +448,15 @@ private void renderConformanceHome(String lang) throws IOException {
441448
expectFilter.br();
442449
expectFilter.input("expect" + count++, "checkbox", null, 0).nbsp().tx(translateExpectationEnglish(expect));
443450
}
444-
XhtmlNode conditionFilter = filters.td();
445-
conditionFilter.attribute("title", rc.formatPhrase(RenderingContext.CSTABLE_TITLE_COND));
446-
conditionFilter.input("conditionFilter", "radio", null, 0).attribute("id", "conditionYes").attribute("value", "true").nbsp().tx(rc.formatPhrase(RenderingContext.CSTABLE_COND_YES));
447-
conditionFilter.br();
448-
conditionFilter.input("conditionFilter", "radio", null, 0).attribute("id", "conditionNo").attribute("value", "false").nbsp().tx(rc.formatPhrase(RenderingContext.CSTABLE_COND_NO));
449-
conditionFilter.br();
450-
conditionFilter.input("conditionFilter", "radio", null, 0).nbsp().attribute("id", "conditionAny").attribute("value", "").attribute("checked", "true").tx(rc.formatPhrase(RenderingContext.CSTABLE_COND_ANY));
451+
if (hasConditionalTrue && hasConditionalFalse) {
452+
XhtmlNode conditionFilter = filters.td();
453+
conditionFilter.attribute("title", rc.formatPhrase(RenderingContext.CSTABLE_TITLE_COND));
454+
conditionFilter.input("conditionFilter", "radio", null, 0).attribute("id", "conditionYes").attribute("value", "true").nbsp().tx(rc.formatPhrase(RenderingContext.CSTABLE_COND_YES));
455+
conditionFilter.br();
456+
conditionFilter.input("conditionFilter", "radio", null, 0).attribute("id", "conditionNo").attribute("value", "false").nbsp().tx(rc.formatPhrase(RenderingContext.CSTABLE_COND_NO));
457+
conditionFilter.br();
458+
conditionFilter.input("conditionFilter", "radio", null, 0).nbsp().attribute("id", "conditionAny").attribute("value", "").attribute("checked", "true").tx(rc.formatPhrase(RenderingContext.CSTABLE_COND_ANY));
459+
}
451460
if (!usedActors.isEmpty()) {
452461
XhtmlNode actorFilter = filters.td();
453462
actorFilter.attribute("title", rc.formatPhrase(RenderingContext.CSTABLE_TITLE_ACTOR));
@@ -517,7 +526,9 @@ private void renderConformanceHome(String lang) throws IOException {
517526
expectNode.br();
518527
expectNode.tx(translateExpectationEnglish(expectation));
519528
}
520-
tr.td().style("text-align: center;").tx(clause.isConditional() ? "X" : " ");
529+
if (hasConditionalTrue && hasConditionalFalse) {
530+
tr.td().style("text-align: center;").tx(clause.isConditional() ? "X" : " ");
531+
}
521532
if (!usedActors.isEmpty()) {
522533
XhtmlNode actors = tr.td();
523534
boolean firstActor = true;
@@ -959,6 +970,13 @@ public void categoryUsed(Coding category) {
959970
if (!usedCategories.containsKey(category.getCode()))
960971
usedCategories.put(category.getCode(), category);
961972
}
973+
974+
public void processConditional(boolean conditional) {
975+
if (conditional)
976+
hasConditionalTrue = true;
977+
else
978+
hasConditionalFalse = true;
979+
}
962980

963981
public void extractExpectations(List<String> expectations, String text) {
964982
if (text.contains(termShallNot) || text.contains(termShallNotPlural)) {

0 commit comments

Comments
 (0)