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