use of se.inera.intyg.common.support.modules.support.api.notification.ArendeCount in project webcert by sklintyg.
the class FragorOchSvarCreatorImpl method performFragorCount.
private Pair<ArendeCount, ArendeCount> performFragorCount(List<FragaSvarStatus> fsStatuses) {
int skickadeFragorTotalt = 0;
int skickadeFragorBesvarade = 0;
int skickadeFragorEjBesvarade = 0;
int skickadeFragorHanterade = 0;
int mottagnaFragorTotalt = 0;
int mottagnaFragorBesvarade = 0;
int mottagnaFragorEjBesvarade = 0;
int mottagnaFragorHanterade = 0;
for (FragaSvarStatus fsStatus : fsStatuses) {
if (isFromWebcert(fsStatus)) {
skickadeFragorTotalt++;
if (fsStatus.isClosed()) {
skickadeFragorHanterade++;
} else if (fsStatus.hasAnswerSet()) {
skickadeFragorBesvarade++;
} else {
skickadeFragorEjBesvarade++;
}
} else if (isFromFK(fsStatus)) {
mottagnaFragorTotalt++;
if (fsStatus.isClosed()) {
mottagnaFragorHanterade++;
} else if (fsStatus.hasAnswerSet()) {
mottagnaFragorBesvarade++;
} else {
mottagnaFragorEjBesvarade++;
}
}
}
return Pair.of(new ArendeCount(skickadeFragorTotalt, skickadeFragorEjBesvarade, skickadeFragorBesvarade, skickadeFragorHanterade), new ArendeCount(mottagnaFragorTotalt, mottagnaFragorEjBesvarade, mottagnaFragorBesvarade, mottagnaFragorHanterade));
}
use of se.inera.intyg.common.support.modules.support.api.notification.ArendeCount in project webcert by sklintyg.
the class NotificationMessageFactoryImpl method createNotificationMessage.
@Override
public NotificationMessage createNotificationMessage(Utkast utkast, HandelsekodEnum handelse, SchemaVersion version, String reference, Amneskod amne, LocalDate sistaSvarsDatum) {
String intygsId = utkast.getIntygsId();
String intygsTyp = utkast.getIntygsTyp();
LocalDateTime handelseTid = LocalDateTime.now();
String logiskAdress = utkast.getEnhetsId();
String utkastJson = utkast.getModel();
FragorOchSvar fragaSvar = null;
ArendeCount skickadeFragor = null;
ArendeCount mottagnaFragor = null;
if (SchemaVersion.VERSION_3 == version) {
Pair<ArendeCount, ArendeCount> arenden = Pair.of(ArendeCount.getEmpty(), ArendeCount.getEmpty());
// Add a count of questions to the message
if (USES_FRAGOR_OCH_SVAR.contains(handelse)) {
arenden = fragorOchSvarCreator.createArenden(intygsId, intygsTyp);
}
skickadeFragor = arenden.getLeft();
mottagnaFragor = arenden.getRight();
} else {
fragaSvar = FragorOchSvar.getEmpty();
// Add a count of questions to the message
if (USES_FRAGOR_OCH_SVAR.contains(handelse)) {
fragaSvar = fragorOchSvarCreator.createFragorOchSvar(intygsId);
}
}
return new NotificationMessage(intygsId, intygsTyp, handelseTid, handelse, logiskAdress, utkastJson, fragaSvar, skickadeFragor, mottagnaFragor, version, reference, amne, sistaSvarsDatum);
}
use of se.inera.intyg.common.support.modules.support.api.notification.ArendeCount in project webcert by sklintyg.
the class NotificationMessageFactoryTest method testCreateNotificationMessageForUsesFragorOchSvarSchemaVersion3.
@Test
public void testCreateNotificationMessageForUsesFragorOchSvarSchemaVersion3() {
when(mockFragorOchSvarCreator.createArenden(INTYGS_ID, INTYGS_TYP)).thenReturn(Pair.of(new ArendeCount(1, 1, 1, 1), new ArendeCount(2, 2, 2, 2)));
Utkast utkast = createUtkast(INTYGS_ID);
final String reference = "ref";
NotificationMessage msg = notificationMessageFactory.createNotificationMessage(utkast, HandelsekodEnum.NYFRFV, SchemaVersion.VERSION_3, reference, null, null);
assertNotNull(msg);
assertNotNull(msg.getHandelse());
assertEquals(HandelsekodEnum.NYFRFV, msg.getHandelse());
assertNotNull(msg.getHandelseTid());
assertEquals(INTYGS_ID, msg.getIntygsId());
assertEquals(INTYGS_TYP, msg.getIntygsTyp());
assertEquals("SE12345678-1000", msg.getLogiskAdress());
assertEquals("{model}", msg.getUtkast());
assertEquals(SchemaVersion.VERSION_3, msg.getVersion());
assertEquals(reference, msg.getReference());
assertNull(msg.getFragaSvar());
assertNotNull(msg.getSkickadeFragor());
assertEquals(1, msg.getSkickadeFragor().getTotalt());
assertEquals(1, msg.getSkickadeFragor().getBesvarade());
assertEquals(1, msg.getSkickadeFragor().getEjBesvarade());
assertEquals(1, msg.getSkickadeFragor().getHanterade());
assertNotNull(msg.getMottagnaFragor());
assertEquals(2, msg.getMottagnaFragor().getTotalt());
assertEquals(2, msg.getMottagnaFragor().getBesvarade());
assertEquals(2, msg.getMottagnaFragor().getEjBesvarade());
assertEquals(2, msg.getMottagnaFragor().getHanterade());
verify(mockFragorOchSvarCreator).createArenden(INTYGS_ID, INTYGS_TYP);
verifyNoMoreInteractions(mockFragorOchSvarCreator);
}
use of se.inera.intyg.common.support.modules.support.api.notification.ArendeCount 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.support.modules.support.api.notification.ArendeCount 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());
}
Aggregations