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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations