Search in sources :

Example 1 with RPBSPCI0

use of ca.bc.gov.hlth.hnweb.model.rapid.RPBSPCI0 in project moh-hnweb by bcgov.

the class MspContractsController method inquireContract.

/**
 * Get MSP Coverage info for a Personal Health Number (PHN) of a group Inquiry
 * Maps to the legacy R40.
 *
 * Also used by R37 as the results required for R37 are a subset of those returned for Contract Inquiry so it can return the same result. This
 * does not break overall security as currently all roles with permissions for R37(Get Group Member's Contract Address) also have permission
 * for R40(Contract Inquiry).
 *
 * @param contractInquiryRequest
 * @return The result of the operation.
 */
@PostMapping("/inquire-contract")
public ResponseEntity<ContractInquiryResponse> inquireContract(@Valid @RequestBody ContractInquiryRequest contractInquiryRequest, HttpServletRequest request) {
    Transaction transaction = auditContractInquiryStart(contractInquiryRequest, request);
    try {
        RPBSPCI0Converter converter = new RPBSPCI0Converter();
        RPBSPCI0 rpbspci0Request = converter.convertRequest(contractInquiryRequest);
        RPBSPCI0 rpbspci0Response = mspContractsService.inquireContract(rpbspci0Request);
        ContractInquiryResponse contractInquiryResponse = converter.convertResponse(rpbspci0Response);
        ResponseEntity<ContractInquiryResponse> response = ResponseEntity.ok(contractInquiryResponse);
        logger.info("ContractInquiry response: {} ", rpbspci0Response);
        auditContractInquiryEnd(transaction, contractInquiryResponse);
        return response;
    } catch (Exception e) {
        handleException(transaction, e);
        return null;
    }
}
Also used : RPBSPCI0(ca.bc.gov.hlth.hnweb.model.rapid.RPBSPCI0) ContractInquiryResponse(ca.bc.gov.hlth.hnweb.model.rest.mspcontracts.ContractInquiryResponse) Transaction(ca.bc.gov.hlth.hnweb.persistence.entity.Transaction) RPBSPCI0Converter(ca.bc.gov.hlth.hnweb.converter.rapid.RPBSPCI0Converter) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 2 with RPBSPCI0

use of ca.bc.gov.hlth.hnweb.model.rapid.RPBSPCI0 in project moh-hnweb by bcgov.

the class RPBSPCI0Converter method convertRequest.

public RPBSPCI0 convertRequest(ContractInquiryRequest request) {
    RPBSHeader rpbsHeader = new RPBSHeader();
    rpbsHeader.setOrganization(userInfo.getOrganization());
    rpbsHeader.setTranCode(getTranCode());
    CI0 ci0 = new CI0();
    ci0.setPhn(request.getPhn());
    ci0.setGroupNumber(request.getGroupNumber());
    RPBSPCI0 rpbspci0 = new RPBSPCI0();
    rpbspci0.setRpbsHeader(rpbsHeader);
    rpbspci0.setCi0(ci0);
    return rpbspci0;
}
Also used : RPBSPCI0(ca.bc.gov.hlth.hnweb.model.rapid.RPBSPCI0) RPBSHeader(ca.bc.gov.hlth.hnweb.model.rapid.RPBSHeader) CI0(ca.bc.gov.hlth.hnweb.model.rapid.CI0) RPBSPCI0(ca.bc.gov.hlth.hnweb.model.rapid.RPBSPCI0)

Example 3 with RPBSPCI0

use of ca.bc.gov.hlth.hnweb.model.rapid.RPBSPCI0 in project moh-hnweb by bcgov.

the class RPBSPCI0Converter method convertResponse.

public ContractInquiryResponse convertResponse(RPBSPCI0 rpbspci0) {
    ContractInquiryResponse response = new ContractInquiryResponse();
    RPBSHeader header = rpbspci0.getRpbsHeader();
    handleStatus(header, response);
    CI0 ci0 = rpbspci0.getCi0();
    // Populate Person info
    response.setPhn(ci0.getPhn());
    response.setGroupNumber(ci0.getGroupNumber());
    response.setGroupMemberNumber(StringUtils.trim(ci0.getEmployeeNumber()));
    response.setGroupMemberDepartmentNumber(ci0.getDepartmentNumber());
    response.setHomeAddressLine1(StringUtils.trim(ci0.getHomeAddress().getAddressLine1()));
    response.setHomeAddressLine2(StringUtils.trim(ci0.getHomeAddress().getAddressLine2()));
    response.setHomeAddressLine3(StringUtils.trim(ci0.getHomeAddress().getAddressLine3()));
    response.setHomeAddressLine4(StringUtils.trim(ci0.getHomeAddress().getAddressLine4()));
    response.setHomeAddressPostalCode(StringUtils.trim(ci0.getHomeAddress().getPostalCode()));
    response.setMailingAddressLine1(StringUtils.trim(ci0.getMailAddress().getAddressLine1()));
    response.setMailingAddressLine2(StringUtils.trim(ci0.getMailAddress().getAddressLine2()));
    response.setMailingAddressLine3(StringUtils.trim(ci0.getMailAddress().getAddressLine3()));
    response.setMailingAddressLine4(StringUtils.trim(ci0.getMailAddress().getAddressLine4()));
    response.setMailingAddressPostalCode(StringUtils.trim(ci0.getMailAddress().getPostalCode()));
    response.setTelephone(ci0.getPhone().getPhoneAreaCode() + " " + ci0.getPhone().getPhoneNumber());
    for (RPBSCI0Beneficiary rpbsBeneficiary : ci0.getBeneficiary()) {
        ContractInquiryBeneficiary beneficiary = new ContractInquiryBeneficiary();
        beneficiary.setPhn(rpbsBeneficiary.getPhn());
        beneficiary.setFamilyName(StringUtils.trim(rpbsBeneficiary.getFamilyName()));
        beneficiary.setFirstName(StringUtils.trim(rpbsBeneficiary.getFirstName()));
        beneficiary.setSecondName(StringUtils.trim(rpbsBeneficiary.getSecondName()));
        beneficiary.setThirdName(StringUtils.trim(rpbsBeneficiary.getThirdName()));
        beneficiary.setBirthDate(convertDate(rpbsBeneficiary.getBirthDate()));
        beneficiary.setEffectiveDate(convertDate(rpbsBeneficiary.getEffectiveDate()));
        beneficiary.setCancelDate(StringUtils.equals(ZERO_DATE, rpbsBeneficiary.getCancelDate()) ? null : convertDate(rpbsBeneficiary.getCancelDate()));
        beneficiary.setGender(rpbsBeneficiary.getGender());
        beneficiary.setCancelReason(rpbsBeneficiary.getCancelReason());
        beneficiary.setStudentStatus(rpbsBeneficiary.getStudentStatus());
        beneficiary.setRelationshipCode(rpbsBeneficiary.getRelationshipCode());
        response.getContractInquiryBeneficiaries().add(beneficiary);
    }
    return response;
}
Also used : ContractInquiryResponse(ca.bc.gov.hlth.hnweb.model.rest.mspcontracts.ContractInquiryResponse) ContractInquiryBeneficiary(ca.bc.gov.hlth.hnweb.model.rest.mspcontracts.ContractInquiryBeneficiary) RPBSHeader(ca.bc.gov.hlth.hnweb.model.rapid.RPBSHeader) RPBSCI0Beneficiary(ca.bc.gov.hlth.hnweb.model.rapid.RPBSCI0Beneficiary) CI0(ca.bc.gov.hlth.hnweb.model.rapid.CI0) RPBSPCI0(ca.bc.gov.hlth.hnweb.model.rapid.RPBSPCI0)

Example 4 with RPBSPCI0

use of ca.bc.gov.hlth.hnweb.model.rapid.RPBSPCI0 in project moh-hnweb by bcgov.

the class MspContractsService method inquireContract.

/**
 * Get MSP Coverage info for a Personal Health Number (PHN) of a group(GroupNumber) Inquiry based on the R40/RPBSPCI0 request.
 * @param rpbspci0
 * @return
 * @throws HNWebException
 */
public RPBSPCI0 inquireContract(RPBSPCI0 rpbspci0) throws HNWebException {
    String rpbspci0Str = rpbspci0.serialize();
    logger.info("Request:\n{}", rpbspci0Str);
    ResponseEntity<String> response = postRapidRequest(r40Path, rpbspci0Str);
    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);
    }
    RPBSPCI0 rpbspci0Response = new RPBSPCI0(response.getBody());
    return rpbspci0Response;
}
Also used : RPBSPCI0(ca.bc.gov.hlth.hnweb.model.rapid.RPBSPCI0) HNWebException(ca.bc.gov.hlth.hnweb.exception.HNWebException)

Aggregations

RPBSPCI0 (ca.bc.gov.hlth.hnweb.model.rapid.RPBSPCI0)4 CI0 (ca.bc.gov.hlth.hnweb.model.rapid.CI0)2 RPBSHeader (ca.bc.gov.hlth.hnweb.model.rapid.RPBSHeader)2 ContractInquiryResponse (ca.bc.gov.hlth.hnweb.model.rest.mspcontracts.ContractInquiryResponse)2 RPBSPCI0Converter (ca.bc.gov.hlth.hnweb.converter.rapid.RPBSPCI0Converter)1 HNWebException (ca.bc.gov.hlth.hnweb.exception.HNWebException)1 RPBSCI0Beneficiary (ca.bc.gov.hlth.hnweb.model.rapid.RPBSCI0Beneficiary)1 ContractInquiryBeneficiary (ca.bc.gov.hlth.hnweb.model.rest.mspcontracts.ContractInquiryBeneficiary)1 Transaction (ca.bc.gov.hlth.hnweb.persistence.entity.Transaction)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1