Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi all I'm really struggling to 1

Status
Not open for further replies.

MadCatmk2

Programmer
Oct 3, 2003
145
GB
Hi all

I'm really struggling to find a solution to this problem. I'm using Crystal 9.0 with an Access database.

I have a report outlining contacts made to patients by district nurses over a period of time. It is grouped on the "patient number" and on the "referral number". In its most basic form the report is laid out like this:

PatNo. ReasonCare Modifier
SB1074*3 (referral number)
SB1074 Mobility First
SB1074*4
SB1074 medication First
SB1074 medication recurrence
SB1074*5
SB1074 Mobility First
SB1074 Mobility Recurrence
SB1074 Mobility Recurrence

There are other fields in the final report but none that affect the problem i'm having.

The problem stems from the Modifier field. What this should do is check the reason for care and if its the first case of that one the the Modifier is set to "first", if its any more than the first then it is classed as a "recurrence". This all works as it is but there is one last thing which is causing the problem. If a previous referral for a particular patient contains the reason for care that is found as the first one in the current referral then the modifier should not read "first" but instead read "Persistant" as the patient has been seen before for the same problem, any cases forllowing this will be set to recurrence as normal.

The ideal output should look like this:

PatNo. ReasonCare Modifier
SB1074*3 (referral number)
SB1074 Mobility First
SB1074*4
SB1074 medication First
SB1074 medication recurrence
SB1074*5
SB1074 Mobility Persistant
SB1074 Mobility Recurrence
SB1074 Mobility Recurrence


Hope this makes sense.

Could anyone suggest to me a way of doing this. Any help is much appreciated.

Thanks in advance
 
Sorry. I forgot to add a subject heading to the Previous post
 
Hi !

If I have get it right maybe this can be something to try:

Create two formulas

@ReasonC_reset
WhilePrintingRecords;
StringVar ReasonC;

ReasonC := '';


This one you put in the Patient GroupHeader

@ReasonC_tot
WhilePrintingRecords;
StringVar ReasonC;

if instr(ReasonC,{Table.REASONCARE}) = 0 then
ReasonC := {Table.REASONCARE} + ' ' + ReasonC
else
ReasonC;


This one you put in the detailsection

Now in your Modifier formula you can have a test something like:

if instr({@ReasonC_tot},{Table.REASONCARE}) > 0 then
'Persistant'
else
'First'


Hope it will get you closer to a solution

/Goran
 
This may seem like a stupid question (and more than likely is :eek:) ) When you say @ReasonC_reset / @ReasonC_Tot, what are these? Is it just the name of the formula?

Sorry

Thanks for the help though, it looks very much like what you have said is a big step in the right direction.

Thanks again
 
Hi !
Yes, it was just my name of the formulas.

/Goran
 
Thats great. It is so close to working, there is one problem though. When it looks at the first entry instead of putting 'first' it puts 'persistant'. It seems to read the ReasonC_tot before doing the modifier function. Because of this, there is always an entry in the ReasonC that will cause a persistant entry. Is there some way to calculate the modifer first then the ReasonC_tot.

Thanks again, your help is most appreciated.
 
Ok, in the ReasonC formula you can start the formula with:
EvaluateAfter({YourModifier Formula})

/Goran
 
I'm getting an error saying that a formula cannot refer to itself either directly or indirectly.

The modifier formula is called 'modifier' and is calculated using a running total field (not sure if this would affect anything.

I'm not sure why this is happening.

Thanks
 
Did you place the "EvaluateAfter" in the ReasonC formula ?

Another question:
Do you have two differnet groups ?
One for "patient number" and one for "referral number"?

/Goran
 
It is placed in the ReasonC_tot formula yes.

My apologies for the initial description of the groups. I actually have three groups. The 'patient number', 'patient referral' and also a 'Reason for care'

The reason for the last one is so that i can perform the running total formula modifierRT. This counts the contacts and resets on the change of each 'Reason for care' group. From this running total i get my modifier formula, which is now:

if {#ModifierRT} = 1 then

if instr({@ReasonC_tot},{CONTACTS.PRIMARY_REASON_CARE}) > 0 then
'Persistant'
else
'First'

else if {#ModifierRT} >1 then
"Recurrence"


Does this help you at all?

Thanks
 
From what i can see the problem is caused when the Instr function is called within the modifier formula. It calls ReasonC_tot which refers to the modifier formula indirectly. Knowing that, is there a way around this?
 
Hi again !

I played around a little and I think this can work.

Create another formula
@ReasonC_group

WhilePrintingRecords;
StringVar ReasonC;

ReasonC;

Place this formula in your second Group Footer.

Now you also have to change your Modifier formula like:

if {#ModifierRT} = 1 then

if instr({@ReasonC_group},{CONTACTS.PRIMARY_REASON_CARE}) > 0 then
'Persistant'
else
'First'

else if {#ModifierRT} >1 then
"Recurrence"

Good luck.
 
Thank you so much. That did the trick, not sure exactly why it works. If its not a problem, could you answer what the last group does. Is it just to bypass the fact that modifier cannot be called indirectly from within the ReasonC_tot.

Once again thank you very much, your help is greatly appreciated.
 
Hi !
Glad to hear that it worked.

Well as you said earlier the ReasonC_tot formula get its entry before the Modifier formula was executed.

This last formula don´t have the latest ReasonCode until you reach the GroupFooter of the actual code.

I hope you get the point though I can hear that the explanation not sounds to clear.

/Goran
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top