zhu-yuan-yi-sheng.ts 29 KB

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