hjohnson919
Programmer
I'm converting a formula from Basic to Crystal syntax. I'm using CR 10 against an Avatar (AKA NetSmart) hospital information system. The routine is supposed to calculate the number of days the person has been certified. The error message I'm getting is "A number is required here" and everything from the "ELSE //error here" down is highlighted. Lots of lines of code commented out in order to try to find the error. Is it punctuation?
WhilePrintingRecords;
Global DateVar CertBegin;
Global DateVar CertEnd;
Global DateVar CertSave;
Global NumberVar CertDays;
Global NumberVar FAdultCertDays;
Global NumberVar FAdolCertDays;
Global NumberVar TotalCertDays;
Global BooleanVar FirstRecordFlag;
// ?EndDate is a date
//
IF FirstRecordFlag THEN
(
FirstRecordFlag := FALSE;
CertBegin := {view_episode_summary_admit.preadmit_admission_date};
// Decide what value to use as the end of the certification period
// If there is no decertification date and no discharge, use the parameter date
// If there is no decertification date but there is a discharge, use the discharge date
// If there is a decertification date use it
IF ISNULL({certification.decertified_date}) THEN
(
IF ISNULL({view_episode_summary_admit.date_of_discharge}) THEN
(
CertEnd := {?EndDate}
)
ELSE
(
CertEnd := {view_episode_summary_admit.date_of_discharge}
)
)
ELSE
(
CertEnd := {certification.decertified_date} //decertified_date is not null
);
//Once you have a date for the end of certification, compare it to the beginning of certification
//If they were certified and decertified on the same day, it still counts as 1 day
CertDays := DATEDIFF("d", CertBegin, CertEnd);
IF CertDays = 0 THEN
(
CertDays := 1
)
)
ELSE //error here
//FirstRecordFlag is false so it is a second record
//(
// IF ISNULL({certification.decertified_date})
// THEN
// (
// IF NEXT({view_episode_summary_admit.PATID})={view_episode_summary_admit.PATID}
// AND NEXT({view_episode_summary_admit.EPISODE_NUMBER}) = {view_episode_summary_admit.EPISODE_NUMBER}
// THEN CertSave := {certification.recertified_date}
// ELSE CertBegin := {certification.recertified_date};
//Next record is for a different person or a different episode for this person
// IF ISNULL({view_episode_summary_admit.date_of_discharge})
// THEN CertEnd := {?EndDate}
// ELSE CertEnd := {view_episode_summary_admit.date_of_discharge};
// IF CertBegin = CertEnd
// THEN CertDays := CertDays + 1
//if the person was recertified on the day they were discharged,
//add that one day to the count
// ELSE CertDays := CertDays + DATEDIFF("d", CertBegin, CertEnd);
// )
// ELSE //there is a decert date
// (
CertBegin := CertSave;
// CertEnd := {certification.decertified_date};
// CertDays := CertDays + DATEDIFF("d", CertBegin, CertEnd)
//I'm not sure what to do if a person
//is recertified and decertified on the same day - I'm counting the day as NOT certified here.
//)
//;
IF {view_episode_summary_discharge.disc_unit_code} = "APSF" AND {@AdmitAge} >=18.0
THEN FAdultCertDays := CertDays;
IF {view_episode_summary_discharge.disc_unit_code} = "APSF" AND {@AdmitAge} <18.0
THEN FAdolCertDays := CertDays;
WhilePrintingRecords;
Global DateVar CertBegin;
Global DateVar CertEnd;
Global DateVar CertSave;
Global NumberVar CertDays;
Global NumberVar FAdultCertDays;
Global NumberVar FAdolCertDays;
Global NumberVar TotalCertDays;
Global BooleanVar FirstRecordFlag;
// ?EndDate is a date
//
IF FirstRecordFlag THEN
(
FirstRecordFlag := FALSE;
CertBegin := {view_episode_summary_admit.preadmit_admission_date};
// Decide what value to use as the end of the certification period
// If there is no decertification date and no discharge, use the parameter date
// If there is no decertification date but there is a discharge, use the discharge date
// If there is a decertification date use it
IF ISNULL({certification.decertified_date}) THEN
(
IF ISNULL({view_episode_summary_admit.date_of_discharge}) THEN
(
CertEnd := {?EndDate}
)
ELSE
(
CertEnd := {view_episode_summary_admit.date_of_discharge}
)
)
ELSE
(
CertEnd := {certification.decertified_date} //decertified_date is not null
);
//Once you have a date for the end of certification, compare it to the beginning of certification
//If they were certified and decertified on the same day, it still counts as 1 day
CertDays := DATEDIFF("d", CertBegin, CertEnd);
IF CertDays = 0 THEN
(
CertDays := 1
)
)
ELSE //error here
//FirstRecordFlag is false so it is a second record
//(
// IF ISNULL({certification.decertified_date})
// THEN
// (
// IF NEXT({view_episode_summary_admit.PATID})={view_episode_summary_admit.PATID}
// AND NEXT({view_episode_summary_admit.EPISODE_NUMBER}) = {view_episode_summary_admit.EPISODE_NUMBER}
// THEN CertSave := {certification.recertified_date}
// ELSE CertBegin := {certification.recertified_date};
//Next record is for a different person or a different episode for this person
// IF ISNULL({view_episode_summary_admit.date_of_discharge})
// THEN CertEnd := {?EndDate}
// ELSE CertEnd := {view_episode_summary_admit.date_of_discharge};
// IF CertBegin = CertEnd
// THEN CertDays := CertDays + 1
//if the person was recertified on the day they were discharged,
//add that one day to the count
// ELSE CertDays := CertDays + DATEDIFF("d", CertBegin, CertEnd);
// )
// ELSE //there is a decert date
// (
CertBegin := CertSave;
// CertEnd := {certification.decertified_date};
// CertDays := CertDays + DATEDIFF("d", CertBegin, CertEnd)
//I'm not sure what to do if a person
//is recertified and decertified on the same day - I'm counting the day as NOT certified here.
//)
//;
IF {view_episode_summary_discharge.disc_unit_code} = "APSF" AND {@AdmitAge} >=18.0
THEN FAdultCertDays := CertDays;
IF {view_episode_summary_discharge.disc_unit_code} = "APSF" AND {@AdmitAge} <18.0
THEN FAdolCertDays := CertDays;