Search in sources :

Example 11 with ValueSet

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());
}
Also used : ValueSet(org.hl7.fhir.dstu3.model.ValueSet) Test(org.junit.Test)

Example 12 with ValueSet

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));
}
Also used : ValueSet(org.hl7.fhir.dstu3.model.ValueSet) Test(org.junit.Test)

Example 13 with ValueSet

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;
}
Also used : UnprocessableEntityException(ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException) FhirContext(ca.uhn.fhir.context.FhirContext) DataFormatException(ca.uhn.fhir.parser.DataFormatException) ValueSet(org.hl7.fhir.dstu3.model.ValueSet) IParser(ca.uhn.fhir.parser.IParser)

Example 14 with ValueSet

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;
}
Also used : ValueSet(org.hl7.fhir.dstu3.model.ValueSet) ValueSetComposeComponent(org.hl7.fhir.dstu3.model.ValueSet.ValueSetComposeComponent)

Example 15 with ValueSet

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;
}
Also used : ValueSet(org.hl7.fhir.dstu3.model.ValueSet)

Aggregations

ValueSet (org.hl7.fhir.dstu3.model.ValueSet)13 Test (org.junit.Test)7 ConceptSetComponent (org.hl7.fhir.dstu3.model.ValueSet.ConceptSetComponent)4 ValueSetComposeComponent (org.hl7.fhir.dstu3.model.ValueSet.ValueSetComposeComponent)3 ConceptReferenceComponent (org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceComponent)2 FhirContext (ca.uhn.fhir.context.FhirContext)1 DataFormatException (ca.uhn.fhir.parser.DataFormatException)1 IParser (ca.uhn.fhir.parser.IParser)1 UnprocessableEntityException (ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException)1 Timestamp (java.sql.Timestamp)1 ArrayList (java.util.ArrayList)1