123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- import router from "@/router";
- import * as api from "@/api/inpatient/xiang-mu-lu-ru";
- import XEUtils from "xe-utils";
- import { BizException, ExceptionEnum } from "@/utils/BizException";
- import useCompRef from "@/utils/useCompRef";
- import { ElTable } from "element-plus";
- import { refund } from "@/api/hospitalization-costs/hospitalization-costs-api";
- import { isDev } from "@/utils/public";
- import cyRefList from "@/utils/cyRefList";
- import { useDialog, UseDialogType } from "@/components/cy/CyDialog/index";
- import { useUserStore } from "@/pinia/user-store";
- import { getServerDateApi } from "@/api/public-api";
- import PrintPrescriptionSign from "@/components/xmlr/components/PrintPrescriptionSign.vue";
- import {
- getFrequency,
- getSupplyType,
- } from "@/api/zhu-yuan-yi-sheng/yi-zhu-lu-ru";
- import dayjs from "dayjs";
- type PatInfo = {
- name?: string;
- inpatientNo?: string;
- admissTimes?: number;
- zySerialNo?: string;
- ledgerSn?: number;
- zkWard?: string;
- admissDept?: string;
- referPhysician?: string;
- ward?: string;
- };
- type ChargeCodeType = {
- chargeCodeMx: string;
- serial: string;
- chargeName: string;
- deptCode: string;
- chargeAmount: number;
- amount: number;
- doctorCode: string;
- };
- export type XmlrProps = {
- patNo?: string;
- medicalTechnology?: boolean;
- };
- export const useXmlr = (props: XmlrProps, emits: UseDialogType.Emits) => {
- const userInfo = useUserStore().userInfo;
- const store = reactive({
- // 住院号
- searchPatNo: isDev ? "0434450" : "",
- // 患者信息
- patInfo: {} as PatInfo,
- searchFeeParams: {
- orderNo: "",
- chargeCode: "",
- startTime: "",
- endTime: "",
- orderBy: true,
- chargeType: 0,
- feeSources: 2,
- refundSymbol: 3,
- execDept: props.medicalTechnology ? (isDev ? "" : userInfo.deptCode) : "",
- },
- tabsVal: isDev ? "费用" : "费用",
- feeTotal: 0,
- feeData: [],
- feeCurrentPage: 1,
- feePageSize: 10,
- queryWard: "",
- queryDept: "",
- chargeDate: "",
- });
- const [saveData, saveProxy] = cyRefList<ChargeCodeType>(
- item => {
- return item.chargeCodeMx.trim() + "_" + item.serial.trim();
- },
- item => {
- return `项目【${item.chargeName}】请勿重复添加`;
- }
- );
- const feeTableRef = useCompRef(ElTable);
- const muBanRef = shallowRef();
- const mutation = {
- async getPatInfo(times: number = null) {
- await api
- .getPatientInfo(store.searchPatNo, times)
- .then(res => {
- store.patInfo = res;
- mutation.getFee();
- store.queryWard = res?.admissDept;
- store.queryDept = res?.zkWard;
- getServerDateApi()
- .then(res => {
- //@ts-ignore
- store.chargeDate = res;
- })
- .catch(() => {
- //@ts-ignore
- store.chargeDate = dayjs(new Date()).format(
- "YYYY-MM-DD hh:mm:ss"
- );
- });
- return res;
- })
- .catch(() => {
- mutation.clearData();
- return {};
- });
- },
- getFee() {
- if (XEUtils.isEmpty(store.patInfo)) {
- BizException(ExceptionEnum.MESSAGE_ERROR, "请先查询患者");
- }
- feeTableRef.value.clearSelection();
- api
- .getFee({
- inpatientNo: store.patInfo.inpatientNo,
- admissTimes: store.patInfo.admissTimes,
- medicalTechnology: props.medicalTechnology,
- ...store.searchFeeParams,
- })
- .then(res => {
- store.feeData = res.data;
- store.feeTotal = res.feeTotal;
- });
- },
- clearData() {
- store.patInfo = {};
- store.feeData = [];
- store.feeTotal = 0;
- store.feeCurrentPage = 1;
- saveProxy.clear();
- },
- refund(value) {
- refund({
- inpatientNo: store.patInfo.inpatientNo,
- admissTimes: store.patInfo.admissTimes,
- groupNo: value.groupNo,
- list: value.data,
- }).then(res => {
- mutation.getFee();
- });
- },
- async setPatNo(patNo: string) {
- if (patNo) {
- store.searchPatNo = patNo as string;
- await mutation.getPatInfo();
- }
- },
- closeDialog() {
- emits("cyDialogConfirm");
- },
- feeTableSummaryMethod() {
- const tmp = [];
- tmp[9] = `${store.feeTotal} 元`;
- return tmp;
- },
- async handlePrintPrescriptionSign() {
- const data = feeTableRef.value.getSelectionRows();
- if (data.length === 0) {
- return;
- }
- const filter = XEUtils.filter(data, item => {
- return item.orderNo === 6 && item.serial !== "00";
- });
- if (filter.length === 0) {
- return;
- }
- const frequency = await mutation.getExecutionFrequency();
- const supplyType = await mutation.getSupplyType();
- useDialog(PrintPrescriptionSign, {
- dialogProps: {
- title: "打印处方签",
- fullscreen: true,
- },
- confirmText: "打印",
- params: {
- data: XEUtils.cloneDeep(filter),
- frequency,
- supplyType,
- patientInfo: store.patInfo,
- },
- });
- },
- getExecutionFrequency: XEUtils.once(async () => {
- return await getFrequency();
- }),
- getSupplyType: XEUtils.once(async () => {
- return await getSupplyType();
- }),
- };
- onActivated(() => {
- const patNo = router.currentRoute.value.query.patNo;
- mutation.setPatNo(patNo as string);
- });
- onMounted(async () => {
- await mutation.setPatNo(props.patNo);
- });
- return {
- mutation,
- store,
- feeTableRef,
- medicalTechnology: props.medicalTechnology,
- saveData,
- saveProxy,
- muBanRef,
- };
- };
- export const key = "projectInput";
- export type ProjectInput = ReturnType<typeof useXmlr>;
|