zhu-yuan-yi-sheng.ts 27 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031
  1. import {stringIsBlank, stringNotBlank} from "../../../../utils/blank-utils";
  2. import {ElMessage} from "element-plus";
  3. import {getPatientInfo, getDrgPatInfo} from "../../../../api/inpatient/patient";
  4. import {BizException, ExceptionEnum} from "../../../../utils/BizException";
  5. import {nextTick, Ref, ref, computed, onActivated, onDeactivated} from "vue";
  6. import {getServerDateApi} from "../../../../api/public-api";
  7. import {getFormatDatetime} from "../../../../utils/date";
  8. import {isDev} from "../../../../utils/public";
  9. import {getFrequency, getSupplyType, huoQuYiZhuShuJu} from "../../../../api/zhu-yuan-yi-sheng/yi-zhu-lu-ru";
  10. import EventBus from "../../../../utils/mitt";
  11. import XEUtils from 'xe-utils'
  12. import {getAncillaryInformation} from '../../../../api/zhu-yuan-yi-sheng/jian-yan-jian-cha-shen-qing'
  13. import {timeLimitPromptByPatientNo} from "../../../../api/emr-control/emr-time-limit-prompt";
  14. export interface PatInfo {
  15. inpatientNo?: string
  16. admissTimes?: number,
  17. ledgerSn?: number
  18. admissDate?: string
  19. groupInfoName?: string;
  20. groupInfoWeight?: string;
  21. groupInfoBl?: string
  22. setGroupInfoProfit?: string
  23. groupInfoFeeStand?: string
  24. referPhysician?: string
  25. consultPhysician?: string
  26. deptDirector?: string
  27. zkWard?: string
  28. zkWardName?: string,
  29. sex?: number
  30. age?: number
  31. admissWard?: string
  32. }
  33. // 患者信息
  34. export const huanZheXinXi = ref<PatInfo>({
  35. zkWardName: "",
  36. zkWard: "",
  37. consultPhysician: "",
  38. deptDirector: "",
  39. referPhysician: "",
  40. groupInfoBl: "",
  41. groupInfoFeeStand: "",
  42. groupInfoName: "",
  43. groupInfoWeight: "",
  44. setGroupInfoProfit: "",
  45. ledgerSn: 0,
  46. admissTimes: 0,
  47. inpatientNo: null,
  48. admissDate: ''
  49. })
  50. export function clearPatInfo() {
  51. huanZheXinXi.value = {
  52. zkWardName: "",
  53. zkWard: "",
  54. consultPhysician: "",
  55. deptDirector: "",
  56. referPhysician: "",
  57. groupInfoBl: "",
  58. groupInfoFeeStand: "",
  59. groupInfoName: "",
  60. groupInfoWeight: "",
  61. setGroupInfoProfit: "",
  62. ledgerSn: 0,
  63. admissTimes: 0,
  64. inpatientNo: null,
  65. admissDate: ''
  66. }
  67. }
  68. // 是否点击了修改整个模板
  69. export const muBanMing = ref({})
  70. // 错误信息
  71. export const cuoWuXinXi = ref('')
  72. // 头部大小
  73. export const yzHeaderSize = ref(0)
  74. // 给药方式
  75. export const geiYaoFangShiData = ref([])
  76. // 频率
  77. export const yaoPinPingLvData = ref([])
  78. getSupplyType().then(res => {
  79. geiYaoFangShiData.value = res
  80. })
  81. getFrequency().then(res => {
  82. yaoPinPingLvData.value = res
  83. })
  84. export function youWuXuanZheHuanZhe() {
  85. if (stringIsBlank(huanZheXinXi.value.inpatientNo)) {
  86. ElMessage({
  87. message: '请先选择患者', showClose: true, type: 'error'
  88. })
  89. return true
  90. }
  91. return false
  92. }
  93. export function getSelfBuy(val) {
  94. if (stringIsBlank(val)) return ""
  95. switch (val) {
  96. case '1':
  97. return "自备"
  98. case '2':
  99. return "嘱托"
  100. case '3':
  101. return "基数药"
  102. default:
  103. return "";
  104. }
  105. }
  106. export let zkList = ref([])
  107. export const frequCodeEnum = {
  108. all: 'all',
  109. temporary: 'temporary',
  110. longTerm: 'longTerm',
  111. always: 'ALWAYS',
  112. takeMedicine: 'takeMedicine',
  113. }
  114. // 生成的长期医嘱频率
  115. export const frequencyConfig = 'QD'
  116. export const addTempOrderNo: number = -1
  117. export interface YzType {
  118. id: string;
  119. inpatientNo: string;
  120. admissTimes: number;
  121. actOrderNo: number;
  122. orderCode: string;
  123. orderName: string;
  124. nationalCode?: any;
  125. packRetprice?: any;
  126. frequCode: string;
  127. frequCodeName: string;
  128. instruction?: any;
  129. discription?: any;
  130. infantFlag: string;
  131. orderTime: string;
  132. startTime: string;
  133. endTime?: any;
  134. endTimeTemp?: any;
  135. modifier?: any;
  136. modifierName?: any;
  137. physician: string;
  138. physicianName: string;
  139. drugSpecification?: any;
  140. drugQuan?: any;
  141. drugQuanName?: any;
  142. supplyCode?: any;
  143. supplyCodeName?: any;
  144. drugFlag: string;
  145. enterOper: string;
  146. psFlag: boolean;
  147. zkObj: string
  148. enterOperName: string;
  149. packSizeName: string
  150. enterTime: string;
  151. signer: string;
  152. signerName: string;
  153. confirmTime: string;
  154. miniUnit?: any;
  155. miniUnitName?: any;
  156. drugWeight?: any;
  157. drugWeightUnit?: any;
  158. drugWeightUnitName?: any;
  159. statusFlag: string;
  160. statusTime?: any;
  161. selfBuy: string;
  162. dose?: any;
  163. doseUnit?: any;
  164. doseUnitName?: any;
  165. drugOcc?: any;
  166. drugVolume?: any;
  167. drugVolUnit?: any;
  168. parentNo?: any;
  169. parentNoName?: any;
  170. packSize: number;
  171. packUnit?: any;
  172. paySelf: string;
  173. serial: string;
  174. serialName: string;
  175. groupNo: string;
  176. groupNoName: string;
  177. doctorFlag: string;
  178. execUnit: string;
  179. execUnitName: string;
  180. regFlag: string;
  181. ybSelfFlag?: any;
  182. emergencyFlag?: any;
  183. kfFlag?: any;
  184. kjywFlag?: any;
  185. stockAmount?: any;
  186. deptRestrictions?: any;
  187. visibleFlagZy?: any;
  188. excluBackTime?: any;
  189. excluActOrderNo?: any;
  190. excluType: string;
  191. clCode?: any;
  192. endTimeB?: any;
  193. deptCode: string;
  194. deptName: string;
  195. wardCode: string;
  196. wardName: string;
  197. newFlag: string;
  198. referPhysician?: any;
  199. referPhysicianName?: any;
  200. consultPhysician?: any;
  201. consultPhysicianName?: any;
  202. yyfs?: any;
  203. ssqk?: any;
  204. yysj?: any;
  205. ypLevel?: any;
  206. delFlag?: any;
  207. zkWardCode?: any;
  208. zkDeptCode?: any;
  209. children?: any;
  210. orderGroup?: any;
  211. executer1?: any;
  212. executer2?: any;
  213. newOrderFlag: number;
  214. superiorDoctor?: any;
  215. selfBuyName: string;
  216. statusFlagName: string;
  217. // 关联标志只在前端使用
  218. associationFlag?: boolean
  219. doctorName: string
  220. execDept: string
  221. execDeptName: string
  222. }
  223. export interface SearchOrdersType {
  224. id: string;
  225. pyCode: string;
  226. patternCode: string | null;
  227. patternName: string | null;
  228. orderCode: string;
  229. orderName: string;
  230. specification: string | null;
  231. orderType: string | null;
  232. parentCode: string | null;
  233. excluGroupType: string | null;
  234. discription: string;
  235. serial: string;
  236. groupNo: string;
  237. groupName: string;
  238. infusionFlag: string;
  239. drugFlag: string;
  240. packSize: number;
  241. packSizeName: string;
  242. orderClass: string;
  243. specPack: string | null;
  244. jsyFlag: string | null;
  245. xnhFlag: string | null;
  246. ybComment: string | null;
  247. dosage: string;
  248. ybType: string;
  249. fatherFlag: string | null;
  250. manuName: string;
  251. nationalCode: string;
  252. nationalName: string;
  253. execDept: string | null;
  254. execDeptName: string | null;
  255. chargeCode: string | null;
  256. chargeCodeName: string | null;
  257. retprice: number | null;
  258. quantity: number | null;
  259. selfFlag: string | null;
  260. supriceFlag: string | null;
  261. instruction: string | null;
  262. stockAmount: string;
  263. ybFlagNew: string;
  264. drugSpecification: string;
  265. dcode: string;
  266. drugFlagName: string;
  267. infusionFlagName: string;
  268. }
  269. // 医嘱数据
  270. export const yiZhuData = ref<YzType>({
  271. actOrderNo: addTempOrderNo,
  272. admissTimes: 0,
  273. confirmTime: "",
  274. deptCode: "",
  275. deptName: "",
  276. doctorFlag: "",
  277. enterOper: "",
  278. enterOperName: "",
  279. enterTime: "",
  280. excluType: "",
  281. groupNoName: "",
  282. infantFlag: "",
  283. inpatientNo: "",
  284. newFlag: "",
  285. newOrderFlag: 0,
  286. paySelf: "",
  287. physician: "",
  288. regFlag: "",
  289. selfBuyName: "",
  290. serialName: "",
  291. signer: "",
  292. signerName: "",
  293. statusFlagName: "",
  294. wardCode: "",
  295. wardName: "",
  296. id: '',
  297. orderName: '',
  298. orderCode: '',
  299. // 频率
  300. frequCode: '',
  301. frequCodeName: '',
  302. drugSpecification: '',
  303. dose: 0,
  304. // 领量
  305. doseUnit: '',
  306. doseUnitName: '',
  307. supplyCode: '',
  308. supplyCodeName: '',
  309. startTime: '',
  310. endTime: '',
  311. orderTime: '',
  312. doctorName: '',
  313. drugFlag: '',
  314. execUnit: '',
  315. execUnitName: '',
  316. parentNo: '',
  317. parentNoName: '',
  318. physicianName: '',
  319. discription: '',
  320. instruction: null,
  321. kfFlag: null,
  322. selfBuy: null,
  323. ybSelfFlag: '0',
  324. emergencyFlag: '0',
  325. drugQuan: 0,
  326. miniUnitName: '',
  327. serial: '',
  328. miniUnit: '',
  329. psFlag: false,
  330. kjywFlag: 0,
  331. yyfs: null,
  332. ssqk: null,
  333. yysj: null,
  334. zkObj: '',
  335. zkWardCode: '',
  336. zkDeptCode: '',
  337. statusFlag: '1',
  338. groupNo: '00',
  339. // 包装规格
  340. packSizeName: '',
  341. packUnit: '',
  342. // 执行用量
  343. drugOcc: '',
  344. packSize: 0,
  345. execDept: '',
  346. execDeptName: ''
  347. });
  348. export const yiZhuDataInit = (clearOrderNo: boolean = true): void => {
  349. yiZhuData.value = {
  350. id: '',
  351. actOrderNo: clearOrderNo ? addTempOrderNo : yiZhuData.value.actOrderNo,
  352. admissTimes: 0,
  353. confirmTime: "",
  354. deptCode: "",
  355. deptName: "",
  356. doctorFlag: "",
  357. enterOper: "",
  358. enterOperName: "",
  359. enterTime: "",
  360. excluType: "",
  361. groupNoName: "",
  362. infantFlag: "",
  363. inpatientNo: "",
  364. newFlag: "",
  365. newOrderFlag: 0,
  366. paySelf: "",
  367. physician: "",
  368. regFlag: "",
  369. selfBuyName: "",
  370. serialName: "",
  371. signer: "",
  372. signerName: "",
  373. statusFlagName: "",
  374. wardCode: "",
  375. wardName: "",
  376. orderName: '',
  377. orderCode: '',
  378. // 频率
  379. frequCode: '',
  380. frequCodeName: '',
  381. drugSpecification: '',
  382. dose: 0,
  383. // 领量
  384. doseUnit: '',
  385. doseUnitName: '',
  386. supplyCode: '',
  387. supplyCodeName: '',
  388. startTime: '',
  389. endTime: '',
  390. orderTime: '',
  391. doctorName: '',
  392. drugFlag: '',
  393. execUnit: '',
  394. execUnitName: '',
  395. parentNo: '',
  396. parentNoName: '',
  397. physicianName: '',
  398. discription: '',
  399. instruction: null,
  400. kfFlag: null,
  401. selfBuy: null,
  402. ybSelfFlag: '0',
  403. emergencyFlag: '0',
  404. drugQuan: 0,
  405. miniUnitName: '',
  406. serial: '',
  407. miniUnit: '',
  408. psFlag: false,
  409. kjywFlag: 0,
  410. yyfs: null,
  411. ssqk: null,
  412. yysj: null,
  413. zkObj: '',
  414. zkWardCode: '',
  415. zkDeptCode: '',
  416. statusFlag: '1',
  417. groupNo: '00',
  418. // 包装规格
  419. packSizeName: '',
  420. packUnit: '',
  421. // 执行用量
  422. drugOcc: '',
  423. packSize: 0,
  424. execDept: '',
  425. execDeptName: ''
  426. }
  427. }
  428. // 保存医嘱数据
  429. export const yzData = ref<Array<YzType>>([])
  430. export const jsQueryYzData = async () => {
  431. if (stringNotBlank(huanZheXinXi.value.inpatientNo)) {
  432. yzData.value = await huoQuYiZhuShuJu({
  433. patNo: huanZheXinXi.value.inpatientNo,
  434. times: huanZheXinXi.value.admissTimes
  435. })
  436. }
  437. }
  438. let newDate = ''
  439. getServerDateApi().then(res => {
  440. newDate = res
  441. })
  442. // 医嘱查询条件
  443. export const queryParam = ref({
  444. displayRange: 2,
  445. frequCode: isDev ? frequCodeEnum.all : frequCodeEnum.longTerm,
  446. zhuangTai: 0,
  447. groupNo: '73',
  448. patNo: '',
  449. times: 0,
  450. });
  451. // 设置分组符号
  452. export function setYzOrderGroup(): void {
  453. yzData.value = yzDataToTree(yzData.value)
  454. }
  455. // yzData 转成树状图
  456. export function yzDataToTree(data: YzType[]): YzType[] {
  457. if (data.length === 0) {
  458. return []
  459. }
  460. // 没有匹配到父级的子节点
  461. let noParent: Map<number, YzType> = new Map();
  462. // 克隆一下原来的数据
  463. let cloneData: YzType[] = JSON.parse(JSON.stringify(data))
  464. // 转 map
  465. let tempMap: Map<number, YzType> = new Map();
  466. let tree: YzType[] = [];
  467. // 保存子元素的数据
  468. let children: YzType[] = [];
  469. XEUtils.arrayEach(cloneData, (item) => {
  470. let key: number = item.actOrderNo
  471. noParent.set(key, item);
  472. tempMap.set(key, item)
  473. if (typeof item.parentNo === 'undefined' || item.parentNo === null) {
  474. tree.push(item)
  475. noParent.delete(key)
  476. } else {
  477. children.push(item)
  478. }
  479. setSerialName(item);
  480. trimString(item);
  481. item.orderGroup = "";
  482. })
  483. XEUtils.arrayEach(children, (item) => {
  484. // 子节点的 key 值
  485. let key: number = item.actOrderNo;
  486. if (tempMap.has(item.parentNo)) {
  487. noParent.delete(key);
  488. let parent = tempMap.get(item.parentNo);
  489. parent.orderGroup = "┌";
  490. parent.children = parent.children || [];
  491. parent.children.push(item);
  492. item.orderGroup = "丨";
  493. }
  494. });
  495. // 判断 noParent 不为空
  496. if (noParent.size > 0) {
  497. // 把 noParent 的 value 全部放到 tree 数组中
  498. let a = Array.from(noParent.values());
  499. tree.push(...a)
  500. }
  501. let list: YzType[] = []
  502. //循环 tree 节点,设置结尾的 orderGroup 为 "└" 并且清空children数组
  503. XEUtils.arrayEach(tree, (item) => {
  504. list.push(item)
  505. // 判断 item 的 children 节点不为空
  506. if (item.children && item.children.length > 0) {
  507. item.children = XEUtils.orderBy(item.children, [["actOrderNo", "asc"]])
  508. item.children[item.children.length - 1].orderGroup = "└"
  509. // 把 item 的 children 节点全部添加到 list数组
  510. list.push(...item.children)
  511. // 在把 children 清空
  512. item.children = []
  513. }
  514. });
  515. return list
  516. }
  517. export const setOrderDataAndTwinkle = async (order, data: YzType[]) => {
  518. let temp = data;
  519. let tempMap = new Map();
  520. XEUtils.arrayEach(temp, (item) => {
  521. tempMap.set(item.actOrderNo, item)
  522. })
  523. for (let i = yzData.value.length - 1; i >= 0; i--) {
  524. let item = yzData.value[i];
  525. if (item.statusFlag !== '1') {
  526. continue;
  527. }
  528. let orderNo = item.actOrderNo;
  529. if (tempMap.has(orderNo)) {
  530. yzData.value[i] = tempMap.get(orderNo)
  531. tempMap.delete(orderNo)
  532. }
  533. if (tempMap.size === 0) {
  534. break;
  535. }
  536. }
  537. if (tempMap.size > 0) {
  538. let list = Array.from(tempMap.values());
  539. yzData.value.push(...list);
  540. }
  541. await nextTick();
  542. setYzOrderGroup();
  543. // 设置高亮
  544. yzMitt.emit('setOrderNoTwinkle', order);
  545. }
  546. // 设置项目名称
  547. function getSerial(val: string): string {
  548. val = XEUtils.trim(val)
  549. switch (val) {
  550. case "00":
  551. return "项目";
  552. case "01":
  553. return "小包装";
  554. case "02":
  555. return "大包装";
  556. default :
  557. return "";
  558. }
  559. }
  560. // 删除对象中的 string 类型的前后空格
  561. function trimString(obj: any) {
  562. for (let key in obj) {
  563. if (typeof obj[key] === 'string') {
  564. obj[key] = XEUtils.trim(obj[key])
  565. }
  566. }
  567. }
  568. function setSerialName(item: any) {
  569. let temp = getSerial(item.seria)
  570. item.serialName = temp
  571. item.groupNoName = temp
  572. }
  573. // 数据筛选
  574. export const tempYzData = computed<YzType[]>(() => {
  575. let temp = XEUtils.filter(yzData.value, (item) => {
  576. let flag: boolean = queryParam.value.displayRange === 0
  577. let frequFlag: boolean = queryParam.value.frequCode === frequCodeEnum.all
  578. let zhuangTai: boolean = queryParam.value.zhuangTai === 0
  579. if (isCydy()) {
  580. return item.selfBuy === '4'
  581. }
  582. if (item.statusFlag === '1') {
  583. return true
  584. }
  585. if (queryParam.value.displayRange === 1) {
  586. // 停止的医嘱
  587. flag = item.statusFlag === '5'
  588. } else if (queryParam.value.displayRange === 2) {
  589. flag = item.statusFlag === '2' || item.statusFlag === '3' || item.statusFlag === '4'
  590. } else if (queryParam.value.displayRange === 3) {
  591. flag = getFormatDatetime(newDate, 'YYYY-MM-DD') === getFormatDatetime(item.startTime, 'YYYY-MM-DD')
  592. }
  593. if (queryParam.value.frequCode === frequCodeEnum.temporary) {
  594. frequFlag = item.frequCode === 'ONCE'
  595. } else if (queryParam.value.frequCode === frequCodeEnum.longTerm) {
  596. frequFlag = item.frequCode !== 'ONCE'
  597. }
  598. if (queryParam.value.zhuangTai === 1) {
  599. zhuangTai = item.statusFlag === '1'
  600. } else if (queryParam.value.zhuangTai === 2) {
  601. zhuangTai = item.statusFlag === '2'
  602. } else if (queryParam.value.zhuangTai === 3) {
  603. zhuangTai = item.statusFlag === '3' || item.statusFlag === '4'
  604. } else if (queryParam.value.zhuangTai === 5) {
  605. zhuangTai = item.statusFlag === '5'
  606. }
  607. return flag && frequFlag && zhuangTai;
  608. })
  609. return XEUtils.orderBy(temp, [['actOrderNo', 'asc']])
  610. })
  611. // 获取医嘱的下标
  612. export const getYzIndex = (key: string) => {
  613. let temp = tempYzData.value.findIndex(item => {
  614. return item.id == key
  615. })
  616. if (typeof temp === 'undefined') {
  617. return '没有找到序号'
  618. } else {
  619. return temp
  620. }
  621. }
  622. interface yZErrorType {
  623. dialog: boolean
  624. type: number
  625. data: any
  626. }
  627. // 错误信息
  628. export const errorMsg: Ref<yZErrorType> = ref({
  629. dialog: false,
  630. type: 1,
  631. data: {}
  632. })
  633. // 添加新地会诊申请
  634. export const consultationApplication = ref(false)
  635. // 添加手术申请
  636. export const operationApplication = ref([])
  637. // 添加检查申请
  638. export const addCheckList = ref([])
  639. // 添加检验申请
  640. export const xuanZhongJianYan = ref({
  641. data: [],
  642. weiBianMa: [],
  643. daiXuanZhong: [],
  644. })
  645. // 检验树状图
  646. export const jyTree = ref([])
  647. // 检查树状图
  648. export const jcTree = ref([])
  649. export const mingXi = ref({
  650. weiYi: [],
  651. list: [],
  652. })
  653. export const jcExtraInformation = ref<ExtraInformationType>()
  654. export const jyExtraInformation = ref<ExtraInformationType>()
  655. interface ExtraInformationType {
  656. reqComment: string
  657. reqTzComment: string
  658. reqOtherResult: string
  659. diagCode: string
  660. diagText: string
  661. }
  662. const defaultExtraInformation: ExtraInformationType = {
  663. diagCode: "",
  664. diagText: "",
  665. reqOtherResult: "",
  666. reqTzComment: "",
  667. reqComment: ''
  668. }
  669. const strDefaultExtraInformation = JSON.stringify(defaultExtraInformation)
  670. export function clickTimeLimitReminder() {
  671. timeLimitPromptByPatientNo(huanZheXinXi.value.inpatientNo).then(res => {
  672. yzMitt.emit('setTimeLimitPrompt', res)
  673. })
  674. }
  675. /**
  676. * 点击查询患者信息
  677. * @param patNo 住院号
  678. */
  679. export const clickOnThePatient = async (patNo: string) => {
  680. switchPatients();
  681. huanZheXinXi.value = await getPatientInfo(patNo) as any;
  682. changePatientHook.forEach(item => {
  683. item()
  684. })
  685. getDrgPatInfo(huanZheXinXi.value).then(res => {
  686. if (res != null) {
  687. huanZheXinXi.value.groupInfoName = res['name']
  688. huanZheXinXi.value.groupInfoWeight = res['weight']
  689. huanZheXinXi.value.groupInfoBl = res['groupInfoBl']
  690. huanZheXinXi.value.setGroupInfoProfit = res['profit']
  691. huanZheXinXi.value.groupInfoFeeStand = res['fee_stand']
  692. }
  693. })
  694. if (yzMitt.exists('queryYz')) {
  695. await nextTick();
  696. await yzMitt.emit('queryYz');
  697. } else {
  698. await jsQueryYzData();
  699. }
  700. queryParam.value.frequCode = frequCodeEnum.all;
  701. queryParam.value.zhuangTai = 0;
  702. queryParam.value.displayRange = 2;
  703. clearAssociate();
  704. const temp = getAncillaryInformation(huanZheXinXi.value.inpatientNo, huanZheXinXi.value.admissTimes);
  705. if (temp) {
  706. let str = JSON.stringify(temp);
  707. jcExtraInformation.value = JSON.parse(str);
  708. jyExtraInformation.value = JSON.parse(str);
  709. } else {
  710. jcExtraInformation.value = JSON.parse(strDefaultExtraInformation);
  711. jyExtraInformation.value = JSON.parse(strDefaultExtraInformation);
  712. }
  713. }
  714. const switchPatients = (): boolean => {
  715. let str = ''
  716. if (stringNotBlank(yiZhuData.value.actOrderNo) && yiZhuData.value.statusFlag === '1') {
  717. if (yiZhuData.value.actOrderNo !== addTempOrderNo) {
  718. str += "存在未保存的医嘱。"
  719. }
  720. }
  721. if (yzMitt.exists('ssNotSave') && yzMitt.emit('ssNotSave')) {
  722. str += '存在未保存的手术申请。'
  723. }
  724. if (consultationApplication.value) {
  725. str += '存在未保存的会诊申请。'
  726. }
  727. if (addCheckList.value.length > 0) {
  728. str += '存在未保存的检查申请。'
  729. }
  730. if (xuanZhongJianYan.value.data.length > 0) {
  731. str += '存在未保存的检验申请。'
  732. }
  733. if (mingXi.value.list.length > 0) {
  734. str += '存在未保存的草药医嘱。'
  735. }
  736. if (stringIsBlank(huanZheXinXi.value.inpatientNo)) {
  737. addCheckList.value = []
  738. xuanZhongJianYan.value = {
  739. data: [],
  740. weiBianMa: [],
  741. daiXuanZhong: [],
  742. }
  743. return true
  744. } else {
  745. if (stringNotBlank(str)) {
  746. BizException(ExceptionEnum.LOGICAL_ERROR, str);
  747. }
  748. }
  749. return true;
  750. }
  751. // 是出院带药
  752. export function isCydy(): boolean {
  753. return queryParam.value.frequCode === frequCodeEnum.takeMedicine;
  754. }
  755. export const associateOrders = ref<{
  756. actOrderNo: number | null,
  757. associatedGroup: number[]
  758. }>({
  759. actOrderNo: null,
  760. associatedGroup: []
  761. })
  762. export const clearAssociate = () => {
  763. associateOrders.value = {
  764. actOrderNo: null,
  765. associatedGroup: []
  766. }
  767. XEUtils.lastEach(yzData.value, (item: YzType) => {
  768. item.associationFlag = false
  769. })
  770. }
  771. export const drugManual = ref({
  772. dialog: false,
  773. code: '',
  774. open: (code: string, serial: string) => {
  775. drugManual.value.dialog = true
  776. drugManual.value.code = code + '_' + serial
  777. }
  778. })
  779. export let tableHeader = [
  780. {label: '编码', prop: 'orderCode'},
  781. {label: '包装', prop: 'serial'},
  782. {label: '名称', prop: 'orderName', width: 220},
  783. {label: '规格', prop: 'drugSpecification'},
  784. {label: '描述', prop: 'discription'},
  785. {label: '库存', prop: 'stockAmount'},
  786. {label: '大包装', prop: 'specPack'},
  787. {label: '医保类型', prop: 'ybFlagNew'},
  788. {label: '医保编码', prop: 'nationalCode'},
  789. {label: '医保名称', prop: 'nationalName'},
  790. {label: '医保备注', prop: 'ybComment'},
  791. {label: '大输液', prop: 'infusionFlagName'},
  792. {label: '厂家', prop: 'manuName'},
  793. {label: '类型', prop: 'orderType'},
  794. {label: '毒麻类型', prop: 'drugFlagName'},
  795. {label: '药房', prop: 'groupName'},
  796. ]
  797. export declare type AddJcParams = {
  798. execDept: string,
  799. execDeptName: string,
  800. orderCode: string,
  801. orderName: string,
  802. note: string,
  803. collectionInfo: string;
  804. genderRestriction: number;
  805. minAgeRestriction: number;
  806. maxAgeRestriction: number;
  807. startTime?: string
  808. orderType?: string;
  809. isTheParentNode?: string
  810. }
  811. export const jyJcRestriction = (data: AddJcParams, error: boolean = true) => {
  812. if (stringNotBlank(huanZheXinXi.value.inpatientNo)) {
  813. if (data.genderRestriction && data.genderRestriction !== huanZheXinXi.value.sex) {
  814. error && BizException(ExceptionEnum.MESSAGE_ERROR, '患者性别不允许开此项目。')
  815. return false
  816. }
  817. if (data.minAgeRestriction && data.minAgeRestriction >= huanZheXinXi.value.age) {
  818. error && BizException(ExceptionEnum.MESSAGE_ERROR, "项目最小年龄限制" + data.minAgeRestriction + "岁,患者年龄不符合。")
  819. return false
  820. }
  821. if (data.maxAgeRestriction && data.maxAgeRestriction <= huanZheXinXi.value.age) {
  822. error && BizException(ExceptionEnum.MESSAGE_ERROR, "项目最大年龄限制" + data.maxAgeRestriction + "岁,患者年龄不符合。")
  823. return false
  824. }
  825. }
  826. return true
  827. }
  828. export const addJcCheck = async (data: AddJcParams) => {
  829. let temp = addCheckList.value.findIndex(item => {
  830. return item.orderCode === data.orderCode
  831. })
  832. if (temp > -1) {
  833. BizException(ExceptionEnum.MESSAGE_ERROR, '请勿重复添加。')
  834. }
  835. jyJcRestriction(data)
  836. data.startTime = await getServerDateApi();
  837. addCheckList.value.push(data)
  838. }
  839. export interface YzMitt {
  840. openDoctorAuthoriztion: (drugCode: string) => Promise<{
  841. code: string
  842. }>,
  843. jySave: () => void,
  844. jySaveTemplate: () => void
  845. upperDoctorSetting: (data: any) => void
  846. tableScroll: (val: number) => void
  847. clearSelected: () => void
  848. scrollEndAndTwinkle: (val: any) => Promise<void>,
  849. setOrderNoTwinkle: (val: number) => Promise<void>,
  850. getSelectedData: () => YzType[],
  851. toAddAnOrder: () => Promise<boolean>,
  852. duplicateAndPaste: () => void
  853. openTheOrderPopUpWindow: () => void,
  854. emptyTheWorkbench: () => void
  855. copy: (actOrderNo: number, frequCode: string) => void,
  856. paste: () => void
  857. allowReplication: () => boolean,
  858. deleteAnOrderByOrderNo: (data: YzType, clearOrNot: boolean) => void
  859. queryYz: (tableScrollTop?: boolean) => Promise<any>,
  860. confirmMedicalAdvice: () => void,
  861. allergen: () => void,
  862. clickOnTheOrderTemplate: () => void,
  863. clickAssociate: (data: YzType) => Promise<void>
  864. rowClick: (data: YzType) => void
  865. queryFeeByOrderNo: (data: YzType) => void,
  866. setTimeLimitPrompt: (data: any) => void
  867. ssNotSave: () => boolean
  868. getCurrentWard: () => string
  869. [key: string]: (...args: any[]) => any
  870. }
  871. export const yzMitt = new EventBus<YzMitt>();
  872. export const yzSize = ref({
  873. w: 0,
  874. h: 0
  875. })
  876. export const confirmLoading = ref<boolean>(false)
  877. /**
  878. * 参数一 : 项目编码
  879. * 参数二:项目的类型 00 - 项目 01-小包装 09 - 大包装
  880. * 参数三: 患者当前科室
  881. * 参数四,当前选中的药房
  882. * 参数五:授权的医生
  883. * 参数六:当前医嘱的状态
  884. * @param val 参数
  885. */
  886. export function feeKey(...val: string[]) {
  887. return val.join("_")
  888. }
  889. /**
  890. * 两个数据中把 右边的数据根据 name 赋值给左边的数据
  891. */
  892. export class RefFillingValue<R, F> {
  893. private refData: Ref<R>;
  894. private readonly FillingData: F;
  895. constructor(refData: Ref<R>, FillingData: F) {
  896. this.refData = refData
  897. this.FillingData = FillingData
  898. }
  899. /**
  900. * 把左边的值填充到右边
  901. * @param name 根据名称填充
  902. */
  903. setValue(name: keyof F) {
  904. // @ts-ignore
  905. this.refData.value[name] = this.FillingData[name]
  906. return this
  907. }
  908. /**
  909. * 为第一个数据填充默认值
  910. * @param name ref 中的 key
  911. * @param value 要赋的值
  912. */
  913. setDefaultValueByName(name: keyof R, value: any) {
  914. this.refData.value[name] = value
  915. return this
  916. }
  917. }
  918. const changePatientHook = new Map();
  919. let changePatientHookLength = 0;
  920. export function onChangePatient(cb: () => void) {
  921. new ChangePatient(changePatientHookLength++, cb)
  922. }
  923. function ChangePatient(index: number, cb: () => void) {
  924. onActivated(() => {
  925. changePatientHook.set(index, cb)
  926. if (huanZheXinXi.value.inpatientNo) {
  927. cb()
  928. }
  929. })
  930. onDeactivated(() => {
  931. changePatientHook.delete(index)
  932. })
  933. }
  934. export const openPatientImage = (value: string | { patNo?: string, patientUid?: string }): void => {
  935. if (XEUtils.isString(value)) {
  936. window.open(`http://172.16.32.122:8081/Clinical?inHospitalNum=${value}`, '_blank')
  937. }
  938. if (XEUtils.isObject(value)) {
  939. if (value.patientUid) {
  940. window.open(`http://172.16.32.122:8081/Clinical?patientUid=${value.patientUid}`, '_blank')
  941. return
  942. }
  943. }
  944. }