Search in sources :

Example 1 with HNWebException

use of ca.bc.gov.hlth.hnweb.exception.HNWebException in project moh-hnweb by bcgov.

the class MspContractsService method getContractPeriods.

/**
 * Get Contracts Periods for a Personal Health Number (PHN) Inquiry based on the R32/RPBSPMC0 request.
 *
 * @param rpbspmc0
 * @return The {@link RPBSPMC0} response.
 * @throws HNWebException
 */
public RPBSPMC0 getContractPeriods(RPBSPMC0 rpbspmc0, Transaction transaction) throws HNWebException {
    String rpbspmc0Str = rpbspmc0.serialize();
    logger.info("Request:\n{}", rpbspmc0Str);
    messageSent(transaction);
    ResponseEntity<String> response = postRapidRequest(r32Path, rpbspmc0Str);
    messageReceived(transaction);
    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);
    }
    RPBSPMC0 rpbsmc0Response = new RPBSPMC0(response.getBody());
    return rpbsmc0Response;
}
Also used : RPBSPMC0(ca.bc.gov.hlth.hnweb.model.rapid.RPBSPMC0) HNWebException(ca.bc.gov.hlth.hnweb.exception.HNWebException)

Example 2 with HNWebException

use of ca.bc.gov.hlth.hnweb.exception.HNWebException in project moh-hnweb by bcgov.

the class EligibilityService method checkMspCoverageStatus.

/**
 * Checks for MSP Coverage Status based on the E45 request.
 *
 * @param e45
 * @return The E45 response.
 * @throws HNWebException
 * @throws HL7Exception
 */
public Message checkMspCoverageStatus(E45 e45, Transaction transaction) throws HNWebException, HL7Exception {
    String e45v2 = parser.encode(e45);
    messageSent(transaction, V2MessageUtil.getMessageID(e45));
    ResponseEntity<String> response = postHibcRequest(e45Path, e45Username, e45Password, e45v2);
    if (response.getStatusCode() != HttpStatus.OK) {
        logger.error("Could not connect to downstream service. Service returned {}", response.getStatusCode());
        throw new HNWebException(ExceptionType.DOWNSTREAM_FAILURE);
    }
    Message v2Response = parseResponse(response.getBody(), "E45");
    messageReceived(transaction, V2MessageUtil.getMessageID(v2Response));
    return v2Response;
}
Also used : HNWebException(ca.bc.gov.hlth.hnweb.exception.HNWebException) Message(ca.uhn.hl7v2.model.Message)

Example 3 with HNWebException

use of ca.bc.gov.hlth.hnweb.exception.HNWebException in project moh-hnweb by bcgov.

the class EligibilityService method checkEligibility.

/**
 * Checks for subject eligibility based on the R15 request.
 *
 * @param r15
 * @return The R15 response.
 * @throws HNWebException
 * @throws HL7Exception
 */
public Message checkEligibility(R15 r15, Transaction transaction) throws HNWebException, HL7Exception {
    String r15v2 = parser.encode(r15);
    messageSent(transaction, V2MessageUtil.getMessageID(r15));
    ResponseEntity<String> response = postHibcRequest(r15Path, r15Username, r15Password, r15v2);
    if (response.getStatusCode() != HttpStatus.OK) {
        logger.error("Could not connect to downstream service. Service returned {}", response.getStatusCode());
        throw new HNWebException(ExceptionType.DOWNSTREAM_FAILURE);
    }
    Message v2Response = parseResponse(response.getBody(), "R15");
    messageReceived(transaction, V2MessageUtil.getMessageID(v2Response));
    return v2Response;
}
Also used : HNWebException(ca.bc.gov.hlth.hnweb.exception.HNWebException) Message(ca.uhn.hl7v2.model.Message)

Example 4 with HNWebException

use of ca.bc.gov.hlth.hnweb.exception.HNWebException in project moh-hnweb by bcgov.

the class EnrollmentService method enrollSubscriber.

/**
 * Enrolls a subscriber by sending a HL7 V2 message to external enrollment service. It was the R50 message to create a V2 String and sends this
 * over Https using TLS. The endpoint also requires Basic Authentication.
 *
 * @param r50
 * @param transaction
 * @return
 * @throws HL7Exception
 * @throws IOException
 */
