handle time outs doing vsac import (starlink obstructions)
This commit is contained in:
parent
46bdec9054
commit
5118c26ee4
|
@ -114,64 +114,86 @@ public class VSACImporter extends OIDBasedValueSetImporter {
|
||||||
private boolean processOid(String dest, boolean onlyNew, Map<String, String> errs, FHIRToolingClient fhirToolingClient, String oid)
|
private boolean processOid(String dest, boolean onlyNew, Map<String, String> errs, FHIRToolingClient fhirToolingClient, String oid)
|
||||||
throws IOException, InterruptedException, FileNotFoundException {
|
throws IOException, InterruptedException, FileNotFoundException {
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
boolean ok = true;
|
||||||
long t = System.currentTimeMillis();
|
long t = System.currentTimeMillis();
|
||||||
ValueSet vs = null;
|
ValueSet vs = null;
|
||||||
try {
|
try {
|
||||||
vs = fhirToolingClient.read(ValueSet.class, oid);
|
vs = fhirToolingClient.read(ValueSet.class, oid);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errs.put(oid, "Read: " +e.getMessage());
|
if (e.getMessage().contains("timed out")) {
|
||||||
System.out.println("Read "+oid+" failed @ "+Utilities.describeDuration(System.currentTimeMillis()-t)+"ms: "+e.getMessage());
|
ok = false;
|
||||||
return false;
|
} else {
|
||||||
|
errs.put(oid, "Read: " +e.getMessage());
|
||||||
|
System.out.println("Read "+oid+" failed @ "+Utilities.describeDuration(System.currentTimeMillis()-t)+"ms: "+e.getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
t = System.currentTimeMillis();
|
if (ok) {
|
||||||
try {
|
|
||||||
Parameters p = new Parameters();
|
|
||||||
p.addParameter("url", new UriType(vs.getUrl()));
|
|
||||||
ValueSet vse = fhirToolingClient.expandValueset(null, p);
|
|
||||||
vs.setExpansion(vse.getExpansion());
|
|
||||||
} catch (Exception e) {
|
|
||||||
errs.put(oid, "Expansion: " +e.getMessage());
|
|
||||||
System.out.println("Expand "+oid+" failed @ "+Utilities.describeDuration(System.currentTimeMillis()-t)+"ms: "+e.getMessage());
|
|
||||||
}
|
|
||||||
while (isIncomplete(vs.getExpansion())) {
|
|
||||||
Parameters p = new Parameters();
|
|
||||||
int offset = vs.getExpansion().getParameter("offset").getValueIntegerType().getValue() + vs.getExpansion().getParameter("count").getValueIntegerType().getValue();
|
|
||||||
p.addParameter("offset", offset);
|
|
||||||
p.addParameter("url", new UriType(vs.getUrl()));
|
|
||||||
t = System.currentTimeMillis();
|
t = System.currentTimeMillis();
|
||||||
try {
|
try {
|
||||||
ValueSet vse = fhirToolingClient.expandValueset(null, p);
|
Parameters p = new Parameters();
|
||||||
vs.getExpansion().getContains().addAll(vse.getExpansion().getContains());
|
p.addParameter("url", new UriType(vs.getUrl()));
|
||||||
vs.getExpansion().setParameter(vse.getExpansion().getParameter());
|
ValueSet vse = fhirToolingClient.expandValueset(null, p);
|
||||||
} catch (Exception e2) {
|
vs.setExpansion(vse.getExpansion());
|
||||||
errs.put(oid, "Expansion: " +e2.getMessage()+" @ "+offset);
|
} catch (Exception e) {
|
||||||
System.out.println("Expand "+oid+" @ "+offset+" failed @ "+Utilities.describeDuration(System.currentTimeMillis()-t)+"ms: "+e2.getMessage());
|
if (e.getMessage().contains("timed out")) {
|
||||||
}
|
ok = false;
|
||||||
}
|
} else {
|
||||||
vs.getExpansion().setOffsetElement(null);
|
errs.put(oid, "Expansion: " +e.getMessage());
|
||||||
vs.getExpansion().getParameter().clear();
|
System.out.println("Expand "+oid+" failed @ "+Utilities.describeDuration(System.currentTimeMillis()-t)+"ms: "+e.getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (vs.hasTitle()) {
|
|
||||||
if (vs.getTitle().equals(vs.getDescription())) {
|
|
||||||
vs.setTitle(vs.getName());
|
|
||||||
} else {
|
|
||||||
// System.out.println(oid);
|
|
||||||
// System.out.println(" name: "+vs.getName());
|
|
||||||
// System.out.println(" title: "+vs.getTitle());
|
|
||||||
// System.out.println(" desc: "+vs.getDescription());
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
vs.setTitle(vs.getName());
|
|
||||||
}
|
}
|
||||||
if (vs.getUrl().startsWith("https://")) {
|
if (ok) {
|
||||||
System.out.println("URL is https: "+vs.getUrl());
|
while (isIncomplete(vs.getExpansion())) {
|
||||||
|
Parameters p = new Parameters();
|
||||||
|
int offset = vs.getExpansion().getParameter("offset").getValueIntegerType().getValue() + vs.getExpansion().getParameter("count").getValueIntegerType().getValue();
|
||||||
|
p.addParameter("offset", offset);
|
||||||
|
p.addParameter("url", new UriType(vs.getUrl()));
|
||||||
|
t = System.currentTimeMillis();
|
||||||
|
try {
|
||||||
|
ValueSet vse = fhirToolingClient.expandValueset(null, p);
|
||||||
|
vs.getExpansion().getContains().addAll(vse.getExpansion().getContains());
|
||||||
|
vs.getExpansion().setParameter(vse.getExpansion().getParameter());
|
||||||
|
} catch (Exception e2) {
|
||||||
|
if (e2.getMessage().contains("timed out")) {
|
||||||
|
ok = false;
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
errs.put(oid, "Expansion: " +e2.getMessage()+" @ "+offset);
|
||||||
|
System.out.println("Expand "+oid+" @ "+offset+" failed @ "+Utilities.describeDuration(System.currentTimeMillis()-t)+"ms: "+e2.getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
vs.setName(makeValidName(vs.getName()));
|
if (ok) {
|
||||||
JurisdictionUtilities.setJurisdictionCountry(vs.getJurisdiction(), "US");
|
vs.getExpansion().setOffsetElement(null);
|
||||||
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(Utilities.path(dest, "ValueSet-" + oid + ".json")), vs);
|
vs.getExpansion().getParameter().clear();
|
||||||
|
|
||||||
return true;
|
if (vs.hasTitle()) {
|
||||||
|
if (vs.getTitle().equals(vs.getDescription())) {
|
||||||
|
vs.setTitle(vs.getName());
|
||||||
|
} else {
|
||||||
|
// System.out.println(oid);
|
||||||
|
// System.out.println(" name: "+vs.getName());
|
||||||
|
// System.out.println(" title: "+vs.getTitle());
|
||||||
|
// System.out.println(" desc: "+vs.getDescription());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
vs.setTitle(vs.getName());
|
||||||
|
}
|
||||||
|
if (vs.getUrl().startsWith("https://")) {
|
||||||
|
System.out.println("URL is https: "+vs.getUrl());
|
||||||
|
}
|
||||||
|
vs.setName(makeValidName(vs.getName()));
|
||||||
|
JurisdictionUtilities.setJurisdictionCountry(vs.getJurisdiction(), "US");
|
||||||
|
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(Utilities.path(dest, "ValueSet-" + oid + ".json")), vs);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isIncomplete(ValueSetExpansionComponent expansion) {
|
private boolean isIncomplete(ValueSetExpansionComponent expansion) {
|
||||||
|
|
Loading…
Reference in New Issue