我正在 AllScripts 中运行一个提供患者更新报告的查询。我有我想要的所有列,除了一个之外的所有列都正确返回。另一个是不正确的,据说,但它有很多值可以返回,而不是我想要的。编码:
SELECT PT_BASIC.PATIENT_CODE, PT_BASIC.NAME_LAST,
PT_BASIC.NAME_FIRST,
PT_ADMISSION.ADMIT_DATE,
PT_ADMISSION.TERMINATION_DATE,
C_DIAGNOSIS.DIAGNOSIS,
PT_BASIC.DATE_OF_BIRTH, PT_BASIC.SEX,
PT_STATUS.STATUS_CODE,
O_DATASET.DATASET_NAME,
RES_BASIC.ORGANIZATION_NAME,
RES_BASIC_2.NAME_FULL,
PT_STATUS.STATUS_DATE,
RES_BASIC_3.NAME_FULL NAME_FULL_2,
RES_BASIC_3.NAME_FIRST NAME_FIRST_2,
RES_BASIC_3.NAME_LAST NAME_LAST_2,
C_DIAGNOSIS.ICD9_CODE,
RES_BASIC_4.NAME_FULL NAME_FULL_3,
A_ASSIGNMENT_TYPE.DESCRIPTION,
res_basic_3.name_last + ', ' + res_basic_3.name_first res_basic_3_name_last_res
FROM PT_BASIC PT_BASIC
INNER JOIN PT_ADMISSION PT_ADMISSION ON
(PT_ADMISSION.PATIENT_ID = PT_BASIC.PATIENT_ID)
INNER JOIN PT_STATUS PT_STATUS ON
(PT_STATUS.ADMISSION_ID = PT_ADMISSION.ADMISSION_ID)
AND (PT_STATUS.PATIENT_ID = PT_ADMISSION.PATIENT_ID)
INNER JOIN PTC_DIAGNOSIS PTC_DIAGNOSIS ON
(PTC_DIAGNOSIS.PT_DIAGNOSIS_ID = PT_STATUS.PRIMARY_DIAGNOSIS_ID)
AND (PTC_DIAGNOSIS.PATIENT_ID = PT_STATUS.PATIENT_ID)
INNER JOIN C_DIAGNOSIS C_DIAGNOSIS ON
(C_DIAGNOSIS.DIAGNOSIS_ID = PTC_DIAGNOSIS.DIAGNOSIS_ID)
AND (C_DIAGNOSIS.DIAGNOSIS_SET_ID = PTC_DIAGNOSIS.DIAGNOSIS_SET_ID)
INNER JOIN O_DATASET O_DATASET ON
(O_DATASET.DATASET_ID = PT_BASIC.DATASET_ID)
LEFT OUTER JOIN PT_ADMISSION_REFERRAL PT_ADMISSION_REFERRAL ON
(PT_ADMISSION_REFERRAL.REFERRAL_ID = PT_BASIC.PATIENT_ID)
FULL OUTER JOIN RES_BASIC RES_BASIC ON
(RES_BASIC.RESOURCE_ID = PT_ADMISSION.REFERRAL_SOURCE)
FULL OUTER JOIN RES_BASIC RES_BASIC_2 ON
(RES_BASIC_2.RESOURCE_ID = PT_STATUS.ASSOCIATED_FACILITY_ID)
FULL OUTER JOIN RES_BASIC RES_BASIC_3 ON
(RES_BASIC_3.RESOURCE_ID = PT_ADMISSION.PHYSICIAN_ID1)
FULL OUTER JOIN PT_ASSIGNMENT PT_ASSIGNMENT ON
(PT_ASSIGNMENT.ASSIGNMENT_ID = PT_BASIC.PATIENT_ID)
FULL OUTER JOIN A_ASSIGNMENT_TYPE A_ASSIGNMENT_TYPE ON
(A_ASSIGNMENT_TYPE.ADMIN_SET_ID = PT_ASSIGNMENT.ADMIN_SET_ID)
AND (A_ASSIGNMENT_TYPE.TYPE_ID = PT_ASSIGNMENT.ASSIGNMENT_TYPE)
FULL OUTER JOIN RES_BASIC RES_BASIC_4 ON
(RES_BASIC_4.RESOURCE_ID = PT_ASSIGNMENT.RESOURCE_ID)
WHERE
( O_DATASET.DATASET_NAME = 'LIVE Seasons Hospice' )
AND ( PT_ADMISSION.ADMIT_DATE > CONVERT(DATETIME,'2012-01-01',120) )
ORDER BY PT_STATUS.STATUS_DATE DESC,
PT_ADMISSION.ADMIT_DATE DESC,
PT_BASIC.PATIENT_CODE
我现在正在处理的部分是 A_ASSIGNMENT_TYPE.DESCRIPTION。在每个患者中,都有一个分配列表。描述是指派类型,例如社会工作者或入职护士。我只在寻找 PCC。提取此信息的代码是:
(PT_ASSIGNMENT.ASSIGNMENT_ID = PT_BASIC.PATIENT_ID)
FULL OUTER JOIN A_ASSIGNMENT_TYPE A_ASSIGNMENT_TYPE ON
(A_ASSIGNMENT_TYPE.ADMIN_SET_ID = PT_ASSIGNMENT.ADMIN_SET_ID)
AND (A_ASSIGNMENT_TYPE.TYPE_ID = PT_ASSIGNMENT.ASSIGNMENT_TYPE)
FULL OUTER JOIN RES_BASIC RES_BASIC_4 ON
(RES_BASIC_4.RESOURCE_ID = PT_ASSIGNMENT.RESOURCE_ID)
现在,与不查找分配的查询相比,我的查询获得了正确数量的条目,并且它提取了与该分配关联的正确名称 (res_basic_4),但它提取了我不需要的分配。我只希望它列出 PCC 的名称,即使在资源名称为空白的情况下(因为没有分配 PCC)。