District Health Information Software 2District Health ... · – Hibernate configuration –...

31
District Health Information Software 2 District Health Information Software 2 (DHIS 2) (DHIS 2)

Transcript of District Health Information Software 2District Health ... · – Hibernate configuration –...

Page 1: District Health Information Software 2District Health ... · – Hibernate configuration – Testing – Development tips and conventionsDevelopment tips and conventions. DHIS 2DHIS

District Health Information Software 2District Health Information Software 2

(DHIS 2)(DHIS 2)

Page 2: District Health Information Software 2District Health ... · – Hibernate configuration – Testing – Development tips and conventionsDevelopment tips and conventions. DHIS 2DHIS

IntroductionIntroduction

• Purpose– Demonstrate use of frameworks in a real-life application

Demonstrate and provide information about DHIS 2 for project– Demonstrate and provide information about DHIS 2 for project work

• Contents– Domain model– Project structure & repository layout– Application design– Hibernate configuration– Testing– Development tips and conventions– Development tips and conventions

Page 3: District Health Information Software 2District Health ... · – Hibernate configuration – Testing – Development tips and conventionsDevelopment tips and conventions. DHIS 2DHIS

DHIS 2DHIS 2

• Application for collection, validation, analysis, and presentation of aggregate / statistical dataaggregate / statistical data

• Tailored to health information management• Tailored to health information management

• Dynamic data model and flexible user interface• Dynamic data model and flexible user interface

B d J d l t f k• Based on open source Java development frameworks

Page 4: District Health Information Software 2District Health ... · – Hibernate configuration – Testing – Development tips and conventionsDevelopment tips and conventions. DHIS 2DHIS

Domain modelDomain model

• DataElement– Meta-data definition of captured enitities

Example: BCG doses given for infant under 1 year– Example: BCG doses given for infant under 1 year

DATAELEMENT Java-type Db-attr

id int unique, not-null

uuid string unique

name string unique, not-null

alternativeName string unique

shortName string unique, not-null

code string uniquecode string unique

description string -

active boolean -

type string not-null

aggregationOperator string not-null

Page 5: District Health Information Software 2District Health ... · – Hibernate configuration – Testing – Development tips and conventionsDevelopment tips and conventions. DHIS 2DHIS

Domain modelDomain model

• Period– Time interval between start- and end-date

• PeriodType– Example: Yearly, quarterly, monthly, weeklya p e ea y, qua te y, o t y, ee y

PERIOD Java-type Db-attr

id int unique, not-nullid int unique, not null

periodType PeriodType -

startDate Date -

dD t D tendDate Date -

PERIODTYPE Java-type Db-attr

id int unique, not-null

name name not-null

Page 6: District Health Information Software 2District Health ... · – Hibernate configuration – Testing – Development tips and conventionsDevelopment tips and conventions. DHIS 2DHIS

Domain modelDomain model

• OrganisationUnit– Example: Ministry of Health, Province, District, Hospital, Ward

ORGANISATIONUNIT Java-type Db-attr

id int unique not-nullid int unique, not null

uuid string unique

name string unique, not-null

shortName string unique, not-null

organisationUnitcode string unique

openingDate Date -

closedDate Date -

active boolean -

comment string -g

Page 7: District Health Information Software 2District Health ... · – Hibernate configuration – Testing – Development tips and conventionsDevelopment tips and conventions. DHIS 2DHIS

Domain modelDomain model

• OrganisationUnitGroup– Used to organize analysis and reports / output

O i ti U itG S t• OrganisationUnitGroupSet– Set of OrganisationUnitGroups– Compulsory and / or exclusive– Compulsory and / or exclusive

ORGANISATIONUNITGROUPSET Java-type Db-attr

id int unique, not-null

name string unique, not-null

description string -p g

organisationUnitGroups Set<OrganisationUnitGroup> -

compulsory boolean -

exclusive boolean -

Page 8: District Health Information Software 2District Health ... · – Hibernate configuration – Testing – Development tips and conventionsDevelopment tips and conventions. DHIS 2DHIS

Domain modelDomain model

• Source– Generic in order to allow any type of Sources