public Message enrollSubscriber(R50 r50, Transaction transaction) throws HNWebException, HL7Exception {
    logger.debug("Enroll subscriber for Message ID [{}]; Transaction ID [{}]", r50.getMSH().getMsh10_MessageControlID(), transaction.getTransactionId().toString());
    String r50v2RequiredFormat = formatMessage(r50);
    logger.debug("Updated V2 message:\n{}", r50v2RequiredFormat);
    messageSent(transaction, V2MessageUtil.getMessageID(r50));
    ResponseEntity<String> response = postHibcRequest(r50Path, r50Username, r50Password, r50v2RequiredFormat);
    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);
    }
    Message v2Response = parseR50v2ToAck(response.getBody());
    messageReceived(transaction, V2MessageUtil.getMessageID(v2Response));
    return v2Response;
}
Also used : HNWebException(ca.bc.gov.hlth.hnweb.exception.HNWebException) Message(ca.uhn.hl7v2.model.Message)

Example 5 with HNWebException

use of ca.bc.gov.hlth.hnweb.exception.HNWebException in project moh-hnweb by bcgov.

the class GroupMemberService method cancelDependent.

/**
 * Cancels the group member's dependent coverage based on the R36/RPBSPWP0.
 *
 * @param rpbspwp0
 * @return The RPBSPWP0 response.
 * @throws HNWebException
 */
public RPBSPWP0 cancelDependent(RPBSPWP0 rpbspwp0, Transaction transaction) throws HNWebException {
    String rpbspwp0Str = rpbspwp0.serialize();
    logger.info("Request {}", rpbspwp0Str);
    messageSent(transaction);
    ResponseEntity<String> response = postRapidRequest(r36Path, rpbspwp0Str);
    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);
    }
    RPBSPWP0 rpbspwp0Response = new RPBSPWP0(response.getBody());
    return rpbspwp0Response;
}
Also used : HNWebException(ca.bc.gov.hlth.hnweb.exception.HNWebException) RPBSPWP0(ca.bc.gov.hlth.hnweb.model.rapid.RPBSPWP0)

Aggregations

HNWebException (ca.bc.gov.hlth.hnweb.exception.HNWebException)17 Message (ca.uhn.hl7v2.model.Message)3 MessageMetaData (ca.bc.gov.hlth.hnweb.model.v3.MessageMetaData)2 UserInfo (ca.bc.gov.hlth.hnweb.security.UserInfo)2 HL7Config (ca.bc.gov.hlth.hnweb.serialization.HL7Config)2 HL7Serializer (ca.bc.gov.hlth.hnweb.serialization.HL7Serializer)2 KeyManagerFactory (javax.net.ssl.KeyManagerFactory)2 TrustManagerFactory (javax.net.ssl.TrustManagerFactory)2 ExceptionType (ca.bc.gov.hlth.hnweb.exception.ExceptionType)1 RPBSPCI0 (ca.bc.gov.hlth.hnweb.model.rapid.RPBSPCI0)1 RPBSPED0 (ca.bc.gov.hlth.hnweb.model.rapid.RPBSPED0)1 RPBSPEE0 (ca.bc.gov.hlth.hnweb.model.rapid.RPBSPEE0)1 RPBSPMC0 (ca.bc.gov.hlth.hnweb.model.rapid.RPBSPMC0)1 RPBSPWB0 (ca.bc.gov.hlth.hnweb.model.rapid.RPBSPWB0)1 RPBSPWC0 (ca.bc.gov.hlth.hnweb.model.rapid.RPBSPWC0)1 RPBSPWP0 (ca.bc.gov.hlth.hnweb.model.rapid.RPBSPWP0)1 RPBSPXP0 (ca.bc.gov.hlth.hnweb.model.rapid.RPBSPXP0)1 FindCandidatesResponse (ca.bc.gov.hlth.hnweb.model.v3.FindCandidatesResponse)1 GetDemographicsResponse (ca.bc.gov.hlth.hnweb.model.v3.GetDemographicsResponse)1 EventMessage (ca.bc.gov.hlth.hnweb.persistence.entity.EventMessage)1