Skip to content

Commit

Permalink
UHM-1172 Fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
pamcdm committed Apr 1, 2014
1 parent b831062 commit 4f12a8c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,20 @@
*/
package org.openmrs.module.appointmentscheduling;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.Predicate;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.openmrs.BaseOpenmrsData;
import org.openmrs.BaseOpenmrsMetadata;
import org.openmrs.BaseOpenmrsObject;
import org.openmrs.Patient;
import org.openmrs.Visit;
import org.openmrs.module.appointmentscheduling.serialize.AppointmentStatusSerializer;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
* It is a model class. It should extend either {@link BaseOpenmrsObject} or
Expand All @@ -35,42 +37,41 @@ public class Appointment extends BaseOpenmrsData implements Serializable {
private static final long serialVersionUID = 1L;

// TODO confirm that "WALK-IN" should be considered active
@JsonSerialize(using = AppointmentStatusSerializer.class)
public enum AppointmentStatus {
SCHEDULED("Scheduled", false, false), RESCHEDULED("Rescheduled", false, false), WALKIN("Walk-In", false, true), CANCELLED(
"Cancelled", true, false), WAITING("Waiting", false, true), INCONSULTATION("In-Consultation", false, true), COMPLETED(
"Completed", false, false), MISSED("Missed", false, false), CANCELLED_AND_NEEDS_RESCHEDULE(
"Cancelled and Needs Reschedule", true, false);

private final String name;

/**
* Whether or not an appointment with this status should be considered "cancelled" Cancelled
* statuses: CANCELLED, CANCELLED_AND_NEEDS_RESCHEDULE
*/
private Boolean cancelled;
private boolean cancelled;

/**
* Whether or not an appointment with this status is an "active" appointment, where
* active=patient checked-in and present within the health facility Active statuses: WALKIN,
* WAITING, INCONSULTATION
*/
private Boolean active;
private boolean active;

private AppointmentStatus(final String name, final Boolean cancelled, final Boolean active) {
private AppointmentStatus(final String name, final boolean cancelled, final boolean active) {
this.name = name;
this.cancelled = cancelled;
this.active = active;
}

public String getName() {
return this.name;
}

public Boolean isCancelled() {
public boolean isCancelled() {
return this.cancelled;
}

public Boolean isActive() {
public boolean isActive() {
return this.active;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.openmrs.module.appointmentscheduling.serialize;

import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.JsonSerializer;
import org.codehaus.jackson.map.SerializerProvider;
import org.openmrs.module.appointmentscheduling.Appointment;

import java.io.IOException;

public class AppointmentStatusSerializer extends JsonSerializer<Appointment.AppointmentStatus> {


@Override
public void serialize(Appointment.AppointmentStatus appointmentStatus, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException, JsonProcessingException {

jsonGenerator.writeStartObject();
jsonGenerator.writeFieldName("name");
jsonGenerator.writeString(appointmentStatus.getName());
jsonGenerator.writeFieldName("active");
jsonGenerator.writeBoolean(appointmentStatus.isActive());
jsonGenerator.writeFieldName("cancelled");
jsonGenerator.writeBoolean(appointmentStatus.isActive());
jsonGenerator.writeEndObject();
}
}

0 comments on commit 4f12a8c

Please sign in to comment.