实施预约系统

时间:2018-04-14 11:36:47

标签: java mysql performance spring-mvc spring-boot

我正在开发一个用于移动应用的弹簧启动MVC REST API,该系统是在诊所预约的病人,我正在寻找显示医生可用时间问题的最佳解决方案。

问题定义:系统应允许用户从日历中选择,诊所,医生和具体日期(年/月/日),系统应显示选择日期的可用时间,预约持续时间为30分钟,从早上7点到下午6点。

更多澄清: 该系统由许多诊所和属于这些诊所的医生组成,每位医生都有固定的时间供用户预订。这些时间分为每个半小时预约的日期。用户不能同时在同一位医生处预订。

示例: 病人乔伊于2018年5月21日3:30预约了x医生的预约, 另一名患者杰克已经打开申请预约他选择了医生x并且他选择了与乔伊相同的日期(21-may-2018),系统将显示从早上7点到下午6点(7:00,7:30)的时间。 ,8:00,8:30 ......)排除3:30。

解决方案尝试: 1)在数据库中创建一个每年填充可用时间的工作,并用flag标记时间。 2)当客户询问可用时间时,系统迭代医生的所有预约并找到这些时间。 3)制作一个包含时间和日期的静态列表,当用户要求可用次数迭代约会时,从列表中删除属于约会的时间。 4)制作数据库日历。 5)让管理页面的用户从管理页面手动填写时间。 我尝试了所有这些可能的解决方案但我没有发现它们非常有效我正在寻找更好的解决方案。

代码示例:  控制器部分:

@Override
public List<String> getAvailableTimes(String date) {
    List<String> availableTimes = findAvailableTimes(date);

    if(availableTimes == null || availableTimes.isEmpty())
        throw new BackendException("No times available for the given date");

    return availableTimes;
}

private List<String> findAvailableTimes(String date){

    //TODO write the logic for findding the available times 
    return null;
}

服务实施:

 public interface AppointmentRepo extends IRepository<Appointment, Long> {

List<Appointment> findByCustomer(Customer customer);

     }

存储库:

@Entity
public class Appointment extends BaseEntity {

/**
 * 
 */
private static final long serialVersionUID = 1L;

private Date appoitmentDate;

// Relations
@ManyToOne(fetch = FetchType.LAZY)
private Doctor doctor;
@ManyToOne(fetch = FetchType.LAZY)
private Clinic clinic;
@ManyToOne(fetch = FetchType.LAZY)
private Customer customer;
@ManyToOne(fetch = FetchType.LAZY)
private Follower follower;
@ManyToOne(fetch = FetchType.LAZY)
private AppointmentStatus appointmentStatus;
@OneToOne(fetch = FetchType.LAZY)
private Report report;

// Setters and Getters
public Doctor getDoctor() {
    return doctor;
}

public void setDoctor(Doctor doctor) {
    this.doctor = doctor;
}

public Clinic getClinic() {
    return clinic;
}

public void setClinic(Clinic clinic) {
    this.clinic = clinic;
}

public Customer getCustomer() {
    return customer;
}

public void setCustomer(Customer customer) {
    this.customer = customer;
}

public Follower getFollower() {
    return follower;
}

public void setFollower(Follower follower) {
    this.follower = follower;
}

public Date getAppoitmentDate() {
    return appoitmentDate;
}

public void setAppoitmentDate(Date appoitmentDate) {
    this.appoitmentDate = appoitmentDate;
}

public AppointmentStatus getAppointmentStatus() {
    return appointmentStatus;
}

public void setAppointmentStatus(AppointmentStatus appointmentStatus) {
    this.appointmentStatus = appointmentStatus;
}

public Report getReport() {
    return report;
}

public void setReport(Report report) {
    this.report = report;
}

}

实体:

update_beta <- function(beta) {

    y <- matrix(nrow = n_words)

    result <- 0
    for (i in 1:n_topics) {
    for (d in 1:length(document)) {
      temp <- 0
      for (j in 1:n_topics) {
        temp <- temp + alpha_d[d,j] * sum(beta[,j]*Wdij[[d]][,j+2]) - r_d[d]
      }
      result <- result + temp[1] * alpha_d[d,i] * Wdij[[d]][,i+2]
    }
    y <- cbind(y, result)
    }
    y <- y[, -1]

    return(y)
}


# Some fake data
n_words <- 10
k <- 3
d <- 8
beta <- runif(n_words * k)  %>% matrix(., ncol = k)
Wdij <- lapply(1:d, function(x) {runif(n_words * k, min = 0, max = 1)  %>% 
matrix(., ncol = k)})
alpha_d <- runif(d * k) %>% matrix(., ncol = k, byrow = T)
r_d <- runif(d)

# Run
library(nleqslv)
beta_result <- nleqslv(beta, update_beta)

2 个答案:

答案 0 :(得分:1)

我有一个开源的调度实用程序库(适用于Android),可以处理数小时的业务和调度项目。它具有检查重复预订的功能,但到目前为止,它还没有直接的返回预约时间的机制,但我将把它作为优先事项添加。您可以将此库的数组用于不同的诊所。您可以通过使用库中的机制在给定时间或之后获取下一个可用插槽并遍历每个约会的机制来间接获取插槽。登陆页面位于https://bitbucket.org/warwick/schedule_utils_demo/src/master/,它还带有一个演示应用程序及其源代码。您还可以从Google Play商店下载演示应用:https://play.google.com/store/apps/details?id=com.WarwickWestonWright.ScheduleUtilsDemo 尽管它是一个Android库,但是在我牢记这一点构建它时,将其转变为标准Java库非常容易。当我添加了获取可用插槽列表的机制后,我将对此文章进行更新。

答案 1 :(得分:0)

我认为这不是一个编程问题,而是一个数据设计问题。

创建一个表(实体)clinic_id, doctor_id,主键为timedatepatient_id,外键为stateweeknumber字段。 state字段可以具有以下值:open,reserved,used,no show。默认是打开的

在接下来的两个月内填写此表(附表描述了哪个诊所,哪位医生有时间)。

这是一项很多工作,但是一旦你拥有它,你就可以每周更新一次表格。 (增加一周)尽管最初工作很多,但它也是一个灵活的解决方案,因为时间表的变化很容易应用

患者选择ClinicDoctorSchedule,系统将从timedates所有clinic_id返回doctor_id =所选诊所en timedate =所选医生firstweekdayhour 1}}介于lastweekdayhourstate之间,datetime =开启。

当患者选择patient_id两件事时:

  1. 外键值填充 public void SearchSubCategories`enter code here`(final String searchTxt){ new Handler().postDelayed(new Runnable() { @Override public void run() { dataStoredArrayList.clear(); myRecyclerAdapter.notifyDataSetChanged(); mparser = new SecondParseDataClass(getActivity()); mparser.setOnDataRetrievalCallback(new OnDataRetrievalCallback() { @Override public void onDataRetrieval(ArrayList<DataStored> dataSet) { dataStoredArrayList.addAll(dataSet); myRecyclerAdapter.notifyDataSetChanged(); } }); mparser.execute("http://192.168.3.10/fetchtext.php", "2",searchTxt); } }, 0); }
  2. 州`从开放到保留。
  3. 希望这有点帮助。

相关问题