Current source in DHIS 2 is OrganisationUnit– Current source in DHIS 2 is OrganisationUnit– Abstract class - OrganisationUnit extends Source

SOURCE Java-type Db-attryp

id int unique, not-null

Page 9: District Health Information Software 2District Health ... · – Hibernate configuration – Testing – Development tips and conventionsDevelopment tips and conventions. DHIS 2DHIS

Domain modelDomain model

• DataValue– Captured data for a combination of DataElement, Period,

and Sourceand Source

DATAVALUE Java-type Db-attr

dataElement DataElement -

period Period -

source Sourcesource Source -

value String -

storedBy String -

timeStamp Date -

comment String -

Page 10: District Health Information Software 2District Health ... · – Hibernate configuration – Testing – Development tips and conventionsDevelopment tips and conventions. DHIS 2DHIS

Domain modelDomain model

• DataValue associations

DataElement

1N

1Source (OrganisationUnit)DataValue

NN

1

Period

1

Page 11: District Health Information Software 2District Health ... · – Hibernate configuration – Testing – Development tips and conventionsDevelopment tips and conventions. DHIS 2DHIS

Domain modelDomain model

• Indicator– Formula based on DataElements

Used to improve data analysis– Used to improve data analysis– Example: BCG under 1 year coverage = BCG doses under 1

year / Total population under 1 year– Multiplied with a factor (IndicatorType)

• Indicator associationsIndicatorType

1N

Indicator

NIndicatorGroupN N

Page 12: District Health Information Software 2District Health ... · – Hibernate configuration – Testing – Development tips and conventionsDevelopment tips and conventions. DHIS 2DHIS

Domain modelDomain modelINDICATOR Java-type Db-attr

id int unique, not-null

uuid string unique

name string unique, not-null

alternativeName string unique

shortName string unique not-nullshortName string unique, not-null

code string unique

description string -

indicatorType IndicatorType -

numerator string -

numeratorDescription string -

numeratorAggregationOperator string -

denominator string -

denominatorDescription stringdenominatorDescription string -

denominatorAggregationOperator string -

Page 13: District Health Information Software 2District Health ... · – Hibernate configuration – Testing – Development tips and conventionsDevelopment tips and conventions. DHIS 2DHIS

Domain modelDomain model

• IndicatorType– Example: Rate (1), Percent (100), Per thousand (1000)

I di t G• IndicatorGroup– Used to organize analysis and reports / output

INDICATORTYPE Java-type Db-attr

id int unique, not-null

t i i t llname string unique, not-null

factor int -

INDICATORGROUP J t Db ttINDICATORGROUP Java-type Db-attr

id int unique, not-null

uuid string unique

name string unique, not-null

members Set<Indicator> -

Page 14: District Health Information Software 2District Health ... · – Hibernate configuration – Testing – Development tips and conventionsDevelopment tips and conventions. DHIS 2DHIS

Domain modelDomain model

• DataSet– Set of data elements

Used to organize data entry / input– Used to organize data entry / input

DATASET Java-type Db-attr

id int unique, not-null

name string unique not nullname string unique, not-null

periodType PeriodType -

dataElements Collection<DataElement> -

Page 15: District Health Information Software 2District Health ... · – Hibernate configuration – Testing – Development tips and conventionsDevelopment tips and conventions. DHIS 2DHIS

Domain modelDomain model

• DataSet associations

PeriodType

1N

NDataSet DataElement

NN

N

Source

Page 16: District Health Information Software 2District Health ... · – Hibernate configuration – Testing – Development tips and conventionsDevelopment tips and conventions. DHIS 2DHIS

Domain modelDomain model

SourceDataElementGroup PeriodTypeOrgUnitGroupSet

DataValueDataElement PeriodOrgUnitGroup

DataSet Indicator IndicatorGroupOrganisationUnit

Expression IndicatorTypeUser

Core

AggregatedDataValue AggregatedIndicatorValueValidationRule

Page 17: District Health Information Software 2District Health ... · – Hibernate configuration – Testing – Development tips and conventionsDevelopment tips and conventions. DHIS 2DHIS

