dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24781
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12200: fix bug for j2me
------------------------------------------------------------
revno: 12200
committer: Lai <lai.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-09-23 15:00:15 +0700
message:
fix bug for j2me
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierStore.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/ActivityReportingService.java
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/DefaultPatientIdentifierService.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientIdentifierStore.java
dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.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/patient/PatientIdentifierService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierService.java 2013-09-23 04:29:22 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierService.java 2013-09-23 08:00:15 +0000
@@ -70,7 +70,7 @@
Patient getPatient( PatientIdentifierType idenType, String value );
- Collection<Patient> getPatientsByIdentifier( String identifier, int min, int max );
+ Collection<Patient> getPatientsByIdentifier( String identifier, Integer min, Integer max );
int countGetPatientsByIdentifier( String identifier );
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierStore.java 2013-09-23 04:29:22 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierStore.java 2013-09-23 08:00:15 +0000
@@ -68,7 +68,7 @@
Patient getPatient( PatientIdentifierType idenType, String value );
- Collection<Patient> getPatientsByIdentifier( String identifier, int min, int max );
+ Collection<Patient> getPatientsByIdentifier( String identifier, Integer min, Integer max );
int countGetPatientsByIdentifier( String identifier );
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/ActivityReportingService.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/ActivityReportingService.java 2013-09-10 16:29:20 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/ActivityReportingService.java 2013-09-23 08:00:15 +0000
@@ -85,7 +85,7 @@
public Patient addRelationship( Relationship enrollmentRelationship, int orgUnitId )
throws NotAllowedException;
- public Program getAllAnonymousProgram( int orgUnitId )
+ public Program getAllProgramByOrgUnit( int orgUnitId, String programType )
throws NotAllowedException;
public Program findProgram( String programInfo )
=== 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-18 09:04:09 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Patient.java 2013-09-23 08:00:15 +0000
@@ -267,8 +267,16 @@
DataOutputStream dout = new DataOutputStream( bout );
dout.writeInt( this.getId() );
- dout.writeUTF( this.getName() );
-
+
+ if ( name != null )
+ {
+ dout.writeBoolean( true );
+ dout.writeUTF( name );
+ }
+ else
+ {
+ dout.writeBoolean( false );
+ }
if ( organisationUnitName != null )
{
dout.writeBoolean( true );
=== 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-20 04:49:42 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2013-09-23 08:00:15 +0000
@@ -838,8 +838,11 @@
List<org.hisp.dhis.patient.PatientAttribute> atts;
patientModel.setId( patient.getId() );
- patientModel.setName( patient.getName() );
-
+
+ if ( patient.getName() != null )
+ {
+ patientModel.setName( patient.getName() );
+ }
Period period = new Period( new DateTime( patient.getBirthDate() ), new DateTime() );
patientModel.setAge( period.getYears() );
/*
@@ -850,7 +853,10 @@
{
patientModel.setOrganisationUnitName( patient.getOrganisationUnit().getName() );
}
- patientModel.setPhoneNumber( patient.getPhoneNumber() );
+ if ( patient.getPhoneNumber() != null )
+ {
+ patientModel.setPhoneNumber( patient.getPhoneNumber() );
+ }
this.setSetting( getSettings() );
@@ -908,9 +914,8 @@
identifiers
.add( new org.hisp.dhis.api.mobile.model.PatientIdentifier( idTypeName, id.getIdentifier() ) );
}
-
- patientModel.setIdentifiers( identifiers );
}
+ patientModel.setIdentifiers( identifiers );
patientModel.setPatientAttValues( patientAtts );
@@ -1313,15 +1318,24 @@
}
@Override
- public org.hisp.dhis.api.mobile.model.LWUITmodel.Program getAllAnonymousProgram( int orgUnitId )
+ public org.hisp.dhis.api.mobile.model.LWUITmodel.Program getAllProgramByOrgUnit( int orgUnitId, String programType )
throws NotAllowedException
{
String programsInfo = "";
OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( orgUnitId );
- List<Program> tempPrograms = new ArrayList<Program>(
- programService.getProgramsByCurrentUser( Program.SINGLE_EVENT_WITHOUT_REGISTRATION ) );
+ List<Program> tempPrograms = null;
+
+ if ( Integer.valueOf( programType )==( Program.SINGLE_EVENT_WITHOUT_REGISTRATION ) )
+ {
+ tempPrograms = new ArrayList<Program>( programService.getProgramsByCurrentUser( Program.SINGLE_EVENT_WITHOUT_REGISTRATION ) );
+ }
+ else if ( Integer.valueOf( programType )==( Program.MULTIPLE_EVENTS_WITH_REGISTRATION ) )
+ {
+ tempPrograms = new ArrayList<Program>( programService.getProgramsByCurrentUser( Program.MULTIPLE_EVENTS_WITH_REGISTRATION ) );
+ }
+
List<Program> programs = new ArrayList<Program>();
for ( Program program : tempPrograms )
@@ -1336,9 +1350,9 @@
{
if ( programs.size() == 1 )
{
- Program anonymousProgram = programs.get( 0 );
+ Program program = programs.get( 0 );
- return getMobileAnonymousProgram( anonymousProgram );
+ return getMobileAnonymousProgram( program );
}
else
{
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientIdentifierService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientIdentifierService.java 2013-09-23 04:29:22 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientIdentifierService.java 2013-09-23 08:00:15 +0000
@@ -128,7 +128,7 @@
return patientIdentifierStore.getPatient( idenType, value );
}
- public Collection<Patient> getPatientsByIdentifier( String identifier, int min, int max )
+ public Collection<Patient> getPatientsByIdentifier( String identifier, Integer min, Integer max )
{
return patientIdentifierStore.getPatientsByIdentifier( identifier, min, max );
}
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java 2013-09-18 03:49:35 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java 2013-09-23 08:00:15 +0000
@@ -260,9 +260,9 @@
public Collection<Patient> getPatientsForMobile( String searchText, int orgUnitId )
{
Set<Patient> patients = new HashSet<Patient>();
- patients.addAll( patientIdentifierService.getPatientsByIdentifier( searchText, 0, Integer.MAX_VALUE ) );
- patients.addAll( getPatientsByNames( searchText, 0, Integer.MAX_VALUE ) );
- patients.addAll( getPatientsByPhone( searchText, 0, Integer.MAX_VALUE ) );
+ patients.addAll( patientIdentifierService.getPatientsByIdentifier( searchText, 0, Integer.MAX_VALUE) );
+ patients.addAll( getPatientsByNames( searchText, null, null ) );
+ patients.addAll( getPatientsByPhone( searchText, null, null ) );
// if an org-unit has been selected, filter out every patient that has a
// different org-unit
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientIdentifierStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientIdentifierStore.java 2013-09-23 04:29:22 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientIdentifierStore.java 2013-09-23 08:00:15 +0000
@@ -31,6 +31,7 @@
import java.util.Collection;
import java.util.Date;
+import org.hibernate.Criteria;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
@@ -130,10 +131,18 @@
}
@SuppressWarnings( "unchecked" )
- public Collection<Patient> getPatientsByIdentifier( String identifier, int min, int max )
- {
- return getCriteria( Restrictions.ilike( "identifier", "%" + identifier + "%" ) )
+ public Collection<Patient> getPatientsByIdentifier( String identifier, Integer min, Integer max )
+ {
+ if( min != null & max != null )
+ {
+ return getCriteria( Restrictions.ilike( "identifier", "%" + identifier + "%" ) )
.setProjection( Projections.property( "patient" ) ).setFirstResult( min ).setMaxResults( max ).list();
+ }
+ else
+ {
+ return getCriteria( Restrictions.ilike( "identifier", "%" + identifier + "%" ) )
+ .setProjection( Projections.property( "patient" ) ).list();
+ }
}
public int countGetPatientsByIdentifier( String identifier )
=== modified file 'dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java'
--- dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java 2013-09-20 04:49:42 +0000
+++ dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java 2013-09-23 08:00:15 +0000
@@ -383,7 +383,7 @@
public Program getAnonymousProgram( @PathVariable int id, @RequestHeader( "programType" ) String programType )
throws NotAllowedException
{
- return activityReportingService.getAllAnonymousProgram( id );
+ return activityReportingService.getAllProgramByOrgUnit( id, programType );
}
@RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/LWUIT/orgUnits/{id}/findProgram" )