work on oid to URI conversion - scope and efficiency
This commit is contained in:
parent
86b9db4aec
commit
0287248a48
|
@ -62,6 +62,7 @@ import org.hl7.fhir.r5.model.CapabilityStatement;
|
|||
import org.hl7.fhir.r5.model.CodeSystem;
|
||||
import org.hl7.fhir.r5.model.CodeSystem.CodeSystemContentMode;
|
||||
import org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent;
|
||||
import org.hl7.fhir.r5.model.CodeSystem.ConceptPropertyComponent;
|
||||
import org.hl7.fhir.r5.model.CodeableConcept;
|
||||
import org.hl7.fhir.r5.model.Coding;
|
||||
import org.hl7.fhir.r5.model.ConceptMap;
|
||||
|
@ -69,6 +70,7 @@ import org.hl7.fhir.r5.model.Constants;
|
|||
import org.hl7.fhir.r5.model.ElementDefinition;
|
||||
import org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent;
|
||||
import org.hl7.fhir.r5.model.Enumerations.PublicationStatus;
|
||||
import org.hl7.fhir.r5.model.Identifier;
|
||||
import org.hl7.fhir.r5.model.ImplementationGuide;
|
||||
import org.hl7.fhir.r5.model.Library;
|
||||
import org.hl7.fhir.r5.model.Measure;
|
||||
|
@ -181,6 +183,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
|||
|
||||
private UcumService ucumService;
|
||||
protected Map<String, byte[]> binaries = new HashMap<String, byte[]>();
|
||||
protected Map<String, String> oidCache = new HashMap<>();
|
||||
|
||||
protected Map<String, Map<String, ValidationResult>> validationCache = new HashMap<String, Map<String,ValidationResult>>();
|
||||
protected String tsServer;
|
||||
|
@ -336,6 +339,10 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
|||
}
|
||||
map.put(r.getId(), r);
|
||||
|
||||
if (r instanceof CodeSystem || r instanceof NamingSystem) {
|
||||
oidCache.clear();
|
||||
}
|
||||
|
||||
if (r instanceof CanonicalResource) {
|
||||
CanonicalResource m = (CanonicalResource) r;
|
||||
String url = m.getUrl();
|
||||
|
@ -1633,20 +1640,53 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
|||
if (oid != null && oid.startsWith("urn:oid:")) {
|
||||
oid = oid.substring(8);
|
||||
}
|
||||
if (oidCache.containsKey(oid)) {
|
||||
return oidCache.get(oid);
|
||||
}
|
||||
|
||||
String uri = OIDUtils.getUriForOid(oid);
|
||||
if (uri != null) {
|
||||
oidCache.put(oid, uri);
|
||||
return uri;
|
||||
}
|
||||
CodeSystem cs = fetchCodeSystem("http://terminology.hl7.org/CodeSystem/v2-tables");
|
||||
if (cs != null) {
|
||||
for (ConceptDefinitionComponent cc : cs.getConcept()) {
|
||||
for (ConceptPropertyComponent cp : cc.getProperty()) {
|
||||
if (Utilities.existsInList(cp.getCode(), "v2-table-oid", "v2-cs-oid") && oid.equals(cp.getValue().primitiveValue())) {
|
||||
for (ConceptPropertyComponent cp2 : cc.getProperty()) {
|
||||
if ("v2-cs-uri".equals(cp2.getCode())) {
|
||||
oidCache.put(oid, cp2.getValue().primitiveValue());
|
||||
return cp2.getValue().primitiveValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (CodeSystem css : codeSystems.getList()) {
|
||||
if (("urn:oid:"+oid).equals(css.getUrl())) {
|
||||
oidCache.put(oid, css.getUrl());
|
||||
return css.getUrl();
|
||||
}
|
||||
for (Identifier id : css.getIdentifier()) {
|
||||
if ("urn:ietf:rfc:3986".equals(id.getSystem()) && ("urn:oid:"+oid).equals(id.getValue())) {
|
||||
oidCache.put(oid, css.getUrl());
|
||||
return css.getUrl();
|
||||
}
|
||||
}
|
||||
}
|
||||
for (NamingSystem ns : systems.getList()) {
|
||||
if (hasOid(ns, oid)) {
|
||||
uri = getUri(ns);
|
||||
if (uri != null) {
|
||||
oidCache.put(oid, null);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
oidCache.put(oid, null);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -67,19 +67,6 @@ public class OIDUtils {
|
|||
if (r.equals("2.16.840.1.113883.6.88"))
|
||||
return "http://www.nlm.nih.gov/research/umls/rxnorm"; // todo: confirm this
|
||||
|
||||
if (r.equals("2.16.840.1.113883.5.1008"))
|
||||
return "http://terminology.hl7.org/v3/NullFlavor";
|
||||
if (r.equals("2.16.840.1.113883.5.111"))
|
||||
return "http://terminology.hl7.org/v3/RoleCode";
|
||||
if (r.equals("2.16.840.1.113883.5.4"))
|
||||
return "http://terminology.hl7.org/v3/ActCode";
|
||||
if (r.equals("2.16.840.1.113883.5.8"))
|
||||
return "http://terminology.hl7.org/v3/ActReason";
|
||||
if (r.equals("2.16.840.1.113883.5.83"))
|
||||
return "http://terminology.hl7.org/v3/ObservationInterpretation";
|
||||
if (r.equals("2.16.840.1.113883.6.238"))
|
||||
return "http://terminology.hl7.org/v3/Race";
|
||||
|
||||
if (r.equals("2.16.840.1.113883.6.59"))
|
||||
return "http://hl7.org/fhir/sid/cvx";
|
||||
if (r.equals("2.16.840.1.113883.12.292"))
|
||||
|
@ -88,8 +75,6 @@ public class OIDUtils {
|
|||
if (r.equals("2.16.840.1.113883.6.12"))
|
||||
return "http://www.ama-assn.org/go/cpt";
|
||||
|
||||
if (r.startsWith("2.16.840.1.113883.12."))
|
||||
return "http://hl7.org/fhir/sid/v2-"+r.substring(21);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -397,6 +397,8 @@ public class I18nConstants {
|
|||
public static final String TERMINOLOGY_TX_SYSTEM_NO_CODE = "TERMINOLOGY_TX_SYSTEM_NO_CODE";
|
||||
public static final String TERMINOLOGY_TX_SYSTEM_RELATIVE = "Terminology_TX_System_Relative";
|
||||
public static final String TERMINOLOGY_TX_SYSTEM_UNKNOWN = "Terminology_TX_System_Unknown";
|
||||
public static final String TERMINOLOGY_TX_SYSTEM_WRONG_BUILD = "TERMINOLOGY_TX_SYSTEM_WRONG_BUILD";
|
||||
public static final String TERMINOLOGY_TX_SYSTEM_WRONG_HTML = "TERMINOLOGY_TX_SYSTEM_WRONG_HTML";
|
||||
public static final String TERMINOLOGY_TX_SYSTEM_VALUESET = "Terminology_TX_System_ValueSet";
|
||||
public static final String TERMINOLOGY_TX_SYSTEM_VALUESET2 = "Terminology_TX_System_ValueSet2";
|
||||
public static final String TERMINOLOGY_TX_VALUESET_NOTFOUND = "Terminology_TX_ValueSet_NotFound";
|
||||
|
|
Loading…
Reference in New Issue