I have a Diagnosis table like shown below (just an eg) There are 50 ICD10 columns as shown below.
+----+-------------+------+----------------+------+-----+------+-------+--------------+-------+
| ID | ICD10_Diag1 | POA1 | ICD10_Diag2 | POA2 | ... | .... | POA49 | ICD10_Diag50 | POA50 |
+----+-------------+------+----------------+------+-----+------+-------+--------------+-------+
| 1 | A234 - Flu | Y | B456 - Cough | Y | | | N | A844 - Fever | N |
+----+-------------+------+----------------+------+-----+------+-------+--------------+-------+
| 2 | A563 - Cold | Y | I567 - Cardiac | Y | | | | | |
+----+-------------+------+----------------+------+-----+------+-------+--------------+-------+
| 3 | C354 - CHF | N | | | | | | | |
+----+-------------+------+----------------+------+-----+------+-------+--------------+-------+
I'm trying to see how I can transpose this table structure so that I can perform the below operation.
Find the records which contain these Diagnosis codes(A234, F384, I567) and their corresponding POA is 'Y'. Even if a single match is found then then ignore the rest of the diagnosis even if there is a match.
SQL
Select * from myTable WHERE ('%A234%', '%F384%', '%I567%') IN (ICD10_Diag1, ICD10_Diag2, ICD10_Diag3, ICD10_Diag4)
I know this is not the right way to do it, I'm trying to find an alternative
Desired Result
1 A234-Flu
2 I567 - Cardiac