Search in sources :

Example 1 with RPBSPWP0

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

the class GroupMemberService method cancelDependent.

/**
 * Cancels the group member's dependent coverage based on the R36/RPBSPWP0.
 *
 * @param rpbspwp0
 * @return The RPBSPWP0 response.
 * @throws HNWebException
 */
public RPBSPWP0 cancelDependent(RPBSPWP0 rpbspwp0, Transaction transaction) throws HNWebException {
    String rpbspwp0Str = rpbspwp0.serialize();
    logger.info("Request {}", rpbspwp0Str);
    messageSent(transaction);
    ResponseEntity<String> response = postRapidRequest(r36Path, rpbspwp0Str);
    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);
    }
    RPBSPWP0 rpbspwp0Response = new RPBSPWP0(response.getBody());
    return rpbspwp0Response;
}
Also used : HNWebException(ca.bc.gov.hlth.hnweb.exception.HNWebException) RPBSPWP0(ca.bc.gov.hlth.hnweb.model.rapid.RPBSPWP0)

Example 2 with RPBSPWP0

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

the class GroupMemberController method cancelDependent.

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

Example 3 with RPBSPWP0

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

the class RPBSPWP0Converter method convertRequest.

public RPBSPWP0 convertRequest(CancelDependentRequest request) {
    RPBSHeader rpbsHeader = new RPBSHeader();
    rpbsHeader.setOrganization(userInfo.getOrganization());
    rpbsHeader.setTranCode(getTranCode());
    WP0 wp0 = new WP0();
    wp0.setGroupNumber(request.getGroupNumber());
    wp0.setSubscriberPhn(request.getPhn());
    wp0.setBeneficiaryPhn(request.getDependentPhn());
    wp0.setCoverageCancelDate(formatDate(request.getCoverageCancelDate()));
    wp0.setPayerCancelReason(request.getCancelReason());
    RPBSPWP0 rpbspwp0 = new RPBSPWP0();
    rpbspwp0.setRpbsHeader(rpbsHeader);
    rpbspwp0.setWp0(wp0);
    return rpbspwp0;
}
Also used : RPBSPWP0(ca.bc.gov.hlth.hnweb.model.rapid.RPBSPWP0) WP0(ca.bc.gov.hlth.hnweb.model.rapid.WP0) RPBSHeader(ca.bc.gov.hlth.hnweb.model.rapid.RPBSHeader) RPBSPWP0(ca.bc.gov.hlth.hnweb.model.rapid.RPBSPWP0)

Aggregations

RPBSPWP0 (ca.bc.gov.hlth.hnweb.model.rapid.RPBSPWP0)3 RPBSPWP0Converter (ca.bc.gov.hlth.hnweb.converter.rapid.RPBSPWP0Converter)1 HNWebException (ca.bc.gov.hlth.hnweb.exception.HNWebException)1 RPBSHeader (ca.bc.gov.hlth.hnweb.model.rapid.RPBSHeader)1 WP0 (ca.bc.gov.hlth.hnweb.model.rapid.WP0)1 CancelDependentResponse (ca.bc.gov.hlth.hnweb.model.rest.groupmember.CancelDependentResponse)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