Wiki Spaces

Documentation
Projects
Resources

Get Help from Others

Q&A: Ask OpenMRS
Discussion: OpenMRS Talk
Real-Time: IRC Chat | Slack

Documentation

Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
public static void main(String[] args) {
  File propsFile = new File(OpenmrsUtil.getApplicationDataDirectory(), "openmrs-runtime.properties");**
  Properties props = new Properties();
  OpenmrsUtil.loadProperties(props, propsFile);
  Context.startup("jdbc:mysql://localhost:3306/db-name?autoReconnect=true", "openmrs-db-user", "3jknfjkn33ijt", propsFileprops);
  try {
    Context.openSession();
    Context.authenticate("admin", "test");
    List<Patient> patients = Context.getPatientService().getPatients("John");
    for (Patient patient : patients) {
      System.out.println("Found patient with name " + patient.getPersonName() + " and uuid: " + patient.getUuid());
    }
    ...
  }
  finally {
    Context.closeSession();
  }
}

...