Merge pull request #747 from hapifhir/gg-202202-rendering
Gg 202202 rendering
This commit is contained in:
commit
356dadd7d7
|
@ -0,0 +1,105 @@
|
|||
package org.hl7.fhir.convertors.misc.utg;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.r4.formats.IParser;
|
||||
import org.hl7.fhir.r4.formats.IParser.OutputStyle;
|
||||
import org.hl7.fhir.r4.formats.JsonParser;
|
||||
import org.hl7.fhir.r4.formats.XmlParser;
|
||||
import org.hl7.fhir.r4.model.Bundle;
|
||||
import org.hl7.fhir.r4.model.Bundle.BundleType;
|
||||
import org.hl7.fhir.r4.model.CodeSystem;
|
||||
import org.hl7.fhir.r4.model.CodeSystem.CodeSystemContentMode;
|
||||
import org.hl7.fhir.r4.model.Period;
|
||||
import org.hl7.fhir.r4.model.Provenance;
|
||||
import org.hl7.fhir.r4.model.Provenance.ProvenanceAgentComponent;
|
||||
import org.hl7.fhir.r4.model.Resource;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
|
||||
public class UTGCaseSensitivePopulator {
|
||||
|
||||
public static void main(String[] args) throws FileNotFoundException, IOException {
|
||||
new UTGCaseSensitivePopulator().process(new File(args[0]));
|
||||
|
||||
}
|
||||
|
||||
private void process(File root) throws FileNotFoundException, IOException {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.setType(BundleType.COLLECTION);
|
||||
bundle.setId("hxutg1-1-0-12");
|
||||
|
||||
scanFolders(root, bundle);
|
||||
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(root.getAbsolutePath(), "input", "sourceOfTruth", "history", "utgrel1hx-1-0-12.json")), bundle);
|
||||
System.out.println("Done");
|
||||
}
|
||||
|
||||
private void scanFolders(File folder, Bundle bundle) throws FileNotFoundException, IOException {
|
||||
Calendar today = Calendar.getInstance();
|
||||
Date dt = today.getTime();
|
||||
today.set(Calendar.HOUR_OF_DAY, 0);
|
||||
Date d = today.getTime();
|
||||
System.out.println("Scan "+folder.getAbsolutePath());
|
||||
|
||||
for (File f : folder.listFiles()) {
|
||||
if (f.isDirectory() && !f.getName().equals("retired")) {
|
||||
scanFolders(f, bundle);
|
||||
} else if (f.getName().endsWith(".xml")) {
|
||||
processFile(f, bundle, new XmlParser(), d, dt);
|
||||
} else if (f.getName().endsWith(".json")) {
|
||||
processFile(f, bundle, new JsonParser(), d, dt);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void processFile(File f, Bundle bundle, IParser parser, Date d, Date dt) {
|
||||
try {
|
||||
Resource r = parser.parse(new FileInputStream(f));
|
||||
if (r instanceof CodeSystem) {
|
||||
if (processCodeSystem((CodeSystem) r, bundle, d, dt)) {
|
||||
parser.setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(f), r);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean processCodeSystem(CodeSystem cs, Bundle bundle, Date d, Date dt) {
|
||||
if (cs.hasCaseSensitive()) {
|
||||
return false;
|
||||
}
|
||||
if (!cs.getUrl().startsWith("http://terminology.hl7.org") || cs.getContent() == CodeSystemContentMode.NOTPRESENT) {
|
||||
return false;
|
||||
}
|
||||
cs.setCaseSensitive(true);
|
||||
Provenance p = new Provenance();
|
||||
p.setId("cs-286-"+cs.getId());
|
||||
p.addTarget().setReference("CodeSystem/"+cs.getId());
|
||||
p.setOccurred(new Period());
|
||||
p.getOccurredPeriod().setEnd(d);
|
||||
p.setRecorded(dt);
|
||||
p.addReason().setText("Populate Missing caseSensitive property;UP-286").addCoding().setSystem("http://terminology.hl7.org/CodeSystem/v3-ActReason").setCode("METAMGT");
|
||||
p.getActivity().addCoding().setSystem("http://terminology.hl7.org/CodeSystem/v3-DataOperation").setCode("UPDATE");
|
||||
ProvenanceAgentComponent agent = p.addAgent();
|
||||
agent.getType().addCoding().setSystem("http://terminology.hl7.org/CodeSystem/provenance-participant-type").setCode("author");
|
||||
agent.getWho().setDisplay("Grahame Grieve");
|
||||
agent = p.addAgent();
|
||||
agent.getType().addCoding().setSystem("http://terminology.hl7.org/CodeSystem/provenance-participant-type").setCode("custodian");
|
||||
agent.getWho().setDisplay("Vocabulary WG");
|
||||
|
||||
bundle.addEntry().setFullUrl("http://terminology.hl7.org/fhir/Provenance/cs-286-"+cs.getId()).setResource(p);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -553,7 +553,17 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
}
|
||||
|
||||
public List<ElementDefinition> getChildList(StructureDefinition structure, ElementDefinition element) {
|
||||
return getChildList(structure, element.getPath(), element.getId(), false);
|
||||
if (element.hasContentReference()) {
|
||||
ElementDefinition target = element;
|
||||
for (ElementDefinition t : structure.getSnapshot().getElement()) {
|
||||
if (t.getId().equals(element.getContentReference().substring(1))) {
|
||||
target = t;
|
||||
}
|
||||
}
|
||||
return getChildList(structure, target.getPath(), target.getId(), false);
|
||||
} else {
|
||||
return getChildList(structure, element.getPath(), element.getId(), false);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateMaps(StructureDefinition base, StructureDefinition derived) throws DefinitionException {
|
||||
|
@ -2524,10 +2534,10 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
// re-enabled 11-Feb 2022 GDG - we do want to do this. At least, $assemble in davinci-dtr, where the markdown comes from the SDC IG, and an SDC local reference must be changed to point to SDC. in this case, it's called when generating snapshots
|
||||
// added processRelatives parameter to deal with this (well, to try)
|
||||
if (processRelatives && webUrl != null) {
|
||||
System.out.println("Making "+url+" relative to '"+webUrl+"'");
|
||||
// System.out.println("Making "+url+" relative to '"+webUrl+"'");
|
||||
b.append(webUrl);
|
||||
} else {
|
||||
System.out.println("Not making "+url+" relative to '"+webUrl+"'");
|
||||
// System.out.println("Not making "+url+" relative to '"+webUrl+"'");
|
||||
}
|
||||
i = i + 1;
|
||||
}
|
||||
|
@ -3680,7 +3690,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
}
|
||||
|
||||
|
||||
private String codeForAggregation(AggregationMode a) {
|
||||
public static String codeForAggregation(AggregationMode a) {
|
||||
switch (a) {
|
||||
case BUNDLED : return "b";
|
||||
case CONTAINED : return "c";
|
||||
|
@ -3689,7 +3699,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
}
|
||||
}
|
||||
|
||||
private String hintForAggregation(AggregationMode a) {
|
||||
public static String hintForAggregation(AggregationMode a) {
|
||||
if (a != null)
|
||||
return a.getDefinition();
|
||||
else
|
||||
|
|
|
@ -104,7 +104,7 @@ public class BundleRenderer extends ResourceRenderer {
|
|||
xn.para().b().tx("Exception generating narrative: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
root.blockquote().addChildren(xn);
|
||||
root.blockquote().para().addChildren(xn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ public class BundleRenderer extends ResourceRenderer {
|
|||
List<BaseWrapper> sections = section.children("section");
|
||||
for (BaseWrapper child : sections) {
|
||||
if (nested) {
|
||||
addSection(x.blockquote(), child, level+1, true);
|
||||
addSection(x.blockquote().para(), child, level+1, true);
|
||||
} else {
|
||||
addSection(x, child, level+1, true);
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ public class BundleRenderer extends ResourceRenderer {
|
|||
List<SectionComponent> sections = section.getSection();
|
||||
for (SectionComponent child : sections) {
|
||||
if (nested) {
|
||||
addSection(x.blockquote(), child, level+1, true);
|
||||
addSection(x.blockquote().para(), child, level+1, true);
|
||||
} else {
|
||||
addSection(x, child, level+1, true);
|
||||
}
|
||||
|
@ -300,7 +300,7 @@ public class BundleRenderer extends ResourceRenderer {
|
|||
xn = makeExceptionXhtml(e, "generating narrative");
|
||||
}
|
||||
}
|
||||
root.blockquote().getChildNodes().addAll(checkInternalLinks(b, xn.getChildNodes()));
|
||||
root.blockquote().para().getChildNodes().addAll(checkInternalLinks(b, xn.getChildNodes()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public class CodeSystemRenderer extends TerminologyRenderer {
|
|||
h.addText(cs.hasTitle() ? cs.getTitle() : cs.getName());
|
||||
addMarkdown(x, cs.getDescription());
|
||||
if (cs.hasCopyright())
|
||||
generateCopyright(x, cs);
|
||||
generateCopyright(x, cs );
|
||||
}
|
||||
|
||||
generateProperties(x, cs);
|
||||
|
@ -245,7 +245,7 @@ public class CodeSystemRenderer extends TerminologyRenderer {
|
|||
if (cs == null) {
|
||||
return false;
|
||||
}
|
||||
return CodeSystemUtilities.hasCode(cs, code);
|
||||
return code == null ? false : CodeSystemUtilities.hasCode(cs, code);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -223,7 +223,7 @@ public class PatientRenderer extends ResourceRenderer {
|
|||
|
||||
@Override
|
||||
public boolean render(XhtmlNode x, ResourceWrapper r) throws FHIRFormatError, DefinitionException, IOException {
|
||||
describe(x, r);
|
||||
describe(x.para(), r);
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -168,10 +168,12 @@ public class QuestionnaireResponseRenderer extends ResourceRenderer {
|
|||
r.getCells().add(gen.new Cell(null, context.getDefinitionsTarget() == null ? "" : context.getDefinitionsTarget()+"#item."+linkId, linkId, null, null));
|
||||
r.getCells().add(gen.new Cell(null, null, text, null, null));
|
||||
r.getCells().add(gen.new Cell(null, null, null, null, null));
|
||||
if (answers.size() == 0) {
|
||||
if (answers == null || answers.size() == 0) {
|
||||
r.getCells().add(gen.new Cell(null, null, null, null, null));
|
||||
for (BaseWrapper si : items) {
|
||||
renderTreeItem(gen, r.getSubRows(), q, si);
|
||||
if (items != null) {
|
||||
for (BaseWrapper si : items) {
|
||||
renderTreeItem(gen, r.getSubRows(), q, si);
|
||||
}
|
||||
}
|
||||
} else if (answers.size() == 1) {
|
||||
BaseWrapper ans = answers.get(0);
|
||||
|
|
|
@ -314,6 +314,9 @@ public class XhtmlComposer {
|
|||
else if (node.getNodeType() == NodeType.Element) {
|
||||
Element child = e.getOwnerDocument().createElementNS(XHTML_NS, node.getName());
|
||||
e.appendChild(child);
|
||||
for (String n : node.getAttributes().keySet()) {
|
||||
child.setAttribute(n, node.getAttribute(n));
|
||||
}
|
||||
for (XhtmlNode c : node.getChildNodes()) {
|
||||
appendChild(child, c);
|
||||
}
|
||||
|
|
|
@ -670,7 +670,7 @@ TYPE_SPECIFIC_CHECKS_DT_URL_EXAMPLE = Example URLs are not allowed in this conte
|
|||
UNICODE_BIDI_CONTROLS_CHARS_DISALLOWED = The Unicode sequence has bi-di control characters which are not allowed in this context: {1}
|
||||
UNICODE_BIDI_CONTROLS_CHARS_MATCH = The Unicode sequence has unterminated bi-di control characters (see CVE-2021-42574): {1}
|
||||
CODESYSTEM_CS_HL7_MISSING_ELEMENT_SHALL = HL7 Defined CodeSystems SHALL have a stated value for the {0} element so that users know the status and meaning of the code system clearly
|
||||
CODESYSTEM_CS_HL7_MISSING_ELEMENT_SHOULD = HL7 Defined CodeSystems SHOULD have a stated value for the {0} element so that users know the status and meaning of the code system clearly
|
||||
CODESYSTEM_CS_HL7_MISSING_ELEMENT_SHOULD = HL7 Defined CodeSystems SHOULD have a stated value for the {0} element so that users know the status and meaning of the code system clearly
|
||||
CODESYSTEM_CS_NONHL7_MISSING_ELEMENT = CodeSystems SHOULD have a stated value for the {0} element so that users know the status and meaning of the code system clearly
|
||||
CODESYSTEM_CS_HL7_PRESENT_ELEMENT_SUPPL = CodeSystems SHOULD NOT have a stated value for the {0} element when they are a supplement
|
||||
CODESYSTEM_CS_HL7_PRESENT_ELEMENT_SUPPL_WRONG = CodeSystem Supplements SHALL have a content value of 'supplement'
|
||||
|
|
Loading…
Reference in New Issue