Accessing records

To access a record, use one of the methods in EncountersDAO. These methods usually take the encounter id or patient id and populate an instance of the form class with the data. To access a form by Id (from FormDisplayAction):

BaseEncounter encounter = (BaseEncounter)EncountersDAO.getOneById(encounterId, new Long(formId), clazz);

Once the encounter is loaded, you may forward the encounter in the request and access its properties via the jsp. The properties in each form class are usually the column name. (In ZEPRS, it is simply the work "field" concatenated with the id of the form field.)

Dynasite generates two packages of code:

  • org.cidrz.project.zeprs.valueobject.gen - a one-to-one representation of the form, using the same data types as in the form.
  • org.cidrz.project.zeprs.valueobject.report.gen - each enumeration has an additional String version. This is veery useful when creating reports, because you can populate the String version with the value of the enumeration id.

Since the ZEPRS application uses the old property naming convention of "field" + id, the org.cidrz.project.zeprs.valueobject.report.gen classes use the table column instead for the property name (surname_6R rather than field6). Other Zcore implementations use only the table column for property names.

Code examples

The form classes can be a convenient way to generate reports. The following code from ChooseReportAction generates delivery summary reports using that form's DeliverySumReport class.

List records = ReportDAO.getAll(beginDate, endDate, siteId, 66, DeliverySumReport.class);

To access a list of Admin records and use paging:

List items = EncountersDAO.getAll(conn, formId, "SQL_RETRIEVE_ALL_ADMIN" + formId, className, maxRows, offset);