Skip to content

Commit

Permalink
Merge pull request #990 from HL7/UserFriendlyDependencyTable
Browse files Browse the repository at this point in the history
Reader friendly dependency table
  • Loading branch information
grahamegrieve authored Nov 29, 2024
2 parents bfee787 + 4e22cd5 commit 067bb16
Show file tree
Hide file tree
Showing 2 changed files with 222 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2176,98 +2176,98 @@ private void generateNarratives(boolean isRegen) throws Exception {
try {
for (FetchedResource r : f.getResources()) {
if (!isRegen || r.isRegenAfterValidation()) {
if (r.getExampleUri()==null || genExampleNarratives) {
if (!passesNarrativeFilter(r)) {
noNarrativeResources.add(r);
logDebugMessage(LogCategory.PROGRESS, "narrative for "+f.getName()+" : "+r.getId()+" suppressed");
if (r.getResource() != null && r.getResource() instanceof DomainResource) {
((DomainResource) r.getResource()).setText(null);
}
r.getElement().removeChild("text");
} else {
List<Locale> langs = translationLocales();
logDebugMessage(LogCategory.PROGRESS, "narrative for "+f.getName()+" : "+r.getId());
if (r.getResource() != null && isConvertableResource(r.getResource().fhirType())) {
boolean regen = false;
for (Locale lang : langs) {
boolean first = true;
RenderingContext lrc = rc.copy(false).setDefinitionsTarget(igpkp.getDefinitionsName(r));
lrc.setLocale(lang);
lrc.setRules(GenerationRules.VALID_RESOURCE);
lrc.setDefinitionsTarget(igpkp.getDefinitionsName(r));
lrc.setSecondaryLang(!first);
first = false;
if (r.getResource() instanceof DomainResource && (langs.size() > 1 || !(((DomainResource) r.getResource()).hasText() && ((DomainResource) r.getResource()).getText().hasDiv()))) {
regen = true;
if (r.getExampleUri()==null || genExampleNarratives) {
if (!passesNarrativeFilter(r)) {
noNarrativeResources.add(r);
logDebugMessage(LogCategory.PROGRESS, "narrative for "+f.getName()+" : "+r.getId()+" suppressed");
if (r.getResource() != null && r.getResource() instanceof DomainResource) {
((DomainResource) r.getResource()).setText(null);
}
r.getElement().removeChild("text");
} else {
List<Locale> langs = translationLocales();
logDebugMessage(LogCategory.PROGRESS, "narrative for "+f.getName()+" : "+r.getId());
if (r.getResource() != null && isConvertableResource(r.getResource().fhirType())) {
boolean regen = false;
for (Locale lang : langs) {
boolean first = true;
RenderingContext lrc = rc.copy(false).setDefinitionsTarget(igpkp.getDefinitionsName(r));
lrc.setLocale(lang);
lrc.setRules(GenerationRules.VALID_RESOURCE);
lrc.setDefinitionsTarget(igpkp.getDefinitionsName(r));
lrc.setSecondaryLang(!first);
first = false;
if (r.getResource() instanceof DomainResource && (langs.size() > 1 || !(((DomainResource) r.getResource()).hasText() && ((DomainResource) r.getResource()).getText().hasDiv()))) {
regen = true;
ResourceRenderer rr = RendererFactory.factory(r.getResource(), lrc);
if (rr.renderingUsesValidation()) {
r.setRegenAfterValidation(true);
needsRegen = true;
}
rr.setMultiLangMode(langs.size() > 1).renderResource(ResourceWrapper.forResource(lrc, r.getResource()));
} else if (r.getResource() instanceof Bundle) {
regen = true;
new BundleRenderer(lrc).setMultiLangMode(langs.size() > 1).renderResource(ResourceWrapper.forResource(lrc, r.getResource()));
} else if (r.getResource() instanceof Parameters) {
regen = true;
Parameters p = (Parameters) r.getResource();
new ParametersRenderer(lrc).setMultiLangMode(langs.size() > 1).renderResource(ResourceWrapper.forResource(lrc, p));
} else if (r.getResource() instanceof DomainResource) {
checkExistingNarrative(f, r, ((DomainResource) r.getResource()).getText().getDiv());
}
} else if (r.getResource() instanceof Bundle) {
regen = true;
new BundleRenderer(lrc).setMultiLangMode(langs.size() > 1).renderResource(ResourceWrapper.forResource(lrc, r.getResource()));
} else if (r.getResource() instanceof Parameters) {
regen = true;
Parameters p = (Parameters) r.getResource();
new ParametersRenderer(lrc).setMultiLangMode(langs.size() > 1).renderResource(ResourceWrapper.forResource(lrc, p));
} else if (r.getResource() instanceof DomainResource) {
checkExistingNarrative(f, r, ((DomainResource) r.getResource()).getText().getDiv());
}
if (regen) {
Element e = convertToElement(r, r.getResource());
e.copyUserData(r.getElement());
r.setElement(e);
}
} else {
boolean first = true;
for (Locale lang : langs) {
RenderingContext lrc = rc.copy(false).setParser(getTypeLoader(f,r));
lrc.clearAnchors();
lrc.setLocale(lang);
lrc.setRules(GenerationRules.VALID_RESOURCE);
lrc.setSecondaryLang(!first);
first = false;
}
if (regen) {
Element e = convertToElement(r, r.getResource());
e.copyUserData(r.getElement());
r.setElement(e);
}
} else {
boolean first = true;
for (Locale lang : langs) {
RenderingContext lrc = rc.copy(false).setParser(getTypeLoader(f,r));
lrc.clearAnchors();
lrc.setLocale(lang);
lrc.setRules(GenerationRules.VALID_RESOURCE);
lrc.setSecondaryLang(!first);
first = false;
if (isDomainResource(r) && (isRegen || langs.size() > 1 || !hasNarrative(r.getElement()))) {
ResourceWrapper rw = ResourceWrapper.forResource(lrc, r.getElement());
ResourceWrapper rw = ResourceWrapper.forResource(lrc, r.getElement());
ResourceRenderer rr = RendererFactory.factory(rw, lrc);
if (rr.renderingUsesValidation()) {
r.setRegenAfterValidation(true);
needsRegen = true;
}
rr.setMultiLangMode(langs.size() > 1).renderResource(rw);
otherFilesRun.addAll(lrc.getFiles());
} else if (r.fhirType().equals("Bundle")) {
lrc.setAddName(true);
for (Element e : r.getElement().getChildrenByName("entry")) {
Element res = e.getNamedChild("resource");
if (res!=null && "http://hl7.org/fhir/StructureDefinition/DomainResource".equals(res.getProperty().getStructure().getBaseDefinition())) {
ResourceWrapper rw = ResourceWrapper.forResource(lrc, res);
otherFilesRun.addAll(lrc.getFiles());
} else if (r.fhirType().equals("Bundle")) {
lrc.setAddName(true);
for (Element e : r.getElement().getChildrenByName("entry")) {
Element res = e.getNamedChild("resource");
if (res!=null && "http://hl7.org/fhir/StructureDefinition/DomainResource".equals(res.getProperty().getStructure().getBaseDefinition())) {
ResourceWrapper rw = ResourceWrapper.forResource(lrc, res);
ResourceRenderer rr = RendererFactory.factory(rw, lrc);
if (rr.renderingUsesValidation()) {
r.setRegenAfterValidation(true);
needsRegen = true;
}
if (hasNarrative(res)) {
if (hasNarrative(res)) {
rr.checkNarrative(rw);
} else {
} else {
rr.setMultiLangMode(langs.size() > 1).renderResource(rw);
}
}
}
} else if (isDomainResource(r) && hasNarrative(r.getElement())) {
checkExistingNarrative(f, r, r.getElement().getNamedChild("text").getNamedChild("div").getXhtml());
}
} else if (isDomainResource(r) && hasNarrative(r.getElement())) {
checkExistingNarrative(f, r, r.getElement().getNamedChild("text").getNamedChild("div").getXhtml());
}
}
}
} else {
logDebugMessage(LogCategory.PROGRESS, "skipped narrative for "+f.getName()+" : "+r.getId());
}
} else {
logDebugMessage(LogCategory.PROGRESS, "skipped narrative for "+f.getName()+" : "+r.getId());
}
}
}
} finally {
f.finish("generateNarratives");
}
Expand Down Expand Up @@ -9056,6 +9056,8 @@ private void generateSummaryOutputs(DBBuilder db) throws Exception {
start = System.currentTimeMillis();
trackedFragment("3", "dependency-table-short", depr.render(publishedIg, false, false, false), otherFilesRun, start, "dependency-table-short", "Cross");
start = System.currentTimeMillis();
trackedFragment("3", "dependency-table-nontech", depr.renderNonTech(publishedIg), otherFilesRun, start, "dependency-table-nontech", "Cross");
start = System.currentTimeMillis();
trackedFragment("4", "globals-table", depr.renderGlobals(), otherFilesRun, start, "globals-table", "Cross");

// now, list the profiles - all the profiles
Expand Down Expand Up @@ -11661,7 +11663,7 @@ private String processRefTag(DBBuilder db, String src, FetchedFile f) {
private ContextUtilities cu;

private boolean logLoading;

private JsonObject approvedIgsForCustomResources;
private Set<String> customResourceNames = new HashSet<>();
private List<StructureDefinition> customResources = new ArrayList<>();
Expand Down Expand Up @@ -12221,7 +12223,7 @@ private byte[] saveNativeResourceOutputs(FetchedFile f, FetchedResource r) throw
Element eNN = element;
jp.compose(element, bsj, OutputStyle.NORMAL, igpkp.getCanonical());
if (!r.isCustomResource()) {
npm.addFile(isExample(f,r ) ? Category.EXAMPLE : Category.RESOURCE, element.fhirType()+"-"+r.getId()+".json", bsj.toByteArray());
npm.addFile(isExample(f,r ) ? Category.EXAMPLE : Category.RESOURCE, element.fhirType()+"-"+r.getId()+".json", bsj.toByteArray());
} else if ("StructureDefinition".equals(r.fhirType())) {
npm.addFile(Category.RESOURCE, element.fhirType()+"-"+r.getId()+".json", bsj.toByteArray());
StructureDefinition sdt = (StructureDefinition) r.getResource().copy();
Expand All @@ -12238,7 +12240,7 @@ private byte[] saveNativeResourceOutputs(FetchedFile f, FetchedResource r) throw
new JsonParser().setOutputStyle(OutputStyle.NORMAL).compose(bsj, bin);
npm.addFile(isExample(f,r ) ? Category.EXAMPLE : Category.RESOURCE, "Binary-"+r.getId()+".json", bsj.toByteArray());
}

if (module.isNoNarrative()) {
// we don't use the narrative in these resources in _includes, so we strip it - it slows Jekyll down greatly
eNN = (Element) element.copy();
Expand Down
Loading

0 comments on commit 067bb16

Please sign in to comment.