use of org.hl7.fhir.dstu2016may.model.ValueSet in project gpconnect-demonstrator by nhsconnect.
the class ValueSetValidator method findValueSet.
private ValueSet findValueSet(String systemUrl) {
int valueSetNamePos = systemUrl.lastIndexOf("/") + 1;
String valueSetFilename = String.format("%s.xml", systemUrl.substring(valueSetNamePos));
ValueSet valSet = null;
String xmlContent = null;
if (fhirValueSetsCheckWebFirst == true) {
xmlContent = readValueSetFromWeb(valueSetFilename);
}
if (xmlContent == null) {
xmlContent = readValueSetFromDisk(valueSetFilename);
}
if (fhirValueSetsCheckWebFirst == false && xmlContent == null) {
xmlContent = readValueSetFromWeb(valueSetFilename);
}
if (xmlContent != null) {
try {
FhirContext fhirCtx = FhirContext.forDstu3();
IParser parser = fhirCtx.newXmlParser();
valSet = parser.parseResource(ValueSet.class, xmlContent);
} catch (DataFormatException ex) {
LOG.error(String.format("Error parsing valueSetFilename: %s", valueSetFilename));
}
}
if (valSet == null) {
throw OperationOutcomeFactory.buildOperationOutcomeException(new UnprocessableEntityException(String.format("Could not find or parse Value Set [SystemUrl: %s] at: %s. See system log for details.", systemUrl, valueSetFilename)), SystemCode.REFERENCE_NOT_FOUND, IssueType.NOTFOUND);
}
return valSet;
}
use of org.hl7.fhir.dstu2016may.model.ValueSet in project gpconnect-demonstrator by nhsconnect.
the class ValueSetValidator method validateCode.
public Boolean validateCode(Coding code) {
String systemUrl = code.getSystem();
ValueSet valSet = loadValueSet(systemUrl);
// Check Code System
@SuppressWarnings("unused") ValueSetComposeComponent codeSys = valSet.getCompose();
@SuppressWarnings("unused") List<ValueSet.ConceptReferenceComponent> concepts;
return true;
}
use of org.hl7.fhir.dstu2016may.model.ValueSet in project gpconnect-demonstrator by nhsconnect.
the class ValueSetValidator method loadValueSet.
private ValueSet loadValueSet(String systemUrl) {
ValueSet set;
set = getValueSetFromCache(systemUrl);
if (set == null) {
set = findValueSet(systemUrl);
if (valueSetCache == null) {
valueSetCache = new HashMap<String, ValueSet>();
}
valueSetCache.put(systemUrl, set);
}
return set;
}
use of org.hl7.fhir.dstu2016may.model.ValueSet in project bunsen by cerner.
the class ValueSets method expandValuesIterator.
private static Iterator<Value> expandValuesIterator(ValueSet valueSet) {
List<Value> values = new ArrayList<>();
ValueSetComposeComponent compose = valueSet.getCompose();
for (ConceptSetComponent inclusion : compose.getInclude()) {
for (ConceptReferenceComponent concept : inclusion.getConcept()) {
Value value = new Value();
value.setValueSetUri(valueSet.getUrl());
value.setValueSetVersion(valueSet.getVersion());
value.setSystem(inclusion.getSystem());
value.setVersion(inclusion.getVersion());
value.setValue(concept.getCode());
values.add(value);
}
}
return values.iterator();
}
use of org.hl7.fhir.dstu2016may.model.ValueSet in project bunsen by cerner.
the class ValueSets method withValueSets.
private ValueSets withValueSets(Dataset<ValueSet> newValueSets, Dataset<Value> newValues) {
Dataset<UrlAndVersion> newMembers = getUrlAndVersions(newValueSets);
// Instantiating a new composite ConceptMaps requires a new timestamp
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
Dataset<ValueSet> newValueSetsWithTimestamp = newValueSets.withColumn("timestamp", lit(timestamp.toString()).cast("timestamp")).as(VALUE_SET_ENCODER);
return new ValueSets(spark, this.members.union(newMembers), this.valueSets.union(newValueSetsWithTimestamp), this.values.union(newValues));
}
Aggregations