use of ca.bc.gov.hlth.hnweb.converter.rapid.RPBSPPL0Converter in project moh-hnweb by bcgov.
the class EligibilityController method lookupPhn.
/**
* Lookup PHNs based on the contract number and group number.
* Maps to the legacy R42.
*
* @param lookupPhnRequest
* @return The result of the query
*/
@PostMapping("/lookup-phn")
public ResponseEntity<LookupPhnResponse> lookupPhn(@Valid @RequestBody LookupPhnRequest lookupPhnRequest, HttpServletRequest request) {
Transaction transaction = transactionStart(request, TransactionType.PHN_LOOKUP);
addAffectedParty(transaction, IdentifierType.GROUP_NUMBER, lookupPhnRequest.getGroupNumber());
addAffectedParty(transaction, IdentifierType.CONTRACT_NUMBER, lookupPhnRequest.getContractNumber());
try {
RPBSPPL0Converter converter = new RPBSPPL0Converter();
RPBSPPL0 r42Request = converter.convertRequest(lookupPhnRequest);
RPBSPPL0 r42Response = eligibilityService.lookupPhn(r42Request, transaction);
LookupPhnResponse lookupPhnResponse = converter.convertResponse(r42Response);
ResponseEntity<LookupPhnResponse> response = ResponseEntity.ok(lookupPhnResponse);
logger.info("lookupPhn response: {} ", lookupPhnResponse);
transactionComplete(transaction);
lookupPhnResponse.getBeneficiaries().forEach(beneficiary -> addAffectedParty(transaction, IdentifierType.PHN, beneficiary.getPhn()));
return response;
} catch (Exception e) {
handleException(transaction, e);
return null;
}
}
Aggregations