Search in sources :

Example 1 with GetDemographicsResponse

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

the class EnrollmentController method getPersonDetails.

@PostMapping("/get-person-details")
public ResponseEntity<GetPersonDetailsResponse> getPersonDetails(@Valid @RequestBody GetPersonDetailsRequest personDetailsRequest, HttpServletRequest request) {
    logger.info("Demographic request: {} ", personDetailsRequest.getPhn());
    Transaction transaction = transactionStart(request, TransactionType.GET_PERSON_DETAILS);
    addAffectedParty(transaction, IdentifierType.PHN, personDetailsRequest.getPhn());
    try {
        GetDemographicsConverter converter = new GetDemographicsConverter();
        GetDemographicsRequest demographicsRequest = converter.convertRequest(personDetailsRequest.getPhn());
        GetDemographicsResponse demoGraphicsResponse = enrollmentService.getDemographics(demographicsRequest, transaction);
        GetPersonDetailsResponse personDetailsResponse = converter.convertResponse(demoGraphicsResponse);
        ResponseEntity<GetPersonDetailsResponse> responseEntity = ResponseEntity.ok(personDetailsResponse);
        auditGetPersonSearchComplete(transaction, personDetailsResponse);
        return responseEntity;
    } catch (Exception e) {
        handleException(transaction, e);
        return null;
    }
}
Also used : GetPersonDetailsResponse(ca.bc.gov.hlth.hnweb.model.rest.enrollment.GetPersonDetailsResponse) Transaction(ca.bc.gov.hlth.hnweb.persistence.entity.Transaction) GetDemographicsConverter(ca.bc.gov.hlth.hnweb.converter.hl7v3.GetDemographicsConverter) GetDemographicsRequest(ca.bc.gov.hlth.hnweb.model.v3.GetDemographicsRequest) GetDemographicsResponse(ca.bc.gov.hlth.hnweb.model.v3.GetDemographicsResponse) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 2 with GetDemographicsResponse

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

the class GetDemographicsConverter method buildPersonDetails.

private void buildPersonDetails(GetDemographicsResponse demographicsResponse, GetPersonDetailsResponse personDetailsResponse) {
    Name nameObj = demographicsResponse.getPerson().getDeclaredName();
    if (nameObj == null) {
        nameObj = demographicsResponse.getPerson().getDocumentedName();
    }
    personDetailsResponse.setPhn(demographicsResponse.getPerson().getPhn());
    personDetailsResponse.setGivenName(nameObj.getFirstGivenName());
    personDetailsResponse.setSecondName(nameObj.getSecondGivenName());
    personDetailsResponse.setSurname(nameObj.getSurname());
    String birthDate = V3MessageUtil.convertDateToString(demographicsResponse.getPerson().getBirthDate());
    personDetailsResponse.setDateOfBirth(birthDate);
    personDetailsResponse.setGender(demographicsResponse.getPerson().getGender());
}
Also used : Name(ca.bc.gov.hlth.hnweb.model.v3.Name)

Example 3 with GetDemographicsResponse

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

the class HL7SerializerTest method test_toXML.

@Test
public void test_toXML() 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");
    GetDemographicsRequest getDemoQuery = new GetDemographicsRequest();
    getDemoQuery.setPhn("9862716574");
    Object request = hl7.toXml(getDemoQuery, mmd);
    assertNotNull(request);
    GetDemographicsResponse demographicsResponse = hl7.fromXml(TestUtil.convertXMLFileToString(path), GetDemographicsResponse.class);
    assertEquals("9862716574", demographicsResponse.getPerson().getPhn());
    assertEquals(3, demographicsResponse.getResultCount());
    mockStatic.close();
}
Also used : MessageMetaData(ca.bc.gov.hlth.hnweb.model.v3.MessageMetaData) GetDemographicsRequest(ca.bc.gov.hlth.hnweb.model.v3.GetDemographicsRequest) GetDemographicsResponse(ca.bc.gov.hlth.hnweb.model.v3.GetDemographicsResponse) Test(org.junit.jupiter.api.Test)

Example 4 with GetDemographicsResponse

use of ca.bc.gov.hlth.hnweb.model.v3.GetDemographicsResponse 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;
}
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) GetDemographicsResponse(ca.bc.gov.hlth.hnweb.model.v3.GetDemographicsResponse) UserInfo(ca.bc.gov.hlth.hnweb.security.UserInfo)

Aggregations

GetDemographicsResponse (ca.bc.gov.hlth.hnweb.model.v3.GetDemographicsResponse)3 GetDemographicsRequest (ca.bc.gov.hlth.hnweb.model.v3.GetDemographicsRequest)2 MessageMetaData (ca.bc.gov.hlth.hnweb.model.v3.MessageMetaData)2 GetDemographicsConverter (ca.bc.gov.hlth.hnweb.converter.hl7v3.GetDemographicsConverter)1 HNWebException (ca.bc.gov.hlth.hnweb.exception.HNWebException)1 GetPersonDetailsResponse (ca.bc.gov.hlth.hnweb.model.rest.enrollment.GetPersonDetailsResponse)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