Y
yator
I have a table [tbl_dc_dx] that contains a field for Primary Diagnosis but
only a semi-colon delimited list of Secondary Diagnoses. The list is variable
in length and the[sec_diag] codes are in no particular order.
[tbl_dc_dx] sample data:
Account sec_diag
1 5990;2851;6262;2809;6202
2 6262;2800;4019;2808;2469
3 2851;9100;9219;E8889;E8497
4 4111;2859;4019;
5 5855;42822;2724
6 25000;4019;4580;2801
A list of applicable diagnosis codes is available in a table called
[tbl_dx_codes].
[tbl_dx_codes] sample data:
diag_cd diag_desc
2800 280.0-CHR BLOOD LOSS ANEMIA
2801 280.1-IRON DEF ANEMIA DIETARY
2808 280.8-IRON DEFIC ANEMIA NEC
2809 280.9-IRON DEFIC ANEMIA NOS
2810 281.0-PERNICIOUS ANEMIA
I would like to evaluate the [tbl_dc_dx].[sec_diag] field to find the first
result that matches the [tbl_dx_codes].[diag_cd] and return the fields
[tbl_dx_codes].[diag_cd] and [tbl_dx_codes].[diag_desc]
So the query would return:
Account diag_cd diag_desc
1 2809 280.9-IRON DEFIC ANEMIA NOS
2 2800 280.0-CHR BLOOD LOSS ANEMIA
6 2801 280.1-IRON DEF ANEMIA DIETARY
only a semi-colon delimited list of Secondary Diagnoses. The list is variable
in length and the[sec_diag] codes are in no particular order.
[tbl_dc_dx] sample data:
Account sec_diag
1 5990;2851;6262;2809;6202
2 6262;2800;4019;2808;2469
3 2851;9100;9219;E8889;E8497
4 4111;2859;4019;
5 5855;42822;2724
6 25000;4019;4580;2801
A list of applicable diagnosis codes is available in a table called
[tbl_dx_codes].
[tbl_dx_codes] sample data:
diag_cd diag_desc
2800 280.0-CHR BLOOD LOSS ANEMIA
2801 280.1-IRON DEF ANEMIA DIETARY
2808 280.8-IRON DEFIC ANEMIA NEC
2809 280.9-IRON DEFIC ANEMIA NOS
2810 281.0-PERNICIOUS ANEMIA
I would like to evaluate the [tbl_dc_dx].[sec_diag] field to find the first
result that matches the [tbl_dx_codes].[diag_cd] and return the fields
[tbl_dx_codes].[diag_cd] and [tbl_dx_codes].[diag_desc]
So the query would return:
Account diag_cd diag_desc
1 2809 280.9-IRON DEFIC ANEMIA NOS
2 2800 280.0-CHR BLOOD LOSS ANEMIA
6 2801 280.1-IRON DEF ANEMIA DIETARY