Advertisement
Guest User

12345

a guest
Dec 6th, 2016
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.45 KB | None | 0 0
  1. package inClass20.inClass20;
  2.  
  3. import java.io.IOException;
  4. import java.time.LocalDateTime;
  5.  
  6. import javax.swing.JOptionPane;
  7.  
  8. import edu.unl.cse.soft160.rest_connector.connector.ObservationRecord;
  9. import edu.unl.cse.soft160.rest_connector.connector.OpenMRSConnection;
  10. import edu.unl.cse.soft160.rest_connector.connector.PatientRecord;
  11.  
  12. public class LatestHeartRate {
  13. public static void main(String... arguments) throws IOException {
  14. String serverURI = JOptionPane.showInputDialog("Enter OpenMRS Server URI");
  15. String username = JOptionPane.showInputDialog("Enter username");
  16. String password = JOptionPane.showInputDialog("Enter password");
  17. String patientID = "";
  18. // System.out.println(
  19. // "System test for retrieving biographical data and observations for
  20. // patient 10000X on the default server:");
  21. // System.out.println();
  22. // OpenMRSConnection connection = new
  23. // OpenMRSConnection("localhost:8080", "admin", "Admin123");
  24. OpenMRSConnection connection;
  25. if (serverURI == null || username == null || password == null) {
  26. JOptionPane.showMessageDialog(null, "no report");
  27. }
  28. try {
  29. connection = new OpenMRSConnection(serverURI, username, password);
  30.  
  31. } catch (java.net.ProtocolException e) {
  32. JOptionPane.showMessageDialog(null, "Invalid credentials.");
  33. return;
  34. } catch (java.net.ConnectException e) {
  35. JOptionPane.showMessageDialog(null, "Could not contact server");
  36. return;
  37. } catch (java.io.FileNotFoundException e) {
  38. JOptionPane.showMessageDialog(null, "Could not contact server");
  39. return;
  40. } catch (java.lang.NullPointerException e) {
  41. return;
  42. }
  43.  
  44. try {
  45. patientID = JOptionPane.showInputDialog("Enter patient ID");
  46. // PatientRecord patientRecord =
  47. // connection.getPatientRecord("10000X");
  48. String hr = "";
  49. LocalDateTime last = LocalDateTime.MIN;
  50. PatientRecord patientRecord = connection.getPatientRecord(patientID);
  51. for (ObservationRecord observationRecord : connection.getObservationRecords(patientRecord.getUUID())) {
  52. // String suffix = observationRecord.getMeasurement() == null ?
  53. // : " = " + observationRecord.getMeasurement().toString();
  54. if (observationRecord.getConcept().equals("Pulse")) {
  55. if (last.isBefore(observationRecord.getTimestamp())) {
  56. last = observationRecord.getTimestamp();
  57. hr = observationRecord.getMeasurement().toString();
  58. }
  59. }
  60. // Patient [ID] had a heart rate of [HR] beats per minute at
  61. // [TIMESTAMP]
  62. }
  63. System.out.println("Patient" + patientID + " had a heart rate of " + hr + " beats per minute at " + last);
  64.  
  65. } catch (IllegalArgumentException e) {
  66. JOptionPane.showMessageDialog(null,
  67. "Patient ID " + patientID + " is malformed; it should be alphanumeric.");
  68. return;
  69. } catch (java.lang.NullPointerException e) {
  70. JOptionPane.showMessageDialog(null, "no report");
  71. return;
  72. }
  73.  
  74. // System.out.println(" UUID: " + patientRecord.getUUID());
  75. // System.out.println(" Family Name: " + patientRecord.getFamilyName());
  76. // System.out.println(" Given Name: " + patientRecord.getGivenName());
  77. // System.out.println(" Birth Date: " + patientRecord.getBirthDate());
  78. // System.out.println(" Deceased: " + patientRecord.getDeceased());
  79. // System.out.println(" Location: " + patientRecord.getLocation());
  80.  
  81. // System.out.println();
  82. // System.out.println("(Output should match data accessible for patient
  83. // " + patientID
  84. // + " through the patient dashboard.)");
  85. }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement