Search in sources :

Example 16 with LookupRequest

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

the class FhirBatchApiRestTest method singleRequestWithInvalidParameters.

@Test
public void singleRequestWithInvalidParameters() {
    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();
    // Completely invalid request
    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("500")).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)

Example 17 with LookupRequest

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

the class ExpandValueSetRequestDeserializationTest method testDeserialization.

// @Test
public void testDeserialization() {
    Coding coding = Coding.builder().system("http://hl7.org/fhir/issue-severity").code("fatal").build();
    LookupRequest request = LookupRequest.builder().coding(coding).build();
    Fhir fhirParameters = new Parameters.Fhir(request);
    fhirParameters.getParameters().forEach(p -> System.out.println(p));
    Optional<Parameter> findFirst = fhirParameters.getParameters().stream().filter(p -> {
        Coding pCoding = (Coding) p.getValue();
        return pCoding.getSystemValue().equals("http://hl7.org/fhir/issue-severity");
    }).findFirst();
    assertTrue(findFirst.isPresent());
}
Also used : OperationOutcomeCode(com.b2international.snowowl.fhir.core.codesystems.OperationOutcomeCode) ValidationException(com.b2international.snowowl.fhir.core.exceptions.ValidationException) IssueSeverity(com.b2international.snowowl.fhir.core.codesystems.IssueSeverity) Parameter(com.b2international.snowowl.fhir.core.model.dt.Parameter) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Assert.assertTrue(org.junit.Assert.assertTrue) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) Test(org.junit.Test) Uri(com.b2international.snowowl.fhir.core.model.dt.Uri) LookupRequest(com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest) IssueType(com.b2international.snowowl.fhir.core.codesystems.IssueType) Json(com.b2international.snowowl.fhir.core.model.dt.Parameters.Json) ExpandValueSetRequest(com.b2international.snowowl.fhir.core.model.valueset.ExpandValueSetRequest) Issue(com.b2international.snowowl.fhir.core.model.Issue) Optional(java.util.Optional) Builder(com.b2international.snowowl.fhir.core.model.Issue.Builder) Parameters(com.b2international.snowowl.fhir.core.model.dt.Parameters) Coding(com.b2international.snowowl.fhir.core.model.dt.Coding) FhirExceptionIssueMatcher(com.b2international.snowowl.fhir.tests.FhirExceptionIssueMatcher) Coding(com.b2international.snowowl.fhir.core.model.dt.Coding) Parameter(com.b2international.snowowl.fhir.core.model.dt.Parameter) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) LookupRequest(com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest)

Example 18 with LookupRequest

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

the class ExpandValueSetRequestDeserializationTest method fullCircleTest.

// @Test
public void fullCircleTest() throws Exception {
    Coding coding = Coding.builder().system("http://hl7.org/fhir/issue-severity").code("fatal").build();
    System.out.println("Building the lookup request object.");
    LookupRequest request = LookupRequest.builder().coding(coding).build();
    Json json1 = new Parameters.Json(request);
    System.out.println("JSON params:" + json1);
    Fhir fhir = new Parameters.Fhir(json1.parameters());
    String fhirJson = objectMapper.writeValueAsString(fhir);
    System.out.println("This is the JSON request from the client: " + fhirJson);
    System.out.println("This is happening in the server-side...");
    Fhir parameters = objectMapper.readValue(fhirJson, Parameters.Fhir.class);
    System.out.println("Deserialized into FHIR parameters..." + parameters.getParameters());
    System.out.println("Back to Domain JSON...");
    Json json = new Parameters.Json(parameters);
    LookupRequest lookupRequest = objectMapper.convertValue(json, LookupRequest.class);
    System.out.println("... and back to the object representation we started from:" + lookupRequest);
}
Also used : Parameters(com.b2international.snowowl.fhir.core.model.dt.Parameters) Coding(com.b2international.snowowl.fhir.core.model.dt.Coding) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) Json(com.b2international.snowowl.fhir.core.model.dt.Parameters.Json) LookupRequest(com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest)

Example 19 with LookupRequest

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

the class LookupRequestDeserializationTest method testDeserialization.

@Test
public void testDeserialization() {
    Coding coding = Coding.builder().system("http://hl7.org/fhir/issue-severity").code("fatal").build();
    LookupRequest request = LookupRequest.builder().coding(coding).build();
    Fhir fhirParameters = new Parameters.Fhir(request);
    // fhirParameters.getParameters().forEach(p -> System.out.println(p));
    Optional<Parameter> findFirst = fhirParameters.getParameters().stream().filter(p -> {
        Coding pCoding = (Coding) p.getValue();
        return pCoding.getSystemValue().equals("http://hl7.org/fhir/issue-severity");
    }).findFirst();
    assertTrue(findFirst.isPresent());
}
Also used : OperationOutcomeCode(com.b2international.snowowl.fhir.core.codesystems.OperationOutcomeCode) ValidationException(com.b2international.snowowl.fhir.core.exceptions.ValidationException) IssueSeverity(com.b2international.snowowl.fhir.core.codesystems.IssueSeverity) Parameter(com.b2international.snowowl.fhir.core.model.dt.Parameter) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Assert.assertTrue(org.junit.Assert.assertTrue) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) Test(org.junit.Test) LookupRequest(com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest) IssueType(com.b2international.snowowl.fhir.core.codesystems.IssueType) Json(com.b2international.snowowl.fhir.core.model.dt.Parameters.Json) Issue(com.b2international.snowowl.fhir.core.model.Issue) Optional(java.util.Optional) Builder(com.b2international.snowowl.fhir.core.model.Issue.Builder) Parameters(com.b2international.snowowl.fhir.core.model.dt.Parameters) Coding(com.b2international.snowowl.fhir.core.model.dt.Coding) FhirExceptionIssueMatcher(com.b2international.snowowl.fhir.tests.FhirExceptionIssueMatcher) Coding(com.b2international.snowowl.fhir.core.model.dt.Coding) Parameter(com.b2international.snowowl.fhir.core.model.dt.Parameter) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) LookupRequest(com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

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