use of org.hl7.fhir.dstu3.model.ValueSet in project bunsen by cerner.
the class ValueSetsTest method testWithValueSetsFromDirectoryXml.
@Test
public void testWithValueSetsFromDirectoryXml() {
ValueSets valueSets = ValueSets.getEmpty(spark).withValueSetsFromDirectory("src/test/resources/xml/valuesets");
ValueSet marriedValueSet = valueSets.getValueSet("urn:cerner:bunsen:valueset:married_maritalstatus", "0.0.1");
Assert.assertNotNull(marriedValueSet);
Assert.assertEquals("urn:cerner:bunsen:valueset:married_maritalstatus", marriedValueSet.getUrl());
Assert.assertEquals("0.0.1", marriedValueSet.getVersion());
}
use of org.hl7.fhir.dstu3.model.ValueSet in project bunsen by cerner.
the class ValueSetsTest method testExpandValues.
@Test
public void testExpandValues() {
ValueSet valueSet = ValueSets.getEmpty(spark).withValueSets(valueSet("urn:cerner:valueset:valueset", "1")).getValueSet("urn:cerner:valueset:valueset", "1");
List<Value> values = ValueSets.expandValues(valueSet);
Value expectedValue = new Value("urn:cerner:valueset:valueset", "1", "urn:cerner:system", "1", "a");
Assert.assertEquals(1, values.size());
Assert.assertEquals(expectedValue, values.get(0));
}
use of org.hl7.fhir.dstu3.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.dstu3.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.dstu3.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;
}
Aggregations