=== modified file 'local/in/dhis-web-reports-national/pom.xml' --- local/in/dhis-web-reports-national/pom.xml 2012-03-30 08:17:05 +0000 +++ local/in/dhis-web-reports-national/pom.xml 2012-04-04 11:58:27 +0000 @@ -19,6 +19,10 @@ + + javax.servlet + servlet-api + @@ -64,10 +68,10 @@ org.hisp.dhis dhis-service-datamart-default - + org.hisp.dhis dhis-service-aggregationengine-default @@ -82,19 +86,23 @@ org.hisp.dhis dhis-support-external - + org.hisp.dhis dhis-in-service-survey ${project.version} - + + + org.hisp.dhis + dhis-web-api @@ -180,4 +188,7 @@ + + ../../ + === added file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/action/GetIndicatorsAction.java' --- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/action/GetIndicatorsAction.java 1970-01-01 00:00:00 +0000 +++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/action/GetIndicatorsAction.java 2012-04-04 11:58:27 +0000 @@ -0,0 +1,77 @@ +package org.hisp.dhis.reports.action; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator; +import org.hisp.dhis.indicator.Indicator; +import org.hisp.dhis.indicator.IndicatorGroup; +import org.hisp.dhis.indicator.IndicatorService; + +import com.opensymphony.xwork2.Action; + +public class GetIndicatorsAction implements Action +{ + + private final static int ALL = 0; + + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private IndicatorService indicatorService; + + public void setIndicatorService( IndicatorService indicatorService ) + { + this.indicatorService = indicatorService; + } + + // ------------------------------------------------------------------------- + // Input & output + // ------------------------------------------------------------------------- + + private Integer id; + + public void setId( Integer id ) + { + this.id = id; + } + + private List indicators; + + public List getIndicators() + { + return indicators; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute()throws Exception + { + + if ( id == null || id == 0 ) + { + indicators = new ArrayList( indicatorService.getAllIndicators() ); + } + else + { + IndicatorGroup indicatorGroup = indicatorService.getIndicatorGroup( id ); + + if ( indicatorGroup != null ) + { + indicators = new ArrayList( indicatorGroup.getMembers() ); + } + else + { + indicators = new ArrayList(); + } + } + Collections.sort( indicators, new IdentifiableObjectNameComparator() ); + return SUCCESS; + + } + +} === modified file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/activeplan/action/ActivePlanReportsResultAction.java' --- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/activeplan/action/ActivePlanReportsResultAction.java 2011-12-26 10:07:59 +0000 +++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/activeplan/action/ActivePlanReportsResultAction.java 2012-04-04 11:58:27 +0000 @@ -1125,8 +1125,8 @@ { DataElement d1e = dataElementService.getDataElement( Integer.parseInt( deCodeString ) ); - PatientDataValue patientDataValue1 = patientDataValueService.getPatientDataValue( - programStageInstance, d1e, selectedOrgUnit ); + //PatientDataValue patientDataValue1 = patientDataValueService.getPatientDataValue( programStageInstance, d1e, selectedOrgUnit ); + PatientDataValue patientDataValue1 = patientDataValueService.getPatientDataValue( programStageInstance, d1e ); if ( patientDataValue1 == null ) { tempStr = " "; @@ -1282,9 +1282,8 @@ { if ( !deCollectedNames.contains( dename ) ) { - PatientDataValue patientDataValue1 = patientDataValueService - .getPatientDataValue( programStageInstanceName, d1e, - selectedOrgUnit ); + //PatientDataValue patientDataValue1 = patientDataValueService.getPatientDataValue( programStageInstanceName, d1e, selectedOrgUnit ); + PatientDataValue patientDataValue1 = patientDataValueService.getPatientDataValue( programStageInstanceName, d1e ); if ( patientDataValue1 != null ) { valuePresent = true; @@ -1319,9 +1318,8 @@ { if ( !deCollectedNames.contains( dename ) ) { - PatientDataValue patientDataValue1 = patientDataValueService - .getPatientDataValue( programStageInstanceName, d1e, - selectedOrgUnit ); + //PatientDataValue patientDataValue1 = patientDataValueService.getPatientDataValue( programStageInstanceName, d1e,selectedOrgUnit ); + PatientDataValue patientDataValue1 = patientDataValueService.getPatientDataValue( programStageInstanceName, d1e ); if ( patientDataValue1 != null ) { valuePresent = true; @@ -1369,8 +1367,8 @@ // +deCollectedNames ); if ( !deCollectedNames.contains( dename ) ) { - PatientDataValue patientDataValue1 = patientDataValueService - .getPatientDataValue( programStageInstanceName, d1e, selectedOrgUnit ); + //PatientDataValue patientDataValue1 = patientDataValueService.getPatientDataValue( programStageInstanceName, d1e, selectedOrgUnit ); + PatientDataValue patientDataValue1 = patientDataValueService.getPatientDataValue( programStageInstanceName, d1e ); if ( patientDataValue1 != null ) { valuePresent = true; === added file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/benificiaryinfo/action/GetPatientDetailsAction.java' --- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/benificiaryinfo/action/GetPatientDetailsAction.java 1970-01-01 00:00:00 +0000 +++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/benificiaryinfo/action/GetPatientDetailsAction.java 2012-04-04 11:58:27 +0000 @@ -0,0 +1,254 @@ +package org.hisp.dhis.reports.benificiaryinfo.action; + +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.hisp.dhis.patient.Patient; +import org.hisp.dhis.patient.PatientAttribute; +import org.hisp.dhis.patient.PatientAttributeGroup; +import org.hisp.dhis.patient.PatientIdentifier; +import org.hisp.dhis.patient.PatientIdentifierType; +import org.hisp.dhis.patient.PatientService; +import org.hisp.dhis.patientattributevalue.PatientAttributeValue; +import org.hisp.dhis.patientattributevalue.PatientAttributeValueService; + +import com.opensymphony.xwork2.Action; + +public class GetPatientDetailsAction +implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private PatientService patientService; + + public void setPatientService( PatientService patientService ) + { + this.patientService = patientService; + } + + private PatientAttributeValueService patientAttributeValueService; + + public void setPatientAttributeValueService( PatientAttributeValueService patientAttributeValueService ) + { + this.patientAttributeValueService = patientAttributeValueService; + } + + +/* + private PatientIdentifierService patientIdentifierService; + + public void setPatientIdentifierService( PatientIdentifierService patientIdentifierService ) + { + this.patientIdentifierService = patientIdentifierService; + } + + private ProgramService programService; + + public void setProgramService( ProgramService programService ) + { + this.programService = programService; + } + + + + private PatientAttributeService patientAttributeService; + + public void setPatientAttributeService( PatientAttributeService patientAttributeService ) + { + this.patientAttributeService = patientAttributeService; + } + + private PatientAttributeGroupService patientAttributeGroupService; + + public void setPatientAttributeGroupService( PatientAttributeGroupService patientAttributeGroupService ) + { + this.patientAttributeGroupService = patientAttributeGroupService; + } + + private PatientIdentifierTypeService patientIdentifierTypeService; + + public void setPatientIdentifierTypeService( PatientIdentifierTypeService patientIdentifierTypeService ) + { + this.patientIdentifierTypeService = patientIdentifierTypeService; + } +*/ + + // ------------------------------------------------------------------------- + // Input/Output and its Getter / Setter + // ------------------------------------------------------------------------- + + private int id; + + public void setId( int id ) + { + this.id = id; + } + + private Patient patient; + + public Patient getPatient() + { + return patient; + } +/* + private Patient representative; + + public Patient getRepresentative() + { + return representative; + } +*/ + private PatientIdentifier patientIdentifier; + + public PatientIdentifier getPatientIdentifier() + { + return patientIdentifier; + } + /* + private Collection programs; + + public Collection getPrograms() + { + return programs; + } + */ + private Map patientAttributeValueMap = new HashMap(); + + public Map getPatientAttributeValueMap() + { + return patientAttributeValueMap; + } + + private Collection noGroupAttributes; + + public Collection getNoGroupAttributes() + { + return noGroupAttributes; + } + + private List attributeGroups; + + public List getAttributeGroups() + { + return attributeGroups; + } + + private Collection identifierTypes; + + public Collection getIdentifierTypes() + { + return identifierTypes; + } +/* + private Map identiferMap; + + public Map getIdentiferMap() + { + return identiferMap; + } + + private String childContactName; + + public String getChildContactName() + { + return childContactName; + } + + private String childContactType; + + public String getChildContactType() + { + return childContactType; + } + */ + private String systemIdentifier; + + public String getSystemIdentifier() + { + return systemIdentifier; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + patient = patientService.getPatient( id ); + + // patientIdentifier = patientIdentifierService.getPatientIdentifier( patient ); + + // = patientIdentifierTypeService.getAllPatientIdentifierTypes(); + + /* + identiferMap = new HashMap(); + + PatientIdentifierType idType = null; + representative = patient.getRepresentative(); + + if ( patient.isUnderAge() && representative != null ) + { + for ( PatientIdentifier representativeIdentifier : representative.getIdentifiers() ) + { + if ( representativeIdentifier.getIdentifierType() != null + && representativeIdentifier.getIdentifierType().isRelated() ) + { + //identiferMap.put( representativeIdentifier.getIdentifierType().getId(), representativeIdentifier.getIdentifier() ); + } + } + } + + for ( PatientIdentifier identifier : patient.getIdentifiers() ) + { + idType = identifier.getIdentifierType(); + + if ( idType != null ) + { + //identiferMap.put( identifier.getIdentifierType().getId(), identifier.getIdentifier() ); + } + else + { + systemIdentifier = identifier.getIdentifier(); + } + } + */ + for ( PatientAttribute patientAttribute : patient.getAttributes() ) + { + patientAttributeValueMap.put( patientAttribute.getId(), PatientAttributeValue.UNKNOWN ); + } + + Collection patientAttributeValues = patientAttributeValueService.getPatientAttributeValues( patient ); + + for ( PatientAttributeValue patientAttributeValue : patientAttributeValues ) + { + if ( PatientAttribute.TYPE_COMBO.equalsIgnoreCase( patientAttributeValue.getPatientAttribute() + .getValueType() ) ) + { + patientAttributeValueMap.put( patientAttributeValue.getPatientAttribute().getId(), + patientAttributeValue.getPatientAttributeOption().getName() ); + } + else + { + patientAttributeValueMap.put( patientAttributeValue.getPatientAttribute().getId(), + patientAttributeValue.getValue() ); + } + } + /* + programs = programService.getAllPrograms(); + + noGroupAttributes = patientAttributeService.getPatientAttributesNotGroup(); + + attributeGroups = new ArrayList( patientAttributeGroupService.getAllPatientAttributeGroups() ); + Collections.sort( attributeGroups, new PatientAttributeGroupSortOrderComparator() ); + */ + return SUCCESS; + + } + +} + === added file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/benificiaryinfo/action/GetPatientReportResultAction.java' --- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/benificiaryinfo/action/GetPatientReportResultAction.java 1970-01-01 00:00:00 +0000 +++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/benificiaryinfo/action/GetPatientReportResultAction.java 2012-04-04 11:58:27 +0000 @@ -0,0 +1,838 @@ +package org.hisp.dhis.reports.benificiaryinfo.action; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +import jxl.Workbook; +import jxl.format.Alignment; +import jxl.format.Border; +import jxl.format.BorderLineStyle; +import jxl.format.VerticalAlignment; +import jxl.write.Blank; +import jxl.write.Label; +import jxl.write.Number; +import jxl.write.WritableCellFormat; +import jxl.write.WritableSheet; +import jxl.write.WritableWorkbook; + +import org.hisp.dhis.config.Configuration_IN; +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.PatientIdentifier; +import org.hisp.dhis.patient.PatientIdentifierService; +import org.hisp.dhis.patient.PatientService; +import org.hisp.dhis.patientattributevalue.PatientAttributeValue; +import org.hisp.dhis.patientattributevalue.PatientAttributeValueService; +import org.hisp.dhis.program.Program; +import org.hisp.dhis.program.ProgramService; +import org.hisp.dhis.reports.ReportService; +import org.hisp.dhis.reports.Report_inDesign; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.support.rowset.SqlRowSet; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; + +import com.opensymphony.xwork2.Action; + +public class GetPatientReportResultAction implements Action +{ + + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ReportService reportService; + + public void setReportService( ReportService reportService ) + { + this.reportService = reportService; + } + + private PatientService patientService; + + public void setPatientService( PatientService patientService ) + { + this.patientService = patientService; + } + + private ProgramService programService; + + public void setProgramService( ProgramService programService ) + { + this.programService = programService; + } + + private PatientIdentifierService patientIdentifierService; + + public void setPatientIdentifierService( PatientIdentifierService patientIdentifierService ) + { + this.patientIdentifierService = patientIdentifierService; + } + /* + private PatientAttributeService patientAttributeService; + + public void setPatientAttributeService( PatientAttributeService patientAttributeService ) + { + this.patientAttributeService = patientAttributeService; + } + */ + private PatientAttributeValueService patientAttributeValueService; + + public void setPatientAttributeValueService( PatientAttributeValueService patientAttributeValueService ) + { + this.patientAttributeValueService = patientAttributeValueService; + } + + private JdbcTemplate jdbcTemplate; + + public void setJdbcTemplate( JdbcTemplate jdbcTemplate ) + { + this.jdbcTemplate = jdbcTemplate; + } + + private I18nFormat format; + + public void setFormat( I18nFormat format ) + { + this.format = format; + } + + // ------------------------------------------------------------------------- + // Input/Output and its Getter / Setter + // ------------------------------------------------------------------------- + + + private int patientId; + + public void setPatientId( int patientId ) + { + this.patientId = patientId; + } + + private int selProgramId; + + public void setSelProgramId( int selProgramId ) + { + this.selProgramId = selProgramId; + } + + private String excelTemplateName; + + public void setExcelTemplateName( String excelTemplateName ) + { + this.excelTemplateName = excelTemplateName; + } + + private String xmlTemplateName; + + public void setXmlTemplateName( String xmlTemplateName ) + { + this.xmlTemplateName = xmlTemplateName; + } + + private String inputTemplatePath; + private String outputReportPath; + private String raFolderName; + + + private String fileName; + + public String getFileName() + { + return fileName; + } + + private InputStream inputStream; + + public InputStream getInputStream() + { + return inputStream; + } + + + private List serviceType; + private List deCodeType; + private List sheetList; + private List rowList; + private List colList; + private List progList; + + private Patient patient; + private Program program; + + private Map patientAttributeValueMap = new HashMap(); + + public Map getPatientAttributeValueMap() + { + return patientAttributeValueMap; + } + + private Map programStageDataElementValueMap = new HashMap(); + + public Map getProgramStageDataElementValueMap() + { + return programStageDataElementValueMap; + } + + + private Date executionDate; + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + + + public String execute() throws Exception + { + + System.out.println( "Report Generation Start Time is : \t" + new Date() ); + + raFolderName = reportService.getRAFolderName(); + + + //System.out.println( "PatientId= " + patientId + "----SelProgramId= " + selProgramId ); + // System.out.println( "-----excelTemplateName=" + excelTemplateName + "-----xmlTemplateName=" + xmlTemplateName ); + patient = patientService.getPatient( patientId ); + //OrganisationUnit orgunit = patient.getOrganisationUnit(); + + program = programService.getProgram( selProgramId ); + + String reportFileNameTB = excelTemplateName; + // String deCodesXMLFileName = xmlTemplateName; + + inputTemplatePath = System.getenv( "DHIS2_HOME" ) + File.separator + raFolderName + File.separator + "template" + File.separator + reportFileNameTB; + outputReportPath = System.getenv( "DHIS2_HOME" ) + File.separator + Configuration_IN.DEFAULT_TEMPFOLDER; + File newdir = new File( outputReportPath ); + if( !newdir.exists() ) + { + newdir.mkdirs(); + } + outputReportPath += File.separator + UUID.randomUUID().toString() + ".xls"; + /* + select identifier from patientidentifier where patientid = 122748 and patientidentifiertypeid = 1; + + + select patientdatavalue.programstageinstanceid,programstageinstance.programstageid, + dataelementid,organisationunitid,value from patientdatavalue + inner join programstageinstance on patientdatavalue.programstageinstanceid = programstageinstance.programstageinstanceid + inner join programinstance on programstageinstance.programinstanceid = programinstance.programinstanceid + where programinstance.patientid = 122748; + + select patientdatavalue.programstageinstanceid,programstageinstance.programstageid,programinstance.enrollmentdate,programinstance.programinstanceid, + dataelementid,organisationunitid,value from patientdatavalue + inner join programstageinstance on patientdatavalue.programstageinstanceid = programstageinstance.programstageinstanceid + inner join programinstance on programstageinstance.programinstanceid = programinstance.programinstanceid + where programinstance.patientid = 6417; + + select patientdatavalue.programstageinstanceid,programstageinstance.programstageid,programinstance.enrollmentdate,programinstance.programinstanceid, + dataelementid,organisationunitid,value from patientdatavalue + inner join programstageinstance on patientdatavalue.programstageinstanceid = programstageinstance.programstageinstanceid + inner join programinstance on programstageinstance.programinstanceid = programinstance.programinstanceid + where programinstance.patientid = 6417 and organisationunitid = 13692; + + + + final query + + select patientdatavalue.programstageinstanceid,programstageinstance.programstageid, + dataelementid,organisationunitid,programstageinstance.executiondate,value from patientdatavalue + inner join programstageinstance on patientdatavalue.programstageinstanceid = programstageinstance.programstageinstanceid + inner join programinstance on programstageinstance.programinstanceid = programinstance.programinstanceid + where programinstance.patientid = 6417; + + query for ACS Report + + SELECT patient.patientid, patient.firstname, patient.gender, patient.birthdate, programstageinstanceid, executiondate,patient.middlename,patient.lastname,patient.registrationdate FROM programstageinstance + INNER JOIN programinstance ON programinstance.programinstanceid = programstageinstance.programinstanceid + INNER JOIN patient on programinstance.patientid = patient.patientid + WHERE programinstance.programid IN (1) + AND executiondate >= '2012-03-30' + AND executiondate <= '2012-03-30' + AND patient.organisationunitid = 1 ORDER BY executiondate ; + + + * + * + */ + + String query = "SELECT patientdatavalue.programstageinstanceid,programstageinstance.programstageid,dataelementid,value,programstageinstance.executiondate from patientdatavalue " + + " INNER JOIN programstageinstance on patientdatavalue.programstageinstanceid = programstageinstance.programstageinstanceid " + + " INNER JOIN programinstance on programstageinstance.programinstanceid = programinstance.programinstanceid " + + " WHERE programinstance.patientid = " + patient.getId() + " ORDER BY executiondate" ; + + + + SqlRowSet sqlResultSet = jdbcTemplate.queryForRowSet( query ); + + if ( sqlResultSet != null ) + { + sqlResultSet.beforeFirst(); + while ( sqlResultSet.next() ) + { + String programStageDataElement = ""; + + int programStageInstanceId = sqlResultSet.getInt( 1 ); + int programStageId = sqlResultSet.getInt( 2 ); + int dataElementId = sqlResultSet.getInt( 3 ); + String deValue = sqlResultSet.getString( 4 ); + executionDate = sqlResultSet.getDate( 5 ); + + programStageDataElement = programStageId + ":" + dataElementId; + + programStageDataElementValueMap.put( programStageDataElement, deValue ); + + } + } + + for ( PatientAttribute patientAttribute : patient.getAttributes() ) + { + patientAttributeValueMap.put( patientAttribute.getId(), PatientAttributeValue.UNKNOWN ); + } + + Collection patientAttributeValues = patientAttributeValueService.getPatientAttributeValues( patient ); + + for ( PatientAttributeValue patientAttributeValue : patientAttributeValues ) + { + if ( PatientAttribute.TYPE_COMBO.equalsIgnoreCase( patientAttributeValue.getPatientAttribute() + .getValueType() ) ) + { + patientAttributeValueMap.put( patientAttributeValue.getPatientAttribute().getId(), + patientAttributeValue.getPatientAttributeOption().getName() ); + } + else + { + patientAttributeValueMap.put( patientAttributeValue.getPatientAttribute().getId(), + patientAttributeValue.getValue() ); + } + } + + + generateReport(); + + //System.out.println( "PatientId=" + patientId + "----SelProgramId= " + selProgramId ); + //System.out.println( "-----excelTemplateName=" + excelTemplateName + "-----xmlTemplateName=" + xmlTemplateName ); + System.out.println( "Report Generation End Time is : \t" + new Date() ); + + return SUCCESS; + } + + public void generateReport() throws Exception + { + Workbook templateWorkbook = Workbook.getWorkbook( new File( inputTemplatePath ) ); + WritableWorkbook outputReportWorkbook = Workbook.createWorkbook( new File( outputReportPath ), templateWorkbook ); + + // Cell formatting + WritableCellFormat wCellformat = new WritableCellFormat(); + wCellformat.setBorder( Border.ALL, BorderLineStyle.THIN ); + wCellformat.setAlignment( Alignment.CENTRE ); + wCellformat.setVerticalAlignment( VerticalAlignment.CENTRE ); + wCellformat.setWrap( true ); + + WritableCellFormat deWCellformat = new WritableCellFormat(); + deWCellformat.setBorder( Border.ALL, BorderLineStyle.THIN ); + deWCellformat.setAlignment( Alignment.CENTRE ); + deWCellformat.setVerticalAlignment( VerticalAlignment.JUSTIFY ); + deWCellformat.setWrap( true ); + + // SimpleDateFormat simpleDateFormat = new SimpleDateFormat( "yyyy-MM-dd" ); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat( "dd-MM-yyyy" ); + + String deCodesXMLFileName = xmlTemplateName; + + List reportDesignList = reportService.getReportDesign( deCodesXMLFileName ); + + + // List deCodesList = getDECodes( deCodesXMLFileName ); + /* + String query = "SELECT patient.patientid, patient.firstname, patient.gender, patient.birthdate, programstageinstanceid, executiondate FROM programstageinstance " + + " INNER JOIN programinstance ON programinstance.programinstanceid = programstageinstance.programinstanceid " + + " INNER JOIN patient on programinstance.patientid = patient.patientid " + + " WHERE programinstance.programid IN ("+ reportLevelTB +") " + + " AND executiondate >= '"+startDate+"'" + + " AND executiondate <= '"+endDate+"' "+ + " AND patient.organisationunitid = "+ ouIDTB +" ORDER BY executiondate" ; + + + SqlRowSet sqlResultSet1 = jdbcTemplate.queryForRowSet( query ); + if ( sqlResultSet1 != null ) + { + */ + int rowNo = 1; + // sqlResultSet1.beforeFirst(); + /* + while ( sqlResultSet1.next() ) + { + int patientId = sqlResultSet1.getInt( 1 ); + String patientName = sqlResultSet1.getString( 2 ); + String patinetGender = sqlResultSet1.getString( 3 ); + Date patientBirthDate = sqlResultSet1.getDate( 4 ); + int programStageInstanceId = sqlResultSet1.getInt( 5 ); + Date executionDate = sqlResultSet1.getDate( 6 ); + + Patient patient = patientService.getPatient( patientId ); + + ProgramStageInstance prgStageInstance = programStageInstanceService.getProgramStageInstance( programStageInstanceId ); + + */ + List patientIdentifiers = new ArrayList( patientIdentifierService.getPatientIdentifiers( patient ) ); + int count1 = 0; + Iterator reportDesignIterator = reportDesignList.iterator(); + while( reportDesignIterator.hasNext() ) + { + Report_inDesign report_inDesign = (Report_inDesign) reportDesignIterator.next(); + + String deType = report_inDesign.getPtype(); + String sType = report_inDesign.getStype(); + String deCodeString = report_inDesign.getExpression(); + String tempStr = ""; + + //int tempColNo = colList.get( count1 ); + // int sheetNo = sheetList.get( count1 ); + // String tempStr = ""; + // String sType = serviceType.get( count1 ); + // int tempRowNo = rowList.get( count1 ); + + if( sType.equalsIgnoreCase("slno") ) + { + tempStr = "" + rowNo; + } + else if( deCodeString.equalsIgnoreCase("GENDER") ) + { + tempStr = patient.getGender(); + } + else if( deCodeString.equalsIgnoreCase("AGE") ) + { + if( patient.getDobType() == 'V' || patient.getDobType() == 'D') + { + tempStr = simpleDateFormat.format(patient.getBirthDate()); + } + else + { + tempStr = patient.getAge(); + + } + } + + /* + else if( deCodeString.equalsIgnoreCase("DOB") ) + { + tempStr = simpleDateFormat.format(patient.getBirthDate()); + } + */ + + else if( deCodeString.equalsIgnoreCase("ADMISSION") ) + { + //tempStr = program.getDateOfEnrollmentDescription(); + tempStr = simpleDateFormat.format( executionDate ); + } + + + else if( deCodeString.equalsIgnoreCase("FACILITY") ) + { + tempStr = patient.getOrganisationUnit().getName(); + } + + else if( deCodeString.equalsIgnoreCase("PATIENTNAME") ) + { + tempStr = patient.getFullName(); + } + + + + else if( sType.equalsIgnoreCase("identifier") ) + { + //System.out.println( "Inside pipart0" ); + tempStr = " "; + for( PatientIdentifier patientIdentifier : patientIdentifiers ) + { + //System.out.println( patientIdentifier.getId() + " : " + deCode ); + if( patientIdentifier.getIdentifierType() != null && patientIdentifier.getIdentifierType().getId() == Integer.parseInt(deCodeString) ) + { + try + { + tempStr = patientIdentifier.getIdentifier(); + } + catch( Exception e ) + { + } + break; + } + } + } + else if( sType.equalsIgnoreCase("attributes") ) + { + tempStr = " "; + for( PatientAttribute patientAttribute : patient.getAttributes() ) + { + if( patientAttribute.getId() == Integer.parseInt(deCodeString) ) + { + try + { + tempStr = patientAttributeValueMap.get( patientAttribute.getId() ); + } + catch( Exception e ) + { + } + break; + } + } + } + /* + else if( sType.equalsIgnoreCase("PI-PART6") ) + { + tempStr = " "; + for( PatientAttribute patientAttribute : patient.getAttributes() ) + { + if( patientIdentifier.getIdentifierType() != null && patientIdentifier.getIdentifierType().getId() == Integer.parseInt(deCode) ) + { + try + { + tempStr = patientIdentifier.getIdentifier().split("-")[6]; + } + catch( Exception e ) + { + } + break; + } + } + } + else if( sType.equalsIgnoreCase("dataelement") ) + { + DataElement de = dataElementService.getDataElement( Integer.parseInt( deCode ) ); + PatientDataValue patientDV = patientDataValueService.getPatientDataValue( prgStageInstance, de, selectedOrgUnit ); + if( patientDV != null && patientDV.getValue() != null ) + { + tempStr = patientDV.getValue(); + } + } + else if( sType.equalsIgnoreCase("dataelement-dd") ) + { + DataElement de = dataElementService.getDataElement( Integer.parseInt( deCode ) ); + PatientDataValue patientDV = patientDataValueService.getPatientDataValue( prgStageInstance, de, selectedOrgUnit ); + if( patientDV != null && patientDV.getValue() != null ) + { + Integer optionComboId = Integer.parseInt( patientDV.getValue() ); + DataElementCategoryOptionCombo deCOC = dataElementCategoryOptionComboService.getDataElementCategoryOptionCombo( optionComboId ); + tempStr = deCOC.getName(); + } + } + */ + else if( sType.equalsIgnoreCase("dataelement") ) + { + tempStr = " "; + tempStr = programStageDataElementValueMap.get( deCodeString ); + } + + else if( sType.equalsIgnoreCase("dataelementdate") ) + { + tempStr = programStageDataElementValueMap.get( deCodeString ); + + if ( tempStr != null ) + { + Date tempDate = format.parseDate( tempStr ); + Calendar tempSDate = Calendar.getInstance(); + tempSDate.setTime( tempDate ); + + tempStr = simpleDateFormat.format( tempSDate.getTime() ); + } + else + { + tempStr = " "; + } + + } + else if( sType.equalsIgnoreCase("after7thday") ) + { + tempStr = programStageDataElementValueMap.get( deCodeString ); + + if ( tempStr != null ) + { + Date tempDate = format.parseDate( tempStr ); + Calendar tempSDate = Calendar.getInstance(); + tempSDate.setTime( tempDate ); + tempSDate.add(Calendar.DATE, 7); + //tempStr = "" + tempSDate.get(Calendar.YEAR) + "-" + ( tempSDate.get(Calendar.MONTH) + 1) + "-" +tempSDate.get(Calendar.DATE); + tempStr = simpleDateFormat.format( tempSDate.getTime() ); + + } + else + { + tempStr = " "; + } + + } + + else if( sType.equalsIgnoreCase("after15thday") ) + { + tempStr = programStageDataElementValueMap.get( deCodeString ); + + if ( tempStr != null ) + { + Date tempDate = format.parseDate( tempStr ); + Calendar tempSDate = Calendar.getInstance(); + tempSDate.setTime( tempDate ); + tempSDate.add(Calendar.DATE, 15); + //tempStr = "" + tempSDate.get(Calendar.YEAR) + "-" + ( tempSDate.get(Calendar.MONTH) + 1) + "-" +tempSDate.get(Calendar.DATE); + + tempStr = simpleDateFormat.format( tempSDate.getTime() ); + + } + else + { + tempStr = " "; + } + + } + + else if( sType.equalsIgnoreCase("1stmonth") ) + { + tempStr = programStageDataElementValueMap.get( deCodeString ); + + if ( tempStr != null ) + { + Date tempDate = format.parseDate( tempStr ); + Calendar tempSDate = Calendar.getInstance(); + tempSDate.setTime( tempDate ); + tempSDate.add(Calendar.MONTH, 1); + //tempStr = "" + tempSDate.get(Calendar.YEAR) + "-" + ( tempSDate.get(Calendar.MONTH) + 1) + "-" +tempSDate.get(Calendar.DATE); + tempStr = simpleDateFormat.format( tempSDate.getTime() ); + + } + else + { + tempStr = " "; + } + + } + + else if( sType.equalsIgnoreCase("after45thday") ) + { + tempStr = programStageDataElementValueMap.get( deCodeString ); + + if ( tempStr != null ) + { + Date tempDate = format.parseDate( tempStr ); + Calendar tempSDate = Calendar.getInstance(); + tempSDate.setTime( tempDate ); + tempSDate.add(Calendar.DATE, 45); + //tempStr = "" + tempSDate.get(Calendar.YEAR) + "-" + ( tempSDate.get(Calendar.MONTH) + 1) + "-" +tempSDate.get(Calendar.DATE); + tempStr = simpleDateFormat.format( tempSDate.getTime() ); + + } + else + { + tempStr = " "; + } + } + + else if( sType.equalsIgnoreCase("2ndmonth") ) + { + tempStr = programStageDataElementValueMap.get( deCodeString ); + + if ( tempStr != null ) + { + Date tempDate = format.parseDate( tempStr ); + Calendar tempSDate = Calendar.getInstance(); + tempSDate.setTime( tempDate ); + tempSDate.add(Calendar.MONTH, 2); + // tempStr = "" + tempSDate.get(Calendar.DATE); + // tempStr = "" + tempSDate.get(Calendar.YEAR) + "-" + ( tempSDate.get(Calendar.MONTH) + 1) + "-" +tempSDate.get(Calendar.DATE); + tempStr = simpleDateFormat.format( tempSDate.getTime() ); + + } + else + { + tempStr = " "; + } + } + + else if( sType.equalsIgnoreCase("3rdmonth") ) + { + tempStr = programStageDataElementValueMap.get( deCodeString ); + + if ( tempStr != null ) + { + Date tempDate = format.parseDate( tempStr ); + Calendar tempSDate = Calendar.getInstance(); + tempSDate.setTime( tempDate ); + tempSDate.add(Calendar.MONTH, 3); + // tempStr = "" + tempSDate.get(Calendar.DATE); + //tempStr = "" + tempSDate.get(Calendar.YEAR) + "-" + ( tempSDate.get(Calendar.MONTH) + 1) + "-" +tempSDate.get(Calendar.DATE); + tempStr = simpleDateFormat.format( tempSDate.getTime() ); + + } + else + { + tempStr = " "; + } + } + + else if( sType.equalsIgnoreCase("6thmonth") ) + { + tempStr = programStageDataElementValueMap.get( deCodeString ); + + if ( tempStr != null ) + { + Date tempDate = format.parseDate( tempStr ); + Calendar tempSDate = Calendar.getInstance(); + tempSDate.setTime( tempDate ); + tempSDate.add(Calendar.MONTH, 6); + // tempStr = "" + tempSDate.get(Calendar.DATE); + //tempStr = "" + tempSDate.get(Calendar.YEAR) + "-" + ( tempSDate.get(Calendar.MONTH) + 1) + "-" +tempSDate.get(Calendar.DATE); + tempStr = simpleDateFormat.format( tempSDate.getTime() ); + + } + else + { + tempStr = " "; + } + } + else if( sType.equalsIgnoreCase("1year") ) + { + tempStr = programStageDataElementValueMap.get( deCodeString ); + + if ( tempStr != null ) + { + Date tempDate = format.parseDate( tempStr ); + Calendar tempSDate = Calendar.getInstance(); + tempSDate.setTime( tempDate ); + tempSDate.add(Calendar.YEAR, 1); + // tempStr = "" + tempSDate.get(Calendar.DATE); + //tempStr = "" + tempSDate.get(Calendar.YEAR) + "-" +tempSDate.get(Calendar.MONTH) + "-" +tempSDate.get(Calendar.DATE); + + tempStr = simpleDateFormat.format( tempSDate.getTime() ); + + } + else + { + tempStr = " "; + } + } + + //System.out.println( sType + " : " + tempStr ); + + //System.out.println( sType + " : " + deCodeString + " : " + tempStr ); + + int tempRowNo = report_inDesign.getRowno(); + int tempColNo = report_inDesign.getColno(); + int sheetNo = report_inDesign.getSheetno(); + WritableSheet sheet0 = outputReportWorkbook.getSheet( sheetNo ); + if ( tempStr == null || tempStr.equals( " " ) ) + { + + + sheet0.addCell( new Blank( tempColNo, tempRowNo, wCellformat ) ); + } + else + { + + if ( deCodeString.equalsIgnoreCase( "FACILITYP" ) || deCodeString.equalsIgnoreCase( "FACILITYPP" ) || deCodeString.equalsIgnoreCase( "FACILITYPPP" ) || deCodeString.equalsIgnoreCase( "FACILITYPPPP" ) ) + { + + } + + else + { + // System.out.println( sType + " : " + deCode + " : " + tempStr ); + try + { + sheet0.addCell( new Number( tempColNo, tempRowNo, Double.parseDouble( tempStr ), wCellformat ) ); + } + catch( Exception e ) + { + sheet0.addCell( new Label( tempColNo, tempRowNo, tempStr, wCellformat ) ); + } + } + + } + + count1++; + } + + rowNo++; + //} + //} + + outputReportWorkbook.write(); + outputReportWorkbook.close(); + fileName = excelTemplateName; + File outputReportFile = new File( outputReportPath ); + inputStream = new BufferedInputStream( new FileInputStream( outputReportFile ) ); + outputReportFile.deleteOnExit(); + + } + +/* + public List getDECodes( String fileName ) + { + List deCodes = new ArrayList(); + String path = System.getenv( "DHIS2_HOME" ) + File.separator + raFolderName + File.separator + fileName; + + try + { + DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); + Document doc = docBuilder.parse( new File( path ) ); + if ( doc == null ) + { + return null; + } + + NodeList listOfDECodes = doc.getElementsByTagName( "de-code" ); + int totalDEcodes = listOfDECodes.getLength(); + + for ( int s = 0; s < totalDEcodes; s++ ) + { + Element deCodeElement = ( Element ) listOfDECodes.item( s ); + NodeList textDECodeList = deCodeElement.getChildNodes(); + deCodes.add( ( ( Node ) textDECodeList.item( 0 ) ).getNodeValue().trim() ); + serviceType.add( deCodeElement.getAttribute( "stype" ) ); + deCodeType.add( deCodeElement.getAttribute( "type" ) ); + sheetList.add( new Integer( deCodeElement.getAttribute( "sheetno" ) ) ); + rowList.add( new Integer( deCodeElement.getAttribute( "rowno" ) ) ); + colList.add( new Integer( deCodeElement.getAttribute( "colno" ) ) ); + progList.add( new Integer( deCodeElement.getAttribute( "progno" ) ) ); + }// end of for loop with s var + + }// try block end + catch ( SAXParseException err ) + { + } + catch ( SAXException e ) + { + Exception x = e.getException(); + ( ( x == null ) ? e : x ).printStackTrace(); + } + catch ( Throwable t ) + { + t.printStackTrace(); + } + + return deCodes; + } + +*/ + + +} === added file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/benificiaryinfo/action/GetRegistredPatientInformationAction.java' --- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/benificiaryinfo/action/GetRegistredPatientInformationAction.java 1970-01-01 00:00:00 +0000 +++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/benificiaryinfo/action/GetRegistredPatientInformationAction.java 2012-04-04 11:58:27 +0000 @@ -0,0 +1,467 @@ +package org.hisp.dhis.reports.benificiaryinfo.action; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.OrganisationUnitService; +import org.hisp.dhis.paging.ActionPagingSupport; +import org.hisp.dhis.patient.Patient; +import org.hisp.dhis.patient.PatientAttribute; +import org.hisp.dhis.patient.PatientAttributeService; +import org.hisp.dhis.patient.PatientService; +import org.hisp.dhis.patientattributevalue.PatientAttributeValue; +import org.hisp.dhis.patientattributevalue.PatientAttributeValueService; +import org.hisp.dhis.reports.ReportService; +import org.hisp.dhis.reports.util.ProgramDetail; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; + +public class GetRegistredPatientInformationAction extends ActionPagingSupport +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + + private PatientAttributeValueService patientAttributeValueService; + + public void setPatientAttributeValueService( PatientAttributeValueService patientAttributeValueService ) + { + this.patientAttributeValueService = patientAttributeValueService; + } + + + private PatientAttributeService patientAttributeService; + + public void setPatientAttributeService( PatientAttributeService patientAttributeService ) + { + this.patientAttributeService = patientAttributeService; + } + + private ReportService reportService; + + public void setReportService( ReportService reportService ) + { + this.reportService = reportService; + } + + private OrganisationUnitService organisationUnitService; + + public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) + { + this.organisationUnitService = organisationUnitService; + } + + private PatientService patientService; + + public void setPatientService( PatientService patientService ) + { + this.patientService = patientService; + } + + // ------------------------------------------------------------------------- + // Input + // ------------------------------------------------------------------------- + + private List searchText = new ArrayList(); + + public void setSearchText( List searchText ) + { + this.searchText = searchText; + } + + private Boolean listAll; + + public void setListAll( Boolean listAll ) + { + this.listAll = listAll; + } + + public Boolean getListAll() + { + return listAll; + } + + private List searchingAttributeId = new ArrayList(); + + public void setSearchingAttributeId( List searchingAttributeId ) + { + this.searchingAttributeId = searchingAttributeId; + } + /* + private List programs; + + public List getPrograms() + { + return programs; + } + */ + // ------------------------------------------------------------------------- + // Output + // ------------------------------------------------------------------------- + + + + private Integer total; + + public Integer getTotal() + { + return total; + } + + private Map mapPatientPatientAttr = new HashMap(); + + public Map getMapPatientPatientAttr() + { + return mapPatientPatientAttr; + } + + private Collection patients = new ArrayList(); + + public Collection getPatients() + { + return patients; + } + /* + private Map> mapPatientPrograms = new HashMap>(); + + public Map> getMapPatientPrograms() + { + return mapPatientPrograms; + } + */ + + + // ------------------------------------------------------------------------- + // Getters/Setters + // ------------------------------------------------------------------------- + + + private List patientAttributes = new ArrayList(); + + public List getPatientAttributes() + { + return patientAttributes; + } + + private Map mapPatientOrgunit = new HashMap(); + + public Map getMapPatientOrgunit() + { + return mapPatientOrgunit; + } + + private String raFolderName; + + + private List programList; + + public List getProgramList() + { + return programList; + } + + private int ouIDTB; + + public void setOuIDTB( int ouIDTB ) + { + this.ouIDTB = ouIDTB; + } + + private Boolean isSelectedOrg; + + public void setIsSelectedOrg( Boolean isSelectedOrg ) + { + this.isSelectedOrg = isSelectedOrg; + } + + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + //OrganisationUnit organisationUnit = selectedStateManager.getSelectedOrganisationUnit(); + OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( ouIDTB ); + // --------------------------------------------------------------------- + // Get all of patients into the selected organisation unit + // --------------------------------------------------------------------- + /* + if ( listAll != null && listAll ) + { + listAllPatient( organisationUnit ); + + return SUCCESS; + } + */ + // --------------------------------------------------------------------- + // Search patients by attributes + // --------------------------------------------------------------------- + + //System.out.println( "searchingAttributeId= " + searchingAttributeId + "---,searchText= " + searchText ); + + //System.out.println( "OrganisationUnit= " + ouIDTB + "---,is Selected Org checked = " + isSelectedOrg ); + + raFolderName = reportService.getRAFolderName(); + + programList = new ArrayList(); + + for ( Integer attributeId : searchingAttributeId ) + { + if ( attributeId != null && attributeId != 0 ) + { + patientAttributes.add( patientAttributeService.getPatientAttribute( attributeId ) ); + } + } + + + if( isSelectedOrg ) + { + searchPatientByNameAndOrgUnit( searchText , organisationUnit ); + } + else + { + searchPatientByAttributes( searchingAttributeId, searchText ); + } + + + getProgramDetailList(); + + return SUCCESS; + + } + + // ------------------------------------------------------------------------- + // Supporting methods + // ------------------------------------------------------------------------- +/* + private void listAllPatient( OrganisationUnit organisationUnit ) + { + total = patientService.countGetPatientsByOrgUnit( organisationUnit ); + this.paging = createPaging( total ); + + patients = new ArrayList( patientService.getPatients( organisationUnit, paging.getStartPos(), paging + .getPageSize() ) ); + } +*/ + + private void searchPatientByNameAndOrgUnit( List searchText , OrganisationUnit organisationUnit ) + { + + total = patientService.countGetPatientsByOrgUnit( organisationUnit ); + this.paging = createPaging( total ); + + //Collection tempPatients = new ArrayList(); + for( String text : searchText ) + { + //tPatients( OrganisationUnit organisationUnit, String searchText, int min, int max ) + + List tempPatients = new ArrayList( patientService.getPatients( organisationUnit, text, paging.getStartPos(), paging.getPageSize() )); + patients.addAll( tempPatients ); + } + + total = patients.size(); + this.paging = createPaging( total ); + + + Collection attributeValues = patientAttributeValueService.getPatientAttributeValues( patients ); + + for ( Patient patient : patients ) + { + //programs.addAll( patient.getPrograms() ); + + mapPatientOrgunit.put( patient.getId(), getHierarchyOrgunit( patient.getOrganisationUnit() ) ); + + for ( PatientAttributeValue attributeValue : attributeValues ) + { + mapPatientPatientAttr.put( patient.getId() + "-" + attributeValue.getPatientAttribute().getId(), + attributeValue.getValue() ); + } + + //mapPatientPrograms.put( patient.getId(), getProgramsByPatient( patient ) ); + } + + } + + + private void searchPatientByAttributes( List searchingAttributeId, List searchText ) + { + total = patientAttributeValueService.countSearchPatients( searchingAttributeId, searchText ); + this.paging = createPaging( total ); + + patients = patientAttributeValueService.searchPatients( searchingAttributeId, searchText, paging.getStartPos(), + paging.getPageSize() ); + + /* + if ( isSelectedOrg ) + { + Iterator patientIterator = patients.iterator(); + while ( patientIterator.hasNext() ) + { + Patient patient = patientIterator.next(); + + OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( ouIDTB ); + + if ( patient.getOrganisationUnit().getId() != orgUnit.getId() ) + { + patientIterator.remove(); + } + } + total = patients.size(); + this.paging = createPaging( total ); + } + */ + + Collection attributeValues = patientAttributeValueService.getPatientAttributeValues( patients ); + + for ( Patient patient : patients ) + { + //programs.addAll( patient.getPrograms() ); + + mapPatientOrgunit.put( patient.getId(), getHierarchyOrgunit( patient.getOrganisationUnit() ) ); + + for ( PatientAttributeValue attributeValue : attributeValues ) + { + mapPatientPatientAttr.put( patient.getId() + "-" + attributeValue.getPatientAttribute().getId(), + attributeValue.getValue() ); + } + + //mapPatientPrograms.put( patient.getId(), getProgramsByPatient( patient ) ); + } + } + + private String getHierarchyOrgunit( OrganisationUnit orgunit ) + { + String hierarchyOrgunit = orgunit.getName(); + + while ( orgunit.getParent() != null ) + { + hierarchyOrgunit = orgunit.getParent().getName() + " / " + hierarchyOrgunit; + + orgunit = orgunit.getParent(); + } + + return hierarchyOrgunit; + } +/* + private List getProgramsByPatient( Patient patient ) + { + + List tempPrograms = new ArrayList( patient.getPrograms()); + List programsList = new ArrayList(); + + if( tempPrograms != null && tempPrograms.size() != 0 ) + { + for( Program program : tempPrograms ) + { + programsList.add( program ); + } + + } + + return programsList; + } +*/ + + public void getProgramDetailList() + { + String fileName = "NBITSProgramList.xml"; + String path = System.getProperty( "user.home" ) + File.separator + "dhis" + File.separator + raFolderName + File.separator + fileName; + try + { + String newpath = System.getenv( "DHIS2_HOME" ); + if ( newpath != null ) + { + path = newpath + File.separator + raFolderName + File.separator + fileName; + } + } + catch ( NullPointerException npe ) + { + // do nothing, but we might be using this somewhere without + // DHIS2_HOME set, which will throw a NPE + } + + String programId = ""; + String programName = ""; + String excelTemplateName = ""; + String xmlTemplateName = ""; + + try + { + DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); + Document doc = docBuilder.parse( new File( path ) ); + if ( doc == null ) + { + System.out.println( "XML File Not Found at user home" ); + return; + } + + NodeList listOfReports = doc.getElementsByTagName( "program" ); + int totalReports = listOfReports.getLength(); + for ( int s = 0; s < totalReports; s++ ) + { + Node reportNode = listOfReports.item( s ); + if ( reportNode.getNodeType() == Node.ELEMENT_NODE ) + { + Element programElement = (Element) reportNode; + programId = programElement.getAttribute( "id" ); + + NodeList programNameList = programElement.getElementsByTagName( "name" ); + Element programNameElement = (Element) programNameList.item( 0 ); + NodeList textProgramNameList = programNameElement.getChildNodes(); + programName = ((Node) textProgramNameList.item( 0 )).getNodeValue().trim(); + + + NodeList programExcelNameList = programElement.getElementsByTagName( "excelTemplateName" ); + Element programExcelElement = (Element) programExcelNameList.item( 0 ); + NodeList textProgramExcelNameList = programExcelElement.getChildNodes(); + excelTemplateName = ((Node) textProgramExcelNameList.item( 0 )).getNodeValue().trim(); + + NodeList programXMLNameList = programElement.getElementsByTagName( "xmlTemplateName" ); + Element programXMLElement = (Element) programXMLNameList.item( 0 ); + NodeList textProgramXMLNameList = programXMLElement.getChildNodes(); + xmlTemplateName = ((Node) textProgramXMLNameList.item( 0 )).getNodeValue().trim(); + + + ProgramDetail programObj = new ProgramDetail(programId, programName, excelTemplateName, xmlTemplateName); + programList.add( programObj ); + + } + }// end of for loop with s var + }// try block end + catch ( SAXParseException err ) + { + System.out.println( "** Parsing error" + ", line " + err.getLineNumber() + ", uri " + err.getSystemId() ); + System.out.println( " " + err.getMessage() ); + } + catch ( SAXException e ) + { + Exception x = e.getException(); + ((x == null) ? e : x).printStackTrace(); + } + catch ( Throwable t ) + { + t.printStackTrace(); + } + + }// getReportList end + + + +} === added file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/benificiaryinfo/action/PatientInfoReportsFormAction.java' --- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/benificiaryinfo/action/PatientInfoReportsFormAction.java 1970-01-01 00:00:00 +0000 +++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/benificiaryinfo/action/PatientInfoReportsFormAction.java 2012-04-04 11:58:27 +0000 @@ -0,0 +1,61 @@ +package org.hisp.dhis.reports.benificiaryinfo.action; + +import java.util.Collection; + +import org.hisp.dhis.patient.PatientAttribute; +import org.hisp.dhis.patient.PatientAttributeService; + +import com.opensymphony.xwork2.Action; + +public class PatientInfoReportsFormAction implements Action +{ + + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private PatientAttributeService patientAttributeService; + + public void setPatientAttributeService( PatientAttributeService patientAttributeService ) + { + this.patientAttributeService = patientAttributeService; + } + + // ------------------------------------------------------------------------- + // Input/output + // ------------------------------------------------------------------------- + + private Collection patientAttributes; + + public Collection getPatientAttributes() + { + return patientAttributes; + } + + + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() throws Exception + { + + patientAttributes = patientAttributeService.getAllPatientAttributes(); + /* + programs = programService.getAllPrograms(); + + organisationUnit = selectionManager.getSelectedOrganisationUnit(); + + if ( organisationUnit == null ) + { + status = 1; + } + else if ( !organisationUnit.isHasPatients() ) + { + status = 2; + } + */ + return SUCCESS; + } +} === added file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/ed/action/RankingReportResultAction.java' --- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/ed/action/RankingReportResultAction.java 1970-01-01 00:00:00 +0000 +++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/ed/action/RankingReportResultAction.java 2012-04-04 11:58:27 +0000 @@ -0,0 +1,542 @@ +package org.hisp.dhis.reports.ed.action; + +import static org.hisp.dhis.system.util.ConversionUtils.getIdentifiers; +import static org.hisp.dhis.system.util.TextUtils.getCommaDelimitedString; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import jxl.Workbook; +import jxl.format.Alignment; +import jxl.format.Border; +import jxl.format.BorderLineStyle; +import jxl.format.Colour; +import jxl.format.VerticalAlignment; +import jxl.write.Formula; +import jxl.write.Label; +import jxl.write.Number; +import jxl.write.WritableCellFormat; +import jxl.write.WritableSheet; +import jxl.write.WritableWorkbook; + +import org.amplecode.quick.StatementManager; +import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator; +import org.hisp.dhis.config.Configuration_IN; +import org.hisp.dhis.indicator.Indicator; +import org.hisp.dhis.indicator.IndicatorService; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.OrganisationUnitService; +import org.hisp.dhis.period.Period; +import org.hisp.dhis.period.PeriodService; +import org.hisp.dhis.reports.ReportService; +import org.hisp.dhis.user.CurrentUserService; + +import com.opensymphony.xwork2.Action; + +public class RankingReportResultAction implements Action +{ + private final String GENERATEAGGDATA = "generateaggdata"; + + private final String USEEXISTINGAGGDATA = "useexistingaggdata"; + + private final String USECAPTUREDDATA = "usecaptureddata"; + + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + private StatementManager statementManager; + + public void setStatementManager( StatementManager statementManager ) + { + this.statementManager = statementManager; + } + + private PeriodService periodService; + + public void setPeriodService( PeriodService periodService ) + { + this.periodService = periodService; + } + + private IndicatorService indicatorService; + + public void setIndicatorService( IndicatorService indicatorService ) + { + this.indicatorService = indicatorService; + } + + private ReportService reportService; + + public void setReportService( ReportService reportService ) + { + this.reportService = reportService; + } + + private CurrentUserService currentUserService; + + public void setCurrentUserService( CurrentUserService currentUserService ) + { + this.currentUserService = currentUserService; + } + + private OrganisationUnitService organisationUnitService; + + public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) + { + this.organisationUnitService = organisationUnitService; + } + + // ------------------------------------------------------------------------- + // Getter & Setter + // ------------------------------------------------------------------------- + private InputStream inputStream; + + public InputStream getInputStream() + { + return inputStream; + } + + private String fileName; + + public String getFileName() + { + return fileName; + } + + private Integer selectedStartPeriodId; + + public void setSelectedStartPeriodId( Integer selectedStartPeriodId ) + { + this.selectedStartPeriodId = selectedStartPeriodId; + } + + private Integer selectedEndPeriodId; + + public void setSelectedEndPeriodId( Integer selectedEndPeriodId ) + { + this.selectedEndPeriodId = selectedEndPeriodId; + } +/* + private Integer indicatorGroupId; + + public void setIndicatorGroupId( Integer indicatorGroupId ) + { + this.indicatorGroupId = indicatorGroupId; + } +*/ + private String aggData; + + public void setAggData( String aggData ) + { + this.aggData = aggData; + } + + private List orgUnitList; + + private List selectedIndicators; + + public void setSelectedIndicators( List selectedIndicators ) + { + this.selectedIndicators = selectedIndicators; + } + + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + statementManager.initialise(); + + String[] excelColumns = + { "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z", + "AA","AB","AC","AD","AE","AF","AG","AH","AI","AJ","AK","AL","AM","AN","AO","AP","AQ","AR","AS","AT","AU","AV","AW","AX","AY","AZ", + "BA","BB","BC","BD","BE","BF","BG","BH","BI","BJ","BK","BL","BM","BN","BO","BP","BQ","BR","BS","BT","BU","BV","BW","BX","BY","BZ" + }; + + orgUnitList = new ArrayList(); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat( "MMM-yy" ); + + //System.out.println( "selected Indicators size : " + selectedIndicators.size() ); + + System.out.println( "Report Generation Start Time is : \t" + new Date() ); + + String outputReportPath = System.getenv( "DHIS2_HOME" ) + File.separator + Configuration_IN.DEFAULT_TEMPFOLDER; + File newdir = new File( outputReportPath ); + if( !newdir.exists() ) + { + newdir.mkdirs(); + } + outputReportPath += File.separator + UUID.randomUUID().toString() + ".xls"; + + WritableWorkbook outputReportWorkbook = Workbook.createWorkbook( new File( outputReportPath ) ); + WritableSheet sheet0 = outputReportWorkbook.createSheet( "RankingReport", 0 ); + + // Period Info + Period selectedStartPeriod = periodService.getPeriod( selectedStartPeriodId ); + Period selectedEndPeriod = periodService.getPeriod( selectedEndPeriodId ); + + if ( selectedStartPeriod == null || selectedEndPeriod == null ) + { + System.out.println( "There is no period with that id" ); + sheet0.addCell( new Label( 2, 2, "There is no period with that id", getCellFormat2() ) ); + outputReportWorkbook.write(); + outputReportWorkbook.close(); + + fileName = "RankingReport.xls"; + File outputReportFile = new File( outputReportPath ); + inputStream = new BufferedInputStream( new FileInputStream( outputReportFile ) ); + + outputReportFile.deleteOnExit(); + statementManager.destroy(); + return SUCCESS; + } + + List periodList = new ArrayList( periodService.getIntersectingPeriods( selectedStartPeriod.getStartDate(), selectedEndPeriod.getEndDate() ) ); + Collection periodIds = new ArrayList( getIdentifiers(Period.class, periodList ) ); + String periodIdsByComma = getCommaDelimitedString( periodIds ); + + + List curUserRootOrgUnitList = new ArrayList( currentUserService.getCurrentUser().getOrganisationUnits() ); + String orgUnitName = ""; + + if ( curUserRootOrgUnitList != null && curUserRootOrgUnitList.size() > 0 ) + { + for ( OrganisationUnit orgUnit : curUserRootOrgUnitList ) + { + orgUnitName += orgUnit.getName() + ", "; + List childList = new ArrayList( orgUnit.getChildren() ); + Collections.sort( childList, new IdentifiableObjectNameComparator() ); + orgUnitList.addAll( childList ); + orgUnitList.add( orgUnit ); + } + } + + if ( curUserRootOrgUnitList == null || curUserRootOrgUnitList.size() == 0 ) + { + System.out.println( "There is no orgunit with that User" ); + sheet0.addCell( new Label( 2, 2, "There is no orgunit with that User", getCellFormat2() ) ); + outputReportWorkbook.write(); + outputReportWorkbook.close(); + + fileName = "RankingReport.xls"; + File outputReportFile = new File( outputReportPath ); + inputStream = new BufferedInputStream( new FileInputStream( outputReportFile ) ); + + outputReportFile.deleteOnExit(); + statementManager.destroy(); + + return SUCCESS; + } + + //IndicatorGroup selectedIndicatorGroup = indicatorService.getIndicatorGroup( indicatorGroupId ); + + //if ( selectedIndicatorGroup == null ) + if ( selectedIndicators == null || selectedIndicators.size() == 0 ) + { + System.out.println( "There is no IndicatorGroup with that id" ); + sheet0.addCell( new Label( 2, 2, "There is no IndicatorGroup with that id", getCellFormat2() ) ); + outputReportWorkbook.write(); + outputReportWorkbook.close(); + + fileName = "IndicatorReport.xls"; + File outputReportFile = new File( outputReportPath ); + inputStream = new BufferedInputStream( new FileInputStream( outputReportFile ) ); + + outputReportFile.deleteOnExit(); + + statementManager.destroy(); + return SUCCESS; + } + + //List indicators = new ArrayList( selectedIndicatorGroup.getMembers() ); + + List indicatorList = new ArrayList(); + Iterator deIterator = selectedIndicators.iterator(); + while ( deIterator.hasNext() ) + { + // String indicatorId = (String) deIterator.next(); + int serviceID = Integer.parseInt( (String) deIterator.next() ); + Indicator indicator = indicatorService.getIndicator( serviceID ); + + indicatorList.add( indicator ); + + } + + //String dataElmentIdsByComma = getDataelementIds( indicators ); + String dataElmentIdsByComma = getDataelementIds( indicatorList ); + //String dataElmentIdsByComma = getDataelementIds( indicators ); + + int rowCount = 4; + int colCount = 0; + + // Printing Header Info + sheet0.mergeCells( colCount, rowCount, colCount, rowCount + 1 ); + sheet0.addCell( new Label( colCount++, rowCount, "Sl. No.", getCellFormat1() ) ); + sheet0.mergeCells( colCount, rowCount, colCount, rowCount + 1 ); + sheet0.addCell( new Label( colCount++, rowCount, "Facility", getCellFormat1() ) ); + + //for ( Indicator indicator : indicators ) + for ( Indicator indicator : indicatorList ) + { + sheet0.mergeCells( colCount, rowCount, colCount + 1, rowCount ); + sheet0.addCell( new Label( colCount, rowCount, indicator.getName(), getCellFormat1() ) ); + //sheet0.addCell( new Label( colCount++, rowCount + 1, "Numerator", getCellFormat1() ) ); + //sheet0.addCell( new Label( colCount++, rowCount + 1, "Denominator", getCellFormat1() ) ); + sheet0.addCell( new Label( colCount++, rowCount + 1, "Indicator Value", getCellFormat1() ) ); + sheet0.addCell( new Label( colCount++, rowCount + 1, "Rank", getCellFormat1() ) ); + } + + // Printing Main Header Info + //String mainHeaderInfo = "Indicator Group Name - " + selectedIndicatorGroup.getName() + " ,OrgUnit Name is "+ orgUnitName + " From : " + String mainHeaderInfo = "OrgUnit Name is "+ orgUnitName + " From : " + simpleDateFormat.format( selectedStartPeriod.getStartDate() ) + " To : " + + simpleDateFormat.format( selectedEndPeriod.getStartDate() ); + sheet0.mergeCells( 0, 1, colCount - 1, 1 ); + sheet0.addCell( new Label( 0, 1, mainHeaderInfo, getCellFormat1() ) ); + + rowCount += 2; + int slno = 1; + int rowStart = rowCount+1; + for ( OrganisationUnit ou : orgUnitList ) + { + colCount = 0; + Map aggDeMap = new HashMap(); + if( aggData.equalsIgnoreCase( USEEXISTINGAGGDATA ) ) + { + aggDeMap.putAll( reportService.getResultDataValueFromAggregateTable( ou.getId(), dataElmentIdsByComma, periodIdsByComma ) ); + } + else if( aggData.equalsIgnoreCase( GENERATEAGGDATA ) ) + { + List childOrgUnitTree = new ArrayList( organisationUnitService.getOrganisationUnitWithChildren( ou.getId() ) ); + List childOrgUnitTreeIds = new ArrayList( getIdentifiers( OrganisationUnit.class, childOrgUnitTree ) ); + String childOrgUnitsByComma = getCommaDelimitedString( childOrgUnitTreeIds ); + + aggDeMap.putAll( reportService.getAggDataFromDataValueTable( childOrgUnitsByComma, dataElmentIdsByComma, periodIdsByComma ) ); + } + else if( aggData.equalsIgnoreCase( USECAPTUREDDATA ) ) + { + aggDeMap.putAll( reportService.getAggDataFromDataValueTable( ""+ou.getId(), dataElmentIdsByComma, periodIdsByComma ) ); + } + + if ( slno != orgUnitList.size() ) + { + sheet0.addCell( new Number( colCount++, rowCount, slno, getCellFormat2() ) ); + sheet0.addCell( new Label( colCount++, rowCount, ou.getName(), getCellFormat2() ) ); + } + else + { + sheet0.addCell( new Label( colCount++, rowCount, "", getCellFormat1() ) ); + sheet0.addCell( new Label( colCount++, rowCount, ou.getName(), getCellFormat1() ) ); + } + + //for ( Indicator indicator : indicators ) + for ( Indicator indicator : indicatorList ) + { + Double numValue = 0.0; + Double denValue = 0.0; + Double indValue = 0.0; + + try + { + numValue = Double.parseDouble( reportService.getAggVal( indicator.getNumerator(), aggDeMap ) ); + } + catch( Exception e ) + { + numValue = 0.0; + } + + try + { + denValue = Double.parseDouble( reportService.getAggVal( indicator.getDenominator(), aggDeMap ) ); + } + catch( Exception e ) + { + denValue = 0.0; + } + + try + { + if( denValue != 0.0 ) + { + indValue = ( numValue / denValue ) * indicator.getIndicatorType().getFactor(); + } + else + { + indValue = 0.0; + } + } + catch( Exception e ) + { + indValue = 0.0; + } + + if ( indValue == null ) + indValue = 0.0; + if ( numValue == null ) + numValue = 0.0; + if ( denValue == null ) + denValue = 0.0; + + numValue = Math.round( numValue * Math.pow( 10, 1 ) ) / Math.pow( 10, 1 ); + denValue = Math.round( denValue * Math.pow( 10, 1 ) ) / Math.pow( 10, 1 ); + indValue = Math.round( indValue * Math.pow( 10, 1 ) ) / Math.pow( 10, 1 ); + + //sheet0.addCell( new Number( colCount++, rowCount, numValue, getCellFormat2() ) ); + //sheet0.addCell( new Number( colCount++, rowCount, denValue, getCellFormat2() ) ); + + + if( slno != orgUnitList.size() ) + { + sheet0.addCell( new Number( colCount++, rowCount, indValue, getCellFormat2() ) ); + String rankFormula = "RANK("+ excelColumns[colCount-1] +""+(rowCount+1)+","+excelColumns[colCount-1]+""+rowStart+""+":"+excelColumns[colCount-1]+""+(rowStart+orgUnitList.size()-2)+",0)"; + System.out.println( rankFormula ); + sheet0.addCell( new Formula( colCount++, rowCount, rankFormula, getCellFormat1()) ); + } + else + { + //sheet0.mergeCells( 0, rowCount, colCount - 1, rowCount ); + //sheet0.addCell( new Label( 0, rowCount++, "", getCellFormat1() ) ); + + sheet0.addCell( new Number( colCount++, rowCount, indValue, getCellFormat1() ) ); + sheet0.addCell( new Label( colCount++, rowCount, " ", getCellFormat1()) ); + } + } + + slno++; + rowCount++; + } + + // Printing Indicator Formula Info + rowCount++; + colCount = 2; + + sheet0.mergeCells( colCount, rowCount, colCount + 2, rowCount ); + sheet0.addCell( new Label( colCount, rowCount, "Indicator Name", getCellFormat1() ) ); + colCount += 3; + sheet0.mergeCells( colCount, rowCount, colCount + 2, rowCount ); + sheet0.addCell( new Label( colCount, rowCount, "Numerator Desciption", getCellFormat1() ) ); + colCount += 3; + sheet0.mergeCells( colCount, rowCount, colCount + 2, rowCount ); + sheet0.addCell( new Label( colCount, rowCount, "Denominator Description", getCellFormat1() ) ); + + rowCount++; + + //for ( Indicator indicator : indicators ) + for ( Indicator indicator : indicatorList ) + { + colCount = 2; + + sheet0.mergeCells( colCount, rowCount, colCount + 2, rowCount ); + sheet0.addCell( new Label( colCount, rowCount, indicator.getName(), getCellFormat2() ) ); + colCount += 3; + sheet0.mergeCells( colCount, rowCount, colCount + 2, rowCount ); + sheet0.addCell( new Label( colCount, rowCount, indicator.getNumeratorDescription(), getCellFormat2() ) ); + colCount += 3; + sheet0.mergeCells( colCount, rowCount, colCount + 2, rowCount ); + sheet0.addCell( new Label( colCount, rowCount, indicator.getDenominatorDescription(), getCellFormat2() ) ); + + rowCount++; + } + + outputReportWorkbook.write(); + outputReportWorkbook.close(); + + + fileName = "RankingReport_" + orgUnitName + "_" + simpleDateFormat.format( selectedStartPeriod.getStartDate() ) + "_" + simpleDateFormat.format( selectedEndPeriod.getStartDate() ) + ".xls"; + fileName = fileName.replaceAll( " ", "" ); + fileName = fileName.replaceAll( ",", "_" ); + + File outputReportFile = new File( outputReportPath ); + + System.out.println( fileName ); + + inputStream = new BufferedInputStream( new FileInputStream( outputReportFile ) ); + + outputReportFile.deleteOnExit(); + + statementManager.destroy(); + System.out.println( "Report Generation End Time is : \t" + new Date() ); + return SUCCESS; + } + + + public WritableCellFormat getCellFormat1() + throws Exception + { + WritableCellFormat wCellformat = new WritableCellFormat(); + + wCellformat.setBorder( Border.ALL, BorderLineStyle.THIN ); + wCellformat.setAlignment( Alignment.CENTRE ); + wCellformat.setVerticalAlignment( VerticalAlignment.CENTRE ); + wCellformat.setBackground( Colour.GRAY_25 ); + wCellformat.setWrap( true ); + + return wCellformat; + } + + public WritableCellFormat getCellFormat2() + throws Exception + { + WritableCellFormat wCellformat = new WritableCellFormat(); + + wCellformat.setBorder( Border.ALL, BorderLineStyle.THIN ); + wCellformat.setAlignment( Alignment.CENTRE ); + wCellformat.setVerticalAlignment( VerticalAlignment.CENTRE ); + wCellformat.setWrap( true ); + + return wCellformat; + } + + public String getDataelementIds( List indicatorList ) + { + String dataElmentIdsByComma = "-1"; + for( Indicator indicator : indicatorList ) + { + String formula = indicator.getNumerator() + " + " + indicator.getDenominator(); + try + { + Pattern pattern = Pattern.compile( "(\\[\\d+\\.\\d+\\])" ); + + Matcher matcher = pattern.matcher( formula ); + StringBuffer buffer = new StringBuffer(); + + while ( matcher.find() ) + { + String replaceString = matcher.group(); + + replaceString = replaceString.replaceAll( "[\\[\\]]", "" ); + replaceString = replaceString.substring( 0, replaceString.indexOf( '.' ) ); + + int dataElementId = Integer.parseInt( replaceString ); + dataElmentIdsByComma += "," + dataElementId; + replaceString = ""; + matcher.appendReplacement( buffer, replaceString ); + } + } + catch( Exception e ) + { + + } + } + + return dataElmentIdsByComma; + } + + +} === modified file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/portal/action/PortalReportsResultAction.java' --- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/portal/action/PortalReportsResultAction.java 2012-02-02 09:56:51 +0000 +++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/portal/action/PortalReportsResultAction.java 2012-04-04 11:58:27 +0000 @@ -765,7 +765,8 @@ if ( pStageInstance.getExecutionDate() != null ) { if ( includePeriod.equalsIgnoreCase( "periodincluding" ) ) { if ( pStageInstance.getExecutionDate().before( eDate ) ) { - PatientDataValue patientDataValue1 = patientDataValueService.getPatientDataValue( pStageInstance, d1e, patientOuList.get(patient) ); + //PatientDataValue patientDataValue1 = patientDataValueService.getPatientDataValue( pStageInstance, d1e, patientOuList.get(patient) ); + PatientDataValue patientDataValue1 = patientDataValueService.getPatientDataValue( pStageInstance, d1e ); if ( patientDataValue1 == null ) { tempStr = " "; @@ -798,7 +799,8 @@ } } } else { - PatientDataValue patientDataValue1 = patientDataValueService.getPatientDataValue( pStageInstance, d1e, patientOuList.get(patient) ); + //PatientDataValue patientDataValue1 = patientDataValueService.getPatientDataValue( pStageInstance, d1e, patientOuList.get(patient) ); + PatientDataValue patientDataValue1 = patientDataValueService.getPatientDataValue( pStageInstance, d1e ); if ( patientDataValue1 == null ) { tempStr = " "; @@ -853,7 +855,8 @@ { ProgramStageInstance programStageInstance = itrPSI.next(); - PatientDataValue patientDataValue = patientDataValueService.getPatientDataValue( programStageInstance, d1e, patientOuList.get(patient) ); + //PatientDataValue patientDataValue = patientDataValueService.getPatientDataValue( programStageInstance, d1e, patientOuList.get(patient) ); + PatientDataValue patientDataValue = patientDataValueService.getPatientDataValue( programStageInstance, d1e ); //System.out.println("psi = "+programStageInstance.getId() + " de = "+d1e + " ou = "+patientOuList.get(patient)); if ( patientDataValue != null ) { @@ -1006,7 +1009,8 @@ while ( itrPSI.hasNext() ) { ProgramStageInstance programStageInstance = itrPSI.next(); - PatientDataValue patientDataValue = patientDataValueService.getPatientDataValue( programStageInstance, d1e, patientOuList.get(patient) ); + //PatientDataValue patientDataValue = patientDataValueService.getPatientDataValue( programStageInstance, d1e, patientOuList.get(patient) ); + PatientDataValue patientDataValue = patientDataValueService.getPatientDataValue( programStageInstance, d1e ); if ( patientDataValue != null ) { if ( d1e.getType().equalsIgnoreCase( DataElement.VALUE_TYPE_DATE ) ) @@ -1058,7 +1062,8 @@ { ProgramStageInstance programStageInstance = itrPSI.next(); - PatientDataValue patientDataValue1 = patientDataValueService.getPatientDataValue( programStageInstance, d1e, patientOuList.get(patient) ); + //PatientDataValue patientDataValue1 = patientDataValueService.getPatientDataValue( programStageInstance, d1e, patientOuList.get(patient) ); + PatientDataValue patientDataValue1 = patientDataValueService.getPatientDataValue( programStageInstance, d1e ); if ( patientDataValue1 != null ) { ifaCount = Integer.parseInt( patientDataValue1.getValue() ) + ifaCount; @@ -1457,7 +1462,8 @@ if ( pStageInstance.getExecutionDate() != null ) { if ( includePeriod.equalsIgnoreCase( "periodincluding" ) ) { if ( pStageInstance.getExecutionDate().before( eDate ) ) { - PatientDataValue patientDataValue1 = patientDataValueService.getPatientDataValue( pStageInstance, d1e, patientOuList.get(patient) ); + //PatientDataValue patientDataValue1 = patientDataValueService.getPatientDataValue( pStageInstance, d1e, patientOuList.get(patient) ); + PatientDataValue patientDataValue1 = patientDataValueService.getPatientDataValue( pStageInstance, d1e ); if ( patientDataValue1 == null ) { tempStr = " "; @@ -1490,8 +1496,8 @@ } } } else { - PatientDataValue patientDataValue1 = patientDataValueService.getPatientDataValue( pStageInstance, d1e, patientOuList.get(patient) ); - + //PatientDataValue patientDataValue1 = patientDataValueService.getPatientDataValue( pStageInstance, d1e, patientOuList.get(patient) ); + PatientDataValue patientDataValue1 = patientDataValueService.getPatientDataValue( pStageInstance, d1e ); if ( patientDataValue1 == null ) { tempStr = " "; } else if ( d1e.getType().equalsIgnoreCase( DataElement.VALUE_TYPE_STRING ) && d1e.isMultiDimensional() ) { @@ -1545,7 +1551,8 @@ { ProgramStageInstance programStageInstance = itrPSI.next(); - PatientDataValue patientDataValue = patientDataValueService.getPatientDataValue( programStageInstance, d1e, patientOuList.get(patient) ); + //PatientDataValue patientDataValue = patientDataValueService.getPatientDataValue( programStageInstance, d1e, patientOuList.get(patient) ); + PatientDataValue patientDataValue = patientDataValueService.getPatientDataValue( programStageInstance, d1e ); //System.out.println("psi = "+programStageInstance.getId() + " de = "+d1e + " ou = "+patientOuList.get(patient)); if ( patientDataValue != null ) { @@ -1698,7 +1705,8 @@ while ( itrPSI.hasNext() ) { ProgramStageInstance programStageInstance = itrPSI.next(); - PatientDataValue patientDataValue = patientDataValueService.getPatientDataValue( programStageInstance, d1e, patientOuList.get(patient) ); + // PatientDataValue patientDataValue = patientDataValueService.getPatientDataValue( programStageInstance, d1e, patientOuList.get(patient) ); + PatientDataValue patientDataValue = patientDataValueService.getPatientDataValue( programStageInstance, d1e ); if ( patientDataValue != null ) { if ( d1e.getType().equalsIgnoreCase( DataElement.VALUE_TYPE_DATE ) ) @@ -1750,7 +1758,8 @@ { ProgramStageInstance programStageInstance = itrPSI.next(); - PatientDataValue patientDataValue1 = patientDataValueService.getPatientDataValue( programStageInstance, d1e, patientOuList.get(patient) ); + // PatientDataValue patientDataValue1 = patientDataValueService.getPatientDataValue( programStageInstance, d1e, patientOuList.get(patient) ); + PatientDataValue patientDataValue1 = patientDataValueService.getPatientDataValue( programStageInstance, d1e ); if ( patientDataValue1 != null ) { ifaCount = Integer.parseInt( patientDataValue1.getValue() ) + ifaCount; === modified file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/portal/action/PortalReportsResult_ACS.java' --- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/portal/action/PortalReportsResult_ACS.java 2012-02-17 07:09:28 +0000 +++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/portal/action/PortalReportsResult_ACS.java 2012-04-04 11:58:27 +0000 @@ -354,7 +354,8 @@ else if( sType.equalsIgnoreCase("dataelement") ) { DataElement de = dataElementService.getDataElement( Integer.parseInt( deCode ) ); - PatientDataValue patientDV = patientDataValueService.getPatientDataValue( prgStageInstance, de, selectedOrgUnit ); + //PatientDataValue patientDV = patientDataValueService.getPatientDataValue( prgStageInstance, de, selectedOrgUnit ); + PatientDataValue patientDV = patientDataValueService.getPatientDataValue( prgStageInstance, de ); if( patientDV != null && patientDV.getValue() != null ) { tempStr = patientDV.getValue(); @@ -363,7 +364,8 @@ else if( sType.equalsIgnoreCase("dataelement-dd") ) { DataElement de = dataElementService.getDataElement( Integer.parseInt( deCode ) ); - PatientDataValue patientDV = patientDataValueService.getPatientDataValue( prgStageInstance, de, selectedOrgUnit ); + //PatientDataValue patientDV = patientDataValueService.getPatientDataValue( prgStageInstance, de, selectedOrgUnit ); + PatientDataValue patientDV = patientDataValueService.getPatientDataValue( prgStageInstance, de ); if( patientDV != null && patientDV.getValue() != null ) { Integer optionComboId = Integer.parseInt( patientDV.getValue() ); @@ -374,7 +376,8 @@ else if( sType.equalsIgnoreCase("dataelement-b") ) { DataElement de = dataElementService.getDataElement( Integer.parseInt( deCode ) ); - PatientDataValue patientDV = patientDataValueService.getPatientDataValue( prgStageInstance, de, selectedOrgUnit ); + //PatientDataValue patientDV = patientDataValueService.getPatientDataValue( prgStageInstance, de, selectedOrgUnit ); + PatientDataValue patientDV = patientDataValueService.getPatientDataValue( prgStageInstance, de ); if( patientDV != null && patientDV.getValue() != null ) { if( patientDV.getValue().equalsIgnoreCase("false") ) @@ -394,13 +397,15 @@ //System.out.println( " dealy : " + dealy + " ,reason: " + reason ); DataElement deDealy = dataElementService.getDataElement( Integer.parseInt( dealy ) ); - PatientDataValue patientDelayDV = patientDataValueService.getPatientDataValue( prgStageInstance, deDealy, selectedOrgUnit ); + //PatientDataValue patientDelayDV = patientDataValueService.getPatientDataValue( prgStageInstance, deDealy, selectedOrgUnit ); + PatientDataValue patientDelayDV = patientDataValueService.getPatientDataValue( prgStageInstance, deDealy ); if( patientDelayDV != null && patientDelayDV.getValue() != null ) { if( patientDelayDV.getValue().equalsIgnoreCase("true") ) { DataElement deReason = dataElementService.getDataElement( Integer.parseInt( reason ) ); - PatientDataValue patientReasonDV = patientDataValueService.getPatientDataValue( prgStageInstance, deReason, selectedOrgUnit ); + //PatientDataValue patientReasonDV = patientDataValueService.getPatientDataValue( prgStageInstance, deReason, selectedOrgUnit ); + PatientDataValue patientReasonDV = patientDataValueService.getPatientDataValue( prgStageInstance, deReason ); if( patientReasonDV != null && patientReasonDV.getValue() != null ) { Integer optionComboId = Integer.parseInt( patientReasonDV.getValue() ); @@ -431,14 +436,16 @@ } DataElement deWeight = dataElementService.getDataElement( Integer.parseInt( weightDE ) ); - PatientDataValue patientWeightDV = patientDataValueService.getPatientDataValue( prgStageInstance, deWeight, selectedOrgUnit ); + // PatientDataValue patientWeightDV = patientDataValueService.getPatientDataValue( prgStageInstance, deWeight, selectedOrgUnit ); + PatientDataValue patientWeightDV = patientDataValueService.getPatientDataValue( prgStageInstance, deWeight ); if( patientWeightDV != null && patientWeightDV.getValue() != null ) { tempStrWeight = patientWeightDV.getValue(); } DataElement deHeight = dataElementService.getDataElement( Integer.parseInt( heightDE ) ); - PatientDataValue patientHeightDV = patientDataValueService.getPatientDataValue( prgStageInstance, deHeight, selectedOrgUnit ); + //PatientDataValue patientHeightDV = patientDataValueService.getPatientDataValue( prgStageInstance, deHeight, selectedOrgUnit ); + PatientDataValue patientHeightDV = patientDataValueService.getPatientDataValue( prgStageInstance, deHeight ); if( patientHeightDV != null && patientHeightDV.getValue() != null ) { tempStrHeight = patientHeightDV.getValue(); @@ -485,14 +492,16 @@ } DataElement deStart = dataElementService.getDataElement( Integer.parseInt( startDE ) ); - PatientDataValue patientStartDV = patientDataValueService.getPatientDataValue( prgStageInstance, deStart, selectedOrgUnit ); + //PatientDataValue patientStartDV = patientDataValueService.getPatientDataValue( prgStageInstance, deStart, selectedOrgUnit ); + PatientDataValue patientStartDV = patientDataValueService.getPatientDataValue( prgStageInstance, deStart ); if( patientStartDV != null && patientStartDV.getValue() != null ) { tempStartDate = patientStartDV.getValue(); } DataElement deEnd = dataElementService.getDataElement( Integer.parseInt( endDE ) ); - PatientDataValue patientEndDV = patientDataValueService.getPatientDataValue( prgStageInstance, deEnd, selectedOrgUnit ); + //PatientDataValue patientEndDV = patientDataValueService.getPatientDataValue( prgStageInstance, deEnd, selectedOrgUnit ); + PatientDataValue patientEndDV = patientDataValueService.getPatientDataValue( prgStageInstance, deEnd ); if( patientEndDV != null && patientEndDV.getValue() != null ) { tempEndDate = patientEndDV.getValue(); @@ -551,14 +560,16 @@ } DataElement dePDate = dataElementService.getDataElement( Integer.parseInt( pdate ) ); - PatientDataValue patientPdateDV = patientDataValueService.getPatientDataValue( prgStageInstance, dePDate, selectedOrgUnit ); + //PatientDataValue patientPdateDV = patientDataValueService.getPatientDataValue( prgStageInstance, dePDate, selectedOrgUnit ); + PatientDataValue patientPdateDV = patientDataValueService.getPatientDataValue( prgStageInstance, dePDate ); if( patientPdateDV != null && patientPdateDV.getValue() != null ) { tempPDate = patientPdateDV.getValue(); } DataElement dePTime = dataElementService.getDataElement( Integer.parseInt( pTime ) ); - PatientDataValue patientPTimeDV = patientDataValueService.getPatientDataValue( prgStageInstance, dePTime, selectedOrgUnit ); + //PatientDataValue patientPTimeDV = patientDataValueService.getPatientDataValue( prgStageInstance, dePTime, selectedOrgUnit ); + PatientDataValue patientPTimeDV = patientDataValueService.getPatientDataValue( prgStageInstance, dePTime ); if( patientPTimeDV != null && patientPTimeDV.getValue() != null ) { tempPTime = patientPTimeDV.getValue(); @@ -603,7 +614,8 @@ } DataElement deAcsDate = dataElementService.getDataElement( Integer.parseInt( acsDate ) ); - PatientDataValue patientAcsdateDV = patientDataValueService.getPatientDataValue( prgStageInstance, deAcsDate, selectedOrgUnit ); + //PatientDataValue patientAcsdateDV = patientDataValueService.getPatientDataValue( prgStageInstance, deAcsDate, selectedOrgUnit ); + PatientDataValue patientAcsdateDV = patientDataValueService.getPatientDataValue( prgStageInstance, deAcsDate ); if( patientAcsdateDV != null && patientAcsdateDV.getValue() != null ) { tempAcsDate = patientAcsdateDV.getValue(); @@ -611,14 +623,16 @@ DataElement deAcsTime = dataElementService.getDataElement( Integer.parseInt( acsTime ) ); - PatientDataValue patientAcsTimeDV = patientDataValueService.getPatientDataValue( prgStageInstance, deAcsTime, selectedOrgUnit ); + //PatientDataValue patientAcsTimeDV = patientDataValueService.getPatientDataValue( prgStageInstance, deAcsTime, selectedOrgUnit ); + PatientDataValue patientAcsTimeDV = patientDataValueService.getPatientDataValue( prgStageInstance, deAcsTime ); if( patientAcsTimeDV != null && patientAcsTimeDV.getValue() != null ) { tempAcsTime = patientAcsTimeDV.getValue(); } DataElement dePreDate = dataElementService.getDataElement( Integer.parseInt( preDate ) ); - PatientDataValue patientPredateDV = patientDataValueService.getPatientDataValue( prgStageInstance, dePreDate, selectedOrgUnit ); + //PatientDataValue patientPredateDV = patientDataValueService.getPatientDataValue( prgStageInstance, dePreDate, selectedOrgUnit ); + PatientDataValue patientPredateDV = patientDataValueService.getPatientDataValue( prgStageInstance, dePreDate ); if( patientPredateDV != null && patientPredateDV.getValue() != null ) { tempPreDate = patientPredateDV.getValue(); @@ -627,7 +641,8 @@ DataElement dePreTime = dataElementService.getDataElement( Integer.parseInt( preTime ) ); - PatientDataValue patientPreTimeDV = patientDataValueService.getPatientDataValue( prgStageInstance, dePreTime, selectedOrgUnit ); + //PatientDataValue patientPreTimeDV = patientDataValueService.getPatientDataValue( prgStageInstance, dePreTime, selectedOrgUnit ); + PatientDataValue patientPreTimeDV = patientDataValueService.getPatientDataValue( prgStageInstance, dePreTime ); if( patientPreTimeDV != null && patientPreTimeDV.getValue() != null ) { tempPreTime = patientPreTimeDV.getValue(); @@ -799,7 +814,8 @@ else if( sType.equalsIgnoreCase("dataelement") ) { DataElement de = dataElementService.getDataElement( Integer.parseInt( deCode ) ); - PatientDataValue patientDV = patientDataValueService.getPatientDataValue( prgStageInstance, de, selectedOrgUnit ); + PatientDataValue patientDV = patientDataValueService.getPatientDataValue( prgStageInstance, de ); + //PatientDataValue patientDV = patientDataValueService.getPatientDataValue( prgStageInstance, de, selectedOrgUnit ); if( patientDV != null && patientDV.getValue() != null ) { tempStr = patientDV.getValue(); @@ -808,7 +824,8 @@ else if( sType.equalsIgnoreCase("dataelement-dd") ) { DataElement de = dataElementService.getDataElement( Integer.parseInt( deCode ) ); - PatientDataValue patientDV = patientDataValueService.getPatientDataValue( prgStageInstance, de, selectedOrgUnit ); + //PatientDataValue patientDV = patientDataValueService.getPatientDataValue( prgStageInstance, de, selectedOrgUnit ); + PatientDataValue patientDV = patientDataValueService.getPatientDataValue( prgStageInstance, de ); if( patientDV != null && patientDV.getValue() != null ) { Integer optionComboId = Integer.parseInt( patientDV.getValue() ); @@ -819,7 +836,8 @@ else if( sType.equalsIgnoreCase("dataelement-b") ) { DataElement de = dataElementService.getDataElement( Integer.parseInt( deCode ) ); - PatientDataValue patientDV = patientDataValueService.getPatientDataValue( prgStageInstance, de, selectedOrgUnit ); + //PatientDataValue patientDV = patientDataValueService.getPatientDataValue( prgStageInstance, de, selectedOrgUnit ); + PatientDataValue patientDV = patientDataValueService.getPatientDataValue( prgStageInstance, de ); if( patientDV != null && patientDV.getValue() != null ) { if( patientDV.getValue().equalsIgnoreCase("false") ) === modified file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/portal/action/PortalReportsResult_Action.java' --- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/portal/action/PortalReportsResult_Action.java 2012-02-17 07:09:28 +0000 +++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/portal/action/PortalReportsResult_Action.java 2012-04-04 11:58:27 +0000 @@ -434,7 +434,8 @@ else if( sType.equalsIgnoreCase("dataelement") ) { DataElement de = dataElementService.getDataElement( Integer.parseInt( deCode ) ); - PatientDataValue patientDV = patientDataValueService.getPatientDataValue( prgStageInstance, de, selectedOrgUnit ); + //PatientDataValue patientDV = patientDataValueService.getPatientDataValue( prgStageInstance, de, selectedOrgUnit ); + PatientDataValue patientDV = patientDataValueService.getPatientDataValue( prgStageInstance, de ); if( patientDV != null && patientDV.getValue() != null ) { tempStr = patientDV.getValue(); @@ -443,7 +444,8 @@ else if( sType.equalsIgnoreCase("dataelement-dd") ) { DataElement de = dataElementService.getDataElement( Integer.parseInt( deCode ) ); - PatientDataValue patientDV = patientDataValueService.getPatientDataValue( prgStageInstance, de, selectedOrgUnit ); + //PatientDataValue patientDV = patientDataValueService.getPatientDataValue( prgStageInstance, de, selectedOrgUnit ); + PatientDataValue patientDV = patientDataValueService.getPatientDataValue( prgStageInstance, de ); if( patientDV != null && patientDV.getValue() != null ) { Integer optionComboId = Integer.parseInt( patientDV.getValue() ); @@ -454,7 +456,8 @@ else if( sType.equalsIgnoreCase("dataelement-b") ) { DataElement de = dataElementService.getDataElement( Integer.parseInt( deCode ) ); - PatientDataValue patientDV = patientDataValueService.getPatientDataValue( prgStageInstance, de, selectedOrgUnit ); + //PatientDataValue patientDV = patientDataValueService.getPatientDataValue( prgStageInstance, de, selectedOrgUnit ); + PatientDataValue patientDV = patientDataValueService.getPatientDataValue( prgStageInstance, de ); if( patientDV != null && patientDV.getValue() != null ) { if( patientDV.getValue().equalsIgnoreCase("false") ) === added file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/util/ProgramDetail.java' --- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/util/ProgramDetail.java 1970-01-01 00:00:00 +0000 +++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/util/ProgramDetail.java 2012-04-04 11:58:27 +0000 @@ -0,0 +1,129 @@ +package org.hisp.dhis.reports.util; + + +public class ProgramDetail +{ + /** + * Unique Id + */ + private String id; + + /** + * Report Name + */ + private String name; + + /** + * excelTemplateName is the xls Template File Name for this report + */ + private String excelTemplateName; + + /** + * xmlTemplateName is the xml Template File Name for this report + */ + private String xmlTemplateName; + + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + public ProgramDetail() + { + + } + + public ProgramDetail( String id, String name ) + { + this.id = id; + this.name = name; + } + + public ProgramDetail( String id, String name, String excelTemplateName, String xmlTemplateName ) + { + this.id = id; + this.name = name; + this.excelTemplateName = excelTemplateName; + this.xmlTemplateName = xmlTemplateName; + } + + + // ------------------------------------------------------------------------- + // hashCode and equals + // ------------------------------------------------------------------------- + + @Override + public int hashCode() + { + return name.hashCode(); + } + + @Override + public boolean equals( Object o ) + { + if ( this == o ) + { + return true; + } + + if ( o == null ) + { + return false; + } + + if ( !(o instanceof ProgramDetail ) ) + { + return false; + } + + final ProgramDetail other = ( ProgramDetail ) o; + + return name.equals( other.getName() ); + } + + + // ------------------------------------------------------------------------- + // Getters and setters + // ------------------------------------------------------------------------- + + public String getId() + { + return id; + } + + public void setId( String id ) + { + this.id = id; + } + + public String getName() + { + return name; + } + + public void setName( String name ) + { + this.name = name; + } + + public String getExcelTemplateName() + { + return excelTemplateName; + } + + public void setExcelTemplateName( String excelTemplateName ) + { + this.excelTemplateName = excelTemplateName; + } + + public String getXmlTemplateName() + { + return xmlTemplateName; + } + + public void setXmlTemplateName( String xmlTemplateName ) + { + this.xmlTemplateName = xmlTemplateName; + } + +} === modified file 'local/in/dhis-web-reports-national/src/main/resources/META-INF/dhis/beans.xml' --- local/in/dhis-web-reports-national/src/main/resources/META-INF/dhis/beans.xml 2012-03-19 06:11:45 +0000 +++ local/in/dhis-web-reports-national/src/main/resources/META-INF/dhis/beans.xml 2012-04-04 11:58:27 +0000 @@ -208,6 +208,25 @@ + + + + + + + + + + + + + + + - @@ -457,6 +476,7 @@ + @@ -1274,7 +1294,63 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + css/StylesForTags.css F_EDREPORT_GENERATE + + + /dhis-web-reports/responseIndicator.vm + javascript/reports.js,javascript/date.js + plainTextError + + + + + @@ -197,6 +208,15 @@ 1024 + + + application/vnd.ms-excel + inputStream + filename="${fileName}" + 1024 + + 1024 - + + + + + /main.vm + /dhis-web-reports/patientInfoReportsForm.vm + /dhis-web-reports/menuWithTreeForPatientInfo.vm + ../dhis-web-commons/ouwt/ouwt.js,../dhis-web-commons/javascripts/lists.js,javascript/patient.js,javascript/hashtable.js + css/StylesForTags.css + F_REPORT_BENIFICIARY_INFO + + + + + /content.vm + /dhis-web-reports/patientRegistrationList.vm + ../dhis-web-commons/javascripts/lists.js,javascript/patient.js,javascript/hashtable.js + css/StylesForTags.css + F_REPORT_BENIFICIARY_INFO + + + + /content.vm + /dhis-web-reports/patientDetails.vm + + + + + + application/vnd.ms-excel + inputStream + filename="${fileName}" + 1024 + + + + + === modified file 'local/in/dhis-web-reports-national/src/main/webapp/WEB-INF/web.xml' --- local/in/dhis-web-reports-national/src/main/webapp/WEB-INF/web.xml 2011-03-08 21:38:01 +0000 +++ local/in/dhis-web-reports-national/src/main/webapp/WEB-INF/web.xml 2012-04-04 11:58:27 +0000 @@ -23,7 +23,7 @@ OpenSessionInViewFilter - org.springframework.orm.hibernate3.support.OpenSessionInViewFilter + org.springframework.orm.hibernate4.support.OpenSessionInViewFilter springSecurityFilterChain === added file 'local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/patient.js' --- local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/patient.js 1970-01-01 00:00:00 +0000 +++ local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/javascript/patient.js 2012-04-04 11:58:27 +0000 @@ -0,0 +1,220 @@ +//----------------------------------------------------------------------------- +// Search Patient +//----------------------------------------------------------------------------- + +function searchPatientsOnKeyUp( event ) +{ + var key = getKeyCode( event ); + + if ( key==13 )// Enter + { + searchPatients(); + } +} + +function getKeyCode(e) +{ + if (window.event) + return window.event.keyCode; + return (e)? e.which : null; +} + + +function searchPatients() +{ + hideById( 'listPatientDiv' ); + var searchTextFields = jQuery('[name=searchText]'); + var flag = true; + jQuery( searchTextFields ).each( function( i, item ) + { + if( jQuery( item ).val() == '' ) + { + showWarningMessage( i18n_specify_search_criteria ); + flag = false; + } + }); + + if(!flag) return; + + contentDiv = 'listPatientDiv'; + jQuery( "#loaderDiv" ).show(); + $.ajax({ + url: 'searchRegistredPatient.action', + type:"POST", + data: getParamsForDiv('searchPatientDiv'), + success: function( html ){ + statusSearching = 1; + setInnerHTML( 'listPatientDiv', html ); + showById('listPatientDiv'); + jQuery( "#loaderDiv" ).hide(); + } + }); +} + +function getParamsForDiv( patientDiv ) +{ + var params = ''; + jQuery("#" + patientDiv + " :input").each(function() + { + var elementId = $(this).attr('id'); + + if( $(this).attr('type') == 'checkbox' ) + { + var checked = jQuery(this).attr('checked') ? true : false; + params += elementId + "=" + checked + "&"; + } + else if( $(this).attr('type') != 'button' ) + { + params += elementId + "="+ htmlEncode(jQuery(this).val()) + "&"; + } + }); + + return params; +} + +//----------------------------------------------------------------------------- +//View patient details +//----------------------------------------------------------------------------- + +function showPatientDetails( patientId ) +{ + $('#detailsInfo').load("getPatientDetails.action", + { + id:patientId + } + , function( ){ + }).dialog({ + title: i18n_patient_details, + maximize: true, + closable: true, + modal:true, + overlay:{background:'#000000', opacity:0.1}, + width: 500, + height: 500 + });; +} + + +function getSelectedOrgUnit( orgUnitIds ) +{ + jQuery.postJSON("getOrgUnitName.action",{ + id : orgUnitIds[0] + }, function( json ){ + setFieldValue( "ouNameTB",json.organisationUnit.name ); + }); +} + +function getOUDetails(orgUnitIds) +{ + $.post("getOrgUnitDetails.action", + { + orgUnitId : orgUnitIds + }, + function (data) + { + getOUDetailsRecevied(data); + },'xml'); +} + +function getOUDetailsRecevied(xmlObject) +{ + + var orgUnits = xmlObject.getElementsByTagName("orgunit"); + + for ( var i = 0; i < orgUnits.length; i++ ) + { + var id = orgUnits[ i ].getElementsByTagName("id")[0].firstChild.nodeValue; + var orgUnitName = orgUnits[ i ].getElementsByTagName("name")[0].firstChild.nodeValue; + var level = orgUnits[ i ].getElementsByTagName("level")[0].firstChild.nodeValue; + + document.getElementById("ouNameTB").value = orgUnitName; + //document.reportForm.ouNameTB.value = orgUnitName; + } +} + + +function generatePatientReport( event, patientId ) +{ + + var tempPatientId = ""; + var tempProgramId = ""; + + var programDropDown = document.getElementById("programId_"+patientId); + var selProgramId = programDropDown.options[ programDropDown.selectedIndex ].value; + //alert(patientId +"----" + selProgramId ); + + var excelTemplateName = ""; + var xmlTemplateName = ""; + + tempPatientId = patientId; + tempProgramId = selProgramId; + + + var flag = 1; + + + for ( i = 0; i < programIds.length; i++ ) + { + if( selProgramId == programIds[i] ) + { + //alert( programIds[i] + "----" + selProgramId ); + excelTemplateName = programExcelFileNames.get(programIds[i]); + xmlTemplateName = programXmlFileNames.get(programIds[i]); + //alert( excelTemplateName + "----" + xmlTemplateName ); + //document.getElementById("exportToExcel").href="generatePatientReport.action?patientId=" + patientId + "&selProgramId=" + selProgramId + "&excelTemplateName=" + excelTemplateName + "&xmlTemplateName=" + xmlTemplateName; + + flag = 2; + break; + } + + } + if( flag != 2 ) + { + //alert("There is no xml and xls template for selected program"); + showWarningMessage( i18n_no_xls_xml ); + return; + + } + + else + { + /* + document.forms[0].method="Post"; + document.forms[0].action="../Customer"; + document.forms[0].submit(); + */ + + //event.target.href = "generatePatientReport.action?patientId=" + patientId + "&selProgramId=" + selProgramId + "&excelTemplateName=" + excelTemplateName + "&xmlTemplateName=" + xmlTemplateName; + + //alert( tempPatientId + "----" + tempProgramId + "----" + excelTemplateName + "----" + xmlTemplateName ); + + document.getElementById("patientId").value = tempPatientId; + document.getElementById("selProgramId").value = tempProgramId; + document.getElementById("excelTemplateName").value = excelTemplateName; + document.getElementById("xmlTemplateName").value = xmlTemplateName; + + /* + alert( document.getElementById("patientId").value ); + alert( document.getElementById("selProgramId").value ); + alert( document.getElementById("excelTemplateName").value ); + alert( document.getElementById("xmlTemplateName").value ); + */ + document.patientForm.action = "generatePatientReport.action"; + document.patientForm.submit(); + + /* + document.PatientForm.method="get"; + + document.PatientForm.action = "generatePatientReport.action?patientId=" + patientId + "&selProgramId=" + selProgramId + "&excelTemplateName=" + excelTemplateName + "&xmlTemplateName=" + xmlTemplateName; + document.PatientForm.submit(); + */ + //document.getElementById("exportToExcel").href="generatePatientReport.action?patientId=" + patientId + "&selProgramId=" + selProgramId + "&excelTemplateName=" + excelTemplateName + "&xmlTemplateName=" + xmlTemplateName; + } + + //event.target.href = "generatePatientReport.action?patientId=" + patientId + "&selProgramId=" + selProgramId; + + //document.getElementById("exportToExcel").href="generatePatientReport.action?patientId=" + patientId + "&selProgramId=" + selProgramId; + + //alert( event.target.href ); + +} === modified file 'local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/menu.vm' --- local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/menu.vm 2011-12-14 11:06:08 +0000 +++ local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/menu.vm 2012-04-04 11:58:27 +0000 @@ -82,19 +82,20 @@ #if( $auth.hasAccess( "dhis-web-reports", "benificiaryInfoReportsAnalyser") ) === added file 'local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/menuWithTreeForPatientInfo.vm' --- local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/menuWithTreeForPatientInfo.vm 1970-01-01 00:00:00 +0000 +++ local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/menuWithTreeForPatientInfo.vm 2012-04-04 11:58:27 +0000 @@ -0,0 +1,36 @@ +

$i18n.getString( "report_analyser" )

+ + + +
+ +#parse( "/dhis-web-commons/ouwt/orgunittree.vm" ) + + \ No newline at end of file === added file 'local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/patientDetails.vm' --- local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/patientDetails.vm 1970-01-01 00:00:00 +0000 +++ local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/patientDetails.vm 2012-04-04 11:58:27 +0000 @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + #foreach( $patientIdentifier in $patient.identifiers ) + + + + + #end + + + + + + #foreach( $attribute in $patient.attributes ) + #if( $patientAttributeValueMap.get( $attribute.id ) != " " ) + + + + + #end + #end + + + + + + +
+ + + $patient.getFullName() +
+ + + $i18n.getString($patient.gender) +
+ + $!patient.dobType +
+ + $format.formatDate( $!patient.birthDate ) +
+ + #if($!patient.bloodGroup && !$patient.bloodGroup.equals("")) $patient.bloodGroup #else $i18n.getString('none') #end +
 
+ + + $patientIdentifier.identifier +
 
+ + #if($attribute.valueType=="YES/NO") + $attribute.id $i18n.getString( $patientAttributeValueMap.get( $attribute.id ) ) + #else + $attribute.id $patientAttributeValueMap.get( $attribute.id ) + #end +
 
+ #foreach( $program in $patient.programs ) + $program.name
+ #end +
\ No newline at end of file === added file 'local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/patientInfoReportsForm.vm' --- local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/patientInfoReportsForm.vm 1970-01-01 00:00:00 +0000 +++ local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/patientInfoReportsForm.vm 2012-04-04 11:58:27 +0000 @@ -0,0 +1,39 @@ + +

$i18n.getString( "patient_management" )

+
+ +
+ + + + + + + + + + + + + + +
$i18n.getString( "search_by_name_id" ) + +
+ + +       + $i18n.getString( "organisationunit" ) :         $i18n.getString( "in_selected_orgU" )     
+
+
+#parse( "/dhis-web-commons/loader/loader.vm" ) + + \ No newline at end of file === added file 'local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/patientRegistrationList.vm' --- local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/patientRegistrationList.vm 1970-01-01 00:00:00 +0000 +++ local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/patientRegistrationList.vm 2012-04-04 11:58:27 +0000 @@ -0,0 +1,213 @@ + + + + +
+ + + + + + + + + + + + + + + + + + +
$i18n.getString( "search_result_matching_the_search_criteria" ):  $i18n.getString( "search_patients_by_attributes" )
$i18n.getString( "total_result" )  $!total
+ + +#if( $patients.size() > 0 ) + + + + + + + + +
+ + + #foreach( $attribute in $patientAttributes ) + + #end + + + + + #if($mapPatientOrgunit.size()!=0) + + #end + + + + + + #foreach( $attribute in $patientAttributes ) + + #end + + + + + #if($mapPatientOrgunit.size()!=0) + + #end + ##if($mapPatientPrograms.size()!=0) + + ##end + + + + + + + #set( $mark = false ) + #foreach( $patient in $patients ) + + + + + #foreach( $attribute in $patientAttributes ) + #set ( $key = $patient.id + '-' + $attribute.id ) + + #end + + + + + + + + + + #if($mapPatientOrgunit.size()!=0) + + + + #end + ##if($mapPatientPrograms.size()!=0) + ##set( $programs = $mapPatientPrograms.get( $patient.id ) ) + #set( $programs = $patient.getPrograms() ) + #if( $programs.size() !=0 ) + + #else + + #end + + #if( $patient.getPrograms().size() !=0 ) + + #else + + #end + + + + + #set( $mark = !$mark) + #end + + +
#$attribute.name$i18n.getString( "full_name" )$i18n.getString( "gender" )$i18n.getString( "date_of_birth" )$i18n.getString( "age" )$i18n.getString( "hierachy_orgunit" )$i18n.getString( "enrolled_in_program" ) $i18n.getString( "operations" )
+ #set( $nr = ( ( $paging.getCurrentPage() - 1 ) * $paging.pageSize ) + $velocityCount ) + $nr + + #if( $attribute.valueType == 'YES/NO') + $i18n.getString( $mapPatientPatientAttr.get($key) ) + #else + $mapPatientPatientAttr.get($key) + #end + $!patient.getFullName()$i18n.getString($!patient.gender)$format.formatDate( $!patient.birthDate)$!patient.getAge()$!mapPatientOrgunit.get($patient.id) + + + + + + + + + $i18n.getString( "show_details" ) + + + + + + +
+
+

+
+ #parse( "/dhis-web-commons/paging/paging.vm" ) +
+
+ + +#end +
+ +
+
+