Search in sources :

Example 11 with LogRequest

use of se.inera.intyg.webcert.web.service.log.dto.LogRequest in project webcert by sklintyg.

the class LogMessagePopulatorImplTest method buildLogRequest.

private LogRequest buildLogRequest(String additionalInfo) {
    LogRequest logRequest = new LogRequest();
    logRequest.setPatientId(Personnummer.createPersonnummer("19121212-1212").get());
    logRequest.setAdditionalInfo(additionalInfo);
    return logRequest;
}
Also used : LogRequest(se.inera.intyg.webcert.web.service.log.dto.LogRequest)

Example 12 with LogRequest

use of se.inera.intyg.webcert.web.service.log.dto.LogRequest in project webcert by sklintyg.

the class LogRequestFactoryTest method testCreateLogRequestFromUtkastCoherentJournaling.

@Test
public void testCreateLogRequestFromUtkastCoherentJournaling() {
    final String intygsId = "intygsId";
    Utkast utkast = new Utkast();
    utkast.setIntygsId(intygsId);
    utkast.setIntygsTyp("ts-bas");
    utkast.setPatientPersonnummer(patientPersonnummer);
    LogRequest res = LogRequestFactory.createLogRequestFromUtkast(utkast, true);
    assertNotNull(res);
    assertEquals(intygsId, res.getIntygId());
    assertEquals("Läsning i enlighet med sammanhållen journalföring", res.getAdditionalInfo());
}
Also used : LogRequest(se.inera.intyg.webcert.web.service.log.dto.LogRequest) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) Test(org.junit.Test)

Example 13 with LogRequest

use of se.inera.intyg.webcert.web.service.log.dto.LogRequest in project webcert by sklintyg.

the class LogRequestFactoryTest method testCreateLogRequestFromUtlatandeCoherentJournaling.

@Test
public void testCreateLogRequestFromUtlatandeCoherentJournaling() {
    final String intygsId = "intygsId";
    Utlatande utlatande = mock(Utlatande.class);
    GrundData grundData = new GrundData();
    grundData.setPatient(new Patient());
    grundData.setSkapadAv(new HoSPersonal());
    grundData.getSkapadAv().setVardenhet(new Vardenhet());
    grundData.getSkapadAv().getVardenhet().setVardgivare(new Vardgivare());
    when(utlatande.getId()).thenReturn(intygsId);
    when(utlatande.getTyp()).thenReturn("ts-bas");
    when(utlatande.getGrundData()).thenReturn(grundData);
    LogRequest res = LogRequestFactory.createLogRequestFromUtlatande(utlatande, true);
    assertNotNull(res);
    assertEquals(intygsId, res.getIntygId());
    assertEquals("Läsning i enlighet med sammanhållen journalföring", res.getAdditionalInfo());
}
Also used : LogRequest(se.inera.intyg.webcert.web.service.log.dto.LogRequest) Test(org.junit.Test)

Example 14 with LogRequest

use of se.inera.intyg.webcert.web.service.log.dto.LogRequest in project webcert by sklintyg.

the class LogRequestFactoryTest method testCreateLogRequestFromUtlatande.

@Test
public void testCreateLogRequestFromUtlatande() {
    final String patientNamn = Arrays.asList(patientFornamn, patientMellannamn, patientEfternamn).stream().collect(Collectors.joining(" "));
    Utlatande utlatande = mock(Utlatande.class);
    GrundData grundData = new GrundData();
    grundData.setPatient(new Patient());
    grundData.getPatient().setPersonId(patientPersonnummer);
    grundData.getPatient().setFullstandigtNamn(patientNamn);
    grundData.setSkapadAv(new HoSPersonal());
    grundData.getSkapadAv().setVardenhet(new Vardenhet());
    grundData.getSkapadAv().getVardenhet().setEnhetsid(enhetsid);
    grundData.getSkapadAv().getVardenhet().setEnhetsnamn(enhetsnamn);
    grundData.getSkapadAv().getVardenhet().setVardgivare(new Vardgivare());
    grundData.getSkapadAv().getVardenhet().getVardgivare().setVardgivarid(vardgivarid);
    grundData.getSkapadAv().getVardenhet().getVardgivare().setVardgivarnamn(vardgivarnamn);
    when(utlatande.getId()).thenReturn(intygsId);
    when(utlatande.getTyp()).thenReturn("ts-bas");
    when(utlatande.getGrundData()).thenReturn(grundData);
    LogRequest res = LogRequestFactory.createLogRequestFromUtlatande(utlatande);
    assertNotNull(res);
    assertEquals(intygsId, res.getIntygId());
    assertEquals(patientPersonnummer, res.getPatientId());
    assertEquals(patientNamn, res.getPatientName());
    assertEquals(enhetsid, res.getIntygCareUnitId());
    assertEquals(enhetsnamn, res.getIntygCareUnitName());
    assertEquals(vardgivarid, res.getIntygCareGiverId());
    assertEquals(vardgivarnamn, res.getIntygCareGiverName());
    assertNull(res.getAdditionalInfo());
}
Also used : LogRequest(se.inera.intyg.webcert.web.service.log.dto.LogRequest) Test(org.junit.Test)

