Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.openmrs.api.example;
- import org.openmrs.Patient;
- import org.openmrs.util.DatabaseUpdateException;
- import org.openmrs.util.InputRequiredException;
- import org.openmrs.util.OpenmrsUtil;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileNotFoundException;
- import java.util.List;
- import java.util.Properties;
- import org.openmrs.User;
- import static org.openmrs.api.context.Context.*;
- import static org.openmrs.api.context.Context.closeSession;
- import static org.openmrs.util.OpenmrsUtil.loadProperties;
- public class Example {
- public static void main(String[] args) throws FileNotFoundException, InputRequiredException, DatabaseUpdateException {
- File propsFile = new File("C:\\Users\\The Bright\\openmrs\\server1", "openmrs-runtime.properties");
- Properties props = new Properties();
- loadProperties(props, new FileInputStream(propsFile));
- //System.out.println(props);
- startup("jdbc:mysql://127.0.0.1:3306/server2?autoReconnect=true", "root", "root", props);
- try {
- openSession();
- authenticate("admin", "Admin123");
- List<User> users = getUserService().getAllUsers();
- for (User usr : users) {
- System.out.println("Found patient with name " + usr.getPersonName() + " and uuid: " + usr.getUuid());
- }
- } finally {
- closeSession();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement