Changeset 5410
- Timestamp:
- 08/30/08 23:59:53 (3 months ago)
- Files:
-
- openmrs-modules/mrngen/metadata/config.xml (modified) (1 diff)
- openmrs-modules/mrngen/src/org/openmrs/module/mrngen/MRNGenUtil.java (modified) (1 diff)
- openmrs-modules/mrngen/src/org/openmrs/module/mrngen/advice/PatientServiceAroundAdvisor.java (modified) (6 diffs)
- openmrs-modules/mrngen/src/org/openmrs/module/mrngen/db/hibernate/HibernateMRNSequenceDAO.java (modified) (4 diffs)
- openmrs-modules/mrngen/web/src/org/openmrs/module/mrngen/web/MRNGenFormController.java (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
openmrs-modules/mrngen/metadata/config.xml
r4828 r5410 7 7 <id>mrngen</id> 8 8 <name>MRN Generator Module</name> 9 <version>1. 0</version>9 <version>1.1</version> 10 10 <package>org.openmrs.module.@MODULE_ID@</package> 11 11 <author>Ratnakar Malla</author> openmrs-modules/mrngen/src/org/openmrs/module/mrngen/MRNGenUtil.java
r4570 r5410 63 63 } 64 64 65 65 66 } openmrs-modules/mrngen/src/org/openmrs/module/mrngen/advice/PatientServiceAroundAdvisor.java
r4639 r5410 10 10 import org.apache.commons.logging.Log; 11 11 import org.apache.commons.logging.LogFactory; 12 import org.openmrs.PatientIdentifier; 13 import org.openmrs.module.ModuleException; 12 import org.openmrs.api.context.Context; 14 13 import org.openmrs.module.mrngen.MRNGenUtil; 15 14 import org.openmrs.module.mrngen.MRNSequenceResponse; 16 import org.openmrs.util.OpenmrsUtil;17 15 import org.springframework.aop.Advisor; 18 16 import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor; 19 import org.springframework.validation.BindException; 17 import org.openmrs.patient.IdentifierValidator; 18 import org.openmrs.module.ModuleException; 19 import org.openmrs.PatientIdentifier; 20 20 21 21 /** … … 24 24 * @author Ratnakar Malla 25 25 * @vesrion 1.0 26 * 08/30/2008: rmalla : Modified to add check digit only if a validator exists. 26 27 */ 27 28 public class PatientServiceAroundAdvisor extends StaticMethodMatcherPointcutAdvisor implements Advisor { … … 53 54 Object[] obj = invocation.getArguments(); 54 55 org.openmrs.Patient patient= (org.openmrs.Patient)obj[0]; 55 System.out.println("** PatientServiceAroundAdvice patient==null " + (patient==null));56 56 Set<PatientIdentifier> piSet = patient.getIdentifiers(); 57 System.out.println("** PatientServiceAroundAdvice piSet==null " + (piSet==null));58 57 Iterator<PatientIdentifier> piSetIterator = piSet.iterator(); 59 58 while(piSetIterator.hasNext()) 60 59 { 61 60 PatientIdentifier pi = piSetIterator.next(); 62 System.out.println("** PatientServiceAroundAdvice pi.getIdentifier() " + (pi.getIdentifier()==null));63 61 if (pi.getIdentifier().contains("TEMPID_WILL_BE_REPLACED")) 64 62 { … … 66 64 MRNSequenceResponse mrsr = new MRNGenUtil().generateIDs(1,""+pi.getIdentifierType().getPatientIdentifierTypeId()).get(0); 67 65 String line= mrsr.getPrefix() + mrsr.getLval(); 68 pi.setIdentifier( line + "-" + OpenmrsUtil.getCheckDigit(line)); 66 org.openmrs.PatientIdentifierType pit =pi.getIdentifierType(); 67 IdentifierValidator piv = null; 68 if (pit.getValidator()!=null) 69 { 70 piv=Context.getPatientService().getIdentifierValidator(pit.getValidator()); 71 } 72 if (piv!=null) 73 { 74 line = piv.getValidIdentifier(line); 75 } 76 pi.setIdentifier( line); 69 77 } 70 78 } … … 74 82 try 75 83 { 76 System.out.println("** invocation=null " + (invocation==null));77 84 o =invocation.proceed(); 78 System.out.println("** invocation=null End " );79 85 }catch (Exception e) 80 86 { … … 89 95 } 90 96 91 92 97 93 98 } openmrs-modules/mrngen/src/org/openmrs/module/mrngen/db/hibernate/HibernateMRNSequenceDAO.java
r4570 r5410 10 10 import org.hibernate.SessionFactory; 11 11 import org.openmrs.DataEntryStatistic; 12 import org.openmrs.PatientIdentifierType; 12 13 import org.openmrs.api.db.DAOException; 13 14 import org.openmrs.module.mrngen.MRNSequenceResponse; 14 15 import org.openmrs.module.mrngen.MRNSequenceResponseDerived; 15 16 import org.openmrs.module.mrngen.db.MRNSequenceDAO; 17 18 /** 19 * 20 * 21 * @author Ratnakar Malla 22 * Hibernate DAO object for MRNSequence Response 23 * @version 1.0 24 * 08/30/2008: rmalla : Modified to include PatientIdentifierType when getResponses is called. 25 */ 16 26 17 27 public class HibernateMRNSequenceDAO implements MRNSequenceDAO { … … 72 82 { 73 83 74 String hql = "select mrsr.prefix,mrsr.lval,mrsr.id,mrsr.patientIdentifierTypeId,mrsr.setupcomplete from MRNSequenceResponse as mrsr where mrsr.patientIdentifierTypeId=:patientIdentifierTypeId"; 84 String hql = "select mrsr.prefix,mrsr.lval,mrsr.id,mrsr.patientIdentifierTypeId," + 85 " mrsr.setupcomplete,mrsr.patientIdentifierType from MRNSequenceResponse as mrsr " + 86 " where mrsr.patientIdentifierTypeId=:patientIdentifierTypeId"; 75 87 Query q = sessionFactory.getCurrentSession().createQuery(hql); 76 88 q.setInteger("patientIdentifierTypeId", Integer.parseInt(patientIdentifierTypeId)); … … 107 119 s.setPatientIdentifierTypeId(pidTypeId); 108 120 String setupComplete=null; 109 if (holder[ 0]!=null)121 if (holder[4]!=null) 110 122 { 111 123 setupComplete = (String)holder[4]; … … 113 125 s.setSetupcomplete(setupComplete); 114 126 127 PatientIdentifierType pitype = null; 128 if (holder[5]!=null) 129 { 130 s.setPatientIdentifierType((PatientIdentifierType)holder[5]); 131 } 132 115 133 derivedList.add(s); 116 134 } openmrs-modules/mrngen/web/src/org/openmrs/module/mrngen/web/MRNGenFormController.java
r4639 r5410 27 27 import org.springframework.web.servlet.ModelAndView; 28 28 import org.springframework.web.servlet.mvc.SimpleFormController; 29 import org.openmrs.patient.IdentifierValidator; 29 30 30 31 /** … … 34 35 * Spring Form for Bulk MRN Generator 35 36 * @version 1.0 37 * 08/30/2008: rmalla : Modified to add check digit only if a validator exists. 36 38 */ 37 39 … … 79 81 HttpServletResponse response, Object obj, BindException errors) 80 82 throws Exception { 81 82 log.error("Inside onSubmit MRNGenFormController0");83 83 84 String site = request.getParameter("site");84 String site = request.getParameter("site"); 85 85 String first = request.getParameter("mrn_first"); 86 86 String count = request.getParameter("mrn_count"); … … 150 150 151 151 String line = mrsrList.get(i).getPrefix() + mrsrList.get(i).getLval(); 152 int checkdigit; 153 try { 154 checkdigit = OpenmrsUtil.getCheckDigit(line); 152 org.openmrs.PatientIdentifierType pit =mrsrList.get(i).getPatientIdentifierType(); 153 154 if (pit.getValidator()!=null) 155 { 156 IdentifierValidator piv = Context.getPatientService(). 157 getIdentifierValidator(pit.getValidator()); 158 line = piv.getValidIdentifier(line); 155 159 } 156 catch (Exception e) {157 throw new ServletException(e);158 }159 line = line + "-" + checkdigit;160 160 161 161 response.getOutputStream().println(line);