医嘱查询代码初始化
This commit is contained in:
@@ -8,6 +8,16 @@ import com.openhis.web.doctorstation.dto.AdviceBaseDto;
|
|||||||
*/
|
*/
|
||||||
public interface IDoctorStationAdviceAppService {
|
public interface IDoctorStationAdviceAppService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询医嘱信息
|
||||||
|
*
|
||||||
|
* @param adviceBaseDto 查询条件
|
||||||
|
* @param searchKey 模糊查询关键字
|
||||||
|
* @param locationId 药房id
|
||||||
|
* @param pageNo 当前页
|
||||||
|
* @param pageSize 每页多少条
|
||||||
|
* @return 医嘱信息
|
||||||
|
*/
|
||||||
IPage<AdviceBaseDto> getAdviceBaseInfo(AdviceBaseDto adviceBaseDto, String searchKey, Long locationId,
|
IPage<AdviceBaseDto> getAdviceBaseInfo(AdviceBaseDto adviceBaseDto, String searchKey, Long locationId,
|
||||||
Integer pageNo, Integer pageSize);
|
Integer pageNo, Integer pageSize);
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,25 @@
|
|||||||
package com.openhis.web.doctorstation.appservice.impl;
|
package com.openhis.web.doctorstation.appservice.impl;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.openhis.common.constant.CommonConstants;
|
||||||
|
import com.openhis.common.enums.ConditionCode;
|
||||||
|
import com.openhis.common.utils.HisQueryUtils;
|
||||||
import com.openhis.web.doctorstation.appservice.IDoctorStationAdviceAppService;
|
import com.openhis.web.doctorstation.appservice.IDoctorStationAdviceAppService;
|
||||||
import com.openhis.web.doctorstation.dto.AdviceBaseDto;
|
import com.openhis.web.doctorstation.dto.AdviceBaseDto;
|
||||||
|
import com.openhis.web.doctorstation.dto.AdviceInventoryDto;
|
||||||
|
import com.openhis.web.doctorstation.dto.AdvicePriceDto;
|
||||||
import com.openhis.web.doctorstation.mapper.DoctorStationAdviceAppMapper;
|
import com.openhis.web.doctorstation.mapper.DoctorStationAdviceAppMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -19,19 +32,100 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
|||||||
DoctorStationAdviceAppMapper doctorStationAdviceAppMapper;
|
DoctorStationAdviceAppMapper doctorStationAdviceAppMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 查询医嘱信息
|
||||||
*
|
*
|
||||||
* @param adviceBaseDto
|
* @param adviceBaseDto 查询条件
|
||||||
* @param searchKey
|
* @param searchKey 模糊查询关键字
|
||||||
* @param locationId
|
* @param locationId 药房id
|
||||||
* @param pageNo
|
* @param pageNo 当前页
|
||||||
* @param pageSize
|
* @param pageSize 每页多少条
|
||||||
* @return
|
* @return 医嘱信息
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public IPage<AdviceBaseDto> getAdviceBaseInfo(AdviceBaseDto adviceBaseDto, String searchKey, Long locationId,
|
public IPage<AdviceBaseDto> getAdviceBaseInfo(AdviceBaseDto adviceBaseDto, String searchKey, Long locationId,
|
||||||
Integer pageNo, Integer pageSize) {
|
Integer pageNo, Integer pageSize) {
|
||||||
|
// 构建查询条件
|
||||||
|
QueryWrapper<AdviceBaseDto> queryWrapper = HisQueryUtils.buildQueryWrapper(adviceBaseDto, searchKey,
|
||||||
|
new HashSet<>(Arrays.asList("advice_name", "py_str", "wb_str")), null);
|
||||||
|
IPage<AdviceBaseDto> adviceBaseInfo =
|
||||||
|
doctorStationAdviceAppMapper.getAdviceBaseInfo(new Page<>(pageNo, pageSize),
|
||||||
|
CommonConstants.TableName.MED_MEDICATION_DEFINITION, CommonConstants.TableName.ADM_DEVICE_DEFINITION,
|
||||||
|
CommonConstants.TableName.WOR_ACTIVITY_DEFINITION, queryWrapper);
|
||||||
|
List<AdviceBaseDto> adviceBaseDtoList = adviceBaseInfo.getRecords();
|
||||||
|
// 医嘱定义ID集合
|
||||||
|
List<Long> adviceDefinitionIdList =
|
||||||
|
adviceBaseDtoList.stream().map(AdviceBaseDto::getAdviceDefinitionId).collect(Collectors.toList());
|
||||||
|
// 费用定价主表ID集合
|
||||||
|
List<Long> chargeItemDefinitionIdList =
|
||||||
|
adviceBaseDtoList.stream().map(AdviceBaseDto::getChargeItemDefinitionId).collect(Collectors.toList());
|
||||||
|
// 医嘱库存集合
|
||||||
|
List<AdviceInventoryDto> adviceInventory = doctorStationAdviceAppMapper.getAdviceInventory(locationId,
|
||||||
|
adviceDefinitionIdList, CommonConstants.SqlCondition.ABOUT_INVENTORY_TABLE_STR);
|
||||||
|
// 费用定价子表信息
|
||||||
|
List<AdvicePriceDto> childCharge = doctorStationAdviceAppMapper
|
||||||
|
.getChildCharge(ConditionCode.UNIT_PRODUCT_BATCH_NUM.getInfo(), chargeItemDefinitionIdList);
|
||||||
|
// 费用定价主表信息
|
||||||
|
List<AdvicePriceDto> mainCharge = doctorStationAdviceAppMapper.getMainCharge(chargeItemDefinitionIdList);
|
||||||
|
// 药品和耗材
|
||||||
|
List<AdviceBaseDto> medicationAndDeviceList = adviceBaseDtoList.stream()
|
||||||
|
.filter(e -> CommonConstants.TableName.MED_MEDICATION_DEFINITION.equals(e.getAdviceTableName())
|
||||||
|
|| CommonConstants.TableName.ADM_DEVICE_DEFINITION.equals(e.getAdviceTableName()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
// 药品和耗材-赋值
|
||||||
|
String unitCode = ""; // 包装单位
|
||||||
|
String minUnitCode; // 小单位
|
||||||
|
Long chargeItemDefinitionId; // 费用定价主表ID
|
||||||
|
for (AdviceBaseDto baseDto : medicationAndDeviceList) {
|
||||||
|
// 每一条医嘱的库存集合信息
|
||||||
|
List<AdviceInventoryDto> inventoryList =
|
||||||
|
adviceInventory.stream().filter(e -> baseDto.getAdviceDefinitionId().equals(e.getItemId())
|
||||||
|
&& baseDto.getAdviceTableName().equals(e.getItemTable())).collect(Collectors.toList());
|
||||||
|
// 库存信息
|
||||||
|
baseDto.setInventoryList(inventoryList);
|
||||||
|
|
||||||
return null;
|
unitCode = baseDto.getUnitCode();
|
||||||
|
minUnitCode = baseDto.getMinUnitCode();
|
||||||
|
chargeItemDefinitionId = baseDto.getChargeItemDefinitionId();
|
||||||
|
|
||||||
|
List<AdvicePriceDto> priceDtoList = new ArrayList<>();
|
||||||
|
// 库存信息里取 单位,产品批号 去匹配价格
|
||||||
|
for (AdviceInventoryDto adviceInventoryDto : inventoryList) {
|
||||||
|
Long finalChargeItemDefinitionId = chargeItemDefinitionId;
|
||||||
|
String finalUnitCode = unitCode;
|
||||||
|
String finalMinUnitCode = minUnitCode;
|
||||||
|
// 匹配包装单位
|
||||||
|
List<AdvicePriceDto> advicePrice1 = childCharge.stream()
|
||||||
|
.filter(e -> e.getDefinitionId().equals(finalChargeItemDefinitionId) && e.getConditionValue()
|
||||||
|
.equals(String.format(CommonConstants.Common.COMMA, finalUnitCode,
|
||||||
|
adviceInventoryDto.getLotNumber())))
|
||||||
|
.peek(e -> e.setUnitCode(finalUnitCode)) // 设置 unitCode
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
// 匹配最小单位
|
||||||
|
List<AdvicePriceDto> advicePrice2 = childCharge.stream()
|
||||||
|
.filter(e -> e.getDefinitionId().equals(finalChargeItemDefinitionId) && e.getConditionValue()
|
||||||
|
.equals(String.format(CommonConstants.Common.COMMA, finalMinUnitCode,
|
||||||
|
adviceInventoryDto.getLotNumber())))
|
||||||
|
.peek(e -> e.setUnitCode(finalMinUnitCode)) // 设置 unitCode
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
priceDtoList.addAll(advicePrice1);
|
||||||
|
priceDtoList.addAll(advicePrice2);
|
||||||
|
}
|
||||||
|
// 价格信息
|
||||||
|
baseDto.setPriceList(priceDtoList);
|
||||||
|
}
|
||||||
|
// 诊疗
|
||||||
|
List<AdviceBaseDto> activityList = adviceBaseDtoList.stream()
|
||||||
|
.filter(e -> CommonConstants.TableName.WOR_ACTIVITY_DEFINITION.equals(e.getAdviceTableName()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
// 诊疗-赋值
|
||||||
|
for (AdviceBaseDto baseDto : activityList) {
|
||||||
|
List<AdvicePriceDto> priceList =
|
||||||
|
mainCharge.stream().filter(e -> baseDto.getChargeItemDefinitionId().equals(e.getDefinitionId()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
// 价格信息
|
||||||
|
baseDto.setPriceList(priceList);
|
||||||
|
}
|
||||||
|
return adviceBaseInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,13 +26,24 @@ public class DoctorStationAdviceController {
|
|||||||
|
|
||||||
private final IDoctorStationAdviceAppService iDoctorStationAdviceAppService;
|
private final IDoctorStationAdviceAppService iDoctorStationAdviceAppService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询医嘱信息
|
||||||
|
*
|
||||||
|
* @param adviceBaseDto 查询条件
|
||||||
|
* @param searchKey 模糊查询关键字
|
||||||
|
* @param locationId 药房id
|
||||||
|
* @param pageNo 当前页
|
||||||
|
* @param pageSize 每页多少条
|
||||||
|
* @return 医嘱信息
|
||||||
|
*/
|
||||||
@GetMapping(value = "/advice-base-info")
|
@GetMapping(value = "/advice-base-info")
|
||||||
public R<?> getAdviceBaseInfo(AdviceBaseDto adviceBaseDto,
|
public R<?> getAdviceBaseInfo(AdviceBaseDto adviceBaseDto,
|
||||||
@RequestParam(value = "searchKey", defaultValue = "") String searchKey,
|
@RequestParam(value = "searchKey", defaultValue = "") String searchKey,
|
||||||
@RequestParam(value = "locationId") Long locationId,
|
@RequestParam(value = "locationId",required = false) Long locationId,
|
||||||
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
|
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
|
||||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
|
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||||
return null;
|
return R.ok(
|
||||||
|
iDoctorStationAdviceAppService.getAdviceBaseInfo(adviceBaseDto, searchKey, locationId, pageNo, pageSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import java.math.BigDecimal;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||||
|
import com.openhis.common.annotation.Dict;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
@@ -33,4 +34,9 @@ public class AdvicePriceDto {
|
|||||||
/** 价格 */
|
/** 价格 */
|
||||||
private BigDecimal price;
|
private BigDecimal price;
|
||||||
|
|
||||||
|
/** 单位 */
|
||||||
|
@Dict(dictCode = "unit_code")
|
||||||
|
private String unitCode;
|
||||||
|
private String unitCode_dictText;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.openhis.web.doctorstation.mapper;
|
package com.openhis.web.doctorstation.mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@@ -8,6 +10,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.openhis.web.doctorstation.dto.AdviceBaseDto;
|
import com.openhis.web.doctorstation.dto.AdviceBaseDto;
|
||||||
|
import com.openhis.web.doctorstation.dto.AdviceInventoryDto;
|
||||||
|
import com.openhis.web.doctorstation.dto.AdvicePriceDto;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 医生站-医嘱/处方 应用Mapper
|
* 医生站-医嘱/处方 应用Mapper
|
||||||
@@ -30,4 +34,33 @@ public interface DoctorStationAdviceAppMapper {
|
|||||||
@Param("activityTableName") String activityTableName,
|
@Param("activityTableName") String activityTableName,
|
||||||
@Param(Constants.WRAPPER) QueryWrapper<AdviceBaseDto> queryWrapper);
|
@Param(Constants.WRAPPER) QueryWrapper<AdviceBaseDto> queryWrapper);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询医嘱库存
|
||||||
|
*
|
||||||
|
* @param locationId 药房id
|
||||||
|
* @param adviceDefinitionIdList 医嘱定义ID集合
|
||||||
|
* @param SqlCondition sql条件
|
||||||
|
* @return 医嘱库存
|
||||||
|
*/
|
||||||
|
List<AdviceInventoryDto> getAdviceInventory(@Param("locationId") Long locationId,
|
||||||
|
@Param("adviceDefinitionIdList") List<Long> adviceDefinitionIdList, @Param("SqlCondition") String SqlCondition);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询 费用定价子表
|
||||||
|
*
|
||||||
|
* @param conditionCode 命中条件
|
||||||
|
* @param chargeItemDefinitionIdList 费用定价主表ID集合
|
||||||
|
* @return 费用定价子表
|
||||||
|
*/
|
||||||
|
List<AdvicePriceDto> getChildCharge(@Param("conditionCode") String conditionCode,
|
||||||
|
@Param("chargeItemDefinitionIdList") List<Long> chargeItemDefinitionIdList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询 费用定价主表
|
||||||
|
*
|
||||||
|
* @param chargeItemDefinitionIdList 费用定价主表ID集合
|
||||||
|
* @return 费用定价子表
|
||||||
|
*/
|
||||||
|
List<AdvicePriceDto> getMainCharge(@Param("chargeItemDefinitionIdList") List<Long> chargeItemDefinitionIdList);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,4 +116,66 @@
|
|||||||
${ew.customSqlSegment}
|
${ew.customSqlSegment}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getAdviceInventory" resultType="com.openhis.web.doctorstation.dto.AdviceInventoryDto">
|
||||||
|
SELECT
|
||||||
|
T1.item_id,
|
||||||
|
T1.item_table,
|
||||||
|
T1.base_quantity,
|
||||||
|
T1.base_unit_code,
|
||||||
|
T1.min_quantity,
|
||||||
|
T1.min_unit_code,
|
||||||
|
T1.lot_number,
|
||||||
|
T2.NAME AS location_name
|
||||||
|
FROM
|
||||||
|
wor_inventory_item AS T1
|
||||||
|
LEFT JOIN adm_location AS T2 ON T2.ID = T1.location_id
|
||||||
|
AND T2.delete_flag = '0'
|
||||||
|
WHERE
|
||||||
|
T1.delete_flag = '0'
|
||||||
|
<if test="locationId != null">
|
||||||
|
AND T1.location_id = #{locationId}
|
||||||
|
</if>
|
||||||
|
<if test="adviceDefinitionIdList != null and !adviceDefinitionIdList.isEmpty()">
|
||||||
|
AND T1.item_id IN
|
||||||
|
<foreach collection="adviceDefinitionIdList" item="itemId" open="(" separator="," close=")">
|
||||||
|
#{itemId}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
AND T1.item_table IN ( ${SqlCondition} )
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getChildCharge" resultType="com.openhis.web.doctorstation.dto.AdvicePriceDto">
|
||||||
|
SELECT definition_id,
|
||||||
|
condition_value,
|
||||||
|
condition_code,
|
||||||
|
amount AS price
|
||||||
|
FROM adm_charge_item_def_detail
|
||||||
|
WHERE delete_flag = '0'
|
||||||
|
AND condition_code = #{conditionCode}
|
||||||
|
<if test="chargeItemDefinitionIdList != null and !chargeItemDefinitionIdList.isEmpty()">
|
||||||
|
AND definition_id IN
|
||||||
|
<foreach collection="chargeItemDefinitionIdList" item="itemId" open="(" separator="," close=")">
|
||||||
|
#{itemId}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
ORDER BY priority DESC
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getMainCharge" resultType="com.openhis.web.doctorstation.dto.AdvicePriceDto">
|
||||||
|
SELECT
|
||||||
|
id AS definition_id,
|
||||||
|
charge_name,
|
||||||
|
price
|
||||||
|
FROM
|
||||||
|
adm_charge_item_definition
|
||||||
|
WHERE
|
||||||
|
delete_flag = '0'
|
||||||
|
<if test="chargeItemDefinitionIdList != null and !chargeItemDefinitionIdList.isEmpty()">
|
||||||
|
AND id IN
|
||||||
|
<foreach collection="chargeItemDefinitionIdList" item="itemId" open="(" separator="," close=")">
|
||||||
|
#{itemId}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user