Search in sources :

Example 26 with Relations

use of se.inera.intyg.webcert.web.web.controller.api.dto.Relations 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)

Example 27 with Relations

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

the class IntygRelationHelperImpl method getRelationsForIntyg.

@Override
public Relations getRelationsForIntyg(String intygId) {
    Relations certificateRelations = new Relations();
    ListRelationsForCertificateResponseType response = getRelationsFromIntygstjanst(intygId);
    // Iterate over all relations fetched from IT, split them up into parent and child relation(s)
    response.getIntygRelation().stream().flatMap(ir -> ir.getRelation().stream()).forEach(r -> applyRelation(intygId, certificateRelations, r));
    // Enrich with any relations present only in Webcert (e.g. for utkast etc.)
    Relations webcertRelations = certificateRelationService.getRelations(intygId);
    mergeRelations(certificateRelations, webcertRelations);
    return certificateRelations;
}
Also used : ListRelationsForCertificateResponseType(se.inera.intyg.clinicalprocess.healthcond.certificate.listrelationsforcertificate.v1.ListRelationsForCertificateResponseType) ListRelationsForCertificateType(se.inera.intyg.clinicalprocess.healthcond.certificate.listrelationsforcertificate.v1.ListRelationsForCertificateType) CertificateRelationService(se.inera.intyg.webcert.web.service.relation.CertificateRelationService) Autowired(org.springframework.beans.factory.annotation.Autowired) ListRelationsForCertificateResponderInterface(se.inera.intyg.clinicalprocess.healthcond.certificate.listrelationsforcertificate.v1.ListRelationsForCertificateResponderInterface) Collectors(java.util.stream.Collectors) Value(org.springframework.beans.factory.annotation.Value) List(java.util.List) WebcertCertificateRelation(se.inera.intyg.webcert.common.model.WebcertCertificateRelation) Relations(se.inera.intyg.webcert.web.web.controller.api.dto.Relations) UtkastStatus(se.inera.intyg.webcert.common.model.UtkastStatus) IntygRelations(se.inera.intyg.clinicalprocess.healthcond.certificate.listrelationsforcertificate.v1.IntygRelations) Service(org.springframework.stereotype.Service) RelationKod(se.inera.intyg.common.support.common.enumerations.RelationKod) ListIntygEntry(se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry) Collections(java.util.Collections) Relation(se.inera.intyg.clinicalprocess.healthcond.certificate.listrelationsforcertificate.v1.Relation) ListRelationsForCertificateResponseType(se.inera.intyg.clinicalprocess.healthcond.certificate.listrelationsforcertificate.v1.ListRelationsForCertificateResponseType) Relations(se.inera.intyg.webcert.web.web.controller.api.dto.Relations) IntygRelations(se.inera.intyg.clinicalprocess.healthcond.certificate.listrelationsforcertificate.v1.IntygRelations)

Aggregations

Relations (se.inera.intyg.webcert.web.web.controller.api.dto.Relations)27 Test (org.junit.Test)12 IntygRelations (se.inera.intyg.clinicalprocess.healthcond.certificate.listrelationsforcertificate.v1.IntygRelations)11 ListRelationsForCertificateType (se.inera.intyg.clinicalprocess.healthcond.certificate.listrelationsforcertificate.v1.ListRelationsForCertificateType)7 Patient (se.inera.intyg.common.support.model.common.internal.Patient)7 WebcertCertificateRelation (se.inera.intyg.webcert.common.model.WebcertCertificateRelation)7 ClassPathResource (org.springframework.core.io.ClassPathResource)6 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)5 Personnummer (se.inera.intyg.schemas.contract.Personnummer)5 ArrayList (java.util.ArrayList)4 ListRelationsForCertificateResponseType (se.inera.intyg.clinicalprocess.healthcond.certificate.listrelationsforcertificate.v1.ListRelationsForCertificateResponseType)4 Fk7263Utlatande (se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande)4 Status (se.inera.intyg.common.support.model.Status)4 Response (javax.ws.rs.core.Response)3 Before (org.junit.Before)3 Utlatande (se.inera.intyg.common.support.model.common.internal.Utlatande)3 ModuleNotFoundException (se.inera.intyg.common.support.modules.registry.ModuleNotFoundException)3 CertificateResponse (se.inera.intyg.common.support.modules.support.api.dto.CertificateResponse)3 ValidationStatus (se.inera.intyg.common.support.modules.support.api.dto.ValidationStatus)3 ModuleException (se.inera.intyg.common.support.modules.support.api.exception.ModuleException)3