Search in sources :

Example 1 with FindCandidatesRequest

use of ca.bc.gov.hlth.hnweb.model.v3.FindCandidatesRequest in project moh-hnweb by bcgov.

the class HL7SerializerTest method test_findCandidate.

@Test
public void test_findCandidate() throws Exception {
    HL7Config hl7Config = new HL7Config();
    HL7Serializer hl7 = new HL7Serializer(hl7Config);
    MessageMetaData mmd = new MessageMetaData("testId");
    mmd.setDataEntererExt("train96");
    mmd.setOrganization("HOOPC");
    mmd.setSourceSystemOverride("BCHCIM");
    FindCandidatesRequest getDemoQuery = new FindCandidatesRequest();
    getDemoQuery.setSurname("Purple");
    getDemoQuery.setFirstGivenName("Barney");
    getDemoQuery.setBirthDate("19400101");
    Object request = hl7.toXml(getDemoQuery, mmd);
    assertNotNull(request);
    FindCandidatesResponse demographicsResponse = hl7.fromXml(TestUtil.convertXMLFileToString(path1), FindCandidatesResponse.class);
    assertEquals("9999999999", demographicsResponse.getResults().get(0).getPerson().getPhn());
    assertEquals(3, demographicsResponse.getResultCount());
}
Also used : MessageMetaData(ca.bc.gov.hlth.hnweb.model.v3.MessageMetaData) FindCandidatesRequest(ca.bc.gov.hlth.hnweb.model.v3.FindCandidatesRequest) FindCandidatesResponse(ca.bc.gov.hlth.hnweb.model.v3.FindCandidatesResponse) Test(org.junit.jupiter.api.Test)

Example 2 with FindCandidatesRequest

use of ca.bc.gov.hlth.hnweb.model.v3.FindCandidatesRequest in project moh-hnweb by bcgov.

the class FindCandidatesConverter method convertRequest.

public FindCandidatesRequest convertRequest(NameSearchRequest nameSearchRequest) {
    logger.debug("Find Candidates for Name: [{}] DOB: [{}]", nameSearchRequest.getSurname() + nameSearchRequest.getGivenName(), nameSearchRequest.getDateOfBirth());
    FindCandidatesRequest findCandidatesRequest = new FindCandidatesRequest();
    Name name = new Name();
    name.setSurname(nameSearchRequest.getSurname());
    name.setFirstGivenName(nameSearchRequest.getGivenName());
    name.setSecondGivenName(nameSearchRequest.getSecondName());
    findCandidatesRequest.setName(name);
    findCandidatesRequest.setBirthDate(V3MessageUtil.dateOnlyFormatter.format(nameSearchRequest.getDateOfBirth()));
    findCandidatesRequest.setGender(nameSearchRequest.getGender());
    return findCandidatesRequest;
}
Also used : FindCandidatesRequest(ca.bc.gov.hlth.hnweb.model.v3.FindCandidatesRequest) Name(ca.bc.gov.hlth.hnweb.model.v3.Name)

Example 3 with FindCandidatesRequest

use of ca.bc.gov.hlth.hnweb.model.v3.FindCandidatesRequest in project moh-hnweb by bcgov.

the class EnrollmentController method getNameSearch.

@PostMapping("/name-search")
public ResponseEntity<NameSearchResponse> getNameSearch(@Valid @RequestBody NameSearchRequest nameSearchRequest, HttpServletRequest request) {
    logger.info("Name Search request: {} ", nameSearchRequest.getGivenName());
    Transaction transaction = transactionStart(request, TransactionType.NAME_SEARCH);
    try {
        FindCandidatesConverter converter = new FindCandidatesConverter();
        FindCandidatesRequest findCandidatesRequest = converter.convertRequest(nameSearchRequest);
        FindCandidatesResponse findCandidatesResponse = enrollmentService.findCandidates(findCandidatesRequest, transaction);
        NameSearchResponse nameSearchResponse = converter.convertResponse(findCandidatesResponse);
        ResponseEntity<NameSearchResponse> responseEntity = ResponseEntity.ok(nameSearchResponse);
        auditGetNameSearchComplete(transaction, nameSearchResponse);
        return responseEntity;
    } catch (Exception e) {
        handleException(transaction, e);
        return null;
    }
}
Also used : Transaction(ca.bc.gov.hlth.hnweb.persistence.entity.Transaction) NameSearchResponse(ca.bc.gov.hlth.hnweb.model.rest.enrollment.NameSearchResponse) FindCandidatesRequest(ca.bc.gov.hlth.hnweb.model.v3.FindCandidatesRequest) FindCandidatesResponse(ca.bc.gov.hlth.hnweb.model.v3.FindCandidatesResponse) FindCandidatesConverter(ca.bc.gov.hlth.hnweb.converter.hl7v3.FindCandidatesConverter) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 4 with FindCandidatesRequest

