Search in sources :

Example 41 with Personnummer

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

the class IntygServiceTest method testHandleSignedCompletion.

@Test
public void testHandleSignedCompletion() throws Exception {
    final String intygId = "intygId";
    final String intygTyp = "intygTyp";
    final String relationIntygId = "relationIntygId";
    final String recipient = new Fk7263EntryPoint().getDefaultRecipient();
    final Personnummer personnummer = PERSNR;
    Fk7263Utlatande utlatande = objectMapper.readValue(json, Fk7263Utlatande.class);
    utlatande.setId(intygId);
    utlatande.setTyp(intygTyp);
    utlatande.getGrundData().getPatient().setPersonId(personnummer);
    Utkast utkast = new Utkast();
    utkast.setIntygsId(intygId);
    utkast.setIntygsTyp(intygTyp);
    utkast.setRelationKod(RelationKod.KOMPLT);
    utkast.setRelationIntygsId(relationIntygId);
    utkast.setModel(json);
    when(utkastRepository.findOne(intygId)).thenReturn(utkast);
    when(moduleFacade.getUtlatandeFromInternalModel(eq(intygTyp), anyString())).thenReturn(utlatande);
    when(certificateRelationService.getNewestRelationOfType(eq(intygId), eq(RelationKod.ERSATT), eq(Arrays.asList(UtkastStatus.SIGNED)))).thenReturn(Optional.empty());
    when(moduleRegistry.getModuleEntryPoint(intygTyp)).thenReturn(new Fk7263EntryPoint());
    intygService.handleAfterSigned(utkast);
    verify(certificateSenderService).sendCertificate(eq(intygId), eq(personnummer), anyString(), eq(recipient), eq(true));
    verify(mockMonitoringService).logIntygSent(intygId, recipient);
    verify(logservice).logSendIntygToRecipient(any(LogRequest.class));
    verify(arendeService).closeCompletionsAsHandled(relationIntygId, intygTyp);
    verify(notificationService).sendNotificationForIntygSent(intygId);
    ArgumentCaptor<Utkast> utkastCaptor = ArgumentCaptor.forClass(Utkast.class);
    verify(utkastRepository).save(utkastCaptor.capture());
    assertNotNull(utkastCaptor.getValue().getSkickadTillMottagareDatum());
    assertEquals(recipient, utkastCaptor.getValue().getSkickadTillMottagare());
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) LogRequest(se.inera.intyg.webcert.web.service.log.dto.LogRequest) Fk7263Utlatande(se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Fk7263EntryPoint(se.inera.intyg.common.fk7263.support.Fk7263EntryPoint) Test(org.junit.Test)

Example 42 with Personnummer

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

the class CertificateSenderServiceImplTest method sendCertificateWithDelayTest.

@Test
public void sendCertificateWithDelayTest() 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, true);
    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));
    assertEquals("true", 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 43 with Personnummer

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

the class ListCertificatesForCareWithQAResponderImplTest method testListCertificatesForCareWithQA.

@Test
public void testListCertificatesForCareWithQA() {
    final Personnummer personnummer = Personnummer.createPersonnummer("191212121212").get();
    final String enhet = "enhetHsaId";
    final LocalDate deadline = LocalDate.of(2017, 1, 1);
    final String reference = "ref";
    Handelse handelse = new Handelse();
    handelse.setCode(HandelsekodEnum.SKAPAT);
    handelse.setTimestamp(LocalDateTime.now());
    handelse.setAmne(ArendeAmne.AVSTMN);
    handelse.setSistaDatumForSvar(deadline);
    when(intygService.listCertificatesForCareWithQA(any(IntygWithNotificationsRequest.class))).thenReturn(Arrays.asList(new IntygWithNotificationsResponse(null, Arrays.asList(handelse), new ArendeCount(1, 1, 1, 1), new ArendeCount(2, 2, 2, 2), reference)));
    ListCertificatesForCareWithQAType request = new ListCertificatesForCareWithQAType();
    PersonId personId = new PersonId();
    personId.setExtension(personnummer.getPersonnummer());
    request.setPersonId(personId);
    HsaId hsaId = new HsaId();
    hsaId.setExtension(enhet);
    request.getEnhetsId().add(hsaId);
    ListCertificatesForCareWithQAResponseType response = responder.listCertificatesForCareWithQA("logicalAdress", request);
    assertNotNull(response);
    assertNotNull(response.getList());
    assertNotNull(response.getList().getItem());
    assertEquals(1, response.getList().getItem().size());
    assertEquals(1, response.getList().getItem().get(0).getHandelser().getHandelse().size());
    assertEquals(reference, response.getList().getItem().get(0).getRef());
    assertEquals(deadline, response.getList().getItem().get(0).getHandelser().getHandelse().get(0).getSistaDatumForSvar());
    assertEquals(HandelsekodEnum.SKAPAT.name(), response.getList().getItem().get(0).getHandelser().getHandelse().get(0).getHandelsekod().getCode());
    assertEquals(ArendeAmne.AVSTMN.name(), response.getList().getItem().get(0).getHandelser().getHandelse().get(0).getAmne().getCode());
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) ListCertificatesForCareWithQAResponseType(se.riv.clinicalprocess.healthcond.certificate.listCertificatesForCareWithQA.v3.ListCertificatesForCareWithQAResponseType) PersonId(se.riv.clinicalprocess.healthcond.certificate.types.v3.PersonId) ArendeCount(se.inera.intyg.common.support.modules.support.api.notification.ArendeCount) IntygWithNotificationsResponse(se.inera.intyg.webcert.web.service.intyg.dto.IntygWithNotificationsResponse) IntygWithNotificationsRequest(se.inera.intyg.webcert.web.service.intyg.dto.IntygWithNotificationsRequest) ListCertificatesForCareWithQAType(se.riv.clinicalprocess.healthcond.certificate.listCertificatesForCareWithQA.v3.ListCertificatesForCareWithQAType) LocalDate(java.time.LocalDate) HsaId(se.riv.clinicalprocess.healthcond.certificate.types.v3.HsaId) Handelse(se.inera.intyg.webcert.persistence.handelse.model.Handelse) Test(org.junit.Test)

Example 44 with Personnummer

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

the class IntygServiceImpl method fetchIntygData.

/**
 * Returns the IntygContentHolder. Used both externally to frontend and internally in the modules.
 *
 * @param intygsId  the identifier of the intyg.
 * @param intygsTyp the typ of the intyg. Used to call the correct module.
 * @param relations If the relations between intyg should be populated. This can be expensive (several database
 *                  operations). Use sparsely.
 */
private IntygContentHolder fetchIntygData(String intygsId, String intygsTyp, boolean relations, boolean coherentJournaling) {
    IntygContentHolder intygsData = getIntygData(intygsId, intygsTyp, relations);
    LogRequest logRequest = LogRequestFactory.createLogRequestFromUtlatande(intygsData.getUtlatande(), coherentJournaling);
    if (!coherentJournaling) {
        verifyEnhetsAuth(intygsData.getUtlatande(), true);
    }
    Personnummer pnr = intygsData.getUtlatande().getGrundData().getPatient().getPersonId();
    String enhetsId = intygsData.getUtlatande().getGrundData().getSkapadAv().getVardenhet().getEnhetsid();
    verifySekretessmarkering(intygsTyp, webCertUserService.getUser(), enhetsId, pnr);
    // Log read to PDL
    logService.logReadIntyg(logRequest);
    // Log read to monitoring log
    monitoringService.logIntygRead(intygsId, intygsTyp);
    return intygsData;
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) LogRequest(se.inera.intyg.webcert.web.service.log.dto.LogRequest) IntygContentHolder(se.inera.intyg.webcert.web.service.intyg.dto.IntygContentHolder)

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