yxh
yxh
9 天以前 09dc74e264b6262cbe41c9c8476e24705871d4a6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import request from '@/config/axios'
 
// 预约 VO
export interface AppointmentVO {
  id: number,
  applyNo: string  // 预约申请编号
  episodeId: string //就诊流水号
  patSrc: number
  tolerance:number// 是否耐药
  patId: string // 患者编号
  patName: string // 患者姓名
  patGender: number // 患者性别
  patBirthday: Date // 患者生日
  patMobile: string // 患者手机
  patPhone: string // 患者电话
  patIdentityId: string // 身份证号
  patAddr: string // 患者地址
  patDeptCode: string // 患者所在科室代码
  patDeptDesc: string // 患者所在科室名称
  patWardCode: string // 患者所在病区代码
  patWardDesc: string // 患者所在病区名称
  patBedNo: string // 床号
  bookDate: Date // 预约日期
  bookTimeslot: number // 预约时间段
  bookTime: Date // 预约发生时间, 点击预约的时间
  bookCheckType: number // 预约检查项目
  paid: number //已付款
  bookSeqNum: number
  /**
   * 【本需求】非当天预约签到的"已确认"标记。
   * 前端弹窗确认后置 true 传给后端:后端据此放行非当天预约,并按**预留号**取号。
   */
  forceCheckIn?: boolean
  // ========== 以下字段后端 AppointmentRespVO 一直有返回,此前 TS 未声明 ==========
  // 需求1 使用:状态 / 开单医师 / 开单日期 / 距今天数(由 doctorTime 计算)/ 就诊卡号
  status?: string // 状态(字典 ecg_status)
  doctor?: string // 开单医师
  doctorCode?: string // 开单医师代码
  doctorTime?: Date | number | string // 开单日期(开单时间)
  registerDate?: Date | number | string // 登记时间
  hospitalNo?: string // 住院号
  medicalCard?: string // 就诊卡号(库中多为空,页面回退到 outpatientNo)
  doctorAdviceNo?: string // 医嘱号(HIS root 2.16.156.10011.1.28;库中历史数据为空)
  outpatientNo?: string // 门诊号(实测部分数据存的是身份证号)
  bookSrc?: number // 预约来源:0人工 10平台
  roomName?: string // 诊室名称
  remark?: string // 备注
  jjbz?: string // 加急标记
  createTime?: Date | number | string // 创建时间
}
 
/**
 * 【本需求】预约记录页的「预约日期」用日期范围选择器,前端字段是 `bookDateRange`(['2026-11-01','2026-11-30']),
 * 而后端接收的是 `bookDateStart` / `bookDateEnd`(含首尾两天)。
 * 这里统一转换,避免每个调用点各写一遍:分页、导出都走它。
 */
const withBookDateRange = (params: any) => {
  if (!params) return params
  const { bookDateRange, ...rest } = params
  if (Array.isArray(bookDateRange) && bookDateRange.length === 2 && bookDateRange[0] && bookDateRange[1]) {
    rest.bookDateStart = `${bookDateRange[0]} 00:00:00`
    rest.bookDateEnd = `${bookDateRange[1]} 23:59:59`
  }
  return rest
}
 
// 预约 API
export const AppointmentApi = {
  // 查询预约分页
  getAppointmentPage: async (params: any) => {
    return await request.get({ url: `/ecg/appointment/page`, params: withBookDateRange(params) })
  },
 
  // 查询预约详情
  getAppointment: async (id: number) => {
    return await request.get({ url: `/ecg/appointment/get?id=` + id })
  },
 
  //
  getCurAppointmentByPatIdAndCheckType: async (patId: string, checkType: number) => {
    return await request.get({ url: `/ecg/appointment/get-current-by-patient?patId=` + patId + '&checkType=' + checkType })
  },
 
  // 从HIS或者DB查询预约详情
  queryAndCreateAppointmentByPatId: async (patId: string) => {
    return await request.get({ url: `/ecg/appointment/query-and-create-by-patient?patId=` + patId })
  },
 
  // 从HIS查询预约或开单信息
  queryAppointmentFromHis: async (patId: string) => {
    return await request.get({ url: `/ecg/appointment/query-his-by-patient?patId=` + patId })
  },
 
  /**
   * 【本需求:紧急患者不排队直接检查】按「申请单号 / 就诊号 / 患者编号」查近一个月(±30 天)的预约记录。
   * 结果按预约时间倒序;`checkTypes` 为本窗口开展的检查项目(逗号分隔,空则不限)。
   */
  getEmergencyCandidates: async (code: string, checkTypes?: number[]) => {
    const types = Array.isArray(checkTypes) && checkTypes.length > 0 ? checkTypes.join(',') : ''
    return await request.get({
      url:
        `/ecg/appointment/emergency-candidates?code=` +
        encodeURIComponent(code) +
        (types ? `&checkTypes=${types}` : '')
    })
  },
 
  // 新增预约
  createAppointment: async (data: AppointmentVO) => {
    return await request.post({ url: `/ecg/appointment/create`, data })
  },
  // 状态更新
  alterAppointment: async (data: AppointmentVO) => {
    return await request.post({ url: `/ecg/appointment/updateStatus`, data })
  },
 
  // 修改预约
  updateAppointment: async (data: AppointmentVO) => {
    return await request.put({ url: `/ecg/appointment/update`, data })
  },
 
  // 删除预约
  deleteAppointment: async (id: number) => {
    return await request.delete({ url: `/ecg/appointment/delete?id=` + id })
  },
 
  // 导出预约 Excel
  exportAppointment: async (params) => {
    return await request.download({ url: `/ecg/appointment/export-excel`, params: withBookDateRange(params) })
  },
 
  // 预约确认
  confirmAppointment: async (data: AppointmentVO) => {
      return await request.post({ url: `/ecg/appointment/confirm`, data })
  },
 
  // VIP预约确认
  confirmAppointmentVip: async (data: AppointmentVO) => {
      return await request.post({ url: `/ecg/appointment/confirm-vip`, data })
  }
 
}