fix up VSAC import for large value sets
This commit is contained in:
parent
ecd62b6feb
commit
b898cfe59f
|
@ -13,10 +13,13 @@ import org.hl7.fhir.exceptions.FHIRException;
|
|||
import org.hl7.fhir.r4.formats.IParser.OutputStyle;
|
||||
import org.hl7.fhir.r4.formats.JsonParser;
|
||||
import org.hl7.fhir.r4.model.CapabilityStatement;
|
||||
import org.hl7.fhir.r4.model.IntegerType;
|
||||
import org.hl7.fhir.r4.model.OperationOutcome;
|
||||
import org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity;
|
||||
import org.hl7.fhir.r4.model.OperationOutcome.IssueType;
|
||||
import org.hl7.fhir.r4.model.Parameters;
|
||||
import org.hl7.fhir.r4.model.ValueSet;
|
||||
import org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionComponent;
|
||||
import org.hl7.fhir.r4.utils.client.FHIRToolingClient;
|
||||
import org.hl7.fhir.r4.terminologies.JurisdictionUtilities;
|
||||
import org.hl7.fhir.utilities.CSVReader;
|
||||
|
@ -63,6 +66,16 @@ public class VSACImporter extends OIDBasedValueSetImporter {
|
|||
errs.put(oid, "Expansion: " +e.getMessage());
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
while (isIncomplete(vs.getExpansion())) {
|
||||
Parameters p = new Parameters();
|
||||
p.addParameter("offset", vs.getExpansion().getParameter("offset").getValueIntegerType().getValue() + vs.getExpansion().getParameter("count").getValueIntegerType().getValue());
|
||||
ValueSet vse = fhirToolingClient.expandValueset(vs.getUrl(), p);
|
||||
vs.getExpansion().getContains().addAll(vse.getExpansion().getContains());
|
||||
vs.getExpansion().setParameter(vse.getExpansion().getParameter());
|
||||
}
|
||||
vs.getExpansion().setOffsetElement(null);
|
||||
vs.getExpansion().getParameter().clear();
|
||||
|
||||
|
||||
if (vs.hasTitle()) {
|
||||
if (vs.getTitle().equals(vs.getDescription())) {
|
||||
|
@ -97,6 +110,12 @@ public class VSACImporter extends OIDBasedValueSetImporter {
|
|||
System.out.println("Done. " + i + " ValueSets");
|
||||
}
|
||||
|
||||
private boolean isIncomplete(ValueSetExpansionComponent expansion) {
|
||||
IntegerType c = expansion.getParameter("count").getValueIntegerType();
|
||||
IntegerType offset = expansion.getParameter("offset").getValueIntegerType();
|
||||
return c.getValue() + offset.getValue() < expansion.getTotal();
|
||||
}
|
||||
|
||||
private String makeValidName(String name) {
|
||||
StringBuilder b = new StringBuilder();
|
||||
boolean upper = true;
|
||||
|
|
|
@ -885,6 +885,13 @@ public class Parameters extends Resource implements IBaseParameters {
|
|||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Parameters addParameter(String name, int i) {
|
||||
addParameter().setName(name).setValue(new IntegerType(i));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Parameters addParameter(String name, String s) {
|
||||
if (s != null)
|
||||
addParameter().setName(name).setValue(new StringType(s));
|
||||
|
|
|
@ -3268,6 +3268,14 @@ public class ValueSet extends MetadataResource {
|
|||
|
||||
}
|
||||
|
||||
public ValueSetExpansionParameterComponent getParameter(String name) {
|
||||
for (ValueSetExpansionParameterComponent t : getParameter()) {
|
||||
if (name.equals(t.getName())) {
|
||||
return t;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Block()
|
||||
|
@ -6241,6 +6249,8 @@ public class ValueSet extends MetadataResource {
|
|||
return ResourceType.ValueSet;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Search parameter: <b>date</b>
|
||||
* <p>
|
||||
|
|
|
@ -383,6 +383,17 @@ public class FHIRToolingClient {
|
|||
public ValueSet expandValueset(String vsUrl, Parameters expParams) {
|
||||
Map<String, String> parameters = new HashMap<>();
|
||||
parameters.put("url", vsUrl);
|
||||
if (expParams != null) {
|
||||
for (ParametersParameterComponent p : expParams.getParameter()) {
|
||||
if (p.getValue() == null) {
|
||||
throw new FHIRException("Non-value Parameters are not supported for parameter '"+p.getName()+"'");
|
||||
} else if (p.getValue() instanceof PrimitiveType) {
|
||||
parameters.put(p.getName(), p.getValue().primitiveValue());
|
||||
} else {
|
||||
throw new FHIRException("Complex Parameters are not supported for parameter '"+p.getName()+"'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
org.hl7.fhir.r4.utils.client.network.ResourceRequest<Resource> result = null;
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue