use of se.riv.clinicalprocess.healthcond.certificate.listcertificatesforcare.v3.ListCertificatesForCareResponseType 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.ListCertificatesForCareResponseType in project webcert by sklintyg.
the class IntygServiceTest method testListIntygFiltersSekretessmarkering.
@Test
public void testListIntygFiltersSekretessmarkering() throws JAXBException, IOException {
Set<String> set = new HashSet<>();
set.add("fk7263");
set.add("ts-bas");
set.add("doi");
ClassPathResource response = new ClassPathResource("IntygServiceTest/response-list-certificates-with-sekretess.xml");
JAXBContext context = JAXBContext.newInstance(ListCertificatesForCareResponseType.class);
ListCertificatesForCareResponseType listResponse2 = context.createUnmarshaller().unmarshal(new StreamSource(response.getInputStream()), ListCertificatesForCareResponseType.class).getValue();
when(patientDetailsResolver.getSekretessStatus(any())).thenReturn(SekretessStatus.TRUE);
when(authoritiesHelper.getIntygstyperForPrivilege(any(WebCertUser.class), anyString())).thenReturn(set);
when(authoritiesHelper.getIntygstyperAllowedForSekretessmarkering()).thenReturn(Sets.newHashSet("fk7263"));
when(listCertificatesForCareResponder.listCertificatesForCare(eq(LOGICAL_ADDRESS), any(ListCertificatesForCareType.class))).thenReturn(listResponse2);
Pair<List<ListIntygEntry>, Boolean> intygItemListResponse = intygService.listIntyg(Collections.singletonList("enhet-1"), PERSNR);
assertEquals(2, intygItemListResponse.getLeft().size());
}
use of se.riv.clinicalprocess.healthcond.certificate.listcertificatesforcare.v3.ListCertificatesForCareResponseType 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