use of ca.bc.gov.hlth.hnweb.serialization.HL7Serializer in project moh-hnweb by bcgov.
the class EnrollmentService method getDemographics.
/**
* Gets the demographic details by sending a V3 message to external endpoint.
* Calls HL7Serializer api to serialize and deserialize request/response
* @param demographicsRequest
* @param transaction
* @return
* @throws HNWebException
*/
public GetDemographicsResponse getDemographics(GetDemographicsRequest demographicsRequest, 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(demographicsRequest, mmd);
// Create soap wrapper
String xmlString = V3MessageUtil.wrap(formattedRequest.toString());
logger.debug("Get Demographics 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 demographics response
GetDemographicsResponse getDemographicsResponse = hl7Serializer.fromXml(response.getBody(), GetDemographicsResponse.class);
messageReceived(transaction, getDemographicsResponse.getMessageIdExtension());
return getDemographicsResponse;
}
use of ca.bc.gov.hlth.hnweb.serialization.HL7Serializer 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