fix for narrative rendering problem with OperationDefinition

This commit is contained in:
Grahame Grieve 2019-08-16 07:16:24 +10:00
parent 75d86a15ee
commit fb249ea098
6 changed files with 39 additions and 13 deletions

View File

@ -119,7 +119,7 @@ public class NarrativeGenerator implements INarrativeGenerator {
}
public interface ITypeParser {
Base parseType(String xml, String type) throws IOException, FHIRException ;
Base parseType(String xml, String type) throws FHIRFormatError, IOException, FHIRException ;
}
public class ConceptMapRenderInstructions {
@ -1142,7 +1142,7 @@ public class NarrativeGenerator implements INarrativeGenerator {
i++;
if (i > 6)
i = 6;
return "h"+ i;
return "h"+Integer.toString(i);
}
private void filterGrandChildren(List<ElementDefinition> grandChildren, String string, PropertyWrapper prop) {
@ -1958,14 +1958,14 @@ public class NarrativeGenerator implements INarrativeGenerator {
if (rep.hasBoundsPeriod() && rep.getBoundsPeriod().hasStart())
b.append("Starting "+rep.getBoundsPeriod().getStartElement().toHumanDisplay());
if (rep.hasCount())
b.append("Count "+ rep.getCount() +" times");
b.append("Count "+Integer.toString(rep.getCount())+" times");
if (rep.hasDuration())
b.append("Duration "+rep.getDuration().toPlainString()+displayTimeUnits(rep.getPeriodUnit()));
if (rep.hasWhen()) {
String st = "";
if (rep.hasOffset()) {
st = rep.getOffset() +"min ";
st = Integer.toString(rep.getOffset())+"min ";
}
b.append("Do "+st);
for (Enumeration<EventTiming> wh : rep.getWhen())
@ -1977,7 +1977,7 @@ public class NarrativeGenerator implements INarrativeGenerator {
else {
st = Integer.toString(rep.getFrequency());
if (rep.hasFrequencyMax())
st = st + "-"+ rep.getFrequency();
st = st + "-"+Integer.toString(rep.getFrequency());
}
if (rep.hasPeriod()) {
st = st + " per "+rep.getPeriod().toPlainString();
@ -4029,10 +4029,23 @@ public class NarrativeGenerator implements INarrativeGenerator {
tr.td().addText(p.getMin() +".."+p.getMax());
XhtmlNode td = tr.td();
StructureDefinition sd = context.fetchTypeDefinition(p.getType());
if (sd != null)
td.ah(sd.getUserString("path")).tx(p.hasType() ? p.getType() : "");
else
if (sd == null)
td.tx(p.hasType() ? p.getType() : "");
else if (sd.getAbstract() && p.hasExtension(ToolingExtensions.EXT_ALLOWED_TYPE)) {
boolean first = true;
for (Extension ex : p.getExtensionsByUrl(ToolingExtensions.EXT_ALLOWED_TYPE)) {
if (first) first = false; else td.tx(" | ");
String s = ex.getValue().primitiveValue();
StructureDefinition sdt = context.fetchTypeDefinition(s);
if (sdt == null)
td.tx(p.hasType() ? p.getType() : "");
else
td.ah(sdt.getUserString("path")).tx(s);
}
} else
td.ah(sd.getUserString("path")).tx(p.hasType() ? p.getType() : "");
if (p.hasSearchType()) {
td.br();
td.tx("(");

View File

@ -162,6 +162,7 @@ public class ToolingExtensions {
public static final String EXT_MAPPING_TGTTYPE = "http://hl7.org/fhir/tools/StructureDefinition/conceptmap-target-type";
public static final String EXT_MAPPING_TGTCARD = "http://hl7.org/fhir/tools/StructureDefinition/conceptmap-target-cardinality";
public static final String EXT_PRIVATE_BASE = "http://hl7.org/fhir/tools/";
public static final String EXT_ALLOWED_TYPE = "http://hl7.org/fhir/StructureDefinition/operationdefinition-allowed-type";
// specific extension helpers

View File

@ -4119,10 +4119,21 @@ public class NarrativeGenerator implements INarrativeGenerator {
tr.td().addText(Integer.toString(p.getMin())+".."+p.getMax());
XhtmlNode td = tr.td();
StructureDefinition sd = context.fetchTypeDefinition(p.getType());
if (sd != null)
td.ah(sd.getUserString("path")).tx(p.hasType() ? p.getType() : "");
else
if (sd == null)
td.tx(p.hasType() ? p.getType() : "");
else if (sd.getAbstract() && p.hasExtension(ToolingExtensions.EXT_ALLOWED_TYPE)) {
boolean first = true;
for (Extension ex : p.getExtensionsByUrl(ToolingExtensions.EXT_ALLOWED_TYPE)) {
if (first) first = false; else td.tx(" | ");
String s = ex.getValue().primitiveValue();
StructureDefinition sdt = context.fetchTypeDefinition(s);
if (sdt == null)
td.tx(p.hasType() ? p.getType() : "");
else
td.ah(sdt.getUserString("path")).tx(s);
}
} else
td.ah(sd.getUserString("path")).tx(p.hasType() ? p.getType() : "");
if (p.hasSearchType()) {
td.br();
td.tx("(");

View File

@ -162,6 +162,7 @@ public class ToolingExtensions {
public static final String EXT_MAPPING_TGTTYPE = "http://hl7.org/fhir/tools/StructureDefinition/conceptmap-target-type";
public static final String EXT_MAPPING_TGTCARD = "http://hl7.org/fhir/tools/StructureDefinition/conceptmap-target-cardinality";
public static final String EXT_PRIVATE_BASE = "http://hl7.org/fhir/tools/";
public static final String EXT_ALLOWED_TYPE = "http://hl7.org/fhir/StructureDefinition/operationdefinition-allowed-type";
// specific extension helpers

View File

@ -142,7 +142,7 @@ import org.xml.sax.SAXException;
* This is just a wrapper around the InstanceValidator class for convenient use
*
* The following resource formats are supported: XML, JSON, Turtle
* The following versions are supported: 1.0.1, 1.4.0, 3.0.1, and current
* The following versions are supported: 1.0.1, 1.4.0, 3.0.1, 4.0.0, and current
*
* Note: the validation engine is intended to be threadsafe
* To Use:

View File

@ -466,7 +466,7 @@ public class Validator {
x.compose(s, r);
s.close();
}
System.exit(ec);
System.exit(ec > 0 ? 1 : 0);
}
}
}