Project StructureProject StructureRoot POM.

Contains dependency Building root POMContains dependencymanagement and

project aggregation.

will build all projectsexcept dhis-web

Service POM.Root as parent,

contains project aggreg.for service modules

Support POM.Support POM.Root as parent,

contains project aggreg.for support modules

Web POM.Root as parent.

Not included in root

All projects followthe Maven standardNot included in root

project aggregation. directory layout

Page 18: District Health Information Software 2District Health ... · – Hibernate configuration – Testing – Development tips and conventionsDevelopment tips and conventions. DHIS 2DHIS

Project StructureProject StructureWeb root POM. Building web root Root as parent.

Contains dependencymanagement and

project aggregation.

POM will build all web projects

p j gg g

Web maintenance POM.Web root as parent.

C t i j tContains projectaggregation.

Page 19: District Health Information Software 2District Health ... · – Hibernate configuration – Testing – Development tips and conventionsDevelopment tips and conventions. DHIS 2DHIS

Application designApplication design

Presentation layerStruts

Service layerLogic Model

Method invocation

yg

Method invocation

Store layerHibernate

ANSI SQL

Relational database

Page 20: District Health Information Software 2District Health ... · – Hibernate configuration – Testing – Development tips and conventionsDevelopment tips and conventions. DHIS 2DHIS

Store layerStore layer

O t d i bj t• One store per domain object• Performs CRUD operations• Hibernate implementations of each store• Hibernate implementations of each store• All stores have dependencies on the

LocalSessionFactoryBean (Spring)

HibernateDataElementStore

LocalSessionFactoryBean (Spring)

HibernateDataElementStore

LocalSessionFactoryBean

HibernateIndicatorStore

Provides a HibernateSessionFactory

Page 21: District Health Information Software 2District Health ... · – Hibernate configuration – Testing – Development tips and conventionsDevelopment tips and conventions. DHIS 2DHIS

Store layer overviewStore layer overviewCore

DataElementStore DataSetStore SourceStoreCore

module

DataValueStore ExpressionStore

IndicatorStore

PeriodStore

IndicatorStore

DataMartStoreDatamart module

OrgUnitStore UserStoreOrgUnit module

User module

OrgUnitGroupStore Reportingmodule ReportTableStore

Page 22: District Health Information Software 2District Health ... · – Hibernate configuration – Testing – Development tips and conventionsDevelopment tips and conventions. DHIS 2DHIS

Hibernate configurationHibernate configuration

• ConfigurationProvider looks for hibernate.properties:– Inside dhis-support-hibernate (hibernate-default.properties)

On the classpath (src/main/resources) in all projects– On the classpath (src/main/resources) in all projects– In DHIS2_HOME directory (env variable)

• The last file gets precedenceCreate file hibernate.propertiesand put in DHIS2_HOME folderfor configuration to take effect

The last file gets precedence• Separate properties file for testing

– hibernate-test.propertieshibernate test.properties

• PostgreSQL configuration:

hibernate.dialect = org.hibernate.dialect.PostgreSQLDialecthibernate.connection.driver_class = org.postgresql.Driverhibernate.connection.url = jdbc:postgresql:dhis2hibernate.connection.username = dhishib t ti d dhi

Database mustbe created manually

hibernate.connection.password = dhis

Page 23: District Health Information Software 2District Health ... · – Hibernate configuration – Testing – Development tips and conventionsDevelopment tips and conventions. DHIS 2DHIS

Service layerService layer

• Service functionality:– Administration

Settings– Settings– Datamart– Import and exportp p– GIS / mapping– Reporting– User management

Page 24: District Health Information Software 2District Health ... · – Hibernate configuration – Testing – Development tips and conventionsDevelopment tips and conventions. DHIS 2DHIS

Service layer overviewService layer overview

DataElementService DataSetService IndicatorServiceCore

module

DataValueService ExpressionService PeriodService

OrgUnitService CurrentUserServiceOrgUnit module

User moduleOrgUnitService

OrgUnitGroupService

Cu e tUse Se cemodule module

UserSettingService

Aggregation module

