Skip to content
Permalink
Browse files

Indexed patient's Appointments and returned them to the client side

  • Loading branch information
k-joseph committed Jul 3, 2015
1 parent ca1befb commit 868e21c6a7f56c066f4fde8843e83ca360fbc2a2
@@ -1,4 +1,5 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
@@ -14,25 +15,29 @@

<dependencies>

<!-- Add other dependencies from parent's pom:
<dependency>
<groupId>org.other.library</groupId>
<artifactId>library-name</artifactId>
</dependency> -->

<!-- Add other dependencies from parent's pom: <dependency> <groupId>org.other.library</groupId>
<artifactId>library-name</artifactId> </dependency> -->

<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-server</artifactId>
<version>${project.parent.version}</version>
</dependency>

<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>allergyapi-api</artifactId>
<version>${allergyapiVersion}</version>
<type>jar</type>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>allergyapi-api</artifactId>
<version>${allergyapiVersion}</version>
<type>jar</type>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>appointmentscheduling-api</artifactId>
<version>${appointmentschedulingVersion}</version>
<scope>provided</scope>
</dependency>

</dependencies>

@@ -0,0 +1,106 @@
/**
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
*
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
* graphic logo is a trademark of OpenMRS Inc.
*/
package org.openmrs.module.chartsearch;

import java.util.Date;

public class AppointmentItem extends ChartListItem {

private String reason;

private Integer appointmentId;

private String status;

private Date start;

private Date end;

private String type;

private String typeDesc;

private String cancelReason;

private String provider;

public String getReason() {
return reason;
}

public void setReason(String reason) {
this.reason = reason;
}

public Integer getAppointmentId() {
return appointmentId;
}

public void setAppointmentId(Integer appointmentId) {
this.appointmentId = appointmentId;
}

public String getStatus() {
return status;
}

public void setStatus(String status) {
this.status = status;
}

public Date getStart() {
return start;
}

public void setStart(Date start) {
this.start = start;
}

public Date getEnd() {
return end;
}

public void setEnd(Date end) {
this.end = end;
}

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

public String getTypeDesc() {
return typeDesc;
}

public void setTypeDesc(String typeDesc) {
this.typeDesc = typeDesc;
}

public String getCancelReason() {
return cancelReason;
}

public void setCancelReason(String cancelReason) {
this.cancelReason = cancelReason;
}

public String getProvider() {
return provider;
}

public void setProvider(String provider) {
this.provider = provider;
}

}
@@ -54,7 +54,6 @@ public static ChartSearchService getChartSearchService() {
public static String generateJson(boolean wholePageIsToBeLoaded) {

JSONObject jsonToReturn = new JSONObject();
@SuppressWarnings("rawtypes")
List<ChartListItem> returnedResults = SearchAPI.getInstance().getResults();
boolean foundNoResults = false;
JSONObject noResults = new JSONObject();
@@ -92,6 +91,7 @@ public static String generateJson(boolean wholePageIsToBeLoaded) {
List<String> catNms = SearchAPI.getSelectedCategoryNames();
String[] appliedCats = new String[catNms.size()];
JSONArray allergies = generateAllergiesJSONFromResults(returnedResults);
JSONArray appointments = generateAppointmentsJSONFromResults(returnedResults);

jsonToReturn.put("noResults", noResults);
jsonToReturn.put("retrievalTime", SearchAPI.getInstance().getRetrievalTime());
@@ -100,6 +100,7 @@ public static String generateJson(boolean wholePageIsToBeLoaded) {
jsonToReturn.put("searchBookmarks", bookmarks);
jsonToReturn.put("appliedFacets", (String[]) catNms.toArray(appliedCats));
jsonToReturn.put("patientAllergies", allergies);
jsonToReturn.put("patientAppointments", appointments);

addBothPersonalAndGlobalNotesToJSON(searchPhrase, patientId, jsonToReturn, wholePageIsToBeLoaded);

@@ -552,6 +553,33 @@ public static JSONArray generateAllergiesJSONFromResults(List<ChartListItem> ret
return allergies;
}

private static JSONArray generateAppointmentsJSONFromResults(List<ChartListItem> returnedResults) {
JSONArray appointments = new JSONArray();

for (ChartListItem item : returnedResults) {
if (item != null && item instanceof AppointmentItem) {
AppointmentItem appointment = (AppointmentItem) item;
JSONObject json = new JSONObject();
if (appointment.getAppointmentId() != null) {
json.put("id", appointment.getAppointmentId());
json.put("uuid", appointment.getUuid());
json.put("status", appointment.getStatus());
json.put("reason", appointment.getReason());
json.put("type", appointment.getType());
json.put("start", appointment.getStart().getTime());
json.put("end", appointment.getEnd().getTime());
json.put("typeDesc", appointment.getTypeDesc());
json.put("cancelReason", appointment.getCancelReason());
json.put("provider", appointment.getProvider());

appointments.add(json);
}
}
}

return appointments;
}

public static JSONObject generateLocationJson(String location) {
JSONObject jsonLocation = new JSONObject();
jsonLocation.put("location", location);

0 comments on commit 868e21c

Please sign in to comment.
You can’t perform that action at this time.