use of org.hl7.fhir.dstu2016may.model.ValueSet in project org.hl7.fhir.core by hapifhir.
the class SpecDifferenceEvaluator method compareBindings.
private boolean compareBindings(JsonObject element, ElementDefinitionBindingComponent rev, ElementDefinitionBindingComponent orig) {
boolean res = false;
if (rev.getStrength() != orig.getStrength()) {
element.addProperty("binding-strength-changed", true);
res = true;
}
if (!Base.compareDeep(rev.getValueSet(), orig.getValueSet(), false)) {
element.addProperty("binding-valueset-changed", true);
res = true;
}
if (!maxValueSetsMatch(rev, orig)) {
element.addProperty("max-valueset-changed", true);
res = true;
}
if (rev.getStrength() == BindingStrength.REQUIRED && orig.getStrength() == BindingStrength.REQUIRED) {
JsonArray oa = new JsonArray();
JsonArray ra = new JsonArray();
ValueSet vrev = getValueSet(rev.getValueSet(), revision.getExpansions());
ValueSet vorig = getValueSet(rev.getValueSet(), original.getExpansions());
if (vrev != null && vorig != null) {
for (ValueSetExpansionContainsComponent cc : vorig.getExpansion().getContains()) {
if (!hasCode(vrev, cc))
oa.add(new JsonPrimitive(cc.getCode()));
}
for (ValueSetExpansionContainsComponent cc : vrev.getExpansion().getContains()) {
if (!hasCode(vorig, cc))
ra.add(new JsonPrimitive(cc.getCode()));
}
}
if (oa.size() > 0 || ra.size() > 0) {
element.addProperty("binding-codes-changed", true);
res = true;
}
if (oa.size() > 0)
element.add("removed-codes", oa);
if (ra.size() > 0)
element.add("added-codes", ra);
}
return res;
}
use of org.hl7.fhir.dstu2016may.model.ValueSet in project org.hl7.fhir.core by hapifhir.
the class PackageMaintainer method check.
private void check(String ver) throws IOException {
System.out.println("Check " + ver);
List<String> allIds = listResources(Utilities.path(PATH, "hl7.fhir." + ver + ".examples", "package"));
List<String> coreIds = listResources(Utilities.path(PATH, "hl7.fhir." + ver + ".core", "package"));
for (String s : coreIds) {
if (!allIds.contains(s)) {
System.out.println("Core contains " + s + " but allIds doesn't");
}
}
for (String s : allIds) {
if (!coreIds.contains(s)) {
String c = s.substring(0, s.indexOf("-"));
if (Utilities.existsInList(c, "CodeSystem", "ValueSet", "ConceptMap", "StructureDefinition", "StructureMap", "NamingSystem", "SearchParameter", "OperationDefinition", "CapabilityStatement", "Conformance"))
System.out.println("Examples contains " + s + " but core doesn't");
}
}
strip(new File(Utilities.path(PATH, "hl7.fhir." + ver + ".core", "package")));
strip(new File(Utilities.path(PATH, "hl7.fhir." + ver + ".expansions", "package")));
if (!ver.equals("r2b"))
strip(new File(Utilities.path(PATH, "hl7.fhir." + ver + ".elements", "package")));
}
use of org.hl7.fhir.dstu2016may.model.ValueSet in project org.hl7.fhir.core by hapifhir.
the class PhinVadsImporter method process.
private void process(String source, String dest) {
for (File f : new File(source).listFiles()) {
try {
System.out.println("Process " + f.getName());
ValueSet vs = importValueSet(TextFile.fileToBytes(f));
if (vs.getId() != null) {
new JsonParser().compose(new FileOutputStream(Utilities.path(dest, "ValueSet-" + vs.getId() + ".json")), vs);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
use of org.hl7.fhir.dstu2016may.model.ValueSet in project org.hl7.fhir.core by hapifhir.
the class PhinVadsImporter method importValueSet.
private ValueSet importValueSet(byte[] source) throws FHIRException, IOException, ParseException {
// first thing do is split into 2
List<byte[]> parts = Utilities.splitBytes(source, "\r\n\r\n".getBytes());
if (parts.size() < 2) {
TextFile.bytesToFile(source, Utilities.path("[tmp]", "phinvads.txt"));
throw new FHIRException("Unable to parse phinvads value set: " + parts.size() + " parts found");
}
CSVReader rdr = new CSVReader(new ByteArrayInputStream(parts.get(0)));
rdr.setDelimiter('\t');
rdr.setMultiline(true);
rdr.readHeaders();
rdr.line();
ValueSet vs = new ValueSet();
vs.setId(rdr.cell("Value Set OID"));
vs.setUrl("http://phinvads.cdc.gov/fhir/ValueSet/" + vs.getId());
vs.getMeta().setSource("https://phinvads.cdc.gov/vads/ViewValueSet.action?oid=" + vs.getId());
vs.setVersion(rdr.cell("Value Set Version"));
vs.setTitle(rdr.cell("Value Set Name"));
vs.setName(rdr.cell("Value Set Code"));
vs.setDescription(rdr.cell("Value Set Definition"));
if ("Published".equals(rdr.cell("Value Set Status"))) {
vs.setStatus(PublicationStatus.ACTIVE);
} else {
vs.setStatus(PublicationStatus.DRAFT);
}
if (rdr.has("VS Last Updated Date")) {
vs.setDate(new SimpleDateFormat("mm/dd/yyyy").parse(rdr.cell("VS Last Updated Date")));
}
rdr = new CSVReader(new ByteArrayInputStream(parts.get(parts.size() - 1)));
rdr.setMultiline(true);
rdr.setDelimiter('\t');
rdr.readHeaders();
while (rdr.line()) {
String code = rdr.cell("Concept Code");
String display = rdr.cell("Preferred Concept Name");
String csoid = rdr.cell("Code System OID");
String csver = rdr.cell("Code System Version");
String url = context.oid2Uri(csoid);
if (url == null) {
url = "urn:oid:" + csoid;
}
csver = fixVersionforSystem(url, csver);
ConceptSetComponent inc = getInclude(vs, url, csver);
inc.addConcept().setCode(code).setDisplay(display);
}
return vs;
}
use of org.hl7.fhir.dstu2016may.model.ValueSet in project org.hl7.fhir.core by hapifhir.
the class VSACImporter method process.
private void process(String source, String dest, String username, String password) throws FHIRException, IOException, URISyntaxException {
CSVReader csv = new CSVReader(new FileInputStream(source));
csv.readHeaders();
FHIRToolingClient fhirToolingClient = new FHIRToolingClient("https://cts.nlm.nih.gov/fhir", "fhir/vsac");
fhirToolingClient.setUsername(username);
fhirToolingClient.setPassword(password);
int i = 0;
while (csv.line()) {
String oid = csv.cell("OID");
try {
ValueSet vs = fhirToolingClient.read(ValueSet.class, oid);
new JsonParser().compose(new FileOutputStream(Utilities.path(dest, "ValueSet-" + oid + ".json")), vs);
i++;
if (i % 100 == 0) {
System.out.println(i);
}
} catch (Exception e) {
System.out.println("Unable to fetch OID " + oid + ": " + e.getMessage());
}
}
System.out.println("Done. " + i + " ValueSets");
}
Aggregations