Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2025 01 gg misc #1017

Merged
merged 5 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
* Loader: Lazy load binaries for reduced memory usage
* Loader: Support for Archetype processing in IG publisher
* Loader: Process Archetypes properly as both IG input and output + remove ig-r4.json
* Validator: Do not create issue about draft dependency for example bindings
* Validator: Beef up validation of CodeSystem properties that are codes
* Validator: Make sure all validation messages have a message id
* Validator: enforce version-set-specific value for Extension and Extension context
* Validator: Specific Error when ValueSet.compose.include.system refers to a ValueSet
* Renderer: improved version specific extension rendering
* Renderer: Add element view to generated fragments
* Renderer: improve Extension context of use presentation - generate a fragment for that
* Renderer: resolve issues with references between IGs to example resources
* Renderer: add use-context fragment for version contest restrictions
* Renderer: Lookup compliesWithProfile target from link-only dependencies
* Renderer: Accessibility - role=presentation on appropriate tables
* Renderer: Add archetype processing, and also path-other support
* Renderer: resolve issues with references between IGs to example resources
* Renderer: Lookup compliesWithProfile target from link-only dependencies
* Renderer: Update SNOMED editions related routines (add more editions)
* Renderer: Accessibility - role=presentation on appropriate tables
* Packages: Add support for ADL in packages
* Terminology Tests: Report count of tests in output from TxTester
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

