我写这篇文章是为了让那些从未接受过诊断代码的病人。但是我得到了DID的人的结果。只是它没有在输出中显示代码,而是显示其他代码。 但是我不需要包含那些拥有该代码而非NOT IN部分的患者 不工作或我还缺少什么?
select Distinct a.voucher_primary_diagnosis_code, a.Patient_Number, b.Patient_Name vwGenVouchInfo a
left join vwGenPatInfo b on a.Patient_Number=b.patient_number
where
a.Department_Descr = 'Pediatrics' and Actual_Dr_ID <> 6 and Voucher_Primary_Diagnosis_Code not in
('Z00.129', 'Z00.00') order by patient_name
答案 0 :(得分:0)
您可以使用select p.Patient_Number, p.Patient_Name
from vwGenPatInfo p left join
vwGenVouchInfo v
on p.Patient_Number = v.patient_number and
v.Department_Descr = 'Pediatrics' and
v.Actual_Dr_ID <> 6 and
v.Voucher_Primary_Diagnosis_Code in ('Z00.129', 'Z00.00')
where v.patient_number is null
order by p.patient_n
执行此操作。以下是让符合您描述的患者的一种方法:
<p th:text="${#bools.listIsTrue(Item.granted_authorities)}"></p>
请注意,这不会返回有关诊断的信息,因为您正在接收没有您所关心诊断的患者。
答案 1 :(得分:0)
NOT IN
条件适用于单行。但是,您正在寻找与给定患者相关的任何与指定代码匹配的行的EXISTS
量词:
SELECT
a.voucher_primary_diagnosis_code
, a.Patient_Number
, b.Patient_Name
FROM vwGenVouchInfo a
LEFT JOIN vwGenPatInfo b ON a.Patient_Number=b.Patient_Number
WHERE
a.Department_Descr = 'Pediatrics'
AND Actual_Dr_ID <> 6
AND NOT EXISTS (
-- This subquery looks at other vouchers of the same patient.
-- If any of them has Diagnosis Code from the prohibited list,
-- all records for that patient are rejected.
SELECT *
FROM vwGenVouchInfo v
WHERE v.Patient_Number=b.Patient_Number
AND v.Voucher_Primary_Diagnosis_Code IN ('Z00.129', 'Z00.00')
)
ORDER BY Patient_Name