Search in sources :

Example 1 with ProcedureRequest

use of org.hl7.fhir.dstu3.model.ProcedureRequest in project BridgeServer2 by Sage-Bionetworks.

the class CRCController method postProcedureRequest.

@PutMapping("/v1/cuimc/procedurerequests")
public ResponseEntity<StatusMessage> postProcedureRequest() {
    App app = httpBasicAuthentication();
    IParser parser = FHIR_CONTEXT.newJsonParser();
    JsonNode data = parseJson(JsonNode.class);
    ProcedureRequest procedure = parser.parseResource(ProcedureRequest.class, data.toString());
    String userId = findUserId(procedure.getSubject());
    int status = writeReportAndUpdateState(app, userId, data, PROCEDURE_REPORT, AccountStates.TESTS_COLLECTED, true);
    if (status == 200) {
        return ResponseEntity.ok(new StatusMessage("ProcedureRequest updated."));
    }
    return ResponseEntity.created(URI.create("/v1/cuimc/procedurerequests/" + userId)).body(new StatusMessage("ProcedureRequest created."));
}
Also used : App(org.sagebionetworks.bridge.models.apps.App) ProcedureRequest(org.hl7.fhir.dstu3.model.ProcedureRequest) JsonNode(com.fasterxml.jackson.databind.JsonNode) ContactPoint(org.hl7.fhir.dstu3.model.ContactPoint) IParser(ca.uhn.fhir.parser.IParser) StatusMessage(org.sagebionetworks.bridge.models.StatusMessage) PutMapping(org.springframework.web.bind.annotation.PutMapping)

Example 2 with ProcedureRequest

use of org.hl7.fhir.dstu3.model.ProcedureRequest in project cqf-ruler by DBCG.

the class ActivityDefinitionApplyProviderIT method testActivityDefinitionApply.

@Test
public void testActivityDefinitionApply() throws Exception {
    DomainResource activityDefinition = (DomainResource) activityDefinitions.get("opioidcds-risk-assessment-request");
    // Patient First
    Map<String, IBaseResource> resources = uploadTests("test/activitydefinition/Patient");
    IBaseResource patient = resources.get("ExamplePatient");
    Resource applyResult = activityDefinitionApplyProvider.apply(new SystemRequestDetails(), activityDefinition.getIdElement(), patient.getIdElement().getIdPart(), null, null, null, null, null, null, null, null);
    assertTrue(applyResult instanceof ProcedureRequest);
    assertEquals("454281000124100", ((ProcedureRequest) applyResult).getCode().getCoding().get(0).getCode());
}
Also used : DomainResource(org.hl7.fhir.dstu3.model.DomainResource) SystemRequestDetails(ca.uhn.fhir.jpa.partition.SystemRequestDetails) Resource(org.hl7.fhir.dstu3.model.Resource) DomainResource(org.hl7.fhir.dstu3.model.DomainResource) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) ProcedureRequest(org.hl7.fhir.dstu3.model.ProcedureRequest) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) RestIntegrationTest(org.opencds.cqf.ruler.test.RestIntegrationTest)

Example 3 with ProcedureRequest

use of org.hl7.fhir.dstu3.model.ProcedureRequest in project BridgeServer2 by Sage-Bionetworks.

the class CRCControllerTest method makeProcedureRequest.

private String makeProcedureRequest() {
    ProcedureRequest procedure = new ProcedureRequest();
    Identifier id = new Identifier();
    id.setSystem(USER_ID_VALUE_NS);
    id.setValue(TEST_USER_ID);
    Reference ref = new Reference();
    ref.setIdentifier(id);
    procedure.setSubject(ref);
    return FHIR_CONTEXT.newJsonParser().encodeResourceToString(procedure);
}
Also used : Identifier(org.hl7.fhir.dstu3.model.Identifier) Reference(org.hl7.fhir.dstu3.model.Reference) ProcedureRequest(org.hl7.fhir.dstu3.model.ProcedureRequest)

Example 4 with ProcedureRequest

use of org.hl7.fhir.dstu3.model.ProcedureRequest in project BridgeServer2 by Sage-Bionetworks.

the class CRCControllerTest method procedureWrongIdentifier.

@Test(expectedExceptions = BadRequestException.class, expectedExceptionsMessageRegExp = "Could not find Bridge user ID.")
public void procedureWrongIdentifier() throws Exception {
    when(mockRequest.getHeader(AUTHORIZATION)).thenReturn(AUTHORIZATION_HEADER_VALUE);
    when(mockAccountService.authenticate(any(), any())).thenReturn(account);
    when(mockAccountService.getAccount(ACCOUNT_ID)).thenReturn(Optional.of(account));
    Identifier identifier = new Identifier();
    identifier.setSystem("wrong-system");
    identifier.setValue(TEST_USER_ID);
    ProcedureRequest procedure = new ProcedureRequest();
    procedure.addIdentifier(identifier);
    String json = FHIR_CONTEXT.newJsonParser().encodeResourceToString(procedure);
    mockRequestBody(mockRequest, json);
    controller.postProcedureRequest();
}
Also used : Identifier(org.hl7.fhir.dstu3.model.Identifier) ProcedureRequest(org.hl7.fhir.dstu3.model.ProcedureRequest) Test(org.testng.annotations.Test)

Example 5 with ProcedureRequest

use of org.hl7.fhir.dstu3.model.ProcedureRequest in project elexis-server by elexis.

the class ServiceRequestResourceProvider method createProcedureRequest.

@Create
public MethodOutcome createProcedureRequest(@ResourceParam ServiceRequest procedureRequest) {
    MethodOutcome outcome = new MethodOutcome();
    Optional<IProcedureRequest> exists = getTransformer().getLocalObject(procedureRequest);
    if (exists.isPresent()) {
        outcome.setCreated(false);
        outcome.setId(new IdType(procedureRequest.getId()));
    } else {
        Optional<IProcedureRequest> created = getTransformer().createLocalObject(procedureRequest);
        if (created.isPresent()) {
            outcome.setCreated(true);
            outcome.setId(new IdType(created.get().getId()));
        } else {
            throw new InternalErrorException("Creation failed");
        }
    }
    return outcome;
}
Also used : IProcedureRequest(ch.elexis.core.findings.IProcedureRequest) InternalErrorException(ca.uhn.fhir.rest.server.exceptions.InternalErrorException) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) IdType(org.hl7.fhir.r4.model.IdType) Create(ca.uhn.fhir.rest.annotation.Create)

Aggregations

ProcedureRequest (org.hl7.fhir.dstu3.model.ProcedureRequest)23 Test (org.junit.jupiter.api.Test)12 Test (org.junit.Test)10 ServiceRequest (org.hl7.fhir.r4.model.ServiceRequest)6 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)6 IdType (org.hl7.fhir.dstu3.model.IdType)5 Reference (org.hl7.fhir.dstu3.model.Reference)5 Bundle (org.hl7.fhir.dstu3.model.Bundle)4 MethodOutcome (ca.uhn.fhir.rest.api.MethodOutcome)3 Identifier (org.hl7.fhir.dstu3.model.Identifier)2 Resource (org.hl7.fhir.dstu3.model.Resource)2 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)2 Test (org.testng.annotations.Test)2 SystemRequestDetails (ca.uhn.fhir.jpa.partition.SystemRequestDetails)1 IParser (ca.uhn.fhir.parser.IParser)1 Create (ca.uhn.fhir.rest.annotation.Create)1 InternalErrorException (ca.uhn.fhir.rest.server.exceptions.InternalErrorException)1 IProcedureRequest (ch.elexis.core.findings.IProcedureRequest)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 URI (java.net.URI)1