AggregationService Datamartmodule

DataMartService

Page 25: District Health Information Software 2District Health ... · – Hibernate configuration – Testing – Development tips and conventionsDevelopment tips and conventions. DHIS 2DHIS

TestingTesting

Starts and caches a SpringApplicationContext and a

Hibernate session between tests +E ti d t b ith SQL

DhisConvenienceTest

Provides supportive methods for objectcreation, dates etc.

Empties database with SQL

Starts and caches a Spring(extends)

DhisSpringTest DhisTestApplication context and a

Hibernate session + transactionbetween tests

(extends)

DataSetServiceTest DataMartServiceTest

(extends)

Page 26: District Health Information Software 2District Health ... · – Hibernate configuration – Testing – Development tips and conventionsDevelopment tips and conventions. DHIS 2DHIS

Presentation layerPresentation layer

• Struts used as web framework

• Web modules can run independently or in the web portal

• The web portal assembles all web modules (WAR-files) into a complete application

• Common web functionality located in dhis-web-commons

• Common web resources located in dhis-web-commons-( j i t t l t )resources (css, javascript, templates)

Page 27: District Health Information Software 2District Health ... · – Hibernate configuration – Testing – Development tips and conventionsDevelopment tips and conventions. DHIS 2DHIS

Support projectsSupport projects

• DHIS Support External– Configuration manager

• Write and read configuration objects• Write and read configuration objects

– Location manager• Get file or stream for reading

G fil f i i• Get file or stream for writing• Relative to the DHIS2_HOME environment variable

• DHIS Support SystemS Suppo Sys e– Support functionality for processes, object deletion, startup

routines and more– Util classes for codecs, dates, math, PDF, text and more

Page 28: District Health Information Software 2District Health ... · – Hibernate configuration – Testing – Development tips and conventionsDevelopment tips and conventions. DHIS 2DHIS

Installing DHIS 2Installing DHIS 2

• Live package (all-in-one)– Embedded servlet container (Jetty)

Embedded database (H2)– Embedded database (H2)

• Manual installation– Install DBMS (PostgreSQL, MySQL)– Configuration setup– Install servlet container (Tomcat, Jetty)– Deploy DHIS 2 WAR file + BIRT Viewer

Page 29: District Health Information Software 2District Health ... · – Hibernate configuration – Testing – Development tips and conventionsDevelopment tips and conventions. DHIS 2DHIS

Collaboration toolsCollaboration tools

• DHIS 2 on Launchpad– launchpad.net/dhis2

Check out with Bazaar with lp:dhis2– Check out with Bazaar with lp:dhis2

• Developer mailing list• Developer mailing list– Subscribe: launchpad.net/~<username>/+editemails– Post: [email protected]: dhis2 [email protected]

• DHIS 2 site– dhis2.com– Documentation, downloads, screenshots

Page 30: District Health Information Software 2District Health ... · – Hibernate configuration – Testing – Development tips and conventionsDevelopment tips and conventions. DHIS 2DHIS

Development conventionsDevelopment conventions

• Follow the code style– Eclipse: http://heim.ifi.uio.no/joakibj/inf5750/dhis-code-style-eclipse.xml– Import in Eclipse: Properties – Java – Code style – Formatter – New

• Do not break the layered architectureStores for persistence– Stores for persistence

– Services for business logic– Web modules for GUI

• Write informative commit messages

Page 31: District Health Information Software 2District Health ... · – Hibernate configuration – Testing – Development tips and conventionsDevelopment tips and conventions. DHIS 2DHIS

Development tipsDevelopment tips

V ifi d d l t i t (Wi XP)• Verified development environment (Win XP):– Java 1.6.0_02– Maven 2.0.9Maven 2.0.9– Bazaar 1.18

C f• Create working sets in Eclipse to keep track of projects

U M J tt l i d i b d l t• Use Maven Jetty plugin during web development– Invoke with: $ mvn jetty:run-war

• Speed up building with Maven:– Without tests: $ mvn install –Dtest=skip –DfailIfNoTests=false– One test among others: $ mvn test –Dtest=NameOfTestClass*