Search in sources :

Example 1 with RPBSPPE0Converter

use of ca.bc.gov.hlth.hnweb.converter.rapid.RPBSPPE0Converter in project moh-hnweb by bcgov.

the class EligibilityController method inquirePhn.

/**
 * Inquiries on a list of PHNs.
 * Maps to the legacy R41.
 *
 * @param inquirePhnRequest
 * @return The result of the query
 */
@PostMapping("/inquire-phn")
public ResponseEntity<InquirePhnResponse> inquirePhn(@Valid @RequestBody InquirePhnRequest inquirePhnRequest, HttpServletRequest request) {
    Transaction transaction = transactionStart(request, TransactionType.PHN_INQUIRY);
    inquirePhnRequest.getPhns().forEach(phn -> addAffectedParty(transaction, IdentifierType.PHN, phn));
    try {
        RPBSPPE0Converter converter = new RPBSPPE0Converter();
        RPBSPPE0 ppe0Request = converter.convertRequest(inquirePhnRequest);
        RPBSPPE0 ppe0Response = eligibilityService.inquirePhn(ppe0Request, transaction);
        InquirePhnResponse inquirePhnResponse = converter.convertResponse(ppe0Response);
        ResponseEntity<InquirePhnResponse> response = ResponseEntity.ok(inquirePhnResponse);
        logger.info("inquirePHN response: {} ", inquirePhnResponse);
        transactionComplete(transaction);
        inquirePhnResponse.getBeneficiaries().forEach(beneficiary -> addAffectedParty(transaction, IdentifierType.PHN, beneficiary.getPhn()));
        return response;
    } catch (Exception e) {
        handleException(transaction, e);
        return null;
    }
}
Also used : RPBSPPE0(ca.bc.gov.hlth.hnweb.model.rapid.RPBSPPE0) Transaction(ca.bc.gov.hlth.hnweb.persistence.entity.Transaction) RPBSPPE0Converter(ca.bc.gov.hlth.hnweb.converter.rapid.RPBSPPE0Converter) InquirePhnResponse(ca.bc.gov.hlth.hnweb.model.rest.eligibility.InquirePhnResponse) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Aggregations

RPBSPPE0Converter (ca.bc.gov.hlth.hnweb.converter.rapid.RPBSPPE0Converter)1 RPBSPPE0 (ca.bc.gov.hlth.hnweb.model.rapid.RPBSPPE0)1 InquirePhnResponse (ca.bc.gov.hlth.hnweb.model.rest.eligibility.InquirePhnResponse)1 Transaction (ca.bc.gov.hlth.hnweb.persistence.entity.Transaction)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1