dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #23396
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11385: Allow to enter more than one Person Phone number in Add/Update patient form.
------------------------------------------------------------
revno: 11385
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-07-12 11:32:20 +0700
message:
Allow to enter more than one Person Phone number in Add/Update patient form.
modified:
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddPatientAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/UpdatePatientAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/defaultPatientForm.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/patientForm.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-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddPatientAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddPatientAction.java 2013-07-09 08:28:54 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddPatientAction.java 2013-07-12 04:32:20 +0000
@@ -107,7 +107,7 @@
private String gender;
- private String phoneNumber;
+ private String[] phoneNumber;
private String registrationDate;
@@ -178,12 +178,24 @@
// Set Other information for patient
// ---------------------------------------------------------------------
- phoneNumber = (phoneNumber!=null && phoneNumber.trim().equals( systemSettingManager
- .getSystemSetting( SystemSettingManager.KEY_PHONE_NUMBER_AREA_CODE ) )) ? null : phoneNumber;
-
+ String phone = "";
+
+ for ( String _phoneNumber : phoneNumber )
+ {
+ _phoneNumber = (_phoneNumber != null && _phoneNumber.isEmpty() && _phoneNumber.trim().equals(
+ systemSettingManager.getSystemSetting( SystemSettingManager.KEY_PHONE_NUMBER_AREA_CODE ) )) ? null
+ : _phoneNumber;
+ if ( _phoneNumber != null )
+ {
+ phone += _phoneNumber + ";";
+ }
+ }
+
+ phone = (phone.isEmpty()) ? null : phone.substring( 0, phone.length() - 1 );
+
+ patient.setPhoneNumber( phone );
patient.setGender( gender );
patient.setIsDead( false );
- patient.setPhoneNumber( phoneNumber );
patient.setUnderAge( underAge );
patient.setOrganisationUnit( organisationUnit );
patient.setIsDead( isDead );
@@ -276,7 +288,7 @@
{
gender = Patient.FEMALE;
}
-
+
String identifier = PatientIdentifierGenerator.getNewIdentifier( _birthDate, gender );
PatientIdentifier systemGenerateIdentifier = patientIdentifierService.get( null, identifier );
@@ -456,7 +468,7 @@
this.gender = gender;
}
- public void setPhoneNumber( String phoneNumber )
+ public void setPhoneNumber( String[] phoneNumber )
{
this.phoneNumber = phoneNumber;
}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/UpdatePatientAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/UpdatePatientAction.java 2013-07-09 06:58:27 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/UpdatePatientAction.java 2013-07-12 04:32:20 +0000
@@ -90,7 +90,7 @@
{
this.systemSettingManager = systemSettingManager;
}
-
+
// -------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------
@@ -111,7 +111,7 @@
private String gender;
- private String phoneNumber;
+ private String[] phoneNumber;
private boolean underAge;
@@ -179,12 +179,24 @@
// Set Other information for patient
// ---------------------------------------------------------------------
- phoneNumber = (phoneNumber!=null && phoneNumber.trim().equals( systemSettingManager
- .getSystemSetting( SystemSettingManager.KEY_PHONE_NUMBER_AREA_CODE ) )) ? null : phoneNumber;
-
+ String phone = "";
+
+ for ( String _phoneNumber : phoneNumber )
+ {
+ _phoneNumber = (_phoneNumber != null && _phoneNumber.isEmpty() && _phoneNumber.trim().equals(
+ systemSettingManager.getSystemSetting( SystemSettingManager.KEY_PHONE_NUMBER_AREA_CODE ) )) ? null
+ : _phoneNumber;
+ if ( _phoneNumber != null )
+ {
+ phone += _phoneNumber + ";";
+ }
+ }
+
+ phone = (phone.isEmpty()) ? null : phone.substring( 0, phone.length() - 1 );
+
+ patient.setPhoneNumber( phone );
patient.setGender( gender );
patient.setIsDead( false );
- patient.setPhoneNumber( phoneNumber );
patient.setUnderAge( underAge );
patient.setOrganisationUnit( organisationUnit );
patient.setIsDead( isDead );
@@ -222,7 +234,7 @@
patient.setDobType( dobType );
}
-
+
// -------------------------------------------------------------------------------------
// Save PatientIdentifier
// -------------------------------------------------------------------------------------
@@ -435,7 +447,7 @@
this.gender = gender;
}
- public void setPhoneNumber( String phoneNumber )
+ public void setPhoneNumber( String[] phoneNumber )
{
this.phoneNumber = phoneNumber;
}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/defaultPatientForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/defaultPatientForm.vm 2013-07-03 15:40:29 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/defaultPatientForm.vm 2013-07-12 04:32:20 +0000
@@ -60,6 +60,7 @@
<td class='text-column'><label for="phoneNumber">$i18n.getString( "phone_number" )</label></td>
<td class="input-column">
<input type="text" id="phoneNumber" name="phoneNumber" class="{validate:{phone:true}}"/>
+ <input type="button" value='+' style='width:20px;' onclick='addPhoneNumberField("$!phoneNumberAreaCode");' />
</td>
</tr>
#end
@@ -213,8 +214,13 @@
showById('birthDate');
#end
- #if( $!patient.phoneNumber && $patient.phoneNumber!="")
- setFieldValue('phoneNumber',"$!patient.phoneNumber")
+ #if( $!patient.phoneNumber && $patient.phoneNumber!="")
+ var phoneNumbers = "$!patient.phoneNumber".split(';');
+ setFieldValue('phoneNumber',phoneNumbers[0]);
+ for( var i = 1;i<phoneNumbers.length;i++ )
+ {
+ addPhoneNumberField(phoneNumbers[i]);
+ }
#else
setFieldValue('phoneNumber',"$!phoneNumberAreaCode")
#end
=== 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 2013-06-20 08:49:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js 2013-07-12 04:32:20 +0000
@@ -2111,3 +2111,20 @@
$( '#comment' ).css( 'background-color', COLOR_GREEN );
});
}
+
+function addPhoneNumberField(phoneNumberAreaCode)
+{
+ $('.phoneNumberTR').last().after(
+ '<tr class="phoneNumberTR">'
+ + ' <td></td>'
+ + ' <td class="input-column">'
+ + ' <input type="text" id="phoneNumber" name="phoneNumber" class="{validate:{phone:true}}" value="'+phoneNumberAreaCode+'"/>'
+ + ' <input type="button" value="-" onclick="removePhoneNumberField(this)" style="width:20px;" class="{validate:{phone:true}}" value="' + phoneNumberAreaCode + '"/>'
+ + ' </td>'
+ + '</tr>' );
+}
+
+function removePhoneNumberField(_this)
+{
+ $(_this).parent().parent().remove();
+}
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm 2013-07-09 03:26:26 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm 2013-07-12 04:32:20 +0000
@@ -59,10 +59,11 @@
</td>
</tr>
- <tr>
+ <tr class='phoneNumberTR'>
<td class='text-column'><label for="phoneNumber">$i18n.getString( "phone_number" )</label></td>
<td class="input-column">
<input type="text" id="phoneNumber" name="phoneNumber" class="{validate:{phone:true}}"/>
+ <input type="button" value='+' style='width:20px;' onclick='addPhoneNumberField("$!phoneNumberAreaCode");' />
</td>
</tr>
@@ -265,8 +266,13 @@
showById('birthDate');
#end
- #if( $!patient.phoneNumber && $patient.phoneNumber!="")
- setFieldValue('phoneNumber',"$!patient.phoneNumber")
+ #if( $!patient.phoneNumber && $patient.phoneNumber!="")
+ var phoneNumbers = "$!patient.phoneNumber".split(';');
+ setFieldValue('phoneNumber',phoneNumbers[0]);
+ for( var i = 1;i<phoneNumbers.length;i++ )
+ {
+ addPhoneNumberField(phoneNumbers[i]);
+ }
#else
setFieldValue('phoneNumber',"$!phoneNumberAreaCode")
#end