zhu-yuan-yi-sheng.ts 29 KB

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