Search in sources :

Example 6 with PatientMigrationRequest

use of uk.nhs.adaptors.connector.model.PatientMigrationRequest in project nia-patient-switching-standard-adaptor by NHSDigital.

the class EhrExtractMessageHandlerTest method When_HandleMessage_WithStoreAttachmentsThrows_Expect_InlineAttachmentProcessingException.

@Test
public void When_HandleMessage_WithStoreAttachmentsThrows_Expect_InlineAttachmentProcessingException() throws JAXBException, InlineAttachmentProcessingException {
    InboundMessage inboundMessage = new InboundMessage();
    Bundle bundle = new Bundle();
    bundle.setId("Test");
    inboundMessage.setPayload(readInboundMessagePayloadFromFile());
    inboundMessage.setAttachments(new ArrayList<>());
    PatientMigrationRequest migrationRequest = PatientMigrationRequest.builder().losingPracticeOdsCode(LOSING_ODE_CODE).winningPracticeOdsCode(WINNING_ODE_CODE).build();
    when(migrationRequestDao.getMigrationRequest(CONVERSATION_ID)).thenReturn(migrationRequest);
    doThrow(new InlineAttachmentProcessingException("Test Exception")).when(attachmentHandlerService).storeAttachments(any(), any());
    assertThrows(InlineAttachmentProcessingException.class, () -> ehrExtractMessageHandler.handleMessage(inboundMessage, CONVERSATION_ID));
}
Also used : PatientMigrationRequest(uk.nhs.adaptors.connector.model.PatientMigrationRequest) Bundle(org.hl7.fhir.dstu3.model.Bundle) InboundMessage(uk.nhs.adaptors.pss.translator.mhs.model.InboundMessage) InlineAttachmentProcessingException(uk.nhs.adaptors.pss.translator.exception.InlineAttachmentProcessingException) Test(org.junit.jupiter.api.Test)

Example 7 with PatientMigrationRequest

use of uk.nhs.adaptors.connector.model.PatientMigrationRequest in project nia-patient-switching-standard-adaptor by NHSDigital.

the class EhrExtractMessageHandlerTest method prepareMigrationRequestAndMigrationStatusMocks.

@SneakyThrows
private void prepareMigrationRequestAndMigrationStatusMocks() {
    PatientMigrationRequest migrationRequest = PatientMigrationRequest.builder().losingPracticeOdsCode(LOSING_ODE_CODE).winningPracticeOdsCode(WINNING_ODE_CODE).build();
    MigrationStatusLog migrationStatusLog = MigrationStatusLog.builder().date(OffsetDateTime.ofInstant(Instant.now(), ZoneId.systemDefault())).build();
    when(migrationRequestDao.getMigrationRequest(CONVERSATION_ID)).thenReturn(migrationRequest);
    when(migrationStatusLogService.getLatestMigrationStatusLog(CONVERSATION_ID)).thenReturn(migrationStatusLog);
}
Also used : PatientMigrationRequest(uk.nhs.adaptors.connector.model.PatientMigrationRequest) MigrationStatusLog(uk.nhs.adaptors.connector.model.MigrationStatusLog) SneakyThrows(lombok.SneakyThrows)

Example 8 with PatientMigrationRequest

use of uk.nhs.adaptors.connector.model.PatientMigrationRequest in project nia-patient-switching-standard-adaptor by NHSDigital.

the class EhrExtractMessageHandlerTest method When_HandleMessage_WithMapToBundleThrows_Expect_BundleMappingException.

