dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24490
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12009: [j2me] change patient model, improve search patient function, fix minor bugs
------------------------------------------------------------
revno: 12009
committer: Lai <lai.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-09-10 18:29:23 +0700
message:
[j2me] change patient model, improve search patient function, fix minor bugs
modified:
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Patient.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.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-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Patient.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Patient.java 2013-09-10 07:22:13 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Patient.java 2013-09-10 11:29:23 +0000
@@ -86,7 +86,13 @@
private String phoneNumber;
private String organisationUnitName;
+
+ private List<Program> completedPrograms;
+ // -------------------------------------------------------------------------
+ // Getters and setters
+ // -------------------------------------------------------------------------
+
public List<PatientIdentifier> getIdentifiers()
{
return identifiers;
@@ -313,6 +319,20 @@
this.organisationUnitName = organisationUnitName;
}
+ public List<Program> getCompletedPrograms()
+ {
+ return completedPrograms;
+ }
+
+ public void setCompletedPrograms( List<Program> completedPrograms )
+ {
+ this.completedPrograms = completedPrograms;
+ }
+
+ // -------------------------------------------------------------------------
+ // Override Methods
+ // -------------------------------------------------------------------------
+
@Override
public void serialize( DataOutputStream out )
throws IOException
@@ -415,12 +435,13 @@
dout.writeInt( 0 );
}
- // Write Program
+ // Write Programs
dout.writeInt( programs.size() );
for ( Program each : programs )
{
each.serialize( dout );
}
+
/*dout.writeInt( programsID.size() );
for ( Integer each : programsID )
{
@@ -457,6 +478,13 @@
{
each.serialize( dout );
}
+
+ // Write completed Programs
+ dout.writeInt( completedPrograms.size() );
+ for ( Program each : completedPrograms )
+ {
+ each.serialize( dout );
+ }
bout.flush();
bout.writeTo( out );
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2013-09-10 09:00:47 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2013-09-10 11:29:23 +0000
@@ -846,8 +846,13 @@
private org.hisp.dhis.api.mobile.model.LWUITmodel.Patient getPatientModel( Patient patient )
{
org.hisp.dhis.api.mobile.model.LWUITmodel.Patient patientModel = new org.hisp.dhis.api.mobile.model.LWUITmodel.Patient();
+
List<PatientAttribute> patientAtts = new ArrayList<PatientAttribute>();
+
List<org.hisp.dhis.api.mobile.model.LWUITmodel.Program> mobileProgramList = new ArrayList<org.hisp.dhis.api.mobile.model.LWUITmodel.Program>();
+
+ List<org.hisp.dhis.api.mobile.model.LWUITmodel.Program> mobileCompletedProgramList = new ArrayList<org.hisp.dhis.api.mobile.model.LWUITmodel.Program>();
+
List<org.hisp.dhis.patient.PatientAttribute> atts;
patientModel.setId( patient.getId() );
@@ -945,20 +950,36 @@
patientModel.setPatientAttValues( patientAtts );
- // Set all programs
-
+ // Set current programs
List<ProgramInstance> listOfProgramInstance = new ArrayList<ProgramInstance>(
- programInstanceService.getProgramInstances( patient ) );
+ programInstanceService.getProgramInstances( patient, ProgramInstance.STATUS_ACTIVE ) );
if ( listOfProgramInstance.size() > 0 )
{
+ System.out.println("current");
for ( ProgramInstance each : listOfProgramInstance )
{
+ System.out.println(each.getProgram().getName());
mobileProgramList.add( getMobileProgram( patient, each ) );
}
}
-
patientModel.setPrograms( mobileProgramList );
+
+ // Set completed programs
+ List<ProgramInstance> listOfCompletedProgramInstance = new ArrayList<ProgramInstance>(
+ programInstanceService.getProgramInstances( patient, ProgramInstance.STATUS_COMPLETED ) );
+
+ if ( listOfCompletedProgramInstance.size() > 0 )
+ {
+ System.out.println("completed");
+ for ( ProgramInstance each : listOfCompletedProgramInstance )
+ {
+ System.out.println(each.getProgram().getName());
+ mobileCompletedProgramList.add( getMobileProgram( patient, each ) );
+ }
+ }
+ patientModel.setCompletedPrograms( mobileCompletedProgramList );
+
/*
* List<Integer> mobileProgramIDList = new ArrayList<Integer>(); for (
* Program eachProgram : patient.getPrograms()) {
@@ -1170,8 +1191,7 @@
String dataElementName;
- if ( programStageDataElement.getDataElement().getFormName() != null
- || !programStageDataElement.getDataElement().getFormName().trim().equals( "" ) )
+ if ( programStageDataElement.getDataElement().getFormName() != null && !programStageDataElement.getDataElement().getFormName().trim().equals( "" ) )
{
dataElementName = programStageDataElement.getDataElement().getFormName();
}
@@ -1933,6 +1953,7 @@
{
Collection<Patient> patients = new HashSet<Patient>( patientService.getPatientsForMobile( keyword, orgUnitId ) );
OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( orgUnitId );
+
if ( programId != 0 )
{
Program program = programService.getProgram( programId );
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java 2013-09-09 18:25:50 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java 2013-09-10 11:29:23 +0000
@@ -193,9 +193,16 @@
public Collection<Patient> getByOrgUnitProgram( OrganisationUnit organisationUnit, Program program, Integer min,
Integer max )
{
- Criteria criteria = getCriteria( Restrictions.eq( "organisationUnit", organisationUnit ) ).createAlias(
+ Criteria criteria;
+ if ( organisationUnit != null )
+ {
+ criteria = getCriteria( Restrictions.eq( "organisationUnit", organisationUnit ) ).createAlias(
"programs", "program" ).add( Restrictions.eq( "program.id", program.getId() ) );
-
+ }
+ else
+ {
+ criteria = getCriteria().createAlias("programs", "program" ).add( Restrictions.eq( "program.id", program.getId() ) );
+ }
criteria.addOrder( Order.desc( "id" ) );
if ( min != null && max != null )