import org.hl7.fhir.exceptions.FHIRFormatError;
import org.hl7.fhir.igtools.publisher.Publisher.FragmentUseRecord;
import org.hl7.fhir.igtools.publisher.Publisher.LinkedSpecification;
import org.hl7.fhir.igtools.publisher.SpecMapManager.SpecialPackageType;
import org.hl7.fhir.igtools.publisher.modules.IPublisherModule;
import org.hl7.fhir.r5.context.ILoggingService;
Expand Down Expand Up @@ -199,7 +200,7 @@ public String getNextId() {
private String rootFolder;
private String altRootFolder;
private List<SpecMapManager> specs;
private List<SpecMapManager> linkSpecs;
private List<LinkedSpecification> linkSpecs;
private Map<String, LoadedFile> cache = new HashMap<String, LoadedFile>();
private int iteration = 0;
private List<StringPair> otherlinks = new ArrayList<StringPair>();
Expand All @@ -226,7 +227,7 @@ public String getNextId() {
private Map<String, ValidationMessage> jsmsgs = new HashMap<>();
private Map<String, FragmentUseRecord> fragmentUses = new HashMap<>();

public HTMLInspector(String rootFolder, List<SpecMapManager> specs, List<SpecMapManager> linkSpecs, ILoggingService log, String canonical, String packageId, Map<String, List<String>> trackedFragments, List<FetchedFile> sources, IPublisherModule module, boolean isCIBuild, Map<String, FragmentUseRecord> fragmentUses) {
public HTMLInspector(String rootFolder, List<SpecMapManager> specs, List<LinkedSpecification> linkSpecs, ILoggingService log, String canonical, String packageId, Map<String, List<String>> trackedFragments, List<FetchedFile> sources, IPublisherModule module, boolean isCIBuild, Map<String, FragmentUseRecord> fragmentUses) {
this.rootFolder = rootFolder.replace("/", File.separator);
this.specs = specs;
this.linkSpecs = linkSpecs;
Expand Down Expand Up @@ -805,12 +806,12 @@ private boolean checkTarget(String filename, String ref, String rref, StringBuil
}
}
if (!resolved && linkSpecs != null){
for (SpecMapManager spec : linkSpecs) {
if (!resolved && spec.getBase() != null) {
resolved = resolved || spec.getBase().equals(rref) || (spec.getBase()).equals(rref+"/") || (spec.getBase()+"/").equals(rref)|| spec.hasTarget(rref) || Utilities.existsInList(rref, Utilities.pathURL(spec.getBase(), "history.html"));
for (LinkedSpecification spec : linkSpecs) {
if (!resolved && spec.getSpm().getBase() != null) {
resolved = resolved || spec.getSpm().getBase().equals(rref) || (spec.getSpm().getBase()).equals(rref+"/") || (spec.getSpm().getBase()+"/").equals(rref)|| spec.getSpm().hasTarget(rref) || Utilities.existsInList(rref, Utilities.pathURL(spec.getSpm().getBase(), "history.html"));
}
if (!resolved && spec.getBase2() != null) {
resolved = spec.getBase2().equals(rref) || (spec.getBase2()).equals(rref+"/");
if (!resolved && spec.getSpm().getBase2() != null) {
resolved = spec.getSpm().getBase2().equals(rref) || (spec.getSpm().getBase2()).equals(rref+"/");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@
import org.hl7.fhir.r5.renderers.utils.RenderingContext.ExampleScenarioRendererMode;
import org.hl7.fhir.r5.renderers.utils.RenderingContext.FixedValueFormat;
import org.hl7.fhir.r5.renderers.utils.RenderingContext.GenerationRules;
import org.hl7.fhir.r5.renderers.utils.RenderingContext.IResourceLinkResolver;
import org.hl7.fhir.r5.renderers.utils.RenderingContext.ITypeParser;
import org.hl7.fhir.r5.renderers.utils.RenderingContext.KnownLinkType;
import org.hl7.fhir.r5.renderers.utils.RenderingContext.QuestionnaireRendererMode;
Expand Down Expand Up @@ -360,6 +361,7 @@
import org.hl7.fhir.utilities.npm.CommonPackages;
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
import org.hl7.fhir.utilities.npm.NpmPackage;
import org.hl7.fhir.utilities.npm.NpmPackage.PackageResourceInformation;
import org.hl7.fhir.utilities.npm.PackageGenerator.PackageType;
import org.hl7.fhir.utilities.npm.PackageHacker;
import org.hl7.fhir.utilities.npm.PackageList;
Expand Down Expand Up @@ -447,7 +449,7 @@
* ToC is generated by java, needs to be translated
*/

public class Publisher implements ILoggingService, IReferenceResolver, IValidationProfileUsageTracker {
public class Publisher implements ILoggingService, IReferenceResolver, IValidationProfileUsageTracker, IResourceLinkResolver {

public class FragmentUseRecord {

Expand Down Expand Up @@ -654,6 +656,21 @@ public enum LinkTargetType {

}

public static class LinkedSpecification {
private SpecMapManager spm;
private NpmPackage npm;
public LinkedSpecification(SpecMapManager spm, NpmPackage npm) {
super();
this.spm = spm;
this.npm = npm;
}
public SpecMapManager getSpm() {
return spm;
}
public NpmPackage getNpm() {
return npm;
}
}

public enum CacheOption {
LEAVE, CLEAR_ERRORS, CLEAR_ALL;
Expand Down Expand Up @@ -732,7 +749,7 @@ public enum CacheOption {
private IGKnowledgeProvider igpkp;
private List<SpecMapManager> specMaps = new ArrayList<SpecMapManager>();
private List<NpmPackage> npms = new ArrayList<NpmPackage>();
private List<SpecMapManager> linkSpecMaps = new ArrayList<SpecMapManager>();
private List<LinkedSpecification> linkSpecMaps = new ArrayList<>();
private List<String> suppressedIds = new ArrayList<>();

private Map<String, MappingSpace> mappingSpaces = new HashMap<String, MappingSpace>();
Expand Down Expand Up @@ -1582,7 +1599,7 @@ public void setCacheOption(CacheOption cacheOption) {


@Override
public ResourceWithReference resolve(RenderingContext context, String url, String version) {
public ResourceWithReference resolve(RenderingContext context, String url, String version) throws IOException {
if (url == null) {
return null;
}
Expand Down Expand Up @@ -1650,9 +1667,24 @@ public ResourceWithReference resolve(RenderingContext context, String url, Strin
path = null;
}

if (path != null)

return new ResourceWithReference(ResourceReferenceKind.EXTERNAL, url, path, null);
if (path != null) {
InputStream s = null;
if (sp.getNpm() != null && fp.contains("/") && sp.getLoader() != null) {
String[] pl = fp.split("\\/");
String rt = pl[pl.length-2];
String id = pl[pl.length-1];
s = sp.getNpm().loadExampleResource(rt, id);
}
if (s == null) {
return new ResourceWithReference(ResourceReferenceKind.EXTERNAL, url, path, null);
} else {
IContextResourceLoader loader = sp.getLoader();
Resource res = loader.loadResource(s, true);
res.setWebPath(path);
return new ResourceWithReference(ResourceReferenceKind.EXTERNAL, url, path, ResourceWrapper.forResource(context, res));

}
}
}

for (FetchedFile f : fileList) {
Expand Down Expand Up @@ -4132,7 +4164,7 @@ private void loadLinkIg(String packageId) throws Exception {
igm.setName(pi.title());
igm.setBase(pi.canonical());
igm.setBase2(PackageHacker.fixPackageUrl(pi.url()));
linkSpecMaps.add(igm);
linkSpecMaps.add(new LinkedSpecification(igm, pi));
}
}

Expand Down Expand Up @@ -4218,6 +4250,7 @@ private void loadIGPackage(String name, String canonical, String packageId, Stri
igm.setName(name);
igm.setBase(canonical);
igm.setBase2(PackageHacker.fixPackageUrl(pi.url()));
igm.setNpm(pi);
specMaps.add(igm);
if (!VersionUtilities.versionsCompatible(version, pi.fhirVersion())) {
if (!pi.isWarned()) {
Expand All @@ -4227,7 +4260,7 @@ private void loadIGPackage(String name, String canonical, String packageId, Stri
}
}

loadFromPackage(name, canonical, pi, webref, igm, loadDeps);
igm.setLoader(loadFromPackage(name, canonical, pi, webref, igm, loadDeps));
}

private boolean isValidIGToken(String tail) {
Expand Down Expand Up @@ -4264,7 +4297,7 @@ private String getIgUri(NpmPackage pi) throws IOException {



public void loadFromPackage(String name, String canonical, NpmPackage pi, String webref, SpecMapManager igm, boolean loadDeps) throws IOException {
public IContextResourceLoader loadFromPackage(String name, String canonical, NpmPackage pi, String webref, SpecMapManager igm, boolean loadDeps) throws IOException {
if (loadDeps) { // we do not load dependencies for packages the tooling loads on it's own initiative
for (String dep : pi.dependencies()) {
if (!context.hasPackage(dep)) {
Expand All @@ -4291,6 +4324,7 @@ public void loadFromPackage(String name, String canonical, NpmPackage pi, String
smm.setName(dpi.name()+"_"+dpi.version());
smm.setBase(dpi.canonical());
smm.setBase2(PackageHacker.fixPackageUrl(dpi.url()));
smm.setNpm(pi);
specMaps.add(smm);
} catch (Exception e) {
if (!"hl7.fhir.core".equals(dpi.name())) {
Expand All @@ -4299,7 +4333,7 @@ public void loadFromPackage(String name, String canonical, NpmPackage pi, String
}

try {
loadFromPackage(dpi.title(), dpi.canonical(), dpi, PackageHacker.fixPackageUrl(dpi.getWebLocation()), smm, true);
smm.setLoader(loadFromPackage(dpi.title(), dpi.canonical(), dpi, PackageHacker.fixPackageUrl(dpi.getWebLocation()), smm, true));
} catch (Exception e) {
throw new IOException("Error loading "+dpi.name()+"#"+dpi.version()+": "+e.getMessage(), e);
}
Expand All @@ -4310,6 +4344,7 @@ public void loadFromPackage(String name, String canonical, NpmPackage pi, String
}
IContextResourceLoader loader = new PublisherLoader(pi, igm, webref, igpkp).makeLoader();
context.loadFromPackage(pi, loader);
return loader;
}

private String fixPackageReference(String dep) {
Expand Down Expand Up @@ -4808,6 +4843,8 @@ private boolean load() throws Exception {
rc.setParser(getTypeLoader(version));
rc.addLink(KnownLinkType.SELF, targetOutput);
rc.setFixedFormat(fixedFormat);
rc.setResolveLinkResolver(this);
rc.setDebug(debug);
module.defineTypeMap(rc.getTypeMap());
if (publishedIg.hasJurisdiction()) {
Locale locale = null;
Expand Down Expand Up @@ -13412,6 +13449,10 @@ private void generateOutputsStructureDefinition(FetchedFile f, FetchedResource r
long start = System.currentTimeMillis();
fragment("StructureDefinition-"+prefixForContainer+sd.getId()+"-sd-xref"+langSfx, sdr.references(), f.getOutputNames(), r, vars, null, start, "xref", "StructureDefinition");
}
if (igpkp.wantGen(r, "use-context")) {
long start = System.currentTimeMillis();
fragment("StructureDefinition-"+prefixForContainer+sd.getId()+"-sd-use-context"+langSfx, sdr.useContext(), f.getOutputNames(), r, vars, null, start, "use-context", "StructureDefinition");
}
if (igpkp.wantGen(r, "changes")) {
long start = System.currentTimeMillis();
fragment("StructureDefinition-"+prefixForContainer+sd.getId()+"-sd-changes"+langSfx, sdr.changeSummary(), f.getOutputNames(), r, vars, null, start, "changes", "StructureDefinition");
Expand Down Expand Up @@ -14840,7 +14881,6 @@ public static void publishDirect(String path) throws Exception {
if (self.countErrs(self.errors) > 0) {
throw new Exception("Building IG '"+path+"' caused an error");
}

}

public long getMaxMemory() {
Expand All @@ -14859,4 +14899,26 @@ public String resolveUri(RenderingContext context, String uri) {
return null;
}

@Override
public <T extends Resource> T findLinkableResource(Class<T> class_, String uri) throws IOException {
for (LinkedSpecification spec : linkSpecMaps) {
String name = class_.getSimpleName();
for (PackageResourceInformation pri : spec.getNpm().listIndexedResources(name)) {
boolean match = false;
if (uri.contains("|")) {
match = uri.equals(pri.getUrl()+"|"+pri.getVersion());
} else {
match = uri.equals(pri.getUrl());
}
if (match) {
InputStream s = spec.getNpm().load(pri);
IContextResourceLoader pl = new PublisherLoader(spec.getNpm(), spec.getSpm(), PackageHacker.fixPackageUrl(spec.getNpm().getWebLocation()), igpkp).makeLoader();
Resource res = pl.loadResource(s, true);
return (T) res;
}
}
}
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.util.Set;

import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.context.IContextResourceLoader;
import org.hl7.fhir.r5.model.Constants;
import org.hl7.fhir.utilities.TextFile;
import org.hl7.fhir.utilities.Utilities;
Expand Down Expand Up @@ -77,6 +78,7 @@ public enum SpecialPackageType {
private String auth;
private String realm;
private String npmVId;
private IContextResourceLoader loader;

private SpecMapManager() {

Expand Down Expand Up @@ -459,7 +461,7 @@ public static SpecMapManager createSpecialPackage(NpmPackage pi, BasePackageCach
res.special = SpecialPackageType.DICOM;
} else if (pi.name().startsWith("hl7.fhir.") && pi.name().endsWith(".examples") ) {
res.special = SpecialPackageType.Examples;
} else {
} else if (!pi.name().startsWith("hl7.fhir.us.core.v")) {
res.special = SpecialPackageType.Simplifier;
}
res.pi = pi;
Expand Down Expand Up @@ -511,5 +513,21 @@ public boolean isCore() {
return "hl7.fhir.core".equals(getNpmName());
}

public NpmPackage getNpm() {
return pi;
}

public void setNpm(NpmPackage pi) {
this.pi = pi;
}

public IContextResourceLoader getLoader() {
return loader;
}

public void setLoader(IContextResourceLoader loader) {
this.loader = loader;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ private void genExtensionPage(String path, StructureDefinition sd) throws IOExce
}
XhtmlNode body = new XhtmlNode(NodeType.Element, "div");
body.h1().tx(sd.getTitle());
var tbl = body.table("grid");
var tbl = body.table("grid", false);
var tr = tbl.tr();
tr.td().b().tx("URL");
tr.td().tx(sd.getUrl());
Expand Down Expand Up @@ -336,7 +336,7 @@ private void genVersionType(String path, StructureDefinition sd, ImplementationG
XhtmlNode body = new XhtmlNode(NodeType.Element, "div");
body.h1().tx(sd.getName());
body.para().tx("FHIR Cross-version Mappings for "+sd.getType()+" based on the R5 structure");
XhtmlNode tbl = body.table("grid");
XhtmlNode tbl = body.table("grid", false);
XhtmlNode tr = tbl.tr();

// we're going to generate a table with a column for each target structure definition in the chains that terminate in the provided sd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ private String buildExtensionTable(String type, List<ExtensionDefinition> defini
} else {
kind = "data type";
}
var tbl = x.table("list");
var tbl = x.table("list", false);
var tr = tbl.tr();
var td = tr.td();
td.b().tx("Identity");
Expand Down Expand Up @@ -1318,7 +1318,7 @@ public String renderVSList(String versionToAnnotate, List<ValueSet> vslist, bool

XhtmlNode x = new XhtmlNode(NodeType.Element, "div");
Collections.sort(vslist, new CanonicalResourceSortByUrl());
var tbl = x.table("grid");
var tbl = x.table("grid", false);
var tr = tbl.tr();
tr.th().tx("URL");
if (versions) {
Expand Down Expand Up @@ -1613,7 +1613,7 @@ private void resolveCS(List<CodeSystem> list, String url, Resource source) {
public String renderCSList(String versionToAnnotate, List<CodeSystem> cslist, boolean versions, boolean used) throws IOException {
XhtmlNode x = new XhtmlNode(NodeType.Element, "div");
Collections.sort(cslist, new CanonicalResourceSortByUrl());
var tbl = x.table("grid");
var tbl = x.table("grid", false);
var tr = tbl.tr();
tr.th().tx("URL");
if (versions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public XhtmlNode internalGenerate(List<ProvenanceDetails> entries, boolean showT
XhtmlNode div = new XhtmlNode(NodeType.Element, "div");
div.hr();
div.para().b().tx("History");
XhtmlNode tbl = div.table("grid");
XhtmlNode tbl = div.table("grid", false);

// headers
XhtmlNode tr = tbl.tr();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ private static String readOwner(Element resource) {

public static String render(String src, ResourceStatusInformation info, RenderingContext rc) {
StringBuilder b = new StringBuilder();
b.append("<table class=\"");
b.append("<table role=\"presentation\" class=\"");
b.append(info.getColorClass());
b.append("\"><tr>");
String pub = rc.formatPhrase(RenderingContext.MATURITY_PUBLISHER, Utilities.escapeXml(info.getOwner()));
Expand Down
Loading
Loading