147 门诊医生站》医嘱TAB页面:一次性静脉采血器为耗材系统且自动转成中成药类型,点击【保存】报错。

This commit is contained in:
Ranyunqiao
2026-03-16 10:05:55 +08:00
parent f3d011951b
commit bba63d2f1b
6 changed files with 251 additions and 25 deletions

View File

@@ -14,6 +14,8 @@ import com.core.common.utils.MessageUtils;
import com.core.common.utils.SecurityUtils;
import com.core.common.utils.StringUtils;
import com.core.web.util.TenantOptionUtil;
import com.openhis.administration.domain.Account;
import com.openhis.administration.service.IAccountService;
import com.openhis.administration.domain.ChargeItem;
import com.openhis.administration.service.IChargeItemService;
import com.openhis.common.constant.CommonConstants;
@@ -72,6 +74,9 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
@Resource
IChargeItemService iChargeItemService;
@Resource
IAccountService iAccountService;
// @Resource
// IOrganizationLocationService iOrganizationLocationService;
@Resource
@@ -441,9 +446,11 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
iDeviceDispenseService.deleteDeviceDispense(adviceSaveDto.getRequestId());
}
// 🔧 Bug Fix: 跳过耗材的库存校验(耗材的库存校验逻辑不同)
List<AdviceSaveDto> needCheckList = adviceSaveList.stream()
.filter(e -> !DbOpType.DELETE.getCode().equals(e.getDbOpType())
&& !ItemType.ACTIVITY.getValue().equals(e.getAdviceType()))
&& !ItemType.ACTIVITY.getValue().equals(e.getAdviceType())
&& !ItemType.DEVICE.getValue().equals(e.getAdviceType())) // 排除耗材
.collect(Collectors.toList());
// 校验库存
String tipRes = adviceUtils.checkInventory(needCheckList);
@@ -778,7 +785,27 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
chargeItem.setServiceId(deviceRequest.getId()); // 医疗服务ID
chargeItem.setProductTable(adviceSaveDto.getAdviceTableName());// 产品所在表
chargeItem.setProductId(adviceSaveDto.getAdviceDefinitionId());// 收费项id
chargeItem.setAccountId(adviceSaveDto.getAccountId());// 关联账户ID
// 🔧 Bug Fix: 如果accountId为null从就诊中获取账户ID如果没有则自动创建
Long accountId = adviceSaveDto.getAccountId();
if (accountId == null) {
// 尝试从患者就诊中获取默认账户ID自费账户
Account selfAccount = iAccountService.getSelfAccount(adviceSaveDto.getEncounterId());
if (selfAccount != null) {
accountId = selfAccount.getId();
} else {
// 自动创建自费账户
Account newAccount = new Account();
newAccount.setPatientId(adviceSaveDto.getPatientId());
newAccount.setEncounterId(adviceSaveDto.getEncounterId());
newAccount.setContractNo(CommonConstants.BusinessName.DEFAULT_CONTRACT_NO);
newAccount.setTypeCode(AccountType.PERSONAL_CASH_ACCOUNT.getCode());
newAccount.setBalanceAmount(BigDecimal.ZERO);
newAccount.setStatusEnum(AccountStatus.ACTIVE.getValue());
newAccount.setEncounterFlag(Whether.YES.getValue());
accountId = iAccountService.saveAccountByRegister(newAccount);
}
}
chargeItem.setAccountId(accountId);// 关联账户ID
chargeItem.setConditionId(adviceSaveDto.getConditionId()); // 诊断id
chargeItem.setEncounterDiagnosisId(adviceSaveDto.getEncounterDiagnosisId()); // 就诊诊断id
chargeItem.setDispenseId(dispenseId); // 发放ID

View File

@@ -8,6 +8,8 @@ import lombok.Data;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
/**
* 医嘱保存 dto
@@ -80,6 +82,7 @@ public class AdviceSaveDto {
private BigDecimal unitPrice;
/** 总价 */
@JsonSetter(nulls = Nulls.AS_EMPTY)
private BigDecimal totalPrice;
/** 费用定价主表ID */
@@ -256,4 +259,16 @@ public class AdviceSaveDto {
this.founderOrgId = SecurityUtils.getLoginUser().getOrgId(); // 开方人科室
}
/**
* 🔧 Bug Fix: Custom setter for totalPrice to handle NaN and invalid values
* Prevents JSON parse errors when frontend sends NaN or invalid BigDecimal values
*/
public void setTotalPrice(BigDecimal totalPrice) {
if (totalPrice == null || totalPrice.compareTo(BigDecimal.ZERO) < 0) {
this.totalPrice = BigDecimal.ZERO;
} else {
this.totalPrice = totalPrice;
}
}
}

View File

@@ -174,4 +174,12 @@ public interface DoctorStationAdviceAppMapper {
List<ProofAndTestResultDto> getProofAndTestResult(@Param("encounterId") Long encounterId,
@Param("status") Integer status, @Param("typeEnum") Integer typeEnum);
/**
* 获取就诊的默认账户ID
*
* @param encounterId 就诊ID
* @return 默认账户ID如果没有则返回null
*/
Long getDefaultAccountId(@Param("encounterId") Long encounterId);
}

View File

@@ -122,7 +122,7 @@
(SELECT
DISTINCT ON (T1.ID)
T1.tenant_id,
2 AS advice_type,
4 AS advice_type,
T1.bus_no AS bus_no,
T1.category_code AS category_code,
'' AS pharmacology_category_code,
@@ -683,4 +683,13 @@
AND wad.ID = wsr.activity_id )
</select>
<!-- 获取就诊的默认账户ID -->
<select id="getDefaultAccountId" resultType="java.lang.Long">
SELECT aa.id
FROM adm_account aa
WHERE aa.delete_flag = '0'
AND aa.encounter_id = #{encounterId}
LIMIT 1
</select>
</mapper>