Search in sources :

Example 1 with RPBSPED0

use of ca.bc.gov.hlth.hnweb.model.rapid.RPBSPED0 in project moh-hnweb by bcgov.

the class GroupMemberService method updateGroupMemberDepartmentNumber.

/**
 * Update the group member's department number based on the R34/RPBSPPE0 request.
 *
 * @param rpbsped0
 * @return The RPBSPED0 response.
 * @throws HNWebException
 */
public RPBSPED0 updateGroupMemberDepartmentNumber(RPBSPED0 rpbsped0, Transaction transaction) throws HNWebException {
    String rpbsped0Str = rpbsped0.serialize();
    logger.info("Request {}", rpbsped0Str);
    messageSent(transaction);
    ResponseEntity<String> response = postRapidRequest(r34Path, rpbsped0Str);
    messageReceived(transaction);
    logger.debug("Response Status: {} ; Message:\n{}", response.getStatusCode(), response.getBody());
    if (response.getStatusCode() != HttpStatus.OK) {
        logger.error("Could not connect to downstream service. Service returned {}", response.getStatusCode());
        throw new HNWebException(ExceptionType.DOWNSTREAM_FAILURE);
    }
    RPBSPED0 rpbsped0Response = new RPBSPED0(response.getBody());
    return rpbsped0Response;
}
Also used : HNWebException(ca.bc.gov.hlth.hnweb.exception.HNWebException) RPBSPED0(ca.bc.gov.hlth.hnweb.model.rapid.RPBSPED0)

Example 2 with RPBSPED0

use of ca.bc.gov.hlth.hnweb.model.rapid.RPBSPED0 in project moh-hnweb by bcgov.

the class GroupMemberController method updateNumberAndDept.

/**
 * Updates a group member's number and/or department.
 * Maps to the legacy R34.
 *
 * @param updateNumberAndDeptRequest
 * @return The result of the update.
 */
@PostMapping("/update-number-and-dept")
public ResponseEntity<UpdateNumberAndDeptResponse> updateNumberAndDept(@Valid @RequestBody UpdateNumberAndDeptRequest updateNumberAndDeptRequest, HttpServletRequest request) {
    Transaction transaction = auditUpdateNumberAndDeptStart(updateNumberAndDeptRequest, request);
    // Do basic validation since there's no point in calling the downstream systems if the data isn't valid
    if (StringUtils.isBlank(updateNumberAndDeptRequest.getDepartmentNumber()) && StringUtils.isBlank(updateNumberAndDeptRequest.getGroupMemberNumber())) {
        throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Department Number or Group Number is required");
    }
    try {
        // Handle the department number
        UpdateNumberAndDeptResponse deptNumberResponse = new UpdateNumberAndDeptResponse();
        if (StringUtils.isNotBlank(updateNumberAndDeptRequest.getDepartmentNumber())) {
            RPBSPED0Converter rpbsped0Converter = new RPBSPED0Converter();
            RPBSPED0 rpbsped0Request = rpbsped0Converter.convertRequest(updateNumberAndDeptRequest);
            RPBSPED0 rpbsped0Response = groupMemberService.updateGroupMemberDepartmentNumber(rpbsped0Request, transaction);
            deptNumberResponse = rpbsped0Converter.convertResponse(rpbsped0Response);
        }
        // Handle the group member/employee number
        UpdateNumberAndDeptResponse empNumberResponse = new UpdateNumberAndDeptResponse();
        if (StringUtils.isNotBlank(updateNumberAndDeptRequest.getGroupMemberNumber())) {
            RPBSPEE0Converter rpbspee0Converter = new RPBSPEE0Converter();
            RPBSPEE0 rpbspee0Request = rpbspee0Converter.convertRequest(updateNumberAndDeptRequest);
            RPBSPEE0 rpbspee0Response = groupMemberService.updateGroupMemberEmployeeNumber(rpbspee0Request, transaction);
            empNumberResponse = rpbspee0Converter.convertResponse(rpbspee0Response);
        }
        // Combine the results
        UpdateNumberAndDeptResponse updateNumberAndDeptResponse = handleUpdateGroupMemberResponse(deptNumberResponse, empNumberResponse);
        ResponseEntity<UpdateNumberAndDeptResponse> response = ResponseEntity.ok(updateNumberAndDeptResponse);
        logger.info("updateNumberAndDept response: {} ", updateNumberAndDeptResponse);
        transactionComplete(transaction);
        addAffectedParty(transaction, IdentifierType.PHN, updateNumberAndDeptResponse.getPhn());
        return response;
    } catch (Exception e) {
        handleException(transaction, e);
        return null;
    }
}
Also used : Transaction(ca.bc.gov.hlth.hnweb.persistence.entity.Transaction) RPBSPEE0(ca.bc.gov.hlth.hnweb.model.rapid.RPBSPEE0) RPBSPED0(ca.bc.gov.hlth.hnweb.model.rapid.RPBSPED0) RPBSPED0Converter(ca.bc.gov.hlth.hnweb.converter.rapid.RPBSPED0Converter) UpdateNumberAndDeptResponse(ca.bc.gov.hlth.hnweb.model.rest.groupmember.UpdateNumberAndDeptResponse) ResponseStatusException(org.springframework.web.server.ResponseStatusException) ResponseStatusException(org.springframework.web.server.ResponseStatusException) RPBSPEE0Converter(ca.bc.gov.hlth.hnweb.converter.rapid.RPBSPEE0Converter) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 3 with RPBSPED0