use of ca.bc.gov.hlth.hnweb.model.v3.FindCandidatesRequest in project moh-hnweb by bcgov.

the class EnrollmentService method findCandidates.

/**
 * Finds the candidates details by sending a V3 message to external endpoint.
 * Calls HL7Serializer api to serialize and deserialize request/response
 * @param findCandidatesRequest
 * @param transaction
 * @return
 * @throws HNWebException
 */
public FindCandidatesResponse findCandidates(FindCandidatesRequest findCandidatesRequest, Transaction transaction) throws HNWebException {
    HL7Serializer hl7Serializer = new HL7Serializer(new HL7Config());
    UserInfo userInfo = SecurityUtil.loadUserInfo();
    MessageMetaData mmd = new MessageMetaData(userInfo.getUsername(), SOURCE_SYSTEM_OVERRIDE, ORGANIZATION, transaction.getTransactionId().toString());
    // Serialize request object
    Object formattedRequest = hl7Serializer.toXml(findCandidatesRequest, mmd);
    // Create soap wrapper
    String xmlString = V3MessageUtil.wrap(formattedRequest.toString());
    logger.debug("Get Name Search wrapped xml request[{}]", xmlString);
    messageSent(transaction, mmd.getMessageIdExt());
    ResponseEntity<String> response = postHcimRequest(xmlString, transaction.getTransactionId().toString());
    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);
    }
    // De-Serialize findCandidate response
    FindCandidatesResponse findCandidatesResponse = hl7Serializer.fromXml(response.getBody(), FindCandidatesResponse.class);
    messageReceived(transaction, findCandidatesResponse.getMessageIdExtension());
    return findCandidatesResponse;
}
Also used : MessageMetaData(ca.bc.gov.hlth.hnweb.model.v3.MessageMetaData) HL7Serializer(ca.bc.gov.hlth.hnweb.serialization.HL7Serializer) HNWebException(ca.bc.gov.hlth.hnweb.exception.HNWebException) HL7Config(ca.bc.gov.hlth.hnweb.serialization.HL7Config) UserInfo(ca.bc.gov.hlth.hnweb.security.UserInfo) FindCandidatesResponse(ca.bc.gov.hlth.hnweb.model.v3.FindCandidatesResponse)

Aggregations

FindCandidatesRequest (ca.bc.gov.hlth.hnweb.model.v3.FindCandidatesRequest)3 FindCandidatesResponse (ca.bc.gov.hlth.hnweb.model.v3.FindCandidatesResponse)3 MessageMetaData (ca.bc.gov.hlth.hnweb.model.v3.MessageMetaData)2 FindCandidatesConverter (ca.bc.gov.hlth.hnweb.converter.hl7v3.FindCandidatesConverter)1 HNWebException (ca.bc.gov.hlth.hnweb.exception.HNWebException)1 NameSearchResponse (ca.bc.gov.hlth.hnweb.model.rest.enrollment.NameSearchResponse)1 Name (ca.bc.gov.hlth.hnweb.model.v3.Name)1 Transaction (ca.bc.gov.hlth.hnweb.persistence.entity.Transaction)1 UserInfo (ca.bc.gov.hlth.hnweb.security.UserInfo)1 HL7Config (ca.bc.gov.hlth.hnweb.serialization.HL7Config)1 HL7Serializer (ca.bc.gov.hlth.hnweb.serialization.HL7Serializer)1 Test (org.junit.jupiter.api.Test)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1