use of se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande in project webcert by sklintyg.
the class IntygModuleApiControllerTest method setupCertificateData.
@BeforeClass
public static void setupCertificateData() {
utlatande = new Fk7263Utlatande();
utlatande.setId(CERTIFICATE_ID);
utlatande.setTyp(CERTIFICATE_TYPE);
GrundData grundData = new GrundData();
patient = new Patient();
patient.setPersonId(createPnr(PERSON_ID));
patient.setFornamn("Fornamn");
patient.setEfternamn("Efternamn");
grundData.setPatient(patient);
utlatande.setGrundData(grundData);
List<Status> status = new ArrayList<>();
status.add(new Status(CertificateState.RECEIVED, "HSVARD", LocalDateTime.now()));
status.add(new Status(CertificateState.SENT, "FKASSA", LocalDateTime.now()));
}
use of se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande in project webcert by sklintyg.
the class AbstractIntygServiceTest method setupMocks.
@Before
public void setupMocks() throws Exception {
json = FileUtils.getStringFromFile(new ClassPathResource("IntygServiceTest/utlatande.json").getFile());
utlatande = objectMapper.readValue(json, Fk7263Utlatande.class);
CertificateMetaData metaData = buildCertificateMetaData();
certificateResponse = new CertificateResponse(json, utlatande, metaData, false);
when(moduleFacade.getCertificate(any(String.class), any(String.class))).thenReturn(certificateResponse);
when(certificateRelationService.getNewestRelationOfType(anyString(), any(RelationKod.class), any(List.class))).thenReturn(Optional.empty());
when(intygRelationHelper.getRelationsForIntyg(anyString())).thenReturn(new Relations());
when(patientDetailsResolver.resolvePatient(any(Personnummer.class), anyString())).thenReturn(buildPatient(false, false));
when(moduleRegistry.getModuleApi(anyString())).thenReturn(moduleApi);
when(moduleApi.getUtlatandeFromJson(anyString())).thenReturn(new Fk7263Utlatande());
when(moduleApi.updateBeforeSave(anyString(), any(Patient.class))).thenReturn("MODEL");
}
use of se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande in project webcert by sklintyg.
the class IntygServiceRevokeTest method setupMocks.
@Override
@Before
public void setupMocks() throws Exception {
json = FileUtils.getStringFromFile(new ClassPathResource("IntygServiceTest/utlatande.json").getFile());
utlatande = objectMapper.readValue(json, Fk7263Utlatande.class);
CertificateMetaData metaData = buildCertificateMetaData();
certificateResponse = new CertificateResponse(json, utlatande, metaData, false);
when(moduleFacade.getCertificate(any(String.class), any(String.class))).thenReturn(certificateResponse);
when(intygRelationHelper.getRelationsForIntyg(anyString())).thenReturn(new Relations());
when(patientDetailsResolver.resolvePatient(any(Personnummer.class), anyString())).thenReturn(buildPatient(false, false));
when(moduleRegistry.getModuleApi(anyString())).thenReturn(moduleApi);
when(moduleApi.getUtlatandeFromJson(anyString())).thenReturn(new Fk7263Utlatande());
when(moduleApi.updateBeforeSave(anyString(), any(Patient.class))).thenReturn("MODEL");
}
use of se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande in project webcert by sklintyg.
the class IntygServiceTest method testListCertificatesForCareWithQANoNotifications.
@Test
public void testListCertificatesForCareWithQANoNotifications() throws Exception {
final List<String> enhetList = Arrays.asList("enhet");
final String intygType = "intygType";
final String intygId = "intygId";
Fk7263Utlatande utlatande = objectMapper.readValue(json, Fk7263Utlatande.class);
ArendeCount sent = new ArendeCount(1, 2, 3, 4);
ArendeCount received = new ArendeCount(5, 6, 7, 8);
when(moduleRegistry.listAllModules()).thenReturn(Arrays.asList(new IntygModule(intygType, "", "", "", "", "", "", "", "", false)));
when(utkastRepository.findDraftsByPatientAndEnhetAndStatus(eq(PERSON_ID), eq(enhetList), eq(Arrays.asList(UtkastStatus.values())), eq(Collections.singleton(intygType)))).thenReturn(Arrays.asList(getDraft(intygId)));
when(notificationService.getNotifications(eq(intygId))).thenReturn(Collections.emptyList());
when(moduleRegistry.getModuleApi(any(String.class))).thenReturn(moduleApi);
when(moduleApi.getUtlatandeFromJson(anyString())).thenReturn(utlatande);
when(fragorOchSvarCreator.createArenden(eq(intygId), anyString())).thenReturn(Pair.of(sent, received));
List<IntygWithNotificationsResponse> res = intygService.listCertificatesForCareWithQA(new IntygWithNotificationsRequest.Builder().setPersonnummer(PERSNR).setEnhetId(enhetList).build());
assertNotNull(res);
assertEquals(1, res.size());
assertTrue(res.get(0).getNotifications().isEmpty());
assertEquals(1, res.get(0).getSentQuestions().getTotalt());
assertEquals(2, res.get(0).getSentQuestions().getEjBesvarade());
assertEquals(3, res.get(0).getSentQuestions().getBesvarade());
assertEquals(4, res.get(0).getSentQuestions().getHanterade());
assertEquals(5, res.get(0).getReceivedQuestions().getTotalt());
assertEquals(6, res.get(0).getReceivedQuestions().getEjBesvarade());
assertEquals(7, res.get(0).getReceivedQuestions().getBesvarade());
assertEquals(8, res.get(0).getReceivedQuestions().getHanterade());
}
use of se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande in project webcert by sklintyg.
the class IntygServiceTest method testLoggingFetchIntygAsPdfWithSJF.
@Test
public void testLoggingFetchIntygAsPdfWithSJF() throws IOException, IntygModuleFacadeException {
// Set up user
IntegrationParameters parameters = new IntegrationParameters(null, null, null, null, null, null, null, null, null, true, false, false, false);
when(webcertUser.getOrigin()).thenReturn(UserOriginType.DJUPINTEGRATION.name());
when(webcertUser.getParameters()).thenReturn(parameters);
final Utkast draft = getDraft(CERTIFICATE_ID);
when(utkastRepository.findOne(CERTIFICATE_ID)).thenReturn(draft);
Fk7263Utlatande utlatande = objectMapper.readValue(draft.getModel(), Fk7263Utlatande.class);
when(moduleFacade.getUtlatandeFromInternalModel(anyString(), anyString())).thenReturn(utlatande);
when(moduleFacade.convertFromInternalToPdfDocument(anyString(), anyString(), anyList(), anyBoolean())).thenReturn(buildPdfDocument());
intygService.fetchIntygAsPdf(CERTIFICATE_ID, CERTIFICATE_TYPE, false);
// Verify that the isAuthorized check wasn't run (since SJF=true and DJUPINTEGRATION)
verify(webCertUserService, times(0)).isAuthorizedForUnit(anyString(), anyString(), anyBoolean());
}
Aggregations