=== 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 organisationUnits; + + public Set getOrganisationUnits() + { + return organisationUnits; + } + + public void setOrganisationUnits( Set 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 basicOrganisationUnits = currentUserService.getCurrentUser() + .getOrganisationUnits(); + organisationUnits = new HashSet(); + + patient = patientService.getPatient( patientId ); + + for ( OrganisationUnit organisationUnit : basicOrganisationUnits ) + { + organisationUnits.addAll( this.getAllParentOrganisationUnits( organisationUnit ) ); + } + + organisationUnits.add( patient.getOrganisationUnit() ); + + return SUCCESS; + } + + private Collection getAllParentOrganisationUnits( OrganisationUnit organisationUnit ) + { + List parents = new ArrayList(); + 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 @@ + + + + + + + + + + + showPatientProgramStageList.action?patientId=${patientId}&programInstanceId=${programInstanceId}&programId=${programId}&validated=false + + + /dhis-web-light/main.vm + /dhis-web-light/namebased/patientLocationForm.vm + + + + showPatientProgramList.action?patientId=${patientId} + === 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())
  • $i18n.getString("phone_number"): $patient.getPhoneNumber()
  • #end +
  • $i18n.getString("orgunit"): $patient.getOrganisationUnit().getName() [$i18n.getString("change")]
  • #foreach($patientIdentifier in $patientIdentifiers) #if($patientIdentifier.getIdentifierType())
  • $patientIdentifier.getIdentifierType().getName(): $patientIdentifier.getIdentifier()
  • === 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 @@ +

    $i18n.getString( "register_location_for" ) $patient.getFullName()

    + +
    +
    + + +

    + + +

    + +
    + +
    +

    + +

    +
    + +
    + +