Search in sources :

Example 1 with MedicinsktArendeView

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

the class ArendeViewConverter method convertToMedicinsktArendeView.

private List<MedicinsktArendeView> convertToMedicinsktArendeView(List<MedicinsktArende> medicinskaArenden, String intygsId, String intygsTyp) {
    List<MedicinsktArendeView> medicinskaArendenViews = new ArrayList<>();
    if (CollectionUtils.isEmpty(medicinskaArenden)) {
        return medicinskaArendenViews;
    }
    List<String> frageIds = medicinskaArenden.stream().map(MedicinsktArende::getFrageId).distinct().collect(Collectors.toList());
    ModuleApi moduleApi = null;
    try {
        moduleApi = moduleRegistry.getModuleApi(intygsTyp);
    } catch (ModuleNotFoundException e) {
        LOG.error("Module not found for certificate of type {}", intygsTyp);
        Throwables.propagate(e);
    }
    Utlatande utlatande = intygService.fetchIntygData(intygsId, intygsTyp, false).getUtlatande();
    Map<String, List<String>> arendeParameters = moduleApi.getModuleSpecificArendeParameters(utlatande, frageIds);
    for (MedicinsktArende arende : medicinskaArenden) {
        Integer position = getListPositionForInstanceId(arende);
        String jsonPropertyHandle = getJsonPropertyHandle(arende, position, arendeParameters);
        MedicinsktArendeView view = MedicinsktArendeView.builder().setFrageId(arende.getFrageId()).setInstans(arende.getInstans()).setText(arende.getText()).setPosition(Math.max(position - 1, 0)).setJsonPropertyHandle(jsonPropertyHandle).build();
        medicinskaArendenViews.add(view);
    }
    return medicinskaArendenViews;
}
Also used : ModuleApi(se.inera.intyg.common.support.modules.support.api.ModuleApi) ModuleNotFoundException(se.inera.intyg.common.support.modules.registry.ModuleNotFoundException) MedicinsktArende(se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende) Utlatande(se.inera.intyg.common.support.model.common.internal.Utlatande) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) MedicinsktArendeView(se.inera.intyg.webcert.web.web.controller.api.dto.MedicinsktArendeView)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Utlatande (se.inera.intyg.common.support.model.common.internal.Utlatande)1 ModuleNotFoundException (se.inera.intyg.common.support.modules.registry.ModuleNotFoundException)1 ModuleApi (se.inera.intyg.common.support.modules.support.api.ModuleApi)1 MedicinsktArende (se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende)1 MedicinsktArendeView (se.inera.intyg.webcert.web.web.controller.api.dto.MedicinsktArendeView)1