=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramService.java 2013-08-23 15:56:19 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramService.java 2013-09-11 16:02:06 +0000 @@ -50,6 +50,8 @@ Program getProgram( int id ); Program getProgramByName( String name ); + + Program getProgramByCode( String code ); Collection getAllPrograms(); === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientIdentifierStore.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientIdentifierStore.java 2013-09-11 04:12:50 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientIdentifierStore.java 2013-09-11 16:02:06 +0000 @@ -126,6 +126,6 @@ { Number rs = (Number) getCriteria( Restrictions.ilike( "identifier", identifier ) ).setProjection( Projections.rowCount() ).uniqueResult(); - return rs != null ? true: false; + return ( rs != null & rs.intValue() > 0 )? true: false; } } === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramService.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramService.java 2013-08-23 16:05:01 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramService.java 2013-09-11 16:02:06 +0000 @@ -69,7 +69,7 @@ // ------------------------------------------------------------------------- // Implementation methods // ------------------------------------------------------------------------- - + @Override public int saveProgram( Program program ) { @@ -175,11 +175,16 @@ { return i18n( i18nService, programStore.getByUid( uid ) ); } - + @Override public Collection getProgramsByDisplayOnAllOrgunit( boolean displayOnAllOrgunit, OrganisationUnit orgunit ) { - return i18n( i18nService, programStore.getProgramsByDisplayOnAllOrgunit( displayOnAllOrgunit, orgunit ) ); - } - + return i18n( i18nService, programStore.getProgramsByDisplayOnAllOrgunit( displayOnAllOrgunit, orgunit ) ); + } + + public Program getProgramByCode( String code ) + { + return i18n( i18nService, programStore.getByCode( code ) ); + } + } === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/GetPatientAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/GetPatientAction.java 2013-09-03 06:39:59 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/GetPatientAction.java 2013-09-11 16:02:06 +0000 @@ -81,8 +81,6 @@ private PatientAttributeValueService patientAttributeValueService; - private PatientAttributeService patientAttributeService; - private PatientIdentifierTypeService patientIdentifierTypeService; private RelationshipService relationshipService; @@ -95,6 +93,8 @@ private PatientAttributeGroupService attributeGroupService; + private PatientAttributeService attributeService; + private I18n i18n; private I18nFormat format; @@ -135,6 +135,8 @@ private Integer programId; + private Map> attributesMap = new HashMap>(); + public void setProgramId( Integer programId ) { this.programId = programId; @@ -159,6 +161,16 @@ this.programStageInstanceId = programStageInstanceId; } + public void setAttributeService( PatientAttributeService attributeService ) + { + this.attributeService = attributeService; + } + + public Map> getAttributesMap() + { + return attributesMap; + } + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -219,44 +231,45 @@ } } + List attributes = new ArrayList(); + if ( customRegistrationForm == null ) { - // ------------------------------------------------------------------------- - // Get identifier-types && attributes - // ------------------------------------------------------------------------- - - programs = programService.getAllPrograms(); - - // ------------------------------------------------------------------------- - // Get identifier-types && attributes - // ------------------------------------------------------------------------- - - identifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes(); - Collection patientAttributesInProgram = new HashSet(); - - noGroupAttributes = patientAttributeService.getPatientAttributesWithoutGroup(); - - Collection programs = programService.getAllPrograms(); - programs.remove( program ); - - for ( Program _program : programs ) - { - identifierTypes.removeAll( _program.getPatientIdentifierTypes() ); - patientAttributesInProgram.removeAll( _program.getPatientAttributes() ); - noGroupAttributes.removeAll( _program.getPatientAttributes() ); - } - attributeGroups = new ArrayList( attributeGroupService.getAllPatientAttributeGroups() ); Collections.sort( attributeGroups, new PatientAttributeGroupSortOrderComparator() ); - for ( PatientAttributeGroup attributeGroup : attributeGroups ) - { - List attributes = attributeGroup.getAttributes(); - attributes.removeAll( patientAttributesInProgram ); - - if ( attributes.size() > 0 ) - { - attributeGroupsMap.put( attributeGroup.getId(), attributes ); + + if ( program == null ) + { + identifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes(); + attributes = new ArrayList( attributeService.getAllPatientAttributes() ); + Collection programs = programService.getAllPrograms(); + for ( Program p : programs ) + { + identifierTypes.removeAll( p.getPatientIdentifierTypes() ); + attributes.removeAll( p.getPatientAttributes() ); + } + } + else + { + identifierTypes = program.getPatientIdentifierTypes(); + attributes = program.getPatientAttributes(); + } + + for ( PatientAttribute attribute : attributes ) + { + PatientAttributeGroup patientAttributeGroup = attribute.getPatientAttributeGroup(); + String groupName = (patientAttributeGroup == null) ? "" : patientAttributeGroup.getDisplayName(); + if ( attributesMap.containsKey( groupName ) ) + { + List attrs = attributesMap.get( groupName ); + attrs.add( attribute ); + } + else + { + List attrs = new ArrayList(); + attrs.add( attribute ); + attributesMap.put( groupName, attrs ); } } @@ -389,11 +402,6 @@ this.patientAttributeValueService = patientAttributeValueService; } - public void setPatientAttributeService( PatientAttributeService patientAttributeService ) - { - this.patientAttributeService = patientAttributeService; - } - public void setPatientIdentifierTypeService( PatientIdentifierTypeService patientIdentifierTypeService ) { this.patientIdentifierTypeService = patientIdentifierTypeService; === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddPatientFormAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddPatientFormAction.java 2013-09-05 17:59:57 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddPatientFormAction.java 2013-09-11 16:02:06 +0000 @@ -32,7 +32,6 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; @@ -102,6 +101,13 @@ this.attributeService = attributeService; } + private PatientService patientService; + + public void setPatientService( PatientService patientService ) + { + this.patientService = patientService; + } + private PatientAttributeGroupService attributeGroupService; public void setAttributeGroupService( PatientAttributeGroupService attributeGroupService ) @@ -109,13 +115,6 @@ this.attributeGroupService = attributeGroupService; } - private PatientService patientService; - - public void setPatientService( PatientService patientService ) - { - this.patientService = patientService; - } - private I18n i18n; public void setI18n( I18n i18n ) @@ -167,13 +166,6 @@ return healthWorkers; } - private Collection noGroupAttributes = new HashSet(); - - public Collection getNoGroupAttributes() - { - return noGroupAttributes; - } - private Collection identifierTypes; public Collection getIdentifierTypes() @@ -181,6 +173,13 @@ return identifierTypes; } + private Map> attributesMap = new HashMap>(); + + public Map> getAttributesMap() + { + return attributesMap; + } + private OrganisationUnit organisationUnit; public OrganisationUnit getOrganisationUnit() @@ -270,36 +269,48 @@ } } + List attributes = new ArrayList(); + if ( customRegistrationForm == null ) { - identifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes(); - - Collection patientAttributesInProgram = new HashSet(); - Collection programs = programService.getAllPrograms(); - programs.remove( program ); - - for ( Program _program : programs ) - { - identifierTypes.removeAll( _program.getPatientIdentifierTypes() ); - patientAttributesInProgram.addAll( _program.getPatientAttributes() ); - } - attributeGroups = new ArrayList( attributeGroupService.getAllPatientAttributeGroups() ); Collections.sort( attributeGroups, new PatientAttributeGroupSortOrderComparator() ); - for ( PatientAttributeGroup attributeGroup : attributeGroups ) - { - List attributes = attributeGroup.getAttributes(); - attributes.removeAll( patientAttributesInProgram ); - - if ( attributes.size() > 0 ) - { - attributeGroupsMap.put( attributeGroup.getId(), attributes ); - } - } - - noGroupAttributes = attributeService.getPatientAttributesWithoutGroup(); - noGroupAttributes.removeAll( patientAttributesInProgram ); + + if ( program == null ) + { + identifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes(); + attributes = new ArrayList( attributeService.getAllPatientAttributes() ); + Collection programs = programService.getAllPrograms(); + for ( Program p : programs ) + { + identifierTypes.removeAll( p.getPatientIdentifierTypes() ); + attributes.removeAll( p.getPatientAttributes() ); + } + } + else + { + identifierTypes = program.getPatientIdentifierTypes(); + attributes = program.getPatientAttributes(); + } + + for ( PatientAttribute attribute : attributes ) + { + PatientAttributeGroup patientAttributeGroup = attribute.getPatientAttributeGroup(); + String groupName = (patientAttributeGroup == null) ? "" : patientAttributeGroup.getDisplayName(); + if ( attributesMap.containsKey( groupName ) ) + { + List attrs = attributesMap.get( groupName ); + attrs.add( attribute ); + } + else + { + List attrs = new ArrayList(); + attrs.add( attribute ); + attributesMap.put( groupName, attrs ); + } + } + } orgunitCountIdentifier = generateOrgunitIdentifier( organisationUnit ); === 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-09-11 09:50:12 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2013-09-11 16:02:06 +0000 @@ -455,7 +455,7 @@ - + F_ACCESS_PATIENT_ATTRIBUTES + + + /dhis-web-commons/ajax/jsonResponseSuccess.vm + + F_ALLOW_EDIT_PATIENT_PROPERTIES + + + + /dhis-web-commons/ajax/jsonResponseSuccess.vm + + F_ALLOW_EDIT_PATIENT_ATTRIBUTES + + + + /dhis-web-commons/ajax/jsonResponseSuccess.vm + + F_ALLOW_EDIT_PATIENT_IDENTIFIERS + === 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-09-09 18:00:50 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm 2013-09-11 16:02:06 +0000 @@ -16,7 +16,7 @@ #end #end - + @@ -27,12 +27,12 @@ $i18n.getString( "demographics" ) - + - + @@ -63,7 +63,7 @@ - + @@ -71,7 +71,7 @@ - + - + @@ -137,7 +137,7 @@ #set( $identifier = $!orgunitCountIdentifier ) #end - + #foreach ($attributeGroup in $attributeGroups ) - #set($attributes = $attributeGroupsMap.get($attributeGroup.id)) - #if($!attributes || $attributes.size() > 0) -   - $attributeGroup.displayName - #end + #set($attributes = $attributesMap.get($attributeGroup.displayName)) +   + $attributeGroup.displayName #foreach($attribute in $attributes ) #if( $attribute ) #set($value = "") #set($value = $patientAttributeValueMap.get($attribute.id)) - + #if( $attribute.valueType == "bool" ) @@ -196,18 +194,14 @@   - - #if ( $noGroupAttributes && $noGroupAttributes.size() > 0) - #if($!noGroupAttributes || $noGroupAttributes.size() > 0) + #set($attributes = $attributesMap.get("")) + #if ($!attributes) $i18n.getString( "other_details" ) - #end - #foreach($attribute in $noGroupAttributes ) - #if( $!attribute && $attribute.program ) - #elseif( $!attribute ) + #foreach($attribute in $attributes ) #set( $attributeValue = "" ) #set( $attributeValue = $!patientAttributeValueMap.get( $attribute.id ) ) #if( $attribute.valueType != 'calculated') - + #if( $attribute.valueType == "bool" ) @@ -236,7 +230,6 @@ #end - #end #end #end @@ -270,6 +263,33 @@ #end \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ViewPatientRegistrationFormAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ViewPatientRegistrationFormAction.java 2013-08-23 16:05:01 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ViewPatientRegistrationFormAction.java 2013-09-11 16:02:06 +0000 @@ -103,7 +103,7 @@ // ------------------------------------------------------------------------- // Getters & Setters // ------------------------------------------------------------------------- - + private Integer programId; public void setProgramId( Integer programId ) @@ -113,13 +113,13 @@ private Collection attributes = new HashSet(); - private Collection identifierTypes = new HashSet(); - public Collection getAttributes() { return attributes; } + private Collection identifierTypes = new HashSet(); + public Collection getIdentifierTypes() { return identifierTypes; @@ -167,30 +167,23 @@ if ( programId == null ) { registrationForm = patientRegistrationFormService.getCommonPatientRegistrationForm(); + + identifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes(); + attributes = patientAttributeService.getAllPatientAttributes(); + for ( Program p : programs ) + { + identifierTypes.remove( p.getPatientIdentifierTypes() ); + attributes.remove( p.getPatientAttributes() ); + } } else { program = programService.getProgram( programId ); + identifierTypes = program.getPatientIdentifierTypes(); + attributes = program.getPatientAttributes(); registrationForm = patientRegistrationFormService.getPatientRegistrationForm( program ); } - - // --------------------------------------------------------------------- - // Get dynamic attributes and identifier-types - // --------------------------------------------------------------------- - - identifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes(); - - attributes = patientAttributeService.getAllPatientAttributes(); - - for ( Program program : programs ) - { - if ( programId == null || program.getId() != programId ) - { - identifierTypes.removeAll( program.getPatientIdentifierTypes() ); - attributes.removeAll( program.getPatientAttributes() ); - } - } - + // --------------------------------------------------------------------- // Get images // --------------------------------------------------------------------- === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/AddProgramAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/AddProgramAction.java 2013-09-10 04:51:49 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/AddProgramAction.java 2013-09-11 16:02:06 +0000 @@ -302,7 +302,7 @@ { this.relationshipFromA = relationshipFromA; } - + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -334,7 +334,7 @@ program.setUseBirthDateAsEnrollmentDate( useBirthDateAsEnrollmentDate ); program.setSelectEnrollmentDatesInFuture( selectEnrollmentDatesInFuture ); program.setSelectIncidentDatesInFuture( selectIncidentDatesInFuture ); - + if ( type == Program.MULTIPLE_EVENTS_WITH_REGISTRATION ) { program.setIgnoreOverdueEvents( ignoreOverdueEvents ); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ShowAddProgramFormAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ShowAddProgramFormAction.java 2013-09-05 17:59:57 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ShowAddProgramFormAction.java 2013-09-11 16:02:06 +0000 @@ -31,6 +31,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.HashSet; import java.util.List; import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator; @@ -138,19 +139,20 @@ public String execute() { - availableIdentifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes(); - - availableAttributes = patientAttributeService.getAllPatientAttributes(); programs = new ArrayList( programService.getAllPrograms() ); Collections.sort( programs, IdentifiableObjectNameComparator.INSTANCE ); - - for ( Program program : programs ) + + + availableAttributes = patientAttributeService.getAllPatientAttributes(); + + availableIdentifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes(); + for ( Program p : programs ) { - availableIdentifierTypes.removeAll( program.getPatientIdentifierTypes() ); - availableAttributes.removeAll( program.getPatientAttributes() ); + availableIdentifierTypes + .removeAll( new HashSet( p.getPatientIdentifierTypes() ) ); } - + userGroups = new ArrayList( userGroupService.getAllUserGroups() ); relationshipTypes = new ArrayList(relationshipTypeService.getAllRelationshipTypes()); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ShowUpdateProgramFormAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ShowUpdateProgramFormAction.java 2013-09-05 17:59:57 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ShowUpdateProgramFormAction.java 2013-09-11 16:02:06 +0000 @@ -204,14 +204,14 @@ availableIdentifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes(); availableAttributes = patientAttributeService.getAllPatientAttributes(); - + availableAttributes.removeAll( new HashSet( program.getPatientAttributes() ) ); + programs = new ArrayList( programService.getAllPrograms() ); - for ( Program program : programs ) + for ( Program p : programs ) { availableIdentifierTypes - .removeAll( new HashSet( program.getPatientIdentifierTypes() ) ); - availableAttributes.removeAll( new HashSet( program.getPatientAttributes() ) ); + .removeAll( new HashSet( p.getPatientIdentifierTypes() ) ); } userGroups = new ArrayList( userGroupService.getAllUserGroups() ); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/resources/org/hisp/dhis/user/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/resources/org/hisp/dhis/user/i18n_module.properties 2013-09-08 08:36:32 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/resources/org/hisp/dhis/user/i18n_module.properties 2013-09-11 16:02:06 +0000 @@ -121,7 +121,10 @@ F_RELATIONSHIPTYPE_ADD=Add Relationship Type F_ORGANISATION_REGISTRATION=Organisation Unit Registration F_PATIENT_REMOVE_EMPTY_EVENTS=Remove Empty Person Events -F_ACCESS_PATIENT_ATTRIBUTES = View and search Person identifiers +F_ACCESS_PATIENT_ATTRIBUTES = View and Search Person identifiers +F_ALLOW_EDIT_PATIENT_ATTRIBUTES = Add and Edit Patient Attributes +F_ALLOW_EDIT_PATIENT_PROPERTIES = Add and Edit Patient Properties +F_ALLOW_EDIT_PATIENT_IDENTIFIERS = Add and Edit Patient Identifiers F_PATIENTATTRIBUTE_ADD=Add/Update Person Attribute F_PATIENTATTRIBUTE_DELETE=Delete Person Attribute F_PATIENTATTRIBUTEVALUE_ADD=Add Person Attribute Value