rendering improvements and remove static use of describeSystem
This commit is contained in:
parent
fec36d70b3
commit
f79fdb44ec
|
@ -1518,6 +1518,15 @@ public String toString() {
|
|||
return hasValue() && getValue() instanceof PrimitiveType<?>;
|
||||
}
|
||||
|
||||
public ParametersParameterComponent getPart(String name) {
|
||||
for (ParametersParameterComponent t : getPart()) {
|
||||
if (name.equals(t.getName())) {
|
||||
return t;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// end addition
|
||||
|
||||
}
|
||||
|
|
|
@ -269,24 +269,24 @@ public class DataRenderer extends Renderer implements CodeResolver {
|
|||
}
|
||||
}
|
||||
|
||||
public static String describeSystem(String system) {
|
||||
if (system == null)
|
||||
return /*!#*/ "[not stated]";
|
||||
if (system.equals("http://loinc.org"))
|
||||
return /*!#*/ "LOINC";
|
||||
if (system.startsWith("http://snomed.info"))
|
||||
return /*!#*/ "SNOWMED CT";
|
||||
if (system.equals("http://www.nlm.nih.gov/research/umls/rxnorm"))
|
||||
return /*!#*/ "RxNorm";
|
||||
if (system.equals("http://hl7.org/fhir/sid/icd-9"))
|
||||
return /*!#*/ "ICD-9";
|
||||
if (system.equals("http://dicom.nema.org/resources/ontology/DCM"))
|
||||
return /*!#*/ "DICOM";
|
||||
if (system.equals("http://unitsofmeasure.org"))
|
||||
return /*!#*/ "UCUM";
|
||||
|
||||
return system;
|
||||
}
|
||||
// public static String describeSystem(String system) {
|
||||
// if (system == null)
|
||||
// return /*!#*/ "[not stated]";
|
||||
// if (system.equals("http://loinc.org"))
|
||||
// return /*!#*/ "LOINC";
|
||||
// if (system.startsWith("http://snomed.info"))
|
||||
// return /*!#*/ "SNOMED CT";
|
||||
// if (system.equals("http://www.nlm.nih.gov/research/umls/rxnorm"))
|
||||
// return /*!#*/ "RxNorm";
|
||||
// if (system.equals("http://hl7.org/fhir/sid/icd-9"))
|
||||
// return /*!#*/ "ICD-9";
|
||||
// if (system.equals("http://dicom.nema.org/resources/ontology/DCM"))
|
||||
// return /*!#*/ "DICOM";
|
||||
// if (system.equals("http://unitsofmeasure.org"))
|
||||
// return /*!#*/ "UCUM";
|
||||
//
|
||||
// return system;
|
||||
// }
|
||||
|
||||
public String displaySystem(String system) {
|
||||
if (system == null)
|
||||
|
@ -1054,7 +1054,7 @@ public class DataRenderer extends Renderer implements CodeResolver {
|
|||
|
||||
CodeSystem cs = context.getWorker().fetchCodeSystem(c.getSystem());
|
||||
systemLink = cs != null ? cs.getWebPath() : null;
|
||||
systemName = cs != null ? crPresent(cs) : describeSystem(c.getSystem());
|
||||
systemName = cs != null ? crPresent(cs) : displaySystem(c.getSystem());
|
||||
link = getLinkForCode(c.getSystem(), c.getVersion(), c.getCode());
|
||||
|
||||
hint = systemName+": "+display+(c.hasVersion() ? " "+/*!#*/"(version = "+c.getVersion()+")" : "");
|
||||
|
@ -1077,7 +1077,7 @@ public class DataRenderer extends Renderer implements CodeResolver {
|
|||
|
||||
CodeSystem cs = context.getWorker().fetchCodeSystem(c.getSystem());
|
||||
|
||||
String sn = cs != null ? crPresent(cs) : describeSystem(c.getSystem());
|
||||
String sn = cs != null ? crPresent(cs) : displaySystem(c.getSystem());
|
||||
String link = getLinkForCode(c.getSystem(), c.getVersion(), c.getCode());
|
||||
if (link != null) {
|
||||
x.ah(link).tx(sn);
|
||||
|
@ -1107,7 +1107,7 @@ public class DataRenderer extends Renderer implements CodeResolver {
|
|||
s = c.getCode();
|
||||
|
||||
if (showCodeDetails) {
|
||||
x.addText(s+" "+/*!#*/"(Details: "+TerminologyRenderer.describeSystem(c.getSystem())+" code "+c.getCode()+" = '"+lookupCode(c.getSystem(), c.getVersion(), c.getCode())+"', stated as '"+c.getDisplay()+"')");
|
||||
x.addText(s+" "+/*!#*/"(Details: "+displaySystem(c.getSystem())+" code "+c.getCode()+" = '"+lookupCode(c.getSystem(), c.getVersion(), c.getCode())+"', stated as '"+c.getDisplay()+"')");
|
||||
} else
|
||||
x.span(null, "{"+c.getSystem()+" "+c.getCode()+"}").addText(s);
|
||||
}
|
||||
|
@ -1596,7 +1596,7 @@ public class DataRenderer extends Renderer implements CodeResolver {
|
|||
x.tx("(unit "+q.getCode()+" from "+q.getSystem()+")");
|
||||
}
|
||||
if (showCodeDetails && q.hasCode()) {
|
||||
x.span("background: LightGoldenRodYellow", null).tx(" "+/*!#*/"(Details: "+TerminologyRenderer.describeSystem(q.getSystem())+" code "+q.getCode()+" = '"+lookupCode(q.getSystem(), null, q.getCode())+"')");
|
||||
x.span("background: LightGoldenRodYellow", null).tx(" "+/*!#*/"(Details: "+displaySystem(q.getSystem())+" code "+q.getCode()+" = '"+lookupCode(q.getSystem(), null, q.getCode())+"')");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.hl7.fhir.exceptions.DefinitionException;
|
|||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.r5.model.Attachment;
|
||||
import org.hl7.fhir.r5.model.CanonicalResource;
|
||||
import org.hl7.fhir.r5.model.ContactDetail;
|
||||
import org.hl7.fhir.r5.model.ContactPoint;
|
||||
import org.hl7.fhir.r5.model.DataRequirement;
|
||||
|
@ -345,7 +346,14 @@ public class LibraryRenderer extends ResourceRenderer {
|
|||
p.tx(att.getTitle());
|
||||
p.tx(": ");
|
||||
}
|
||||
p.code().ah(att.getUrl()).tx(att.getUrl());
|
||||
Resource res = context.getContext().fetchResource(Resource.class, att.getUrl());
|
||||
if (res == null || !res.hasWebPath()) {
|
||||
p.code().ah(att.getUrl()).tx(att.getUrl());
|
||||
} else if (res instanceof CanonicalResource) {
|
||||
p.code().ah(res.getWebPath()).tx(((CanonicalResource) res).present());
|
||||
} else {
|
||||
p.code().ah(res.getWebPath()).tx(att.getUrl());
|
||||
}
|
||||
p.tx(" (");
|
||||
p.code().tx(att.getContentType());
|
||||
p.tx(lang(att));
|
||||
|
|
|
@ -144,7 +144,7 @@ public class QuestionnaireRenderer extends TerminologyRenderer {
|
|||
if (link == null) {
|
||||
li.tx(c.getSystem()+"#"+c.getCode());
|
||||
} else {
|
||||
li.ah(link).tx(describeSystem(c.getSystem()));
|
||||
li.ah(link).tx(displaySystem(c.getSystem()));
|
||||
li.tx(": "+c.getCode());
|
||||
}
|
||||
if (c.hasDisplay()) {
|
||||
|
|
|
@ -2936,7 +2936,7 @@ public class StructureDefinitionRenderer extends ResourceRenderer {
|
|||
|
||||
private String summarizeCoding(Coding value) {
|
||||
String uri = value.getSystem();
|
||||
String system = TerminologyRenderer.describeSystem(uri);
|
||||
String system = displaySystem(uri);
|
||||
if (Utilities.isURL(system)) {
|
||||
if (system.equals("http://cap.org/protocols"))
|
||||
system = context.formatMessage(RenderingContext.STRUC_DEF_CAP);
|
||||
|
|
|
@ -519,7 +519,7 @@ public class ValueSetRenderer extends TerminologyRenderer {
|
|||
x.tx(/*!#*/"SNOMED CT "+m+" edition");
|
||||
}
|
||||
} else {
|
||||
x.tx(describeSystem(u)+" "+/*!#*/"version "+v);
|
||||
x.tx(displaySystem(u)+" "+/*!#*/"version "+v);
|
||||
}
|
||||
} else if (u.equals("http://loinc.org")) {
|
||||
String vd = describeLoincVer(v);
|
||||
|
@ -534,10 +534,10 @@ public class ValueSetRenderer extends TerminologyRenderer {
|
|||
if (cr.hasWebPath()) {
|
||||
x.ah(cr.getWebPath()).tx(t+" "+cr.present()+" "+/*!#*/"(no version) ("+cr.fhirType()+")");
|
||||
} else {
|
||||
x.tx(t+" "+describeSystem(u)+" "+/*!#*/"(no version) ("+cr.fhirType()+")");
|
||||
x.tx(t+" "+displaySystem(u)+" "+/*!#*/"(no version) ("+cr.fhirType()+")");
|
||||
}
|
||||
} else {
|
||||
x.tx(t+" "+describeSystem(u)+" "+/*!#*/"(no version)");
|
||||
x.tx(t+" "+displaySystem(u)+" "+/*!#*/"(no version)");
|
||||
}
|
||||
} else {
|
||||
CanonicalResource cr = (CanonicalResource) getContext().getWorker().fetchResource(Resource.class, u+"|"+v, source);
|
||||
|
@ -545,10 +545,10 @@ public class ValueSetRenderer extends TerminologyRenderer {
|
|||
if (cr.hasWebPath()) {
|
||||
x.ah(cr.getWebPath()).tx(t+" "+cr.present()+" v"+v+" ("+cr.fhirType()+")");
|
||||
} else {
|
||||
x.tx(t+" "+describeSystem(u)+" v"+v+" ("+cr.fhirType()+")");
|
||||
x.tx(t+" "+displaySystem(u)+" v"+v+" ("+cr.fhirType()+")");
|
||||
}
|
||||
} else {
|
||||
x.tx(t+" "+describeSystem(u)+" "+/*!#*/"version "+v);
|
||||
x.tx(t+" "+displaySystem(u)+" "+/*!#*/"version "+v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2396,7 +2396,7 @@ public class StructureMapUtilities {
|
|||
if (Utilities.noString(code))
|
||||
throw new FHIRException("Describe Transform, but the code is blank");
|
||||
Coding c = buildCoding(uri, code);
|
||||
return TerminologyRenderer.describeSystem(c.getSystem()) + "#" + c.getCode() + (c.hasDisplay() ? "(" + c.getDisplay() + ")" : "");
|
||||
return c.getSystem() + "#" + c.getCode() + (c.hasDisplay() ? "(" + c.getDisplay() + ")" : "");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,17 +1,23 @@
|
|||
package org.hl7.fhir.validation.special;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import org.hl7.fhir.ParametersParameter;
|
||||
import org.hl7.fhir.r5.formats.IParser.OutputStyle;
|
||||
import org.hl7.fhir.r5.formats.JsonParser;
|
||||
import org.hl7.fhir.r5.model.Base;
|
||||
import org.hl7.fhir.r5.model.Extension;
|
||||
import org.hl7.fhir.r5.model.OperationOutcome;
|
||||
import org.hl7.fhir.r5.model.OperationOutcome.OperationOutcomeIssueComponent;
|
||||
import org.hl7.fhir.r5.model.Parameters;
|
||||
import org.hl7.fhir.r5.model.Parameters.ParametersParameterComponent;
|
||||
import org.hl7.fhir.r5.model.Resource;
|
||||
import org.hl7.fhir.r5.model.StringType;
|
||||
import org.hl7.fhir.r5.model.ValueSet;
|
||||
import org.hl7.fhir.r5.model.ValueSet.ConceptPropertyComponent;
|
||||
|
@ -20,10 +26,21 @@ import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent;
|
|||
import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionParameterComponent;
|
||||
import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionPropertyComponent;
|
||||
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
|
||||
import org.hl7.fhir.utilities.json.JsonException;
|
||||
|
||||
public class TxTesterSorters {
|
||||
|
||||
|
||||
public static void main(String[] args) throws JsonException, IOException {
|
||||
Resource r = new JsonParser().parse(new FileInputStream(args[0]));
|
||||
switch (r.fhirType()) {
|
||||
case "Parameters" :
|
||||
sortParameters((Parameters) r);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(args[0]), r);
|
||||
}
|
||||
|
||||
public static void sortParameters(Parameters po) {
|
||||
Collections.sort(po.getParameter(), new TxTesterSorters.ParameterSorter());
|
||||
|
@ -190,6 +207,30 @@ public class TxTesterSorters {
|
|||
Collections.sort(o2.getExtension(), new ExtensionSorter());
|
||||
Collections.sort(o1.getPart(), new ParameterSorter());
|
||||
Collections.sort(o2.getPart(), new ParameterSorter());
|
||||
if (o1.getName().equals(o2.getName()) && o1.getName().equals("property")) {
|
||||
String code1 = o1.getPart("code").getValue().primitiveValue().toLowerCase();
|
||||
String code2 = o2.getPart("code").getValue().primitiveValue().toLowerCase();
|
||||
if (code1 != null && code2 != null && !code1.equals(code2)) {
|
||||
return code1.compareTo(code2);
|
||||
}
|
||||
String v1 = o1.getPart("value") != null && o1.getPart("value").hasPrimitiveValue() ? o1.getPart("value").getValue().primitiveValue().toLowerCase() : null;
|
||||
String v2 = o2.getPart("value") != null && o2.getPart("value").hasPrimitiveValue() ? o2.getPart("value").getValue().primitiveValue().toLowerCase() : null;
|
||||
if (v1 != null && v2 != null && !v1.equals(v2)) {
|
||||
return v1.compareTo(v2);
|
||||
}
|
||||
}
|
||||
if (o1.getName().equals(o2.getName()) && o1.getName().equals("designation")) {
|
||||
String code1 = o1.getPart("language").hasValue() ? o1.getPart("language").getValue().primitiveValue().toLowerCase() : "";
|
||||
String code2 = o2.getPart("language").hasValue() ? o2.getPart("language").getValue().primitiveValue().toLowerCase() : "";
|
||||
if (code1 != null && code2 != null && !code1.equals(code2)) {
|
||||
return code1.compareTo(code2);
|
||||
}
|
||||
String v1 = o1.getPart("value") != null && o1.getPart("value").hasPrimitiveValue() ? o1.getPart("value").getValue().primitiveValue().toLowerCase() : null;
|
||||
String v2 = o2.getPart("value") != null && o2.getPart("value").hasPrimitiveValue() ? o2.getPart("value").getValue().primitiveValue().toLowerCase() : null;
|
||||
if (v1 != null && v2 != null && !v1.equals(v2)) {
|
||||
return v1.compareTo(v2);
|
||||
}
|
||||
}
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue