Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue/175 Template Engine for HTML UIs #176

Merged
merged 43 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
0302f07
added missing constants
hhund Feb 7, 2024
e5bd6ac
thymeleaf learning test
hhund Feb 7, 2024
a72e6e2
new thymeleaf based html generator implementation
hhund Feb 7, 2024
4818a40
removed not needed instanceof pattern variables
hhund Feb 7, 2024
66ef4d4
removed not needed method parameter
hhund Feb 7, 2024
3f27503
refactored code Arrays.asList -> List.of
hhund Feb 12, 2024
d5f25f8
status code only error handler for all mime-types
hhund Feb 12, 2024
ebe39ce
modified impl to directly reject non status requests on status port
hhund Feb 12, 2024
15574ff
allow optional questionnaire items
wetret Feb 12, 2024
0c834d3
remove semicolons at end of statements
wetret Feb 12, 2024
3e233f5
Merge branch 'issue/175_Template_Engine_for_HTML_UIs' of [email protected]
hhund Feb 12, 2024
c2feae8
remove not needed imports
hhund Feb 12, 2024
1b9977a
moved adapt... calls to existing if statements in main, code formatting
hhund Feb 12, 2024
feeb991
modified word-break behavior of h1 page title
hhund Feb 12, 2024
d813f9b
use expectedForbidden() or expectedBadRequest() instead of try-catch
wetret Feb 12, 2024
4b8c8fd
form.css and form.js only for QuestionnaireResponse and Task resources
hhund Feb 12, 2024
c17e8c8
Merge branch 'issue/175_Template_Engine_for_HTML_UIs' of [email protected]
hhund Feb 12, 2024
5b306c1
load html-tab as well if url ends with /
wetret Feb 12, 2024
f52d898
code formatting
hhund Feb 12, 2024
ef542cb
removed not needed escape chars, added support for trailing / chars
hhund Feb 12, 2024
f5d1962
improving Task.instantiates-canonical & ActivityDefinition.url patterns
hhund Feb 12, 2024
eea7abc
removed not needed escape chars, remote property injection defense
hhund Feb 12, 2024
c139df4
added TODO comments
hhund Feb 12, 2024
8ef8392
ui mod and theme feature, conf prop description changes, code formatting
hhund Feb 13, 2024
9e378a0
remove static bpe config file
hhund Feb 14, 2024
6a3d5fc
initial BPE UI, new common code, bpe rev proxy, test setups mods
hhund Feb 14, 2024
4a98aeb
margin fixes
hhund Feb 18, 2024
a9753cc
removed not needed line breaks and spaces from html
hhund Feb 18, 2024
e01549a
integrated bpmn.io viewer
hhund Feb 18, 2024
9918a8f
removed not needed RequestContextListener from servlet context
hhund Feb 18, 2024
50fd7c8
Merge remote-tracking branch 'origin/develop' into
hhund Feb 19, 2024
0146506
no more empty items in QuestionnaireResponse if items optional
hhund Feb 19, 2024
288e5e2
added default value for `dev.dsf.bpe.server.base.url` config parameter
hhund Feb 19, 2024
54487f4
improved code readability
hhund Feb 19, 2024
3a186a9
improved warn log message
hhund Feb 19, 2024
3ee24ab
removed not needed attribute, bpmn stored as data-url in download a-tag
hhund Feb 19, 2024
7e22ee5
formatting of RUN command aligned with bpe Dockerfile RUN command
hhund Feb 19, 2024
420a3cb
added missing empty ui folder to bpe docker image
hhund Feb 19, 2024
d26e31a
thymeleafContexts list entry sort order
hhund Feb 19, 2024
64b6a92
removed redundant mod.css files, now using fhir/bpe specific mod files
hhund Feb 19, 2024
36edc1e
removed static mod.css, mod.css only included in html if exists
hhund Feb 19, 2024
9f2dae0
removed not needed log message placeholders
hhund Feb 19, 2024
6ccd70d
simplified logic statement
hhund Feb 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public interface ProcessAuthorizationHelper
String EXTENSION_PROCESS_AUTHORIZATION_PARENT_ORGANIZATION_ROLE_ORGANIZATION_ROLE = "organization-role";

String EXTENSION_PROCESS_AUTHORIZATION_PARENT_ORGANIZATION_ROLE_PRACTITIONER = "http://dsf.dev/fhir/StructureDefinition/extension-process-authorization-parent-organization-role-practitioner";
String EXTENSION_PROCESS_AUTHORIZATION_PARENT_ORGANIZATION_ROLE_PRACTITIONER_PARENT_ORGANIZATION = EXTENSION_PROCESS_AUTHORIZATION_PARENT_ORGANIZATION_ROLE_PARENT_ORGANIZATION;
String EXTENSION_PROCESS_AUTHORIZATION_PARENT_ORGANIZATION_ROLE_PRACTITIONER_ORGANIZATION_ROLE = EXTENSION_PROCESS_AUTHORIZATION_PARENT_ORGANIZATION_ROLE_ORGANIZATION_ROLE;
String EXTENSION_PROCESS_AUTHORIZATION_PARENT_ORGANIZATION_ROLE_PRACTITIONER_PRACTITIONER_ROLE = "practitioner-role";


Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package dev.dsf.fhir.adapter;

import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.Function;
import java.util.function.Predicate;

import org.hl7.fhir.r4.model.Identifier;
import org.hl7.fhir.r4.model.MetadataResource;

