Compare commits
5 Commits
ae9a96822e
...
b27d8a6703
| Author | SHA1 | Date | |
|---|---|---|---|
| b27d8a6703 | |||
| 6f3d4272e6 | |||
| 6e5315fdd6 | |||
| 544d7ee95c | |||
| 7f7f7d69f7 |
@@ -8,6 +8,7 @@ import com.core.common.exception.ServiceException;
|
|||||||
import com.core.common.utils.AssignSeqUtil;
|
import com.core.common.utils.AssignSeqUtil;
|
||||||
import com.core.common.utils.MessageUtils;
|
import com.core.common.utils.MessageUtils;
|
||||||
import com.core.common.utils.SecurityUtils;
|
import com.core.common.utils.SecurityUtils;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.openhis.administration.domain.ChargeItem;
|
import com.openhis.administration.domain.ChargeItem;
|
||||||
import com.openhis.administration.service.IChargeItemService;
|
import com.openhis.administration.service.IChargeItemService;
|
||||||
import com.openhis.common.constant.CommonConstants;
|
import com.openhis.common.constant.CommonConstants;
|
||||||
@@ -31,6 +32,7 @@ import javax.annotation.Resource;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -214,6 +216,28 @@ public class RequestFormManageAppServiceImpl implements IRequestFormManageAppSer
|
|||||||
|
|
||||||
// 如果是手术申请单,需要额外生成手术医嘱
|
// 如果是手术申请单,需要额外生成手术医嘱
|
||||||
if (ActivityDefCategory.PROCEDURE.getCode().equals(typeCode)) {
|
if (ActivityDefCategory.PROCEDURE.getCode().equals(typeCode)) {
|
||||||
|
log.info("开始生成手术医嘱,encounterId={}, patientId={}, typeCode={}", encounterId, patientId, typeCode);
|
||||||
|
// 从 descJson 中解析手术信息
|
||||||
|
String descJson = requestFormSaveDto.getDescJson();
|
||||||
|
Map<String, Object> descMap = null;
|
||||||
|
if (descJson != null && !descJson.isEmpty()) {
|
||||||
|
try {
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
descMap = objectMapper.readValue(descJson, Map.class);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("解析手术申请单 descJson 失败", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取手术信息
|
||||||
|
String surgeryName = descMap != null ? (String) descMap.get("surgeryName") : null;
|
||||||
|
String surgeryCode = descMap != null ? (String) descMap.get("surgeryCode") : null;
|
||||||
|
String surgeryFee = descMap != null ? (String) descMap.get("surgeryFee") : null;
|
||||||
|
String anesthesiaFee = descMap != null ? (String) descMap.get("anesthesiaFee") : null;
|
||||||
|
String plannedTime = descMap != null ? (String) descMap.get("plannedTime") : null;
|
||||||
|
String surgeryIndication = descMap != null ? (String) descMap.get("surgeryIndication") : null;
|
||||||
|
String preoperativeDiagnosis = descMap != null ? (String) descMap.get("preoperativeDiagnosis") : null;
|
||||||
|
|
||||||
// 生成手术医嘱
|
// 生成手术医嘱
|
||||||
ServiceRequest surgeryServiceRequest = new ServiceRequest();
|
ServiceRequest surgeryServiceRequest = new ServiceRequest();
|
||||||
surgeryServiceRequest.setStatusEnum(RequestStatus.DRAFT.getValue());
|
surgeryServiceRequest.setStatusEnum(RequestStatus.DRAFT.getValue());
|
||||||
@@ -224,7 +248,7 @@ public class RequestFormManageAppServiceImpl implements IRequestFormManageAppSer
|
|||||||
surgeryServiceRequest.setQuantity(BigDecimal.valueOf(1));
|
surgeryServiceRequest.setQuantity(BigDecimal.valueOf(1));
|
||||||
surgeryServiceRequest.setUnitCode("次");
|
surgeryServiceRequest.setUnitCode("次");
|
||||||
surgeryServiceRequest.setCategoryEnum(4); // 4-手术
|
surgeryServiceRequest.setCategoryEnum(4); // 4-手术
|
||||||
// 从 activityList 中获取第一个手术 ID 作为活动 ID
|
// 优先从 activityList 获取手术 ID,如果为空则从 descJson 获取
|
||||||
if (!activityList.isEmpty()) {
|
if (!activityList.isEmpty()) {
|
||||||
surgeryServiceRequest.setActivityId(activityList.get(0).getAdviceDefinitionId());
|
surgeryServiceRequest.setActivityId(activityList.get(0).getAdviceDefinitionId());
|
||||||
}
|
}
|
||||||
@@ -233,7 +257,33 @@ public class RequestFormManageAppServiceImpl implements IRequestFormManageAppSer
|
|||||||
surgeryServiceRequest.setEncounterId(encounterId);
|
surgeryServiceRequest.setEncounterId(encounterId);
|
||||||
surgeryServiceRequest.setAuthoredTime(curDate);
|
surgeryServiceRequest.setAuthoredTime(curDate);
|
||||||
surgeryServiceRequest.setOrgId(orgId);
|
surgeryServiceRequest.setOrgId(orgId);
|
||||||
|
// 设置手术相关信息到 contentJson 字段
|
||||||
|
Map<String, String> contentMap = new java.util.HashMap<>();
|
||||||
|
if (surgeryName != null && !surgeryName.isEmpty()) {
|
||||||
|
contentMap.put("surgeryName", surgeryName);
|
||||||
|
}
|
||||||
|
if (surgeryCode != null && !surgeryCode.isEmpty()) {
|
||||||
|
contentMap.put("surgeryCode", surgeryCode);
|
||||||
|
}
|
||||||
|
if (plannedTime != null && !plannedTime.isEmpty()) {
|
||||||
|
contentMap.put("plannedTime", plannedTime);
|
||||||
|
}
|
||||||
|
if (surgeryIndication != null && !surgeryIndication.isEmpty()) {
|
||||||
|
contentMap.put("surgeryIndication", surgeryIndication);
|
||||||
|
}
|
||||||
|
if (preoperativeDiagnosis != null && !preoperativeDiagnosis.isEmpty()) {
|
||||||
|
contentMap.put("preoperativeDiagnosis", preoperativeDiagnosis);
|
||||||
|
}
|
||||||
|
if (!contentMap.isEmpty()) {
|
||||||
|
try {
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
surgeryServiceRequest.setContentJson(objectMapper.writeValueAsString(contentMap));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("序列化手术信息失败", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
iServiceRequestService.save(surgeryServiceRequest);
|
iServiceRequestService.save(surgeryServiceRequest);
|
||||||
|
log.info("手术医嘱生成成功,serviceRequestId={}, prescriptionNo={}", surgeryServiceRequest.getId(), prescriptionNo);
|
||||||
|
|
||||||
// 生成手术收费项目
|
// 生成手术收费项目
|
||||||
ChargeItem surgeryChargeItem = new ChargeItem();
|
ChargeItem surgeryChargeItem = new ChargeItem();
|
||||||
@@ -248,6 +298,7 @@ public class RequestFormManageAppServiceImpl implements IRequestFormManageAppSer
|
|||||||
surgeryChargeItem.setServiceTable(CommonConstants.TableName.WOR_SERVICE_REQUEST);
|
surgeryChargeItem.setServiceTable(CommonConstants.TableName.WOR_SERVICE_REQUEST);
|
||||||
surgeryChargeItem.setServiceId(surgeryServiceRequest.getId());
|
surgeryChargeItem.setServiceId(surgeryServiceRequest.getId());
|
||||||
surgeryChargeItem.setProductTable(CommonConstants.TableName.WOR_ACTIVITY_DEFINITION);
|
surgeryChargeItem.setProductTable(CommonConstants.TableName.WOR_ACTIVITY_DEFINITION);
|
||||||
|
// 优先从 activityList 获取 productId,如果为空则不设置
|
||||||
if (!activityList.isEmpty()) {
|
if (!activityList.isEmpty()) {
|
||||||
surgeryChargeItem.setProductId(activityList.get(0).getAdviceDefinitionId());
|
surgeryChargeItem.setProductId(activityList.get(0).getAdviceDefinitionId());
|
||||||
}
|
}
|
||||||
@@ -255,7 +306,45 @@ public class RequestFormManageAppServiceImpl implements IRequestFormManageAppSer
|
|||||||
surgeryChargeItem.setRequestingOrgId(orgId);
|
surgeryChargeItem.setRequestingOrgId(orgId);
|
||||||
surgeryChargeItem.setQuantityValue(BigDecimal.valueOf(1));
|
surgeryChargeItem.setQuantityValue(BigDecimal.valueOf(1));
|
||||||
surgeryChargeItem.setQuantityUnit("次");
|
surgeryChargeItem.setQuantityUnit("次");
|
||||||
|
// 设置手术费用
|
||||||
|
if (surgeryFee != null && !surgeryFee.isEmpty()) {
|
||||||
|
try {
|
||||||
|
surgeryChargeItem.setUnitPrice(new BigDecimal(surgeryFee));
|
||||||
|
surgeryChargeItem.setTotalPrice(new BigDecimal(surgeryFee));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
log.warn("手术费用格式不正确:{}", surgeryFee);
|
||||||
|
}
|
||||||
|
}
|
||||||
iChargeItemService.save(surgeryChargeItem);
|
iChargeItemService.save(surgeryChargeItem);
|
||||||
|
|
||||||
|
// 如果存在麻醉费用,生成麻醉收费项目
|
||||||
|
if (anesthesiaFee != null && !anesthesiaFee.isEmpty()) {
|
||||||
|
try {
|
||||||
|
BigDecimal anesthesiaFeeAmount = new BigDecimal(anesthesiaFee);
|
||||||
|
if (anesthesiaFeeAmount.compareTo(BigDecimal.ZERO) > 0) {
|
||||||
|
ChargeItem anesthesiaChargeItem = new ChargeItem();
|
||||||
|
anesthesiaChargeItem.setStatusEnum(ChargeItemStatus.DRAFT.getValue());
|
||||||
|
anesthesiaChargeItem.setBusNo(AssignSeqEnum.CHARGE_ITEM_NO.getPrefix().concat(surgeryServiceRequest.getBusNo()));
|
||||||
|
anesthesiaChargeItem.setGenerateSourceEnum(GenerateSource.DOCTOR_PRESCRIPTION.getValue());
|
||||||
|
anesthesiaChargeItem.setPatientId(patientId);
|
||||||
|
anesthesiaChargeItem.setContextEnum(3); // 3-诊疗
|
||||||
|
anesthesiaChargeItem.setEncounterId(encounterId);
|
||||||
|
anesthesiaChargeItem.setEntererId(practitionerId);
|
||||||
|
anesthesiaChargeItem.setEnteredDate(curDate);
|
||||||
|
anesthesiaChargeItem.setServiceTable(CommonConstants.TableName.WOR_SERVICE_REQUEST);
|
||||||
|
anesthesiaChargeItem.setServiceId(surgeryServiceRequest.getId());
|
||||||
|
anesthesiaChargeItem.setProductTable(CommonConstants.TableName.WOR_ACTIVITY_DEFINITION);
|
||||||
|
anesthesiaChargeItem.setRequestingOrgId(orgId);
|
||||||
|
anesthesiaChargeItem.setQuantityValue(BigDecimal.valueOf(1));
|
||||||
|
anesthesiaChargeItem.setQuantityUnit("次");
|
||||||
|
anesthesiaChargeItem.setUnitPrice(anesthesiaFeeAmount);
|
||||||
|
anesthesiaChargeItem.setTotalPrice(anesthesiaFeeAmount);
|
||||||
|
iChargeItemService.save(anesthesiaChargeItem);
|
||||||
|
}
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
log.warn("麻醉费用格式不正确:{}", anesthesiaFee);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00002, new Object[] {"申请单"}));
|
return R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00002, new Object[] {"申请单"}));
|
||||||
|
|||||||
@@ -93,16 +93,19 @@
|
|||||||
T7.med_type_code,
|
T7.med_type_code,
|
||||||
T8.contract_name,
|
T8.contract_name,
|
||||||
CASE
|
CASE
|
||||||
|
WHEN T1.context_enum = #{activity} AND T1.product_table = 'cli_surgery' THEN T9.surgery_name
|
||||||
WHEN T1.context_enum = #{activity} THEN T2."name"
|
WHEN T1.context_enum = #{activity} THEN T2."name"
|
||||||
WHEN T1.context_enum = #{medication} THEN T3."name"
|
WHEN T1.context_enum = #{medication} THEN T3."name"
|
||||||
WHEN T1.context_enum = #{device} THEN T4."name"
|
WHEN T1.context_enum = #{device} THEN T4."name"
|
||||||
END AS item_name,
|
END AS item_name,
|
||||||
CASE
|
CASE
|
||||||
|
WHEN T1.context_enum = #{activity} AND T1.product_table = 'cli_surgery' THEN NULL
|
||||||
WHEN T1.context_enum = #{activity} THEN T2.yb_no
|
WHEN T1.context_enum = #{activity} THEN T2.yb_no
|
||||||
WHEN T1.context_enum = #{medication} THEN T3.yb_no
|
WHEN T1.context_enum = #{medication} THEN T3.yb_no
|
||||||
WHEN T1.context_enum = #{device} THEN T4.yb_no
|
WHEN T1.context_enum = #{device} THEN T4.yb_no
|
||||||
END AS yb_no,
|
END AS yb_no,
|
||||||
CASE
|
CASE
|
||||||
|
WHEN T1.context_enum = #{activity} AND T1.product_table = 'cli_surgery' THEN T9.id
|
||||||
WHEN T1.context_enum = #{activity} THEN T2.id
|
WHEN T1.context_enum = #{activity} THEN T2.id
|
||||||
WHEN T1.context_enum = #{medication} THEN T3.id
|
WHEN T1.context_enum = #{medication} THEN T3.id
|
||||||
WHEN T1.context_enum = #{device} THEN T4.id
|
WHEN T1.context_enum = #{device} THEN T4.id
|
||||||
@@ -120,6 +123,10 @@
|
|||||||
ON T1.context_enum = #{device}
|
ON T1.context_enum = #{device}
|
||||||
AND T1.product_id = T4.id
|
AND T1.product_id = T4.id
|
||||||
AND T4.delete_flag = '0'
|
AND T4.delete_flag = '0'
|
||||||
|
LEFT JOIN cli_surgery AS T9
|
||||||
|
ON T1.product_table = 'cli_surgery'
|
||||||
|
AND T1.product_id = T9.id
|
||||||
|
AND T9.delete_flag = '0'
|
||||||
LEFT JOIN fin_payment_reconciliation AS T5
|
LEFT JOIN fin_payment_reconciliation AS T5
|
||||||
ON T1.id::TEXT = ANY(string_to_array(T5.charge_item_ids, ','))
|
ON T1.id::TEXT = ANY(string_to_array(T5.charge_item_ids, ','))
|
||||||
AND T5.delete_flag = '0'
|
AND T5.delete_flag = '0'
|
||||||
@@ -185,36 +192,43 @@
|
|||||||
T6.contract_no,
|
T6.contract_no,
|
||||||
T7.med_type_code,
|
T7.med_type_code,
|
||||||
T8.contract_name,
|
T8.contract_name,
|
||||||
CASE
|
CASE
|
||||||
WHEN T1.context_enum = #{activity} THEN T2."name"
|
WHEN T1.context_enum = #{activity} AND T1.product_table = 'cli_surgery' THEN T9.surgery_name
|
||||||
WHEN T1.context_enum = #{medication} THEN T3."name"
|
WHEN T1.context_enum = #{activity} THEN T2."name"
|
||||||
WHEN T1.context_enum = #{device} THEN T4."name"
|
WHEN T1.context_enum = #{medication} THEN T3."name"
|
||||||
END AS item_name,
|
WHEN T1.context_enum = #{device} THEN T4."name"
|
||||||
CASE
|
END AS item_name,
|
||||||
WHEN T1.context_enum = #{activity} THEN T2.yb_no
|
CASE
|
||||||
WHEN T1.context_enum = #{medication} THEN T3.yb_no
|
WHEN T1.context_enum = #{activity} AND T1.product_table = 'cli_surgery' THEN NULL
|
||||||
WHEN T1.context_enum = #{device} THEN T4.yb_no
|
WHEN T1.context_enum = #{activity} THEN T2.yb_no
|
||||||
END AS yb_no,
|
WHEN T1.context_enum = #{medication} THEN T3.yb_no
|
||||||
CASE
|
WHEN T1.context_enum = #{device} THEN T4.yb_no
|
||||||
WHEN T1.context_enum = #{activity} THEN T2.id
|
END AS yb_no,
|
||||||
WHEN T1.context_enum = #{medication} THEN T3.id
|
CASE
|
||||||
WHEN T1.context_enum = #{device} THEN T4.id
|
WHEN T1.context_enum = #{activity} AND T1.product_table = 'cli_surgery' THEN T9.id
|
||||||
END AS item_id,
|
WHEN T1.context_enum = #{activity} THEN T2.id
|
||||||
T5.tendered_amount AS receivable_amount
|
WHEN T1.context_enum = #{medication} THEN T3.id
|
||||||
FROM adm_charge_item AS T1
|
WHEN T1.context_enum = #{device} THEN T4.id
|
||||||
LEFT JOIN wor_activity_definition AS T2
|
END AS item_id,
|
||||||
ON T1.context_enum = #{activity}
|
T5.tendered_amount AS receivable_amount
|
||||||
AND T1.product_id = T2.id
|
FROM adm_charge_item AS T1
|
||||||
AND T2.delete_flag = '0'
|
LEFT JOIN wor_activity_definition AS T2
|
||||||
LEFT JOIN med_medication_definition AS T3
|
ON T1.context_enum = #{activity}
|
||||||
ON T1.context_enum = #{medication}
|
AND T1.product_id = T2.id
|
||||||
AND T1.product_id = T3.id
|
AND T2.delete_flag = '0'
|
||||||
AND T3.delete_flag = '0'
|
LEFT JOIN med_medication_definition AS T3
|
||||||
LEFT JOIN adm_device_definition AS T4
|
ON T1.context_enum = #{medication}
|
||||||
ON T1.context_enum = #{device}
|
AND T1.product_id = T3.id
|
||||||
AND T1.product_id = T4.id
|
AND T3.delete_flag = '0'
|
||||||
AND T4.delete_flag = '0'
|
LEFT JOIN adm_device_definition AS T4
|
||||||
LEFT JOIN fin_payment_reconciliation AS T5
|
ON T1.context_enum = #{device}
|
||||||
|
AND T1.product_id = T4.id
|
||||||
|
AND T4.delete_flag = '0'
|
||||||
|
LEFT JOIN cli_surgery AS T9
|
||||||
|
ON T1.product_table = 'cli_surgery'
|
||||||
|
AND T1.product_id = T9.id
|
||||||
|
AND T9.delete_flag = '0'
|
||||||
|
LEFT JOIN fin_payment_reconciliation AS T5
|
||||||
ON T1.id::TEXT = ANY(string_to_array(T5.charge_item_ids, ','))
|
ON T1.id::TEXT = ANY(string_to_array(T5.charge_item_ids, ','))
|
||||||
AND T5.delete_flag = '0'
|
AND T5.delete_flag = '0'
|
||||||
AND T5.status_enum = 1
|
AND T5.status_enum = 1
|
||||||
|
|||||||
Reference in New Issue
Block a user