Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -3,6 +3,7 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Objects;
import java.util.function.BiConsumer;
import java.util.function.Function;
import java.util.function.Predicate;
Expand All @@ -18,6 +19,7 @@
import org.hl7.fhir.r4.model.Identifier;
import org.hl7.fhir.r4.model.OperationOutcome;
import org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent;
import org.hl7.fhir.r4.model.Reference;
import org.hl7.fhir.r4.model.Resource;
import org.hl7.fhir.r4.model.StringType;
import org.hl7.fhir.r4.model.Task.ParameterComponent;
Expand Down Expand Up @@ -168,6 +170,19 @@ private int getCount(MultivaluedMap<String, String> params, int defaultPageCount
return defaultPageCount;
}

protected final <D extends DomainResource> String getIdentifierValue(D resource, Function<D, Boolean> hasIdentifier,
Function<D, Identifier> getIdentifier)
{
Objects.requireNonNull(hasIdentifier, "hasIdentifier");
Objects.requireNonNull(getIdentifier, "getIdentifier");

if (!hasIdentifier.apply(resource))
return "";

Identifier identifier = getIdentifier.apply(resource);
return (identifier != null && identifier.hasValue()) ? identifier.getValue() : "";
}

protected final <D extends DomainResource> String getIdentifierValues(D resource,
Function<D, Boolean> hasIdentifier, Function<D, List<Identifier>> getIdentifier, String identifierSystem)
{
Expand All @@ -184,6 +199,24 @@ protected final <D extends DomainResource> String getIdentifierValues(D resource
return filteredIdentifiers.get(0) + (filteredIdentifiers.size() > 1 ? ", ..." : "");
}

protected final <D extends DomainResource> String getReferenceIdentifierValues(D resource,
Function<D, Boolean> hasReference, Function<D, List<Reference>> getReference)
{
Objects.requireNonNull(hasReference, "hasReference");
Objects.requireNonNull(getReference, "getReference");

if (!hasReference.apply(resource))
return "";

List<String> identifiers = getReference.apply(resource).stream().filter(Reference::hasIdentifier)
.map(Reference::getIdentifier).filter(Identifier::hasValue).map(Identifier::getValue).toList();

if (identifiers.isEmpty())
return "";

return identifiers.get(0) + (identifiers.size() > 1 ? ", ..." : "");
}

protected final String getResourceType(IIdType id)
{
return id != null ? id.getResourceType() : "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
import org.hl7.fhir.r4.model.DecimalType;
import org.hl7.fhir.r4.model.Enumeration;
import org.hl7.fhir.r4.model.Identifier;
import org.hl7.fhir.r4.model.InstantType;
import org.hl7.fhir.r4.model.IntegerType;
import org.hl7.fhir.r4.model.PrimitiveType;
import org.hl7.fhir.r4.model.Reference;
import org.hl7.fhir.r4.model.Resource;
import org.hl7.fhir.r4.model.StringType;
import org.hl7.fhir.r4.model.UriType;
Expand Down Expand Up @@ -134,6 +136,12 @@ protected final <E extends Base> String getDateTime(E resource, Predicate<E> has
return formatDateTime(getValue(resource, hasDateTime, getDateTime));
}

protected final <E extends Base> String getInstant(E resource, Predicate<E> hasInstant,
Function<E, InstantType> getInstant)
{
return formatDateTime(getValue(resource, hasInstant, getInstant));
}

protected final <E extends Base> Boolean getBoolean(E resource, Predicate<E> hasBoolean,
Function<E, BooleanType> getBoolean)
{
Expand Down Expand Up @@ -175,6 +183,19 @@ protected final <E extends Base> String getEnumeration(E resource, Predicate<E>
return e != null && e.hasCode() ? e.getCode() : null;
}

protected final <E extends Base> ElementSystemValue getIdentifier(E resource, Predicate<E> hasIdentifier,
Function<E, Identifier> getIdentifier)
{
Objects.requireNonNull(hasIdentifier, "hasIdentifier");
Objects.requireNonNull(getIdentifier, "getIdentifier");

if (resource == null || !hasIdentifier.test(resource))
return null;

Identifier identifier = getIdentifier.apply(resource);
return identifier != null ? ElementSystemValue.from(identifier) : null;
}

protected final <E extends Base> List<ElementSystemValue> getIdentifiers(E resource, Predicate<E> hasIdentifier,
Function<E, List<Identifier>> getIdentifier)
{
Expand All @@ -187,4 +208,20 @@ protected final <E extends Base> List<ElementSystemValue> getIdentifiers(E resou
List<Identifier> identifier = getIdentifier.apply(resource);
return identifier != null ? identifier.stream().map(ElementSystemValue::from).toList() : null;
}

protected final <E extends Base> List<ElementSystemValue> getReferenceIdentifiers(E resource,
Predicate<E> hasReference, Function<E, List<Reference>> getReference)
{
Objects.requireNonNull(hasReference, "hasReference");
Objects.requireNonNull(getReference, "getReference");

if (resource == null || !hasReference.test(resource))
return null;

List<Reference> references = getReference.apply(resource);
return references != null
? references.stream().filter(Reference::hasIdentifier).map(Reference::getIdentifier)
.map(ElementSystemValue::from).toList()
: null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package dev.dsf.fhir.adapter;

import java.util.List;

import org.hl7.fhir.r4.model.Attachment;
import org.hl7.fhir.r4.model.DocumentReference;

public class ResourceDocumentReference extends AbstractResource<DocumentReference>
{
private record AttachmentElement(String url, String contentType)
{
static AttachmentElement from(Attachment attachment)
{
return new AttachmentElement(attachment.getUrl(), attachment.getContentType());
}
}

private record Element(ElementSystemValue masterIdentifier, List<ElementSystemValue> identifier,
List<ElementSystemValue> author, String docStatus, String date, List<AttachmentElement> attachment)
{
}

public ResourceDocumentReference()
{
super(DocumentReference.class, AbstractResource.ActiveOrStatus.status(DocumentReference::hasStatusElement,
DocumentReference::getStatusElement));
}

@Override
protected Element toElement(DocumentReference resource)
{
ElementSystemValue masterIdentifier = getIdentifier(resource, DocumentReference::hasMasterIdentifier,
DocumentReference::getMasterIdentifier);
List<ElementSystemValue> identifier = getIdentifiers(resource, DocumentReference::hasIdentifier,
DocumentReference::getIdentifier);

List<ElementSystemValue> author = getReferenceIdentifiers(resource, DocumentReference::hasAuthor,
DocumentReference::getAuthor);
String docStatus = resource.hasDocStatus() ? resource.getDocStatus().toCode() : null;

String date = getInstant(resource, DocumentReference::hasDate, DocumentReference::getDateElement);

List<AttachmentElement> attachment = resource.getContent().stream()
.filter(DocumentReference.DocumentReferenceContentComponent::hasAttachment)
.map(DocumentReference.DocumentReferenceContentComponent::getAttachment).map(AttachmentElement::from)
.toList();

return new Element(masterIdentifier, nullIfEmpty(identifier), nullIfEmpty(author), docStatus, date, attachment);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package dev.dsf.fhir.adapter;

import org.hl7.fhir.r4.model.DocumentReference;

public class SearchSetDocumentReference extends AbstractSearchSet<DocumentReference>
{
private record Row(ElementId id, String masterIdentifier, String author, String status, String docStatus,
String lastUpdated)
{
}

public SearchSetDocumentReference(int defaultPageCount)
{
super(defaultPageCount, DocumentReference.class);
}

@Override
protected Row toRow(ElementId id, DocumentReference resource)
{
String masterIdentifier = getIdentifierValue(resource, DocumentReference::hasMasterIdentifier,
DocumentReference::getMasterIdentifier);
String author = getReferenceIdentifierValues(resource, DocumentReference::hasAuthor,
DocumentReference::getAuthor);
String status = resource.hasStatus() ? resource.getStatus().toCode() : "";
String docStatus = resource.hasDocStatus() ? resource.getDocStatus().toCode() : "";
String lastUpdated = formatLastUpdated(resource);

return new Row(id, masterIdentifier, author, status, docStatus, lastUpdated);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import dev.dsf.fhir.adapter.ResourceActivityDefinition;
import dev.dsf.fhir.adapter.ResourceBinary;
import dev.dsf.fhir.adapter.ResourceCodeSystem;
import dev.dsf.fhir.adapter.ResourceDocumentReference;
import dev.dsf.fhir.adapter.ResourceEndpoint;
import dev.dsf.fhir.adapter.ResourceLibrary;
import dev.dsf.fhir.adapter.ResourceMeasure;
Expand All @@ -33,6 +34,7 @@
import dev.dsf.fhir.adapter.ResourceValueSet;
import dev.dsf.fhir.adapter.SearchSetActivityDefinition;
import dev.dsf.fhir.adapter.SearchSetBinary;
import dev.dsf.fhir.adapter.SearchSetDocumentReference;
import dev.dsf.fhir.adapter.SearchSetEndpoint;
import dev.dsf.fhir.adapter.SearchSetMeasureReport;
import dev.dsf.fhir.adapter.SearchSetMetadataResource;
Expand Down Expand Up @@ -70,14 +72,15 @@ public ThymeleafTemplateService thymeleafTemplateService()
{
List<ThymeleafContext> thymeleafContexts = List.of(new ResourceActivityDefinition(),
new ResourceBinary(propertiesConfig.getDsfServerBaseUrl()), new ResourceCodeSystem(),
new ResourceEndpoint(), new ResourceLibrary(), new ResourceMeasure(),
new ResourceDocumentReference(), new ResourceEndpoint(), new ResourceLibrary(), new ResourceMeasure(),
new ResourceMeasureReport(propertiesConfig.getDsfServerBaseUrl()), new ResourceNamingSystem(),
new ResourceOrganizationAffiliation(), new ResourceOrganization(), new ResourceQuestionnaire(),
new ResourceQuestionnaireResponse(), new ResourceStructureDefinition(), new ResourceSubscription(),
new ResourceTask(), new ResourceValueSet(),
new SearchSetActivityDefinition(propertiesConfig.getDefaultPageCount()),
new SearchSetBinary(propertiesConfig.getDefaultPageCount()),
new SearchSetMetadataResource<>(propertiesConfig.getDefaultPageCount(), CodeSystem.class),
new SearchSetDocumentReference(propertiesConfig.getDefaultPageCount()),
new SearchSetEndpoint(propertiesConfig.getDefaultPageCount()),
new SearchSetMetadataResource<>(propertiesConfig.getDefaultPageCount(), Library.class),
new SearchSetMetadataResource<>(propertiesConfig.getDefaultPageCount(), Measure.class),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ function getInitialBookmarks() {
'$ActivityDefinition': ['ActivityDefinition', "ActivityDefinition?_sort=status,url,version"],
'$Binary': ['Binary'],
'$CodeSystem': ['CodeSystem'],
'$DocumentReference': ['DocumentReference'],
'$Endpoint': ['Endpoint'],
'$NamingSystem': ['NamingSystem'],
'$Library': ['Library'],
Expand Down
39 changes: 39 additions & 0 deletions dsf-fhir/dsf-fhir-server/src/main/resources/fhir/static/dsf.css
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,18 @@ pre.lang-html {
border-left-color: var(--color-row-border-grey);
}

.bundle>#list>table tr[resource-type="DocumentReference"] td[status="current"] {
border-left-color: var(--color-row-border-green);
}

.bundle>#list>table tr[resource-type="DocumentReference"] td[status="superseded"] {
border-left-color: var(--color-row-border-grey);
}

.bundle>#list>table tr[resource-type="DocumentReference"] td[status="entered-in-error"] {
border-left-color: var(--color-row-border-red);
}

.bundle>#list>table tr[resource-type="Endpoint"] td[status="active"] {
border-left-color: var(--color-row-border-green);
}
Expand Down Expand Up @@ -639,6 +651,21 @@ pre.lang-html {
color: var(--color-info-grey);
}

#resource[resource-type="DocumentReference"][status="current"] #base-data {
background-color: var(--color-info-background-green);
color: var(--color-info-green);
}

#resource[resource-type="DocumentReference"][status="superseded"] #base-data {
background-color: var(--color-info-background-grey);
color: var(--color-info-grey);
}

#resource[resource-type="DocumentReference"][status="entered-in-error"] #base-data {
background-color: var(--color-info-background-red);
color: var(--color-info-red);
}

#resource[resource-type="Endpoint"][status="active"] #base-data {
background-color: var(--color-info-background-green);
color: var(--color-info-green);
Expand Down Expand Up @@ -800,6 +827,18 @@ pre.lang-html {
fill: var(--color-info-grey);
}

#resource[resource-type="DocumentReference"][status="current"] #base-data path {
fill: var(--color-info-green);
}

#resource[resource-type="DocumentReference"][status="superseded"] #base-data path {
fill: var(--color-info-grey);
}

#resource[resource-type="DocumentReference"][status="entered-in-error"] #base-data path {
fill: var(--color-info-red);
}

#resource[resource-type="Endpoint"][status="active"] #base-data path {
fill: var(--color-info-green);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<body>
<div id="resource">
<div id="resource-data" th:fragment="resource-data">
<th:block th:insert="~{resourceElements::systemAndValue}" th:with="label='Master Identifier',systemAndValue=${documentReference.masterIdentifier}" th:if="${documentReference.masterIdentifier}"></th:block>
<th:block th:insert="~{resourceElements::identifier}" th:with="identifier=${documentReference.identifier}" th:if="${documentReference.identifier}"></th:block>
<th:block th:insert="~{resourceElements::status}" th:if="${resource.status}"></th:block>
<th:block th:insert="~{resourceElements::string}" th:with="label='Document Status',string=${documentReference.docStatus}" th:if="${documentReference.docStatus}"></th:block>
<th:block th:insert="~{resourceElements::systemsAndValues}" th:with="label='Author',systemsAndValues=${documentReference.author}" th:if="${documentReference.author}"></th:block>
<th:block th:insert="~{resourceElements::string}" th:with="label='Date',string=${documentReference.date}" th:if="${documentReference.date}"></th:block>
<th:block th:insert="~{resourceElements::attachments}" th:with="attachments=${documentReference.attachment}" th:if="${documentReference.attachment}"></th:block>
<th:block th:insert="~{resourceElements::additionalValuesComment}"></th:block>
</div>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,21 @@
</li>
</ul>
</div>

<div th:class="${class} ? ${class} : 'element element-100'" th:fragment="attachments">
<label>Attachments</label>
<ul th:if="${attachments}" th:each="a : ${attachments}">
<li class="attachments">
<th:block th:if="${a.url != null and a.contentType != null}">
<a href="#" title="Open" th:href="${a.url}" th:title="'Open ' + ${a.url}" th:text="${a.url} + ' (' + ${a.contentType} + ')'">url</a>
</th:block>
<th:block th:if="${a.url != null and a.contentType == null}">
<a href="#" title="Open" th:href="${a.url}" th:title="'Open ' + ${a.url}" th:text="${a.url}">url</a>
</th:block>
</li>
</ul>
</div>

<i th:fragment="additionalValuesComment">See json or xml for additional values.</i>
</div>
</body>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<body>
<table>
<tr th:fragment="header"><th>ID</th><th>Master Identifier</th><th>Author</th><th>Status</th><th>Document Status</th><th>Last Updated</th></tr>
<tr th:fragment="row" title="Open" th:title="'Open ' + ${element.id.resourceType}" th:attr="resource-type=${element.id.resourceType}">
<td class="id-value" status="current" th:attr="status=${element.status}"><a href="#" title="Open" th:href="${element.id.href}" th:title="'Open ' + ${element.id.resourceType}" th:text="${element.id.value}">id</a></td>
<td th:text="${element.masterIdentifier}">identifier</td>
<td th:text="${element.author}">name</td>
<td th:text="${element.status}">status</td>
<td th:text="${element.docStatus}">docStatus</td>
<td th:text="${element.lastUpdated}">lastUpdated</td>
</tr>
</table>
</body>
</html>