use of ca.bc.gov.hlth.hnweb.model.rapid.RPBSPED0 in project moh-hnweb by bcgov.

the class RPBSPED0Converter method convertRequest.

public RPBSPED0 convertRequest(UpdateNumberAndDeptRequest request) {
    RPBSHeader rpbsHeader = new RPBSHeader();
    rpbsHeader.setOrganization(userInfo.getOrganization());
    rpbsHeader.setTranCode(getTranCode());
    ED0 ed0 = new ED0();
    ed0.setGroupNumber(request.getGroupNumber());
    ed0.setPhn(request.getPhn());
    ed0.setDepartmentNumber(request.getDepartmentNumber());
    RPBSPED0 rpbsped0 = new RPBSPED0();
    rpbsped0.setRpbsHeader(rpbsHeader);
    rpbsped0.setEd0(ed0);
    return rpbsped0;
}
Also used : RPBSPED0(ca.bc.gov.hlth.hnweb.model.rapid.RPBSPED0) ED0(ca.bc.gov.hlth.hnweb.model.rapid.ED0) RPBSHeader(ca.bc.gov.hlth.hnweb.model.rapid.RPBSHeader) RPBSPED0(ca.bc.gov.hlth.hnweb.model.rapid.RPBSPED0)

Aggregations

RPBSPED0 (ca.bc.gov.hlth.hnweb.model.rapid.RPBSPED0)3 RPBSPED0Converter (ca.bc.gov.hlth.hnweb.converter.rapid.RPBSPED0Converter)1 RPBSPEE0Converter (ca.bc.gov.hlth.hnweb.converter.rapid.RPBSPEE0Converter)1 HNWebException (ca.bc.gov.hlth.hnweb.exception.HNWebException)1 ED0 (ca.bc.gov.hlth.hnweb.model.rapid.ED0)1 RPBSHeader (ca.bc.gov.hlth.hnweb.model.rapid.RPBSHeader)1 RPBSPEE0 (ca.bc.gov.hlth.hnweb.model.rapid.RPBSPEE0)1 UpdateNumberAndDeptResponse (ca.bc.gov.hlth.hnweb.model.rest.groupmember.UpdateNumberAndDeptResponse)1 Transaction (ca.bc.gov.hlth.hnweb.persistence.entity.Transaction)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1 ResponseStatusException (org.springframework.web.server.ResponseStatusException)1