This may be a bit of a challenge, but here goes...
1. Add a second copy of the table with the admissions data to the report. Crystal will throw a warning saying that the table is already used and asking if you want to "alias" it. It will then add the table with "_1" on the end of the table name. For this example, I'll call the two tables Admissions and Admissions_1.
2. Link from Admissions to Admissions_1 on MR number and make it a left outer join.
3. In the Select Expert, add something like the following (include the parentheses to get it to work correctly!)
(
IsNull({Admissions_1.MR_NUMBER}) or
(
{Admissions_1.DISCHARGE_DATE} < {Admissions.DISCHARGE_DATE} and
{Admissions_1.DISCHARGE_DATE} > DateAdd('yyyy', -1, {Admissions.DISCHARGE_DATE})
)
)
4. Create a formula that looks something like this:
{@HasPriorAdmit}
if IsNull({Admissions_1.MR_NUMBER}) then 'NO' else 'YES'
NOTE: If the patient has multiple prior admisssions, this will increase the number of records that will appear in the details section of your report. One way around this will be to create a patient group and put all of the patient data in that group while suppressing the details section. Depending on the design of your report and the other data that needs to be displayed, this may or may not be a valid solution.
-Dell