May 25, 200817 yr Newbies I am a medic at an overnight camp and am trying to create a database to track the camper's medication delivery and all their illnesses and injuries while at camp. I am trying to create a script that will automatically, when executed, create records based on a record in one layout in another layout. I want to give it a date range and time of delivery range and have it generate each event (or time when pills are delivered). I attached my script, be kind, this is my first time making a script. Thanks for any and all your help! If [ MedicationLine::Times ≠ "" and MedicationLine::StartDate ≠ "" and MedicationLine::EndDate ≠ "" and MedicationLine::StartTime ≠ "" and MedicationLine::EndTime ≠ "" ] Set Variable [ $medicationline; Value:MedicationLine::MedicationLineID ] Set Variable [ $begindate; Value:Date ( 6 ; 15 ; 2008 ) ] Set Variable [ $enddate; Value:Date ( Month ( MedicationLine::EndDate ) ; Day ( MedicationLine::EndDate ) ; Year ( MedicationLine::EndDate ) ) - $begindate ] Set Variable [ $days; Value:Date ( Month ( MedicationLine::StartDate ) ; Day ( MedicationLine::StartDate ) ; Year ( MedicationLine::StartDate ) ) - $begindate ] Set Variable [ $times; Value:MedicationLine::StartTime ] Go to Layout [ “Pill Call” (Pill Call) ] Loop Loop If [ MedicationLine::Times = $times ] New Record/Request Set Field [ Pill Call::MedicationLineFK; $medicationline ] Set Field [ Pill Call::TimeFK; $times ] Set Field [ Pill Call::DayFK; $days ] End If Set Variable [ $times; Value:MedicationLine::Times + 1 ] Exit Loop If [ If ( $enddate = $days ; $times = MedicationLine::EndTime ; $times = 10 ) ] End Loop Exit Loop If [ $enddate = $days ] Set Variable [ $days; Value:$days + 1 ] Set Variable [ $times; Value:1 ] End Loop End If pillcall_script.pdf relationship_map.pdf Edited May 25, 200817 yr by Guest Added more database info and relationships
May 26, 200817 yr First of all, I recommend using the "Code" button, it does help make a long script more readable. Your script has several problems. Let's start with this line: Exit Loop If [ If ( $enddate = $days ; $times = MedicationLine::EndTime ; $times = 10 ) ] The "Exit Loop If" step should contain a function that returns true(1) or false(0). If you want to require all 3 of the above equivalencies you'd write it like this: Exit Loop If[ $enddate = $days AND $times = MedicationLine::EndTime AND $times = 10 ] You didn't specify what result you are seeing and how it differs from your expected result. That would be helpful.
Create an account or sign in to comment