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