commit
541e903d50
|
@ -3463,6 +3463,11 @@ public class ProfileUtilities {
|
|||
|
||||
|
||||
public void sortDifferential(StructureDefinition base, StructureDefinition diff, String name, List<String> errors, boolean errorIfChanges) throws FHIRException {
|
||||
int index = 0;
|
||||
for (ElementDefinition ed : diff.getDifferential().getElement()) {
|
||||
ed.setUserData("ed.index", Integer.toString(index));
|
||||
index++;
|
||||
}
|
||||
List<ElementDefinition> original = new ArrayList<>();
|
||||
original.addAll(diff.getDifferential().getElement());
|
||||
final List<ElementDefinition> diffList = diff.getDifferential().getElement();
|
||||
|
@ -3520,7 +3525,7 @@ public class ProfileUtilities {
|
|||
ElementDefinition e = diffList.get(i);
|
||||
ElementDefinition n = newDiff.get(i);
|
||||
if (!n.getPath().equals(e.getPath())) {
|
||||
errors.add("The element "+e.getPath()+" is out of order (and maybe others after it)");
|
||||
errors.add("The element "+(e.hasId() ? e.getId() : e.getPath())+" @diff["+e.getUserString("ed.index")+"] is out of order (and maybe others after it)");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -166,7 +166,9 @@ public class LanguageUtils {
|
|||
}
|
||||
for (TranslationUnit t : translations) {
|
||||
if (!usedUnits.contains(t)) {
|
||||
messages.add(new ValidationMessage(Source.Publisher, IssueType.INFORMATIONAL, t.getId(), "Unused '"+t.getLanguage()+"' translation '"+t.getSrcText()+"' -> '"+t.getTgtText()+"'", IssueSeverity.INFORMATION));
|
||||
if (messages != null) {
|
||||
messages.add(new ValidationMessage(Source.Publisher, IssueType.INFORMATIONAL, t.getId(), "Unused '"+t.getLanguage()+"' translation '"+t.getSrcText()+"' -> '"+t.getTgtText()+"'", IssueSeverity.INFORMATION));
|
||||
}
|
||||
}
|
||||
}
|
||||
return r;
|
||||
|
@ -182,7 +184,9 @@ public class LanguageUtils {
|
|||
}
|
||||
for (TranslationUnit t : translations) {
|
||||
if (!usedUnits.contains(t)) {
|
||||
messages.add(new ValidationMessage(Source.Publisher, IssueType.INFORMATIONAL, t.getId(), "Unused '"+t.getLanguage()+"' translation '"+t.getSrcText()+"' -> '"+t.getTgtText()+"'", IssueSeverity.INFORMATION));
|
||||
if (messages != null) {
|
||||
messages.add(new ValidationMessage(Source.Publisher, IssueType.INFORMATIONAL, t.getId(), "Unused '"+t.getLanguage()+"' translation '"+t.getSrcText()+"' -> '"+t.getTgtText()+"'", IssueSeverity.INFORMATION));
|
||||
}
|
||||
}
|
||||
}
|
||||
return r;
|
||||
|
@ -296,7 +300,9 @@ public class LanguageUtils {
|
|||
}
|
||||
}
|
||||
}
|
||||
for (Element c : element.getChildren()) {
|
||||
List<Element> cl = new ArrayList<Element>();
|
||||
cl.addAll(element.getChildren());
|
||||
for (Element c : cl) {
|
||||
if (!c.getName().equals("designation")) {
|
||||
t = t + importFromTranslations(element, c, translations, usedUnits);
|
||||
}
|
||||
|
|
|
@ -897,7 +897,7 @@ public class StructureDefinitionRenderer extends ResourceRenderer {
|
|||
Row parent = null;
|
||||
if (child.hasSliceName()) {
|
||||
// ok, we're a slice
|
||||
if (slicer == null || !slicer.getId().equals(child.getPath())) {
|
||||
if (slicer == null || !noTail(slicer.getId()).equals(child.getPath())) {
|
||||
parent = gen.new Row();
|
||||
String anchorE = child.getPath();
|
||||
anchorE = makeAnchorUnique(anchorE);
|
||||
|
@ -906,7 +906,7 @@ public class StructureDefinitionRenderer extends ResourceRenderer {
|
|||
parent.setColor(context.getProfileUtilities().getRowColor(child, isConstraintMode));
|
||||
parent.setLineColor(1);
|
||||
parent.setIcon("icon_slice.png", context.formatPhrase(RenderingContext.TEXT_ICON_SLICE));
|
||||
parent.getCells().add(gen.new Cell(null, null, "Slices for "+ child.getName(), "", null));
|
||||
parent.getCells().add(gen.new Cell(null, null, context.formatPhrase(RenderingContext.STRUC_DEF_SLICE_FOR, child.getName()), "", null));
|
||||
switch (context.getStructureMode()) {
|
||||
case BINDINGS:
|
||||
case OBLIGATIONS:
|
||||
|
@ -947,6 +947,16 @@ public class StructureDefinitionRenderer extends ResourceRenderer {
|
|||
return slicingRow;
|
||||
}
|
||||
|
||||
private String noTail(String id) {
|
||||
if (id.contains(".")) {
|
||||
String t = id.substring(id.lastIndexOf(".")+1);
|
||||
if (Utilities.isInteger(t)) {
|
||||
return id.substring(0, id.lastIndexOf("."));
|
||||
}
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
private String makeAnchorUnique(String anchor) {
|
||||
if (anchors.containsKey(anchor)) {
|
||||
int c = anchors.get(anchor)+1;
|
||||
|
@ -1063,7 +1073,7 @@ public class StructureDefinitionRenderer extends ResourceRenderer {
|
|||
hint = checkAdd(hint, !hasDef ? null : gt(element.getDefinitionElement()));
|
||||
}
|
||||
if (element.hasSlicing() && slicesExist(elements, element)) { // some elements set up slicing but don't actually slice, so we don't augment the name
|
||||
sName = context.formatPhrase(RenderingContext.STRUC_DEF_SLICE_FOR, sName);
|
||||
sName = context.formatPhrase(RenderingContext.STRUC_DEF_SLICE_FOR, sName);
|
||||
}
|
||||
Cell left = gen.new Cell(null, ref, sName, hint, null);
|
||||
row.getCells().add(left);
|
||||
|
|
|
@ -100,7 +100,8 @@ public class SpreadsheetGenerator {
|
|||
if (name.length() > MAX_SENSITIVE_SHEET_NAME_LEN - 2) {
|
||||
name = name.substring(0, MAX_SENSITIVE_SHEET_NAME_LEN - 2);
|
||||
}
|
||||
String s = fixSheetNameChars(name);
|
||||
name = fixSheetNameChars(name);
|
||||
String s = name;
|
||||
if (sheetNames.containsKey(s)) {
|
||||
int i = 1;
|
||||
do {
|
||||
|
|
|
@ -1,25 +1,17 @@
|
|||
package org.hl7.fhir.r5.renderers.spreadsheets;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.hl7.fhir.exceptions.DefinitionException;
|
||||
import org.hl7.fhir.r5.context.IWorkerContext;
|
||||
import org.hl7.fhir.r5.context.SimpleWorkerContext;
|
||||
import org.hl7.fhir.r5.model.CanonicalType;
|
||||
import org.hl7.fhir.r5.model.ElementDefinition;
|
||||
import org.hl7.fhir.r5.model.ValueSet;
|
||||
import org.hl7.fhir.r5.model.ValueSet.ConceptReferenceComponent;
|
||||
import org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent;
|
||||
import org.hl7.fhir.r5.model.ValueSet.ConceptSetFilterComponent;
|
||||
import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent;
|
||||
import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionParameterComponent;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionMappingComponent;
|
||||
import org.hl7.fhir.utilities.i18n.I18nConstants;
|
||||
|
||||
public class ValueSetSpreadsheetGenerator extends CanonicalSpreadsheetGenerator {
|
||||
|
||||
|
@ -36,11 +28,12 @@ public class ValueSetSpreadsheetGenerator extends CanonicalSpreadsheetGenerator
|
|||
System.out.println("no valueset!");
|
||||
}
|
||||
addValueSetMetadata(renderCanonicalResource(vs, false), vs);
|
||||
int i = 0;
|
||||
for (ConceptSetComponent inc : vs.getCompose().getInclude()) {
|
||||
genInclude(vs, inc, "Include");
|
||||
genInclude(vs, inc, "Include", i++);
|
||||
}
|
||||
for (ConceptSetComponent exc : vs.getCompose().getExclude()) {
|
||||
genInclude(vs, exc, "Exclude");
|
||||
genInclude(vs, exc, "Exclude", i++);
|
||||
}
|
||||
if (vs.hasExpansion()) {
|
||||
if (vs.getExpansion().hasParameter()) {
|
||||
|
@ -82,11 +75,11 @@ public class ValueSetSpreadsheetGenerator extends CanonicalSpreadsheetGenerator
|
|||
return value ? "" : "false";
|
||||
}
|
||||
|
||||
private void genInclude(ValueSet vs, ConceptSetComponent inc, String mode) {
|
||||
private void genInclude(ValueSet vs, ConceptSetComponent inc, String mode, int count) {
|
||||
if (inc.hasSystem()) {
|
||||
genIncludeSystem(vs, inc, mode);
|
||||
genIncludeSystem(vs, inc, mode, count);
|
||||
} else {
|
||||
genIncludeValueSets(vs, inc, mode);
|
||||
genIncludeValueSets(vs, inc, mode, count);
|
||||
}
|
||||
// String subname = inc.hasSystem() ? : "ValueSets";
|
||||
//
|
||||
|
@ -107,14 +100,14 @@ public class ValueSetSpreadsheetGenerator extends CanonicalSpreadsheetGenerator
|
|||
// configureSheet(sheet, sd);
|
||||
}
|
||||
|
||||
private void genIncludeValueSets(ValueSet vs, ConceptSetComponent inc, String mode) {
|
||||
Sheet sheet = makeSheet(mode+" ValueSets");
|
||||
private void genIncludeValueSets(ValueSet vs, ConceptSetComponent inc, String mode, int count) {
|
||||
Sheet sheet = makeSheet(mode+" ValueSet #"+count);
|
||||
addValueSets(sheet, inc.getValueSet());
|
||||
configureSheet(sheet);
|
||||
}
|
||||
|
||||
private void genIncludeSystem(ValueSet vs, ConceptSetComponent inc, String mode) {
|
||||
Sheet sheet = makeSheet(mode+" from "+dr.displaySystem(inc.getSystem()));
|
||||
private void genIncludeSystem(ValueSet vs, ConceptSetComponent inc, String mode, int count) {
|
||||
Sheet sheet = makeSheet(mode+" #"+count);
|
||||
if (inc.hasValueSet()) {
|
||||
addValueSets(sheet, inc.getValueSet());
|
||||
}
|
||||
|
|
|
@ -84,12 +84,12 @@ public class NarrativeGenerationTests {
|
|||
|
||||
@Override
|
||||
public String getLinkFor(String corePath, String typeSimple) {
|
||||
throw new NotImplementedException();
|
||||
return "http://test/link";
|
||||
}
|
||||
|
||||
@Override
|
||||
public BindingResolution resolveBinding(StructureDefinition def, ElementDefinitionBindingComponent binding, String path) throws FHIRException {
|
||||
throw new NotImplementedException();
|
||||
return new BindingResolution("test", "http://test");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -102,7 +102,7 @@ public class NarrativeGenerationTests {
|
|||
return new BindingResolution(vs.present(), "valueset-"+vs.getIdBase()+".html");
|
||||
}
|
||||
}
|
||||
throw new NotImplementedException();
|
||||
return new BindingResolution("test", "http://test/ns");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -120,7 +120,7 @@ public class NarrativeGenerationTests {
|
|||
|
||||
@Override
|
||||
public String getLinkForUrl(String corePath, String s) {
|
||||
throw new NotImplementedException();
|
||||
return "http://test/link/url";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -30,61 +30,73 @@ public class PackageHacker {
|
|||
private static boolean useSecureReferences = false;
|
||||
|
||||
public static void main(String[] args) throws FileNotFoundException, IOException {
|
||||
new PackageHacker().massEdit(new File("/Users/grahamegrieve/web/hl7.org/fhir"));
|
||||
// new PackageHacker().edit("/Users/grahamegrieve/web/hl7.org/fhir/us/vitals/2020Sep/package.tgz");
|
||||
// new PackageHacker().massEdit(new File("/Users/grahamegrieve/web/hl7.org/fhir"));
|
||||
new PackageHacker().edit("/Users/grahamegrieve/web/hl7.org/fhir/6.0.0-ballot1/hl7.fhir.r6.core.tgz");
|
||||
new PackageHacker().edit("/Users/grahamegrieve/web/hl7.org/fhir/6.0.0-ballot1/hl7.fhir.r6.corexml.tgz");
|
||||
new PackageHacker().edit("/Users/grahamegrieve/web/hl7.org/fhir/6.0.0-ballot1/hl7.fhir.r6.examples.tgz");
|
||||
new PackageHacker().edit("/Users/grahamegrieve/web/hl7.org/fhir/6.0.0-ballot1/hl7.fhir.r6.expansions.tgz");
|
||||
new PackageHacker().edit("/Users/grahamegrieve/web/hl7.org/fhir/6.0.0-ballot1/hl7.fhir.r6.search.tgz");
|
||||
new PackageHacker().edit("/Users/grahamegrieve/web/hl7.org/fhir/6.0.0-ballot2/hl7.fhir.r6.core.tgz");
|
||||
new PackageHacker().edit("/Users/grahamegrieve/web/hl7.org/fhir/6.0.0-ballot2/hl7.fhir.r6.corexml.tgz");
|
||||
new PackageHacker().edit("/Users/grahamegrieve/web/hl7.org/fhir/6.0.0-ballot2/hl7.fhir.r6.examples.tgz");
|
||||
new PackageHacker().edit("/Users/grahamegrieve/web/hl7.org/fhir/6.0.0-ballot2/hl7.fhir.r6.expansions.tgz");
|
||||
new PackageHacker().edit("/Users/grahamegrieve/web/hl7.org/fhir/6.0.0-ballot2/hl7.fhir.r6.search.tgz");
|
||||
|
||||
// new PackageHacker().edit(args[0]);
|
||||
}
|
||||
|
||||
private void massEdit(File dir) throws IOException {
|
||||
System.out.println("process "+dir.getAbsolutePath());
|
||||
for (File f : dir.listFiles()) {
|
||||
if (f.isDirectory()) {
|
||||
massEdit(f);
|
||||
} else if (f.getName().equals("package.tgz")) {
|
||||
try {
|
||||
FileInputStream fs = ManagedFileAccess.inStream(f);
|
||||
NpmPackage pck = NpmPackage.fromPackage(fs);
|
||||
if ("fhir.core".equals(pck.getNpm().str("type"))) {
|
||||
System.out.println("!!change "+f.getAbsolutePath());
|
||||
pck.getNpm().remove("type");
|
||||
pck.getNpm().set("type", "Core");
|
||||
FileOutputStream fso = ManagedFileAccess.outStream(f);
|
||||
try {
|
||||
pck.save(fso);
|
||||
} finally {
|
||||
fso.close();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("!!Error: "+e.getMessage());
|
||||
}
|
||||
} else if (f.getName().startsWith("hl7.fhir.r") && f.getName().endsWith(".examples.tgz")) {
|
||||
try {
|
||||
FileInputStream fs = ManagedFileAccess.inStream(f);
|
||||
NpmPackage pck = NpmPackage.fromPackage(fs);
|
||||
if ("fhir.examples".equals(pck.getNpm().str("type"))) {
|
||||
System.out.println("!!change "+f.getAbsolutePath());
|
||||
pck.getNpm().remove("type");
|
||||
pck.getNpm().set("type", "Examples");
|
||||
FileOutputStream fso = ManagedFileAccess.outStream(f);
|
||||
try {
|
||||
pck.save(fso);
|
||||
} finally {
|
||||
fso.close();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("!!Error: "+e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
// private void massEdit(File dir) throws IOException {
|
||||
// System.out.println("process "+dir.getAbsolutePath());
|
||||
// for (File f : dir.listFiles()) {
|
||||
// if (f.isDirectory()) {
|
||||
// massEdit(f);
|
||||
// } else if (f.getName().equals("package.tgz")) {
|
||||
// try {
|
||||
// FileInputStream fs = ManagedFileAccess.inStream(f);
|
||||
// NpmPackage pck = NpmPackage.fromPackage(fs);
|
||||
// if ("fhir.core".equals(pck.getNpm().str("type"))) {
|
||||
// System.out.println("!!change "+f.getAbsolutePath());
|
||||
// pck.getNpm().remove("type");
|
||||
// pck.getNpm().set("type", "Core");
|
||||
// FileOutputStream fso = ManagedFileAccess.outStream(f);
|
||||
// try {
|
||||
// pck.save(fso);
|
||||
// } finally {
|
||||
// fso.close();
|
||||
// }
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// System.out.println("!!Error: "+e.getMessage());
|
||||
// }
|
||||
// } else if (f.getName().startsWith("hl7.fhir.r") && f.getName().endsWith(".examples.tgz")) {
|
||||
// try {
|
||||
// FileInputStream fs = ManagedFileAccess.inStream(f);
|
||||
// NpmPackage pck = NpmPackage.fromPackage(fs);
|
||||
// if ("fhir.examples".equals(pck.getNpm().str("type"))) {
|
||||
// System.out.println("!!change "+f.getAbsolutePath());
|
||||
// pck.getNpm().remove("type");
|
||||
// pck.getNpm().set("type", "Examples");
|
||||
// FileOutputStream fso = ManagedFileAccess.outStream(f);
|
||||
// try {
|
||||
// pck.save(fso);
|
||||
// } finally {
|
||||
// fso.close();
|
||||
// }
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// System.out.println("!!Error: "+e.getMessage());
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
private void edit(String name) throws FileNotFoundException, IOException {
|
||||
File f = ManagedFileAccess.file(name);
|
||||
if (!f.exists())
|
||||
throw new Error("Unable to find "+f.getAbsolutePath());
|
||||
|
||||
System.out.println("Loading Package "+f.getAbsolutePath());
|
||||
NpmPackage pck = null;
|
||||
FileInputStream fs = ManagedFileAccess.inStream(f);
|
||||
try {
|
||||
|
@ -95,15 +107,15 @@ public class PackageHacker {
|
|||
System.out.println("Altering Package "+f.getAbsolutePath());
|
||||
System.out.println(nice(pck.getNpm()));
|
||||
|
||||
change(pck.getNpm());
|
||||
if (change(pck.getNpm())) {
|
||||
|
||||
System.out.println("Revised Package");
|
||||
System.out.println("=======================");
|
||||
System.out.println(nice(pck.getNpm()));
|
||||
System.out.println("=======================");
|
||||
System.out.print("save? y/n: ");
|
||||
int r = System.in.read();
|
||||
if (r == 'y') {
|
||||
// System.out.print("save? y/n: ");
|
||||
// int r = System.in.read();
|
||||
// if (r == 'y') {
|
||||
f.renameTo(ManagedFileAccess.file(Utilities.changeFileExt(name, ".tgz.bak")));
|
||||
FileOutputStream fso = ManagedFileAccess.outStream(f);
|
||||
try {
|
||||
|
@ -111,7 +123,8 @@ public class PackageHacker {
|
|||
} finally {
|
||||
fso.close();
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
private void fixExampleContent(Map<String, byte[]> content) {
|
||||
|
@ -129,10 +142,13 @@ public class PackageHacker {
|
|||
return JsonParser.compose(json, true);
|
||||
}
|
||||
|
||||
private void change(JsonObject npm) throws FileNotFoundException, IOException {
|
||||
private boolean change(JsonObject npm) throws FileNotFoundException, IOException {
|
||||
// fixVersions(npm, ver);
|
||||
npm.remove("notForPublication");
|
||||
npm.set("name", "hl7.fhir.us.vitals");
|
||||
if (npm.has("notForPublication")) {
|
||||
npm.remove("notForPublication");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void fixVersionInContent(Map<String, byte[]> content) {
|
||||
|
|
|
@ -560,7 +560,6 @@ public class HierarchicalTableGenerator {
|
|||
}
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class TableModel {
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -21,7 +21,7 @@
|
|||
<commons_compress_version>1.26.0</commons_compress_version>
|
||||
<guava_version>32.0.1-jre</guava_version>
|
||||
<hapi_fhir_version>6.4.1</hapi_fhir_version>
|
||||
<validator_test_case_version>1.5.20</validator_test_case_version>
|
||||
<validator_test_case_version>1.5.21-SNAPSHOT</validator_test_case_version>
|
||||
<jackson_version>2.17.0</jackson_version>
|
||||
<junit_jupiter_version>5.9.2</junit_jupiter_version>
|
||||
<junit_platform_launcher_version>1.8.2</junit_platform_launcher_version>
|
||||
|
|
Loading…
Reference in New Issue