Solved

need to get data based on a date plus or minus four hours from another date

Posted on 2014-09-05
6
374 Views
Last Modified: 2014-09-22
Attached is a report.  i need to pull the medication 'taken time' based on four hours plus or minus the procedure start time.

The procedure start time is a calculated field based on a given event.  The formula is on the report called procedure start.

Example:  Test Heidi had a surgery on 6/10.  There are two taken times showing, because the report is pulling all medications she has ever been given.  I want just the medications given +/- four hours from the procedure start time.

Thank you for your assistance.
OR-GI-Antibiotic-Admins-NCH-ver2.rpt
0
Comment
Question by:Becky Edwards
6 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 40307046
You may find members here somewhat hesitant about downloading a file here, especially one.that is not txt or pdf.  So if you are trying to describe something here you may be better off pasting it in as an image.
0
 
LVL 34

Expert Comment

by:James0628
ID: 40307434
Anthony Perkins,

 Posting the actual report (RPT) file is usually the best option with a question like this, as long as the report doesn't include any "sensitive" information.  That way we can see the report structure, etc. for ourselves.

 FWIW, in this case the file d/l'ed with an HTML extension, but it is actually a CR report file.  I'm not sure what happened there.  I recently read that EE was having problems with some file uploads, so maybe EE changed the extension.

 James
0
 
LVL 16

Accepted Solution

by:
DcpKing earned 500 total points
ID: 40307435
Within the report, or within the code providing data for the report, you can probably use a function datediff to get the number you want.

datediff has 3 parameters - the units, the first datetime, and the last datetime. Note that the format of the units can vary - in SSRS "m" indicates months whereas in T-SQL you use just an m - no quotes!

So in your case you have a patient who had surgery on June 10 but you must also have a time. So we'll assume that surgery was started at 2014:06:10 15:00:00 (3 pm). This can be called tiSurgery.

In a query for all medications administered +/- four hours of that time one would be comparing a medication administration datetime from a table, which can be called tiMedAdmin, in the following way:

abs (  datediff(hour, tiSurgery, tiMedAdmin)  )  < 4

Values where tiMedAdmin is before tiSurgery will be negative, hence the use of the abs() function (absolute value).


hth

Mike
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 34

Expert Comment

by:James0628
ID: 40307449
bjrhart,

 Group selection may work.  Go to Report > Selection Formulas > Group and enter the following formula:

{MAR_ADMIN_INFO.TAKEN_TIME} in
 DateAdd ("h", -4, Maximum ({@Proc Start}, {ORDER_MED.ORDER_MED_ID})) to
 DateAdd ("h", 4, Maximum ({@Proc Start}, {ORDER_MED.ORDER_MED_ID}))


 That uses DateAdd to subtract 4 hours from the start time and add 4 hours, to create the range.

 I am assuming that ORDER_MED_ID is a unique ID for every time a patient is given any medication, as opposed to an ID for the medications themselves.  IOW, you do not have the same ORDER_MED_ID for every time a patient is given medication X.  (I hope that made sense :-)

 If the group selection formula works, note that group selection is really suppression.  The report is still reading all of the same records (it has to, in order to get the value for {@Proc Start}, and then determine if that group should be included).  So, if you use any CR summaries, they will include the groups that are not shown.  Also, if the group tree is visible when someone runs the report, the tree will include the groups that are not shown, but if someone tries to select one of them, CR will just move to the nearest visible group.


 If the group selection works, but, for example, you want to use summaries, or the report is just reading a lot of extra data that is then not shown, and that slows the report down; then you may need to do this by writing a query that selects the correct data before it is sent to the report, and using that as the datasource.  That would be the most efficient solution.

 James
0
 

Author Closing Comment

by:Becky Edwards
ID: 40337389
Actually, Mike, this is what I was looking for. A way to create a formula based on two fields.  I may have problems because one of the fields is actually a formula, but I will cross that road when I get there.

Thank you,

Becky
0
 
LVL 16

Expert Comment

by:DcpKing
ID: 40337774
Then ask that question too (separately). Post a comment here saying you're starting another question, with the question title, and people who've seen this one can help you there too.

As for the field being a formula, do you mean that it is an expression involving two or more other fields? If so, you might get something like this:

abs (  datediff(hour, tiSurgery, (tiMedStart + (3 * tiMedInterval) ) )  )  < 4

where you might be looking at a start time and a number of intervals after (where meds are given at each interval)

hth

Mike
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Join & Write a Comment

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now