use of ca.bc.gov.hlth.hnweb.converter.hl7v2.R15Converter in project moh-hnweb by bcgov.
the class EligibilityController method checkEligibility.
/**
* Checks eligibility for the PHN for the specified date.
* Maps to the legacy R15.
*
* @param checkEligibilityRequest
* @return The result of the query
*/
@PostMapping("/check-eligibility")
public ResponseEntity<CheckEligibilityResponse> checkEligibility(@Valid @RequestBody CheckEligibilityRequest checkEligibilityRequest, HttpServletRequest request) {
Transaction transaction = transactionStart(request, TransactionType.CHECK_ELIGIBILITY);
addAffectedParty(transaction, IdentifierType.PHN, checkEligibilityRequest.getPhn());
try {
R15Converter converter = new R15Converter(mshDefaults);
R15 r15 = converter.convertRequest(checkEligibilityRequest, transaction.getTransactionId().toString());
Message r15Response = eligibilityService.checkEligibility(r15, transaction);
CheckEligibilityResponse checkEligibilityResponse = converter.convertResponse(r15Response);
ResponseEntity<CheckEligibilityResponse> response = ResponseEntity.ok(checkEligibilityResponse);
logger.info("checkEligibility response: {} ", checkEligibilityResponse);
transactionComplete(transaction);
addAffectedParty(transaction, IdentifierType.PHN, checkEligibilityResponse.getPhn());
return response;
} catch (Exception e) {
handleException(transaction, e);
return null;
}
}
Aggregations