improve codesystem property rendering
This commit is contained in:
parent
ca240e4659
commit
c86fc8bbb5
|
@ -372,4 +372,48 @@ public class CodeSystemUtilities {
|
|||
return false;
|
||||
}
|
||||
|
||||
public static boolean hasCode(CodeSystem cs, String code) {
|
||||
for (ConceptDefinitionComponent cc : cs.getConcept()) {
|
||||
if (hasCode(cc, code)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean hasCode(ConceptDefinitionComponent cc, String code) {
|
||||
if (code.equals(cc.getCode())) {
|
||||
return true;
|
||||
}
|
||||
for (ConceptDefinitionComponent c : cc.getConcept()) {
|
||||
if (hasCode(c, code)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ConceptDefinitionComponent getCode(CodeSystem cs, String code) {
|
||||
for (ConceptDefinitionComponent cc : cs.getConcept()) {
|
||||
ConceptDefinitionComponent cd = getCode(cc, code);
|
||||
if (cd != null) {
|
||||
return cd;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static ConceptDefinitionComponent getCode(ConceptDefinitionComponent cc, String code) {
|
||||
if (code.equals(cc.getCode())) {
|
||||
return cc;
|
||||
}
|
||||
for (ConceptDefinitionComponent c : cc.getConcept()) {
|
||||
ConceptDefinitionComponent cd = getCode(c, code);
|
||||
if (cd != null) {
|
||||
return cd;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2935,19 +2935,44 @@ public class NarrativeGenerator implements INarrativeGenerator {
|
|||
return true;
|
||||
}
|
||||
String uri = cp.getUri();
|
||||
String code = null;
|
||||
if (Utilities.noString(uri)){
|
||||
return false;
|
||||
}
|
||||
if (uri.contains("#")) {
|
||||
code = uri.substring(uri.indexOf("#")+1);
|
||||
uri = uri.substring(0, uri.indexOf("#"));
|
||||
}
|
||||
return
|
||||
Utilities.existsInList(uri, "http://hl7.org/fhir/concept-properties") ||
|
||||
codeSystemPropList.contains(uri);
|
||||
if (Utilities.existsInList(uri, "http://hl7.org/fhir/concept-properties") || codeSystemPropList.contains(uri)) {
|
||||
return true;
|
||||
};
|
||||
CodeSystem cs = context.fetchCodeSystem(uri);
|
||||
if (cs == null) {
|
||||
return false;
|
||||
}
|
||||
return CodeSystemUtilities.hasCode(cs, code);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private String getDisplayForProperty(String uri) {
|
||||
if (Utilities.noString(uri)){
|
||||
return null;
|
||||
}
|
||||
String code = null;
|
||||
if (uri.contains("#")) {
|
||||
code = uri.substring(uri.indexOf("#")+1);
|
||||
uri = uri.substring(0, uri.indexOf("#"));
|
||||
}
|
||||
CodeSystem cs = context.fetchCodeSystem(uri);
|
||||
if (cs == null) {
|
||||
return null;
|
||||
}
|
||||
ConceptDefinitionComponent cc = CodeSystemUtilities.getCode(cs, code);
|
||||
return cc == null ? null : cc.getDisplay();
|
||||
}
|
||||
|
||||
|
||||
private int countConcepts(List<ConceptDefinitionComponent> list) {
|
||||
int count = list.size();
|
||||
for (ConceptDefinitionComponent c : list)
|
||||
|
@ -3475,7 +3500,14 @@ public class NarrativeGenerator implements INarrativeGenerator {
|
|||
tr.td().b().tx(context.translator().translate("xhtml-gen-cs", "Version", lang));
|
||||
if (properties != null) {
|
||||
for (PropertyComponent pc : properties) {
|
||||
tr.td().b().tx(context.translator().translate("xhtml-gen-cs", ToolingExtensions.getPresentation(pc, pc.getCodeElement()), lang));
|
||||
String display = ToolingExtensions.getPresentation(pc, pc.getCodeElement());
|
||||
if (display == null || display.equals(pc.getCode()) && pc.hasUri()) {
|
||||
display = getDisplayForProperty(pc.getUri());
|
||||
if (display == null) {
|
||||
display = pc.getCode();
|
||||
}
|
||||
}
|
||||
tr.td().b().tx(context.translator().translate("xhtml-gen-cs", display, lang));
|
||||
}
|
||||
}
|
||||
return tr;
|
||||
|
|
Loading…
Reference in New Issue