=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java 2013-08-07 03:44:17 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java 2013-08-08 06:20:51 +0000 @@ -134,7 +134,9 @@ Grid getCompletenessProgramStageInstance( Collection orgunits, Program program, String startDate, String endDate, I18n i18n ); - + Collection sendMessages( ProgramStageInstance programStageInstance, int status, I18nFormat format ); + Collection getProgramStageInstance( Patient patient ); + } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java 2013-07-23 04:16:21 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java 2013-08-08 06:20:51 +0000 @@ -124,5 +124,7 @@ Collection getOrgunitIds( Date startDate, Date endDate ); Grid getCompleteness( Collection orgunitIds, Program program, String startDate, String endDate, I18n i18n ); + + Collection get( Patient patient ); } === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java 2013-08-07 03:44:17 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java 2013-08-08 06:20:51 +0000 @@ -581,6 +581,11 @@ return outboundSmsList; } + public Collection getProgramStageInstance( Patient patient ) + { + return programStageInstanceStore.get( patient ); + } + // ------------------------------------------------------------------------- // Supportive methods // ------------------------------------------------------------------------- === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java 2013-07-25 02:32:32 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java 2013-08-08 06:20:51 +0000 @@ -394,13 +394,13 @@ public Collection getSendMesssageEvents() { String sql = " ( " + sendMessageToPatientSql() + " ) "; - - sql += " UNION ( " + sendMessageToHealthWorkerSql() + " ) "; + + sql += " UNION ( " + sendMessageToHealthWorkerSql() + " ) "; sql += " UNION ( " + sendMessageToOrgunitRegisteredSql() + " ) "; - + sql += " UNION ( " + sendMessageToUsersSql() + " ) "; - + sql += " UNION ( " + sendMessageToUserGroupsSql() + " ) "; SqlRowSet rs = jdbcTemplate.queryForRowSet( sql ); @@ -734,7 +734,8 @@ return rs != null ? rs.intValue() : 0; } - public Grid getCompleteness( Collection orgunitIds, Program program, String startDate, String endDate, I18n i18n ) + public Grid getCompleteness( Collection orgunitIds, Program program, String startDate, String endDate, + I18n i18n ) { String sql = "SELECT ou.name as orgunit, ps.name as events, psi.completeduser as user_name, count(psi.programstageinstanceid) as number_of_events " + " FROM programstageinstance psi INNER JOIN programstage ps " @@ -777,6 +778,13 @@ return grid; } + @SuppressWarnings( "unchecked" ) + public Collection get( Patient patient ) + { + return getCriteria().createAlias( "patients", "patient" ) + .add( Restrictions.eq( "patient.id", patient.getId() ) ).list(); + } + // ------------------------------------------------------------------------- // Supportive methods // ------------------------------------------------------------------------- @@ -2461,7 +2469,8 @@ + " and pg.type=1 and prm.daysallowedsendmessage is not null " + " and psi.executiondate is null " + " and ( DATE(now()) - DATE(psi.duedate) ) = prm.daysallowedsendmessage " - + " and prm.whentosend is null and prm.sendto = " + + PatientReminder.SEND_TO_ORGUGNIT_REGISTERED; + + " and prm.whentosend is null and prm.sendto = " + + +PatientReminder.SEND_TO_ORGUGNIT_REGISTERED; } private String sendMessageToUsersSql() @@ -2492,9 +2501,10 @@ + " and pg.type=1 and prm.daysallowedsendmessage is not null " + " and psi.executiondate is null " + " and ( DATE(now()) - DATE(psi.duedate) ) = prm.daysallowedsendmessage " - + " and prm.whentosend is null and prm.sendto = " + PatientReminder.SEND_TO_ALL_USERS_IN_ORGUGNIT_REGISTERED; + + " and prm.whentosend is null and prm.sendto = " + + PatientReminder.SEND_TO_ALL_USERS_IN_ORGUGNIT_REGISTERED; } - + private String sendMessageToUserGroupsSql() { return "select psi.programstageinstanceid, uif.phonenumber,prm.templatemessage, p.firstname, p.middlename, p.lastname, org.name as orgunitName ," @@ -2523,7 +2533,6 @@ + " and pg.type=1 and prm.daysallowedsendmessage is not null " + " and psi.executiondate is not null " + " and ( DATE(now()) - DATE(psi.duedate) ) = prm.daysallowedsendmessage " - + " and prm.whentosend is null " - + " and prm.sendto = " + PatientReminder.SEND_TO_USER_GROUP; + + " and prm.whentosend is null " + " and prm.sendto = " + PatientReminder.SEND_TO_USER_GROUP; } } === 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-12 04:32:20 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddPatientAction.java 2013-08-08 06:20:51 +0000 @@ -53,6 +53,10 @@ import org.hisp.dhis.patient.PatientService; import org.hisp.dhis.patient.util.PatientIdentifierGenerator; import org.hisp.dhis.patientattributevalue.PatientAttributeValue; +import org.hisp.dhis.relationship.Relationship; +import org.hisp.dhis.relationship.RelationshipService; +import org.hisp.dhis.relationship.RelationshipType; +import org.hisp.dhis.relationship.RelationshipTypeService; import org.hisp.dhis.setting.SystemSettingManager; import org.hisp.dhis.user.UserService; @@ -93,6 +97,10 @@ private SystemSettingManager systemSettingManager; + private RelationshipTypeService relationshipTypeService; + + private RelationshipService relationshipService; + // ------------------------------------------------------------------------- // Input // ------------------------------------------------------------------------- @@ -123,6 +131,10 @@ private String deathDate; + private Integer relationshipId; + + private boolean relationshipFromA; + private String message; // ------------------------------------------------------------------------- @@ -364,6 +376,43 @@ Integer id = patientService.createPatient( patient, representativeId, relationshipTypeId, patientAttributeValues ); + // ------------------------------------------------------------------------- + // Create relationship + // ------------------------------------------------------------------------- + + if ( relationshipId != null && relationshipTypeId != null ) + { + Patient relationship = patientService.getPatient( relationshipId ); + if ( relationship != null ) + { + if ( underAge ) + { + patient.setRepresentative( relationship ); + } + + Relationship rel = new Relationship(); + if ( relationshipFromA ) + { + rel.setPatientA( relationship ); + rel.setPatientB( patient ); + } + else + { + rel.setPatientA( patient ); + rel.setPatientB( relationship ); + } + if ( relationshipTypeId != null ) + { + RelationshipType relType = relationshipTypeService.getRelationshipType( relationshipTypeId ); + if ( relType != null ) + { + rel.setRelationshipType( relType ); + relationshipService.saveRelationship( rel ); + } + } + } + } + message = id + "_" + systemGenerateIdentifier.getIdentifier(); return SUCCESS; @@ -378,6 +427,26 @@ this.userService = userService; } + public void setRelationshipTypeService( RelationshipTypeService relationshipTypeService ) + { + this.relationshipTypeService = relationshipTypeService; + } + + public void setRelationshipId( Integer relationshipId ) + { + this.relationshipId = relationshipId; + } + + public void setRelationshipFromA( boolean relationshipFromA ) + { + this.relationshipFromA = relationshipFromA; + } + + public void setRelationshipService( RelationshipService relationshipService ) + { + this.relationshipService = relationshipService; + } + public void setSystemSettingManager( SystemSettingManager systemSettingManager ) { this.systemSettingManager = systemSettingManager; === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java 2013-06-11 05:55:48 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java 2013-08-08 06:20:51 +0000 @@ -220,9 +220,10 @@ // Get patient-attribute-values // --------------------------------------------------------------------- - Collection _attributeValues = patientAttributeValueService.getPatientAttributeValues( patient ); + Collection _attributeValues = patientAttributeValueService + .getPatientAttributeValues( patient ); attributeValues = new HashSet(); - + for ( Program program : programs ) { Collection atttributes = program.getPatientAttributes(); @@ -234,14 +235,14 @@ } } } - + // --------------------------------------------------------------------- // Get patient-identifiers // --------------------------------------------------------------------- Collection _identifiers = patient.getIdentifiers(); identifiers = new HashSet(); - + for ( Program program : programs ) { Collection identifierTypes = program.getPatientIdentifierTypes(); @@ -249,11 +250,11 @@ { if ( !identifierTypes.contains( identifier.getIdentifierType() ) ) { - identifiers.add(identifier); + identifiers.add( identifier ); } } } - + // --------------------------------------------------------------------- // Get relationship // --------------------------------------------------------------------- === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentAction.java 2013-03-06 04:14:33 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentAction.java 2013-08-08 06:20:51 +0000 @@ -47,6 +47,7 @@ import org.hisp.dhis.program.ProgramInstance; import org.hisp.dhis.program.ProgramInstanceService; import org.hisp.dhis.program.ProgramStageInstance; +import org.hisp.dhis.program.ProgramStageInstanceService; import org.hisp.dhis.program.comparator.ProgramStageInstanceVisitDateComparator; import com.opensymphony.xwork2.Action; @@ -69,6 +70,8 @@ private SelectedStateManager selectedStateManager; + private ProgramStageInstanceService programStageInstanceService; + // ------------------------------------------------------------------------- // Input/Output // ------------------------------------------------------------------------- @@ -93,6 +96,8 @@ private ProgramInstance programInstance; + private Collection linkProgramStageInstances = new HashSet(); + // ------------------------------------------------------------------------- // Getters/Setters // ------------------------------------------------------------------------- @@ -102,6 +107,16 @@ this.selectedStateManager = selectedStateManager; } + public Collection getLinkProgramStageInstances() + { + return linkProgramStageInstances; + } + + public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService ) + { + this.programStageInstanceService = programStageInstanceService; + } + public Collection getNoGroupAttributes() { return noGroupAttributes; @@ -185,6 +200,8 @@ programStageInstances = new ArrayList( programInstance.getProgramStageInstances() ); Collections.sort( programStageInstances, new ProgramStageInstanceVisitDateComparator() ); + + linkProgramStageInstances = programStageInstanceService.getProgramStageInstance( programInstance.getPatient() ); loadIdentifierTypes( programInstance ); === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddRelationshipPatientAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddRelationshipPatientAction.java 2012-09-21 10:27:45 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddRelationshipPatientAction.java 2013-08-08 06:20:51 +0000 @@ -27,9 +27,11 @@ package org.hisp.dhis.caseentry.action.patient; +import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import org.hisp.dhis.organisationunit.OrganisationUnit; @@ -100,17 +102,25 @@ private Collection healthWorkers; + private List programs; + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- public String execute() { - patient = patientService.getPatient( id.intValue() ); + OrganisationUnit organisationUnit = selectionManager.getSelectedOrganisationUnit(); + patient = patientService.getPatient( id ); identifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes(); Collection patientAttributes = patientAttributeService.getAllPatientAttributes(); - Collection programs = programService.getAllPrograms(); + + programs = new ArrayList( programService.getProgramsByDisplayOnAllOrgunit( true, null ) ); + programs.addAll( programService.getProgramsByDisplayOnAllOrgunit( false, organisationUnit ) ); + programs.retainAll( programService.getProgramsByCurrentUser() ); + programs.removeAll( programService.getPrograms( Program.SINGLE_EVENT_WITHOUT_REGISTRATION ) ); + for ( Program program : programs ) { identifierTypes.removeAll( program.getPatientIdentifierTypes() ); @@ -172,7 +182,6 @@ } } - OrganisationUnit organisationUnit = selectionManager.getSelectedOrganisationUnit(); healthWorkers = organisationUnit.getUsers(); return SUCCESS; @@ -181,12 +190,17 @@ // ------------------------------------------------------------------------- // Getter/Setter // ------------------------------------------------------------------------- - + public void setSelectionManager( OrganisationUnitSelectionManager selectionManager ) { this.selectionManager = selectionManager; } + public List getPrograms() + { + return programs; + } + public void setProgramService( ProgramService programService ) { this.programService = programService; === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2013-08-07 08:46:28 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2013-08-08 06:20:51 +0000 @@ -487,6 +487,10 @@ ref="org.hisp.dhis.patient.PatientAttributeOptionService" /> + + + -

