Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8328033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:18:42+00:00 2026-06-09T01:18:42+00:00

I have a project that requires me to match medical procedures in a SQL

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T01:18:43+00:00Added an answer on June 9, 2026 at 1:18 am

    you could do the following

    select   * 
    from     tableA a1
             inner join tableA a2
               on  a1.patientid = a2.patientid
               and a2.textvaluecolumn = 'abnormal'
    where    a1.textvaluecolumn = 'screening'
    and      datediff(wk, a1.date, a2.date) = 1
    

    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 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently working on a project that requires me to match our database of
I have a project that requires the following. Four arrays will be declared in
I have a project that requires some configuration files. I want to keep the
I have recently just created Java project using Eclipse that requires 2 JAR files
$(.container).hover( function(){ $(.child-1).hide(0); $(.child-2).show(0); },function(){ $(.child-1).show(0); $(.child-2).hide(0); }); A project I have requires that
A common occurrence I have with one particular project is that it requires the
I have a project that requires an ASP.Net app to use google credentials and
I have a maven project that requires a property to be set at the
I have a C# application (project A) that requires X.dll. I have added the
Hii all,, I have some project that requires me to do Image processing, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.