use of se.inera.intyg.webcert.web.service.intyg.dto.IntygContentHolder in project webcert by sklintyg.
the class IntygServiceTest method testFetchIntygDataHasSentStatusWhenIntygstjanstIsUnavailableAndDraftHadSentDate.
@SuppressWarnings("unchecked")
@Test
public void testFetchIntygDataHasSentStatusWhenIntygstjanstIsUnavailableAndDraftHadSentDate() throws Exception {
when(moduleFacade.getCertificate(CERTIFICATE_ID, CERTIFICATE_TYPE)).thenThrow(WebServiceException.class);
when(utkastRepository.findOneByIntygsIdAndIntygsTyp(CERTIFICATE_ID, CERTIFICATE_TYPE)).thenReturn(getIntyg(CERTIFICATE_ID, LocalDateTime.now(), null));
IntygContentHolder intygContentHolder = intygService.fetchIntygData(CERTIFICATE_ID, CERTIFICATE_TYPE, false);
assertEquals(intygContentHolder.getStatuses().size(), 2);
assertEquals(intygContentHolder.getStatuses().get(0).getType(), CertificateState.SENT);
assertNotNull(intygContentHolder.getUtlatande());
// ensure that correct call is made to moduleFacade
verify(moduleFacade).getCertificate(CERTIFICATE_ID, CERTIFICATE_TYPE);
// Assert pdl log
verify(logservice).logReadIntyg(any(LogRequest.class));
}
use of se.inera.intyg.webcert.web.service.intyg.dto.IntygContentHolder in project webcert by sklintyg.
the class IntygServiceTest method testFetchIntygDataWithRelationITUnavailable.
@Test
public void testFetchIntygDataWithRelationITUnavailable() throws Exception {
when(moduleFacade.getCertificate(any(String.class), any(String.class))).thenThrow(new WebServiceException(""));
when(utkastRepository.findOneByIntygsIdAndIntygsTyp(CERTIFICATE_ID, CERTIFICATE_TYPE)).thenReturn(getIntyg(CERTIFICATE_ID, null, null));
IntygContentHolder res = intygService.fetchIntygDataWithRelations(CERTIFICATE_ID, CERTIFICATE_TYPE, false);
assertNotNull(res);
assertNotNull(res.getRelations());
verify(moduleFacade).getCertificate(CERTIFICATE_ID, CERTIFICATE_TYPE);
verify(utkastRepository).findOneByIntygsIdAndIntygsTyp(CERTIFICATE_ID, CERTIFICATE_TYPE);
verify(logservice).logReadIntyg(any(LogRequest.class));
verify(mockMonitoringService).logIntygRead(CERTIFICATE_ID, CERTIFICATE_TYPE);
verify(certificateRelationService).getRelations(eq(CERTIFICATE_ID));
}
use of se.inera.intyg.webcert.web.service.intyg.dto.IntygContentHolder in project webcert by sklintyg.
the class IntygServiceTest method testDeceasedIsNotSetForAlivePatientDjupintegration.
@Test
public void testDeceasedIsNotSetForAlivePatientDjupintegration() {
when(webcertUser.getOrigin()).thenReturn(UserOriginType.DJUPINTEGRATION.name());
when(webcertUser.getParameters()).thenReturn(new IntegrationParameters("", "", "", "", "", "", "", "", "", false, false, false, true));
IntygContentHolder intygData = intygService.fetchIntygData(CERTIFICATE_ID, CERTIFICATE_TYPE, false);
assertFalse(intygData.isDeceased());
}
use of se.inera.intyg.webcert.web.service.intyg.dto.IntygContentHolder 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;
}
use of se.inera.intyg.webcert.web.service.intyg.dto.IntygContentHolder in project webcert by sklintyg.
the class IntygServiceImpl method isRevoked.
@Override
public boolean isRevoked(String intygsId, String intygsTyp, boolean coherentJournaling) {
IntygContentHolder intygData = getIntygData(intygsId, intygsTyp, false);
// Log read of revoke status to monitoring log
monitoringService.logIntygRevokeStatusRead(intygsId, intygsTyp);
return intygData.isRevoked();
}
Aggregations