Search in sources :

Example 1 with RPBSPWC0

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

the class GroupMemberController method cancelGroupMember.

/**
 * Cancels a group member's coverage.
 * Maps to the legacy R35.
 *
 * @param cancelGroupMemberRequest
 * @return The result of the operation.
 */
@PostMapping("/cancel-group-member")
public ResponseEntity<CancelGroupMemberResponse> cancelGroupMember(@Valid @RequestBody CancelGroupMemberRequest cancelGroupMemberRequest, HttpServletRequest request) {
    Transaction transaction = auditCancelGroupMemberStart(cancelGroupMemberRequest, request);
    try {
        RPBSPWC0Converter converter = new RPBSPWC0Converter();
        RPBSPWC0 rpbspwc0 = converter.convertRequest(cancelGroupMemberRequest);
        RPBSPWC0 rpbspwc0Response = groupMemberService.cancelGroupMember(rpbspwc0, transaction);
        CancelGroupMemberResponse cancelGroupMemberResponse = converter.convertResponse(rpbspwc0Response);
        ResponseEntity<CancelGroupMemberResponse> response = ResponseEntity.ok(cancelGroupMemberResponse);
        logger.info("cancelGroupMemberResponse response: {} ", cancelGroupMemberResponse);
        transactionComplete(transaction);
        addAffectedParty(transaction, IdentifierType.PHN, cancelGroupMemberResponse.getPhn());
        return response;
    } catch (Exception e) {
        handleException(transaction, e);
        return null;
    }
}
Also used : Transaction(ca.bc.gov.hlth.hnweb.persistence.entity.Transaction) CancelGroupMemberResponse(ca.bc.gov.hlth.hnweb.model.rest.groupmember.CancelGroupMemberResponse) RPBSPWC0(ca.bc.gov.hlth.hnweb.model.rapid.RPBSPWC0) RPBSPWC0Converter(ca.bc.gov.hlth.hnweb.converter.rapid.RPBSPWC0Converter) ResponseStatusException(org.springframework.web.server.ResponseStatusException) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 2 with RPBSPWC0

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

the class RPBSPWC0Converter method convertRequest.

public RPBSPWC0 convertRequest(CancelGroupMemberRequest request) {
    RPBSHeader rpbsHeader = new RPBSHeader();
    rpbsHeader.setOrganization(userInfo.getOrganization());
    rpbsHeader.setTranCode(getTranCode());
    WC0 wc0 = new WC0();
    wc0.setGroupNumber(request.getGroupNumber());
    wc0.setPhn(request.getPhn());
    wc0.setCoverageCancelDate(formatDate(request.getCoverageCancelDate()));
    wc0.setPayerCancelReason(request.getCancelReason());
    RPBSPWC0 rpbspwc0 = new RPBSPWC0();
    rpbspwc0.setRpbsHeader(rpbsHeader);
    rpbspwc0.setWc0(wc0);
    return rpbspwc0;
}
Also used : RPBSPWC0(ca.bc.gov.hlth.hnweb.model.rapid.RPBSPWC0) WC0(ca.bc.gov.hlth.hnweb.model.rapid.WC0) RPBSHeader(ca.bc.gov.hlth.hnweb.model.rapid.RPBSHeader) RPBSPWC0(ca.bc.gov.hlth.hnweb.model.rapid.RPBSPWC0)

Example 3 with RPBSPWC0

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

the class GroupMemberService method cancelGroupMember.

/**
 * Cancels the group member's coverage based on the R35/RPBSPWC0.
 *
 * @param rpbspwc0
 * @return The RPBSPWC0 response.
 * @throws HNWebException
 */
public RPBSPWC0 cancelGroupMember(RPBSPWC0 rpbspwc0, Transaction transaction) throws HNWebException {
    String rpbspwc0Str = rpbspwc0.serialize();
    logger.info("Request {}", rpbspwc0Str);
    messageSent(transaction);
    ResponseEntity<String> response = postRapidRequest(r35Path, rpbspwc0Str);
    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);
    }
    RPBSPWC0 rpbspwc0Response = new RPBSPWC0(response.getBody());
    return rpbspwc0Response;
}
Also used : HNWebException(ca.bc.gov.hlth.hnweb.exception.HNWebException) RPBSPWC0(ca.bc.gov.hlth.hnweb.model.rapid.RPBSPWC0)

Aggregations

RPBSPWC0 (ca.bc.gov.hlth.hnweb.model.rapid.RPBSPWC0)3 RPBSPWC0Converter (ca.bc.gov.hlth.hnweb.converter.rapid.RPBSPWC0Converter)1 HNWebException (ca.bc.gov.hlth.hnweb.exception.HNWebException)1 RPBSHeader (ca.bc.gov.hlth.hnweb.model.rapid.RPBSHeader)1 WC0 (ca.bc.gov.hlth.hnweb.model.rapid.WC0)1 CancelGroupMemberResponse (ca.bc.gov.hlth.hnweb.model.rest.groupmember.CancelGroupMemberResponse)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