Joined: 03 Jun 2008
Location: United States
Online Status: Offline
Posts: 20
Topic: Need help with formula Posted: 22 Jul 2008 at 10:21am
I am working on a report for a medical facility. Currently the report is returning duplicate records if the patient has been admitted to the facility more than once.
I am trying to add a statement to Select Export formula editor that will eliminate duplicate records.
The statement I added is: {PATIENT_FAC_ADMISSION.ADMITTED_Y} = "Y" or {PATIENT_FAC_ADMISSION.DISCHARGE_DATE} >= {?Start Date}
The possible values for PATIENT_FAC_ADMISSION.ADMITTED_Y is either Y or null.
The {?Start Date} is a parameter the user enters.
I am trying to bring back records for patients that are either currently admitted, or were discharged at some date later than the start date the user entered as a parameter.
For example, I am running the report for the month of June. I want records returned on all patients that are currently admitted and any patients who were admitted, but discharged after June 1. I hope that makes sense.
When I test the formula in the Select Expert formula editor, no errors are found, but if I save it and try to refresh the data, the report locks up.
The existing formula, which brings back duplicate records is:
MIMS_USER.MIMS_USER_ID} = {?MimsUser} and
{MIMS_USER_FACILITY.FACILITY_CODE}={?Facility} and
{DIALYSUM.FACILITY_CODE} = {?Facility} and
{DIALYSUM.DATETIME} >={?Start Date} and
{DIALYSUM.DATETIME} <={?End Date} and
{DIALYSUM.DEPARTMENT} = 3 and
{DIALYSUM.DURATION_VARIANCE} < -5.00 and
{DIALYSUM.DURATION_VARIANCE} > -200 and
{DIALYSUM.PROCESS_STATUS} = "FINAL"
I am adding the new statement to the end of formula.
Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Posted: 22 Jul 2008 at 3:14pm
Try adding parenthses around this new part of your filter:
({PATIENT_FAC_ADMISSION.ADMITTED_Y} = "Y" or {PATIENT_FAC_ADMISSION.DISCHARGE_DATE} >= {?Start Date})
'And' and 'Or' are evaluated sequentially. So with your formula, it's looking for all of the records that meet all of the criteria before the 'or' PLUS ALL of the data that meets the discharge date criteria after the 'or'. This is not a Crystal issue, it's the way the SQL works.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum