Merge pull request #414 from hapifhir/gg-2010-jan

Gg 2010 jan
This commit is contained in:
Grahame Grieve 2021-01-15 03:41:56 +11:00 committed by GitHub
commit 1b378ac9b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 78 additions and 15 deletions

View File

@ -459,6 +459,10 @@ public class ProfileUtilities extends TranslatingUtilities {
}
public List<ElementDefinition> getChildList(StructureDefinition profile, String path, String id, boolean diff) {
return getChildList(profile, path, id, diff, false);
}
public List<ElementDefinition> getChildList(StructureDefinition profile, String path, String id, boolean diff, boolean refs) {
List<ElementDefinition> res = new ArrayList<ElementDefinition>();
boolean capturing = id==null;
@ -483,7 +487,7 @@ public class ProfileUtilities extends TranslatingUtilities {
if (capturing) {
String p = e.getPath();
if (!Utilities.noString(e.getContentReference()) && path.startsWith(p)) {
if (refs && !Utilities.noString(e.getContentReference()) && path.startsWith(p)) {
if (path.length() > p.length()) {
return getChildList(profile, e.getContentReference()+"."+path.substring(p.length()+1), null, diff);
} else if (e.getContentReference().startsWith("#")) {
@ -511,6 +515,10 @@ public class ProfileUtilities extends TranslatingUtilities {
return res;
}
public List<ElementDefinition> getChildList(StructureDefinition structure, ElementDefinition element, boolean diff, boolean refs) {
return getChildList(structure, element.getPath(), element.getId(), diff, refs);
}
public List<ElementDefinition> getChildList(StructureDefinition structure, ElementDefinition element, boolean diff) {
return getChildList(structure, element.getPath(), element.getId(), diff);
}
@ -3313,7 +3321,7 @@ public class ProfileUtilities extends TranslatingUtilities {
c.getPieces().add(gen.new Piece("#"+ed.getElement().getPath(), tail(ed.getElement().getPath()), ed.getElement().getPath()));
} else {
c.getPieces().add(gen.new Piece(null, translate("sd.table", "See ", ed.getElement().getPath()), null));
c.getPieces().add(gen.new Piece(corePath+ed.getSource().getUserString("path")+"#"+ed.getElement().getPath(), tail(ed.getElement().getPath())+" ("+ed.getSource().getType()+")", ed.getElement().getPath()));
c.getPieces().add(gen.new Piece(pfx(corePath, ed.getSource().getUserString("path"))+"#"+ed.getElement().getPath(), tail(ed.getElement().getPath())+" ("+ed.getSource().getType()+")", ed.getElement().getPath()));
}
}
return c;
@ -3446,6 +3454,10 @@ public class ProfileUtilities extends TranslatingUtilities {
}
private String pfx(String prefix, String url) {
return Utilities.isAbsoluteUrl(url) ? url : prefix + url;
}
public void genTargetLink(HierarchicalTableGenerator gen, String profileBaseFileName, String corePath, Cell c, TypeRefComponent t, String u) {
if (u.startsWith("http://hl7.org/fhir/StructureDefinition/")) {
StructureDefinition sd = context.fetchResource(StructureDefinition.class, u);

View File

@ -678,5 +678,32 @@ public class ResourceFactory extends Factory {
}
}
public static DataType createPrimitive(String type, String value) {
switch (type) {
case "boolean": return new BooleanType(value);
case "integer": return new IntegerType(value);
case "integer64": return new Integer64Type(value);
case "string": return new StringType(value);
case "decimal": return new DecimalType(value);
case "uri": return new UriType(value);
case "url": return new UrlType(value);
case "canonical": return new CanonicalType(value);
case "base64Binary": return new Base64BinaryType(value);
case "instant": return new InstantType(value);
case "date": return new DateType(value);
case "dateTime": return new DateTimeType(value);
case "time": return new TimeType(value);
case "code": return new CodeType(value);
case "oid": return new OidType(value);
case "id": return new IdType(value);
case "markdown": return new MarkdownType(value);
case "unsignedInt": return new UnsignedIntType(value);
case "positiveInt": return new PositiveIntType(value);
case "uuid": return new UuidType(value);
default:
throw new FHIRException("Unknown Primitive Type '"+type+"'");
}
}
}

View File

@ -72,7 +72,7 @@ public class ElementWrappers {
@Override
public List<PropertyWrapper> children() {
if (list == null) {
children = context.getProfileUtilities().getChildList(structure, definition);
children = context.getProfileUtilities().getChildList(structure, definition, false, true);
if (children.isEmpty() && !Utilities.noString(type)) {
StructureDefinition sd = context.getWorker().fetchTypeDefinition(type);
children = context.getProfileUtilities().getChildList(sd, sd.getSnapshot().getElementFirstRep());

View File

@ -282,6 +282,16 @@ public class CodeSystemUtilities {
return cs;
}
public static boolean makeCSShareable(CodeSystem cs) {
if (!cs.hasMeta())
cs.setMeta(new Meta());
for (UriType t : cs.getMeta().getProfile())
if (t.getValue().equals("http://hl7.org/fhir/StructureDefinition/shareablecodesystem"))
return false;
cs.getMeta().getProfile().add(new CanonicalType("http://hl7.org/fhir/StructureDefinition/shareablecodesystem"));
return true;
}
public static void setOID(CodeSystem cs, String oid) {
if (!oid.startsWith("urn:oid:"))
oid = "urn:oid:" + oid;

View File

@ -57,6 +57,16 @@ public class ValueSetUtilities {
return vs;
}
public static boolean makeVSShareable(ValueSet vs) {
if (!vs.hasMeta())
vs.setMeta(new Meta());
for (UriType t : vs.getMeta().getProfile())
if (t.getValue().equals("http://hl7.org/fhir/StructureDefinition/shareablevalueset"))
return false;
vs.getMeta().getProfile().add(new CanonicalType("http://hl7.org/fhir/StructureDefinition/shareablevalueset"));
return true;
}
public static void checkShareable(ValueSet vs) {
if (!vs.hasMeta())
throw new Error("ValueSet "+vs.getUrl()+" is not shareable");

View File

@ -149,7 +149,7 @@ public class TestingUtilities extends BaseTestingUtilities {
public static String checkXMLIsSame(String f1, String f2) throws Exception {
String result = compareXml(f1, f2);
if (result != null && SHOW_DIFF) {
String diff = Utilities.path(System.getenv("ProgramFiles(X86)"), "WinMerge", "WinMergeU.exe");
String diff = Utilities.path(System.getenv("ProgramFiles"), "WinMerge", "WinMergeU.exe");
List<String> command = new ArrayList<String>();
command.add("\"" + diff + "\" \"" + f1 + "\" \"" + f2 + "\"");

View File

@ -181,7 +181,9 @@ public class ToolingExtensions {
public static final String EXT_EXP_FRAGMENT = "http://hl7.org/fhir/tools/StructureDefinition/expansion-codesystem-fragment";
public static final String EXT_EXP_TOOCOSTLY = "http://hl7.org/fhir/StructureDefinition/valueset-toocostly";
public static final String EXT_MUST_SUPPORT = "http://hl7.org/fhir/StructureDefinition/elementdefinition-type-must-support";
public static final String EXT_TRANSLATABLE = "http://hl7.org/fhir/StructureDefinition/elementdefinition-translatable";
public static final String EXT_PATTERN = "http://hl7.org/fhir/StructureDefinition/elementdefinition-pattern";
// specific extension helpers
public static Extension makeIssueSource(Source source) {

View File

@ -240,16 +240,18 @@ public class HierarchicalTableGenerator extends TranslatingUtilities {
pieces.add(piece);
return this;
}
public Cell addMarkdown(String md) {
try {
Parser parser = Parser.builder().build();
Node document = parser.parse(md);
HtmlRenderer renderer = HtmlRenderer.builder().escapeHtml(true).build();
String html = renderer.render(document);
pieces.addAll(htmlToParagraphPieces(html, null));
} catch (Exception e) {
e.printStackTrace();
if (!Utilities.noString(md)) {
try {
Parser parser = Parser.builder().build();
Node document = parser.parse(md);
HtmlRenderer renderer = HtmlRenderer.builder().escapeHtml(true).build();
String html = renderer.render(document);
pieces.addAll(htmlToParagraphPieces(html, null));
} catch (Exception e) {
e.printStackTrace();
}
}
return this;
}

View File

@ -19,7 +19,7 @@
<properties>
<hapi_fhir_version>5.1.0</hapi_fhir_version>
<validator_test_case_version>1.1.56</validator_test_case_version>
<validator_test_case_version>1.1.57-SNAPSHOT</validator_test_case_version>
<junit_jupiter_version>5.6.2</junit_jupiter_version>
<maven_surefire_version>3.0.0-M4</maven_surefire_version>
<jacoco_version>0.8.5</jacoco_version>