dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24517
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12033: Set uniqueness across all identifier types.
------------------------------------------------------------
revno: 12033
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-09-11 11:12:50 +0700
message:
Set uniqueness across all identifier types.
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-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientIdentifierService.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientIdentifierStore.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientAction.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-08-23 15:56:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierService.java 2013-09-11 04:12:50 +0000
@@ -47,26 +47,29 @@
PatientIdentifier getPatientIdentifier( int id );
PatientIdentifier getPatientIdentifier( Patient patient );
-
+
Collection<PatientIdentifier> getAllPatientIdentifiers();
-
+
Collection<PatientIdentifier> getPatientIdentifiersByType( PatientIdentifierType identifierType );
Collection<PatientIdentifier> getPatientIdentifiersByIdentifier( String identifier );
-
- PatientIdentifier getPatientIdentifier(String identifier, Patient patient);
-
- PatientIdentifier getPatientIdentifier(PatientIdentifierType identifierType, Patient patient);
-
+
+ PatientIdentifier getPatientIdentifier( String identifier, Patient patient );
+
+ PatientIdentifier getPatientIdentifier( PatientIdentifierType identifierType, Patient patient );
+
Collection<PatientIdentifier> getPatientIdentifiers( Patient patient );
-
+
PatientIdentifier get( PatientIdentifierType type, String identifier );
-
- Patient getPatient( PatientIdentifierType idenType, String value);
-
+
+ Patient getPatient( PatientIdentifierType idenType, String value );
+
Collection<Patient> getPatientsByIdentifier( String identifier, int min, int max );
-
+
int countGetPatientsByIdentifier( String identifier );
-
- Collection<PatientIdentifier> getPatientIdentifiers(Collection<PatientIdentifierType> identifierTypes, Patient patient);
+
+ Collection<PatientIdentifier> getPatientIdentifiers( Collection<PatientIdentifierType> identifierTypes,
+ Patient patient );
+
+ boolean checkDuplicateIdentifier( 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-08-23 15:56:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierStore.java 2013-09-11 04:12:50 +0000
@@ -66,4 +66,6 @@
Collection<PatientIdentifier> get(Collection<PatientIdentifierType> identifierTypes, Patient patient);
+ boolean checkDuplicateIdentifier( String identifier );
+
}
=== 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-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientIdentifierService.java 2013-09-11 04:12:50 +0000
@@ -69,7 +69,7 @@
{
patientIdentifierStore.update( patientIdentifier );
}
-
+
public PatientIdentifier getPatientIdentifier( int id )
{
return patientIdentifierStore.get( id );
@@ -79,7 +79,7 @@
{
return patientIdentifierStore.get( patient );
}
-
+
public Collection<PatientIdentifier> getAllPatientIdentifiers()
{
return patientIdentifierStore.getAll();
@@ -94,12 +94,12 @@
{
return patientIdentifierStore.getByIdentifier( identifier );
}
-
+
public PatientIdentifier getPatientIdentifier( String identifier, Patient patient )
{
return patientIdentifierStore.getPatientIdentifier( identifier, patient );
}
-
+
public PatientIdentifier getPatientIdentifier( PatientIdentifierType identifierType, Patient patient )
{
return patientIdentifierStore.getPatientIdentifier( identifierType, patient );
@@ -109,7 +109,7 @@
{
return patientIdentifierStore.getPatientIdentifiers( patient );
}
-
+
public PatientIdentifier get( PatientIdentifierType type, String identifier )
{
return patientIdentifierStore.get( type, identifier );
@@ -119,20 +119,26 @@
{
return patientIdentifierStore.getPatient( idenType, value );
}
-
+
public Collection<Patient> getPatientsByIdentifier( String identifier, int min, int max )
{
return patientIdentifierStore.getPatientsByIdentifier( identifier, min, max );
}
-
+
public int countGetPatientsByIdentifier( String identifier )
{
return patientIdentifierStore.countGetPatientsByIdentifier( identifier );
}
-
- public Collection<PatientIdentifier> getPatientIdentifiers(Collection<PatientIdentifierType> identifierTypes, Patient patient)
+
+ public Collection<PatientIdentifier> getPatientIdentifiers( Collection<PatientIdentifierType> identifierTypes,
+ Patient patient )
{
return patientIdentifierStore.get( identifierTypes, patient );
}
-
+
+ @Override
+ public boolean checkDuplicateIdentifier( String identifier )
+ {
+ return patientIdentifierStore.checkDuplicateIdentifier( identifier );
+ }
}
=== 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-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientIdentifierStore.java 2013-09-11 04:12:50 +0000
@@ -104,8 +104,8 @@
@SuppressWarnings( "unchecked" )
public Collection<Patient> getPatientsByIdentifier( String identifier, int min, int max )
{
- return getCriteria( Restrictions.ilike( "identifier", "%" + identifier + "%" ) ).setProjection(
- Projections.property( "patient" ) ).setFirstResult( min ).setMaxResults( max ).list();
+ return getCriteria( Restrictions.ilike( "identifier", "%" + identifier + "%" ) )
+ .setProjection( Projections.property( "patient" ) ).setFirstResult( min ).setMaxResults( max ).list();
}
public int countGetPatientsByIdentifier( String identifier )
@@ -122,4 +122,10 @@
.list();
}
+ public boolean checkDuplicateIdentifier( String identifier )
+ {
+ Number rs = (Number) getCriteria( Restrictions.ilike( "identifier", identifier ) ).setProjection(
+ Projections.rowCount() ).uniqueResult();
+ return rs != null ? true: false;
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientAction.java 2013-09-06 08:24:36 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientAction.java 2013-09-11 04:12:50 +0000
@@ -214,12 +214,11 @@
if ( StringUtils.isNotBlank( value ) )
{
- PatientIdentifier identifier = patientIdentifierService.get( idType, value );
+ boolean isDuplicate = patientIdentifierService.checkDuplicateIdentifier( value );
- if ( identifier != null
- && (id == null || identifier.getPatient().getId() != id) )
+ if ( isDuplicate )
{
- idDuplicate += idType.getName() + ", ";
+ idDuplicate += value + ", ";
}
}
}