Merge pull request #1669 from hapifhir/2024-06-gg-render-attachments

release notes + render attachments
This commit is contained in:
Grahame Grieve 2024-06-27 07:57:28 +10:00 committed by GitHub
commit 3b02eaedec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 66 additions and 12 deletions

View File

@ -1,7 +1,24 @@
## Validator Changes
* no changes
* Change how count is calculated when expanding value sets
* Fix value set expansion bugs
* Fix for fhirpath issue on command line (#1650)
* Add IG dependency validator
* work around bad r4 extension definitions
* don't reload different sub-version of extensions pack
## Other code changes
* no changes
* Rework rendering library from ground up
* Merge Fix: Fix split logic of canonical into url and version in several places (#1663)
* Suppress spurious message when code system is unknown
* don't raise needless and wrong exceptions about extension definitions when rendering
* fix duplicate link creation
* Stop recursive rendering crash
* Obligation rendering improvements
* Handle extra profiles on resources in an IG when converting between versions
* Fixed issue with actor title not rendering in obligations
* Test and adaption for dateOp #1655
* Use assertj instead of hamcrest (#1662)
* More transifex work
* Add support for local packages during testing

View File

@ -33,6 +33,8 @@ package org.hl7.fhir.r5.model;
import java.net.URI;
import org.hl7.fhir.r5.utils.ToolingExtensions;
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
/**
@ -87,6 +89,16 @@ public class CanonicalType extends UriType {
var s = primitiveValue();
return s == null || !s.contains("|") ? null : s.substring(s.indexOf("|")+1);
}
public String getCanonical() {
if (hasPrimitiveValue()) {
return primitiveValue();
}
if (hasExtension(ToolingExtensions.EXT_ALTERNATE_CANONICAL)) {
return getExtensionString(ToolingExtensions.EXT_ALTERNATE_CANONICAL);
}
return null;
}
}

View File

@ -801,6 +801,9 @@ public class DataRenderer extends Renderer implements CodeResolver {
case "Ratio":
renderRatio(status, x, type);
break;
case "Attachment":
renderAttachment(status, x, type);
break;
case "CodeableReference":
if (type.has("concept")) {
renderCodeableConcept(status, x, type.child("concept"));
@ -847,6 +850,15 @@ public class DataRenderer extends Renderer implements CodeResolver {
renderQuantity(status, x, type.child("denominator"));
}
private void renderAttachment(RenderingStatus status, XhtmlNode x, ResourceWrapper att) {
String ct = att.primitiveValue("contentType");
if (att.has("url")) {
x.tx(context.formatMessage(RenderingContext.DATA_REND_ATT_URL, ct, att.primitiveValue("url")));
} else if (att.has("data")) {
x.tx(context.formatMessage(RenderingContext.DATA_REND_ATT_DATA, ct, displayDataType(att.child("data"))));
}
}
private void renderContactDetail(RenderingStatus status, XhtmlNode x, ResourceWrapper cd) {
if (cd.has("name")) {
x.tx(cd.primitiveValue("name")+": ");

View File

@ -406,7 +406,7 @@ public class ObligationsRenderer extends Renderer {
if (!ob.actors.isEmpty() || ob.compare.actors.isEmpty()) {
boolean firstActor = true;
for (CanonicalType anActor : ob.actors) {
ActorDefinition ad = context.getContext().fetchResource(ActorDefinition.class, anActor.getValue());
ActorDefinition ad = context.getContext().fetchResource(ActorDefinition.class, anActor.getCanonical());
boolean existingActor = ob.compare != null && ob.compare.actors.contains(anActor);
if (!firstActor) {
@ -416,7 +416,11 @@ public class ObligationsRenderer extends Renderer {
if (!existingActor)
actorId.style(STYLE_UNCHANGED);
actorId.addText(ad.getTitle());
if (ad == null) {
actorId.addText(anActor.getCanonical());
} else {
actorId.ah(ad.getWebPath()).tx(ad.getTitle());
}
}
if (ob.compare != null) {
@ -428,7 +432,9 @@ public class ObligationsRenderer extends Renderer {
firstActor = true;
}
actorId = actorId.span(STYLE_REMOVED, null);
if (compAd.hasWebPath()) {
if (compAd == null) {
actorId.ah(context.prefixLocalHref(compActor.toString()), compActor.toString()).tx(compActor.toString());
} else if (compAd.hasWebPath()) {
actorId.ah(context.prefixLocalHref(compAd.getWebPath()), compActor.toString()).tx(compAd.present());
} else {
actorId.span(null, compActor.toString()).tx(compAd.present());
@ -446,13 +452,15 @@ public class ObligationsRenderer extends Renderer {
for (String eid : ob.elementIds) {
elementIds.sep(", ");
ElementDefinition ed = profile.getSnapshot().getElementById(eid);
boolean inScope = inScopePaths.contains(ed.getPath());
String name = eid.substring(eid.indexOf(".") + 1);
if (ed != null && inScope) {
String link = defPath + "#" + anchorPrefix + eid;
elementIds.ah(context.prefixLocalHref(link)).tx(name);
} else {
elementIds.code().tx(name);
if (ed != null) {
boolean inScope = inScopePaths.contains(ed.getPath());
String name = eid.substring(eid.indexOf(".") + 1);
if (ed != null && inScope) {
String link = defPath + "#" + anchorPrefix + eid;
elementIds.ah(context.prefixLocalHref(link)).tx(name);
} else {
elementIds.code().tx(name);
}
}
}

View File

@ -274,6 +274,7 @@ public class ToolingExtensions {
public static final String EXT_IG_URL = "http://hl7.org/fhir/tools/StructureDefinition/implementationguide-resource-uri";
public static final String EXT_VS_CS_SUPPL_NEEDED = "http://hl7.org/fhir/StructureDefinition/valueset-supplement";
public static final String EXT_TYPE_PARAMETER = "http://hl7.org/fhir/tools/StructureDefinition/type-parameter";
public static final String EXT_ALTERNATE_CANONICAL = "http://hl7.org/fhir/StructureDefinition/alternate-canonical";
// specific extension helpers

View File

@ -911,6 +911,8 @@ public class RenderingI18nContext extends I18nBase {
public static final String PROF_DRIV_SUMM_NONE = "PROF_DRIV_SUMM_NONE";
public static final String PROF_DRIV_SUMM = "PROF_DRIV_SUMM";
public static final String DOCUMENT_SUMMARY = "DOCUMENT_SUMMARY";
public static final String DATA_REND_ATT_URL = "DATA_REND_ATT_URL";
public static final String DATA_REND_ATT_DATA = "DATA_REND_ATT_DATA";
protected String getMessagesSourceFileName() {
return "rendering-phrases";

View File

@ -915,3 +915,5 @@ PROF_DRIV_SUMM_NONE = {0}
PROF_DRIV_SUMM = {0}: {1}
BUNDLE_HEADER_DOCUMENT_CONTENTS = Additional Resources Included in Document
DOCUMENT_SUMMARY = <param name="status"/> Document at <param name="date"/> by <param name="author"/> for <param name="subject"/> <if test="has-encounter = true"> in encounter <param name="encounter"/></if>
DATA_REND_ATT_URL = {0} @ {1}
DATA_REND_ATT_DATA = {0}: {1}