zhu-yuan-yi-sheng.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. // 判断是否选择了患者
  2. import {stringIsBlank, stringNotBlank} from "@/utils/blank-utils";
  3. import {ElMessage} from "element-plus";
  4. import {getPatientInfo} from "@/api/inpatient/patient";
  5. import {BizException, ExceptionEnum} from "@/utils/BizException";
  6. import {ref} from "vue";
  7. import {getServerDateApi} from "@/api/public-api";
  8. import {getFormatDatetime} from "@/utils/date";
  9. import {isDev} from "@/utils/public";
  10. import {getFrequency, getSupplyType, huoQuYiZhuShuJu} from "@/api/zhu-yuan-yi-sheng/yi-zhu-lu-ru";
  11. import EventBus from "@/utils/mitt";
  12. import {hzMitt, hzMittEnum} from "@/views/hospitalization/zhu-yuan-yi-sheng/hui-zhen/hui-zhen";
  13. // 患者信息
  14. export const huanZheXinXi = ref({})
  15. // 是否点击了修改整个模板
  16. export const muBanMing = ref({})
  17. // 错误信息
  18. export const cuoWuXinXi = ref('')
  19. // 头部大小
  20. export const yzHeaderSize = ref(0)
  21. // 给药方式
  22. export const geiYaoFangShiData = ref([])
  23. // 频率
  24. export const yaoPinPingLvData = ref([])
  25. getSupplyType().then(res => {
  26. geiYaoFangShiData.value = res
  27. })
  28. getFrequency().then(res => {
  29. yaoPinPingLvData.value = res
  30. })
  31. export function youWuXuanZheHuanZhe() {
  32. if (stringIsBlank(huanZheXinXi.value.inpatientNo)) {
  33. ElMessage({
  34. message: '请先选择患者', showClose: true, type: 'error'
  35. })
  36. return true
  37. }
  38. return false
  39. }
  40. export function getSelfBuy(val) {
  41. if (stringIsBlank(val)) return ""
  42. switch (val) {
  43. case '1':
  44. return "自备"
  45. case '2':
  46. return "嘱托"
  47. case '3':
  48. return "基数药"
  49. default:
  50. return "";
  51. }
  52. }
  53. export function shouShuDengJi(val) {
  54. if (stringIsBlank(val)) return ""
  55. switch (val) {
  56. case "1":
  57. return "四级";
  58. case "2":
  59. return "三级";
  60. case "3":
  61. return "二级";
  62. case "4":
  63. return "一级";
  64. default:
  65. return "";
  66. }
  67. }
  68. export let zkList = ref([])
  69. export const frequCodeEnum = {
  70. all: 'all',
  71. temporary: 'temporary',
  72. longTerm: 'longTerm',
  73. always: 'ALWAYS',
  74. takeMedicine: 'takeMedicine',
  75. }
  76. // 医嘱数据
  77. export const yiZhuData = ref({
  78. id: '',
  79. actOrderNo: isDev ? 'tempOrderNo' : null,
  80. orderName: '',
  81. orderCode: '',
  82. // 频率
  83. frequCode: '',
  84. frequCodeName: '',
  85. drugSpecification: '',
  86. dose: 0,
  87. // 领量
  88. doseUnit: '',
  89. doseUnitName: '',
  90. supplyCode: '',
  91. supplyCodeName: '',
  92. startTime: '',
  93. endTime: '',
  94. orderTime: '',
  95. doctorName: '',
  96. drugFlag: '',
  97. execUnit: '',
  98. execUnitName: '',
  99. parentNo: '',
  100. parentNoName: '',
  101. physicianName: '',
  102. discription: '',
  103. instruction: null,
  104. kfFlag: null,
  105. selfBuy: null,
  106. ybSelfFlag: '0',
  107. emergencyFlag: '0',
  108. drugQuan: 0,
  109. miniUnitName: '',
  110. serial: '',
  111. miniUnit: '',
  112. psFlag: false,
  113. kjywFlag: 0,
  114. yyfs: null,
  115. ssqk: null,
  116. yysj: null,
  117. zkObj: '',
  118. zkWardCode: '',
  119. zkDeptCode: '',
  120. statusFlag: '1',
  121. groupNo: '00',
  122. // 包装规格
  123. packSizeName: '',
  124. packUnit: '',
  125. // 执行用量
  126. drugOcc: ''
  127. });
  128. export const yiZhuDataInit = () => {
  129. yiZhuData.value = {
  130. id: '',
  131. actOrderNo: isDev ? 'tempOrderNo' : null,
  132. orderName: '',
  133. orderCode: '',
  134. // 频率
  135. frequCode: '',
  136. frequCodeName: '',
  137. drugSpecification: '',
  138. dose: 0,
  139. // 领量
  140. doseUnit: '',
  141. doseUnitName: '',
  142. supplyCode: '',
  143. supplyCodeName: '',
  144. startTime: '',
  145. endTime: '',
  146. orderTime: '',
  147. doctorName: '',
  148. drugFlag: '',
  149. execUnit: '',
  150. execUnitName: '',
  151. parentNo: '',
  152. parentNoName: '',
  153. physicianName: '',
  154. discription: '',
  155. instruction: null,
  156. kfFlag: null,
  157. selfBuy: null,
  158. ybSelfFlag: '0',
  159. emergencyFlag: '0',
  160. drugQuan: 0,
  161. miniUnitName: '',
  162. serial: '',
  163. miniUnit: '',
  164. psFlag: false,
  165. kjywFlag: 0,
  166. yyfs: null,
  167. ssqk: null,
  168. yysj: null,
  169. zkObj: '',
  170. zkWardCode: '',
  171. zkDeptCode: '',
  172. statusFlag: '1',
  173. groupNo: '00',
  174. packSize: 0,
  175. }
  176. }
  177. // 保存医嘱数据
  178. export const yzData = ref([])
  179. export const jsQueryYzData = () => {
  180. if (stringNotBlank(huanZheXinXi.value.inpatientNo)) {
  181. huoQuYiZhuShuJu({
  182. patNo: huanZheXinXi.value.inpatientNo,
  183. times: huanZheXinXi.value.admissTimes
  184. }).then(res => {
  185. yzData.value = res
  186. });
  187. }
  188. }
  189. let newDate = ''
  190. getServerDateApi().then(res => {
  191. newDate = res
  192. })
  193. // 医嘱查询条件
  194. export const queryParam = ref({
  195. displayRange: 0,
  196. frequCode: isDev ? frequCodeEnum.all : frequCodeEnum.longTerm,
  197. zhuangTai: isDev ? 0 : 3,
  198. groupNo: '73',
  199. patNo: '',
  200. times: 0,
  201. });
  202. // 数据筛选
  203. export const tempYzData = computed(() => {
  204. return yzData.value.filter((item, index) => {
  205. let flag = queryParam.value.displayRange === 0
  206. let frequFlag = queryParam.value.frequCode === frequCodeEnum.all
  207. let zhuangTai = queryParam.value.zhuangTai === 0
  208. if (isCydy()) {
  209. return item.selfBuy === '4'
  210. }
  211. if (queryParam.value.displayRange === 1) {
  212. // 停止的医嘱
  213. flag = item.statusFlag === '5'
  214. } else if (queryParam.value.displayRange === 2) {
  215. flag = item.statusFlag === '2' || item.statusFlag === '3' || item.statusFlag === '4'
  216. } else if (queryParam.value.displayRange === 3) {
  217. flag = getFormatDatetime(newDate, 'YYYY-MM-DD') === getFormatDatetime(item.startTime, 'YYYY-MM-DD')
  218. }
  219. if (queryParam.value.frequCode === frequCodeEnum.temporary) {
  220. frequFlag = item.frequCode === 'ONCE'
  221. } else if (queryParam.value.frequCode === frequCodeEnum.longTerm) {
  222. frequFlag = item.frequCode !== 'ONCE'
  223. }
  224. if (queryParam.value.zhuangTai === 1) {
  225. zhuangTai = item.statusFlag === '1'
  226. } else if (queryParam.value.zhuangTai === 2) {
  227. zhuangTai = item.statusFlag === '2'
  228. } else if (queryParam.value.zhuangTai === 3) {
  229. zhuangTai = item.statusFlag === '3' || item.statusFlag === '4'
  230. } else if (queryParam.value.zhuangTai === 5) {
  231. zhuangTai = item.statusFlag === '5'
  232. }
  233. return flag && frequFlag && zhuangTai && item.selfBuy !== '4';
  234. }).sort((a, b) => {
  235. return a.actOrderNo - b.actOrderNo
  236. })
  237. })
  238. // 获取医嘱的下标
  239. export const getYzIndex = (key) => {
  240. let temp = tempYzData.value.findIndex(item => {
  241. return item.id == key
  242. })
  243. if (typeof temp === 'undefined') {
  244. return '没有找到序号'
  245. } else {
  246. return temp
  247. }
  248. }
  249. // 错误信息
  250. export const errorMsg = ref({
  251. dialog: false,
  252. type: 1,
  253. data: {}
  254. })
  255. // 添加新的会诊申请
  256. export const consultationApplication = ref(false)
  257. // 添加手术申请
  258. export const operationApplication = ref([])
  259. // 添加检查申请
  260. export const addCheckList = ref([])
  261. // 添加检验申请
  262. export const xuanZhongJianYan = ref({
  263. data: [],
  264. weiBianMa: [],
  265. daiXuanZhong: [],
  266. })
  267. // 检验树状图
  268. export const jyTree = ref([])
  269. // 检查树状图
  270. export const jcTree = ref([])
  271. /**
  272. * 具体的草药明细
  273. * @type {Ref<UnwrapRef<{weiYi: *[], list: *[]}>>}
  274. */
  275. export const mingXi = ref({
  276. weiYi: [],
  277. list: [],
  278. })
  279. /**
  280. * 点击查询患者信息
  281. * @param patNo 住院号
  282. */
  283. export const clickOnThePatient = async (patNo) => {
  284. switchPatients()
  285. huanZheXinXi.value = await getPatientInfo(patNo)
  286. clearAssociate()
  287. }
  288. const switchPatients = () => {
  289. let str = ''
  290. if (stringNotBlank(yiZhuData.value.actOrderNo) && yiZhuData.value.statusFlag === '1') {
  291. if (yiZhuData.value.actOrderNo !== 'tempOrderNo') {
  292. str += "存在未保存的医嘱。"
  293. }
  294. }
  295. if (operationApplication.value.length > 0) {
  296. str += '存在未保存的手术申请。'
  297. }
  298. if (consultationApplication.value) {
  299. str += '存在未保存的会诊申请。'
  300. }
  301. if (addCheckList.value.length > 0) {
  302. str += '存在未保存的检查申请。'
  303. }
  304. if (xuanZhongJianYan.value.data.length > 0) {
  305. str += '存在未保存的检验申请。'
  306. }
  307. if (mingXi.value.list.length > 0) {
  308. str += '存在未保存的草药医嘱。'
  309. }
  310. if (stringIsBlank(huanZheXinXi.value.inpatientNo)) {
  311. return true
  312. } else {
  313. if (stringNotBlank(str)) {
  314. BizException(ExceptionEnum.LOGICAL_ERROR, str);
  315. }
  316. }
  317. return true;
  318. }
  319. // 是出院带药
  320. export function isCydy() {
  321. return queryParam.value.frequCode === frequCodeEnum.takeMedicine;
  322. }
  323. export const associateOrders = ref({
  324. actOrderNo: null,
  325. associatedGroup: []
  326. })
  327. export const clearAssociate = () => {
  328. associateOrders.value = {
  329. actOrderNo: null,
  330. associatedGroup: []
  331. }
  332. for (let i = 0, len = yzData.value.length; i < len; i++) {
  333. let item = yzData.value[i]
  334. item.associationFlag = false
  335. }
  336. }
  337. export const drugManual = ref({
  338. dialog: false,
  339. code: '',
  340. open: (code, serial) => {
  341. drugManual.value.dialog = true
  342. drugManual.value.code = code + '_' + serial
  343. }
  344. })
  345. export let tableHeader = [
  346. {label: '编码', prop: 'orderCode'},
  347. {label: '包装', prop: 'serial'},
  348. {label: '名称', prop: 'orderName', width: 220},
  349. {label: '规格', prop: 'drugSpecification'},
  350. {label: '描述', prop: 'discription'},
  351. {label: '库存', prop: 'stockAmount'},
  352. {label: '大包装', prop: 'specPack'},
  353. {label: '医保类型', prop: 'ybFlagNew'},
  354. {label: '医保编码', prop: 'nationalCode'},
  355. {label: '医保名称', prop: 'nationalName'},
  356. {label: '医保备注', prop: 'ybComment'},
  357. {label: '大输液', prop: 'infusionFlagName'},
  358. {label: '厂家', prop: 'manuName'},
  359. {label: '类型', prop: 'orderType'},
  360. {label: '毒麻类型', prop: 'drugFlagName'},
  361. {label: '药房', prop: 'groupName'},
  362. ]
  363. export const addJcCheck = async (data) => {
  364. let temp = addCheckList.value.findIndex(item => {
  365. return item.orderCode === data.orderCode
  366. })
  367. if (temp > -1) {
  368. BizException(ExceptionEnum.MESSAGE_ERROR, '请勿重复添加。')
  369. }
  370. data.startTime = await getServerDateApi()
  371. addCheckList.value.push(data)
  372. }
  373. export const yzMitt = new EventBus();