Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register

Changeset 5294

Show
Ignore:
Timestamp:
08/16/08 15:01:43 (3 months ago)
Author:
sunbiz
Message:

registration: Fixed New Patient Registration's XPath Query

Files:

Legend:

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

    r5217 r5294  
    66    <id>registration</id> 
    77    <name>Registration Module</name> 
    8     <version>1.0</version> 
     8    <version>0.7</version> 
    99    <package>org.openmrs.module.@MODULE_ID@</package> 
    1010    <author>Saptarshi Purkayastha</author> 
  • openmrs-modules/registration/metadata/moduleApplicationContext.xml

    r5217 r5294  
    2626        <property name="sessionForm"><value>true</value></property> 
    2727        <property name="commandName"><value>patient</value></property> 
    28        <property name="successView"><value>registrationSummary.list</value></property> 
     28        <property name="successView"><value>registrationSummary.list</value></property> 
    2929        <property name="commandClass"><value>org.openmrs.module.registration.model.RegisterPatientModel</value></property> 
    3030        <property name="formView"><value>/module/@MODULE_ID@/registerPatientForm</value></property> 
  • openmrs-modules/registration/web/src/org/openmrs/module/registration/web/controller/RegisterPatientFormController.java

    r5259 r5294  
    3030import org.dom4j.io.SAXReader; 
    3131import org.dom4j.io.XMLWriter; 
     32import org.jaxen.XPath; 
     33import org.jaxen.dom4j.Dom4jXPath; 
    3234import org.openmrs.Location; 
    3335import org.openmrs.Patient; 
     
    6668        Location location = new Location(1); 
    6769        PatientIdentifierType identType = patientService.getPatientIdentifierType(1); 
    68         PatientIdentifier patientIdentifier = new PatientIdentifier(patientModel.getIdentifierString(), identType, location); 
     70        String patientIdentifierString = patientModel.getIdentifierString(); 
     71        PatientIdentifier patientIdentifier = new PatientIdentifier(patientIdentifierString, identType, location); 
    6972        openmrsPatient.addIdentifier(patientIdentifier); 
    7073 
     
    7982        Document document = reader.read(availableIDs.toURI().toURL()); 
    8083        Element root = document.getRootElement(); 
    81         List list = document.selectNodes("//patientIDs/available"); 
     84        XPath xpathSelector = new Dom4jXPath("//patientIDs/available"); 
     85        List list = xpathSelector.selectNodes(document); 
    8286        if (list.size() > 0) { 
    8387            Element usedNode = (Element) list.get(0); 
     
    9195        writer.write(document); 
    9296        writer.close(); 
    93          
     97 
    9498        patientService.savePatient(openmrsPatient); 
    95         return new ModelAndView(new RedirectView(getSuccessView())); 
     99        return new ModelAndView(new RedirectView(getSuccessView()+"?patientIdentifier="+patientIdentifierString)); 
    96100    } 
    97101 
     
    130134                    SAXReader reader = new SAXReader(); 
    131135                    Document document = reader.read(availableIDs.toURI().toURL()); 
    132                     Element root = document.getRootElement(); 
    133                     List list = document.selectNodes("//patientIDs/available"); 
     136                    XPath xpathSelector = new Dom4jXPath("//patientIDs/available"); 
     137                    List list = xpathSelector.selectNodes(document); 
    134138                    if (list.size() > 0) { 
    135139                        if (list.size() < 5) { 
    136                             registerPatientModel.setMessage("Very Few IDs ("+list.size()+") Left. Please Upload New IDs"); 
     140                            registerPatientModel.setMessage("Very Few IDs (" + list.size() + ") Left. Please Upload New IDs"); 
    137141                        } 
    138142                        registerPatientModel.setIdentifierString(((Element) list.get(0)).getText()); 
    139                     } 
    140                     else { 
     143                    } else { 
    141144                        registerPatientModel.setMessage("No Identifiers Left. Please Upload New IDs"); 
    142145                    } 
    143                 }else
     146                } else
    144147                    registerPatientModel.setMessage("AvailableIDs File Not Found. Please Upload Generated File from Options Page"); 
    145148                }