Search in sources :

Example 11 with LookupRequest

use of com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest in project snow-owl by b2ihealthcare.

the class BundleEntryTest method buildInvalidParametersEntry.

@Test
public void buildInvalidParametersEntry() {
    ValidationException exception = assertThrows(ValidationException.class, () -> {
        LookupRequest lookupRequest = LookupRequest.builder().code("23245-4").system("http://loinc.org").build();
        Json json1 = new Parameters.Json(lookupRequest);
        ParametersRequestEntry entry = ParametersRequestEntry.builder().request(BatchRequest.createGetRequest("CodeSystem/$lookup")).resource(new Parameters.Fhir(json1.parameters())).build();
    });
    Issue expectedIssue = validationErrorIssueBuilder.addLocation("ParametersRequestEntry.post").detailsWithDisplay(OperationOutcomeCode.MSG_PARAM_INVALID, "Parameter 'post' content is invalid [false]. Violation: Only POST requests can be parameter-based.").build();
    assertThat(exception, FhirExceptionIssueMatcher.issue(expectedIssue));
}
Also used : ValidationException(com.b2international.snowowl.fhir.core.exceptions.ValidationException) Json(com.b2international.snowowl.fhir.core.model.dt.Parameters.Json) LookupRequest(com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 12 with LookupRequest

use of com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest in project snow-owl by b2ihealthcare.

the class BundleEntryTest method requestEntryWithParametersTest.

@Test
public void requestEntryWithParametersTest() throws Exception {
    LookupRequest lookupRequest = LookupRequest.builder().code("23245-4").system("http://loinc.org").build();
    Json json1 = new Parameters.Json(lookupRequest);
    ParametersRequestEntry entry = ParametersRequestEntry.builder().request(BatchRequest.createPostRequest("CodeSystem/$lookup")).resource(new Parameters.Fhir(json1.parameters())).build();
    String json = objectMapper.writeValueAsString(entry);
    Entry readEntry = objectMapper.readValue(json, Entry.class);
    assertTrue(readEntry instanceof ParametersRequestEntry);
}
Also used : Json(com.b2international.snowowl.fhir.core.model.dt.Parameters.Json) LookupRequest(com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 13 with LookupRequest

use of com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest in project snow-owl by b2ihealthcare.

the class LookupSnomedRestTest method lookupVersionPostTest.

@Test
public void lookupVersionPostTest() throws Exception {
    Coding coding = Coding.builder().system("http://snomed.info/sct/900000000000207008/version/20170131").code(Concepts.IS_A).build();
    LookupRequest request = LookupRequest.builder().coding(coding).build();
    Fhir fhirParameters = new Parameters.Fhir(request);
    givenAuthenticatedRequest(FHIR_ROOT_CONTEXT).contentType(APPLICATION_FHIR_JSON).body(fhirParameters).when().post("/CodeSystem/$lookup").then().statusCode(200).body("resourceType", equalTo("Parameters")).body("parameter.size()", is(2)).body("parameter[0].name", equalTo("name")).body("parameter[0].valueString", equalTo("SNOMED CT")).body("parameter[1].name", equalTo("display")).body("parameter[1].valueString", equalTo("Is a"));
}
Also used : Coding(com.b2international.snowowl.fhir.core.model.dt.Coding) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) LookupRequest(com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest) Test(org.junit.Test) FhirRestTest(com.b2international.snowowl.fhir.tests.FhirRestTest)

Example 14 with LookupRequest

use of com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest in project snow-owl by b2ihealthcare.

the class FhirCodeSystemLookupOperationTest method POST_CodeSystem_$lookup_Existing_Property.

@Test
public void POST_CodeSystem_$lookup_Existing_Property() throws Exception {
    LookupRequest request = LookupRequest.builder().coding(Coding.of(SNOMEDCT_URL, CLINICAL_FINDING)).addProperty("parent").build();
    givenAuthenticatedRequest(FHIR_ROOT_CONTEXT).contentType(APPLICATION_FHIR_JSON).body(toFhirParameters(request)).when().post(CODESYSTEM_LOOKUP).then().assertThat().statusCode(200).body("resourceType", equalTo("Parameters")).body("parameter[0].name", equalTo("name")).body("parameter[0].valueString", equalTo("SNOMEDCT")).body("parameter[1].name", equalTo("display")).body("parameter[1].valueString", equalTo("Clinical finding")).body("parameter[2].name", equalTo("property")).body("parameter[2].part[0].valueCode", equalTo("parent")).body("parameter[2].part[1].valueCode", equalTo(Concepts.ROOT_CONCEPT)).body("parameter[2].part[2].valueString", equalTo("SNOMED CT Concept"));
}
Also used : LookupRequest(com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest) FhirRestTest(com.b2international.snowowl.fhir.tests.FhirRestTest) Test(org.junit.Test)

Example 15 with LookupRequest

use of com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest in project snow-owl by b2ihealthcare.

the class FhirBatchApiRestTest method singleRequestWithFailedLookup.

@Test
public void singleRequestWithFailedLookup() {
    LookupRequest request = LookupRequest.builder().coding(Coding.builder().system("http://snomed.info/sct").code(Concepts.IS_A).build()).build();
    Json json = new Parameters.Json(request);
    ParametersRequestEntry entry = ParametersRequestEntry.builder().request(BatchRequest.createPostRequest("CodeSystem/$lookup")).resource(new Parameters.Fhir(json.parameters())).build();
    RequestEntry entry2 = RequestEntry.builder().request(BatchRequest.createGetRequest("CodeSystem/$lookup?system=whatever&code=1234")).build();
    Bundle bundle = Bundle.builder().language("en").total(2).type(BundleType.BATCH).addEntry(entry).addEntry(entry2).build();
    givenAuthenticatedRequest(FHIR_ROOT_CONTEXT).contentType(APPLICATION_FHIR_JSON).body(bundle).when().post("/").prettyPeek().then().statusCode(200).body("resourceType", equalTo("Bundle")).body("type", is("batch-response")).body("entry[0].response.status", equalTo("200")).body("entry[0].resource.resourceType", equalTo("Parameters")).body("entry[1].response.status", equalTo("404")).body("entry[1].resource.resourceType", equalTo("OperationOutcome"));
}
Also used : Json(com.b2international.snowowl.fhir.core.model.dt.Parameters.Json) LookupRequest(com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest) Test(org.junit.Test) FhirRestTest(com.b2international.snowowl.fhir.tests.FhirRestTest)

Aggregations

LookupRequest (com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest)19 Test (org.junit.Test)16 Json (com.b2international.snowowl.fhir.core.model.dt.Parameters.Json)13 Fhir (com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir)11 FhirTest (com.b2international.snowowl.fhir.tests.FhirTest)9 FhirRestTest (com.b2international.snowowl.fhir.tests.FhirRestTest)7 Coding (com.b2international.snowowl.fhir.core.model.dt.Coding)6 Parameters (com.b2international.snowowl.fhir.core.model.dt.Parameters)6 ValidationException (com.b2international.snowowl.fhir.core.exceptions.ValidationException)3 Bundle (com.b2international.snowowl.fhir.core.model.Bundle)3 ParametersRequestEntry (com.b2international.snowowl.fhir.core.model.ParametersRequestEntry)3 Parameter (com.b2international.snowowl.fhir.core.model.dt.Parameter)3 IssueSeverity (com.b2international.snowowl.fhir.core.codesystems.IssueSeverity)2 IssueType (com.b2international.snowowl.fhir.core.codesystems.IssueType)2 OperationOutcomeCode (com.b2international.snowowl.fhir.core.codesystems.OperationOutcomeCode)2 BatchRequest (com.b2international.snowowl.fhir.core.model.BatchRequest)2 Entry (com.b2international.snowowl.fhir.core.model.Entry)2 Issue (com.b2international.snowowl.fhir.core.model.Issue)2 Builder (com.b2international.snowowl.fhir.core.model.Issue.Builder)2 OperationOutcomeEntry (com.b2international.snowowl.fhir.core.model.OperationOutcomeEntry)2