首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >实施预约系统

问实施预约系统
EN

Stack Overflow用户
提问于 2018-04-14 19:36:47
回答 2查看 2.8K关注 0票数 0

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

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

更多说明:该系统由许多诊所组成,医生属于这些诊所,每个医生都有固定的时间,用户可以预约。这些时间被划分为每个半小时预约的日期。用户不能同时预约同一个医生。

例如:患者Joey预约了医生x,在2018年5月21日3:30,另一名患者jack打开应用程序预约了他选择的医生x,他选择了与joey相同的日期(2018年5月21日)系统将显示从早上7点到下午6点(7 :00,7:30,8:00,8:30……)的时间,不包括3:30。

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

代码示例:控制器部分:

代码语言:javascript
复制
 @RequestMapping(method = RequestMethod.GET , value = "/availabletimes")
public ResponseEntity<ResponseUtil> getAvailableTimes(@RequestParam String date){

    try {
        return new ResponseEntity<ResponseUtil> (new ResponseUtil(200, Constants.SUCCESS_STATUS, "Cancelled", service.getAvailableTimes(date)),HttpStatus.OK);
    }catch (BackendException e) {
        return new ResponseEntity<ResponseUtil> (new ResponseUtil(403, Constants.FAILED_STATUS, e.getMessage(), null),HttpStatus.FORBIDDEN);
    }

}

服务实现:

代码语言:javascript
复制
@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;
}

存储库:

代码语言:javascript
复制
 public interface AppointmentRepo extends IRepository<Appointment, Long> {

List<Appointment> findByCustomer(Customer customer);

     }

实体:

代码语言:javascript
复制
@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;
}

}
EN

回答 2

Stack Overflow用户

发布于 2018-09-29 15:59:22

我有一个开源的日程安排工具库(适用于Android),可以处理几个小时的业务和日程安排项目。它有一个检查重复预订的设施,但到目前为止,它还没有返回预约时段的直接机制,但我会将此作为优先事项添加。您可以将此库的数组用于不同的诊所。您可以通过使用库中的机制间接获得空位,该机制用于在给定时间或之后获得下一个可用空位,并循环通过每个约会。登陆页面在这里:https://bitbucket.org/warwick/schedule_utils_demo/src/master/,它还附带了一个演示应用程序及其源代码。您也可以从Google Play Store下载演示应用程序:https://play.google.com/store/apps/details?id=com.WarwickWestonWright.ScheduleUtilsDemo,尽管它是一个安卓库,但将其转换为标准的Java库是非常容易的,因为我在构建它时考虑到了这一点。当我添加了获取可用插槽列表的机制后,我会更新这篇文章。

票数 1
EN

Stack Overflow用户

发布于 2018-04-14 20:23:43

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

创建一个表(实体) ClinicDoctorSchedule,其中包含主键clinic_id, doctor_id、一个timedate、一个指向patient_id的外键和一个state字段。状态字段可以具有以下值:打开、保留、使用、不显示。默认设置为打开

填写下两个月的日程表(日程表描述在哪个诊所,哪个医生有空)。

这是一项大量的工作,但是一旦你有了它,你就可以每周更新一次表。(每周递增一次)虽然最初的工作量很大,但它也是一种灵活的解决方案,因为更改日程很容易应用

患者选择一个weeknumber,系统从ClinicDoctorSchedule all timedates返回,其中clinic_id =选定的诊所en doctor_id =选定的医生,timedate介于firstweekdayhour和lastweekdayhour之间,state =打开。

当患者选择datetime时,会发生两件事:

  1. 外键值已填充patient_id
  2. The状态`从open变为reserved。

希望这能对你有所帮助。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49831003

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档