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