Advertisement
Guest User

Untitled

a guest
May 16th, 2018
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. package com.test;
  2.  
  3. import java.io.File;
  4. import java.util.List;
  5. import java.util.Properties;
  6.  
  7. import org.openmrs.Patient;
  8. import org.openmrs.api.context.Context;
  9. import org.openmrs.module.ModuleMustStartException;
  10. import org.openmrs.util.DatabaseUpdateException;
  11. import org.openmrs.util.InputRequiredException;
  12. import org.openmrs.util.OpenmrsUtil;
  13.  
  14. public class Test {
  15.  
  16. public static void main(String [] args) throws ModuleMustStartException, DatabaseUpdateException, InputRequiredException {
  17.  
  18.  
  19. File propsFile = new File(OpenmrsUtil.getApplicationDataDirectory(), "openmrs-runtime.properties");
  20. Properties props = new Properties();
  21. OpenmrsUtil.loadProperties(props, propsFile);
  22. Context.startup("jdbc:mysql://localhost:3306/openmrs?autoReconnect=true", "root", "onlylord", props);
  23. try {
  24.  
  25.  
  26. Context.openSession();
  27. Context.authenticate("admin", "Admin123");
  28. List<Patient> patients = Context.getPatientService().getPatients("John");
  29. for (Patient patient : patients) {
  30. System.out.println("Found patient with name " + patient.getPersonName() + " and uuid: " + patient.getUuid());
  31. }
  32.  
  33. }
  34. finally {
  35. Context.closeSession();
  36. }
  37.  
  38.  
  39.  
  40.  
  41. }
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement