Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register
Show
Ignore:
Timestamp:
08/06/08 17:17:55 (5 months ago)
Author:
mseaton
Message:

synchronization_bidirectional_branch: merge from [4734] to [5181].

Files:

Legend:

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

    r4969 r5183  
    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);