=== 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 2012-06-07 04:23:40 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java 2012-06-14 13:07:22 +0000 @@ -32,13 +32,10 @@ import java.util.Map; import org.hisp.dhis.common.Grid; -import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.i18n.I18n; import org.hisp.dhis.i18n.I18nFormat; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.patient.Patient; -import org.hisp.dhis.patient.PatientAttribute; -import org.hisp.dhis.patient.PatientIdentifierType; /** * @author Abyot Asalefew @@ -67,7 +64,7 @@ Collection getProgramStageInstances( Date dueDate, Boolean completed ); Collection getProgramStageInstances( Date startDate, Date endDate ); - + Collection getProgramStageInstances( Date startDate, Date endDate, Boolean completed ); Collection getAllProgramStageInstances(); @@ -88,18 +85,14 @@ List get( OrganisationUnit unit, Date after, Date before, Boolean completed ); List getProgramStageInstances( Patient patient, Boolean completed ); - - Grid getTabularReport( ProgramStage programStage, List hiddenCols, - List identifiers, List fixedAttributes, List attributes, - List dataElements, Map identifierKeys, Map attributeKeys, - Map dataElementKeys, Collection organisationUnits, - int level, Date startDate, Date endDate, boolean descOrder, Integer min, Integer max ); - - int getTabularReportCount( ProgramStage programStage, List identifiers, List fixedAttributes, List attributes, - List dataElements, Map identifierKeys, Map attributeKeys, - Map dataElementKeys, Collection organisationUnits, - int level, Date startDate, Date endDate ); - + + Grid getTabularReport( ProgramStage programStage, List searchingKeys, + Collection organisationUnits, int level, Date startDate, Date endDate, boolean descOrder, Integer min, + Integer max ); + + int getTabularReportCount( ProgramStage programStage, List searchingKeys, + Collection organisationUnits, int level, Date startDate, Date endDate ); + List getProgramStageInstancesReport( ProgramInstance programInstance, I18nFormat format, I18n i18n ); - + } === 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 2012-05-28 09:46:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java 2012-06-14 13:07:22 +0000 @@ -33,12 +33,9 @@ import org.hisp.dhis.common.GenericStore; import org.hisp.dhis.common.Grid; -import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitLevel; import org.hisp.dhis.patient.Patient; -import org.hisp.dhis.patient.PatientAttribute; -import org.hisp.dhis.patient.PatientIdentifierType; /** * @author Abyot Asalefew @@ -76,14 +73,10 @@ List get( ProgramStage programStage, OrganisationUnit orgunit, Date startDate, Date endDate, int min, int max ); - Grid getTabularReport( ProgramStage programStage, List hiddenCols, Map orgUnitLevelMap, - List identifiers, List fixedAttributes, List attributes, - List dataElements, Map identifierKeys, Map attributeKeys, - Map dataElementKeys, Collection orgUnits, - int level, int maxLevel, Date startDate, Date endDate, boolean descOrder, Integer min, Integer max ); + Grid getTabularReport( ProgramStage programStage, Map orgUnitLevelMap, + Collection orgUnits, List searchingKeys, int level, int maxLevel, Date startDate, + Date endDate, boolean descOrder, Integer min, Integer max ); - int getTabularReportCount( ProgramStage programStage, List identifiers, List fixedAttributes, List attributes, - List dataElements, Map identifierKeys, Map attributeKeys, - Map dataElementKeys, Collection orgUnits, - int level, int maxLevel, Date startDate, Date endDate ); + int getTabularReportCount( ProgramStage programStage, List searchingKeys, + Collection organisationUnits, int level, int maxLevel, Date startDate, Date endDate ); } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/relationship/RelationshipService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/relationship/RelationshipService.java 2009-11-12 11:27:02 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/relationship/RelationshipService.java 2012-06-14 13:07:22 +0000 @@ -47,6 +47,8 @@ Relationship getRelationship( int id ); Relationship getRelationship( Patient patientA, Patient patientB, RelationshipType relationshipType ); + + Relationship getRelationship( Patient patientA, Patient patientB ); Collection getAllRelationships(); === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/relationship/RelationshipStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/relationship/RelationshipStore.java 2009-11-20 07:45:12 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/relationship/RelationshipStore.java 2012-06-14 13:07:22 +0000 @@ -38,10 +38,11 @@ public interface RelationshipStore extends GenericStore { - String ID = RelationshipStore.class.getName(); Relationship get( Patient patientA, Patient patientB, RelationshipType relationshipType ); + + Relationship get( Patient patientA, Patient patientB ); Collection get( Patient patientA, RelationshipType relationshipType ); === 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 2012-06-07 04:23:40 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java 2012-06-14 13:07:22 +0000 @@ -43,8 +43,6 @@ import org.hisp.dhis.organisationunit.OrganisationUnitLevel; import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.patient.Patient; -import org.hisp.dhis.patient.PatientAttribute; -import org.hisp.dhis.patient.PatientIdentifierType; import org.hisp.dhis.patientdatavalue.PatientDataValue; import org.hisp.dhis.patientdatavalue.PatientDataValueService; import org.hisp.dhis.system.grid.ListGrid; @@ -197,31 +195,27 @@ return programStageInstanceStore.get( patient, completed ); } - public Grid getTabularReport( ProgramStage programStage, List hiddenCols, - List identifiers, List fixedAttributes, List attributes, - List dataElements, Map identifierKeys, Map attributeKeys, - Map dataElementKeys, Collection organisationUnits, - int level, Date startDate, Date endDate, boolean descOrder, Integer min, Integer max ) + public Grid getTabularReport( ProgramStage programStage, List searchingKeys, + Collection organisationUnits, int level, Date startDate, Date endDate, boolean descOrder, Integer min, + Integer max ) { int maxLevel = organisationUnitService.getMaxOfOrganisationUnitLevels(); - + Map orgUnitLevelMap = organisationUnitService.getOrganisationUnitLevelMap(); - - return programStageInstanceStore.getTabularReport( programStage, hiddenCols, orgUnitLevelMap, identifiers, fixedAttributes, attributes, - dataElements, identifierKeys, attributeKeys, dataElementKeys, organisationUnits, level, maxLevel, startDate, endDate, descOrder, min, max ); + + return programStageInstanceStore.getTabularReport( programStage, orgUnitLevelMap, organisationUnits, + searchingKeys, level, maxLevel, startDate, endDate, descOrder, min, max ); } - - public int getTabularReportCount( ProgramStage programStage, List identifiers, List fixedAttributes, List attributes, - List dataElements, Map identifierKeys, Map attributeKeys, - Map dataElementKeys, Collection organisationUnits, - int level, Date startDate, Date endDate ) + + public int getTabularReportCount( ProgramStage programStage, List searchingKeys, + Collection organisationUnits, int level, Date startDate, Date endDate ) { int maxLevel = organisationUnitService.getMaxOfOrganisationUnitLevels(); - - return programStageInstanceStore.getTabularReportCount( programStage, identifiers, fixedAttributes, attributes, - dataElements, identifierKeys, attributeKeys, dataElementKeys, organisationUnits, level, maxLevel, startDate, endDate ); + + return programStageInstanceStore.getTabularReportCount( programStage, searchingKeys, organisationUnits, level, + maxLevel, startDate, endDate ); } - + public List getProgramStageInstancesReport( ProgramInstance programInstance, I18nFormat format, I18n i18n ) { List grids = new ArrayList(); === 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 2012-06-07 13:09:16 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java 2012-06-14 13:07:22 +0000 @@ -26,6 +26,12 @@ */ package org.hisp.dhis.program.hibernate; +import static org.hisp.dhis.patientreport.PatientTabularReport.PREFIX_DATA_ELEMENT; +import static org.hisp.dhis.patientreport.PatientTabularReport.PREFIX_FIXED_ATTRIBUTE; +import static org.hisp.dhis.patientreport.PatientTabularReport.PREFIX_IDENTIFIER_TYPE; +import static org.hisp.dhis.patientreport.PatientTabularReport.PREFIX_PATIENT_ATTRIBUTE; +import static org.hisp.dhis.system.util.TextUtils.lower; + import java.util.ArrayList; import java.util.Collection; import java.util.Date; @@ -39,14 +45,14 @@ import org.hibernate.criterion.Restrictions; import org.hisp.dhis.common.Grid; import org.hisp.dhis.common.GridHeader; -import org.hisp.dhis.dataelement.DataElement; +import org.hisp.dhis.dataelement.DataElementService; import org.hisp.dhis.hibernate.HibernateGenericStore; import org.hisp.dhis.jdbc.StatementBuilder; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitLevel; import org.hisp.dhis.patient.Patient; -import org.hisp.dhis.patient.PatientAttribute; -import org.hisp.dhis.patient.PatientIdentifierType; +import org.hisp.dhis.patient.PatientAttributeService; +import org.hisp.dhis.patient.PatientIdentifierTypeService; import org.hisp.dhis.program.ProgramInstance; import org.hisp.dhis.program.ProgramStage; import org.hisp.dhis.program.ProgramStageInstance; @@ -58,8 +64,6 @@ import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.support.rowset.SqlRowSet; -import static org.hisp.dhis.system.util.TextUtils.*; - /** * @author Abyot Asalefew * @version $Id$ @@ -88,6 +92,27 @@ this.statementBuilder = statementBuilder; } + private PatientIdentifierTypeService patientIdentifierTypeService; + + public void setPatientIdentifierTypeService( PatientIdentifierTypeService patientIdentifierTypeService ) + { + this.patientIdentifierTypeService = patientIdentifierTypeService; + } + + private PatientAttributeService patientAttributeService; + + public void setPatientAttributeService( PatientAttributeService patientAttributeService ) + { + this.patientAttributeService = patientAttributeService; + } + + private DataElementService dataElementService; + + public void setDataElementService( DataElementService dataElementService ) + { + this.dataElementService = dataElementService; + } + // ------------------------------------------------------------------------- // Implemented methods // ------------------------------------------------------------------------- @@ -196,17 +221,13 @@ .setFirstResult( min ).setMaxResults( max ).list(); } - public Grid getTabularReport( ProgramStage programStage, List hiddenCols, - Map orgUnitLevelMap, List identifiers, - List fixedAttributes, List attributes, List dataElements, - Map identifierKeys, Map attributeKeys, Map dataElementKeys, - Collection orgUnits, int level, int maxLevel, Date startDate, Date endDate, boolean descOrder, - Integer min, Integer max ) + public Grid getTabularReport( ProgramStage programStage, Map orgUnitLevelMap, + Collection orgUnits, List searchingKeys, int level, int maxLevel, Date startDate, + Date endDate, boolean descOrder, Integer min, Integer max ) { Grid grid = new ListGrid(); grid.addHeader( new GridHeader( "id", true, true ) ); - grid.addHeader( new GridHeader( "Report date", false, true ) ); // TODO hidden cols @@ -215,32 +236,45 @@ { int l = i + 1; String name = orgUnitLevelMap.containsKey( l ) ? orgUnitLevelMap.get( l ).getName() : "Level " + l; + grid.addHeader( new GridHeader( name, false, true ) ); } - for ( PatientIdentifierType type : identifiers ) - { - grid.addHeader( new GridHeader( type.getName(), false, true ) ); - } - - for ( String attribute : fixedAttributes ) - { - grid.addHeader( new GridHeader( attribute, false, true ) ); - } - - for ( PatientAttribute attribute : attributes ) - { - grid.addHeader( new GridHeader( attribute.getName(), false, true ) ); - } - - for ( DataElement element : dataElements ) - { - grid.addHeader( new GridHeader( element.getDisplayName(), false, true ) ); - } - - String sql = getTabularReportSql( false, programStage, identifiers, fixedAttributes, attributes, dataElements, - identifierKeys, attributeKeys, dataElementKeys, orgUnits, level, maxLevel, startDate, endDate, descOrder, - min, max ); + for ( String searchingKey : searchingKeys ) + { + String[] infor = searchingKey.split( "_" ); + String objectType = infor[0]; + + boolean hidden = Boolean.parseBoolean( infor[2] ); + String name = ""; + + if ( objectType.equals( PREFIX_FIXED_ATTRIBUTE ) ) + { + name = infor[1]; + } + else + { + int objectId = Integer.parseInt( infor[1] ); + + if ( objectType.equals( PREFIX_IDENTIFIER_TYPE ) ) + { + name = patientIdentifierTypeService.getPatientIdentifierType( objectId ).getName(); + } + else if ( objectType.equals( PREFIX_PATIENT_ATTRIBUTE ) ) + { + name = patientAttributeService.getPatientAttribute( objectId ).getName(); + } + else if ( objectType.equals( PREFIX_DATA_ELEMENT ) ) + { + name = dataElementService.getDataElement( objectId ).getName(); + } + } + + grid.addHeader( new GridHeader( name, hidden, true ) ); + } + + String sql = getTabularReportSql( false, programStage, searchingKeys, orgUnits, level, maxLevel, startDate, + endDate, descOrder, min, max ); SqlRowSet rowSet = jdbcTemplate.queryForRowSet( sql ); @@ -249,23 +283,18 @@ return grid; } - public int getTabularReportCount( ProgramStage programStage, List identifiers, - List fixedAttributes, List attributes, List dataElements, - Map identifierKeys, Map attributeKeys, Map dataElementKeys, - Collection orgUnits, int level, int maxLevel, Date startDate, Date endDate ) + public int getTabularReportCount( ProgramStage programStage, List searchingKeys, + Collection organisationUnits, int level, int maxLevel, Date startDate, Date endDate ) { - String sql = getTabularReportSql( true, programStage, identifiers, fixedAttributes, attributes, dataElements, - identifierKeys, attributeKeys, dataElementKeys, orgUnits, level, maxLevel, startDate, endDate, false, null, - null ); + String sql = getTabularReportSql( true, programStage, searchingKeys, organisationUnits, level, maxLevel, + startDate, endDate, false, null, null ); return jdbcTemplate.queryForInt( sql ); } - private String getTabularReportSql( boolean count, ProgramStage programStage, - List identifiers, List fixedAttributes, List attributes, - List dataElements, Map identifierKeys, Map attributeKeys, - Map dataElementKeys, Collection orgUnits, int level, int maxLevel, Date startDate, - Date endDate, boolean descOrder, Integer min, Integer max ) + private String getTabularReportSql( boolean count, ProgramStage programStage, List searchingKeys, + Collection orgUnits, int level, int maxLevel, Date startDate, Date endDate, boolean descOrder, + Integer min, Integer max ) { String sDate = DateUtils.getMediumDateString( startDate ); String eDate = DateUtils.getMediumDateString( endDate ); @@ -273,6 +302,8 @@ String selector = count ? "count(*) " : "* "; String sql = "select " + selector + "from ( select psi.programstageinstanceid, psi.executiondate,"; + String where = ""; + String operator = "where "; for ( int i = 0; i < maxLevel; i++ ) { @@ -281,27 +312,57 @@ + ","; } - for ( PatientIdentifierType type : identifiers ) - { - sql += "(select identifier from patientidentifier where patientid=p.patientid and patientidentifiertypeid=" - + type.getId() + ") as identifier_" + type.getId() + ","; - } - - for ( String attribute : fixedAttributes ) - { - sql += "p." + attribute + ","; - } - - for ( PatientAttribute attribute : attributes ) - { - sql += "(select value from patientattributevalue where patientid=p.patientid and patientattributeid=" - + attribute.getId() + ") as attribute_" + attribute.getId() + ","; - } - - for ( DataElement element : dataElements ) - { - sql += "(select value from patientdatavalue where programstageinstanceid=psi.programstageinstanceid and dataelementid=" - + element.getId() + ") as element_" + element.getId() + ","; + for ( String searchingKey : searchingKeys ) + { + String[] infor = searchingKey.split( "_" ); + String objectType = infor[0]; + + if ( objectType.equals( PREFIX_FIXED_ATTRIBUTE ) ) + { + sql += "p." + infor[1] + ","; + } + else + { + int objectId = Integer.parseInt( infor[1] ); + String value = ""; + + if ( objectType.equals( PREFIX_IDENTIFIER_TYPE ) ) + { + sql += "(select identifier from patientidentifier where patientid=p.patientid and patientidentifiertypeid=" + + objectId + ") as identifier_" + objectId + ","; + + if ( infor.length == 4 ) + { + value = lower( infor[3] ); + where += operator + "lower(identifier_" + objectId + ") " + value + " "; + + operator = "and "; + } + } + else if ( objectType.equals( PREFIX_PATIENT_ATTRIBUTE ) ) + { + sql += "(select value from patientattributevalue where patientid=p.patientid and patientattributeid=" + + objectId + ") as attribute_" + objectId + ","; + if ( infor.length == 4 ) + { + value = lower( infor[3] ); + where += operator + "lower(attribute_" + objectId + ") " + value + " "; + operator = "and "; + } + } + else if ( objectType.equals( PREFIX_DATA_ELEMENT ) ) + { + sql += "(select value from patientdatavalue where programstageinstanceid=psi.programstageinstanceid and dataelementid=" + + objectId + ") as element_" + objectId + ","; + + if ( infor.length == 4 ) + { + value = lower( infor[3] ); + where += operator + "lower(element_" + objectId + ") " + value + " "; + operator = "and "; + } + } + } } sql = sql.substring( 0, sql.length() - 1 ) + " "; // Removing last comma @@ -331,32 +392,15 @@ sql += "psi.executiondate "; sql += descOrder ? "desc " : ""; sql += (min != null && max != null) ? statementBuilder.limitRecord( min, max ) : ""; // TODO - // page - // size + // page + // size sql += ") as tabular "; - String operator = "where "; - - for ( Integer key : identifierKeys.keySet() ) - { - sql += operator + "lower(identifier_" + key + ") " + lower( identifierKeys.get( key ) ) + " "; - operator = "and "; - } - - for ( Integer key : attributeKeys.keySet() ) - { - sql += operator + "lower(attribute_" + key + ") " + lower( attributeKeys.get( key ) ) + " "; - operator = "and "; - } - - for ( Integer key : dataElementKeys.keySet() ) - { - sql += operator + "lower(element_" + key + ") " + lower( dataElementKeys.get( key ) ) + " "; - operator = "and "; - } + // filters + sql += where; sql = sql.substring( 0, sql.length() - 1 ) + " "; // Remove last comma - // if exists + // if exists log.info( sql ); === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/relationship/DefaultRelationshipService.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/relationship/DefaultRelationshipService.java 2011-03-31 01:55:06 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/relationship/DefaultRelationshipService.java 2012-06-14 13:07:22 +0000 @@ -98,4 +98,9 @@ { return relationshipStore.get( patientA, patientB, relationshipType ); } + + public Relationship getRelationship( Patient patientA, Patient patientB ) + { + return relationshipStore.get( patientA, patientB ); + } } === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/relationship/hibernate/HibernateRelationshipStore.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/relationship/hibernate/HibernateRelationshipStore.java 2011-03-31 01:55:06 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/relationship/hibernate/HibernateRelationshipStore.java 2012-06-14 13:07:22 +0000 @@ -70,4 +70,11 @@ Restrictions.eq( "patientB", patientB ), Restrictions.eq( "relationshipType", relationshipType ) ) .uniqueResult(); } + + public Relationship get( Patient patientA, Patient patientB ) + { + return (Relationship) getCriteria( Restrictions.eq( "patientA", patientA ), + Restrictions.eq( "patientB", patientB ) ) + .uniqueResult(); + } } === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2012-06-07 13:09:16 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2012-06-14 13:07:22 +0000 @@ -1,26 +1,26 @@ - + - - + class="org.hisp.dhis.caseaggregation.jdbc.JdbcCaseAggregationConditionStore"> + + - - + + - - - - + class="org.hisp.dhis.activityplan.jdbc.JdbcActivityPlanStore"> + + + + @@ -38,7 +38,11 @@ - + + + + - + @@ -66,9 +70,9 @@ - - - + + + - + @@ -90,20 +95,22 @@ - - - - - - - - - + + + + + + + + + - + @@ -112,23 +119,24 @@ - - - - - - - - - - - + + + + + + + + + + + - - + + @@ -142,33 +150,34 @@ - - + + - - + + - + - - - - - - - - - - + class="org.hisp.dhis.caseaggregation.DefaultCaseAggregationConditionService"> + + + + + + + + + + - + - + - + - - + + @@ -210,15 +221,11 @@ - - - - - + + + + + @@ -229,8 +236,8 @@ ref="org.hisp.dhis.patient.PatientIdentifierService" /> - + - - - + + + @@ -277,99 +284,113 @@ - + - - - - - - + ref="org.hisp.dhis.program.ProgramStageDataElementStore" /> + + + + + + - + - + - - - + - - - - + + + - - - + - - - - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - + - - + + - + - + - - - - - - + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + === 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 2012-05-29 15:37:40 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddPatientAction.java 2012-06-14 13:07:22 +0000 @@ -302,7 +302,7 @@ Integer id = patientService.createPatient( patient, representativeId, relationshipTypeId, patientAttributeValues ); - message = id + ""; + message = id + "_" + systemGenerateIdentifier.getIdentifier(); return SUCCESS; } === 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 2012-03-27 01:29:30 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/GetPatientAction.java 2012-06-14 13:07:22 +0000 @@ -48,6 +48,8 @@ import org.hisp.dhis.patientattributevalue.PatientAttributeValueService; import org.hisp.dhis.program.Program; import org.hisp.dhis.program.ProgramService; +import org.hisp.dhis.relationship.Relationship; +import org.hisp.dhis.relationship.RelationshipService; import com.opensymphony.xwork2.Action; @@ -75,7 +77,9 @@ private PatientAttributeGroupService patientAttributeGroupService; private PatientIdentifierTypeService patientIdentifierTypeService; - + + private RelationshipService relationshipService; + // ------------------------------------------------------------------------- // Input/Output // ------------------------------------------------------------------------- @@ -104,7 +108,7 @@ private String systemIdentifier; - private Patient representative; + private Relationship relationship; // ------------------------------------------------------------------------- // Action implementation @@ -128,8 +132,9 @@ identiferMap = new HashMap(); PatientIdentifierType idType = null; - representative = patient.getRepresentative(); - + Patient representative = patient.getRepresentative(); + relationship = relationshipService.getRelationship( representative, patient ); + if ( patient.isUnderAge() && representative != null ) { for ( PatientIdentifier representativeIdentifier : representative.getIdentifiers() ) @@ -198,6 +203,11 @@ this.patientService = patientService; } + public Relationship getRelationship() + { + return relationship; + } + public void setPatientIdentifierService( PatientIdentifierService patientIdentifierService ) { this.patientIdentifierService = patientIdentifierService; @@ -228,9 +238,9 @@ this.patientIdentifierTypeService = patientIdentifierTypeService; } - public Patient getRepresentative() + public void setRelationshipService( RelationshipService relationshipService ) { - return representative; + this.relationshipService = relationshipService; } public void setId( int id ) === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java 2012-06-11 08:24:34 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java 2012-06-14 13:07:22 +0000 @@ -28,10 +28,7 @@ package org.hisp.dhis.caseentry.action.report; import static org.hisp.dhis.patientreport.PatientTabularReport.PREFIX_DATA_ELEMENT; -import static org.hisp.dhis.patientreport.PatientTabularReport.PREFIX_IDENTIFIER_TYPE; -import static org.hisp.dhis.patientreport.PatientTabularReport.PREFIX_META_DATA; import static org.hisp.dhis.patientreport.PatientTabularReport.PREFIX_PATIENT_ATTRIBUTE; -import static org.hisp.dhis.patientreport.PatientTabularReport.PREFIX_FIXED_ATTRIBUTE; import static org.hisp.dhis.patientreport.PatientTabularReport.VALUE_TYPE_OPTION_SET; import java.util.ArrayList; @@ -55,7 +52,6 @@ import org.hisp.dhis.patient.PatientAttributeOption; import org.hisp.dhis.patient.PatientAttributeService; import org.hisp.dhis.patient.PatientIdentifierType; -import org.hisp.dhis.patient.PatientIdentifierTypeService; import org.hisp.dhis.program.ProgramStage; import org.hisp.dhis.program.ProgramStageInstance; import org.hisp.dhis.program.ProgramStageInstanceService; @@ -102,13 +98,6 @@ this.programStageInstanceService = programStageInstanceService; } - private PatientIdentifierTypeService identifierTypeService; - - public void setIdentifierTypeService( PatientIdentifierTypeService identifierTypeService ) - { - this.identifierTypeService = identifierTypeService; - } - private PatientAttributeService patientAttributeService; public void setPatientAttributeService( PatientAttributeService patientAttributeService ) @@ -246,13 +235,6 @@ return valueTypes; } - private List fixedAttributes = new ArrayList(); - - public void setFixedAttributes( List fixedAttributes ) - { - this.fixedAttributes = fixedAttributes; - } - private Map> mapSuggestedValues = new HashMap>(); public Map> getMapSuggestedValues() @@ -260,14 +242,6 @@ return mapSuggestedValues; } - private Map searchingIdenKeys = new HashMap(); - - private Map searchingAttrKeys = new HashMap(); - - private Map searchingDEKeys = new HashMap(); - - private List hiddenCols = new ArrayList(); - // ------------------------------------------------------------------------- // Implementation Action // ------------------------------------------------------------------------- @@ -303,7 +277,7 @@ if ( selectedOrgunit.getParent() == null ) { organisationUnits = null; // Ignore org unit criteria when - // root + // root } else { @@ -321,41 +295,31 @@ // TODO check sql traffic Date startValue = format.parseDate( startDate ); - Date endValue = format.parseDate( endDate ); - - // --------------------------------------------------------------------- - // Get DE searching-keys - // --------------------------------------------------------------------- - getParams(); - + // --------------------------------------------------------------------- // Generate tabular report // --------------------------------------------------------------------- if ( type == null ) // Tabular report { - int totalRecords = programStageInstanceService.getTabularReportCount( programStage, identifierTypes, - fixedAttributes, patientAttributes, dataElements, searchingIdenKeys, searchingAttrKeys, - searchingDEKeys, organisationUnits, level, startValue, endValue ); + int totalRecords = programStageInstanceService.getTabularReportCount( programStage, searchingValues, + organisationUnits, level, startValue, endValue ); total = getNumberOfPages( totalRecords ); this.paging = createPaging( totalRecords ); // total = paging.getTotal(); //TODO - grid = programStageInstanceService.getTabularReport( programStage, hiddenCols, identifierTypes, - fixedAttributes, patientAttributes, dataElements, searchingIdenKeys, searchingAttrKeys, - searchingDEKeys, organisationUnits, level, startValue, endValue, !orderByOrgunitAsc, paging - .getStartPos(), paging.getPageSize() ); + grid = programStageInstanceService.getTabularReport( programStage, searchingValues, organisationUnits, + level, startValue, endValue, !orderByOrgunitAsc, paging.getStartPos(), paging.getPageSize() ); } else // Download as Excel { - grid = programStageInstanceService.getTabularReport( programStage, hiddenCols, identifierTypes, - fixedAttributes, patientAttributes, dataElements, searchingIdenKeys, searchingAttrKeys, - searchingDEKeys, organisationUnits, level, startValue, endValue, !orderByOrgunitAsc, null, null ); + grid = programStageInstanceService.getTabularReport( programStage, searchingValues, organisationUnits, + level, startValue, endValue, !orderByOrgunitAsc, null, null ); } System.out.println(); System.out.println( grid ); @@ -375,76 +339,20 @@ private void getParams() { - // --------------------------------------------------------------------- - // Get Patient-Identifier searching-keys - // --------------------------------------------------------------------- - int index = 0; for ( String searchingValue : searchingValues ) { String[] infor = searchingValue.split( "_" ); String objectType = infor[0]; - if ( objectType.equals( PREFIX_META_DATA ) ) - { - hiddenCols.add( Boolean.parseBoolean( infor[2] ) ); - } - else if ( objectType.equals( PREFIX_FIXED_ATTRIBUTE ) ) - { - fixedAttributes.add( infor[1] ); - hiddenCols.add( Boolean.parseBoolean( infor[2] ) ); - } - else if ( objectType.equals( PREFIX_IDENTIFIER_TYPE ) ) - { - int objectId = Integer.parseInt( infor[1] ); - PatientIdentifierType identifierType = identifierTypeService.getPatientIdentifierType( objectId ); - identifierTypes.add( identifierType ); - - // Get value-type && suggested-values - valueTypes.add( identifierType.getType() ); - hiddenCols.add( Boolean.parseBoolean( infor[2] ) ); - - // Get searching-value - if ( infor.length == 4 ) - { - searchingIdenKeys.put( objectId, infor[3].trim() ); - values.add( infor[3].trim() ); - } - else - { - values.add( "" ); - } - index++; - } - else if ( objectType.equals( PREFIX_PATIENT_ATTRIBUTE ) ) + if ( objectType.equals( PREFIX_PATIENT_ATTRIBUTE ) ) { int objectId = Integer.parseInt( infor[1] ); PatientAttribute attribute = patientAttributeService.getPatientAttribute( objectId ); patientAttributes.add( attribute ); - - // Get value-type && suggested-values + valueTypes.add( attribute.getValueType() ); mapSuggestedValues.put( index, getSuggestedAttributeValues( attribute ) ); - hiddenCols.add( Boolean.parseBoolean( infor[2] ) ); - - // Get searching-value - if ( infor.length == 4 ) - { - searchingAttrKeys.put( objectId, infor[3].trim() ); - String value = infor[3].trim(); - // if ( attribute.getValueType().equals( - // PatientAttribute.TYPE_BOOL ) ) - // { - // value = (value.indexOf( i18n.getString( "yes" ) ) != -1) - // ? "true" : "false"; - // } - values.add( value ); - } - else - { - values.add( "" ); - } - index++; } else if ( objectType.equals( PREFIX_DATA_ELEMENT ) ) { @@ -456,31 +364,8 @@ String valueType = (dataElement.getOptionSet() != null) ? VALUE_TYPE_OPTION_SET : dataElement.getType(); valueTypes.add( valueType ); mapSuggestedValues.put( index, getSuggestedDataElementValues( dataElement ) ); - hiddenCols.add( Boolean.parseBoolean( infor[2] ) ); - - if ( infor.length == 4 ) - { - String value = infor[3].trim(); - // if ( dataElement.getType().equals( - // DataElement.VALUE_TYPE_BOOL ) ) - // { - // int startIndx = value.indexOf( '\'' ) + 1; - // int endIndx = value.lastIndexOf( '\'' ); - // String key = value.substring( startIndx, endIndx ); - // - // value = (key.equals(i18n.getString( "yes" ))) ? - // value.replace( key, "true" ) : value.replace( key, - // "false" ); - // } - searchingDEKeys.put( objectId, value ); - values.add( value ); - } - else - { - values.add( "" ); - } - index++; } + index++; } } === 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 2012-06-13 08:22:35 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2012-06-14 13:07:22 +0000 @@ -88,8 +88,7 @@ scope="prototype"> - + @@ -424,9 +423,10 @@ - - - + + - + - + @@ -808,19 +808,23 @@ - + - + - - - - @@ -829,13 +833,13 @@ - + - + @@ -847,17 +851,15 @@ class="org.hisp.dhis.caseentry.action.report.GenerateTabularReportAction" scope="prototype"> - - + - + - - - + - - - + - - - + - - $metaData && $mapSuggestedValues.get($mapIndx).size() > 0 ) + "xtype": #if( $mapSuggestedValues.get($mapIndx) && $index > $metaData && $mapSuggestedValues.get($mapIndx).size() > 0 ) "combobox" #else "textfield"