Search in sources :

Example 1 with Personnummer

use of se.inera.intyg.schemas.contract.Personnummer in project webcert by sklintyg.

the class ArendeServiceTest method testFilterArendeFiltersOutNonVerifiedSekretessPatients.

@Test
@SuppressWarnings("unchecked")
public void testFilterArendeFiltersOutNonVerifiedSekretessPatients() {
    WebCertUser webCertUser = createUser();
    Map<Personnummer, SekretessStatus> map = mock(Map.class);
    when(map.get(any(Personnummer.class))).thenReturn(SekretessStatus.UNDEFINED);
    doReturn(map).when(patientDetailsResolver).getSekretessStatusForList(anyList());
    when(webcertUserService.getUser()).thenReturn(webCertUser);
    when(webcertUserService.isAuthorizedForUnit(any(), eq(true))).thenReturn(true);
    List<Arende> queryResults = new ArrayList<>();
    queryResults.add(buildArende(UUID.randomUUID().toString(), LocalDateTime.now(), null));
    queryResults.add(buildArende(UUID.randomUUID().toString(), LocalDateTime.now().minusDays(1), null));
    when(arendeRepository.filterArende(any(Filter.class))).thenReturn(queryResults);
    QueryFragaSvarResponse fsResponse = new QueryFragaSvarResponse();
    fsResponse.setResults(new ArrayList<>());
    fsResponse.setTotalCount(0);
    when(fragaSvarService.filterFragaSvar(any(Filter.class))).thenReturn(fsResponse);
    QueryFragaSvarParameter params = new QueryFragaSvarParameter();
    params.setEnhetId(webCertUser.getValdVardenhet().getId());
    QueryFragaSvarResponse response = service.filterArende(params);
    verify(patientDetailsResolver, times(1)).getSekretessStatusForList(anyList());
    verify(webcertUserService).isAuthorizedForUnit(anyString(), eq(true));
    verify(arendeRepository).filterArende(any(Filter.class));
    verify(fragaSvarService).filterFragaSvar(any(Filter.class));
    assertEquals(0, response.getResults().size());
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) SekretessStatus(se.inera.intyg.webcert.common.model.SekretessStatus) Filter(se.inera.intyg.webcert.persistence.model.Filter) QueryFragaSvarParameter(se.inera.intyg.webcert.web.service.fragasvar.dto.QueryFragaSvarParameter) MedicinsktArende(se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende) Arende(se.inera.intyg.webcert.persistence.arende.model.Arende) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) QueryFragaSvarResponse(se.inera.intyg.webcert.web.service.fragasvar.dto.QueryFragaSvarResponse) Test(org.junit.Test)

Example 2 with Personnummer

use of se.inera.intyg.schemas.contract.Personnummer in project webcert by sklintyg.

the class CertificateSenderServiceImplTest method sendCertificateTest.

@Test
public void sendCertificateTest() throws Exception {
    final String intygsId = "intygsId";
    final Personnummer personId = createPnr("19121212-1212");
    final String jsonBody = "jsonBody";
    final String recipientId = "recipientId";
    service.sendCertificate(intygsId, personId, jsonBody, recipientId);
    ArgumentCaptor<MessageCreator> messageCaptor = ArgumentCaptor.forClass(MessageCreator.class);
    verify(template).send(messageCaptor.capture());
    Message res = messageCaptor.getValue().createMessage(session);
    assertEquals(Constants.SEND_MESSAGE, res.getStringProperty(Constants.MESSAGE_TYPE));
    assertEquals(intygsId, res.getStringProperty(Constants.INTYGS_ID));
    assertEquals(personId.getPersonnummer(), res.getStringProperty(Constants.PERSON_ID));
    assertEquals(recipientId, res.getStringProperty(Constants.RECIPIENT));
    assertEquals(LOGICAL_ADDRESS, res.getStringProperty(Constants.LOGICAL_ADDRESS));
    assertNull(res.getStringProperty(Constants.DELAY_MESSAGE));
    assertEquals(jsonBody, ((TextMessage) res).getText());
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) ActiveMQTextMessage(org.apache.activemq.command.ActiveMQTextMessage) Message(javax.jms.Message) TextMessage(javax.jms.TextMessage) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) MessageCreator(org.springframework.jms.core.MessageCreator) Test(org.junit.Test)

Example 3 with Personnummer

