dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24050
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11738: Event analytics, added attributes and identifiers to tables
------------------------------------------------------------
revno: 11738
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-08-21 17:01:59 +0200
message:
Event analytics, added attributes and identifiers to tables
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GridHeader.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GridHeader.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GridHeader.java 2012-05-11 19:04:25 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GridHeader.java 2013-08-21 15:01:59 +0000
@@ -57,11 +57,24 @@
}
/**
+ * @param name name
+ * @param column column
+ */
+ public GridHeader( String name, String column )
+ {
+ this.name = name;
+ this.column = column;
+ this.type = String.class.getName();
+ this.hidden = false;
+ this.meta = false;
+ }
+
+ /**
* Sets the column property to the name value. Sets the type property to String.
*
- * @param name name
+ * @param name name
* @param hidden hidden
- * @param meta meta
+ * @param meta meta
*/
public GridHeader( String name, boolean hidden, boolean meta )
{
@@ -73,11 +86,11 @@
}
/**
- * @param name name
+ * @param name name
* @param column column
- * @param type type
+ * @param type type
* @param hidden hidden
- * @param meta meta
+ * @param meta meta
*/
public GridHeader( String name, String column, String type, boolean hidden, boolean meta )
{
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java 2013-08-21 10:49:17 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java 2013-08-21 15:01:59 +0000
@@ -260,7 +260,7 @@
throw new RuntimeException( ex );
}
}
-
+
// -------------------------------------------------------------------------
// Getters and setters
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java 2013-08-21 11:56:16 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java 2013-08-21 15:01:59 +0000
@@ -38,6 +38,8 @@
import org.hisp.dhis.analytics.AnalyticsTable;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
+import org.hisp.dhis.patient.PatientAttribute;
+import org.hisp.dhis.patient.PatientIdentifierType;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramService;
@@ -154,6 +156,7 @@
"left join programinstance pi on psi.programinstanceid=pi.programinstanceid " +
"left join programstage ps on psi.programstageid=ps.programstageid " +
"left join program pr on pi.programid=pr.programid " +
+ "left join organisationunit ou on psi.organisationunitid=ou.organisationunitid " +
"left join _orgunitstructure ous on psi.organisationunitid=ous.organisationunitid " +
"where psi.executiondate >= '" + start + "' " +
"and psi.executiondate <= '" + end + "' " +
@@ -186,15 +189,34 @@
String select = "(select value from patientdatavalue where programstageinstanceid=" +
"psi.programstageinstanceid and dataelementid=" + dataElement.getId() + ") as " + dataElement.getUid();
- String[] col = { dataElement.getUid(), "character(255)", select };
+ String[] col = { dataElement.getUid(), "character varying(255)", select };
+ columns.add( col );
+ }
+
+ for ( PatientAttribute attribute : table.getProgram().getPatientAttributes() )
+ {
+ String select = "(select value from patientattributevalue where patientid=pi.patientid and " +
+ "patientattributeid=" + attribute.getId() + ") as " + attribute.getUid();
+
+ String[] col = { attribute.getUid(), "character varying(255)", select };
+ columns.add( col );
+ }
+
+ for ( PatientIdentifierType identifierType : table.getProgram().getPatientIdentifierTypes() )
+ {
+ String select = "(select identifier from patientidentifier where patientid=pi.patientid and " +
+ "patientidentifiertypeid=" + identifierType.getId() + ") as " + identifierType.getUid();
+
+ String[] col = { identifierType.getUid() + "character varying(31)", select };
columns.add( col );
}
String[] psi = { "psi", "character(11) not null", "psi.uid" };
String[] ps = { "ps", "character(11) not null", "ps.uid" };
String[] ed = { "executiondate", "date", "psi.executiondate" };
+ String[] ou = { "ou", "character(11) not null", "ou.uid" };
- columns.addAll( Arrays.asList( psi, ps, ed ) );
+ columns.addAll( Arrays.asList( psi, ps, ed, ou ) );
return columns;
}