Search in sources :

Example 6 with MigrationStatusLog

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

the class PatientTransferServiceTest method handlePatientMigrationRequestWhenRequestIsNew.

@Test
public void handlePatientMigrationRequestWhenRequestIsNew() {
    var expectedPssQueueMessage = TransferRequestMessage.builder().conversationId(CONVERSATION_ID).patientNhsNumber(PATIENT_NHS_NUMBER).toAsid(HEADERS.get(TO_ASID)).fromAsid(HEADERS.get(FROM_ASID)).toOds(HEADERS.get(TO_ODS)).fromOds(HEADERS.get(FROM_ODS)).build();
    var migrationRequestId = 1;
    OffsetDateTime now = OffsetDateTime.now();
    when(dateUtils.getCurrentOffsetDateTime()).thenReturn(now);
    when(patientMigrationRequestDao.getMigrationRequest(CONVERSATION_ID)).thenReturn(null);
    when(patientMigrationRequestDao.getMigrationRequestId(CONVERSATION_ID)).thenReturn(migrationRequestId);
    when(mdcService.getConversationId()).thenReturn(CONVERSATION_ID);
    MigrationStatusLog patientMigrationRequest = service.handlePatientMigrationRequest(parameters, HEADERS);
    assertThat(patientMigrationRequest).isEqualTo(null);
    verify(pssQueuePublisher).sendToPssQueue(expectedPssQueueMessage);
    verify(patientMigrationRequestDao).addNewRequest(PATIENT_NHS_NUMBER, CONVERSATION_ID, LOSING_ODS_CODE, WINNING_ODS_CODE);
    verify(migrationStatusLogDao).addMigrationStatusLog(MigrationStatus.REQUEST_RECEIVED, now, migrationRequestId);
}
Also used : OffsetDateTime(java.time.OffsetDateTime) MigrationStatusLog(uk.nhs.adaptors.connector.model.MigrationStatusLog) Test(org.junit.jupiter.api.Test)

Aggregations

MigrationStatusLog (uk.nhs.adaptors.connector.model.MigrationStatusLog)6 PatientMigrationRequest (uk.nhs.adaptors.connector.model.PatientMigrationRequest)3 Test (org.junit.jupiter.api.Test)2 InboundMessage (uk.nhs.adaptors.pss.translator.mhs.model.InboundMessage)2 DataFormatException (ca.uhn.fhir.parser.DataFormatException)1 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ParseException (java.text.ParseException)1 OffsetDateTime (java.time.OffsetDateTime)1 SneakyThrows (lombok.SneakyThrows)1 RCMRIN030000UK06Message (org.hl7.v3.RCMRIN030000UK06Message)1 ResponseEntity (org.springframework.http.ResponseEntity)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1 Document (org.w3c.dom.Document)1 SAXException (org.xml.sax.SAXException)1 PatientAttachmentLog (uk.nhs.adaptors.connector.model.PatientAttachmentLog)1 AttachmentNotFoundException (uk.nhs.adaptors.pss.translator.exception.AttachmentNotFoundException)1 BundleMappingException (uk.nhs.adaptors.pss.translator.exception.BundleMappingException)1 InlineAttachmentProcessingException (uk.nhs.adaptors.pss.translator.exception.InlineAttachmentProcessingException)1 StorageException (uk.nhs.adaptors.pss.translator.storage.StorageException)1 XmlUnmarshallUtil.unmarshallString (uk.nhs.adaptors.pss.translator.util.XmlUnmarshallUtil.unmarshallString)1