zhu-yuan-yi-sheng.ts 29 KB

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