@Test
public void When_HandleMessage_WithMapToBundleThrows_Expect_BundleMappingException() throws BundleMappingException, AttachmentNotFoundException, ValidationException, InlineAttachmentProcessingException {
    InboundMessage inboundMessage = new InboundMessage();
    inboundMessage.setPayload(readInboundMessagePayloadFromFile());
    inboundMessage.setExternalAttachments(new ArrayList<>());
    PatientMigrationRequest migrationRequest = PatientMigrationRequest.builder().losingPracticeOdsCode(LOSING_ODE_CODE).winningPracticeOdsCode(WINNING_ODE_CODE).build();
    when(migrationRequestDao.getMigrationRequest(CONVERSATION_ID)).thenReturn(migrationRequest);
    when(attachmentReferenceUpdaterService.updateReferenceToAttachment(inboundMessage.getAttachments(), CONVERSATION_ID, inboundMessage.getPayload())).thenReturn(inboundMessage.getPayload());
    doThrow(new BundleMappingException("Test Exception")).when(bundleMapperService).mapToBundle(any(RCMRIN030000UK06Message.class), any());
    assertThrows(BundleMappingException.class, () -> ehrExtractMessageHandler.handleMessage(inboundMessage, CONVERSATION_ID));
}
Also used : PatientMigrationRequest(uk.nhs.adaptors.connector.model.PatientMigrationRequest) InboundMessage(uk.nhs.adaptors.pss.translator.mhs.model.InboundMessage) BundleMappingException(uk.nhs.adaptors.pss.translator.exception.BundleMappingException) RCMRIN030000UK06Message(org.hl7.v3.RCMRIN030000UK06Message) Test(org.junit.jupiter.api.Test)

Example 9 with PatientMigrationRequest

use of uk.nhs.adaptors.connector.model.PatientMigrationRequest in project nia-patient-switching-standard-adaptor by NHSDigital.

the class EHRTimeoutHandlerTest method When_CheckForTimeouts_WithSdsRetrievalException_Expect_MigrationLogNotUpdated.

@Test
public void When_CheckForTimeouts_WithSdsRetrievalException_Expect_MigrationLogNotUpdated() {
    List<PatientMigrationRequest> requests = List.of(mockRequest);
    when(migrationRequestService.getMigrationRequestByCurrentMigrationStatus(EHR_EXTRACT_TRANSLATED)).thenReturn(requests);
    when(persistDurationService.getPersistDurationFor(any(), eq(EHR_EXTRACT_MESSAGE_NAME))).thenThrow(new SdsRetrievalException("Test exception"));
    ehrTimeoutHandler.checkForTimeouts();
    verify(migrationStatusLogService, times(0)).addMigrationStatusLog(any(), any());
}
Also used : PatientMigrationRequest(uk.nhs.adaptors.connector.model.PatientMigrationRequest) SdsRetrievalException(uk.nhs.adaptors.pss.translator.exception.SdsRetrievalException) Test(org.junit.jupiter.api.Test)

Example 10 with PatientMigrationRequest

use of uk.nhs.adaptors.connector.model.PatientMigrationRequest in project nia-patient-switching-standard-adaptor by NHSDigital.

the class PatientTransferService method getBundleResource.

public String getBundleResource() {
    var conversationId = mdcService.getConversationId();
    PatientMigrationRequest patientMigrationRequest = patientMigrationRequestDao.getMigrationRequest(conversationId);
    return patientMigrationRequest.getBundleResource();
}
Also used : PatientMigrationRequest(uk.nhs.adaptors.connector.model.PatientMigrationRequest)

Aggregations

PatientMigrationRequest (uk.nhs.adaptors.connector.model.PatientMigrationRequest)13 Test (org.junit.jupiter.api.Test)5 InlineAttachmentProcessingException (uk.nhs.adaptors.pss.translator.exception.InlineAttachmentProcessingException)5 InboundMessage (uk.nhs.adaptors.pss.translator.mhs.model.InboundMessage)5 RCMRIN030000UK06Message (org.hl7.v3.RCMRIN030000UK06Message)4 SAXException (org.xml.sax.SAXException)4 BundleMappingException (uk.nhs.adaptors.pss.translator.exception.BundleMappingException)4 XmlUnmarshallUtil.unmarshallString (uk.nhs.adaptors.pss.translator.util.XmlUnmarshallUtil.unmarshallString)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 ParseException (java.text.ParseException)3 ValidationException (javax.xml.bind.ValidationException)3 Document (org.w3c.dom.Document)3 MigrationStatusLog (uk.nhs.adaptors.connector.model.MigrationStatusLog)3 PatientAttachmentLog (uk.nhs.adaptors.connector.model.PatientAttachmentLog)3 AttachmentNotFoundException (uk.nhs.adaptors.pss.translator.exception.AttachmentNotFoundException)3 DataFormatException (ca.uhn.fhir.parser.DataFormatException)2 JAXBException (javax.xml.bind.JAXBException)2 Bundle (org.hl7.fhir.dstu3.model.Bundle)2 COPCIN000001UK01Message (org.hl7.v3.COPCIN000001UK01Message)2 ArrayList (java.util.ArrayList)1