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;
}
}
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;
}
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;
}
Aggregations