Search in sources :

Example 26 with ListIntygEntry

use of se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry in project webcert by sklintyg.

the class IntygRelationHelperImpl method decorateIntygListWithRelations.

@Override
public void decorateIntygListWithRelations(List<ListIntygEntry> fullIntygItemList) {
    ListRelationsForCertificateResponseType response = getRelationsFromIntygstjanst(fullIntygItemList.stream().map(ListIntygEntry::getIntygId).collect(Collectors.toList()));
    if (response != null) {
        // Very ugly, iterate over both lists, find matches and create relation(s) on the ListIntygEntries.
        for (IntygRelations ir : response.getIntygRelation()) {
            for (ListIntygEntry lie : fullIntygItemList) {
                if (lie.getIntygId().equals(ir.getIntygsId().getExtension())) {
                    // Create a Relations instance to hold relations.
                    lie.setRelations(new Relations());
                    // Iterate over all relations for this particular intyg
                    for (Relation r : ir.getRelation()) {
                        applyRelation(lie.getIntygId(), lie.getRelations(), r);
                    }
                }
            }
        }
    }
    // account.
    for (ListIntygEntry lie : fullIntygItemList) {
        Relations relations = certificateRelationService.getRelations(lie.getIntygId());
        mergeRelations(lie.getRelations(), relations);
    }
}
Also used : ListRelationsForCertificateResponseType(se.inera.intyg.clinicalprocess.healthcond.certificate.listrelationsforcertificate.v1.ListRelationsForCertificateResponseType) WebcertCertificateRelation(se.inera.intyg.webcert.common.model.WebcertCertificateRelation) Relation(se.inera.intyg.clinicalprocess.healthcond.certificate.listrelationsforcertificate.v1.Relation) IntygRelations(se.inera.intyg.clinicalprocess.healthcond.certificate.listrelationsforcertificate.v1.IntygRelations) ListIntygEntry(se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry) Relations(se.inera.intyg.webcert.web.web.controller.api.dto.Relations) IntygRelations(se.inera.intyg.clinicalprocess.healthcond.certificate.listrelationsforcertificate.v1.IntygRelations)

Aggregations

ListIntygEntry (se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry)26 Test (org.junit.Test)16 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)12 Signatur (se.inera.intyg.webcert.persistence.utkast.model.Signatur)5 List (java.util.List)4 Response (javax.ws.rs.core.Response)3 Personnummer (se.inera.intyg.schemas.contract.Personnummer)3 SekretessStatus (se.inera.intyg.webcert.common.model.SekretessStatus)3 WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)2 ListCertificatesForCareType (se.riv.clinicalprocess.healthcond.certificate.listcertificatesforcare.v3.ListCertificatesForCareType)2 LocalDateTime (java.time.LocalDateTime)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 OptimisticLockException (javax.persistence.OptimisticLockException)1 WebServiceException (javax.xml.ws.WebServiceException)1 ArgumentMatchers.anyBoolean (org.mockito.ArgumentMatchers.anyBoolean)1 ArgumentMatchers.anyList (org.mockito.ArgumentMatchers.anyList)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 OptimisticLockingFailureException (org.springframework.dao.OptimisticLockingFailureException)1 IntygRelations (se.inera.intyg.clinicalprocess.healthcond.certificate.listrelationsforcertificate.v1.IntygRelations)1