Skip to content

Commit

Permalink
Fix narrative generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Grahame Grieve committed Mar 19, 2024
1 parent 0a5d82b commit 78f6a16
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/main/java/org/hl7/fhir/tools/publisher/Publisher.java
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,7 @@ public void execute(String folder, String[] args) throws IOException {
if (isGenerate && buildFlags.get("all"))
produceQA();

page.log("Max Memory Used = "+Utilities.describeSize(page.getMaxMemory()), LogMessageType.Process);
if (!buildFlags.get("all")) {
page.log("This was a Partial Build", LogMessageType.Process);
CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
Expand Down Expand Up @@ -1871,13 +1872,13 @@ private void addTypes(CodeSystem cs, StructureDefinition sd, List<ConceptDefinit
cd.setDisplay(sd.getType());
cd.setDefinition(sd.getDescription());
if (!sd.getType().equals("Base")) {
CodeSystemUtilities.setProperty(cs, cd, "kind", new CodeType(codeForKind(sd)));
CodeSystemUtilities.setProperty(cs, cd, "http://hl7.org/fhir/type-properties#kind", "kind", new CodeType(codeForKind(sd)));
}
if (sd.getAbstract()) {
CodeSystemUtilities.setProperty(cs, cd, "abstract-type", new BooleanType(true));
CodeSystemUtilities.setProperty(cs, cd, "http://hl7.org/fhir/type-properties#abstract-type", "abstract-type", new BooleanType(true));
}
if (sd.hasExtension(ToolingExtensions.EXT_RESOURCE_INTERFACE)) {
CodeSystemUtilities.setProperty(cs, cd, "interface", new BooleanType(true));
CodeSystemUtilities.setProperty(cs, cd, "http://hl7.org/fhir/type-properties#interface", "interface", new BooleanType(true));
}
list.add(cd);
for (StructureDefinition t : types) {
Expand Down Expand Up @@ -5269,21 +5270,24 @@ private void processExample(Example e, ResourceDefn resn, StructureDefinition pr
}
}
}
if (e.getResource() == null && e.getElement() == null) {
String xml = XMLUtil.elementToString(e.getXml().getDocumentElement()).replace("<?xml version=\"1.0\" encoding=\"UTF-16\"?>", "").trim();
e.setElement(new Manager().parseSingle(page.getWorkerContext(), new StringInputStream(xml), FhirFormat.XML));
e.setResource(new XmlParser().parse(xml));
}
} catch (Throwable ex) {
StringWriter errors = new StringWriter();
System.out.println("Error generating narrative for example "+e.getName()+": "+ex.getMessage());
// ex.printStackTrace();
ex.printStackTrace();
XhtmlNode xhtml = new XhtmlNode(NodeType.Element, "div");
xhtml.addTag("p").setAttribute("style", "color: maroon").addText("Error processing narrative: " + ex.getMessage());
xhtml.addTag("p").setAttribute("style", "color: maroon").addText(errors.toString());
narrative = new XhtmlComposer(XhtmlComposer.HTML).compose(xhtml);
}

try {
if (e.getResource() == null && e.getElement() == null) {
String xml = XMLUtil.elementToString(e.getXml().getDocumentElement()).replace("<?xml version=\"1.0\" encoding=\"UTF-16\"?>", "").trim();
e.setElement(new Manager().parseSingle(page.getWorkerContext(), new StringInputStream(xml), FhirFormat.XML));
e.setResource(new XmlParser().parse(xml));
}
} catch (Throwable ex) {
System.out.println("Error reparsing example "+e.getName()+": "+ex.getMessage());
}
if (rt.equals("ValueSet")) {
try {
ValueSet vs = (ValueSet) loadExample(file);
Expand Down

0 comments on commit 78f6a16

Please sign in to comment.