← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7599: Add function to search by age for patients in Registration and Entry form.

 

------------------------------------------------------------
revno: 7599
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-07-13 09:46:02 +0700
message:
  Add function to search by age for patients in Registration and Entry form.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/Patient.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/webapp/dhis-web-caseentry/dataEntryForm.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm


--
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/Patient.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/Patient.java	2012-07-10 14:05:24 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/Patient.java	2012-07-13 02:46:02 +0000
@@ -64,6 +64,7 @@
     public static String PREFIX_PATIENT_ATTRIBUTE = "attr";
     public static String PREFIX_PROGRAM = "prg";
     public static String FIXED_ATTR_BIRTH_DATE = "birthDate";
+    public static String FIXED_ATTR_AGE = "age";
 
     private Integer id;
 

=== 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	2012-07-10 14:05:24 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java	2012-07-13 02:46:02 +0000
@@ -325,6 +325,10 @@
                 {
                     patientWhere += " p." + id + value;
                 }
+                else if ( id.equals( Patient.FIXED_ATTR_AGE ) )
+                {
+                    patientWhere += " ((DATE(now()) - DATE(birthdate))/365) " + value;
+                }
                 else
                 {
                     patientWhere += " lower(p." + id + ")='" + value + "'";
@@ -375,7 +379,7 @@
         {
             sql += statementBuilder.limitRecord( min, max );
         }
-
+System.out.println("\n\n === \n SQL : " + sql );
         return sql;
     }
 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm	2012-07-12 10:23:25 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm	2012-07-13 02:46:02 +0000
@@ -68,7 +68,7 @@
 						#set( $hasOptionSet = 'false')
 					#end
 					#if( $programStageDataElement.dataElement.textType == "longText" )
-						<textarea name="entryfield" type="text" data="{compulsory: $programStageDataElement.compulsory }" id="$id" name="entryfield" value="$!encoder.htmlEncode( $patientDataValue.value )" onchange="saveVal( $programStageDataElement.dataElement.id )" onkeypress="return keyPress(event, this)" tabindex="$tabIndex" ></textarea>
+						<textarea name="entryfield" type="text" data="{compulsory: $programStageDataElement.compulsory }" id="$id" name="entryfield" onchange="saveVal( $programStageDataElement.dataElement.id )" onkeypress="return keyPress(event, this)" tabindex="$tabIndex" >$!encoder.htmlEncode( $patientDataValue.value )</textarea>
 					#elseif( $programStageDataElement.dataElement.type == "bool" )
 						<select name="entryfield" data="{compulsory: $programStageDataElement.compulsory }" id="$id" onchange="saveOpt( $programStageDataElement.dataElement.id )" tabindex="$tabIndex">
 							<option value="">[$i18n.getString( "select_value" )]</option>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2012-07-12 10:23:25 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2012-07-13 02:46:02 +0000
@@ -116,6 +116,10 @@
 	{
 		element.replaceWith( getGenderSelector() );
 	}
+	else if ( attributeId=='fixedAttr_age' )
+	{
+		element.replaceWith( getAgeTextBox() );
+	}
 	else if ( valueType=='YES/NO' )
 	{
 		element.replaceWith( getTrueFalseBox() );
@@ -126,13 +130,6 @@
 	}
 }
 
-function getDateField( container )
-{
-	var dateField = '<select id="dateOperator" style="width:40px;" name="dateOperator" ><option value="="> = </option><option value="<"> < </option><option value="<="> <= </option><option value=">"> > </option><option value=">="> >= </option></select>';
-	dateField += '<input type="text" id="searchText_' + container + '" name="searchText" style="width:200px;">';
-	return dateField;
-}
-
 function getTrueFalseBox()
 {
 	var trueFalseBox  = '<select id="searchText" name="searchText">';
@@ -152,6 +149,13 @@
 	return genderSelector;
 }
 
+function getAgeTextBox( container )
+{
+	var ageField = '<select id="dateOperator" style="width:40px;" name="dateOperator" ><option value="="> = </option><option value="<"> < </option><option value="<="> <= </option><option value=">"> > </option><option value=">="> >= </option></select>';
+	ageField += '<input type="text" id="searchText_' + container + '" name="searchText" style="width:200px;">';
+	return ageField;
+}
+
 //-----------------------------------------------------------------------------
 // Search Patient
 //-----------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm	2012-07-06 09:59:36 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm	2012-07-13 02:46:02 +0000
@@ -34,8 +34,8 @@
 					<option value="iden">$i18n.getString( "search_by_name_identifier" )</option>
 					<option value="prg">$i18n.getString( "search_by_program" )</option>
 					<option value="fixedAttr_birthDate">$i18n.getString( "date_of_birth" )</option>
+					<option value="fixedAttr_age">$i18n.getString( "age_year" )</option>
 					<option value="fixedAttr_gender">$i18n.getString( "gender" )</option>
-					<!-- option value="-3">$i18n.getString( "age" )</option -->
 					<option value="fixedAttr_phoneNumber">$i18n.getString( "phone_number" )</option>
 					#foreach( $attribute in $patientAttributes )
 						<option value="attr_$attribute.id" valueType='$attribute.valueType'>$encoder.htmlEncode( $attribute.name )</option>