use of se.inera.intyg.schemas.contract.Personnummer in project webcert by sklintyg.

the class ElegWebCertUserDetailsServiceTest method buildPersonSvar.

private PersonSvar buildPersonSvar(boolean sekretessMarkerad, PersonSvar.Status status) {
    Personnummer personnummer = Personnummer.createPersonnummer(PERSON_ID).get();
    Person person = new Person(personnummer, sekretessMarkerad, false, "fornamn", "", "Efternamn", "gatan", "12345", "postort");
    return new PersonSvar(person, status);
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) PersonSvar(se.inera.intyg.infra.integration.pu.model.PersonSvar) Person(se.inera.intyg.infra.integration.pu.model.Person)

Example 4 with Personnummer

use of se.inera.intyg.schemas.contract.Personnummer in project webcert by sklintyg.

the class IntygDraftsConverterTest method testConvertIntygToListEntries.

@Test
public void testConvertIntygToListEntries() {
    LocalDateTime modfied = LocalDateTime.parse("2014-01-01T10:00:00");
    String id = "123";
    String type = "type";
    String updatedSignedBy = "Dr Dengroth";
    String updatedSignedByHsaId = "HSA1234";
    Personnummer patientId = Personnummer.createPersonnummer("19121212-1212").get();
    List<Utkast> utkastList = Collections.singletonList(TestIntygFactory.createUtkast(id, modfied, type, updatedSignedBy, updatedSignedByHsaId, UtkastStatus.DRAFT_COMPLETE, patientId));
    List<ListIntygEntry> res = IntygDraftsConverter.convertUtkastsToListIntygEntries(utkastList);
    assertNotNull(res);
    assertEquals(1, res.size());
    ListIntygEntry ref = res.get(0);
    assertEquals(id, ref.getIntygId());
    assertEquals(type, ref.getIntygType());
    assertEquals("DRAFT_COMPLETE", ref.getStatus());
    assertEquals(updatedSignedBy, ref.getUpdatedSignedBy());
    assertEquals(modfied, ref.getLastUpdatedSigned());
}
Also used : LocalDateTime(java.time.LocalDateTime) Personnummer(se.inera.intyg.schemas.contract.Personnummer) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) ListIntygEntry(se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry) Test(org.junit.Test)

Example 5 with Personnummer

use of se.inera.intyg.schemas.contract.Personnummer in project webcert by sklintyg.

the class ArendeViewConverterTest method buildGrundData.

private GrundData buildGrundData(String enhetsId, String enhetsNamn, String patientPersonId, String skapadavPersonId, LocalDateTime timeStamp) {
    GrundData grundData = new GrundData();
    HoSPersonal skapadAv = new HoSPersonal();
    Vardenhet vardenhet = new Vardenhet();
    vardenhet.setEnhetsid(enhetsId);
    vardenhet.setEnhetsnamn(enhetsNamn);
    Vardgivare vardgivare = new Vardgivare();
    vardgivare.setVardgivarid("vardgivarid");
    vardgivare.setVardgivarnamn("vardgivarnamn");
    vardenhet.setVardgivare(vardgivare);
    skapadAv.setVardenhet(vardenhet);
    skapadAv.setFullstandigtNamn(skapadavPersonId);
    skapadAv.setPersonId(skapadavPersonId);
    grundData.setSkapadAv(skapadAv);
    Patient patient = new Patient();
    Personnummer personId = Personnummer.createPersonnummer(patientPersonId).get();
    patient.setPersonId(personId);
    grundData.setPatient(patient);
    grundData.setSigneringsdatum(timeStamp);
    return grundData;
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer)

Aggregations

Personnummer (se.inera.intyg.schemas.contract.Personnummer)44 Test (org.junit.Test)15 SekretessStatus (se.inera.intyg.webcert.common.model.SekretessStatus)15 WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)11 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)11 PersonSvar (se.inera.intyg.infra.integration.pu.model.PersonSvar)8 HashMap (java.util.HashMap)6 Map (java.util.Map)6 Response (javax.ws.rs.core.Response)6 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)6 LocalDateTime (java.time.LocalDateTime)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 GroupableItem (se.inera.intyg.webcert.common.model.GroupableItem)4 Collectors (java.util.stream.Collectors)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3 Fk7263EntryPoint (se.inera.intyg.common.fk7263.support.Fk7263EntryPoint)3