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