[Object DataSources] Patient

This recipe shows how to display patient list by birth year using Object DataSource.

Important: Please remember to drop Patient.jar into the ext folder.

Steps taken:

  1. Create an Object DataSource (dsPatient_List_By_BirthYear.ds).
  2. In the “DataSource Wizard > JavaScript” tab, enter the following script:function pushTo(cxt,dl)
    {
    dl.startData(this);
    importClass(Packages.demo.Clinic);
    //Selection using start year to end year
    var start = new java.lang.Integer(${begain##1950});
    var end = new java.lang.Integer(${end##1960});
    var dIter =new Clinic().getPatients(start,end);
    while (dIter.hasNext())
    {
    rec = this.newRecordInstance();
    data = rec.getData();
    dataObj = dIter.next();
    data[0] = dataObj.getAddress();
    data[1] = dataObj.getID();
    data[2] = dataObj.getYearOfBirth();
    data[3] = dataObj.getFirstName();
    data[4] = dataObj.getLastName();
    data[5] = dataObj.getSex();
    dl.processRecord(rec);
    }
    dl.endData(this);
    }
  3. Create a report template (Patient_List_By_BirthYear.rml) using the Object DataSource. Upon rendering, the patient list according to birth year will display.

To download the necessary files for this recipe, refer to the attached ZIP package.
Patient.zip