public abstract class AbstractMetdataResource<R extends MetadataResource> extends AbstractResource<R>
{
private record Element(String urlAndVersion, List<ElementSystemValue> identifier, String name, String title,
Boolean experimental, String date)
{
}

private final Predicate<R> hasIdentifier;
private final Function<R, List<Identifier>> getIdentifier;

public AbstractMetdataResource(Class<R> resourceType)
{
this(resourceType, null, null);
}

public AbstractMetdataResource(Class<R> resourceType, Predicate<R> hasIdentifier,
Function<R, List<Identifier>> getIdentifier)
{
super(resourceType,
ActiveOrStatus.status(MetadataResource::hasStatusElement, MetadataResource::getStatusElement));

this.hasIdentifier = hasIdentifier;
this.getIdentifier = getIdentifier;
}

@Override
protected void doSetAdditionalVariables(BiConsumer<String, Object> variables, R resource)
{
String url = getUri(resource, MetadataResource::hasUrlElement, MetadataResource::getUrlElement);
String version = getString(resource, MetadataResource::hasVersionElement, MetadataResource::getVersionElement);
String urlAndVersion = (url != null ? url : "") + " | " + (version != null ? version : "");
List<ElementSystemValue> identifier = hasIdentifier != null && getIdentifier != null
? getIdentifiers(resource, hasIdentifier, getIdentifier)
: null;
String name = getString(resource, MetadataResource::hasNameElement, MetadataResource::getNameElement);
String title = getString(resource, MetadataResource::hasTitleElement, MetadataResource::getTitleElement);
Boolean experimental = getBoolean(resource, MetadataResource::hasExperimentalElement,
MetadataResource::getExperimentalElement);
String date = getDateTime(resource, MetadataResource::hasDateElement, MetadataResource::getDateElement);

variables.accept("metadataResource", new Element(urlAndVersion, identifier, name, title, experimental, date));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
package dev.dsf.fhir.adapter;

import java.util.Objects;
import java.util.function.BiConsumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;

import org.hl7.fhir.r4.model.BooleanType;
import org.hl7.fhir.r4.model.CanonicalType;
import org.hl7.fhir.r4.model.Enumeration;
import org.hl7.fhir.r4.model.Resource;

import ca.uhn.fhir.model.api.annotation.ResourceDef;

abstract class AbstractResource<R extends Resource> extends AbstractThymeleafContext<R>
{
private record ResourceData(String type, String id, String version, String lastUpdated, String profiles,
Boolean active, String status)
{
}

static class ActiveOrStatus<R extends Resource>
{
static <R extends Resource> ActiveOrStatus<R> active(Predicate<R> hasActive, Function<R, BooleanType> getActive)
{
return new ActiveOrStatus<>(Objects.requireNonNull(hasActive, "hasActive"),
Objects.requireNonNull(getActive, "getActive"), null, null);
}

static <R extends Resource> ActiveOrStatus<R> status(Predicate<R> hasStatus,
Function<R, Enumeration<?>> getStatus)
{
return new ActiveOrStatus<>(null, null, Objects.requireNonNull(hasStatus, "hasStatus"),
Objects.requireNonNull(getStatus, "getStatus"));
}

private final Predicate<R> hasActive;
private final Function<R, BooleanType> getActive;
private final Predicate<R> hasStatus;
private final Function<R, Enumeration<?>> getStatus;

ActiveOrStatus(Predicate<R> hasActive, Function<R, BooleanType> getActive, Predicate<R> hasStatus,
Function<R, Enumeration<?>> getStatus)
{
this.hasActive = hasActive;
this.getActive = getActive;
this.hasStatus = hasStatus;
this.getStatus = getStatus;

}

Boolean getActive(R resource)
{
return hasActive != null && getActive != null && hasActive.test(resource)
&& getActive.apply(resource).hasValue() ? getActive.apply(resource).getValue() : null;
}

String getStatus(R resource)
{
return hasStatus != null && getStatus != null && hasStatus.test(resource)
&& getStatus.apply(resource).hasCode() ? getStatus.apply(resource).getCode() : null;
}
}

private final String htmlResourceFragment;
private final ActiveOrStatus<R> activeOrStatus;

protected AbstractResource(Class<R> resourceType, ActiveOrStatus<R> activeOrStatus)
{
this(resourceType, activeOrStatus, "resource" + resourceType.getAnnotation(ResourceDef.class).name());
}

protected AbstractResource(Class<R> resourceType, ActiveOrStatus<R> activeOrStatus, String htmlResourceFragment)
{
super(resourceType, "resource");

this.activeOrStatus = activeOrStatus;
this.htmlResourceFragment = htmlResourceFragment;
}

@Override
public boolean isResourceSupported(String requestPathLastElement)
{
return true;
}

@Override
protected final void doSetVariables(BiConsumer<String, Object> variables, R resource)
{
String type = getResourceType().getAnnotation(ResourceDef.class).name();
String id = resource.hasIdElement() ? resource.getIdElement().getIdPart() : "";
String version = resource.hasIdElement() ? resource.getIdElement().getVersionIdPart() : "";
String lastUpdated = formatLastUpdated(resource);
String profiles = resource.hasMeta() && resource.getMeta().hasProfile()
? resource.getMeta().getProfile().stream().filter(CanonicalType::hasValue).map(CanonicalType::getValue)
.map(s -> s.replace("|", " | ")).collect(Collectors.joining(", "))
: null;

Boolean active = activeOrStatus.getActive(resource);
String status = activeOrStatus.getStatus(resource);

variables.accept("htmlResourceFragment", htmlResourceFragment);
variables.accept("resource", new ResourceData(type, id, version, lastUpdated, profiles, active, status));

String resourceTypeName = getResourceType().getAnnotation(ResourceDef.class).name();
variables.accept(resourceTypeName.substring(0, 1).toLowerCase() + resourceTypeName.substring(1),
toElement(resource));

doSetAdditionalVariables(variables, resource);
}

protected abstract Object toElement(R resource);

protected void doSetAdditionalVariables(BiConsumer<String, Object> variables, R resource)
{
}
}
Loading
Loading