Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register

Changeset 5410

Show
Ignore:
Timestamp:
08/30/08 23:59:53 (3 months ago)
Author:
rmalla
Message:

mrngen: rmalla : Modified to add check digit only if a validator exists.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openmrs-modules/mrngen/metadata/config.xml

    r4828 r5410  
    77        <id>mrngen</id> 
    88        <name>MRN Generator Module</name> 
    9         <version>1.0</version> 
     9        <version>1.1</version> 
    1010        <package>org.openmrs.module.@MODULE_ID@</package> 
    1111        <author>Ratnakar Malla</author> 
  • openmrs-modules/mrngen/src/org/openmrs/module/mrngen/MRNGenUtil.java

    r4570 r5410  
    6363        } 
    6464         
     65                 
    6566} 
  • openmrs-modules/mrngen/src/org/openmrs/module/mrngen/advice/PatientServiceAroundAdvisor.java

    r4639 r5410  
    1010import org.apache.commons.logging.Log; 
    1111import org.apache.commons.logging.LogFactory; 
    12 import org.openmrs.PatientIdentifier; 
    13 import org.openmrs.module.ModuleException; 
     12import org.openmrs.api.context.Context; 
    1413import org.openmrs.module.mrngen.MRNGenUtil; 
    1514import org.openmrs.module.mrngen.MRNSequenceResponse; 
    16 import org.openmrs.util.OpenmrsUtil; 
    1715import org.springframework.aop.Advisor; 
    1816import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor; 
    19 import org.springframework.validation.BindException; 
     17import org.openmrs.patient.IdentifierValidator; 
     18import org.openmrs.module.ModuleException; 
     19import org.openmrs.PatientIdentifier; 
    2020 
    2121/** 
     
    2424 * @author Ratnakar Malla 
    2525 * @vesrion 1.0 
     26 * 08/30/2008: rmalla : Modified to add check digit only if a validator exists. 
    2627 */ 
    2728public class PatientServiceAroundAdvisor extends StaticMethodMatcherPointcutAdvisor implements Advisor { 
     
    5354                        Object[] obj = invocation.getArguments(); 
    5455                        org.openmrs.Patient patient= (org.openmrs.Patient)obj[0]; 
    55                         System.out.println("** PatientServiceAroundAdvice patient==null " + (patient==null)); 
    5656                        Set<PatientIdentifier> piSet = patient.getIdentifiers(); 
    57                         System.out.println("** PatientServiceAroundAdvice piSet==null " + (piSet==null)); 
    5857                        Iterator<PatientIdentifier> piSetIterator = piSet.iterator(); 
    5958                        while(piSetIterator.hasNext()) 
    6059                        { 
    6160                                PatientIdentifier pi = piSetIterator.next(); 
    62                                 System.out.println("** PatientServiceAroundAdvice pi.getIdentifier() " + (pi.getIdentifier()==null)); 
    6361                                if (pi.getIdentifier().contains("TEMPID_WILL_BE_REPLACED")) 
    6462                                { 
     
    6664                                        MRNSequenceResponse mrsr = new MRNGenUtil().generateIDs(1,""+pi.getIdentifierType().getPatientIdentifierTypeId()).get(0); 
    6765                                        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); 
    6977                                } 
    7078                        } 
     
    7482                        try 
    7583                        { 
    76                                 System.out.println("** invocation=null " + (invocation==null));  
    7784                                o =invocation.proceed(); 
    78                                 System.out.println("** invocation=null End " ); 
    7985                        }catch (Exception e) 
    8086                        { 
     
    8995        } 
    9096         
    91          
    92          
     97          
    9398} 
  • openmrs-modules/mrngen/src/org/openmrs/module/mrngen/db/hibernate/HibernateMRNSequenceDAO.java

    r4570 r5410  
    1010import org.hibernate.SessionFactory; 
    1111import org.openmrs.DataEntryStatistic; 
     12import org.openmrs.PatientIdentifierType; 
    1213import org.openmrs.api.db.DAOException; 
    1314import org.openmrs.module.mrngen.MRNSequenceResponse; 
    1415import org.openmrs.module.mrngen.MRNSequenceResponseDerived; 
    1516import 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 */ 
    1626 
    1727public class HibernateMRNSequenceDAO implements MRNSequenceDAO { 
     
    7282        { 
    7383                 
    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"; 
    7587                Query q = sessionFactory.getCurrentSession().createQuery(hql); 
    7688                q.setInteger("patientIdentifierTypeId", Integer.parseInt(patientIdentifierTypeId)); 
     
    107119                        s.setPatientIdentifierTypeId(pidTypeId); 
    108120                        String setupComplete=null; 
    109                         if (holder[0]!=null) 
     121                        if (holder[4]!=null) 
    110122                        { 
    111123                                setupComplete = (String)holder[4]; 
     
    113125                        s.setSetupcomplete(setupComplete); 
    114126                         
     127                        PatientIdentifierType pitype = null; 
     128                        if (holder[5]!=null) 
     129                        { 
     130                                s.setPatientIdentifierType((PatientIdentifierType)holder[5]); 
     131                        } 
     132                                                 
    115133                        derivedList.add(s); 
    116134                } 
  • openmrs-modules/mrngen/web/src/org/openmrs/module/mrngen/web/MRNGenFormController.java

    r4639 r5410  
    2727import org.springframework.web.servlet.ModelAndView; 
    2828import org.springframework.web.servlet.mvc.SimpleFormController; 
     29import org.openmrs.patient.IdentifierValidator; 
    2930 
    3031/** 
     
    3435 * Spring Form for Bulk MRN Generator  
    3536 * @version 1.0 
     37 * 08/30/2008: rmalla : Modified to add check digit only if a validator exists. 
    3638 */ 
    3739 
     
    7981                        HttpServletResponse response, Object obj, BindException errors) 
    8082                        throws Exception { 
    81                          
    82                         log.error("Inside onSubmit MRNGenFormController0"); 
    8383                 
    84                      String site = request.getParameter("site"); 
     84                      String site = request.getParameter("site"); 
    8585                        String first = request.getParameter("mrn_first"); 
    8686                        String count = request.getParameter("mrn_count"); 
     
    150150                                 
    151151                                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); 
    155159                                } 
    156                                 catch (Exception e) { 
    157                                         throw new ServletException(e); 
    158                                 } 
    159                                 line = line + "-" + checkdigit;   
    160160                                 
    161161                                response.getOutputStream().println(line);