Skip to content

Commit

Permalink
Rename Appointment to PatientAppointment and associated CRUD service …
Browse files Browse the repository at this point in the history
…met… (#43)
  • Loading branch information
mseaton authored Sep 15, 2023
1 parent 1516107 commit 9ba5254
Show file tree
Hide file tree
Showing 56 changed files with 467 additions and 471 deletions.
2 changes: 1 addition & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.openmrs.module</groupId>
<artifactId>appointmentscheduling</artifactId>
<version>1.18.0-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>
</parent>

<artifactId>appointmentscheduling-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
import java.util.Date;

import org.openmrs.BaseOpenmrsData;
import org.openmrs.module.appointmentscheduling.Appointment.AppointmentStatus;
import org.openmrs.module.appointmentscheduling.PatientAppointment.AppointmentStatus;

public class AppointmentStatusHistory extends BaseOpenmrsData {

private static final long serialVersionUID = 1L;

private Integer appointmentStatusHistoryId;

private Appointment appointment;
private PatientAppointment appointment;

private AppointmentStatus status;

Expand All @@ -36,7 +36,7 @@ public AppointmentStatusHistory() {

}

public AppointmentStatusHistory(Appointment appointment, AppointmentStatus status, Date startDate, Date endDate) {
public AppointmentStatusHistory(PatientAppointment appointment, AppointmentStatus status, Date startDate, Date endDate) {
setAppointment(appointment);
setStatus(status);
setStartDate(startDate);
Expand Down Expand Up @@ -91,11 +91,11 @@ public void setEndDate(Date endDate) {
this.endDate = endDate;
}

public Appointment getAppointment() {
public PatientAppointment getAppointment() {
return appointment;
}

public void setAppointment(Appointment appointment) {
public void setAppointment(PatientAppointment appointment) {
this.appointment = appointment;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* It is a model class. It should extend either {@link BaseOpenmrsObject} or
* {@link BaseOpenmrsMetadata}.
*/
public class Appointment extends BaseOpenmrsData implements Serializable {
public class PatientAppointment extends BaseOpenmrsData implements Serializable {

private static final long serialVersionUID = 1L;

Expand Down Expand Up @@ -121,16 +121,16 @@ public static List<AppointmentStatus> getNotCancelledAppointmentStatuses() {

private AppointmentType appointmentType;

public Appointment() {
public PatientAppointment() {

}

public Appointment(Integer appointmentId) {
public PatientAppointment(Integer appointmentId) {
setId(appointmentId);
}

public Appointment(TimeSlot timeSlot, Visit visit, Patient patient,
AppointmentType appointmentType, AppointmentStatus status) {
public PatientAppointment(TimeSlot timeSlot, Visit visit, Patient patient,
AppointmentType appointmentType, AppointmentStatus status) {
setTimeSlot(timeSlot);
setVisit(visit);
setPatient(patient);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import org.openmrs.annotation.Authorized;
import org.openmrs.api.APIException;
import org.openmrs.api.OpenmrsService;
import org.openmrs.module.appointmentscheduling.Appointment;
import org.openmrs.module.appointmentscheduling.Appointment.AppointmentStatus;
import org.openmrs.module.appointmentscheduling.PatientAppointment;
import org.openmrs.module.appointmentscheduling.PatientAppointment.AppointmentStatus;
import org.openmrs.module.appointmentscheduling.AppointmentBlock;
import org.openmrs.module.appointmentscheduling.AppointmentDailyCount;
import org.openmrs.module.appointmentscheduling.AppointmentRequest;
Expand Down Expand Up @@ -292,7 +292,7 @@ List<AppointmentBlock> getOverlappingAppointmentBlocks(
* <strong>Should</strong> get all appointment
*/
@Authorized(AppointmentUtils.PRIV_VIEW_APPOINTMENTS)
List<Appointment> getAllAppointments();
List<PatientAppointment> getAllPatientAppointments();

/**
* Get all appointments based on includeVoided flag
Expand All @@ -302,7 +302,7 @@ List<AppointmentBlock> getOverlappingAppointmentBlocks(
* <strong>Should</strong> get all appointments based on include voided flag.
*/
@Authorized(AppointmentUtils.PRIV_VIEW_APPOINTMENTS)
public List<Appointment> getAllAppointments(boolean includeVoided);
public List<PatientAppointment> getAllPatientAppointments(boolean includeVoided);

/**
* Gets an appointment by its appointment id.
Expand All @@ -312,7 +312,7 @@ List<AppointmentBlock> getOverlappingAppointmentBlocks(
* <strong>Should</strong> get correct appointment
*/
@Authorized(AppointmentUtils.PRIV_VIEW_APPOINTMENTS)
Appointment getAppointment(Integer appointmentId);
PatientAppointment getPatientAppointment(Integer appointmentId);

/**
* Gets an appointment by its UUID.
Expand All @@ -322,7 +322,7 @@ List<AppointmentBlock> getOverlappingAppointmentBlocks(
* <strong>Should</strong> get correct appointment
*/
@Authorized(AppointmentUtils.PRIV_VIEW_APPOINTMENTS)
Appointment getAppointmentByUuid(String uuid);
PatientAppointment getPatientAppointmentByUuid(String uuid);

/**
* Creates or updates the given appointment in the database.
Expand All @@ -333,7 +333,7 @@ List<AppointmentBlock> getOverlappingAppointmentBlocks(
* <strong>Should</strong> save edited appointment
*/
@Authorized(AppointmentUtils.PRIV_SCHEDULE_APPOINTMENTS)
Appointment saveAppointment(Appointment appointment) throws APIException;
PatientAppointment savePatientAppointment(PatientAppointment appointment) throws APIException;

/**
* Voids a given appointment.
Expand All @@ -344,7 +344,7 @@ List<AppointmentBlock> getOverlappingAppointmentBlocks(
* <strong>Should</strong> void given appointment
*/
@Authorized(AppointmentUtils.PRIV_SCHEDULE_APPOINTMENTS)
Appointment voidAppointment(Appointment appointment, String reason);
PatientAppointment voidPatientAppointment(PatientAppointment appointment, String reason);

/**
* Unvoids an appointment.
Expand All @@ -354,7 +354,7 @@ List<AppointmentBlock> getOverlappingAppointmentBlocks(
* <strong>Should</strong> unvoid given appointment
*/
@Authorized(AppointmentUtils.PRIV_SCHEDULE_APPOINTMENTS)
Appointment unvoidAppointment(Appointment appointment);
PatientAppointment unvoidPatientAppointment(PatientAppointment appointment);

/**
* Completely removes an appointment from the database. This is not reversible.
Expand All @@ -363,26 +363,26 @@ List<AppointmentBlock> getOverlappingAppointmentBlocks(
* <strong>Should</strong> delete given appointment
*/
@Authorized(AppointmentUtils.PRIV_SCHEDULE_APPOINTMENTS)
void purgeAppointment(Appointment appointment);
void purgePatientAppointment(PatientAppointment appointment);

/**
* Returns all Appointments for a given Patient
*
* @param patientId the patient id to search by.
* @param patient the patient id to search by.
* @return all the appointments for the given patient id.
* <strong>Should</strong> return all of the appointments for the given patient.
*/
@Authorized(AppointmentUtils.PRIV_VIEW_APPOINTMENTS)
List<Appointment> getAppointmentsOfPatient(Patient patient);
List<PatientAppointment> getAppointmentsOfPatient(Patient patient);

/**
* Returns the appointment corresponding to the given visit.
*
* @param visitId the visit id to search by.
* @param visit the visit id to search by.
* @return the appointment that is related to this visit, null if there isnt any.
*/
@Authorized(AppointmentUtils.PRIV_VIEW_APPOINTMENTS)
Appointment getAppointmentByVisit(Visit visit);
PatientAppointment getAppointmentByVisit(Visit visit);

// TimeSlot

Expand Down Expand Up @@ -474,7 +474,7 @@ List<AppointmentBlock> getOverlappingAppointmentBlocks(
* <strong>Should</strong> not return voided appointments
*/
@Authorized(AppointmentUtils.PRIV_VIEW_APPOINTMENTS)
List<Appointment> getAppointmentsInTimeSlot(TimeSlot timeSlot);
List<PatientAppointment> getAppointmentsInTimeSlot(TimeSlot timeSlot);

/**
* Should retrieve all appointments in the given time slot that do not have a status that means
Expand All @@ -486,7 +486,7 @@ List<AppointmentBlock> getOverlappingAppointmentBlocks(
* <strong>Should</strong> not return voided appointments
*/
@Authorized(AppointmentUtils.PRIV_VIEW_APPOINTMENTS)
List<Appointment> getAppointmentsInTimeSlotThatAreNotCancelled(
List<PatientAppointment> getAppointmentsInTimeSlotThatAreNotCancelled(
TimeSlot timeSlot);

/**
Expand Down Expand Up @@ -670,7 +670,7 @@ List<AppointmentRequest> getAppointmentRequestsByConstraints(Patient patient, Ap
* @return The most recent appointment for the given patient, null if no appointments were set.
*/
@Authorized(AppointmentUtils.PRIV_VIEW_APPOINTMENTS)
Appointment getLastAppointment(Patient patient);
PatientAppointment getLastAppointment(Patient patient);

/**
* Return a list of time slots that stands within the given constraints.
Expand Down Expand Up @@ -791,9 +791,9 @@ Set<Location> getAllLocationDescendants(Location location,
* <strong>Should</strong> sort by associated time slot
*/
@Authorized(AppointmentUtils.PRIV_VIEW_APPOINTMENTS)
List<Appointment> getAppointmentsByConstraints(Date fromDate, Date toDate,
Location location, Provider provider, AppointmentType type,
AppointmentStatus status) throws APIException;
List<PatientAppointment> getAppointmentsByConstraints(Date fromDate, Date toDate,
Location location, Provider provider, AppointmentType type,
AppointmentStatus status) throws APIException;

/**
* Retrieves Appointments that satisfy the given constraints
Expand All @@ -809,9 +809,9 @@ List<Appointment> getAppointmentsByConstraints(Date fromDate, Date toDate,
* <strong>Should</strong> sort by associated time slot
*/
@Authorized(AppointmentUtils.PRIV_VIEW_APPOINTMENTS)
List<Appointment> getAppointmentsByConstraints(Date fromDate, Date toDate,
Location location, Provider provider, AppointmentType type,
Patient patient, AppointmentStatus status) throws APIException;
List<PatientAppointment> getAppointmentsByConstraints(Date fromDate, Date toDate,
Location location, Provider provider, AppointmentType type,
Patient patient, AppointmentStatus status) throws APIException;

/**
* Retrieves Appointments that satisfy the given constraints
Expand All @@ -827,9 +827,9 @@ List<Appointment> getAppointmentsByConstraints(Date fromDate, Date toDate,
* <strong>Should</strong> sort by associated time slot
*/
@Authorized(AppointmentUtils.PRIV_VIEW_APPOINTMENTS)
List<Appointment> getAppointmentsByConstraints(Date fromDate, Date toDate,
Location location, Provider provider, AppointmentType type,
Patient patient, List<AppointmentStatus> appointmentStatuses);
List<PatientAppointment> getAppointmentsByConstraints(Date fromDate, Date toDate,
Location location, Provider provider, AppointmentType type,
Patient patient, List<AppointmentStatus> appointmentStatuses);

/**
* Retrieves Appointments that satisfy the given constraints
Expand All @@ -847,18 +847,18 @@ List<Appointment> getAppointmentsByConstraints(Date fromDate, Date toDate,
* <strong>Should</strong> sort by associated time slot
*/
@Authorized(AppointmentUtils.PRIV_VIEW_APPOINTMENTS)
List<Appointment> getAppointmentsByConstraints(Date fromDate, Date toDate,
Location location, Provider provider, AppointmentType type,
Patient patient, List<AppointmentStatus> appointmentStatuses,
VisitType visitType, Visit visit) throws APIException;
List<PatientAppointment> getAppointmentsByConstraints(Date fromDate, Date toDate,
Location location, Provider provider, AppointmentType type,
Patient patient, List<AppointmentStatus> appointmentStatuses,
VisitType visitType, Visit visit) throws APIException;
/**
* Retrives the start date of the current status of a given appointment.
*
* @param appointment - The appointment.
* @return the start date of the current status of a given appointment.
*/
@Authorized(AppointmentUtils.PRIV_VIEW_APPOINTMENTS)
Date getAppointmentCurrentStatusStartDate(Appointment appointment);
Date getAppointmentCurrentStatusStartDate(PatientAppointment appointment);

/**
* Changes the given appointment status.
Expand All @@ -867,8 +867,8 @@ List<Appointment> getAppointmentsByConstraints(Date fromDate, Date toDate,
* @param newStatus - The new status
*/
@Authorized(AppointmentUtils.PRIV_SCHEDULE_APPOINTMENTS)
void changeAppointmentStatus(Appointment appointment,
AppointmentStatus newStatus);
void changeAppointmentStatus(PatientAppointment appointment,
AppointmentStatus newStatus);

/**
* Computes the average duration (in Minutes) of a status history by appointment type
Expand Down Expand Up @@ -945,7 +945,7 @@ public Map<AppointmentType, Integer> getAppointmentTypeDistribution(
* @return list of unvoided appointments that their current status is one of the given states.
*/
@Authorized(AppointmentUtils.PRIV_VIEW_APPOINTMENTS)
List<Appointment> getAppointmentsByStatus(List<AppointmentStatus> states);
List<PatientAppointment> getAppointmentsByStatus(List<AppointmentStatus> states);

/**
* Update the status of PAST appointments according to the following conditions: "SCHEDULED"
Expand All @@ -955,7 +955,7 @@ public Map<AppointmentType, Integer> getAppointmentTypeDistribution(
* @return List of the updated appointments
*/
@Authorized(AppointmentUtils.PRIV_SCHEDULE_APPOINTMENTS)
List<Appointment> cleanOpenAppointments();
List<PatientAppointment> cleanOpenAppointments();

@Authorized(AppointmentUtils.PRIV_VIEW_APPOINTMENTS)
boolean verifyDuplicatedAppointmentTypeName(AppointmentType appointmentType);
Expand All @@ -967,7 +967,7 @@ public Map<AppointmentType, Integer> getAppointmentTypeDistribution(
* @return
*/
@Authorized(AppointmentUtils.PRIV_VIEW_APPOINTMENTS)
List<Appointment> getScheduledAppointmentsForPatient(Patient patient);
List<PatientAppointment> getScheduledAppointmentsForPatient(Patient patient);

/**
* Books a new appointment
Expand All @@ -980,7 +980,7 @@ public Map<AppointmentType, Integer> getAppointmentTypeDistribution(
* allowOverbook = false
*/
@Authorized(AppointmentUtils.PRIV_SCHEDULE_APPOINTMENTS)
Appointment bookAppointment(Appointment appointment, Boolean allowOverbook)
PatientAppointment bookAppointment(PatientAppointment appointment, Boolean allowOverbook)
throws TimeSlotFullException;

/**
Expand All @@ -989,28 +989,28 @@ Appointment bookAppointment(Appointment appointment, Boolean allowOverbook)
* @return
*/
@Authorized
List<AppointmentStatusHistory> getAppointmentStatusHistories(Appointment appointment);
List<AppointmentStatusHistory> getAppointmentStatusHistories(PatientAppointment appointment);

/**
* retrieves the most recent status of an appointment
* @param appointment
* @return
*/
@Authorized()
AppointmentStatusHistory getMostRecentAppointmentStatusHistory(Appointment appointment);
AppointmentStatusHistory getMostRecentAppointmentStatusHistory(PatientAppointment appointment);
/**
* returns list of early appointments
*/
@Authorized(AppointmentUtils.PRIV_VIEW_APPOINTMENTS)
List<Appointment> getEarlyAppointments(Date fromDate, Date toDate, Location location,
Provider provider, AppointmentType appointmentType) throws APIException;
List<PatientAppointment> getEarlyAppointments(Date fromDate, Date toDate, Location location,
Provider provider, AppointmentType appointmentType) throws APIException;

/**
* returns list of late appointments
*/
@Authorized(AppointmentUtils.PRIV_VIEW_APPOINTMENTS)
List<Appointment> getLateAppointments(Date fromDate, Date toDate, Location location,
Provider provider, AppointmentType appointmentType) throws APIException;
List<PatientAppointment> getLateAppointments(Date fromDate, Date toDate, Location location,
Provider provider, AppointmentType appointmentType) throws APIException;
/** returns list of appointments aggregated by date
* @param fromDate
* @param toDate
Expand Down
Loading

0 comments on commit 9ba5254

Please sign in to comment.