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;
}
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());
}
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());
}
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());
}
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());
}
Aggregations