R5 related fixes
This commit is contained in:
parent
80ca7e31f9
commit
6fb61b75f0
|
@ -3721,14 +3721,19 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
if (ref != null) {
|
||||
String[] parts = ref.split("\\|");
|
||||
if (parts[0].startsWith("http:") || parts[0].startsWith("https:")) {
|
||||
// c.addPiece(checkForNoChange(t, gen.new Piece(parts[0], "<" + parts[1] + ">", t.getCode()))); Lloyd
|
||||
c.addPiece(checkForNoChange(t, gen.new Piece(parts[0], parts[1], t.getWorkingCode())));
|
||||
if (p.hasExtension(ToolingExtensions.EXT_PROFILE_ELEMENT)) {
|
||||
String pp = p.getExtensionString(ToolingExtensions.EXT_PROFILE_ELEMENT);
|
||||
pp = pp.substring(pp.indexOf("."));
|
||||
c.addPiece(checkForNoChange(t, gen.new Piece(parts[0], parts[1]+pp, t.getWorkingCode())));
|
||||
} else {
|
||||
c.addPiece(checkForNoChange(t, gen.new Piece(parts[0], parts[1], t.getWorkingCode())));
|
||||
}
|
||||
} else {
|
||||
// c.addPiece(checkForNoChange(t, gen.new Piece((t.getProfile().startsWith(corePath)? corePath: "")+parts[0], "<" + parts[1] + ">", t.getCode())));
|
||||
c.addPiece(checkForNoChange(t, gen.new Piece((p.getValue().startsWith(corePath+"StructureDefinition")? corePath: "")+parts[0], parts[1], t.getWorkingCode())));
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
c.addPiece(checkForNoChange(t, gen.new Piece((p.getValue().startsWith(corePath)? corePath: "")+ref, t.getWorkingCode(), null)));
|
||||
}
|
||||
if (!mustSupportMode && isMustSupport(p) && e.getMustSupport()) {
|
||||
c.addPiece(gen.new Piece(null, " ", null));
|
||||
c.addStyledText(translate("sd.table", "This profile must be supported"), "S", "white", "red", null, false);
|
||||
|
@ -5026,7 +5031,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
|
||||
Cell c = gen.new Cell();
|
||||
row.getCells().add(c);
|
||||
c.addPiece(gen.new Piece((ed.getBase().getPath().equals(ed.getPath()) ? ref+ed.getPath() : (VersionUtilities.isThisOrLater("4.1", context.getVersion()) ? corePath+"types-definitions.html#"+ed.getBase().getPath() : corePath+"element-definitions.html#"+ed.getBase().getPath())), t.getName(), null));
|
||||
c.addPiece(gen.new Piece((ed.getBase().getPath().equals(ed.getPath()) ? ref+ed.getPath() : (VersionUtilities.isR5Ver(context.getVersion()) ? corePath+"types-definitions.html#"+ed.getBase().getPath() : corePath+"element-definitions.html#"+ed.getBase().getPath())), t.getName(), null));
|
||||
|
||||
c = gen.new Cell();
|
||||
row.getCells().add(c);
|
||||
|
|
|
@ -21,6 +21,7 @@ public class CanonicalResourceManager<T extends CanonicalResource> {
|
|||
|
||||
private final String[] INVALID_TERMINOLOGY_URLS = {
|
||||
"http://snomed.info/sct",
|
||||
"http://dicom.nema.org/resources/ontology/DCM",
|
||||
"http://nucc.org/provider-taxonomy"
|
||||
};
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ public class RenderingContext {
|
|||
private String tooCostlyNoteNotEmptyDependent;
|
||||
private List<String> codeSystemPropList = new ArrayList<>();
|
||||
|
||||
private ProfileUtilities profileUtilities;
|
||||
private ProfileUtilities profileUtilitiesR;
|
||||
private String definitionsTarget;
|
||||
private String destDir;
|
||||
private boolean inlineGraphics;
|
||||
|
@ -152,7 +152,6 @@ public class RenderingContext {
|
|||
}
|
||||
// default to US locale - discussion here: https://github.com/hapifhir/org.hl7.fhir.core/issues/666
|
||||
this.locale = new Locale.Builder().setLanguageTag("en-US").build();
|
||||
profileUtilities = new ProfileUtilities(worker, null, null);
|
||||
}
|
||||
public RenderingContext copy() {
|
||||
RenderingContext res = new RenderingContext(worker, markdown, terminologyServiceOptions, specificationLink, localPrefix, lang, mode);
|
||||
|
@ -174,7 +173,7 @@ public class RenderingContext {
|
|||
res.tooCostlyNoteNotEmptyDependent = tooCostlyNoteNotEmptyDependent;
|
||||
res.codeSystemPropList.addAll(codeSystemPropList);
|
||||
|
||||
res.profileUtilities = profileUtilities;
|
||||
res.profileUtilitiesR = profileUtilitiesR;
|
||||
res.definitionsTarget = definitionsTarget;
|
||||
res.destDir = destDir;
|
||||
res.addGeneratedNarrativeHeader = addGeneratedNarrativeHeader;
|
||||
|
@ -204,7 +203,10 @@ public class RenderingContext {
|
|||
// -- 2. Markdown support -------------------------------------------------------
|
||||
|
||||
public ProfileUtilities getProfileUtilities() {
|
||||
return profileUtilities;
|
||||
if (profileUtilitiesR == null) {
|
||||
profileUtilitiesR = new ProfileUtilities(worker, null, null);
|
||||
}
|
||||
return profileUtilitiesR;
|
||||
}
|
||||
|
||||
public IWorkerContext getWorker() {
|
||||
|
@ -331,7 +333,7 @@ public class RenderingContext {
|
|||
}
|
||||
|
||||
public RenderingContext setProfileUtilities(ProfileUtilities profileUtilities) {
|
||||
this.profileUtilities = profileUtilities;
|
||||
this.profileUtilitiesR = profileUtilities;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,24 +8,31 @@ import java.util.stream.Stream;
|
|||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.apache.commons.lang3.NotImplementedException;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.r5.conformance.ProfileUtilities;
|
||||
import org.hl7.fhir.r5.conformance.ProfileUtilities.ProfileKnowledgeProvider;
|
||||
import org.hl7.fhir.r5.context.IWorkerContext;
|
||||
import org.hl7.fhir.r5.elementmodel.Manager;
|
||||
import org.hl7.fhir.r5.elementmodel.Manager.FhirFormat;
|
||||
import org.hl7.fhir.r5.formats.JsonParser;
|
||||
import org.hl7.fhir.r5.formats.XmlParser;
|
||||
import org.hl7.fhir.r5.model.Base;
|
||||
import org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent;
|
||||
import org.hl7.fhir.r5.model.Resource;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||
import org.hl7.fhir.r5.renderers.RendererFactory;
|
||||
import org.hl7.fhir.r5.renderers.utils.ElementWrappers;
|
||||
import org.hl7.fhir.r5.renderers.utils.RenderingContext;
|
||||
import org.hl7.fhir.r5.renderers.utils.RenderingContext.ITypeParser;
|
||||
import org.hl7.fhir.r5.renderers.utils.RenderingContext.ResourceRendererMode;
|
||||
import org.hl7.fhir.r5.test.NarrativeGenerationTests.TestProfileKnowledgeProvider;
|
||||
import org.hl7.fhir.r5.test.utils.CompareUtilities;
|
||||
import org.hl7.fhir.r5.test.utils.TestingUtilities;
|
||||
import org.hl7.fhir.utilities.TerminologyServiceOptions;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.xhtml.XhtmlComposer;
|
||||
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
|
||||
import org.hl7.fhir.utilities.xml.XMLUtil;
|
||||
|
@ -40,6 +47,64 @@ import org.xml.sax.SAXException;
|
|||
|
||||
public class NarrativeGenerationTests {
|
||||
|
||||
public class TestProfileKnowledgeProvider implements ProfileKnowledgeProvider {
|
||||
|
||||
private IWorkerContext context;
|
||||
|
||||
public TestProfileKnowledgeProvider(IWorkerContext context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDatatype(String typeSimple) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isResource(String typeSimple) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasLinkFor(String typeSimple) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLinkFor(String corePath, String typeSimple) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BindingResolution resolveBinding(StructureDefinition def, ElementDefinitionBindingComponent binding, String path) throws FHIRException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BindingResolution resolveBinding(StructureDefinition def, String url, String path) throws FHIRException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLinkForProfile(StructureDefinition profile, String url) {
|
||||
if ("http://hl7.org/fhir/StructureDefinition/Composition".equals(url)) {
|
||||
return "http://hl7.org/fhir/composition.html|TestComposition";
|
||||
}
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean prependLinks() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLinkForUrl(String corePath, String s) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class TestTypeParser implements ITypeParser {
|
||||
|
||||
@Override
|
||||
|
@ -111,7 +176,7 @@ public class NarrativeGenerationTests {
|
|||
@MethodSource("data")
|
||||
public void test(String id, TestDetails test) throws Exception {
|
||||
RenderingContext rc = new RenderingContext(context, null, null, "http://hl7.org/fhir", "", null, ResourceRendererMode.END_USER);
|
||||
rc.setDestDir("");
|
||||
rc.setDestDir(Utilities.path("[tmp]", "narrative"));
|
||||
rc.setHeader(test.isHeader());
|
||||
rc.setDefinitionsTarget("test.html");
|
||||
rc.setTerminologyServiceOptions(TerminologyServiceOptions.defaults());
|
||||
|
@ -123,6 +188,7 @@ public class NarrativeGenerationTests {
|
|||
rc.setDateTimeFormatString("yyyy-MM-dd'T'HH:mm:ssZZZZZ");
|
||||
rc.setDateFormatString("yyyy-MM-dd");
|
||||
rc.setMode(test.technical ? ResourceRendererMode.TECHNICAL : ResourceRendererMode.END_USER);
|
||||
rc.setProfileUtilities(new ProfileUtilities(rc.getContext(), null, new TestProfileKnowledgeProvider(rc.getContext())));
|
||||
|
||||
|
||||
Resource source;
|
||||
|
|
|
@ -558,5 +558,12 @@ public class VersionUtilities {
|
|||
return version != null && (version.startsWith("4.") || version.startsWith("5.") || "current".equals(version));
|
||||
}
|
||||
|
||||
public static boolean refersTo(String refVer, String v) {
|
||||
if (v.length() > refVer.length()) {
|
||||
v = v.substring(0, refVer.length());
|
||||
}
|
||||
return refVer.equals(v);
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue