Search in sources :

Example 76 with ValueSet

use of org.hl7.fhir.r4.model.ValueSet in project quality-measure-and-cohort-service by Alvearie.

the class ValueSetUtilTest method testUnsuppliedCodes.

@Test
public void testUnsuppliedCodes() {
    thrown.expect(IllegalArgumentException.class);
    thrown.expectMessage("Value set must include codes but no codes were included.");
    ValueSetArtifact artifact = new ValueSetArtifact();
    artifact.setUrl("fakeUrl");
    ValueSet fakeValueSet = new ValueSet();
    fakeValueSet.setId("fakeId");
    fakeValueSet.setVersion("fakeVersion");
    artifact.setFhirResource(fakeValueSet);
    ValueSetUtil.validateArtifact(artifact);
}
Also used : ValueSet(org.hl7.fhir.r4.model.ValueSet) Test(org.junit.Test)

Example 77 with ValueSet

use of org.hl7.fhir.r4.model.ValueSet in project quality-measure-and-cohort-service by Alvearie.

the class ValueSetUtilTest method testUnsuppliedVersion.

@Test
public void testUnsuppliedVersion() {
    thrown.expect(IllegalArgumentException.class);
    thrown.expectMessage("Value Set Version must be supplied");
    ValueSetArtifact artifact = new ValueSetArtifact();
    artifact.setUrl("fakeUrl");
    ValueSet fakeValueSet = new ValueSet();
    fakeValueSet.setId("fakeId");
    artifact.setFhirResource(fakeValueSet);
    ValueSetUtil.validateArtifact(artifact);
}
Also used : ValueSet(org.hl7.fhir.r4.model.ValueSet) Test(org.junit.Test)

Example 78 with ValueSet

use of org.hl7.fhir.r4.model.ValueSet in project quality-measure-and-cohort-service by Alvearie.

the class ValueSetUtilTest method testCorrectValidation.

@Test
public void testCorrectValidation() {
    ValueSetArtifact artifact = new ValueSetArtifact();
    artifact.setUrl("fakeUrl");
    ValueSet fakeValueSet = new ValueSet();
    fakeValueSet.setId("fakeId");
    fakeValueSet.setVersion("fakeVersion");
    ValueSet.ValueSetComposeComponent compose = new ValueSet.ValueSetComposeComponent();
    ValueSet.ConceptSetComponent component = new ValueSet.ConceptSetComponent();
    component.setConcept(Collections.singletonList(new ValueSet.ConceptReferenceComponent(new CodeType("fakeCode"))));
    compose.setInclude(Collections.singletonList(component));
    fakeValueSet.setCompose(compose);
    artifact.setFhirResource(fakeValueSet);
    ValueSetUtil.validateArtifact(artifact);
}
Also used : CodeType(org.hl7.fhir.r4.model.CodeType) ValueSet(org.hl7.fhir.r4.model.ValueSet) Test(org.junit.Test)

Example 79 with ValueSet

use of org.hl7.fhir.r4.model.ValueSet in project elexis-server by elexis.

the class ValueSetResourceProvider method search.

@Search
public ValueSet search(@RequiredParam(name = ValueSet.SP_URL) UriParam urlParam, @OptionalParam(name = "_text") StringParam textParam) {
    // TODO useContext (law, date etc)
    Optional<ICodeElementServiceContribution> contribution = getCodeElementServiceContributionByUri(codeElementService, urlParam.getValue());
    if (contribution.isPresent()) {
        Map<Object, Object> singletonMap = Collections.singletonMap(ICodeElementServiceContribution.CONTEXT_KEYS.DISPLAY, textParam.getValue());
        List<ICodeElement> elements = contribution.get().getElements(singletonMap);
        ValueSet valueSet = getTransformer().getFhirObject(elements).get();
        valueSet.getCompose().getInclude().get(0).setSystem(urlParam.getValue());
        return valueSet;
    }
    return null;
}
Also used : ICodeElementServiceContribution(ch.elexis.core.services.ICodeElementServiceContribution) ValueSet(org.hl7.fhir.r4.model.ValueSet) ICodeElement(ch.elexis.core.model.ICodeElement) Search(ca.uhn.fhir.rest.annotation.Search)

Example 80 with ValueSet

use of org.hl7.fhir.r4.model.ValueSet in project ab2d by CMSgov.

the class CapabilityStatementR4 method populateCS.

public static CapabilityStatement populateCS(String server) {
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
    CapabilityStatement cs = new CapabilityStatement();
    cs.setPublisher("Centers for Medicare &amp; Medicaid Services");
    cs.setKind(CapabilityStatement.CapabilityStatementKind.REQUIREMENTS);
    cs.setStatus(Enumerations.PublicationStatus.DRAFT);
    try {
        Date lastUpdated = sdf.parse("02/22/2020 00:00:00");
        cs.setDate(lastUpdated);
    } catch (Exception ex) {
        cs.setDate(new Date());
    }
    cs.setFhirVersion(Enumerations.FHIRVersion._4_0_0);
    cs.setPurpose("Defines FHIR R4 (V2) version of AB2D bulk data download");
    CodeType codeType = new CodeType();
    codeType.setValue(APPLICATION_JSON);
    CodeType codeType2 = new CodeType();
    codeType2.setValue("application/fhir+json");
    cs.setFormat(List.of(codeType, codeType2));
    CapabilityStatement.CapabilityStatementSoftwareComponent cssc = new CapabilityStatement.CapabilityStatementSoftwareComponent();
    cssc.setName("AB2D");
    cssc.setVersion("V2");
    try {
        Date releaseDate = sdf.parse("05/01/2020 00:00:00");
        cssc.setReleaseDate(releaseDate);
    } catch (Exception ex) {
        cssc.setReleaseDate(new Date());
    }
    cs.setSoftware(cssc);
    CapabilityStatement.CapabilityStatementImplementationComponent implementation = new CapabilityStatement.CapabilityStatementImplementationComponent();
    implementation.setDescription("AB2D FHIR R4 Bulk Data Download Implementation");
    implementation.setUrl(server);
    cs.setImplementation(implementation);
    CapabilityStatement.CapabilityStatementRestComponent rest = new CapabilityStatement.CapabilityStatementRestComponent();
    rest.setMode(CapabilityStatement.RestfulCapabilityMode.SERVER);
    CapabilityStatement.CapabilityStatementRestSecurityComponent security = new CapabilityStatement.CapabilityStatementRestSecurityComponent();
    security.setCors(true);
    CodeableConcept codeableConcept = new CodeableConcept();
    Coding coding = new Coding();
    coding.setSystem("http://hl7.org/fhir/ValueSet/restful-security-service");
    coding.setCode("OAuth");
    coding.setDisplay("OAuth");
    codeableConcept.setCoding(List.of(coding));
    codeableConcept.setText("OAuth");
    security.setService(List.of(codeableConcept));
    rest.setSecurity(security);
    List<CapabilityStatement.CapabilityStatementRestResourceOperationComponent> restComponents = new ArrayList<>();
    restComponents.add(createOperation("export", server + "/Patient/$export"));
    restComponents.add(createOperation("export by contract", server + "/Group/{contractNumber}/$export"));
    restComponents.add(createOperation("cancel", server + "/Job/{jobUuid}/$status"));
    restComponents.add(createOperation("status", server + "/Job/{jobUuid}/$status"));
    restComponents.add(createOperation("download", server + "/Job/{jobUuid}/file/{filename}"));
    restComponents.add(createOperation("capability", server + "/metadata"));
    rest.setOperation(restComponents);
    rest.setInteraction(List.of(new CapabilityStatement.SystemInteractionComponent().setCode(CapabilityStatement.SystemRestfulInteraction.BATCH)));
    cs.setRest(List.of(rest));
    return cs;
}
Also used : ArrayList(java.util.ArrayList) Date(java.util.Date) Coding(org.hl7.fhir.r4.model.Coding) CapabilityStatement(org.hl7.fhir.r4.model.CapabilityStatement) CodeType(org.hl7.fhir.r4.model.CodeType) SimpleDateFormat(java.text.SimpleDateFormat) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Aggregations

ValueSet (org.hl7.fhir.r5.model.ValueSet)159 ValueSet (org.hl7.fhir.r4.model.ValueSet)116 Test (org.junit.jupiter.api.Test)115 ArrayList (java.util.ArrayList)101 FHIRException (org.hl7.fhir.exceptions.FHIRException)100 IOException (java.io.IOException)97 ValueSet (org.hl7.fhir.dstu3.model.ValueSet)59 ValueSet (org.hl7.fhir.r4b.model.ValueSet)59 FileNotFoundException (java.io.FileNotFoundException)58 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)56 TerminologyServiceException (org.hl7.fhir.exceptions.TerminologyServiceException)46 HashMap (java.util.HashMap)45 Test (org.junit.Test)45 CodeSystem (org.hl7.fhir.r5.model.CodeSystem)43 File (java.io.File)36 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)36 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)31 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)29 RestIntegrationTest (org.opencds.cqf.ruler.test.RestIntegrationTest)29 FileInputStream (java.io.FileInputStream)27