Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import lombok.RequiredArgsConstructor;
import org.hisp.dhis.dxf2.events.trackedentity.store.Function;
import org.hisp.dhis.dxf2.events.trackedentity.store.QueryElement;
import org.hisp.dhis.dxf2.events.trackedentity.store.Subselect;
import org.hisp.dhis.dxf2.events.trackedentity.store.TableColumn;

/**
Expand Down Expand Up @@ -71,15 +70,7 @@ public enum COLUMNS {
ORGUNIT_UID(new TableColumn("o", "uid", "ou_uid")),
ORGUNIT_NAME(new TableColumn("o", "name", "ou_name")),
COC_UID(new TableColumn("coc", "uid", "cocuid")),
CAT_OPTIONS(
new Subselect(
"( "
+ "SELECT string_agg(opt.uid::text, ',') "
+ "FROM dataelementcategoryoption opt "
+ "join categoryoptioncombos_categoryoptions ccc "
+ "on opt.categoryoptionid = ccc.categoryoptionid "
+ "WHERE coc.categoryoptioncomboid = ccc.categoryoptioncomboid )",
"catoptions")),
CAT_OPTIONS(new TableColumn("catopts", "catoptions")),
ASSIGNED_USER(new TableColumn("ui", "uid", "userid")),
ASSIGNED_USER_FIRST_NAME(new TableColumn("ui", "firstname")),
ASSIGNED_USER_SURNAME(new TableColumn("ui", "surname")),
Expand Down Expand Up @@ -118,6 +109,13 @@ public static String getQuery() {
+ "join organisationunit o on psi.organisationunitid = o.organisationunitid "
+ "join categoryoptioncombo coc on psi.attributeoptioncomboid = coc.categoryoptioncomboid "
+ "left join userinfo ui on psi.assigneduserid = ui.userinfoid "
+ "left join lateral ("
+ "select string_agg(opt.uid::text, ',') as catoptions "
+ "from dataelementcategoryoption opt "
+ "join categoryoptioncombos_categoryoptions ccc "
+ "on opt.categoryoptionid = ccc.categoryoptionid "
+ "where coc.categoryoptioncomboid = ccc.categoryoptioncomboid "
+ ") catopts on true "
+ "where pi.programinstanceid in (:ids)";
}

Expand Down
Loading