use of se.riv.clinicalprocess.healthcond.certificate.listcertificatesforcare.v3.ListCertificatesForCareType in project webcert by sklintyg.
the class ListCertificatesForCareResponderStub method listCertificatesForCare.
@Override
@StubLatencyAware
@StubModeAware
public ListCertificatesForCareResponseType listCertificatesForCare(String logicalAddress, ListCertificatesForCareType parameters) {
ListCertificatesForCareResponseType response = new ListCertificatesForCareResponseType();
response.setIntygsLista(new ListaType());
response.getIntygsLista().getIntyg();
List<CertificateHolder> intygForEnhetAndPersonnummer = intygStore.getIntygForEnhetAndPersonnummer(parameters.getEnhetsId().stream().map(HsaId::getExtension).collect(Collectors.toList()), parameters.getPersonId().getExtension());
for (CertificateHolder cert : intygForEnhetAndPersonnummer) {
Intyg intyg = getIntyg(cert);
intyg.getStatus().addAll(CertificateStateHolderConverter.toIntygsStatusType(cert.getCertificateStates()));
response.getIntygsLista().getIntyg().add(intyg);
}
return response;
}
use of se.riv.clinicalprocess.healthcond.certificate.listcertificatesforcare.v3.ListCertificatesForCareType in project webcert by sklintyg.
the class IntygServiceTest method testListIntyg.
@Test
public void testListIntyg() {
final String enhetsId = "enhet-1";
// setup intygstjansten WS mock to return intyg information
when(listCertificatesForCareResponder.listCertificatesForCare(eq(LOGICAL_ADDRESS), any(ListCertificatesForCareType.class))).thenReturn(listResponse);
Pair<List<ListIntygEntry>, Boolean> intygItemListResponse = intygService.listIntyg(Collections.singletonList(enhetsId), PERSNR);
ArgumentCaptor<ListCertificatesForCareType> argument = ArgumentCaptor.forClass(ListCertificatesForCareType.class);
verify(listCertificatesForCareResponder).listCertificatesForCare(eq(LOGICAL_ADDRESS), argument.capture());
assertEquals(2, intygItemListResponse.getLeft().size());
ListIntygEntry meta = intygItemListResponse.getLeft().get(0);
assertEquals("1", meta.getIntygId());
assertEquals("fk7263", meta.getIntygType());
assertEquals(CertificateState.SENT.name(), meta.getStatus());
assertTrue(PERSNR.equals(meta.getPatientId()));
assertEquals(1, argument.getValue().getEnhetsId().size());
assertNotNull(argument.getValue().getEnhetsId().get(0).getRoot());
assertEquals(enhetsId, argument.getValue().getEnhetsId().get(0).getExtension());
assertNotNull(argument.getValue().getPersonId().getRoot());
assertEquals("191212121212", argument.getValue().getPersonId().getExtension());
}
use of se.riv.clinicalprocess.healthcond.certificate.listcertificatesforcare.v3.ListCertificatesForCareType in project webcert by sklintyg.
the class IntygServiceImpl method listIntyg.
@Override
public Pair<List<ListIntygEntry>, Boolean> listIntyg(List<String> enhetId, Personnummer personnummer) {
ListCertificatesForCareType request = new ListCertificatesForCareType();
request.setPersonId(InternalConverterUtil.getPersonId(personnummer));
SekretessStatus sekretessmarkering = patientDetailsResolver.getSekretessStatus(personnummer);
for (String id : enhetId) {
request.getEnhetsId().add(InternalConverterUtil.getHsaId(id));
}
try {
ListCertificatesForCareResponseType response = listCertificateService.listCertificatesForCare(logicalAddress, request);
List<ListIntygEntry> fullIntygItemList = intygConverter.convertIntygToListIntygEntries(response.getIntygsLista().getIntyg());
intygRelationHelper.decorateIntygListWithRelations(fullIntygItemList);
fullIntygItemList = filterByIntygTypeForUser(fullIntygItemList, sekretessmarkering);
addDraftsToListForIntygNotSavedInIntygstjansten(fullIntygItemList, enhetId, personnummer);
return Pair.of(fullIntygItemList, Boolean.FALSE);
} catch (WebServiceException wse) {
LOG.warn("Error when connecting to intygstjÀnsten: {}", wse.getMessage());
}
// If intygstjansten was unavailable, we return whatever certificates we can find and clearly inform
// the caller that the set of certificates are only those that have been issued by WebCert.
List<ListIntygEntry> intygItems = buildIntygItemListFromDrafts(enhetId, personnummer);
for (ListIntygEntry lie : intygItems) {
lie.setRelations(certificateRelationService.getRelations(lie.getIntygId()));
}
return Pair.of(intygItems, Boolean.TRUE);
}
Aggregations