fix code system rendering
This commit is contained in:
parent
e6ecc998ea
commit
aec4a6c58a
|
@ -2080,6 +2080,10 @@ public class CodeSystem extends MetadataResource {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return getCode()+": "+getDisplay();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Block()
|
@Block()
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class CodeSystemUtilities {
|
||||||
|
|
||||||
private boolean hasExtraRelationships(List<ConceptDefinitionComponent> concept) {
|
private boolean hasExtraRelationships(List<ConceptDefinitionComponent> concept) {
|
||||||
for (ConceptDefinitionComponent cd : concept) {
|
for (ConceptDefinitionComponent cd : concept) {
|
||||||
if (getSubsumedBy(cd) != null) {
|
if (!getSubsumedBy(cd).isEmpty()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
for (ConceptDefinitionComponent cdc : cd.getConcept()) {
|
for (ConceptDefinitionComponent cdc : cd.getConcept()) {
|
||||||
|
@ -83,11 +83,12 @@ public class CodeSystemUtilities {
|
||||||
if (restructure) {
|
if (restructure) {
|
||||||
List<ConceptDefinitionComponent> res = new ArrayList<>();
|
List<ConceptDefinitionComponent> res = new ArrayList<>();
|
||||||
for (ConceptDefinitionComponent cd : cs.getConcept()) {
|
for (ConceptDefinitionComponent cd : cs.getConcept()) {
|
||||||
if (getSubsumedBy(cd) == null) {
|
if (getSubsumedBy(cd).isEmpty()) {
|
||||||
res.add(cd);
|
res.add(cd);
|
||||||
processed.add(cd.getCode());
|
processed.add(cd.getCode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
System.out.println("children of (root): "+res);
|
||||||
return res;
|
return res;
|
||||||
} else {
|
} else {
|
||||||
return cs.getConcept();
|
return cs.getConcept();
|
||||||
|
@ -100,11 +101,12 @@ public class CodeSystemUtilities {
|
||||||
processed.add(cd.getCode());
|
processed.add(cd.getCode());
|
||||||
}
|
}
|
||||||
for (ConceptDefinitionComponent cd : cs.getConcept()) {
|
for (ConceptDefinitionComponent cd : cs.getConcept()) {
|
||||||
if (context.getCode().equals(getSubsumedBy(cd)) && !processed.contains(cd.getCode())) {
|
if (getSubsumedBy(cd).contains(context.getCode()) && !processed.contains(cd.getCode())) {
|
||||||
res.add(cd);
|
res.add(cd);
|
||||||
processed.add(cd.getCode());
|
processed.add(cd.getCode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
System.out.println("children of "+context+": "+res);
|
||||||
return res;
|
return res;
|
||||||
} else {
|
} else {
|
||||||
return context.getConcept();
|
return context.getConcept();
|
||||||
|
@ -112,22 +114,24 @@ public class CodeSystemUtilities {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getSubsumedBy(ConceptDefinitionComponent cd) {
|
private List<String> getSubsumedBy(ConceptDefinitionComponent cd) {
|
||||||
|
List<String> codes = new ArrayList<>();
|
||||||
for (ConceptPropertyComponent cp : cd.getProperty()) {
|
for (ConceptPropertyComponent cp : cd.getProperty()) {
|
||||||
if (cp.getCode().equals("subsumedBy")) {
|
if (cp.getCode().equals("subsumedBy")) {
|
||||||
return cp.getValue().primitiveValue();
|
codes.add(cp.getValue().primitiveValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return codes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ConceptDefinitionComponent> getOtherChildren(ConceptDefinitionComponent context) {
|
public List<ConceptDefinitionComponent> getOtherChildren(ConceptDefinitionComponent context) {
|
||||||
List<ConceptDefinitionComponent> res = new ArrayList<>();
|
List<ConceptDefinitionComponent> res = new ArrayList<>();
|
||||||
for (ConceptDefinitionComponent cd : cs.getConcept()) {
|
for (ConceptDefinitionComponent cd : cs.getConcept()) {
|
||||||
if (context.getCode().equals(getSubsumedBy(cd)) && processed.contains(cd.getCode())) {
|
if (getSubsumedBy(cd).contains(context.getCode()) && processed.contains(cd.getCode())) {
|
||||||
res.add(cd);
|
res.add(cd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
System.out.println("non-children of "+context+": "+res);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2671,7 +2671,7 @@ public class NarrativeGenerator implements INarrativeGenerator {
|
||||||
if (header) {
|
if (header) {
|
||||||
XhtmlNode h = x.h2();
|
XhtmlNode h = x.h2();
|
||||||
h.addText(cs.hasTitle() ? cs.getTitle() : cs.getName());
|
h.addText(cs.hasTitle() ? cs.getTitle() : cs.getName());
|
||||||
// .... addMarkdown(x, cs.getDescription());
|
addMarkdown(x, cs.getDescription());
|
||||||
if (cs.hasCopyright())
|
if (cs.hasCopyright())
|
||||||
generateCopyright(x, cs, lang);
|
generateCopyright(x, cs, lang);
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,6 +123,7 @@ public class NarrativeGenerationTests {
|
||||||
DomainResource target = (DomainResource) new XmlParser().parse(TestingUtilities.loadTestResourceStream("r5", "narrative", test.getId()+"-expected.xml"));
|
DomainResource target = (DomainResource) new XmlParser().parse(TestingUtilities.loadTestResourceStream("r5", "narrative", test.getId()+"-expected.xml"));
|
||||||
gen.generate(source);
|
gen.generate(source);
|
||||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(TestingUtilities.tempFile("narrative", test.getId()+"-actual.xml")), source);
|
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(TestingUtilities.tempFile("narrative", test.getId()+"-actual.xml")), source);
|
||||||
|
source = (DomainResource) new XmlParser().parse(new FileInputStream(TestingUtilities.tempFile("narrative", test.getId()+"-actual.xml")));
|
||||||
Assert.assertTrue("Output does not match expected", source.equalsDeep(target));
|
Assert.assertTrue("Output does not match expected", source.equalsDeep(target));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue