Search in sources :

Example 1 with ListCertificatesForCareType

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;
}
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 ListCertificatesForCareType

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());
}
Also used : ListCertificatesForCareType(se.riv.clinicalprocess.healthcond.certificate.listcertificatesforcare.v3.ListCertificatesForCareType) ListIntygEntry(se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry) 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) Test(org.junit.Test)

Example 3 with ListCertificatesForCareType

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);
}
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

ListIntygEntry (se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry)2 ListCertificatesForCareResponseType (se.riv.clinicalprocess.healthcond.certificate.listcertificatesforcare.v3.ListCertificatesForCareResponseType)2 ListCertificatesForCareType (se.riv.clinicalprocess.healthcond.certificate.listcertificatesforcare.v3.ListCertificatesForCareType)2 ArrayList (java.util.ArrayList)1 List (java.util.List)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 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 ListaType (se.riv.clinicalprocess.healthcond.certificate.listcertificatesforcare.v3.ListaType)1 HsaId (se.riv.clinicalprocess.healthcond.certificate.types.v3.HsaId)1 Intyg (se.riv.clinicalprocess.healthcond.certificate.v3.Intyg)1