Search in sources :

Example 1 with RPBSPWB0

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

the class GroupMemberService method addDependent.

/**
 * Add a dependent for the group member based on the R31/RPBSPWB0 request.
 *
 * @param rpbspwb0
 * @param transaction
 * @return The RPBSPWB0 response.
 * @throws HNWebException
 */
public RPBSPWB0 addDependent(RPBSPWB0 rpbspwb0, Transaction transaction) throws HNWebException {
    String rpbspwb0Str = rpbspwb0.serialize();
    logger.info("Request {}", rpbspwb0Str);
    messageSent(transaction);
    ResponseEntity<String> response = postRapidRequest(r31Path, rpbspwb0Str);
    messageReceived(transaction);
    logger.info("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);
    }
    RPBSPWB0 rpbspwb0Response = new RPBSPWB0(response.getBody());
    return rpbspwb0Response;
}
Also used : HNWebException(ca.bc.gov.hlth.hnweb.exception.HNWebException) RPBSPWB0(ca.bc.gov.hlth.hnweb.model.rapid.RPBSPWB0)

Example 2 with RPBSPWB0

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

the class RPBSPWB0Converter method convertRequest.

public RPBSPWB0 convertRequest(AddDependentRequest request) {
    RPBSHeader rpbsHeader = new RPBSHeader();
    rpbsHeader.setOrganization(userInfo.getOrganization());
    rpbsHeader.setTranCode(getTranCode());
    WB0 wb0 = new WB0();
    wb0.setGroupNumber(request.getGroupNumber());
    wb0.setPhn(request.getPhn());
    wb0.setBenficiaryPHN(request.getDependentPhn());
    wb0.setCoverageEffectiveDate(formatDate(request.getCoverageEffectiveDate()));
    wb0.setRelationshipCode(request.getRelationship());
    wb0.setStudentFlag(request.getIsStudent());
    if (StringUtils.equals("Y", request.getIsStudent())) {
        wb0.setStudentEndDate(formatDate(request.getStudentEndDate()));
    } else {
        wb0.setStudentEndDate("");
    }
    RPBSPWB0 rpbspwb0 = new RPBSPWB0();
    rpbspwb0.setRpbsHeader(rpbsHeader);
    rpbspwb0.setWb0(wb0);
    return rpbspwb0;
}
Also used : RPBSPWB0(ca.bc.gov.hlth.hnweb.model.rapid.RPBSPWB0) WB0(ca.bc.gov.hlth.hnweb.model.rapid.WB0) RPBSHeader(ca.bc.gov.hlth.hnweb.model.rapid.RPBSHeader) RPBSPWB0(ca.bc.gov.hlth.hnweb.model.rapid.RPBSPWB0)

Example 3 with RPBSPWB0

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

the class GroupMemberController method addDependent.

/**
 * Add a dependent to a group member's coverage.
 * Maps to the legacy R31.
 *
 * @param addDependentRequest
 * @return The result of the operation.
 */
@PostMapping("/add-dependent")
public ResponseEntity<AddDependentResponse> addDependent(@Valid @RequestBody AddDependentRequest addDependentRequest, HttpServletRequest request) {
    Transaction transaction = auditAddDependentStart(addDependentRequest, request);
    try {
        RPBSPWB0Converter converter = new RPBSPWB0Converter();
        RPBSPWB0 rpbspwb0Request = converter.convertRequest(addDependentRequest);
        RPBSPWB0 rpbspwb0Response = groupMemberService.addDependent(rpbspwb0Request, transaction);
        AddDependentResponse addDependentResponse = converter.convertResponse(rpbspwb0Response);
        ResponseEntity<AddDependentResponse> response = ResponseEntity.ok(addDependentResponse);
        logger.info("addDependentResponse response: {} ", addDependentResponse);
        transactionComplete(transaction);
        addAffectedParty(transaction, IdentifierType.PHN, addDependentResponse.getPhn());
        return response;
    } catch (Exception e) {
        handleException(transaction, e);
        return null;
    }
}
Also used : RPBSPWB0Converter(ca.bc.gov.hlth.hnweb.converter.rapid.RPBSPWB0Converter) Transaction(ca.bc.gov.hlth.hnweb.persistence.entity.Transaction) AddDependentResponse(ca.bc.gov.hlth.hnweb.model.rest.groupmember.AddDependentResponse) RPBSPWB0(ca.bc.gov.hlth.hnweb.model.rapid.RPBSPWB0) ResponseStatusException(org.springframework.web.server.ResponseStatusException) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Aggregations

RPBSPWB0 (ca.bc.gov.hlth.hnweb.model.rapid.RPBSPWB0)3 RPBSPWB0Converter (ca.bc.gov.hlth.hnweb.converter.rapid.RPBSPWB0Converter)1 HNWebException (ca.bc.gov.hlth.hnweb.exception.HNWebException)1 RPBSHeader (ca.bc.gov.hlth.hnweb.model.rapid.RPBSHeader)1 WB0 (ca.bc.gov.hlth.hnweb.model.rapid.WB0)1 AddDependentResponse (ca.bc.gov.hlth.hnweb.model.rest.groupmember.AddDependentResponse)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