Search in sources :

Example 1 with ListCertificatesForCareResponseType

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;
}
Also used : CertificateHolder(se.inera.intyg.common.support.modules.support.api.CertificateHolder) Intyg(se.riv.clinicalprocess.healthcond.certificate.v3.Intyg) ListaType(se.riv.clinicalprocess.healthcond.certificate.listcertificatesforcare.v3.ListaType) HsaId(se.riv.clinicalprocess.healthcond.certificate.types.v3.HsaId) ListCertificatesForCareResponseType(se.riv.clinicalprocess.healthcond.certificate.listcertificatesforcare.v3.ListCertificatesForCareResponseType) StubModeAware(se.inera.intyg.webcert.intygstjanststub.mode.StubModeAware) StubLatencyAware(se.inera.intyg.webcert.intygstjanststub.mode.StubLatencyAware)

Example 2 with ListCertificatesForCareResponseType

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());
}
Also used : ListCertificatesForCareType(se.riv.clinicalprocess.healthcond.certificate.listcertificatesforcare.v3.ListCertificatesForCareType) StreamSource(javax.xml.transform.stream.StreamSource) JAXBContext(javax.xml.bind.JAXBContext) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) ArrayList(java.util.ArrayList) List(java.util.List) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ArgumentMatchers.anyBoolean(org.mockito.ArgumentMatchers.anyBoolean) ClassPathResource(org.springframework.core.io.ClassPathResource) ListCertificatesForCareResponseType(se.riv.clinicalprocess.healthcond.certificate.listcertificatesforcare.v3.ListCertificatesForCareResponseType) HashSet(java.util.HashSet) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) Test(org.junit.Test)

Example 3 with ListCertificatesForCareResponseType

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);
}
Also used : ListCertificatesForCareType(se.riv.clinicalprocess.healthcond.certificate.listcertificatesforcare.v3.ListCertificatesForCareType) SekretessStatus(se.inera.intyg.webcert.common.model.SekretessStatus) WebServiceException(javax.xml.ws.WebServiceException) ListIntygEntry(se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry) ListCertificatesForCareResponseType(se.riv.clinicalprocess.healthcond.certificate.listcertificatesforcare.v3.ListCertificatesForCareResponseType)

Aggregations

ListCertificatesForCareResponseType (se.riv.clinicalprocess.healthcond.certificate.listcertificatesforcare.v3.ListCertificatesForCareResponseType)3 ListCertificatesForCareType (se.riv.clinicalprocess.healthcond.certificate.listcertificatesforcare.v3.ListCertificatesForCareType)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 JAXBContext (javax.xml.bind.JAXBContext)1 StreamSource (javax.xml.transform.stream.StreamSource)1 WebServiceException (javax.xml.ws.WebServiceException)1 Test (org.junit.Test)1 ArgumentMatchers.anyBoolean (org.mockito.ArgumentMatchers.anyBoolean)1 ArgumentMatchers.anyList (org.mockito.ArgumentMatchers.anyList)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 ClassPathResource (org.springframework.core.io.ClassPathResource)1 CertificateHolder (se.inera.intyg.common.support.modules.support.api.CertificateHolder)1 SekretessStatus (se.inera.intyg.webcert.common.model.SekretessStatus)1 StubLatencyAware (se.inera.intyg.webcert.intygstjanststub.mode.StubLatencyAware)1 StubModeAware (se.inera.intyg.webcert.intygstjanststub.mode.StubModeAware)1 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)1 ListIntygEntry (se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry)1 ListaType (se.riv.clinicalprocess.healthcond.certificate.listcertificatesforcare.v3.ListaType)1