yyghClinicMsg.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. const app = getApp();
  2. import yygh from "../../../../config/api/yygh/index.js";
  3. import pay from "../../../../config/api/pay/index.js";
  4. import regeneratorRuntime from "../../../../../utils/runtime.js";
  5. import common from "../../../../../utils/common.js";
  6. import publicFn from "../../../../../utils/publicFn.js";
  7. import { pagesPatientFn } from '@/utils';
  8. import apiRootUrl from "../../../../../config/api.js";
  9. import icon from "../../../../../utils/icon.js";
  10. Page({
  11. data: {
  12. iconUrl:icon,
  13. withoutCard:false,//是否可以无卡预约
  14. noDataValue: '当前医生暂无排班', //医生是否有排班
  15. doctorItem: {},
  16. dateInfoSelected: {}, //当前选择的排班时间
  17. showCon: false,
  18. showNoData: false,
  19. numberList: [], //预约时段
  20. numberInfoSelected: {}, //当前选中的预约时段
  21. currentUser: {},
  22. doctorInfoIsShow: false,
  23. doctorInfo: {}, //医生详情信息
  24. doctorListConfig: {}, //医生列表页配置
  25. serviceId:'',
  26. },
  27. onLoad: function(options) {
  28. let queryBean = app.globalData.queryBean || {};
  29. /**医生列表页配置 */
  30. let doctorListConfig = common.deepCopy(app.globalData.config.pageConfiguration.yyghDoctorList_config)
  31. /**当前页面配置 */
  32. let pageConfig = common.deepCopy(app.globalData.config.pageConfiguration.yyghClinicMsg_config)
  33. let dateInfoSelected = {}
  34. /**通过上级页面传的item和点击的排班Index 取到当前点击的排班时间 如果是从预约挂号页面进来的 则取挂号排班时间*/
  35. if(options?.schedule){
  36. dateInfoSelected = common.parse(options?.schedule)
  37. }else if (queryBean.Data_1 && options.selectedIndex) {
  38. dateInfoSelected = queryBean.Data_1[options.selectedIndex]
  39. }
  40. options?.deptCode && (queryBean.DeptCode = options?.deptCode)
  41. options?.doctorCode && (queryBean.DoctorCode = options?.doctorCode)
  42. this.setData({
  43. options:options,
  44. serviceId:options.serviceId || '',
  45. queryBean: queryBean,
  46. dateInfoSelected: dateInfoSelected,
  47. doctorListConfig: doctorListConfig,
  48. pageConfig: pageConfig,
  49. withoutCard: app.globalData.withoutCard
  50. })
  51. },
  52. onShow: function() {
  53. this.main()
  54. },
  55. async main() {
  56. this.setData({
  57. currentUser: app.globalData.currentUser
  58. })
  59. let showNoData = true;
  60. /**获取医生信息 */
  61. await this.setterDoctorList();
  62. if (!common.isEmpty(this.data.doctorItem)) {
  63. showNoData = false
  64. /**获取预约时间段 */
  65. await this.queryNumbers()
  66. }
  67. this.setData({
  68. showCon: true,
  69. showNoData: showNoData
  70. })
  71. },
  72. /**
  73. * 医生详情点击
  74. */
  75. async doctorInfoClick() {
  76. let doctorItem = this.data.doctorItem;
  77. let queryData = {
  78. HosId: app.globalData.districtId || app.globalData.hosId,
  79. DeptCode: doctorItem.DeptCode || '',
  80. DoctorCode: doctorItem.DoctorCode || '',
  81. DoctorName: ''
  82. }
  83. let resp = await yygh.queryClinicBaseDoctor(queryData);
  84. if (!common.isEmpty(resp)) {
  85. this.setData({
  86. doctorInfoIsShow: true,
  87. doctorInfo: resp[0]
  88. })
  89. }
  90. },
  91. /**
  92. * 预约时段点击
  93. */
  94. numberClick(e) {
  95. this.setData({
  96. numberInfoSelected: this.data.numberList[e.currentTarget.dataset.index]
  97. })
  98. },
  99. /**
  100. * 日期选择
  101. */
  102. timeClick(e) {
  103. let item = e.currentTarget.dataset.item;
  104. let index = e.currentTarget.dataset.index;
  105. let schedulIndex = e.currentTarget.dataset.schedulindex;
  106. if ((item.IsHalt == 7 && item.WaitLeaveCount <= 0) || item.IsHalt == '2') {
  107. return;
  108. }
  109. this.setData({
  110. numberList:[],
  111. dateInfoSelected: item
  112. })
  113. // 判断不等于约满或者不等于停诊查询号源
  114. if(item.IsHalt !=7 && item.IsHalt != '2'){
  115. this.queryNumbers()
  116. }
  117. },
  118. /**
  119. * 获取号源列表
  120. */
  121. async queryNumbers() {
  122. let dateInfoSelected = this.data.dateInfoSelected;
  123. let queryData = {
  124. HosId: app.globalData.districtId || app.globalData.hosId,
  125. DeptCode: dateInfoSelected.DeptCode,
  126. DoctorCode: dateInfoSelected.DoctorCode,
  127. RegDate: dateInfoSelected.RegDate,
  128. TimeSlice: dateInfoSelected.TimeSlice,
  129. ScheduleId: dateInfoSelected.ScheduleId,
  130. TransactionCode: 2002,
  131. }
  132. let numberList = await yygh.queryNumbers(queryData)
  133. let numberInfoSelected = {}
  134. if(!common.isEmpty(this.data.options?.number)){
  135. numberInfoSelected = common.parse(this.data.options?.number)
  136. }else{
  137. numberInfoSelected = numberList[0]
  138. }
  139. this.setData({
  140. numberList: numberList || [],
  141. numberInfoSelected: numberInfoSelected, //默认选中第一个号源
  142. })
  143. },
  144. /**
  145. * 处理医生列表返回值
  146. */
  147. async setterDoctorList() {
  148. let queryBean = this.data.queryBean;
  149. let dateInfoSelected = this.data.dateInfoSelected;
  150. let result = [];
  151. let hasAllSchedules = this.data.doctorListConfig.hasAllSchedules;
  152. let queryData = {
  153. HosId: app.globalData.districtId || app.globalData.hosId,
  154. DeptCode: queryBean.DeptCode,
  155. DoctorCode: queryBean.DoctorCode,
  156. WorkDateStart: hasAllSchedules ? "" : dateInfoSelected.RegDate,
  157. WorkDateEnd: hasAllSchedules ? "" : dateInfoSelected.RegDate,
  158. TitleCode: "",
  159. OrderByDoc: '1',
  160. WaitRule: '1'
  161. }
  162. // 判断为当日挂号
  163. if(this.data.serviceId == '009'){
  164. queryData.WorkDateStart = common.getDate()
  165. queryData.WorkDateEnd = common.getDate()
  166. queryData.ServiceId = this.data.serviceId
  167. }
  168. let resp = await yygh.queryClinicDoctorSchedule(queryData)
  169. if (!common.isEmpty(resp)) {
  170. let doctorItem = resp[0];
  171. /**如果医生头像没有域名 添加域名 */
  172. if (doctorItem.PhotoUrl && doctorItem.PhotoUrl.indexOf('http') == '-1') {
  173. doctorItem.PhotoUrl = apiRootUrl.ApiRootUrl + doctorItem.PhotoUrl
  174. }
  175. doctorItem.PhotoUrl = doctorItem.PhotoUrl.replace(/\\/g, '/')
  176. doctorItem.Data_1.map(item => {
  177. item.RegDateDiy = item.RegDate.substring(5)
  178. item.WeekName = item.RegDate == common.newDay()?'今天':item.WeekName
  179. item.DeptName = doctorItem.DeptName
  180. item.DeptCode = doctorItem.DeptCode
  181. item.DoctorName = doctorItem.DoctorName
  182. item.DoctorCode = doctorItem.DoctorCode
  183. })
  184. // 数据处理 医生多科室
  185. let obj = [{
  186. Check:true,
  187. DeptName:doctorItem.DeptName,
  188. DeptCode:doctorItem.DeptCode,
  189. DoctorName:doctorItem.DoctorName,
  190. DoctorCode:doctorItem.DoctorCode,
  191. Data_1:doctorItem.Data_1,
  192. }]
  193. doctorItem.Scheduling = obj
  194. /**重新赋值当前项 否则提交订单后后退不刷新值 */
  195. let dateInfoSelected = resp.filter(item => item && item.ScheduleId == this.data.dateInfoSelected.ScheduleId)[0] || this.data.dateInfoSelected
  196. this.setData({
  197. doctorItem: doctorItem,
  198. /**历史医生进入 无ScheduleId 重新赋值 */
  199. dateInfoSelected: this.data.dateInfoSelected.ScheduleId ? dateInfoSelected : doctorItem && doctorItem.Data_1 && doctorItem.Data_1[0] || {}
  200. })
  201. }
  202. },
  203. switchChange(e) {
  204. let value = e.detail.value;
  205. this.setData({
  206. reducibleOnly: value
  207. })
  208. this.main()
  209. },
  210. /**
  211. * 立即预约点击
  212. */
  213. async confirmClick(e) {
  214. let currentUser = this.data.currentUser;
  215. let formId = e.detail.formId;
  216. let dateInfoSelected = this.data.dateInfoSelected;
  217. let numberInfoSelected = this.data.numberInfoSelected;
  218. let doctorItem = this.data.doctorItem;
  219. // 查询当前用户 是否被授权
  220. if(await publicFn.isCurrentUserAuth(currentUser,'Book',true)) return
  221. /**是否存在待支付订单 */
  222. if (await pagesPatientFn.hasOrderToBePaid('0,009')) return
  223. common.throttle(async() => {
  224. if (common.isEmpty(this.data.dateInfoSelected)) {
  225. common.showToast('请选择预约日期')
  226. return
  227. }
  228. if (common.isEmpty(this.data.numberInfoSelected)) {
  229. common.showToast('请选择预约时间')
  230. return
  231. }
  232. /**消息推送 */
  233. // let pushData = {
  234. // SceneId: formeId,
  235. // OpenId: wx.getStorageSync('openid')
  236. // }
  237. // await complete.pushBaiduAndWxSceneId(pushData)
  238. /**锁号 */
  239. let queryData = {
  240. HosId: app.globalData.districtId || app.globalData.hosId,
  241. ScheduleId: dateInfoSelected.ScheduleId,
  242. DeptCode: dateInfoSelected.DeptCode,
  243. DoctorCode: dateInfoSelected.DoctorCode,
  244. RegType: '1',
  245. RegDate: dateInfoSelected.RegDate,
  246. TimeSlice: dateInfoSelected.TimeSlice,
  247. SqNo: numberInfoSelected.SqNo,
  248. CommendTime: numberInfoSelected.EndTime ? `${numberInfoSelected.StartTime}-${numberInfoSelected.EndTime}` : numberInfoSelected.StartTime,
  249. SourceCode: numberInfoSelected.SourceCode,
  250. MemberId:currentUser.memberId,
  251. CardType: '1',
  252. CardNo: currentUser.cardNo || '',
  253. MemberStore:{
  254. cardEncryptionStore: currentUser.encryptionStore || '',
  255. baseMemberEncryptionStore:currentUser.baseMemberEncryptionStore
  256. },
  257. Store:{
  258. cardEncryptionStore: currentUser.encryptionStore || '',
  259. baseMemberEncryptionStore:currentUser.baseMemberEncryptionStore
  260. }
  261. }
  262. let lockResp = await yygh.lockOrder(queryData);
  263. if (!common.isEmpty(lockResp)) {
  264. /**锁号成功 */
  265. /**本地下单 */
  266. let addorderData = {
  267. HosId: app.globalData.hosId,
  268. OrderId: lockResp[0].OrderId,
  269. PrescNo: '',
  270. PayMoney: lockResp[0].Fee,
  271. TotalMoney: lockResp[0].Fee,
  272. IsOnlinePay: lockResp[0].IsOnlinePay,
  273. PriceName: '挂号支付',
  274. OperatorId: wx.getStorageSync('openid'),
  275. ServiceId: '0',
  276. PayFeeItem: '0',
  277. EqptType: '1',
  278. BankCardNo: '',
  279. BankSeqNo: '',
  280. ChargeSource: '',
  281. MemberId: currentUser.memberId,
  282. OperatorName: currentUser.MemberName,
  283. Store:{
  284. cardEncryptionStore: currentUser.encryptionStore || '',
  285. baseMemberEncryptionStore:currentUser.baseMemberEncryptionStore
  286. },
  287. Data_1: {
  288. DoctorCode: dateInfoSelected.DoctorCode || doctorItem.DoctorCode,
  289. DoctorName: dateInfoSelected.DoctorName || doctorItem.DoctorName,
  290. DeptCode: dateInfoSelected.DeptCode || doctorItem.DeptCode,
  291. DeptName: dateInfoSelected.DeptName || doctorItem.DeptName,
  292. RegDate: dateInfoSelected.RegDate,
  293. CommendTime: numberInfoSelected.CommendTime,
  294. scene_id: formId,
  295. FeeInfo: lockResp[0].FeeInfo,
  296. scene_type: '1',
  297. TransactionCode: '6001'
  298. }
  299. }
  300. let addOrderResp = await pay.addOrderLocal(addorderData)
  301. if (!common.isEmpty(addOrderResp)) {
  302. /**本地下单成功 */
  303. let url = `/pagesPatient/st1/business/pay/payState/payState?pageType=yygh&orderId=${lockResp[0].OrderId}`
  304. if (lockResp[0].IsOnlinePay == '1') {
  305. /**在线支付 */
  306. url = `/pagesPatient/st1/business/pay/payMent/payMent?orderId=${lockResp[0].OrderId}`
  307. } else if (lockResp[0].IsOnlinePay == '2') {
  308. /**不支付 boockService挂号 */
  309. let queryData = {
  310. HosId: app.globalData.districtId || app.globalData.hosId,
  311. OrderId: lockResp[0].OrderId,
  312. OperatorId: wx.getStorageSync('openid'),
  313. TransactionCode: "3003",
  314. MemberId: currentUser.memberId,
  315. SourceType:0,
  316. Store:{
  317. cardEncryptionStore: currentUser.encryptionStore || '',
  318. baseMemberEncryptionStore:currentUser.baseMemberEncryptionStore
  319. },
  320. }
  321. let {resp,resData} = await yygh.bookService(queryData)
  322. if (resData.RespCode != 10000) {
  323. await yygh.unlock({OrderId:lockResp[0].OrderId})
  324. return
  325. }
  326. }
  327. common.goToUrl(url)
  328. }
  329. }
  330. })
  331. },
  332. /**
  333. * 查询医生其它科室排班
  334. */
  335. async queryScheduleList(e){
  336. let hasAllSchedules = this.data.doctorListConfig.hasAllSchedules;
  337. let dateInfoSelected = this.data.dateInfoSelected;
  338. let doctorItem = this.data.doctorItem
  339. let querData = {
  340. workDateEnd: hasAllSchedules ? "" : dateInfoSelected.RegDate,
  341. workDateStart: hasAllSchedules ? "" : dateInfoSelected.RegDate,
  342. doctorCode: doctorItem.DoctorCode,
  343. deptCode:doctorItem.DeptCode ,
  344. hosId: app.globalData.districtId || app.globalData.hosId,
  345. WaitRule: '1'
  346. }
  347. let res = await yygh.queryScheduleList(querData)
  348. if(common.isNotEmpty(res)){
  349. let scheduleList = []
  350. res.map(async (item,index)=>{
  351. // 转换返回数据 小写转大写
  352. item.hisQueryClinicSchedules = common.changeObj(item.hisQueryClinicSchedules)
  353. item.hisQueryBaseDoctor = common.changeObj(item.hisQueryBaseDoctor)
  354. if(item.hisQueryClinicSchedules.length > 0){
  355. // 判断是否多数据处理 星期 时间 上下午
  356. if(item.hisQueryClinicSchedules.length > 0){
  357. item.hisQueryClinicSchedules.map(ele=>{
  358. ele.WeekName = ele.RegDate == common.newDay()?'今天':common.weekDay(ele.RegDate,1)
  359. ele.RegDateDiy = ele.RegDate.substring(5)
  360. ele.TimeSliceStr = ele.TimeSlice==1?'上午':ele.TimeSlice==2?'下午':'全天'
  361. })
  362. }
  363. scheduleList.push({
  364. Check:item.hisQueryBaseDoctor.DeptCode==doctorItem.DeptCode?true:false,
  365. DeptName:item.hisQueryBaseDoctor.DeptName,
  366. DeptCode:item.hisQueryBaseDoctor.DeptCode,
  367. DoctorName:doctorItem.DoctorName,
  368. DoctorCode:doctorItem.DoctorCode,
  369. Data_1:item.hisQueryClinicSchedules,
  370. showAllSchedu:item.showAllSchedu,
  371. })
  372. }
  373. })
  374. // 给当前查询的医生新加列表
  375. doctorItem.Scheduling = scheduleList
  376. }
  377. // 查询过的医生 不展示switch
  378. doctorItem.ShowDeptSwitch = true
  379. this.setData({
  380. doctorItem:doctorItem
  381. })
  382. },
  383. /**
  384. * 折叠列表
  385. */
  386. foldList(e) {
  387. let schedulIndex = e.currentTarget.dataset.schedulindex
  388. let doctorItem = this.data.doctorItem
  389. // 当前点击的科室是打开的状态,则进行关闭,不查号源
  390. if(doctorItem.Scheduling[schedulIndex].Check){
  391. doctorItem.Scheduling[schedulIndex].Check = false
  392. this.setData({
  393. doctorItem
  394. })
  395. }else{
  396. let dateInfoSelected = {}
  397. // 全部遍历关闭展开数据信息
  398. doctorItem.Scheduling.map(item=>item.Check = false)
  399. // 当前打开
  400. doctorItem.Scheduling[schedulIndex].Check = true
  401. // 过滤当前打开的排班信息 获取到未满未停诊的排班
  402. let dateInfoSelecteds = doctorItem.Scheduling[schedulIndex].Data_1.filter(item=>item.IsHalt != '7' || item.IsHalt != '2')
  403. // 判断过滤条件是否为空 为空踢提示
  404. if(common.isEmpty(dateInfoSelecteds)){
  405. common.showToast("查询号源失败,请选择一个排班信息")
  406. }else{
  407. // 否者查询号源
  408. dateInfoSelected = dateInfoSelecteds[0]
  409. }
  410. this.setData({
  411. dateInfoSelected: dateInfoSelected,
  412. doctorItem
  413. })
  414. this.queryNumbers()
  415. }
  416. },
  417. // 候补登记
  418. async waitRegistration(){
  419. let currentUser = this.data.currentUser;
  420. let dateInfoSelected = this.data.dateInfoSelected;
  421. let doctorItem = this.data.doctorItem;
  422. if(dateInfoSelected.WaitLeaveCount<=0)return
  423. let queryData = {
  424. HosId: app.globalData.districtId ||app.globalData.hosId,
  425. OpenId: wx.getStorageSync("openid"),
  426. MemberId: currentUser.memberId,
  427. ScheduleId: dateInfoSelected.ScheduleId,
  428. DeptCode: doctorItem.DeptCode,
  429. DoctorCode: doctorItem.DoctorCode,
  430. RegDate: dateInfoSelected.RegDate,
  431. WeekId: dateInfoSelected.WeekId,
  432. TimeId: dateInfoSelected.TimeSlice,
  433. Store:{
  434. cardEncryptionStore: currentUser.encryptionStore || '',
  435. baseMemberEncryptionStore:currentUser.baseMemberEncryptionStore
  436. }
  437. }
  438. let {resp,resData} = await yygh.checkBeforeAddWaitList(queryData)
  439. if (resData.RespCode == '10000') {
  440. doctorItem.Intro = ''
  441. doctorItem.Data_1 = ''
  442. doctorItem.Scheduling = ''
  443. let querBen = encodeURIComponent(JSON.stringify({
  444. doctorItem,
  445. dateInfoSelected
  446. }))
  447. common.goToUrl(`/pagesPatient/st1/business/yygh/waitRegistration/waitRegistration?querBen=${querBen}`)
  448. }
  449. }
  450. })