dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #18310
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7669: [mobile] support for change Person organisation unit
------------------------------------------------------------
revno: 7669
committer: Long <thanhlongngo1988@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-07-23 16:58:04 +0700
message:
[mobile] support for change Person organisation unit
added:
dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetPatientLocationFormAction.java
dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/RegisterPatientLocationAction.java
dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/namebased/patientLocationForm.vm
modified:
dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties
dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/namebased/beneficiaryProgramList.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
=== added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetPatientLocationFormAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetPatientLocationFormAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetPatientLocationFormAction.java 2012-07-23 09:58:04 +0000
@@ -0,0 +1,120 @@
+package org.hisp.dhis.light.namebaseddataentry.action;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.patient.PatientService;
+import org.hisp.dhis.user.CurrentUserService;
+
+import com.opensymphony.xwork2.Action;
+
+public class GetPatientLocationFormAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private CurrentUserService currentUserService;
+
+ public CurrentUserService getCurrentUserService()
+ {
+ return currentUserService;
+ }
+
+ public void setCurrentUserService( CurrentUserService currentUserService )
+ {
+ this.currentUserService = currentUserService;
+ }
+
+ private PatientService patientService;
+
+ public PatientService getPatientService()
+ {
+ return patientService;
+ }
+
+ public void setPatientService( PatientService patientService )
+ {
+ this.patientService = patientService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input & Output
+ // -------------------------------------------------------------------------
+
+ private Set<OrganisationUnit> organisationUnits;
+
+ public Set<OrganisationUnit> getOrganisationUnits()
+ {
+ return organisationUnits;
+ }
+
+ public void setOrganisationUnits( Set<OrganisationUnit> organisationUnits )
+ {
+ this.organisationUnits = organisationUnits;
+ }
+
+ private Integer patientId;
+
+ public Integer getPatientId()
+ {
+ return patientId;
+ }
+
+ public void setPatientId( Integer patientId )
+ {
+ this.patientId = patientId;
+ }
+
+ private Patient patient;
+
+ public Patient getPatient()
+ {
+ return patient;
+ }
+
+ public void setPatient( Patient patient )
+ {
+ this.patient = patient;
+ }
+
+ @Override
+ public String execute()
+ throws Exception
+ {
+ Collection<OrganisationUnit> basicOrganisationUnits = currentUserService.getCurrentUser()
+ .getOrganisationUnits();
+ organisationUnits = new HashSet<OrganisationUnit>();
+
+ patient = patientService.getPatient( patientId );
+
+ for ( OrganisationUnit organisationUnit : basicOrganisationUnits )
+ {
+ organisationUnits.addAll( this.getAllParentOrganisationUnits( organisationUnit ) );
+ }
+
+ organisationUnits.add( patient.getOrganisationUnit() );
+
+ return SUCCESS;
+ }
+
+ private Collection<? extends OrganisationUnit> getAllParentOrganisationUnits( OrganisationUnit organisationUnit )
+ {
+ List<OrganisationUnit> parents = new ArrayList<OrganisationUnit>();
+ parents.add( organisationUnit );
+
+ while ( organisationUnit.getParent() != null )
+ {
+ parents.add( organisationUnit.getParent() );
+ organisationUnit = organisationUnit.getParent();
+ }
+ return parents;
+ }
+
+}
=== added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/RegisterPatientLocationAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/RegisterPatientLocationAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/RegisterPatientLocationAction.java 2012-07-23 09:58:04 +0000
@@ -0,0 +1,74 @@
+package org.hisp.dhis.light.namebaseddataentry.action;
+
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.patient.PatientService;
+
+import com.opensymphony.xwork2.Action;
+
+public class RegisterPatientLocationAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private PatientService patientService;
+
+ public void setPatientService( PatientService patientService )
+ {
+ this.patientService = patientService;
+ }
+
+ private OrganisationUnitService organisationUnitService;
+
+ public OrganisationUnitService getOrganisationUnitService()
+ {
+ return organisationUnitService;
+ }
+
+ public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+ {
+ this.organisationUnitService = organisationUnitService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input & Output
+ // -------------------------------------------------------------------------
+
+ private Integer patientId;
+
+ public Integer getPatientId()
+ {
+ return patientId;
+ }
+
+ public void setPatientId( Integer patientId )
+ {
+ this.patientId = patientId;
+ }
+
+ private Integer orgUnitId;
+
+ public Integer getOrgUnitId()
+ {
+ return orgUnitId;
+ }
+
+ public void setOrgUnitId( Integer orgUnitId )
+ {
+ this.orgUnitId = orgUnitId;
+ }
+
+ @Override
+ public String execute()
+ throws Exception
+ {
+ Patient patient = patientService.getPatient( patientId );
+ patient.setOrganisationUnit( organisationUnitService.getOrganisationUnit( orgUnitId ) );
+ patientService.savePatient( patient );
+
+ return SUCCESS;
+ }
+
+}
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml 2012-07-15 07:10:03 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml 2012-07-23 09:58:04 +0000
@@ -251,6 +251,23 @@
<property name="relationshipService"
ref="org.hisp.dhis.relationship.RelationshipService" />
</bean>
+
+ <bean
+ id="org.hisp.dhis.light.namebaseddataentry.action.RegisterPatientLocationAction"
+ class="org.hisp.dhis.light.namebaseddataentry.action.RegisterPatientLocationAction">
+ <property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
+ <property name="organisationUnitService"
+ ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+ </bean>
+
+ <bean
+ id="org.hisp.dhis.light.namebaseddataentry.action.GetPatientLocationFormAction"
+ class="org.hisp.dhis.light.namebaseddataentry.action.GetPatientLocationFormAction">
+ <property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
+ <property name="currentUserService"
+ ref="org.hisp.dhis.user.CurrentUserService" />
+ </bean>
+
<!-- Beneficiary Registration -->
<bean
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties 2012-07-16 09:20:08 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties 2012-07-23 09:58:04 +0000
@@ -104,3 +104,6 @@
declared=Declared
verified=Verified
anomynous_program_list=Anonymous Program List
+orgunit=Organisation Unit
+change=Change
+register_location_for=Register Location For
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml 2012-07-18 04:43:02 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml 2012-07-23 09:58:04 +0000
@@ -205,6 +205,17 @@
<result name="success" type="redirect">showPatientProgramStageList.action?patientId=${patientId}&programInstanceId=${programInstanceId}&programId=${programId}&validated=false
</result>
</action>
+
+ <action name="showPatientLocationForm"
+ class="org.hisp.dhis.light.namebaseddataentry.action.GetPatientLocationFormAction">
+ <result name="success" type="velocity">/dhis-web-light/main.vm</result>
+ <param name="page">/dhis-web-light/namebased/patientLocationForm.vm</param>
+ </action>
+
+ <action name="registerPatientLocation"
+ class="org.hisp.dhis.light.namebaseddataentry.action.RegisterPatientLocationAction">
+ <result name="success" type="redirect">showPatientProgramList.action?patientId=${patientId}</result>
+ </action>
<!-- Beneficiary Registration -->
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/namebased/beneficiaryProgramList.vm'
--- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/namebased/beneficiaryProgramList.vm 2012-07-15 07:44:23 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/namebased/beneficiaryProgramList.vm 2012-07-23 09:58:04 +0000
@@ -39,6 +39,7 @@
#if($patient.getPhoneNumber())
<li><strong>$i18n.getString("phone_number"):</strong> $patient.getPhoneNumber()</li>
#end
+ <li><strong>$i18n.getString("orgunit"):</strong> $patient.getOrganisationUnit().getName() <a href="showPatientLocationForm.action?patientId=$patient.id">[$i18n.getString("change")]</a></li>
#foreach($patientIdentifier in $patientIdentifiers)
#if($patientIdentifier.getIdentifierType())
<li><strong>$patientIdentifier.getIdentifierType().getName():</strong> $patientIdentifier.getIdentifier()</li>
=== added file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/namebased/patientLocationForm.vm'
--- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/namebased/patientLocationForm.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/namebased/patientLocationForm.vm 2012-07-23 09:58:04 +0000
@@ -0,0 +1,33 @@
+<h2>$i18n.getString( "register_location_for" ) $patient.getFullName()</h2>
+
+<form action="registerPatientLocation.action" method="POST">
+<div class="header-box" align="center">
+<input type="hidden" name="patientId" value="$patient.id"/>
+
+<p style="text-align: left;">
+ <label>$i18n.getString( "select_orgunit" )</label>
+ <select name="orgUnitId">
+ #foreach($orgUnit in $organisationUnits)
+ <option value="$orgUnit.getId()" #if($orgUnit.id == $patient.getOrganisationUnit().id) selected="selected" #end>$orgUnit.getName()</option>
+ #end
+ </select>
+</p>
+
+</div>
+
+<div class="header-box" align="center">
+ <p>
+ <input type="submit" style="width: 100%;" value="$i18n.getString("register")" />
+ </p>
+</div>
+
+</form>
+
+<div id="footer">
+<h2>$i18n.getString( "navigate_to" )</h2>
+<ul>
+ <li><a href="showPatientProgramList.action?patientId=$patient.getId()">$!encoder.htmlEncode( ${patient.getFullName()} )</a></li>
+ <li> <a href="trackingMenu.action"> $i18n.getString("tracking_menu")</a> </li>
+ <li><a href="index.action">$i18n.getString("home")</a></li>
+</ul>
+</div>