Search in sources :

Example 1 with RPBSPPL0Converter

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;
    }
}
Also used : Transaction(ca.bc.gov.hlth.hnweb.persistence.entity.Transaction) LookupPhnResponse(ca.bc.gov.hlth.hnweb.model.rest.eligibility.LookupPhnResponse) RPBSPPL0(ca.bc.gov.hlth.hnweb.model.rapid.RPBSPPL0) RPBSPPL0Converter(ca.bc.gov.hlth.hnweb.converter.rapid.RPBSPPL0Converter) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Aggregations

RPBSPPL0Converter (ca.bc.gov.hlth.hnweb.converter.rapid.RPBSPPL0Converter)1 RPBSPPL0 (ca.bc.gov.hlth.hnweb.model.rapid.RPBSPPL0)1 LookupPhnResponse (ca.bc.gov.hlth.hnweb.model.rest.eligibility.LookupPhnResponse)1 Transaction (ca.bc.gov.hlth.hnweb.persistence.entity.Transaction)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1