fix up vsac importer for changes to client

This commit is contained in:
Grahame Grieve 2024-04-20 23:33:48 +10:00
parent 81cb12d0ed
commit dd3981c090
1 changed files with 8 additions and 4 deletions

View File

@ -92,6 +92,7 @@ public class VSACImporter extends OIDBasedValueSetImporter {
t = System.currentTimeMillis(); t = System.currentTimeMillis();
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
System.out.println("Unable to fetch OID " + oid + ": " + e.getMessage()); System.out.println("Unable to fetch OID " + oid + ": " + e.getMessage());
errs.put(oid, e.getMessage()); errs.put(oid, e.getMessage());
} }
@ -126,7 +127,7 @@ public class VSACImporter extends OIDBasedValueSetImporter {
try { try {
Parameters p = new Parameters(); Parameters p = new Parameters();
p.addParameter("url", new UriType(vs.getUrl())); p.addParameter("url", new UriType(vs.getUrl()));
ValueSet vse = fhirToolingClient.expandValueset(vs, p); ValueSet vse = fhirToolingClient.expandValueset(null, p);
vs.setExpansion(vse.getExpansion()); vs.setExpansion(vse.getExpansion());
} catch (Exception e) { } catch (Exception e) {
errs.put(oid, "Expansion: " +e.getMessage()); errs.put(oid, "Expansion: " +e.getMessage());
@ -139,7 +140,7 @@ public class VSACImporter extends OIDBasedValueSetImporter {
p.addParameter("url", new UriType(vs.getUrl())); p.addParameter("url", new UriType(vs.getUrl()));
t = System.currentTimeMillis(); t = System.currentTimeMillis();
try { try {
ValueSet vse = fhirToolingClient.expandValueset(vs, p); ValueSet vse = fhirToolingClient.expandValueset(null, p);
vs.getExpansion().getContains().addAll(vse.getExpansion().getContains()); vs.getExpansion().getContains().addAll(vse.getExpansion().getContains());
vs.getExpansion().setParameter(vse.getExpansion().getParameter()); vs.getExpansion().setParameter(vse.getExpansion().getParameter());
} catch (Exception e2) { } catch (Exception e2) {
@ -163,6 +164,9 @@ public class VSACImporter extends OIDBasedValueSetImporter {
} else { } else {
vs.setTitle(vs.getName()); vs.setTitle(vs.getName());
} }
if (vs.getUrl().startsWith("https://")) {
System.out.println("URL is https: "+vs.getUrl());
}
vs.setName(makeValidName(vs.getName())); vs.setName(makeValidName(vs.getName()));
JurisdictionUtilities.setJurisdictionCountry(vs.getJurisdiction(), "US"); JurisdictionUtilities.setJurisdictionCountry(vs.getJurisdiction(), "US");
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(Utilities.path(dest, "ValueSet-" + oid + ".json")), vs); new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(Utilities.path(dest, "ValueSet-" + oid + ".json")), vs);
@ -171,8 +175,8 @@ public class VSACImporter extends OIDBasedValueSetImporter {
} }
private boolean isIncomplete(ValueSetExpansionComponent expansion) { private boolean isIncomplete(ValueSetExpansionComponent expansion) {
IntegerType c = expansion.getParameter("count").getValueIntegerType(); IntegerType c = expansion.getParameter("count") != null ? expansion.getParameter("count").getValueIntegerType() : new IntegerType(0);
IntegerType offset = expansion.getParameter("offset").getValueIntegerType(); IntegerType offset = expansion.getParameter("offset") != null ? expansion.getParameter("offset").getValueIntegerType() : new IntegerType(0);
return c.getValue() + offset.getValue() < expansion.getTotal(); return c.getValue() + offset.getValue() < expansion.getTotal();
} }