CapabilityStatement Message and Document rendering

This commit is contained in:
caspears 2024-08-01 23:05:49 -07:00
parent 4281b0fa48
commit 2d5049c938
3 changed files with 136 additions and 0 deletions

View File

@ -18,6 +18,10 @@ import org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestComponen
import org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestResourceComponent; import org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestResourceComponent;
import org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestResourceOperationComponent; import org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestResourceOperationComponent;
import org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent; import org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent;
import org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementDocumentComponent;
import org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementMessagingComponent;
import org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementMessagingSupportedMessageComponent;
import org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementMessagingEndpointComponent;
import org.hl7.fhir.r5.model.CapabilityStatement.ReferenceHandlingPolicy; import org.hl7.fhir.r5.model.CapabilityStatement.ReferenceHandlingPolicy;
import org.hl7.fhir.r5.model.CapabilityStatement.ResourceInteractionComponent; import org.hl7.fhir.r5.model.CapabilityStatement.ResourceInteractionComponent;
import org.hl7.fhir.r5.model.CapabilityStatement.SystemInteractionComponent; import org.hl7.fhir.r5.model.CapabilityStatement.SystemInteractionComponent;
@ -382,6 +386,25 @@ public class CapabilityStatementRenderer extends ResourceRenderer {
} }
} }
int messagingNum = conf.getMessaging().size();
nextLevel = 3;
if (messagingNum > 0) {
x.h(2,"messaging").addText((context.formatPhrase(RenderingContext.CAPABILITY_MESSAGING_CAPS)));
int count=1;
for (CapabilityStatementMessagingComponent msg : conf.getMessaging())
{
addMessagingPanel(status, res, x, msg, nextLevel, count, messagingNum);
count++;
}
}
int documentNum = conf.getDocument().size();
nextLevel = 3;
if (documentNum > 0) {
x.h(2,"document").addText((context.formatPhrase(RenderingContext.CAPABILITY_DOCUMENT_CAPS)));
addDocumentTable(status, res, x, conf, nextLevel);
}
if (multExpectationsPresent) { if (multExpectationsPresent) {
addWarningPanel(x,"⹋⹋ - " + context.formatPhrase(RenderingContext.CAPABILITY_MULT_EXT)); addWarningPanel(x,"⹋⹋ - " + context.formatPhrase(RenderingContext.CAPABILITY_MULT_EXT));
} }
@ -592,6 +615,107 @@ public class CapabilityStatementRenderer extends ResourceRenderer {
} }
private void addMessagingPanel(RenderingStatus status, ResourceWrapper res, XhtmlNode x, CapabilityStatementMessagingComponent msg, int nextLevel, int index, int total) throws FHIRFormatError, DefinitionException, IOException {
XhtmlNode panel= null;
XhtmlNode body = null;
XhtmlNode row = null;
XhtmlNode heading = null;
XhtmlNode table;
XhtmlNode tbody;
XhtmlNode tr;
panel = x.div().attribute("class", "panel panel-default");
heading = panel.div().attribute("class", "panel-heading").h(nextLevel,"messaging_" + Integer.toString(index)).attribute("class", "panel-title");
if(total == 1)
{
heading.addText(context.formatPhrase(RenderingContext.CAPABILITY_MESSAGING_CAP));
}
else
{
heading.addText(context.formatPhrase(RenderingContext.CAPABILITY_MESSAGING_CAP) + " " + String.valueOf(index));
}
body = panel.div().attribute("class", "panel-body");
if(msg.hasReliableCache())
{
addLead(body, "Reliable Cache Length");
body.br();
body.addText(String.valueOf(msg.getReliableCache()) + " Minute(s)");
body.br();
}
if(msg.hasEndpoint())
{
body.h(nextLevel+1,"msg_end_"+Integer.toString(index)).addText(context.formatPhrase(RenderingContext.CAPABILITY_ENDPOINTS));
table = body.table("table table-condensed table-hover");
tr = table.addTag("thead").tr();
tr.th().addText("Protocol");
tr.th().addText("Address");
tbody = table.addTag("tbody");
for (CapabilityStatementMessagingEndpointComponent end : msg.getEndpoint())
{
tr = tbody.tr();
renderDataType(status, tr.td(), wrapNC(end.getProtocol()));
renderUri(status, tr.td(), wrapNC(end.getAddressElement()));
}
body.br();
}
if(msg.hasSupportedMessage())
{
body.h(nextLevel+1,"msg_end_"+Integer.toString(index)).addText(context.formatPhrase(RenderingContext.CAPABILITY_SUPP_MSGS));
table = body.table("table table-condensed table-hover");
tr = table.addTag("thead").tr();
tr.th().addText("Mode");
tr.th().addText(context.formatPhrase(RenderingContext.GENERAL_DEFINITION));
tbody = table.addTag("tbody");
for (CapabilityStatementMessagingSupportedMessageComponent sup : msg.getSupportedMessage())
{
tr = tbody.tr();
tr.td().addText(sup.getMode().toCode());
renderCanonical(status, res, tr.td(), StructureDefinition.class, sup.getDefinitionElement());
}
if(msg.hasDocumentation())
{
addLead(body, context.formatPhrase(RenderingContext.GENERAL_DOCUMENTATION));
addMarkdown(body.blockquote(), msg.getDocumentation());
}
body.br();
}
}
private void addDocumentTable(RenderingStatus status, ResourceWrapper res, XhtmlNode x, CapabilityStatement conf, int nextLevel) throws FHIRFormatError, DefinitionException, IOException {
XhtmlNode table;
XhtmlNode tbody;
XhtmlNode tr;
table = x.table("table table-condensed table-hover");
tr = table.addTag("thead").tr();
tr.th().addText("Mode");
tr.th().addText(context.formatPhrase(RenderingContext.CAPABILITY_PROF_RES_DOC));
tr.th().addText(context.formatPhrase(RenderingContext.GENERAL_DOCUMENTATION));
tbody = table.addTag("tbody");
for (CapabilityStatementDocumentComponent document : conf.getDocument()) {
tr = tbody.tr();
tr.td().addText(document.getMode().toCode());
renderCanonical(status, res, tr.td(), StructureDefinition.class, document.getProfileElement());
if(document.hasDocumentation())
{
addMarkdown(tr.td(), document.getDocumentation());
}
else
{
tr.td().nbsp();
}
}
}
private String getCorsText(boolean on) { private String getCorsText(boolean on) {
if (on) { if (on) {
return context.formatPhrase(RenderingContext.CAPABILITY_CORS_YES); return context.formatPhrase(RenderingContext.CAPABILITY_CORS_YES);

View File

@ -102,6 +102,7 @@ public class RenderingI18nContext extends I18nBase {
public static final String CAPABILITY_PATCH_INT = "CAPABILITY_PATCH_INT"; public static final String CAPABILITY_PATCH_INT = "CAPABILITY_PATCH_INT";
public static final String GENERAL_PROF = "GENERAL_PROF"; public static final String GENERAL_PROF = "GENERAL_PROF";
public static final String CAPABILITY_PROF_CONF = "CAPABILITY_PROF_CONF"; public static final String CAPABILITY_PROF_CONF = "CAPABILITY_PROF_CONF";
public static final String CAPABILITY_PROF_RES_DOC = "CAPABILITY_PROF_RES_DOC";
public static final String CAPABILITY_PROF_MAP = "CAPABILITY_PROF_MAP"; public static final String CAPABILITY_PROF_MAP = "CAPABILITY_PROF_MAP";
public static final String CAPABILITY_PUB_BY = "CAPABILITY_PUB_BY"; public static final String CAPABILITY_PUB_BY = "CAPABILITY_PUB_BY";
public static final String CAPABILITY_PUB_ON = "CAPABILITY_PUB_ON"; public static final String CAPABILITY_PUB_ON = "CAPABILITY_PUB_ON";
@ -109,6 +110,9 @@ public class RenderingI18nContext extends I18nBase {
public static final String CAPABILITY_REF_PROF = "CAPABILITY_REF_PROF"; public static final String CAPABILITY_REF_PROF = "CAPABILITY_REF_PROF";
public static final String CAPABILITY_REQ_RECOM = "CAPABILITY_REQ_RECOM"; public static final String CAPABILITY_REQ_RECOM = "CAPABILITY_REQ_RECOM";
public static final String CAPABILITY_REST_CAPS = "CAPABILITY_REST_CAPS"; public static final String CAPABILITY_REST_CAPS = "CAPABILITY_REST_CAPS";
public static final String CAPABILITY_DOCUMENT_CAPS = "CAPABILITY_DOCUMENT_CAPS";
public static final String CAPABILITY_MESSAGING_CAPS = "CAPABILITY_MESSAGING_CAPS";
public static final String CAPABILITY_MESSAGING_CAP = "CAPABILITY_MESSAGING_CAP";
public static final String CAPABILITY_REST_CONFIG = "CAPABILITY_REST_CONFIG"; public static final String CAPABILITY_REST_CONFIG = "CAPABILITY_REST_CONFIG";
public static final String CAPABILITY_RES_CONF = "CAPABILITY_RES_CONF"; public static final String CAPABILITY_RES_CONF = "CAPABILITY_RES_CONF";
public static final String CAPABILITY_RES_ENB = "CAPABILITY_RES_ENB"; public static final String CAPABILITY_RES_ENB = "CAPABILITY_RES_ENB";
@ -129,6 +133,8 @@ public class RenderingI18nContext extends I18nBase {
public static final String CAPABILITY_SUPP_FORM = "CAPABILITY_SUPP_FORM"; public static final String CAPABILITY_SUPP_FORM = "CAPABILITY_SUPP_FORM";
public static final String CAPABILITY_SUPP_PATCH_FORM = "CAPABILITY_SUPP_PATCH_FORM"; public static final String CAPABILITY_SUPP_PATCH_FORM = "CAPABILITY_SUPP_PATCH_FORM";
public static final String CAPABILITY_SUPP_PROFS = "CAPABILITY_SUPP_PROFS"; public static final String CAPABILITY_SUPP_PROFS = "CAPABILITY_SUPP_PROFS";
public static final String CAPABILITY_SUPP_MSGS = "CAPABILITY_SUPP_MSGS";
public static final String CAPABILITY_ENDPOINTS = "CAPABILITY_ENDPOINTS";
public static final String CAPABILITY_SUPP_THE = "CAPABILITY_SUPP_THE"; public static final String CAPABILITY_SUPP_THE = "CAPABILITY_SUPP_THE";
public static final String CAPABILITY_SUPPS_THE = "CAPABILITY_SUPPS_THE"; public static final String CAPABILITY_SUPPS_THE = "CAPABILITY_SUPPS_THE";
public static final String GENERAL_TYPE = "GENERAL_TYPE"; public static final String GENERAL_TYPE = "GENERAL_TYPE";

View File

@ -98,6 +98,7 @@ PARS_SUMMARY_LIST = Parameters: {0}
CAPABILITY_PATCH_INT = PATCH a new resource version (patch interaction) CAPABILITY_PATCH_INT = PATCH a new resource version (patch interaction)
GENERAL_PROF = Profile GENERAL_PROF = Profile
CAPABILITY_PROF_CONF = Profile Conformance CAPABILITY_PROF_CONF = Profile Conformance
CAPABILITY_PROF_RES_DOC = Document Resource Profile
CAPABILITY_PROF_MAP = Profile Mapping CAPABILITY_PROF_MAP = Profile Mapping
CAPABILITY_PUB_BY = Published by: {0} CAPABILITY_PUB_BY = Published by: {0}
CAPABILITY_PUB_ON = Published on: {0} CAPABILITY_PUB_ON = Published on: {0}
@ -105,6 +106,9 @@ CAPABILITY_READ_INT = GET a resource (read interaction)
CAPABILITY_REF_PROF = Reference Policy CAPABILITY_REF_PROF = Reference Policy
CAPABILITY_REQ_RECOM = Required and recommended search parameters CAPABILITY_REQ_RECOM = Required and recommended search parameters
CAPABILITY_REST_CAPS = FHIR RESTful Capabilities CAPABILITY_REST_CAPS = FHIR RESTful Capabilities
CAPABILITY_DOCUMENT_CAPS = FHIR Document Capabilities
CAPABILITY_MESSAGING_CAPS = FHIR Messaging Capabilities
CAPABILITY_MESSAGING_CAP = Messaging Capability
CAPABILITY_REST_CONFIG = REST Configuration: {0} CAPABILITY_REST_CONFIG = REST Configuration: {0}
CAPABILITY_RES_CONF = Resource Conformance: {0} CAPABILITY_RES_CONF = Resource Conformance: {0}
CAPABILITY_RES_ENB = The linked resources enabled for CAPABILITY_RES_ENB = The linked resources enabled for
@ -125,6 +129,8 @@ CAPABILITY_SUPPS = Supports
CAPABILITY_SUPP_FORM = Supported Formats: CAPABILITY_SUPP_FORM = Supported Formats:
CAPABILITY_SUPP_PATCH_FORM = Supported Patch Formats: CAPABILITY_SUPP_PATCH_FORM = Supported Patch Formats:
CAPABILITY_SUPP_PROFS = Supported Profiles CAPABILITY_SUPP_PROFS = Supported Profiles
CAPABILITY_SUPP_MSGS = Supported Message(s)
CAPABILITY_ENDPOINTS = Endpoint(s)
CAPABILITY_SUPP_THE = support the CAPABILITY_SUPP_THE = support the
CAPABILITY_SUPPS_THE = Supports the CAPABILITY_SUPPS_THE = Supports the
GENERAL_TYPE = Type GENERAL_TYPE = Type