diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/appservice/IRequestFormManageAppService.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/appservice/IRequestFormManageAppService.java index dd22b991..f865495d 100755 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/appservice/IRequestFormManageAppService.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/appservice/IRequestFormManageAppService.java @@ -43,6 +43,19 @@ public interface IRequestFormManageAppService { */ List getRequestForm(Long encounterId, String typeCode, String startDate, String endDate); + /** + * 查询申请单(支持筛选+状态+关键字) + * + * @param encounterId 就诊id + * @param typeCode 申请单类型 + * @param startDate 开始日期(可选,格式:yyyy-MM-dd) + * @param endDate 结束日期(可选,格式:yyyy-MM-dd) + * @param status 单据状态(可选) + * @param keyword 关键字(可选,申请单号/项目名称模糊匹配) + * @return 申请单列表 + */ + List getRequestForm(Long encounterId, String typeCode, String startDate, String endDate, String status, String keyword); + /** * 分页查询申请单 * diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/appservice/impl/RequestFormManageAppServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/appservice/impl/RequestFormManageAppServiceImpl.java index c73e3c20..d3c1e4e2 100755 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/appservice/impl/RequestFormManageAppServiceImpl.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/appservice/impl/RequestFormManageAppServiceImpl.java @@ -428,12 +428,28 @@ public class RequestFormManageAppServiceImpl implements IRequestFormManageAppSer */ @Override public List getRequestForm(Long encounterId, String typeCode, String startDate, String endDate) { + return getRequestForm(encounterId, typeCode, startDate, endDate, null, null); + } + + /** + * 查询申请单(支持筛选+状态+关键字) + * + * @param encounterId 就诊id + * @param typeCode 申请单类型 + * @param startDate 开始日期(可选,格式:yyyy-MM-dd) + * @param endDate 结束日期(可选,格式:yyyy-MM-dd) + * @param status 单据状态(可选) + * @param keyword 关键字(可选,申请单号/项目名称模糊匹配) + * @return 申请单列表 + */ + @Override + public List getRequestForm(Long encounterId, String typeCode, String startDate, String endDate, String status, String keyword) { // 检查参数 if (encounterId == null) { return new java.util.ArrayList<>(); } - List requestFormList = requestFormManageAppMapper.getRequestForm(encounterId, typeCode, startDate, endDate,null,null); + List requestFormList = requestFormManageAppMapper.getRequestForm(encounterId, typeCode, startDate, endDate, status, keyword); for (RequestFormQueryDto requestFormQueryDto : requestFormList) { // 查询处方详情 List requestFormDetail = diff --git a/openhis-server-new/openhis-application/src/main/resources/mapper/regdoctorstation/RequestFormManageAppMapper.xml b/openhis-server-new/openhis-application/src/main/resources/mapper/regdoctorstation/RequestFormManageAppMapper.xml index de190fff..de33a2ca 100755 --- a/openhis-server-new/openhis-application/src/main/resources/mapper/regdoctorstation/RequestFormManageAppMapper.xml +++ b/openhis-server-new/openhis-application/src/main/resources/mapper/regdoctorstation/RequestFormManageAppMapper.xml @@ -12,12 +12,24 @@ drf.desc_json, drf.requester_id, drf.create_time, - ap.NAME AS patient_name + ap.NAME AS patient_name, + CASE MIN(wsr.status_enum) + WHEN 1 THEN 0 + WHEN 2 THEN 1 + WHEN 3 THEN 4 + WHEN 4 THEN 4 + WHEN 5 THEN 5 + WHEN 6 THEN 5 + WHEN 7 THEN 5 + ELSE NULL + END AS status FROM doc_request_form AS drf LEFT JOIN adm_encounter AS ae ON ae.ID = drf.encounter_id AND ae.delete_flag = '0' LEFT JOIN adm_patient AS ap ON ap.ID = ae.patient_id AND ap.delete_flag = '0' + LEFT JOIN wor_service_request AS wsr ON wsr.prescription_no = drf.prescription_no + AND wsr.delete_flag = '0' WHERE drf.delete_flag = '0' AND drf.encounter_id = #{encounterId} AND drf.type_code = #{typeCode} @@ -27,6 +39,33 @@ AND drf.create_time <= (#{endDate}::date + INTERVAL '1 day' - INTERVAL '1 second') + + AND CASE MIN(wsr.status_enum) + WHEN 1 THEN 0 + WHEN 2 THEN 1 + WHEN 3 THEN 4 + WHEN 4 THEN 4 + WHEN 5 THEN 5 + WHEN 6 THEN 5 + WHEN 7 THEN 5 + ELSE NULL + END = #{status}::integer + + + AND (drf.prescription_no ILIKE '%' || #{keyword} || '%' + OR EXISTS ( + SELECT 1 FROM wor_service_request wsr2 + WHERE wsr2.prescription_no = drf.prescription_no + AND wsr2.delete_flag = '0' + AND wsr2.activity_id IN ( + SELECT id FROM wor_activity_definition wad + WHERE wad.delete_flag = '0' + AND wad.name ILIKE '%' || #{keyword} || '%' + ) + )) + + GROUP BY drf.id, drf.encounter_id, drf.prescription_no, drf.name, drf.desc_json, + drf.requester_id, drf.create_time, ap.name