+

@@ -56,7 +56,7 @@ #parse( "/dhis-web-caseentry/patientForm.vm" ) - + === 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-08-07 08:46:28 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js 2013-08-08 06:20:51 +0000 @@ -1796,10 +1796,11 @@ jQuery('#dashboardHistoryDiv').toggle(); } -function viewPersonProgram ( displayedDiv, hidedDiv ) +function viewPersonProgram ( displayedDiv, hidedDiv1, hideDiv2 ) { showById(displayedDiv); - hideById(hidedDiv); + hideById(hidedDiv1); + hideById(hidedDiv2); } // -------------------------------------------------------------------- === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js 2013-07-25 06:27:06 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js 2013-08-08 06:20:51 +0000 @@ -580,8 +580,7 @@ } var blocked = jQuery('#entryFormContainer [id=blockEntryForm]').val(); - - if( blocked=='true' ) { + if( blocked=='true' ) { blockEntryForm(); } === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js 2013-07-23 09:20:16 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js 2013-08-08 06:20:51 +0000 @@ -370,6 +370,15 @@ disableCompletedButton(true); } } + + var linkedEvent = jQuery(".stage-object-selected").attr("linkedEvent"); + if( linkedEvent=='true' ) { + blockEntryForm(); + disable('executionDate'); + } + else{ + enable('executionDate'); + } resize(); hideLoader(); hideById('contentDiv'); === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageInstanceFlow.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageInstanceFlow.vm 2013-07-30 06:16:43 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageInstanceFlow.vm 2013-08-08 06:20:51 +0000 @@ -7,10 +7,42 @@
+ #foreach( $programStageInstance in $linkProgramStageInstances ) + + + #end + #if( $programStageInstances) #else #set( $programStageInstances = $programInstance.programStageInstances) #end + #foreach( $programStageInstance in $programStageInstances )
+ #set($valueDate=$format.formatDate( $programStageInstance.dueDate )) + #if($!programStageInstance.executionDate) + #set($valueDate=$format.formatDate( $programStageInstance.executionDate )) + #end +
 $!programStageInstance.organisationUnit.name
+ + +
@@ -33,6 +65,7 @@ dueDate="$format.formatDate( $programStageInstance.dueDate )" class="stage-object" value="$programStageInstance.programStage.displayName  $valueDate" + linkedEvent='false' onclick="javascript:loadDataEntry( $programStageInstance.id );">