4 Replies Latest reply on Aug 5, 2009 4:55 AM by mark_d2x

# re date calculation

### Title

re date calculation

### Post

Hi

I am trying to use a calculation to work out if a patient died within 7 days or 30 days of surgery and am using the following formulas:

For within 7 days of surgery:

If((IsEmpty(PATIENT::DATE_OF_DEATH) or IsEmpty(DATE_OF_SURGERY)); ""; If((PATIENT::DATE_OF_DEATH-DATE_OF_SURGERY) ≤ 7; "Yes" ; "No"))

and within 30:

If((IsEmpty(PATIENT::DATE_OF_DEATH) or IsEmpty(DATE_OF_SURGERY)); ""; If(7 < (PATIENT::DATE_OF_DEATH-DATE_OF_SURGERY) ≤ 31; "Yes" ; "No"))

However it also gives a true result if the patient dies say a year and 6 days after the surgery etc

I am lost as to what to add in to get the calculation correct

Many thanks in anticipation

• ###### 1. Re: re date calculation
We need to know the formula of the PATIENT ::DATE_OF_DEATH-DATE_OF_SURGERY field.
• ###### 2. Re: re date calculation

mr_vodka,

DATE_OF_DEATH is a date field in the PATIENT table  and DATE_OF SURGERY is in the treatment table.  The calculation is in the treatment table as it relates to that particular treatment in a 1 to many relationship.

I think this is where I am going wrong;

DATE_OF_DEATH-DATE_OF_SURGERY?

If I have the values

DATE_OF DEATH as 02/01/2008

DATE_OF SURGERY as 01/01/2008 - then date of death within 7 days is true, but if I have  DATE OF DEATH as 29/01/2008 then death within 7 days is false and death within 30 days is true.

However, if I have the DATE OF DEATH as 16/01/2009 then the calculation is displaying Yes as per calculation ;-(

What I expected, is that this would be incremental  ie 1 2 3 4 etc. etc.

I think what is happening is that the calculation is staying at a low number even after a year -  viz. 02/01/2009 would then  be 1 again?

• ###### 3. Re: re date calculation
Assuming you mean to find out if a patient died within 7 days of their last surgery, try:

DATE_OF_DEATH
and
DATE_OF_DEATH - Max ( Treatments:: DATE_OF_SURGERY ) ≤ 7

This calculation should be in the Patients table. Make sure both referenced fields are of type Date.

• ###### 4. Re: re date calculation

Hi comment,

Many thanks for the suggestion, will give it a go and let you know.

Mark