Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.test;
- import java.io.File;
- import java.util.List;
- import java.util.Properties;
- import org.openmrs.Patient;
- import org.openmrs.api.context.Context;
- import org.openmrs.module.ModuleMustStartException;
- import org.openmrs.util.DatabaseUpdateException;
- import org.openmrs.util.InputRequiredException;
- import org.openmrs.util.OpenmrsUtil;
- public class Test {
- public static void main(String [] args) throws ModuleMustStartException, DatabaseUpdateException, InputRequiredException {
- File propsFile = new File(OpenmrsUtil.getApplicationDataDirectory(), "openmrs-runtime.properties");
- Properties props = new Properties();
- OpenmrsUtil.loadProperties(props, propsFile);
- Context.startup("jdbc:mysql://localhost:3306/openmrs?autoReconnect=true", "root", "onlylord", props);
- try {
- Context.openSession();
- Context.authenticate("admin", "Admin123");
- 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();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement