zhu-yuan-yi-sheng.ts 30 KB

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