← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12054: remove first, middle, last name from Patient (wip)

 

------------------------------------------------------------
revno: 12054
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-09-12 09:26:17 +0200
message:
  remove first, middle, last name from Patient (wip)
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.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/HibernatePatientStore.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidateAddRelationshipPatientAction.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/PatientService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java	2013-09-10 13:10:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java	2013-09-12 07:26:17 +0000
@@ -63,14 +63,12 @@
     /**
      * Search Patient base on firstname/middlename/lastname/birthDate/gender
      *
-     * @param firstName
-     * @param middleName
-     * @param lastName
+     * @param name
      * @param birthdate
      * @param gender
      * @return Patient List
      */
-    Collection<Patient> getPatients( String firstName, String middleName, String lastName, Date birthdate, String gender );
+    Collection<Patient> getPatients( String name, Date birthdate, String gender );
 
     /**
      * Search Patient base on gender
@@ -83,7 +81,7 @@
     /**
      * Search Patient base on birthDate
      *
-     * @param birthdate
+     * @param birthDate
      * @return Patient List
      */
     Collection<Patient> getPatientsByBirthDate( Date birthDate );

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java	2013-09-10 13:10:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java	2013-09-12 07:26:17 +0000
@@ -52,7 +52,7 @@
 
     Collection<Patient> getByNames( String name, Integer min, Integer max );
 
-    Collection<Patient> get( String firstName, String middleName, String lastName, Date birthdate, String gender );
+    Collection<Patient> get( String name, Date birthdate, String gender );
 
     Collection<Patient> getByOrgUnit( OrganisationUnit organisationUnit, Integer min, Integer 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-10 13:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java	2013-09-12 07:26:17 +0000
@@ -198,10 +198,9 @@
     }
 
     @Override
-    public Collection<Patient> getPatients( String firstName, String middleName, String lastName, Date birthdate,
-        String gender )
+    public Collection<Patient> getPatients( String name, Date birthdate, String gender )
     {
-        return patientStore.get( firstName, middleName, lastName, birthdate, gender );
+        return patientStore.get( name, birthdate, gender );
     }
 
     @Override

=== 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-10 17:10:43 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java	2013-09-12 07:26:17 +0000
@@ -148,26 +148,17 @@
 
     @Override
     @SuppressWarnings( "unchecked" )
-    public Collection<Patient> get( String firstName, String middleName, String lastName, Date birthdate, String gender )
+    public Collection<Patient> get( String name, Date birthdate, String gender )
 
     {
         Criteria crit = getCriteria();
         Conjunction con = Restrictions.conjunction();
-
-        if ( StringUtils.isNotBlank( firstName ) )
-            con.add( Restrictions.ilike( "firstName", firstName ) );
-
-        if ( StringUtils.isNotBlank( middleName ) )
-            con.add( Restrictions.ilike( "middleName", middleName ) );
-
-        if ( StringUtils.isNotBlank( lastName ) )
-            con.add( Restrictions.ilike( "lastName", lastName ) );
-
+        con.add( Restrictions.ilike( "name", name ) );
         con.add( Restrictions.eq( "gender", gender ) );
         con.add( Restrictions.eq( "birthDate", birthdate ) );
         crit.add( con );
 
-        crit.addOrder( Order.asc( "firstName" ) );
+        crit.addOrder( Order.asc( "name" ) );
 
         return crit.list();
     }
@@ -438,7 +429,7 @@
         String selector = count ? "count(*) " : "* ";
 
         String sql = "select " + selector
-            + " from ( select distinct p.patientid, p.firstname, p.middlename, p.lastname, p.gender, p.phonenumber,";
+            + " from ( select distinct p.patientid, p.name, p.gender, p.phonenumber,";
 
         if ( identifierTypes != null )
         {
@@ -466,7 +457,7 @@
 
         String patientWhere = "";
         String patientOperator = " where ";
-        String patientGroupBy = " GROUP BY  p.patientid, p.firstname, p.middlename, p.lastname, p.gender, p.phonenumber ";
+        String patientGroupBy = " GROUP BY  p.patientid, p.name, p.gender, p.phonenumber ";
         String otherWhere = "";
         String operator = " where ";
         String orderBy = "";
@@ -711,12 +702,12 @@
             if ( isPriorityEvent )
             {
                 subSQL += ",pgi.followup ";
-                orderBy = " ORDER BY pgi.followup desc, p.patientid, p.firstname, p.middlename, p.lastname, duedate asc ";
+                orderBy = " ORDER BY pgi.followup desc, p.patientid, p.name, duedate asc ";
                 patientGroupBy += ",pgi.followup ";
             }
             else
             {
-                orderBy = " ORDER BY p.patientid, p.firstname, p.middlename, p.lastname, duedate asc ";
+                orderBy = " ORDER BY p.patientid, p.name, duedate asc ";
             }
             sql = sql + subSQL + from + " inner join programinstance pgi on " + " (pgi.patientid=p.patientid) "
                 + " inner join programstageinstance psi on " + " (psi.programinstanceid=pgi.programinstanceid) "
@@ -750,7 +741,7 @@
         {
             sql += statementBuilder.limitRecord( min, max );
         }
-        
+
         return sql;
     }
 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidateAddRelationshipPatientAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidateAddRelationshipPatientAction.java	2013-09-06 08:24:36 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidateAddRelationshipPatientAction.java	2013-09-12 07:26:17 +0000
@@ -158,36 +158,16 @@
         // Check duplicated patient
         // ---------------------------------------------------------------------
 
-        int startIndex = fullName.indexOf( ' ' );
-        int endIndex = fullName.lastIndexOf( ' ' );
-
-        String firstName = fullName.substring( 0, startIndex );
-        String middleName;
-        String lastName;
-
-        if ( startIndex == endIndex )
-        {
-            middleName = "";
-            lastName = fullName.substring( startIndex, fullName.length() );
-        }
-        else
-        {
-            middleName = fullName.substring( startIndex + 1, endIndex );
-            lastName = fullName.substring( endIndex, fullName.length() );
-        }
-
         if ( !checkedDuplicate )
         {
-
             // Check duplication name, birthdate, gender
-            patients = patientService.getPatients( firstName, middleName, lastName, format.parseDate( birthDate ),
-                gender );
+            patients = patientService.getPatients( fullName, format.parseDate( birthDate ), gender );
 
             if ( patients != null && patients.size() > 0 )
             {
                 message = i18n.getString( "patient_duplicate" );
-
                 boolean flagDuplicate = false;
+
                 for ( Patient p : patients )
                 {
                     if ( id == null || (id != null && p.getId() != id) )

=== 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-11 04:12:50 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientAction.java	2013-09-12 07:26:17 +0000
@@ -122,32 +122,9 @@
         {
             fullName = fullName.trim();
 
-            int startIndex = fullName.indexOf( ' ' );
-            int endIndex = fullName.lastIndexOf( ' ' );
-
-            String firstName = fullName.toString();
-            String middleName = "";
-            String lastName = "";
-
-            if ( fullName.indexOf( ' ' ) != -1 )
-            {
-                firstName = fullName.substring( 0, startIndex );
-                if ( startIndex == endIndex )
-                {
-                    middleName = "";
-                    lastName = fullName.substring( startIndex + 1, fullName.length() );
-                }
-                else
-                {
-                    middleName = fullName.substring( startIndex + 1, endIndex );
-                    lastName = fullName.substring( endIndex + 1, fullName.length() );
-                }
-            }
-
             if ( !checkedDuplicate && birthDate != null && gender != null )
             {
-                patients = patientService.getPatients( firstName, middleName, lastName, format.parseDate( birthDate ),
-                    gender );
+                patients = patientService.getPatients( fullName, format.parseDate( birthDate ), gender );
 
                 if ( patients != null && patients.size() > 0 )
                 {