From 7cc945469a655eb37d0c4bf57c7c79581471e86d Mon Sep 17 00:00:00 2001 From: Brady James Garvin <bgarvin@cse.unl.edu> Date: Fri, 17 Nov 2017 15:57:58 -0600 Subject: [PATCH] Added support for retrieving a patient's gender. --- .../rest_connector/connector/OpenMRSConnection.java | 3 ++- .../soft160/rest_connector/connector/OpenMRSXPath.java | 4 ++++ .../rest_connector/connector/PatientRecord.java | 10 ++++++++-- .../rest_connector/AllPatientDataSystemTest.java | 1 + 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/rest_connector/src/main/java/edu/unl/cse/soft160/rest_connector/connector/OpenMRSConnection.java b/rest_connector/src/main/java/edu/unl/cse/soft160/rest_connector/connector/OpenMRSConnection.java index e8ba716..dfa3b0d 100644 --- a/rest_connector/src/main/java/edu/unl/cse/soft160/rest_connector/connector/OpenMRSConnection.java +++ b/rest_connector/src/main/java/edu/unl/cse/soft160/rest_connector/connector/OpenMRSConnection.java @@ -52,9 +52,10 @@ public class OpenMRSConnection { String familyName = getString(patientRecord, familyNameInPatientRecord()); String givenName = getString(patientRecord, givenNameInPatientRecord()); LocalDate birthDate = getDate(patientRecord, birthDateInPatientRecord()); + char genderCode = getString(patientRecord, genderCodeInPatientRecord()).charAt(0); Boolean deceased = getBoolean(patientRecord, deceasedFlagInPatientRecord()); String location = getString(visits, patientLocationInVisitDocument(uuid)); - return new PatientRecord(uuid, familyName, givenName, birthDate, deceased, location); + return new PatientRecord(uuid, familyName, givenName, birthDate, genderCode, deceased, location); } public Set<ObservationRecord> getObservationRecords(String patientUUID) throws IOException { diff --git a/rest_connector/src/main/java/edu/unl/cse/soft160/rest_connector/connector/OpenMRSXPath.java b/rest_connector/src/main/java/edu/unl/cse/soft160/rest_connector/connector/OpenMRSXPath.java index 8269d91..a64b02c 100644 --- a/rest_connector/src/main/java/edu/unl/cse/soft160/rest_connector/connector/OpenMRSXPath.java +++ b/rest_connector/src/main/java/edu/unl/cse/soft160/rest_connector/connector/OpenMRSXPath.java @@ -87,6 +87,10 @@ public class OpenMRSXPath { public static String birthDateInPatientRecord() { return path(RELATIVE, STRING.labeled("birthdate")); } + + public static String genderCodeInPatientRecord() { + return path(RELATIVE, STRING.labeled("gender")); + } public static String deceasedFlagInPatientRecord() { return path(RELATIVE, BOOLEAN.labeled("dead")); diff --git a/rest_connector/src/main/java/edu/unl/cse/soft160/rest_connector/connector/PatientRecord.java b/rest_connector/src/main/java/edu/unl/cse/soft160/rest_connector/connector/PatientRecord.java index 28315ed..238c0f7 100644 --- a/rest_connector/src/main/java/edu/unl/cse/soft160/rest_connector/connector/PatientRecord.java +++ b/rest_connector/src/main/java/edu/unl/cse/soft160/rest_connector/connector/PatientRecord.java @@ -7,15 +7,17 @@ public class PatientRecord { protected String familyName; protected String givenName; protected LocalDate birthDate; + protected char genderCode; protected Boolean deceased; protected String location; - public PatientRecord(String uuid, String familyName, String givenName, LocalDate birthDate, Boolean deceased, - String location) { + public PatientRecord(String uuid, String familyName, String givenName, LocalDate birthDate, char genderCode, + Boolean deceased, String location) { this.uuid = uuid; this.familyName = familyName; this.givenName = givenName; this.birthDate = birthDate; + this.genderCode = genderCode; this.deceased = deceased; this.location = location; } @@ -35,6 +37,10 @@ public class PatientRecord { public LocalDate getBirthDate() { return birthDate; } + + public char getGenderCode() { + return genderCode; + } public Boolean getDeceased() { return deceased; diff --git a/rest_connector/src/test/java/edu/unl/cse/soft160/rest_connector/AllPatientDataSystemTest.java b/rest_connector/src/test/java/edu/unl/cse/soft160/rest_connector/AllPatientDataSystemTest.java index eb15162..4d3fcb5 100644 --- a/rest_connector/src/test/java/edu/unl/cse/soft160/rest_connector/AllPatientDataSystemTest.java +++ b/rest_connector/src/test/java/edu/unl/cse/soft160/rest_connector/AllPatientDataSystemTest.java @@ -21,6 +21,7 @@ public class AllPatientDataSystemTest { System.out.println(" Family Name: " + patientRecord.getFamilyName()); System.out.println(" Given Name: " + patientRecord.getGivenName()); System.out.println(" Birth Date: " + patientRecord.getBirthDate()); + System.out.println(" Gender: " + patientRecord.getGenderCode()); System.out.println(" Deceased: " + patientRecord.getDeceased()); System.out.println(" Location: " + patientRecord.getLocation()); for (ObservationRecord observationRecord : connection.getObservationRecords(patientRecord.getUUID())) { -- GitLab