dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #13318
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4236: Change popup to dialog and remove unused methods in Patient module.
------------------------------------------------------------
revno: 4236
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-07-29 15:58:35 +0700
message:
Change popup to dialog and remove unused methods in Patient module.
modified:
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/AddPatientAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ValidatePatientAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/VerifyOrganisationUnitHasParentAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addPatientForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addRelationshipPatientForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/commons.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patient.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/relationshipPatient.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/underage.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/underAgeForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updatePatientForm.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-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 2011-05-26 03:43:41 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java 2011-07-29 08:58:35 +0000
@@ -172,14 +172,14 @@
Conjunction con = Restrictions.conjunction();
if ( StringUtils.isNotBlank( firstName ) )
- con.add( Restrictions.eq( "firstName", firstName ) );
+ con.add( Restrictions.ilike( "firstName", firstName ) );
if ( StringUtils.isNotBlank( middleName ) )
- con.add( Restrictions.eq( "middleName", middleName ) );
+ con.add( Restrictions.ilike( "middleName", middleName ) );
if ( StringUtils.isNotBlank( lastName ) )
- con.add( Restrictions.eq( "lastName", lastName ) );
-
+ con.add( Restrictions.ilike( "lastName", lastName ) );
+
con.add( Restrictions.eq( "gender", gender ) );
con.add( Restrictions.eq( "birthDate", birthdate ) );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/AddPatientAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/AddPatientAction.java 2011-07-11 03:52:31 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/AddPatientAction.java 2011-07-29 08:58:35 +0000
@@ -29,14 +29,13 @@
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
-import org.apache.struts2.ServletActionContext;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.NumberUtils;
+import org.apache.struts2.ServletActionContext;
import org.hisp.dhis.i18n.I18nFormat;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ValidatePatientAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ValidatePatientAction.java 2011-03-31 01:42:05 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ValidatePatientAction.java 2011-07-29 08:58:35 +0000
@@ -185,7 +185,7 @@
{
patients = patientService.getPatient( firstName, middleName, lastName, format.parseDate( birthDate ),
gender );
-
+
if ( patients != null && patients.size() > 0 )
{
message = i18n.getString( "patient_duplicate" );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/VerifyOrganisationUnitHasParentAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/VerifyOrganisationUnitHasParentAction.java 2011-05-13 09:11:13 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/VerifyOrganisationUnitHasParentAction.java 2011-07-29 08:58:35 +0000
@@ -28,6 +28,7 @@
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.patient.state.SelectedStateManager;
import com.opensymphony.xwork2.Action;
@@ -50,6 +51,13 @@
this.organisationUnitService = organisationUnitService;
}
+ private SelectedStateManager selectedStateManager;
+
+ public void setSelectedStateManager( SelectedStateManager selectedStateManager )
+ {
+ this.selectedStateManager = selectedStateManager;
+ }
+
// -------------------------------------------------------------------------
// Input/output
// -------------------------------------------------------------------------
@@ -67,8 +75,7 @@
}
private String message;
-
-
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -76,8 +83,14 @@
public String execute()
throws Exception
{
+ selectedStateManager.clearListAll();
+ selectedStateManager.clearSearchingAttributeId();
+ selectedStateManager.clearSortingAttributeId();
+ selectedStateManager.clearSearchText();
+ selectedStateManager.clearSelectedProgram();
+
message = "";
-
+
OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( orgunitId );
if ( organisationUnit == null )
@@ -91,7 +104,7 @@
}
message = organisationUnit.getName();
-
+
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2011-07-28 06:36:51 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2011-07-29 08:58:35 +0000
@@ -359,6 +359,8 @@
scope="prototype">
<property name="organisationUnitService"
ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+ <property name="selectedStateManager"
+ ref="org.hisp.dhis.patient.state.SelectedStateManager" />
</bean>
<bean id="org.hisp.dhis.patient.action.patient.SearchPatientFormAction"
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2011-07-28 06:36:51 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2011-07-29 08:58:35 +0000
@@ -475,4 +475,8 @@
validation_criteria_management = Validation criteria management
aggregation_data_element = Aggregation data element
aggregation_expression = Aggregation expression
-aggregation_data_element_in_use = Aggregation data element is in use
\ No newline at end of file
+aggregation_data_element_in_use = Aggregation data element is in use
+advanced_search = Advanced search
+add_more_option_to_search = Add more option to search
+duplicated_patient_list = Duplicated patient list
+specfiy_birth_date_or_age = Specfiy birth date or age
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml 2011-07-28 06:36:51 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml 2011-07-29 08:58:35 +0000
@@ -310,12 +310,9 @@
<param name="javascripts">
../dhis-web-commons/ouwt/ouwt.js
,javascript/commons.js
- ,javascript/date.js
,javascript/patient.js
,javascript/relationship.js
,javascript/relationshipPatient.js
- ,../dhis-web-commons/javascripts/jQuery/ui/ui.thickbox.min.js
- ,../dhis-web-commons/javascripts/jQuery/ui/jquery.cluetip.min.js
</param>
</action>
@@ -416,9 +413,10 @@
<action name="showAddRepresentative"
class="org.hisp.dhis.patient.action.patient.ShowAddRepresentativeAction">
- <result name="success" type="velocity">/popup.vm</result>
+ <result name="success" type="velocity">/content.vm</result>
<param name="page">/dhis-web-maintenance-patient/underAgeForm.vm</param>
- <param name="javascripts">javascript/commons.js, javascript/underage.js</param>
+ <param name="javascripts">javascript/underage.js, ../dhis-web-commons/javascripts/date.js</param>
+ <param name="stylesheets">style/basic.css</param>
</action>
<action name="searchPerson"
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addPatientForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addPatientForm.vm 2011-07-19 03:48:05 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addPatientForm.vm 2011-07-29 08:58:35 +0000
@@ -1,7 +1,8 @@
<script>
jQuery(document).ready( function(){
- datePickerValid( 'birthDate' );
+ datePickerValid( 'addPatientForm [id=birthDate]' );
+ addEventForPatientForm( 'addPatientForm' );
jQuery("#addPatientForm").validate({
meta:"validate"
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addRelationshipPatientForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addRelationshipPatientForm.vm 2011-07-19 03:48:05 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addRelationshipPatientForm.vm 2011-07-29 08:58:35 +0000
@@ -1,7 +1,9 @@
<script>
jQuery('#addRelationshipPatientForm').ready( function(){
- datePickerValid( 'birthDate' );
+ datePickerValid( 'addRelationshipPatientForm [id=birthDate]' );
+ hideById('addRelationshipPatientForm [id=underAgeDiv]');
+ addEventForPatientForm('addRelationshipPatientForm');
jQuery("#addRelationshipPatientForm").validate({
meta:"validate"
@@ -12,12 +14,12 @@
}
,beforeValidateHandler: function(form)
{
- var birthDate = $('#birthDate').val();
- var age = $('#age').val();
+ var birthDate = $('#addRelationshipPatientForm [id=birthDate]').val();
+ var age = $('#addRelationshipPatientForm [id=age]').val();
if(age !=''){
- $( "#memberValidator").val(age);
+ $( "#addRelationshipPatientForm [id=memberValidator]").val(age);
}else{
- $( "#memberValidator").val(birthDate);
+ $( "#addRelationshipPatientForm [id=memberValidator]").val(birthDate);
}
}
});
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/commons.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/commons.js 2011-05-19 08:14:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/commons.js 2011-07-29 08:58:35 +0000
@@ -1,16 +1,16 @@
-function dobTypeOnChange(){
+function dobTypeOnChange( container ){
- var type = byId('dobType').value;
+ var type = jQuery('#' + container + ' [id=dobType]').val();
if(type == 'V' || type == 'D'){
- showById('birthdaySpan');
- hideById('ageSpan');
+ showById(container + ' [id=birthdaySpan]');
+ hideById(container + ' [id=ageSpan]');
}else if(type == 'A'){
- hideById('birthdaySpan');
- showById('ageSpan');
+ hideById(container + ' [id=birthdaySpan]');
+ showById(container + ' [id=ageSpan]');
}else {
- hideById('birthdaySpan');
- hideById('ageSpan');
+ hideById(container + ' [id=birthdaySpan]');
+ hideById(container + ' [id=ageSpan]');
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patient.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patient.js 2011-07-20 08:27:12 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patient.js 2011-07-29 08:58:35 +0000
@@ -52,20 +52,9 @@
selection.setListenerFunction( organisationUnitSelected );
//------------------------------------------------------------------------------
-// Check for Integer
+// Search patients by selected attribute
//------------------------------------------------------------------------------
-function isInt( value )
-{
- var number = new Number( value );
-
- if ( isNaN( number ))
- {
- return false;
- }
-
- return true;
-}
function searchingAttributeOnChange()
{
@@ -84,69 +73,19 @@
}
}
-//-----------------------------------------------------------------------------
-//Saver objects
-//-----------------------------------------------------------------------------
-
-function DateSaver( programStageInstanceId_, dueDate_, resultColor_ )
-{
- var SUCCESS = '#ccffcc';
- var ERROR = '#ccccff';
-
- var programStageInstanceId = programStageInstanceId_;
- var dueDate = dueDate_;
- var resultColor = resultColor_;
-
- this.save = function()
- {
- var request = new Request();
- request.setCallbackSuccess( handleResponse );
- request.setCallbackError( handleHttpError );
- request.setResponseTypeXML( 'status' );
- request.send( 'saveDueDate.action?programStageInstanceId=' + programStageInstanceId + '&dueDate=' + dueDate );
- };
-
- function handleResponse( rootElement )
- {
- var codeElement = rootElement.getElementsByTagName( 'code' )[0];
- var code = parseInt( codeElement.firstChild.nodeValue );
-
- if ( code == 0 )
- {
- markValue( resultColor );
- }
- else
- {
- markValue( ERROR );
- window.alert( i18n_saving_value_failed_status_code + '\n\n' + code );
- }
- }
-
- function handleHttpError( errorCode )
- {
- markValue( ERROR );
- window.alert( i18n_saving_value_failed_error_code + '\n\n' + errorCode );
- }
-
- function markValue( color )
- {
-
- var element = document.getElementById( 'value_' + programStageInstanceId + '_date' );
-
- element.style.backgroundColor = color;
- }
-}
-
// -----------------------------------------------------------------------------
// View details
// -----------------------------------------------------------------------------
function showPatientDetails( patientId )
{
- var request = new Request();
- request.setResponseTypeXML( 'patient' );
- request.setCallbackSuccess( patientReceived );
- request.send( 'getPatient.action?id=' + patientId );
+ //$.post( 'getPatient.action', { id:patientId }, patientReceived );
+ $.ajax({
+ url: 'getPatient.action?id=' + patientId,
+ cache: false,
+ dataType: "xml",
+ success: patientReceived
+ });
}
function patientReceived( patientElement )
@@ -287,79 +226,52 @@
$( "#loaderDiv" ).hide();
});
}
-// -----------------------------------------------------------------------------
-// Disable form
-// -----------------------------------------------------------------------------
-function disableForm()
-{
- $('#fullName').attr("disabled", true);
-}
// -----------------------------------------------------------------------------
// Add Patient
// -----------------------------------------------------------------------------
function validateAddPatient()
{
- var age = document.getElementById( 'age' );
- var orgunitcode = document.getElementById('orgunitcode');
- if( age.value != '' )
- {
- if( !isInt( age.value ) )
- {
- window.alert( i18n_age_must_integer );
- age.select();
- age.focus();
-
- return false;
- }
- }
+ $.post( 'validatePatient.action?' + getIdParams( ),
+ {
+ checkedDuplicate: checkedDuplicate,
+ fullName: jQuery( '#addPatientForm [id=fullName]' ).val(),
+ gender: jQuery( '#addPatientForm [id=gender]' ).val(),
+ dobType: jQuery( '#addPatientForm [id=dobType]' ).val(),
+ birthDate: jQuery( '#addPatientForm [id=birthDate]' ).val(),
+ ageType: jQuery( '#addPatientForm [id=ageType]' ).val(),
+ age: jQuery( '#addPatientForm [id=age]' ).val(),
+ gender: jQuery( '#addPatientForm [id=gender]' ).val(),
+ underAge: jQuery( '#addPatientForm [id=underAge]' ).is(":checked"),
+ representativeId: jQuery( '#addPatientForm [id=representativeId]' ).val(),
+ relationshipTypeId: jQuery( '#addPatientForm [id=relationshipTypeId]' ).val()
+ }, addValidationCompleted );
+}
- var params = '&checkedDuplicate='+checkedDuplicate
- +'&fullName=' + getFieldValue( 'fullName' )
- +'&gender=' + getFieldValue( 'gender' )
- +'&dobType=' + getFieldValue( 'dobType' )
- +'&birthDate=' + getFieldValue( 'birthDate' )
- +'&ageType=' + getFieldValue( 'ageType' )
- +'&age=' + getFieldValue( 'age' )
- +'&genre=' + getFieldValue('gender')
- +'&underAge=' + jQuery("#underAge").is(":checked")
- +'&representativeId=' + getFieldValue('representativeId')
- +'&relationshipTypeId=' + getFieldValue('relationshipTypeId')
- + getIdParams();
+function addValidationCompleted( data )
+{
+ var type = $(data).find('message').attr('type');
+ var message = $(data).find('message').text();
- var request = new Request();
- request.setResponseTypeXML( 'message' );
- request.setCallbackSuccess( addValidationCompleted );
- request.sendAsPost( params );
- request.send( "validatePatient.action" );
-
- return false;
-}
-
-function addValidationCompleted( messageElement )
-{
- var type = messageElement.getAttribute( 'type' );
- var message = messageElement.firstChild.nodeValue;
-
- if ( type == 'success' )
- {
- removeDisabledIdentifier();
- addPatient();
- }
- else if ( type == 'error' )
- {
- window.alert( i18n_adding_patient_failed + ':' + '\n' + message );
- }
- else if ( type == 'input' )
- {
- showErrorMessage( message );
- }
- else if( type == 'duplicate' )
- {
- if( !checkedDuplicate )
- showListPatientDuplicate(messageElement, true);
- }
+ if ( type == 'success' )
+ {
+ removeDisabledIdentifier( );
+ addPatient( );
+ }
+ else if ( type == 'error' )
+ {
+ showErrorMessage( i18n_adding_patient_failed + ':' + '\n' + message );
+ }
+ else if ( type == 'input' )
+ {
+ showWarningMessage( message );
+ }
+ else if( type == 'duplicate' )
+ {
+ if( !checkedDuplicate )
+ showListPatientDuplicate(data, true);
+ }
}
@@ -369,25 +281,19 @@
function validateUpdatePatient()
{
- var params = 'id=' + getFieldValue( 'id' )
- +'&fullName=' + getFieldValue( 'fullName' )
- +'&gender=' + getFieldValue( 'gender' )
- +'&birthDate=' + getFieldValue( 'birthDate' )
- + getIdParams();
-
- var request = new Request();
- request.setResponseTypeXML( 'message' );
- request.setCallbackSuccess( updateValidationCompleted );
- request.sendAsPost( params );
- request.send( "validatePatient.action" );
-
- return false;
+ $.post( 'validatePatient.action?' + getIdParams( ),
+ {
+ id: jQuery( '#updatePatientForm [id=id]' ).val(),
+ fullName: jQuery( '#updatePatientForm [id=fullName]' ).val(),
+ gender: jQuery( '#updatePatientForm [id=gender]' ).val(),
+ birthDate: jQuery( '#updatePatientForm [id=birthDate]' ).val()
+ }, updateValidationCompleted );
}
function updateValidationCompleted( messageElement )
{
- var type = messageElement.getAttribute( 'type' );
- var message = messageElement.firstChild.nodeValue;
+ var type = $(messageElement).find('message').attr('type');
+ var message = $(messageElement).find('message').text();
if ( type == 'success' )
{
@@ -396,11 +302,11 @@
}
else if ( type == 'error' )
{
- window.alert( i18n_saving_patient_failed + ':' + '\n' + message );
+ showErrorMessage( i18n_saving_patient_failed + ':' + '\n' + message );
}
else if ( type == 'input' )
{
- showErrorMessage( message );
+ showWarningMessage( message );
}
else if( type == 'duplicate' )
{
@@ -420,114 +326,29 @@
return params;
}
-// remove value of all the disabled identifier fields
-// an identifier field is disabled when its value is inherited from another person ( underAge is true )
-// we don't save inherited identifiers. Only save the representative id.
-function removeDisabledIdentifier()
-{
- jQuery("input.idfield").each(function(){
- if( jQuery(this).is(":disabled"))
- jQuery(this).val("");
- });
-}
-
-//-----------------------------------------------------------------------------
-//Move members
-//-----------------------------------------------------------------------------
-var selectedList;
-var availableList;
-
-function move( listId ) {
-
- var fromList = document.getElementById(listId);
-
- if ( fromList.selectedIndex == -1 ) {return;}
-
- if ( ! availableList )
- {
- availableList = document.getElementById( 'availableList' );
- }
-
- if ( ! selectedList )
- {
- selectedList = document.getElementById( 'selectedList' );
- }
-
- var toList = ( fromList == availableList ? selectedList : availableList );
-
- while ( fromList.selectedIndex > -1 ) {
-
- option = fromList.options.item(fromList.selectedIndex);
- fromList.remove(fromList.selectedIndex);
- toList.add(option, null);
- }
-}
-
-function submitForm() {
-
- if ( ! availableList )
- {
- availableList = document.getElementById('availableList');
- }
-
- if ( ! selectedList )
- {
- selectedList = document.getElementById('selectedList');
- }
-
- selectAll( selectedList );
-
- return false;
-}
-
-function selectAll( list )
-{
- for ( var i = 0, option; option = list.options.item(i); i++ )
- {
- option.selected = true;
- }
-}
-
-function ageOnchange()
-{
- //jQuery("#birthDate").val("").removeClass("error").rules("remove","required");
- //jQuery("#age").rules("add",{required:true});
- jQuery("#birthDate").val("");
-
-}
-
-function bdOnchange()
-{
- //jQuery("#age").rules("remove","required");
- //jQuery("#age").val("");
- //jQuery("#birthDate").rules("add",{required:true});
- jQuery("#age").val("");
-}
-
-
+// -----------------------------------------------------------------------------
// check duplicate patient
-function checkDuplicate()
+// -----------------------------------------------------------------------------
+
+function checkDuplicate( divname )
{
- var params =
- '&fullName=' + getFieldValue( 'fullName' ) +
- '&dobType=' + getFieldValue( 'dobType' ) +
- '&gender=' + getFieldValue( 'gender' ) +
- '&birthDate=' + getFieldValue( 'birthDate' ) +
- '&age=' + getFieldValue( 'age' ) ;
-
- var request = new Request();
- request.setResponseTypeXML( 'message' );
- request.setCallbackSuccess( checkDuplicateCompleted );
- request.sendAsPost( params );
- request.send( "validatePatient.action" );
-
- return false;
+ $.post( 'validatePatient.action',
+ {
+ fullName: jQuery( '#' + divname + ' [id=fullName]' ).val(),
+ dobType: jQuery( '#' + divname + ' [id=dobType]' ).val(),
+ gender: jQuery( '#' + divname + ' [id=gender]' ).val(),
+ birthDate: jQuery( '#' + divname + ' [id=birthDate]' ).val(),
+ age: jQuery( '#' + divname + ' [id=age]' ).val()
+ }, function( xmlObject )
+ {
+ checkDuplicateCompleted( xmlObject );
+ });
}
function checkDuplicateCompleted( messageElement )
{
checkedDuplicate = true;
- var type = messageElement.getAttribute( 'type' );
- var message = messageElement.firstChild.nodeValue;
+ var type = $(messageElement).find('message').attr('type');
+ var message = $(messageElement).find('message').text();
if( type == 'success')
{
@@ -539,7 +360,7 @@
}
else if( type == 'duplicate' )
{
- showListPatientDuplicate(messageElement, false);
+ showListPatientDuplicate( messageElement, false );
}
}
@@ -550,75 +371,76 @@
*/
function showListPatientDuplicate(rootElement, validate)
{
- var message = rootElement.firstChild.nodeValue;
- var patients = rootElement.getElementsByTagName('patient');
+ var message = $(rootElement).find('message').text();
+ var patients = $(rootElement).find('patient');
+
var sPatient = "";
- if( patients && patients.length > 0 )
- {
- for( var i = 0; i < patients.length ; i++ )
- {
+ $( patients ).each( function( i, patient )
+ {
sPatient += "<hr style='margin:5px 0px;'><table>";
- sPatient += "<tr><td><strong>"+i18n_patient_system_id+"</strong></td><td>"+ getElementValue( patients[i], 'systemIdentifier' )+"</td></tr>" ;
- sPatient += "<tr><td><strong>"+i18n_patient_fullName+"</strong></td><td>"+ getElementValue( patients[i], 'fullName' )+"</td></tr>" ;
- sPatient += "<tr><td><strong>"+i18n_patient_gender+"</strong></td><td>"+ getElementValue( patients[i], 'gender' )+"</td></tr>" ;
- sPatient += "<tr><td><strong>"+i18n_patient_date_of_birth+"</strong></td><td>"+getElementValue( patients[i], 'dateOfBirth' ) +"</td></tr>" ;
- sPatient += "<tr><td><strong>"+i18n_patient_age+"</strong></td><td>"+ getElementValue( patients[i], 'age' ) +"</td></tr>" ;
- sPatient += "<tr><td><strong>"+i18n_patient_blood_group+"</strong></td><td>"+ getElementValue( patients[i], 'bloodGroup' ) +"</td></tr>";
- var identifiers = patients[i].getElementsByTagName('identifier');
- if( identifiers && identifiers.length > 0 )
+ sPatient += "<tr><td><strong>" + i18n_patient_system_id + "</strong></td><td>" + $(patient).find('systemIdentifier').text() + "</td></tr>" ;
+ sPatient += "<tr><td><strong>" + i18n_patient_fullName + "</strong></td><td>" + $(patient).find('fullName').text() + "</td></tr>" ;
+ sPatient += "<tr><td><strong>" + i18n_patient_gender + "</strong></td><td>" + $(patient).find('gender').text() + "</td></tr>" ;
+ sPatient += "<tr><td><strong>" + i18n_patient_date_of_birth + "</strong></td><td>" + $(patient).find('dateOfBirth').text() + "</td></tr>" ;
+ sPatient += "<tr><td><strong>" + i18n_patient_age + "</strong></td><td>" + $(patient).find('age').text() + "</td></tr>" ;
+ sPatient += "<tr><td><strong>" + i18n_patient_blood_group + "</strong></td><td>" + $(patient).find('bloodGroup').text() + "</td></tr>";
+
+ var identifiers = $(patient).find('identifier');
+ if( identifiers.length > 0 )
{
- sPatient += "<tr><td colspan='2'><strong>"+i18n_patient_identifiers+"</strong></td></tr>"
- for( var j = 0; j < identifiers.length ; j++ )
- {
+ sPatient += "<tr><td colspan='2'><strong>" + i18n_patient_identifiers + "</strong></td></tr>"
+ $( identifiers ).each( function( i, identifier )
+ {
sPatient +="<tr class='identifierRow'>"
- +"<td><strong>"+getElementValue( identifiers[j], 'name' )+"</strong></td>"
- +"<td>"+getElementValue( identifiers[j], 'value' )+"</td> "
+ +"<td><strong>" + $(identifier).find('name').text() + "</strong></td>"
+ +"<td>" + $(identifier).find('value').text() + "</td> "
+"</tr>";
- }
+ });
}
- var attributes = patients[i].getElementsByTagName('attribute');
- if( attributes && attributes.length > 0 )
+
+ var attributes = $(patient).find('attribute');
+ if( attributes.length > 0 )
{
sPatient += "<tr><td colspan='2'><strong>"+i18n_patient_attributes+"</strong></td></tr>"
- for( var k = 0; k < attributes.length ; k++ )
- {
+ $( attributes ).each( function( i, attribute )
+ {
sPatient +="<tr class='attributeRow'>"
- +"<td><strong>"+getElementValue( attributes[k], 'name' )+"</strong></td>"
- +"<td>"+getElementValue( attributes[k], 'value' )+"</td> "
+ +"<td><strong>" + $(attribute).find('name').text() + "</strong></td>"
+ +"<td>" + $(attribute).find('value').text() + "</td> "
+"</tr>";
- }
+ });
}
- sPatient += "<tr><td colspan='2'><input type='button' id='"+getElementValue( patients[i], 'id' )+"' value='"+i18n_edit_this_patient+"' onclick='showUpdatePatientForm(this.id)'/></td></tr>";
+ sPatient += "<tr><td colspan='2'><input type='button' id='"+ $(patient).find('id').first().text() + "' value='" + i18n_edit_this_patient + "' onclick='showUpdatePatientForm(this.id)'/></td></tr>";
sPatient += "</table>";
- }
+ });
+
jQuery("#thickboxContainer","#hiddenModalContent").html("").append(sPatient);
if( !validate ) jQuery("#btnCreateNew","#hiddenModalContent").click(function(){window.parent.tb_remove();});
else jQuery("#btnCreateNew","#hiddenModalContent").click(function(){window.parent.tb_remove();window.parent.checkedDuplicate = true;window.parent.validatePatient();});
tb_show( message, "#TB_inline?height=500&width=500&inlineId=hiddenModalContent", null);
- }
-}
-
-function validatePatient()
-{
- if( jQuery("#id").val() )
- validateUpdatePatient();
- else validateAddPatient();
-}
-
-// ------------------------------
-// checked = TRUE : show pop up
-// ------------------------------
-// checked = FALSE : find all identifier which is disabled, remove its value and enable it
-// This happen when user chose a representative, but now they dont want this patient to be under age anymore
-// TODO : if user created a new person, should we delete that person in this case ?
+}
+
+// -----------------------------------------------------------------------------
+// Show representative form
+// -----------------------------------------------------------------------------
+
function toggleUnderAge(this_)
{
if( jQuery(this_).is(":checked"))
{
- tb_show(i18n_child_representative,"showAddRepresentative.action?TB_iframe=true&height=400&width=500",null);
+ $('#representativeDiv').dialog('destroy').remove();
+ $('<div id="representativeDiv">' ).load( 'showAddRepresentative.action' ).dialog({
+ title: i18n_child_representative,
+ maximize: true,
+ closable: true,
+ modal:true,
+ overlay:{background:'#000000', opacity:0.1},
+ width: 800,
+ height: 400
+ });
}else
{
- jQuery("input.idfield").each(function(){
+ jQuery("#representativeDiv :input.idfield").each(function(){
if( jQuery(this).is(":disabled"))
{
jQuery(this).removeAttr("disabled").val("");
@@ -629,96 +451,6 @@
}
}
-function changePageSize( baseLink )
-{
- var pageSize = jQuery("#sizeOfPage").val();
- window.location.href = baseLink +"pageSize=" + pageSize ;
-}
-function jumpToPage( baseLink )
-{
- var pageSize = jQuery("#sizeOfPage").val();
- var currentPage = jQuery("#jumpToPage").val();
- window.location.href = baseLink +"pageSize=" + pageSize +"¤tPage=" +currentPage;
-}
-
-/**
- * Overwrite showDetails() of common.js
- * This method will show details div on a pop up instead of show the div in the main table's column.
- * So we will have more place for the main column of the table.
- * @return
- */
-
-function showDetails()
-{
- var detailArea = $("#detailsArea");
- var top = (f_clientHeight() / 2) - 200;
- if ( top < 0 ) top = 0;
- var left = screen.width - detailArea.width() - 100;
- detailArea.css({"left":left+"px","top":top+"px"});
- detailArea.show('fast');
-
-}
-
-/**
- * Get document width, hieght, scroll positions
- * Work with all browsers
- * @return
- */
-
-function f_clientWidth() {
- return f_filterResults (
- window.innerWidth ? window.innerWidth : 0,
- document.documentElement ? document.documentElement.clientWidth : 0,
- document.body ? document.body.clientWidth : 0
- );
-}
-function f_clientHeight() {
- return f_filterResults (
- window.innerHeight ? window.innerHeight : 0,
- document.documentElement ? document.documentElement.clientHeight : 0,
- document.body ? document.body.clientHeight : 0
- );
-}
-function f_scrollLeft() {
- return f_filterResults (
- window.pageXOffset ? window.pageXOffset : 0,
- document.documentElement ? document.documentElement.scrollLeft : 0,
- document.body ? document.body.scrollLeft : 0
- );
-}
-function f_scrollTop() {
- return f_filterResults (
- window.pageYOffset ? window.pageYOffset : 0,
- document.documentElement ? document.documentElement.scrollTop : 0,
- document.body ? document.body.scrollTop : 0
- );
-}
-function f_filterResults(n_win, n_docel, n_body) {
- var n_result = n_win ? n_win : 0;
- if (n_docel && (!n_result || (n_result > n_docel)))
- n_result = n_docel;
- return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
-}
-
-function loadAllPatients()
-{
- hideById('listPatientDiv');
- hideById('addPatientDiv');
- hideById('updatePatientDiv');
-
- jQuery('#loaderDiv').show();
- contentDiv = 'listPatientDiv';
- jQuery('#listPatientDiv').load('searchPatient.action',{
- listAll:true,
- sortPatientAttributeId: getFieldValue('sortPatientAttributeId')
- },
- function(){
- showById('listPatientDiv');
- jQuery('#loaderDiv').hide();
- });
- hideLoader();
-}
-
// ----------------------------------------------------------------
// Add Patient
// ----------------------------------------------------------------
@@ -786,11 +518,10 @@
type: "POST",
url: 'updatePatient.action',
data: getParamsForDiv('updatePatientDiv'),
- success: function() {
+ success: function( json ) {
showProgramEnrollmentSelectForm( getFieldValue('id') );
}
});
- return false;
}
// ----------------------------------------------------------------
@@ -961,10 +692,10 @@
{
var field = document.getElementById( 'value_' + programStageInstanceId + '_date' );
- var dateOfIncident = new Date(byId('dateOfIncident').value);
+ var dateOfIncident = new Date( byId('dateOfIncident').value );
var dueDate = new Date(field.value);
- if(dueDate < dateOfIncident)
+ if( dueDate < dateOfIncident )
{
field.style.backgroundColor = '#FFCC00';
alert( i18n_date_less_incident );
@@ -974,8 +705,7 @@
field.style.backgroundColor = '#ffffcc';
var dateSaver = new DateSaver( programStageInstanceId, field.value, '#ccffcc' );
- dateSaver.save();
-
+ dateSaver.save();s
}
//----------------------------------------------------
@@ -1044,3 +774,169 @@
$( "#loaderDiv" ).hide();
});
}
+
+// -----------------------------------------------------------------------------
+// Load all patients
+// -----------------------------------------------------------------------------
+
+function loadAllPatients()
+{
+ hideById('listPatientDiv');
+ hideById('addPatientDiv');
+ hideById('updatePatientDiv');
+
+ jQuery('#loaderDiv').show();
+ contentDiv = 'listPatientDiv';
+ jQuery('#listPatientDiv').load('searchPatient.action',{
+ listAll:true,
+ sortPatientAttributeId: getFieldValue('sortPatientAttributeId')
+ },
+ function(){
+ showById('listPatientDiv');
+ jQuery('#loaderDiv').hide();
+ });
+ hideLoader();
+}
+
+//-----------------------------------------------------------------------------
+// Saver objects
+//-----------------------------------------------------------------------------
+
+function DateSaver( programStageInstanceId_, dueDate_, resultColor_ )
+{
+ var SUCCESS = '#ccffcc';
+ var ERROR = '#ccccff';
+
+ var programStageInstanceId = programStageInstanceId_;
+ var dueDate = dueDate_;
+ var resultColor = resultColor_;
+
+ this.save = function()
+ {
+ var request = new Request();
+ request.setCallbackSuccess( handleResponse );
+ request.setCallbackError( handleHttpError );
+ request.setResponseTypeXML( 'status' );
+ request.send( 'saveDueDate.action?programStageInstanceId=' + programStageInstanceId + '&dueDate=' + dueDate );
+ };
+
+ function handleResponse( rootElement )
+ {
+ var codeElement = rootElement.getElementsByTagName( 'code' )[0];
+ var code = parseInt( codeElement.firstChild.nodeValue );
+
+ if ( code == 0 )
+ {
+ markValue( resultColor );
+ }
+ else
+ {
+ markValue( ERROR );
+ window.alert( i18n_saving_value_failed_status_code + '\n\n' + code );
+ }
+ }
+
+ function handleHttpError( errorCode )
+ {
+ markValue( ERROR );
+ window.alert( i18n_saving_value_failed_error_code + '\n\n' + errorCode );
+ }
+
+ function markValue( color )
+ {
+
+ var element = document.getElementById( 'value_' + programStageInstanceId + '_date' );
+
+ element.style.backgroundColor = color;
+ }
+}
+
+
+// -----------------------------------------------------------------------------
+// remove value of all the disabled identifier fields
+// an identifier field is disabled when its value is inherited from another person ( underAge is true )
+// we don't save inherited identifiers. Only save the representative id.
+// -----------------------------------------------------------------------------
+
+function removeDisabledIdentifier()
+{
+ jQuery("input.idfield").each(function(){
+ if( jQuery(this).is(":disabled"))
+ jQuery(this).val("");
+ });
+}
+
+function addEventForPatientForm( divname )
+{
+ jQuery("#" + divname + " [id=age]").change(function() {
+ jQuery("#" + divname + " [id=birthDate]").val("");
+ });
+
+ jQuery("#" + divname + " [id=birthDate]").change(function() {
+ jQuery("#" + divname + " [id=age]").val("");
+ });
+
+ jQuery("#" + divname + " [id=checkDuplicateBtn]").click(function() {
+ checkDuplicate( divname );
+ });
+
+ jQuery("#" + divname + " [id=dobType]").click(function() {
+ dobTypeOnChange( divname );
+ });
+}
+
+// -----------------------------------------------------------------------------
+// Show Details
+// -----------------------------------------------------------------------------
+
+function showDetails()
+{
+ var detailArea = $("#detailsArea");
+ var top = (f_clientHeight() / 2) - 200;
+ if ( top < 0 ) top = 0;
+ var left = screen.width - detailArea.width() - 100;
+ detailArea.css({"left":left+"px","top":top+"px"});
+ detailArea.show('fast');
+
+}
+
+/**
+ * Get document width, hieght, scroll positions
+ * Work with all browsers
+ * @return
+ */
+
+function f_clientWidth() {
+ return f_filterResults (
+ window.innerWidth ? window.innerWidth : 0,
+ document.documentElement ? document.documentElement.clientWidth : 0,
+ document.body ? document.body.clientWidth : 0
+ );
+}
+function f_clientHeight() {
+ return f_filterResults (
+ window.innerHeight ? window.innerHeight : 0,
+ document.documentElement ? document.documentElement.clientHeight : 0,
+ document.body ? document.body.clientHeight : 0
+ );
+}
+function f_scrollLeft() {
+ return f_filterResults (
+ window.pageXOffset ? window.pageXOffset : 0,
+ document.documentElement ? document.documentElement.scrollLeft : 0,
+ document.body ? document.body.scrollLeft : 0
+ );
+}
+function f_scrollTop() {
+ return f_filterResults (
+ window.pageYOffset ? window.pageYOffset : 0,
+ document.documentElement ? document.documentElement.scrollTop : 0,
+ document.body ? document.body.scrollTop : 0
+ );
+}
+function f_filterResults(n_win, n_docel, n_body) {
+ var n_result = n_win ? n_win : 0;
+ if (n_docel && (!n_result || (n_result > n_docel)))
+ n_result = n_docel;
+ return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
+}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/relationshipPatient.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/relationshipPatient.js 2011-07-20 08:27:12 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/relationshipPatient.js 2011-07-29 08:58:35 +0000
@@ -9,6 +9,8 @@
hideById( 'searchPatientDiv' );
hideById( 'listPatientDiv' );
hideById( 'listRelationshipDiv' );
+ setInnerHTML('addPatientDiv', '');
+ setInnerHTML('updatePatientDiv', '');
jQuery('#loaderDiv').show();
jQuery('#addRelationshipDiv').load('showAddRelationshipPatient.action',
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/underage.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/underage.js 2011-01-20 15:25:13 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/underage.js 2011-07-29 08:58:35 +0000
@@ -4,57 +4,49 @@
function validateAddRepresentative()
{
- $.post("validatePatient.action?" + getIdParams(),
- {
- fullName: getFieldValue( 'fullName' ),
- gender: getFieldValue( 'gender' ) ,
- birthDate: getFieldValue( 'birthDate' ),
- age: getFieldValue( 'age' ) ,
- dobType: getFieldValue( 'dobType' ) ,
- ageType: getFieldValue( 'ageType' )
- },
- function (data)
- {
- addValidationRepresentativeCompleted(data);
- },'xml');
-
+ $.post("validatePatient.action?" + getIdentifierTypeIdParams(),
+ {
+ fullName: jQuery( '#addRepresentativeForm [id=fullName]' ).val(),
+ gender: jQuery( '#addRepresentativeForm [id=gender]' ).val(),
+ birthDate: jQuery( '#addRepresentativeForm [id=birthDate]' ).val(),
+ age: jQuery( '#addRepresentativeForm [id=age]' ).val(),
+ dobType: jQuery( '#addRepresentativeForm [id=dobType]' ).val(),
+ ageType: jQuery( '#addRepresentativeForm [id=ageType]' ).val()
+ }, addValidationRepresentativeCompleted, "xml" );
}
function addValidationRepresentativeCompleted( messageElement )
{
- messageElement = messageElement.getElementsByTagName( "message" )[0];
- var type = messageElement.getAttribute( "type" );
- var message = messageElement.firstChild.nodeValue;
-
+ var type = $(messageElement).find('message').attr('type');
+ var message = $(messageElement).find('message').text();
+
if ( type == 'success' )
{
- // Use jQuery Ajax submit
- jQuery.ajax({
- type: "POST"
- ,url: "addRepresentative.action"
- ,data: jQuery("#addRepresentativeForm").serialize()
- ,dataType : "xml"
- ,success: function(xml){
- autoChoosePerson( xml );
- }
- ,error: function()
- {
- alert(i18n_error_connect_to_server);
- }
- });
-
+ jQuery.ajax({
+ type: "POST"
+ ,url: "addRepresentative.action"
+ ,data: jQuery("#addRepresentativeForm").serialize()
+ ,dataType : "xml"
+ ,success: function(xml){
+ autoChoosePerson( xml );
+ }
+ ,error: function()
+ {
+ alert(i18n_error_connect_to_server);
+ }
+ });
+
}
else if ( type == 'error' )
{
- window.alert( i18n_adding_patient_failed + ':' + '\n' + message );
+ showErrorMessage( i18n_adding_patient_failed + ':' + '\n' + message );
}
else if ( type == 'input' )
{
- setHeaderMessage( message );
+ showWarningMessage( message );
}
else if( type == 'duplicate' )
{
- jQuery( '#message' ).css({"display":"block"}).html(message);
jQuery("#formContainer").hide();
showPersons("listPersonsDuplicate", messageElement);
}
@@ -62,10 +54,10 @@
//get and build a param String of all the identifierType id and its value
//excluding identifiers which related is False
-function getIdParams()
+function getIdentifierTypeIdParams()
{
var params = "";
- jQuery("input.idfield").each(
+ jQuery("#addRepresentativeForm :input.idfield").each(
function()
{
if( jQuery(this).val() && !jQuery(this).is(":disabled") )
@@ -96,83 +88,82 @@
{
var container = jQuery("#"+divContainer);
container.html("");
- var patients = xmlElement.getElementsByTagName('patient');
+ var patients = $(xmlElement).find('patient');
var sPatient = "";
- if( patients && patients.length > 0 )
- {
- for( var i = 0; i < patients.length ; i++ )
- {
- sPatient += "<hr style='margin:5px 0px;'><table>";
- sPatient += "<tr><td><strong>"+i18n_patient_system_id+"</strong></td><td>"+ getElementValue( patients[i], 'systemIdentifier' )+"</td></tr>" ;
- sPatient += "<tr><td><strong>"+i18n_patient_fullName+"</strong></td><td>"+ getElementValue( patients[i], 'fullName' )+"</td></tr>" ;
- sPatient += "<tr><td><strong>"+i18n_patient_gender+"</strong></td><td>"+ getElementValue( patients[i], 'gender' )+"</td></tr>" ;
- sPatient += "<tr><td><strong>"+i18n_patient_date_of_birth+"</strong></td><td>"+getElementValue( patients[i], 'dateOfBirth' ) +"</td></tr>" ;
- sPatient += "<tr><td><strong>"+i18n_patient_age+"</strong></td><td>"+ getElementValue( patients[i], 'age' ) +"</td></tr>" ;
- sPatient += "<tr><td><strong>"+i18n_patient_blood_group+"</strong></td><td>"+ getElementValue( patients[i], 'bloodGroup' ) +"</td></tr>";
- var identifiers = patients[i].getElementsByTagName('identifier');
- if( identifiers && identifiers.length > 0 )
- {
- for( var j = 0; j < identifiers.length ; j++ )
- {
- sPatient +="<tr class='identifierRow"+getElementValue( patients[i], 'id' )+"' id='iden"+getElementValue( identifiers[j], 'id' )+"'>"
- +"<td><strong>"+getElementValue( identifiers[j], 'name' )+"</strong></td>"
- +"<td class='value'>"+getElementValue( identifiers[j], 'value' )+"</td> "
- +"</tr>";
- }
- }
- var attributes = patients[i].getElementsByTagName('attribute');
- if( attributes && attributes.length > 0 )
- {
- for( var k = 0; k < attributes.length ; k++ )
- {
- sPatient +="<tr class='attributeRow'>"
- +"<td><strong>"+getElementValue( attributes[k], 'name' )+"</strong></td>"
- +"<td>"+getElementValue( attributes[k], 'value' )+"</td> "
- +"</tr>";
- }
- }
- sPatient += "<tr><td colspan='2'><input type='button' id='"+getElementValue( patients[i], 'id' )+"' value='"+i18n_choose_this_person+"' onclick='choosePerson(this)'/></td></tr>";
- sPatient += "</table>";
- }
- container.append(sPatient);
- }else
+
+ if ( patients.length == 0 )
{
var message = "<p>"+i18n_no_result+"</p>";
container.html(message);
}
+
+ $( patients ).each( function( i, patient )
+ {
+ sPatient += "<hr style='margin:5px 0px;'><table>";
+ sPatient += "<tr><td><strong>"+i18n_patient_system_id+"</strong></td><td>"+ $( patient ).find('systemIdentifier').text() +"</td></tr>" ;
+ sPatient += "<tr><td><strong>"+i18n_patient_fullName+"</strong></td><td>"+ $( patient ).find('fullName').text() +"</td></tr>" ;
+ sPatient += "<tr><td><strong>"+i18n_patient_gender+"</strong></td><td>"+ $( patient ).find('gender').text() +"</td></tr>" ;
+ sPatient += "<tr><td><strong>"+i18n_patient_date_of_birth+"</strong></td><td>"+ $( patient ).find('dateOfBirth').text() +"</td></tr>" ;
+ sPatient += "<tr><td><strong>"+i18n_patient_age+"</strong></td><td>"+ $( patient ).find('age').text() +"</td></tr>" ;
+ sPatient += "<tr><td><strong>"+i18n_patient_blood_group+"</strong></td><td>"+ $( patient ).find('bloodGroup').text() +"</td></tr>";
+
+ var identifiers = $( patient ).find('identifier');
+ $( identifiers ).each( function( i, identifier )
+ {
+ sPatient +="<tr class='identifierRow"+ $(identifier).find('id').text() + "' id='iden" + $(identifier).find('id' ).text() + "'>"
+ +"<td><strong>" + $(identifier).find('name').text() + "</strong></td>"
+ +"<td class='value'>" + $(identifier).find('value').text() + "</td> "
+ +"</tr>";
+ });
+
+ var attributes = $( patient ).find('attribute');
+ $( attributes ).each( function( i, attribute )
+ {
+ sPatient += "<tr class='attributeRow'>"
+ + "<td><strong>" + $(attribute).find('name').text() + "</strong></td>"
+ + "<td>" + $(attribute).find('value').text() + "</td> "
+ + "</tr>";
+ });
+
+ sPatient += "<tr><td colspan='2'><input type='button' id='" + $(patient).find('id' ).first().text() +"' value='" + i18n_choose_this_person + "' onclick='choosePerson(this)'/></td></tr>";
+ sPatient += "</table>";
+
+ container.append(sPatient);
+ } );
}
// Will be call after save new person successfully
-function autoChoosePerson(xmlElement)
+function autoChoosePerson( xmlElement )
{
- jQuery("#tab-2").html("<center><strong>"+i18n_add_person_successfully+"</strong></center>");
+ jQuery("#tab-2").html("<center><strong>" + i18n_add_person_successfully + "</strong></center>");
var root = jQuery(xmlElement);
- window.parent.jQuery("#representativeId").val( root.find("id").text() );
- window.parent.jQuery("#relationshipTypeId").val( root.find("relationshipTypeId").text() );
+ jQuery("#addPatientForm [id=representativeId]").val( root.find("id").text() );
+ jQuery("#addPatientForm [id=relationshipTypeId]").val( root.find("relationshipTypeId").text() );
root.find("identifier").each(
function(){
- var inputField = window.parent.jQuery("#iden" + jQuery(this).find("identifierTypeId").text());
+ var inputField = jQuery("#addPatientForm iden" + jQuery(this).find("identifierTypeId").text());
inputField.val( jQuery(this).find("identifierText").text() );
inputField.attr({"disabled":"disabled"});
}
);
- // close thickbox popup
- setTimeout(function(){window.parent.tb_remove();},3000);
-
}
+//------------------------------------------------------------------------------
// Set Representative information to parent page.
+//------------------------------------------------------------------------------
+
function choosePerson(this_)
{
- var relationshipTypeId = jQuery("#relationshipTypeId").val();
+ var relationshipTypeId = jQuery("#searchForm [id=relationshipTypeId]").val();
if( isBlank( relationshipTypeId ))
{
alert(i18n_please_select_relationshipType);
return;
}
+
var id = jQuery(this_).attr("id");
- window.parent.jQuery("#representativeId").val(id);
- window.parent.jQuery("#relationshipTypeId").val(relationshipTypeId);
+ jQuery("#addPatientForm [id=representativeId]").val(id);
+ jQuery("#addPatientForm [id=relationshipTypeId]").val(relationshipTypeId);
jQuery(".identifierRow"+id).each(function(){
var inputField = window.parent.jQuery("#"+jQuery(this).attr("id"));
if( inputField.metadata({type:"attr",name:"data"}).related )
@@ -183,8 +174,7 @@
}
});
- // close thickbox popup
- window.parent.tb_remove();
+ jQuery('#representativeDiv').dialog('close');
}
function toggleSearchType(this_)
@@ -192,36 +182,24 @@
var type = jQuery(this_).val();
if( "identifier" == type )
{
- jQuery("#rowIdentifier").show().find("#identifierTypeId").addClass('required:true');
- jQuery("#rowAttribute").hide().find("#attributeId").removeClass("required");
- jQuery("#searchValue").val("");
+ jQuery("#searchForm [id=rowIdentifier]").show().find("identifierTypeId").addClass('required:true');
+ jQuery("#searchForm [id=rowAttribute]").hide().find("id=attributeId").removeClass("required");
+ jQuery("#searchForm [id=searchValue]").val("");
}
else if( "attribute" == type )
{
- jQuery("#rowIdentifier").hide().find("#identifierTypeId").removeClass("required");
- jQuery("#rowAttribute").show().find("#attributeId").addClass("required:true");
- jQuery("#searchValue").val("");
+ jQuery("#searchForm [id=rowIdentifier]").hide().find("#identifierTypeId").removeClass("required");
+ jQuery("#searchForm [id=rowAttribute]").show().find("#attributeId").addClass("required:true");
+ jQuery("#searchForm [id=searchValue]").val("");
}
else if( "name" == type || "" == type )
{
- jQuery("#rowIdentifier").hide().find("#identifierTypeId").removeClass("required");
- jQuery("#rowAttribute").hide().find("#attributeId").removeClass("required");
- jQuery("#searchValue").val("");
+ jQuery("#searchForm [id=rowIdentifier]").hide().find("#identifierTypeId").removeClass("required");
+ jQuery("#searchForm [id=rowAttribute]").hide().find("#attributeId").removeClass("required");
+ jQuery("#searchForm [id=searchValue]").val("");
}
}
-function ageOnchange()
-{
- jQuery("#birthDate").val("").removeClass("required");
- jQuery("#age").addClass('required:true');
-
-}
-
-function bdOnchange()
-{
- jQuery("#age").val("").removeClass("required");
- jQuery("#birthDate").addClass('required:true');
-}
function isBlank(text)
{
return !text || /^\s*$/.test(text);
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientForm.vm 2011-07-11 03:52:31 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientForm.vm 2011-07-29 08:58:35 +0000
@@ -44,7 +44,7 @@
<tr>
<td><label for="dobType">$i18n.getString( "dob_type" )<em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
<td class="input-column">
- <select id='dobType' name="dobType" style="width:28.3em" onchange="dobTypeOnChange();" class="{validate:{required:false}}">
+ <select id='dobType' name="dobType" style="width:28.3em" class="{validate:{required:true}}">
<option value="" selected="selected">[$i18n.getString( "please_select" )]</option>
<option value="V" >$i18n.getString( "verified" )</option>
<option value="D" >$i18n.getString( "declared" )</option>
@@ -99,21 +99,19 @@
<tr><td colspan="2"> </td></tr>
<tr>
<td></td>
- <td><input type="button" value="$i18n.getString('check_duplicate')" onclick="checkDuplicate();"/></td>
+ <td><input type="button" id='checkDuplicateBtn' name='checkDuplicateBtn' value="$i18n.getString('check_duplicate')" /></td>
</tr>
<tr><td colspan="2"> </td></tr>
<!-- UNDERAGE -->
- <div id='underAgeDiv'>
- <tr>
+ <tr id='underAgeDiv'>
<td>$i18n.getString("is_underage")</td>
<td>
<input type="checkbox" name="underAge" id="underAge" onclick="toggleUnderAge(this);" value="true"/>
</td>
</tr>
- </div>
+
<!--IDENTIFIERS -->
-
<tr><td colspan="2"> </td></tr>
<tr><th colspan="2" class="heading-column">$i18n.getString( "patient_identifiers" )</th></tr>
#foreach ($identifierType in $identifierTypes)
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/underAgeForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/underAgeForm.vm 2011-07-11 03:52:31 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/underAgeForm.vm 2011-07-29 08:58:35 +0000
@@ -1,8 +1,10 @@
<script type="text/javascript">
- jQuery(document).ready(function() {
+ jQuery("#representativeDiv").ready(function() {
+
jQuery("#tabs").tabs();
- datePickerValid( 'birthDate' );
-
+ hideById('addRepresentativeForm [id=underAgeDiv]');
+ addEventForPatientForm('addRepresentativeForm');
+
jQuery("#searchForm").validate({
meta:"validate"
,errorElement:"span"
@@ -15,30 +17,27 @@
});
jQuery("#addRepresentativeForm").validate({
- meta:"validate"
- ,errorElement:"td"
- ,submitHandler: function(form) { validateAddRepresentative(); }
- ,rules : {
- relationshipTypeId : { required: true },
- fullName : {required:true,rangelength:[7,50], unicodechars:true},
- gender : { required: true },
- birthDate :{required:false,dateISO:true,datelessthanequaltoday:true}
- },beforeValidateHandler: function(form)
- {
- var dobType = jQuery('#dobType').val();
-
+ meta:"validate"
+ ,errorElement:"span"
+ ,submitHandler: function(form)
+ {
+ validateAddRepresentative('addRepresentativeForm');
+ }
+ ,beforeValidateHandler: function(form)
+ {
+ var dobType = $('#addRepresentativeForm [id=dobType]').val();
+
if( dobType=='V' || dobType=='D' )
{
- var birthDate = jQuery('#birthDate').val();
+ var birthDate = $('#addRepresentativeForm [id=birthDate]').val();
if( birthDate != '' ){
- jQuery("#memberValidator").val(birthDate);
+ $("#addRepresentativeForm [id=memberValidator]").val(birthDate);
}
}else{
- var age = jQuery('#age').val();
- jQuery("#memberValidator").val(age);
+ var age = $('#addRepresentativeForm [id=age]').val();
+ $("#addRepresentativeForm [id=memberValidator]").val(age);
}
}
-
});
// Esc key for jQuery thickbox
@@ -95,7 +94,7 @@
<tr>
<td >$i18n.getString("relationship_type")<em title="$i18n.getString( "required" )" class="required">*</em></td>
<td >
- <select name="relationshipTypeId" id="relationshipTypeId">
+ <select name="relationshipTypeId" id="relationshipTypeId" style='width:18em'>
<option value="">[$i18n.getString( "please_select" )]</option>
#foreach ($relationship in $relationshipTypes)
<option value="$relationship.id">$!relationship.aIsToB</option>
@@ -106,7 +105,7 @@
<tr>
<td>$i18n.getString("search_by")<em title="$i18n.getString( "required" )" class="required">*</em></td>
<td>
- <select id="searchType" name="searchType" onclick="toggleSearchType(this)">
+ <select id="searchType" name="searchType" onclick="toggleSearchType(this)" style='width:18em'>
<option value="">[$i18n.getString( "please_select" )]</option>
<option value="identifier">$i18n.getString("identifier")</option>
<option value="attribute">$i18n.getString("attribute")</option>
@@ -114,10 +113,10 @@
</select>
</td>
</tr>
- <tr id="rowIdentifier" style="display: none">
+ <tr id="rowIdentifier" style="display: none" >
<td>$i18n.getString("identifier_type")</td>
<td>
- <select name="identifierTypeId" id="identifierTypeId" >
+ <select name="identifierTypeId" id="identifierTypeId" style='width:18em' >
<option value="">[$i18n.getString( "please_select" )]</option>
#foreach($identifierType in $identifierTypes)
<option value="$identifierType.id">$identifierType.name</option>
@@ -129,7 +128,7 @@
<tr id="rowAttribute" style="display: none">
<td>$i18n.getString("attribute")</td>
<td>
- <select name="attributeId" id="attributeId" >
+ <select name="attributeId" id="attributeId" style='width:18em'>
<option value="">[$i18n.getString( "please_select" )]</option>
#foreach($attribute in $attributes)
<option value="$attribute.id">$attribute.name</option>
@@ -140,7 +139,7 @@
<tr><td colspan="2"></td></tr>
<tr>
<td>$i18n.getString("search_value")<em title="$i18n.getString( "required" )" class="required">*</em></td>
- <td><input type="text" name="searchValue" id="searchValue"/></td>
+ <td><input type="text" name="searchValue" id="searchValue" style='width:18em'/></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="$i18n.getString('search')"/></td>
@@ -158,9 +157,9 @@
<form id="addRepresentativeForm" name="addRepresentativeForm" action="addRepresentative.action" method="post">
<table id="formContainer">
<tr>
- <td style='width:8em'><label for="relationship_type">$i18n.getString("relationship_type")<em title="$i18n.getString( "required" )" class="required">*</em></label></td>
+ <td style='width:12.2em'><label for="relationship_type">$i18n.getString("relationship_type")<em title="$i18n.getString( "required" )" class="required">*</em></label></td>
<td >
- <select name="relationshipTypeId" id="relationshipTypeId" style="width:28.2em">
+ <select name="relationshipTypeId" id="relationshipTypeId" style="width:28.2em" class="{validate:{required:true}}">
<option value="">[$i18n.getString( "please_select" )]</option>
#foreach ($relationship in $relationshipTypes)
<option value="$relationship.id">$relationship.aIsToB</option>
@@ -183,7 +182,3 @@
</div>
</div>
-<script>
- hideById('underAgeDiv');
-</script>
-
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updatePatientForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updatePatientForm.vm 2011-07-19 09:32:47 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updatePatientForm.vm 2011-07-29 08:58:35 +0000
@@ -14,6 +14,7 @@
datePickerValid( 'birthDate' );
datePickerValid( 'deathDate' );
+ addEventForPatientForm('updatePatientForm');
jQuery("#btnRepresentativeInfo").cluetip(
{
@@ -84,7 +85,7 @@
<tr>
<td><label for="dobType">$i18n.getString( "dob_type" )<em title="$i18n.getString( "required" )" class="required">*</em></label></td>
<td class="input-column" >
- <select id='dobType' name="dobType" style="width:30.3em" onchange="dobTypeOnChange();" class="{validate:{required:true}}">
+ <select id='dobType' name="dobType" style="width:30.3em" class="{validate:{required:true}}">
<option value="" selected="selected">[$i18n.getString( "please_select" )]</option>
<option value="V" #if($patient.dobType=='V') selected #end>$i18n.getString( "verified" )</option>
<option value="D" #if($patient.dobType=='D') selected #end>$i18n.getString( "declared" )</option>
@@ -102,14 +103,14 @@
<option value="M" #if($patient.getAgeType()=='M') selected #end> $i18n.getString('month')</option>
<option value="Y" #if($patient.getAgeType()=='Y') selected #end> $i18n.getString('year')</option>
</select>
- <input type="text" id="age" name="age" value="$patient.getIntegerValueOfAge()" style="width:12em" onchange="ageOnchange()" class="{validate:{number:true, alphanumeric: true}}">
+ <input type="text" id="age" name="age" value="$patient.getIntegerValueOfAge()" style="width:12em" class="{validate:{number:true, alphanumeric: true}}">
</td>
</tr>
<tr id='birthdaySpan' style="display:none" >
<td><label for="birthDate">$i18n.getString( "date_of_birth" )<em title="$i18n.getString( "required" )" class="required">*</em> </label></td>
<td class="input-column" >
- <input type="text" id="birthDate" name="birthDate" style="width:28em" onchange="bdOnchange()" value="$format.formatDate( $patient.birthDate )" >
+ <input type="text" id="birthDate" name="birthDate" style="width:28em" value="$format.formatDate( $patient.birthDate )" >
</td>
</tr>