diff --git a/avni-server-api/src/main/java/org/avni/server/domain/metabase/DatasetColumn.java b/avni-server-api/src/main/java/org/avni/server/domain/metabase/DatasetColumn.java new file mode 100644 index 000000000..48509b4c7 --- /dev/null +++ b/avni-server-api/src/main/java/org/avni/server/domain/metabase/DatasetColumn.java @@ -0,0 +1,16 @@ +package org.avni.server.domain.metabase; + +public enum DatasetColumn { + NAME(1), + TYPE(2); + + private final int index; + + DatasetColumn(int index) { + this.index = index; + } + + public int getIndex() { + return index; + } +} \ No newline at end of file diff --git a/avni-server-api/src/main/java/org/avni/server/domain/metabase/TableType.java b/avni-server-api/src/main/java/org/avni/server/domain/metabase/TableType.java index f361ed671..d1b221c6e 100644 --- a/avni-server-api/src/main/java/org/avni/server/domain/metabase/TableType.java +++ b/avni-server-api/src/main/java/org/avni/server/domain/metabase/TableType.java @@ -5,6 +5,7 @@ public enum TableType { HOUSEHOLD("Household"), GROUP("Group"), PERSON("Person"), + ENCOUNTER("Encounter"), PROGRAM_ENCOUNTER("ProgramEncounter"), PROGRAM_ENROLMENT("ProgramEnrolment"); diff --git a/avni-server-api/src/main/java/org/avni/server/service/metabase/DatabaseService.java b/avni-server-api/src/main/java/org/avni/server/service/metabase/DatabaseService.java index 784936d15..b3e7dca63 100644 --- a/avni-server-api/src/main/java/org/avni/server/service/metabase/DatabaseService.java +++ b/avni-server-api/src/main/java/org/avni/server/service/metabase/DatabaseService.java @@ -54,12 +54,12 @@ public List getSubjectTypeNames() { List subjectTypeNames = new ArrayList<>(); for (List row : rows) { - String type = row.get(2); + String type = row.get(DatasetColumn.TYPE.getIndex()); if (type.equalsIgnoreCase(TableType.INDIVIDUAL.getTypeName()) || type.equalsIgnoreCase(TableType.HOUSEHOLD.getTypeName()) || type.equalsIgnoreCase(TableType.GROUP.getTypeName()) || type.equalsIgnoreCase(TableType.PERSON.getTypeName())) { - subjectTypeNames.add(row.get(1)); + subjectTypeNames.add(row.get(DatasetColumn.NAME.getIndex())); } } @@ -75,10 +75,11 @@ public List getProgramAndEncounterNames() { List programNames = new ArrayList<>(); for (List row : rows) { - String type = row.get(2); + String type = row.get(DatasetColumn.TYPE.getIndex()); if (type.equalsIgnoreCase(TableType.PROGRAM_ENCOUNTER.getTypeName()) || + type.equalsIgnoreCase(TableType.ENCOUNTER.getTypeName()) || type.equalsIgnoreCase(TableType.PROGRAM_ENROLMENT.getTypeName())) { - programNames.add(row.get(1)); + programNames.add(row.get(DatasetColumn.NAME.getIndex())); } }