Advertisement
Guest User

1234121

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