Example 15 with LogRequest

use of se.inera.intyg.webcert.web.service.log.dto.LogRequest in project webcert by sklintyg.

the class LogServiceImplTest method serviceSendsDocumentAndIdForCreate.

@Test
public void serviceSendsDocumentAndIdForCreate() throws Exception {
    when(userService.getUser()).thenReturn(createUser());
    ArgumentCaptor<MessageCreator> messageCreatorCaptor = ArgumentCaptor.forClass(MessageCreator.class);
    LogRequest logRequest = new LogRequest();
    logRequest.setIntygId("abc123");
    logRequest.setPatientId(createPnr("19121212-1212"));
    logRequest.setPatientName("Hans Olof van der Test");
    logService.logReadIntyg(logRequest);
    verify(template, only()).send(messageCreatorCaptor.capture());
    MessageCreator messageCreator = messageCreatorCaptor.getValue();
    Session session = mock(Session.class);
    ArgumentCaptor<String> intygReadMessageCaptor = ArgumentCaptor.forClass(String.class);
    when(session.createTextMessage(intygReadMessageCaptor.capture())).thenReturn(null);
    messageCreator.createMessage(session);
    String body = intygReadMessageCaptor.getValue();
    PdlLogMessage intygReadMessage = objectMapper.readValue(body, PdlLogMessage.class);
    assertNotNull(intygReadMessage.getLogId());
    assertEquals(ActivityType.READ, intygReadMessage.getActivityType());
    assertEquals(ActivityPurpose.CARE_TREATMENT, intygReadMessage.getPurpose());
    assertEquals("Intyg", intygReadMessage.getPdlResourceList().get(0).getResourceType());
    assertEquals("abc123", intygReadMessage.getActivityLevel());
    assertEquals("HSAID", intygReadMessage.getUserId());
    assertEquals("Markus Gran", intygReadMessage.getUserName());
    assertEquals("Läkare på vårdcentralen", intygReadMessage.getUserAssignment());
    assertEquals("Överläkare", intygReadMessage.getUserTitle());
    assertEquals("VARDENHET_ID", intygReadMessage.getUserCareUnit().getEnhetsId());
    assertEquals("Vårdenheten", intygReadMessage.getUserCareUnit().getEnhetsNamn());
    assertEquals("VARDGIVARE_ID", intygReadMessage.getUserCareUnit().getVardgivareId());
    assertEquals("Vårdgivaren", intygReadMessage.getUserCareUnit().getVardgivareNamn());
    assertEquals("191212121212", intygReadMessage.getPdlResourceList().get(0).getPatient().getPatientId());
    assertEquals("Hans Olof van der Test", intygReadMessage.getPdlResourceList().get(0).getPatient().getPatientNamn());
    assertTrue(intygReadMessage.getTimestamp().minusSeconds(DELAY).isBefore(now()));
    assertTrue(intygReadMessage.getTimestamp().plusSeconds(DELAY).isAfter(now()));
    assertEquals("webcert", intygReadMessage.getSystemId());
    assertEquals("WebCert", intygReadMessage.getSystemName());
}
Also used : LogRequest(se.inera.intyg.webcert.web.service.log.dto.LogRequest) PdlLogMessage(se.inera.intyg.infra.logmessages.PdlLogMessage) MessageCreator(org.springframework.jms.core.MessageCreator) Session(javax.jms.Session) Test(org.junit.Test)

Aggregations

LogRequest (se.inera.intyg.webcert.web.service.log.dto.LogRequest)25 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)11 Test (org.junit.Test)7 Transactional (org.springframework.transaction.annotation.Transactional)5 WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)5 SignaturTicket (se.inera.intyg.webcert.web.service.signatur.dto.SignaturTicket)3 OptimisticLockException (javax.persistence.OptimisticLockException)2 MessageCreator (org.springframework.jms.core.MessageCreator)2 Utlatande (se.inera.intyg.common.support.model.common.internal.Utlatande)2 ModuleApi (se.inera.intyg.common.support.modules.support.api.ModuleApi)2 ModuleException (se.inera.intyg.common.support.modules.support.api.exception.ModuleException)2 UtkastStatus (se.inera.intyg.webcert.common.model.UtkastStatus)2 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 Session (javax.jms.Session)1 DestinationResolutionException (org.springframework.jms.support.destination.DestinationResolutionException)1 Relation (se.inera.intyg.common.support.model.common.internal.Relation)1 ModuleNotFoundException (se.inera.intyg.common.support.modules.registry.ModuleNotFoundException)1 PdlLogMessage (se.inera.intyg.infra.logmessages.PdlLogMessage)1 Personnummer (se.inera.intyg.schemas.contract.Personnummer)1