use of ca.bc.gov.hlth.hnweb.model.rapid.RPBSPED0 in project moh-hnweb by bcgov.
the class GroupMemberService method updateGroupMemberDepartmentNumber.
/**
* Update the group member's department number based on the R34/RPBSPPE0 request.
*
* @param rpbsped0
* @return The RPBSPED0 response.
* @throws HNWebException
*/
public RPBSPED0 updateGroupMemberDepartmentNumber(RPBSPED0 rpbsped0, Transaction transaction) throws HNWebException {
String rpbsped0Str = rpbsped0.serialize();
logger.info("Request {}", rpbsped0Str);
messageSent(transaction);
ResponseEntity<String> response = postRapidRequest(r34Path, rpbsped0Str);
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);
}
RPBSPED0 rpbsped0Response = new RPBSPED0(response.getBody());
return rpbsped0Response;
}
use of ca.bc.gov.hlth.hnweb.model.rapid.RPBSPED0 in project moh-hnweb by bcgov.
the class GroupMemberController method updateNumberAndDept.
/**
* Updates a group member's number and/or department.
* Maps to the legacy R34.
*
* @param updateNumberAndDeptRequest
* @return The result of the update.
*/
@PostMapping("/update-number-and-dept")
public ResponseEntity<UpdateNumberAndDeptResponse> updateNumberAndDept(@Valid @RequestBody UpdateNumberAndDeptRequest updateNumberAndDeptRequest, HttpServletRequest request) {
Transaction transaction = auditUpdateNumberAndDeptStart(updateNumberAndDeptRequest, request);
// Do basic validation since there's no point in calling the downstream systems if the data isn't valid
if (StringUtils.isBlank(updateNumberAndDeptRequest.getDepartmentNumber()) && StringUtils.isBlank(updateNumberAndDeptRequest.getGroupMemberNumber())) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Department Number or Group Number is required");
}
try {
// Handle the department number
UpdateNumberAndDeptResponse deptNumberResponse = new UpdateNumberAndDeptResponse();
if (StringUtils.isNotBlank(updateNumberAndDeptRequest.getDepartmentNumber())) {
RPBSPED0Converter rpbsped0Converter = new RPBSPED0Converter();
RPBSPED0 rpbsped0Request = rpbsped0Converter.convertRequest(updateNumberAndDeptRequest);
RPBSPED0 rpbsped0Response = groupMemberService.updateGroupMemberDepartmentNumber(rpbsped0Request, transaction);
deptNumberResponse = rpbsped0Converter.convertResponse(rpbsped0Response);
}
// Handle the group member/employee number
UpdateNumberAndDeptResponse empNumberResponse = new UpdateNumberAndDeptResponse();
if (StringUtils.isNotBlank(updateNumberAndDeptRequest.getGroupMemberNumber())) {
RPBSPEE0Converter rpbspee0Converter = new RPBSPEE0Converter();
RPBSPEE0 rpbspee0Request = rpbspee0Converter.convertRequest(updateNumberAndDeptRequest);
RPBSPEE0 rpbspee0Response = groupMemberService.updateGroupMemberEmployeeNumber(rpbspee0Request, transaction);
empNumberResponse = rpbspee0Converter.convertResponse(rpbspee0Response);
}
// Combine the results
UpdateNumberAndDeptResponse updateNumberAndDeptResponse = handleUpdateGroupMemberResponse(deptNumberResponse, empNumberResponse);
ResponseEntity<UpdateNumberAndDeptResponse> response = ResponseEntity.ok(updateNumberAndDeptResponse);
logger.info("updateNumberAndDept response: {} ", updateNumberAndDeptResponse);
transactionComplete(transaction);
addAffectedParty(transaction, IdentifierType.PHN, updateNumberAndDeptResponse.getPhn());
return response;
} catch (Exception e) {
handleException(transaction, e);
return null;
}
}
use of ca.bc.gov.hlth.hnweb.model.rapid.RPBSPED0 in project moh-hnweb by bcgov.
the class RPBSPED0Converter method convertRequest.
public RPBSPED0 convertRequest(UpdateNumberAndDeptRequest request) {
RPBSHeader rpbsHeader = new RPBSHeader();
rpbsHeader.setOrganization(userInfo.getOrganization());
rpbsHeader.setTranCode(getTranCode());
ED0 ed0 = new ED0();
ed0.setGroupNumber(request.getGroupNumber());
ed0.setPhn(request.getPhn());
ed0.setDepartmentNumber(request.getDepartmentNumber());
RPBSPED0 rpbsped0 = new RPBSPED0();
rpbsped0.setRpbsHeader(rpbsHeader);
rpbsped0.setEd0(ed0);
return rpbsped0;
}
Aggregations