fix(order): 解决医嘱类型字段处理问题

- 优化了JSON解析逻辑,避免重复解析contentJson字段
- 确保therapyEnum字段正确传递,默认值设置为长期医嘱('1')
- 修复了医嘱保存和签发过程中类型字段丢失的问题
- 统一了前后端therapyEnum字段的默认值处理逻辑
- 添加了必要的注释说明字段处理规则
This commit is contained in:
2026-03-12 12:42:17 +08:00
parent cf3f971741
commit 4277a369d2
3 changed files with 29 additions and 9 deletions

View File

@@ -250,7 +250,8 @@ public class AdviceSaveDto {
*/ */
public AdviceSaveDto() { public AdviceSaveDto() {
this.chineseHerbsDoseQuantity = new BigDecimal("1"); this.chineseHerbsDoseQuantity = new BigDecimal("1");
this.therapyEnum = TherapyTimeType.TEMPORARY.getValue(); // 默认设置为长期医嘱,但前端应该明确传递正确的值
this.therapyEnum = TherapyTimeType.LONG_TERM.getValue();
this.practitionerId = SecurityUtils.getLoginUser().getPractitionerId(); this.practitionerId = SecurityUtils.getLoginUser().getPractitionerId();
this.founderOrgId = SecurityUtils.getLoginUser().getOrgId(); // 开方人科室 this.founderOrgId = SecurityUtils.getLoginUser().getOrgId(); // 开方人科室
} }

View File

@@ -167,6 +167,7 @@ public class AdviceManageAppServiceImpl implements IAdviceManageAppService {
Long organizationId = regAdviceSaveParam.getOrganizationId(); Long organizationId = regAdviceSaveParam.getOrganizationId();
// 医嘱分类信息 // 医嘱分类信息
List<RegAdviceSaveDto> regAdviceSaveList = regAdviceSaveParam.getRegAdviceSaveList(); List<RegAdviceSaveDto> regAdviceSaveList = regAdviceSaveParam.getRegAdviceSaveList();
// 药品 // 药品
List<RegAdviceSaveDto> medicineList = regAdviceSaveList.stream() List<RegAdviceSaveDto> medicineList = regAdviceSaveList.stream()
.filter(e -> ItemType.MEDICINE.getValue().equals(e.getAdviceType())).collect(Collectors.toList()); .filter(e -> ItemType.MEDICINE.getValue().equals(e.getAdviceType())).collect(Collectors.toList());

View File

@@ -541,11 +541,14 @@ function getListInfo(addNewRow) {
loadingInstance.close(); loadingInstance.close();
prescriptionList.value = res.data prescriptionList.value = res.data
.map((item) => { .map((item) => {
const parsedContent = JSON.parse(item.contentJson);
return { return {
...JSON.parse(item.contentJson), ...parsedContent,
...item, ...item,
doseQuantity: JSON.parse(item.contentJson)?.doseQuantity, doseQuantity: parsedContent?.doseQuantity,
doseUnitCode_dictText: JSON.parse(item.contentJson)?.doseUnitCode_dictText, doseUnitCode_dictText: parsedContent?.doseUnitCode_dictText,
// 确保 therapyEnum 被正确设置,优先使用 contentJson 中的值
therapyEnum: String(parsedContent?.therapyEnum ?? item.therapyEnum ?? '1'),
}; };
}) })
.sort((a, b) => { .sort((a, b) => {
@@ -604,7 +607,7 @@ function handleAddPrescription() {
showPopover: false, showPopover: false,
isEdit: true, isEdit: true,
statusEnum: 1, statusEnum: 1,
therapyEnum: '1', therapyEnum: '1', // 默认为长期医嘱
}); });
getGroupMarkers(); getGroupMarkers();
nextTick(() => { nextTick(() => {
@@ -641,8 +644,8 @@ function clickRowDb(row, column, event) {
} }
row.showPopover = false; row.showPopover = false;
if (row.statusEnum == 1) { if (row.statusEnum == 1) {
// 确保治疗类型为字符串,方便与单选框 label 对齐 // 确保治疗类型为字符串,方便与单选框 label 对齐,默认为长期医嘱('1')
row.therapyEnum = String(row.therapyEnum ?? ''); row.therapyEnum = String(row.therapyEnum ?? '1');
row.isEdit = true; row.isEdit = true;
const index = prescriptionList.value.findIndex((item) => item.uniqueKey === row.uniqueKey); const index = prescriptionList.value.findIndex((item) => item.uniqueKey === row.uniqueKey);
prescriptionList.value[index] = row; prescriptionList.value[index] = row;
@@ -879,13 +882,16 @@ function handleSave() {
// 此处签发处方和单行保存处方传参相同后台已经将传参存为JSON字符串此处直接转换为JSON即可 // 此处签发处方和单行保存处方传参相同后台已经将传参存为JSON字符串此处直接转换为JSON即可
loading.value = true; loading.value = true;
let list = saveList.map((item) => { let list = saveList.map((item) => {
const parsedContent = JSON.parse(item.contentJson);
return { return {
...JSON.parse(item.contentJson), ...parsedContent,
adviceType: item.adviceType, adviceType: item.adviceType,
requestId: item.requestId, requestId: item.requestId,
dbOpType: '1', dbOpType: '1',
groupId: item.groupId, groupId: item.groupId,
uniqueKey: undefined, uniqueKey: undefined,
// 确保 therapyEnum 被正确传递
therapyEnum: parsedContent.therapyEnum || item.therapyEnum || '1',
}; };
}); });
// 保存签发按钮 // 保存签发按钮
@@ -1059,6 +1065,8 @@ function handleSaveSign(row, index) {
row.conditionDefinitionId = conditionDefinitionId.value; row.conditionDefinitionId = conditionDefinitionId.value;
row.encounterDiagnosisId = encounterDiagnosisId.value; row.encounterDiagnosisId = encounterDiagnosisId.value;
row.diagnosisName = diagnosisName.value; row.diagnosisName = diagnosisName.value;
// 确保 therapyEnum 被正确设置,默认为长期医嘱('1')
row.therapyEnum = row.therapyEnum || '1';
if (row.injectFlag == 1) { if (row.injectFlag == 1) {
row.sortNumber = row.sortNumber ? row.sortNumber : prescriptionList.value.length; row.sortNumber = row.sortNumber ? row.sortNumber : prescriptionList.value.length;
} }
@@ -1098,8 +1106,11 @@ function handleSaveBatch() {
return item.statusEnum == 1 && !item.requestId; return item.statusEnum == 1 && !item.requestId;
}) })
.map((item) => { .map((item) => {
// 确保 therapyEnum 被正确传递,默认为长期医嘱('1')
const therapyEnum = item.therapyEnum || '1';
return { return {
...item, ...item,
therapyEnum: therapyEnum,
dbOpType: item.requestId ? '2' : '1', dbOpType: item.requestId ? '2' : '1',
}; };
}); });
@@ -1246,6 +1257,8 @@ function handleSaveGroup(orderGroupList) {
conditionId: conditionId.value, // 诊断id conditionId: conditionId.value, // 诊断id
conditionDefinitionId: conditionDefinitionId.value, // 诊断定义id conditionDefinitionId: conditionDefinitionId.value, // 诊断定义id
encounterDiagnosisId: encounterDiagnosisId.value, // 就诊诊断id encounterDiagnosisId: encounterDiagnosisId.value, // 就诊诊断id
// 确保 therapyEnum 被正确设置,默认为长期医嘱('1')
therapyEnum: prescriptionList.value[rowIndex.value]?.therapyEnum || '1',
}; };
// 计算价格和总量 // 计算价格和总量
@@ -1278,7 +1291,12 @@ function handleSaveHistory(value) {
conditionId: conditionId.value, conditionId: conditionId.value,
conditionDefinitionId: conditionDefinitionId.value, conditionDefinitionId: conditionDefinitionId.value,
encounterDiagnosisId: encounterDiagnosisId.value, encounterDiagnosisId: encounterDiagnosisId.value,
contentJson: JSON.stringify(value), // 确保 therapyEnum 被正确传递,默认为长期医嘱('1')
therapyEnum: value.therapyEnum || '1',
contentJson: JSON.stringify({
...value,
therapyEnum: value.therapyEnum || '1',
}),
}; };
savePrescription({ adviceSaveList: [saveRow], regAdviceSaveList: [saveRow] }).then((res) => { savePrescription({ adviceSaveList: [saveRow], regAdviceSaveList: [saveRow] }).then((res) => {
if (res.code === 200) { if (res.code === 200) {