Re: Can you Loop-de-Loop?
- From: Helpful Harry <helpful_harry@xxxxxxxxxxxxxxxx>
- Date: Sat, 29 Apr 2006 15:32:32 +1200
In article <ods45259g7jg1lmnc00a12lf413da7s2ab@xxxxxxx>, VoicesInMyHead
<not@xxxxxxxxxx> wrote:
Order Table
Drug
Drug Table
Drug
Interaction_Drug (Portal List of Interactions)
Hmm. I am beginning to lothe portal loops...
======================
Perform Script [Find Patient History]
//finds only the the records I need to check against
Go to Related Record [Show only related records; From table:"Drug
Table" Using layout:"Drug"]
//finds only the drug from the Order and places me in the necessary
portal
Loop
Go to Portal Row [First]
Loop
If[Drug::Interaction_Drug = Order::Drug]
Show Custom Dialog ["Do Not Dispense";"Blah Blah Blah"]
End If
Go to Portal Row [Next;Exit after last]
End Loop
*****
Go to Record [Next;Exit after last]
End Loop
======================
*****Shouldn't there be a Go to Layout here?
How does the script know to go to the next record of the Order Table
for only the necessary patient? I have tried to add several different
"Go to's" here, but nothing has yet to work.
Since I am trying to...
check portal rows on layout 2 against
a field from a list of records on layout 1,
...do I need to set up a global field to hold the record's field
value(s)?
I think the ***** line would need to be some sort of command to go back
to the Order Table so that it can get the next Order record ... don't
ask me what that is though, unfortunately I've never used FileMaker 7
or 8. It may or may not mean going to a different Layout. (I can't say
I ever liked the idea of putting all the tables in one file - it simply
adds an unnecessary level of confusion. With the tables in separate
files you always knew what the script was acting on.)
BUT, I think you've got a confused system there that may need changing,
although that could just be because you haven't given all of the
details of it here.
It might be better to change Interaction_Drugs in the Drug Table to be
just a normal Text field into which you type each drug name separated
by a carriage return. Also change the data entry method so that the
new drug (and patient details??) in the Orders Table is entered into
Global field and then the user clicks on a Add / Check button which
runs the checking script something like:
Perform Script [Find Patient History]
//find only the the records I need to check against
Go To Record [First]
Loop
If [PatternCount(g_NewDrug & "¶";
DrugsRelationship::Interaction_Drugs & "¶") = 1]
Beep
Show Custom Dialog ["Do Not Dispense";"Blah Blah Blah"]
Exit Script
End If
Go To Record [Next; Exit After Last]
End Loop
// If script reaches here without Exiting, then there is no clash
// so add a new Orders record
New Record
Set Field [Drug; g_NewDrug]
Set Field [ ...
// Transfer other Global fields to new record
Set Field [g_NewDrug; ""]
Set Field [ ...
// Clear the content of the Global fields ready
// for the next new Order
This way you check the one new drug against the existing records and
one related field, so there's no "bouncing" around from table to table
and no portal to loop through (not that there's anything wrong or
complicated about looping through a portal by itself).
Note:
To limit possible problems caused by typos, the g_NewDrug field may be
best set up as a pop-up menu of choices obtained from a relationship
link from Orders to all records in Drugs.
You could also do something similar Drugs where the Interaction_Drugs
is a checkbox field (which luckily means each chosen value will
automatically be spearated by carriage returns) that obtains it's
values from a self-relationship to all records in Drugs ... although
that could be difficult to display if there's LOTS of names to choose
from. In that case a few pop-menu fields (Interaction_Drug1,
Interaction_Drug2, etc.) could be better method and then simply have a
Calculation field to combine them all together,
ie. Interaction_Drugs = Interaction_Drug1 & "¶" & Interaction_Drug2
& ...
although they'd be LONG menus, so you might have to split them up
another way using inter-connected menu options (ie. choose "Red pills"
from one menu and then a second menu shows just all the red pill
options).
This script will also most likely be growing, as there is already talk
of showing the list of conflicting drugs, rather than just a warning.
And only on prescriptions that have refills vs their entire history.
Gotta love it - Can't live without it - Give me more of it
I'm not sure, but the Show Custom Dialog may be able to display the
clashing names in it's message,
ie.
g_NewDrug & " interacts with " & DrugsRelationship::Drug
Or you could easily change this script to not exit the script when it
finds a clash, but instead adds the clash to a Global Text field and
continues looking for more, and then when finished going through the
records it displays the full list of clashes.
The second part would become fairly easy since you can mark individual
Order records as "Out of date" and simply make the loop skip over such
records without checking them.
ie.
Loop
If [OutOfDate <> "Yes"]
If [PatternCount(g_NewDrug & "¶";
DrugsRelationship::Interaction_Drugs & "¶") = 1]
Beep
Show Custom Dialog ["Do Not Dispense";"Blah Blah Blah"]
Exit Script
End If
End If
Go To Record [Next; Exit After Last]
End Loop
The "<>" is a "not equal" symbol (the equals sign with a bar through it
doesn't show up in some newsreader applications) ... either symbol
works in FileMaker.
Helpful Harry
Hopefully helping harassed humans happily handle handiwork hardships ;o)
.
- References:
- Can you Loop-de-Loop?
- From: VoicesInMyHead
- Re: Can you Loop-de-Loop?
- From: Helpful Harry
- Re: Can you Loop-de-Loop?
- From: VoicesInMyHead
- Can you Loop-de-Loop?
- Prev by Date: Re: Server 7 Seems to Dislike My Database
- Next by Date: Re: FM8.03 Open-file script and Get(PrivilegeSetName)
- Previous by thread: Re: Can you Loop-de-Loop?
- Next by thread: Are value list items indexed?
- Index(es):
Loading