Search in sources :

Example 1 with R15Converter

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;
    }
}
Also used : R15Converter(ca.bc.gov.hlth.hnweb.converter.hl7v2.R15Converter) CheckEligibilityResponse(ca.bc.gov.hlth.hnweb.model.rest.eligibility.CheckEligibilityResponse) Transaction(ca.bc.gov.hlth.hnweb.persistence.entity.Transaction) Message(ca.uhn.hl7v2.model.Message) R15(ca.bc.gov.hlth.hnweb.model.v2.message.R15) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Aggregations

R15Converter (ca.bc.gov.hlth.hnweb.converter.hl7v2.R15Converter)1 CheckEligibilityResponse (ca.bc.gov.hlth.hnweb.model.rest.eligibility.CheckEligibilityResponse)1 R15 (ca.bc.gov.hlth.hnweb.model.v2.message.R15)1 Transaction (ca.bc.gov.hlth.hnweb.persistence.entity.Transaction)1 Message (ca.uhn.hl7v2.model.Message)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1