diff --git a/apps/web-antd/src/views/business/chat/components/PrescriptionModal.vue b/apps/web-antd/src/views/business/chat/components/PrescriptionModal.vue index 67d2e88f..11b2a80f 100644 --- a/apps/web-antd/src/views/business/chat/components/PrescriptionModal.vue +++ b/apps/web-antd/src/views/business/chat/components/PrescriptionModal.vue @@ -332,15 +332,15 @@ function openCommonPrescriptionModal() { /** * 处理选择常用方 * @param data 常用方数据,包含prescription和recipes - * @param type 类型:1-中药,2-西药,3-颗粒药 + * @param type 类型:1-西药,2-中药,3-颗粒药 * @description 选择常用方后,将药品列表填充到当前处方中 */ -function handleSelectCommonPrescription(data: any, type: number) { +async function handleSelectCommonPrescription(data: any, type: number) { const { prescription, recipes } = data; // 根据类型处理不同的药品数据 - if (type === 2) { - // 西药(中成药)处方 + if (type === 1) { + // 西药处方 recipes.forEach((recipe: any) => { const newProduct = { index_id: recipe.drug_id || recipe.id, @@ -389,13 +389,34 @@ function handleSelectCommonPrescription(data: any, type: number) { prescriptionStore.currentDrugs.push(newProduct); } }); + + // 写入规则类型和剂量信息(中药)- 使用 ?? 运算符提供默认值 + prescriptionStore.ruleType = prescription.rule_type ?? 1; + prescriptionStore.dosage = prescription.dosage ?? 7; + prescriptionStore.dayDosage = prescription.day_dosage ?? 2; + prescriptionStore.packageMethodId = prescription.package_method_id ?? 2; + + // 如果是委托调剂,写入完整加工规则配置 - 只有有效值才写入(大于0),级联加载 + if (prescription.process_rule_id && prescription.process_rule_id > 0) { + prescriptionStore.processRuleId = prescription.process_rule_id; + // 加载煎法选项 + await prescriptionStore.getProcessRuleListData(prescription.process_rule_id, 0); + } + if (prescription.child_process_rule_id && prescription.child_process_rule_id > 0) { + prescriptionStore.childProcessRuleId = prescription.child_process_rule_id; + // 加载备注选项 + await prescriptionStore.getProcessRuleListData(0, prescription.child_process_rule_id); + } + if (prescription.process_rule_note_id && prescription.process_rule_note_id > 0) { + prescriptionStore.processRuleNoteId = prescription.process_rule_note_id; + } } - // 更新诊断和医嘱 - if (prescription.clinical_diagnose) { + // 更新诊断和医嘱 - 允许空字符串覆盖 + if (prescription.clinical_diagnose !== undefined && prescription.clinical_diagnose !== null) { prescriptionStore.diagnosis = prescription.clinical_diagnose; } - if (prescription.doctor_order) { + if (prescription.doctor_order !== undefined && prescription.doctor_order !== null) { prescriptionStore.medicalAdvice = prescription.doctor_order; } diff --git a/apps/web-antd/src/views/doctor/doctor-reception/components/CommonPrescriptionModal.vue b/apps/web-antd/src/views/doctor/doctor-reception/components/CommonPrescriptionModal.vue index add67cb5..89f63f90 100644 --- a/apps/web-antd/src/views/doctor/doctor-reception/components/CommonPrescriptionModal.vue +++ b/apps/web-antd/src/views/doctor/doctor-reception/components/CommonPrescriptionModal.vue @@ -288,6 +288,18 @@ function getDrugCount(recipes: any[]): number { 医嘱: {{ item.doctor_order }}
++ 调配方式: + {{ item.rule_type === 1 ? '自制剂' : '委托调剂' }} + 剂量:{{ item.dosage || 7 }}天/剂 + 频次:{{ item.day_dosage || 2 }}次/天 +
++ 委托调剂: + 制剂:{{ item.process_rule_name }} + 煎法:{{ item.child_process_rule_name }} + 备注:{{ item.process_rule_note_name }} +
药品:
{{
diff --git a/apps/web-antd/src/views/doctor/doctor-reception/index.vue b/apps/web-antd/src/views/doctor/doctor-reception/index.vue
index 43fbfecf..40bc1f21 100644
--- a/apps/web-antd/src/views/doctor/doctor-reception/index.vue
+++ b/apps/web-antd/src/views/doctor/doctor-reception/index.vue
@@ -8,6 +8,7 @@ import {
DeleteTwoTone,
MinusOutlined,
PlusOutlined,
+ SaveOutlined,
} from '@ant-design/icons-vue';
import {
Button,
@@ -17,6 +18,7 @@ import {
Empty,
Image,
ImagePreviewGroup,
+ Input,
InputNumber,
message,
RadioButton,
@@ -24,7 +26,7 @@ import {
Row,
Select,
SelectOption,
- Modal,
+ Modal as AntModal,
Tag,
Textarea,
Timeline,
@@ -54,6 +56,11 @@ import RefusalOfTreatmentModal
from "#/views/doctor/doctor-reception/components/RefusalOfTreatmentModal.vue";
// 常用方选择弹窗组件
import CommonPrescriptionModal from './components/CommonPrescriptionModal.vue';
+// 保存常用方API
+import {
+ saveChineseCommonPrescriptionApi,
+ saveWestCommonPrescriptionApi,
+} from '#/views/doctor/settings/api';
interface Patient {
id: number;
@@ -171,6 +178,14 @@ const ruleType = ref(1);
const prescriptionList = ref([]);
const drugList = ref([]);
+// ==================== 保存常用方相关状态 ====================
+/** 保存常用方弹窗是否显示 */
+const showSaveCommonPrescriptionModal = ref(false);
+/** 常用方名称输入 */
+const commonPrescriptionName = ref('');
+/** 是否正在保存常用方 */
+const isSavingCommonPrescription = ref(false);
+
/**
* 获取药品使用方式列表
*/
@@ -680,7 +695,7 @@ function openCommonPrescriptionModal() {
* @param type 类型:1-西药,2-中药,3-颗粒药
* @description 选择常用方后,将药品列表填充到当前处方中
*/
-function handleSelectCommonPrescription(data: any, type: number) {
+async function handleSelectCommonPrescription(data: any, type: number) {
const { prescription, recipes } = data;
// 根据类型处理不同的药品数据
@@ -735,19 +750,150 @@ function handleSelectCommonPrescription(data: any, type: number) {
currentDrugs.value.push(newProduct);
}
});
+
+ // 写入规则类型和剂量信息(中药)- 使用 ?? 运算符提供默认值
+ ruleType.value = prescription.rule_type ?? 1;
+ dosage.value = prescription.dosage ?? 7;
+ dayDosage.value = prescription.day_dosage ?? 2;
+ packageMethodId.value = prescription.package_method_id ?? 2;
+
+ // 如果是委托调剂,写入完整加工规则配置 - 只有有效值才写入(大于0),级联加载
+ if (prescription.process_rule_id && prescription.process_rule_id > 0) {
+ processRuleId.value = prescription.process_rule_id;
+ // 加载煎法选项
+ await loadProcessRuleData(prescription.process_rule_id, 0);
+ }
+ if (prescription.child_process_rule_id && prescription.child_process_rule_id > 0) {
+ childProcessRuleId.value = prescription.child_process_rule_id;
+ // 加载备注选项
+ await loadProcessRuleData(0, prescription.child_process_rule_id);
+ }
+ if (prescription.process_rule_note_id && prescription.process_rule_note_id > 0) {
+ processRuleNoteId.value = prescription.process_rule_note_id;
+ }
}
- // 更新诊断和医嘱
- if (prescription.clinical_diagnose) {
+ // 更新诊断和医嘱 - 允许空字符串覆盖
+ if (prescription.clinical_diagnose !== undefined && prescription.clinical_diagnose !== null) {
diagnosis.value = prescription.clinical_diagnose;
}
- if (prescription.doctor_order) {
+ if (prescription.doctor_order !== undefined && prescription.doctor_order !== null) {
medicalAdvice.value = prescription.doctor_order;
}
// 保存到本地存储
updateLocalStorage();
}
+
+// ==================== 保存常用方相关方法 ====================
+
+/**
+ * 打开保存常用方弹窗
+ * @description 检查是否有药品可保存,然后打开弹窗
+ */
+const openSaveCommonPrescriptionModal = () => {
+ // 检查是否有药品
+ if (currentDrugs.value.length === 0) {
+ message.warning('请先添加药品后再保存为常用方');
+ return;
+ }
+ // 清空输入框
+ commonPrescriptionName.value = '';
+ // 打开弹窗
+ showSaveCommonPrescriptionModal.value = true;
+};
+
+/**
+ * 保存当前处方为常用方
+ * @description 根据当前药品类型(中药/西药)调用不同的保存接口
+ */
+const saveAsCommonPrescription = async () => {
+ // 验证名称
+ if (!commonPrescriptionName.value.trim()) {
+ message.warning('请输入常用方名称');
+ return;
+ }
+
+ // 验证是否有药品
+ if (currentDrugs.value.length === 0) {
+ message.warning('没有可保存的药品');
+ return;
+ }
+
+ isSavingCommonPrescription.value = true;
+
+ try {
+ // 根据处方类型选择不同的保存接口
+ if (activeCategory.value === 1) {
+ // 中药处方 - 构建药品详细信息数组
+ const drugs = currentDrugs.value.map((drug) => ({
+ drug_id: drug.id,
+ drug_name: drug.drug_name,
+ number: drug.number || 1,
+ price: drug.price || 0,
+ way_id: drug.way_id || 0,
+ }));
+
+ await saveChineseCommonPrescriptionApi({
+ name: commonPrescriptionName.value.trim(),
+ drugs,
+ store_id: myStoreId.value,
+ clinical_diagnose: diagnosis.value || '',
+ doctor_order: medicalAdvice.value || '',
+ category: String(category.value),
+ dosage: dosage.value,
+ day_dosage: dayDosage.value,
+ rule_type: ruleType.value,
+ package_method_id: ruleType.value === 1 ? packageMethodId.value : undefined,
+ process_rule_id: ruleType.value === 2 ? (processRuleId.value || undefined) : undefined,
+ child_process_rule_id: ruleType.value === 2 ? (childProcessRuleId.value || undefined) : undefined,
+ process_rule_note_id: ruleType.value === 2 ? (processRuleNoteId.value || undefined) : undefined,
+ });
+ } else {
+ // 西药处方 - 构建药品详细信息数组
+ const drugs = currentDrugs.value.map((drug) => ({
+ drug_id: drug.id,
+ drug_name: drug.drug_name,
+ number: drug.number || 1,
+ price: drug.price || 0,
+ image: drug.image || '',
+ instruction: drug.instruction || '',
+ use_type_id: drug.use_type?.id || 0,
+ use_frequency_id: drug.use_frequency?.id || 0,
+ use_time_id: drug.use_num?.id || 0,
+ unit_id: drug.unit?.id || 0,
+ select_number: drug.select_number || 1,
+ }));
+
+ await saveWestCommonPrescriptionApi({
+ name: commonPrescriptionName.value.trim(),
+ drugs,
+ store_id: myStoreId.value,
+ clinical_diagnose: diagnosis.value || '',
+ doctor_order: medicalAdvice.value || '',
+ category: String(category.value),
+ });
+ }
+
+ message.success('常用方保存成功');
+ showSaveCommonPrescriptionModal.value = false;
+ commonPrescriptionName.value = '';
+ } catch (error) {
+ console.error('保存常用方失败:', error);
+ message.error('保存常用方失败,请稍后重试');
+ } finally {
+ isSavingCommonPrescription.value = false;
+ }
+};
+
+/**
+ * 取消保存常用方
+ */
+const cancelSaveCommonPrescription = () => {
+ showSaveCommonPrescriptionModal.value = false;
+ commonPrescriptionName.value = '';
+};
+
const openWesternModal = () => {
// 打开西药处方模态框逻辑
WesternDrugModalApi.setData({
@@ -863,28 +1009,19 @@ const processRuleId = ref();
const processRuleNoteId = ref();
const childProcessRuleId = ref();
-function getProcessRuleListByDoctor(pid = 0, ruleId = 0) {
- let data = {};
- data =
- ruleId === 0
- ? {
- pid,
- }
- : {
- rule_id: ruleId,
- };
- getProcessRuleList(data).then((value) => {
- if (ruleId !== 0) {
- processRuleNoteList.value = value;
- } else if (pid === 0) {
- processRuleList.value = value;
- } else {
- childProcessRuleList.value = value;
- }
- });
+async function loadProcessRuleData(pid = 0, ruleId = 0) {
+ const data = ruleId === 0 ? { pid } : { rule_id: ruleId };
+ const value = await getProcessRuleList(data);
+ if (ruleId !== 0) {
+ processRuleNoteList.value = value;
+ } else if (pid === 0) {
+ processRuleList.value = value;
+ } else {
+ childProcessRuleList.value = value;
+ }
}
-getProcessRuleListByDoctor();
+loadProcessRuleData();
/**
* 选择煎法
@@ -1556,6 +1693,14 @@ watch(
>
选择常用方
+
【{{ item }}】 【{{ item }}】 如需继续开方需要二次签名,确认要二次签名吗?
+ 将当前处方({{ currentDrugs.length }}种药品)保存为常用方模板
+
+ 类型:{{ activeCategory === 1 ? '中药' : '西药(中成药)' }}
+
医嘱:{{ item.doctor_order }}
+ 调配方式:
+ {{ item.rule_type === 1 ? '自制剂' : '委托调剂' }}
+ 剂量:{{ item.dosage || 7 }}天/剂
+ 频次:{{ item.day_dosage || 2 }}次/天
+
+ 委托调剂配置:
+ 制剂:{{ item.process_rule_name }}
+ 煎法:{{ item.child_process_rule_name }}
+ 备注:{{ item.process_rule_note_name }}
+
药品:
- {{ getDrugNames(commonPrescriptionData.chinese[index], 'name') }}
+ {{ getDrugNames(commonPrescriptionData.chinese[index], 'drug_name') }}