Significant speed improvement for terminology cache
This commit is contained in:
parent
42f75dfee0
commit
bd9d486846
|
@ -133,13 +133,23 @@ public class TerminologyCache {
|
||||||
ct.name = getNameForSystem(code.getSystem());
|
ct.name = getNameForSystem(code.getSystem());
|
||||||
else
|
else
|
||||||
ct.name = NAME_FOR_NO_SYSTEM;
|
ct.name = NAME_FOR_NO_SYSTEM;
|
||||||
|
nameCacheToken(vs, ct);
|
||||||
JsonParser json = new JsonParser();
|
JsonParser json = new JsonParser();
|
||||||
json.setOutputStyle(OutputStyle.PRETTY);
|
json.setOutputStyle(OutputStyle.PRETTY);
|
||||||
ValueSet vsc = getVSEssense(vs);
|
if (vs != null && vs.hasUrl() && vs.hasVersion()) {
|
||||||
try {
|
try {
|
||||||
ct.request = "{\"code\" : "+json.composeString(code, "code")+", \"valueSet\" :"+(vsc == null ? "null" : extracted(json, vsc))+(options == null ? "" : ", "+options.toJson())+"}";
|
ct.request = "{\"code\" : "+json.composeString(code, "codeableConcept")+", \"url\": \""+Utilities.escapeJson(vs.getUrl())
|
||||||
} catch (IOException e) {
|
+"\", \"version\": \""+Utilities.escapeJson(vs.getVersion())+"\""+(options == null ? "" : ", "+options.toJson())+"}\r\n";
|
||||||
throw new Error(e);
|
} catch (IOException e) {
|
||||||
|
throw new Error(e);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ValueSet vsc = getVSEssense(vs);
|
||||||
|
try {
|
||||||
|
ct.request = "{\"code\" : "+json.composeString(code, "code")+", \"valueSet\" :"+(vsc == null ? "null" : extracted(json, vsc))+(options == null ? "" : ", "+options.toJson())+"}";
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new Error(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ct.key = String.valueOf(hashNWS(ct.request));
|
ct.key = String.valueOf(hashNWS(ct.request));
|
||||||
return ct;
|
return ct;
|
||||||
|
@ -161,13 +171,23 @@ public class TerminologyCache {
|
||||||
if (c.hasSystem())
|
if (c.hasSystem())
|
||||||
ct.setName(getNameForSystem(c.getSystem()));
|
ct.setName(getNameForSystem(c.getSystem()));
|
||||||
}
|
}
|
||||||
|
nameCacheToken(vs, ct);
|
||||||
JsonParser json = new JsonParser();
|
JsonParser json = new JsonParser();
|
||||||
json.setOutputStyle(OutputStyle.PRETTY);
|
json.setOutputStyle(OutputStyle.PRETTY);
|
||||||
ValueSet vsc = getVSEssense(vs);
|
if (vs != null && vs.hasUrl() && vs.hasVersion()) {
|
||||||
try {
|
try {
|
||||||
ct.request = "{\"code\" : "+json.composeString(code, "codeableConcept")+", \"valueSet\" :"+extracted(json, vsc)+(options == null ? "" : ", "+options.toJson())+"}";
|
ct.request = "{\"code\" : "+json.composeString(code, "codeableConcept")+", \"url\": \""+Utilities.escapeJson(vs.getUrl())+
|
||||||
} catch (IOException e) {
|
"\", \"version\": \""+Utilities.escapeJson(vs.getVersion())+"\""+(options == null ? "" : ", "+options.toJson())+"+}\r\n";
|
||||||
throw new Error(e);
|
} catch (IOException e) {
|
||||||
|
throw new Error(e);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ValueSet vsc = getVSEssense(vs);
|
||||||
|
try {
|
||||||
|
ct.request = "{\"code\" : "+json.composeString(code, "codeableConcept")+", \"valueSet\" :"+extracted(json, vsc)+(options == null ? "" : ", "+options.toJson())+"}";
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new Error(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ct.key = String.valueOf(hashNWS(ct.request));
|
ct.key = String.valueOf(hashNWS(ct.request));
|
||||||
return ct;
|
return ct;
|
||||||
|
@ -187,27 +207,37 @@ public class TerminologyCache {
|
||||||
|
|
||||||
public CacheToken generateExpandToken(ValueSet vs, boolean heirarchical) {
|
public CacheToken generateExpandToken(ValueSet vs, boolean heirarchical) {
|
||||||
CacheToken ct = new CacheToken();
|
CacheToken ct = new CacheToken();
|
||||||
ValueSet vsc = getVSEssense(vs);
|
nameCacheToken(vs, ct);
|
||||||
for (ConceptSetComponent inc : vs.getCompose().getInclude())
|
if (vs.hasUrl() && vs.hasVersion()) {
|
||||||
if (inc.hasSystem())
|
ct.request = "{\"hierarchical\" : "+(heirarchical ? "true" : "false")+", \"url\": \""+Utilities.escapeJson(vs.getUrl())+"\", \"version\": \""+Utilities.escapeJson(vs.getVersion())+"\"}\r\n";
|
||||||
ct.setName(getNameForSystem(inc.getSystem()));
|
} else {
|
||||||
for (ConceptSetComponent inc : vs.getCompose().getExclude())
|
ValueSet vsc = getVSEssense(vs);
|
||||||
if (inc.hasSystem())
|
JsonParser json = new JsonParser();
|
||||||
ct.setName(getNameForSystem(inc.getSystem()));
|
json.setOutputStyle(OutputStyle.PRETTY);
|
||||||
for (ValueSetExpansionContainsComponent inc : vs.getExpansion().getContains())
|
try {
|
||||||
if (inc.hasSystem())
|
ct.request = "{\"hierarchical\" : "+(heirarchical ? "true" : "false")+", \"valueSet\" :"+extracted(json, vsc)+"}\r\n";
|
||||||
ct.setName(getNameForSystem(inc.getSystem()));
|
} catch (IOException e) {
|
||||||
JsonParser json = new JsonParser();
|
throw new Error(e);
|
||||||
json.setOutputStyle(OutputStyle.PRETTY);
|
}
|
||||||
try {
|
|
||||||
ct.request = "{\"hierarchical\" : "+(heirarchical ? "true" : "false")+", \"valueSet\" :"+extracted(json, vsc)+"}\r\n";
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new Error(e);
|
|
||||||
}
|
}
|
||||||
ct.key = String.valueOf(hashNWS(ct.request));
|
ct.key = String.valueOf(hashNWS(ct.request));
|
||||||
return ct;
|
return ct;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void nameCacheToken(ValueSet vs, CacheToken ct) {
|
||||||
|
if (vs != null) {
|
||||||
|
for (ConceptSetComponent inc : vs.getCompose().getInclude())
|
||||||
|
if (inc.hasSystem())
|
||||||
|
ct.setName(getNameForSystem(inc.getSystem()));
|
||||||
|
for (ConceptSetComponent inc : vs.getCompose().getExclude())
|
||||||
|
if (inc.hasSystem())
|
||||||
|
ct.setName(getNameForSystem(inc.getSystem()));
|
||||||
|
for (ValueSetExpansionContainsComponent inc : vs.getExpansion().getContains())
|
||||||
|
if (inc.hasSystem())
|
||||||
|
ct.setName(getNameForSystem(inc.getSystem()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private String getNameForSystem(String system) {
|
private String getNameForSystem(String system) {
|
||||||
if (system.equals("http://snomed.info/sct"))
|
if (system.equals("http://snomed.info/sct"))
|
||||||
return "snomed";
|
return "snomed";
|
||||||
|
|
Loading…
Reference in New Issue