Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 396
  • Last Modified:

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

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
Becky Edwards
Asked:
Becky Edwards
1 Solution
 
Anthony PerkinsCommented:
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
 
James0628Commented:
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
 
DcpKingCommented:
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
James0628Commented:
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
 
Becky EdwardsEpic Clarity DeveloperAuthor Commented:
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
 
DcpKingCommented:
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now