Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register

Changeset 4944

Show
Ignore:
Timestamp:
07/15/08 14:18:15 (1 month ago)
Author:
jmiranda
Message:

Fixed #912 - Data export of patient program information not working correctly. The JSP for the patient program columns (simpleColumn.jsp) was modified in changeset [4150] to use the program ID instead of the string. This change broke the DataExportFunction.getProgram(String) method as it continued to expect the program name as the parameter value. The fix was to change the DataExportFunction.getProgram() method to lookup the program by ID first and then by name if one was not found.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openmrs/trunk/src/api/org/openmrs/reporting/export/DataExportFunctions.java

    r4358 r4944  
    509509        } 
    510510         
    511         public PatientProgram getProgram(String programName) { 
     511         
     512        /** 
     513         * Gets a patient program given a program ID or program name. 
     514         *  
     515         * @param programIdOrName       the identifier or name of the program 
     516         * @return 
     517         */ 
     518        public PatientProgram getProgram(String programIdOrName) { 
     519                 
    512520                Map<Integer, PatientProgram> patientIdProgramMap; 
    513                 if (programMap.containsKey(programName)) { 
    514                         patientIdProgramMap = programMap.get(programName); 
     521                if (programMap.containsKey(programIdOrName)) { 
     522                        patientIdProgramMap = programMap.get(programIdOrName); 
    515523                } else { 
    516                         Program program = Context.getProgramWorkflowService().getProgramByName(programName); 
     524                 
     525                        Program program = null; 
     526                         
     527                        // 
     528                        // Ticket #912 - Fixed by adding some code to lookup the program by ID 
     529                        // 
     530                        try {  
     531                                Integer programId = Integer.parseInt(programIdOrName); 
     532                                program = Context.getProgramWorkflowService().getProgram(programId); 
     533                        } catch (NumberFormatException e) { /* ignore error because we're going to look the program up by name */ } 
     534                         
     535                        if (program == null) {  
     536                                program = Context.getProgramWorkflowService().getProgramByName(programIdOrName); 
     537                        } 
    517538                        patientIdProgramMap = patientSetService.getPatientPrograms(getPatientSetIfNotAllPatients(), program); 
    518                         programMap.put(programName, patientIdProgramMap); 
     539                        programMap.put(programIdOrName, patientIdProgramMap); 
    519540                } 
    520541                return patientIdProgramMap.get(patientId);