I have a project that requires me to match medical procedures in a SQL Server database with a corresponding result. EX: procedure note contains screening and result note appears within a week of that procedure containing abnormal.
The problem is both the procedure notes and the result come into the database as just text in the same table, the only linking information they have is a patient ID. I need to end up with a list of patient ID and date for each matching procedure/result.
I thought about first sorting all text-match procedures and text-match results to separate temporary tables then joining them somehow, but I am not sure how that would work to group by ‘within a week of each other’ and discard the left overs.
Any tips? Any information that would help answer from here?
Requested additional info:
Basically I have this:
PatientID ReportType ReportDate ReportText
24734 Procedure 1/1/1901 Lots O HTML
24734 Report 1/2/1901 Lots O HTML
...
This table is the result of already filtering for the words ‘screening’ and ‘abnormal’ in the ReportText column. So given the two results above we can see the Patient ID matches, and there is one of each report type within a week of each other so they should be a match and listed as one line item.
you could do the following
So you join the same table on patientid, where the left table has the screening part and the right table the abnormal part. Later, you will get some dates, which you can substract from each other with the datediff function, which returns the amount of weeks (wk) difference between the start and end.
You can also use days (d) for that 🙂