Pls feel free to ignore this. This is a very wooly question and on StackOverflow I would be flamed to death!
This is a BIG ask as I am being very vague which I know is annoying.
I am building a system for therapists to be able to send therapeutic texts to patients. I have a basic version up and running using php flie_put and file_get with a gazillion text files. Works fine but obviously not scalable.
Now I want to make a system for 10 therapists all using the same database (final version will have one db per therapist for security).
I am getting myself a bit brain scrambled on the data dictionary and handling randomized dates.
On the data dictionary could someone just force me to come to a firmer naming structure. I seem to be all over the place and once I feel I nail down one part another veers around. (I have put it at the end and NB nearly all varchar are (25) at the moment. They will be scaled appropriately later on.)
SECONDLY RANDOMIZED MESSAGING
It is annoying to get the same email from you therapist at the same time every day.
The desire of the therapists is getting a bit complicated. I came up with three linked schedules that would for example offer a message Weds, Fri and Sat at 11 am and Mon, Tues at 2pm and Sunday every two hours between 9 am and 9pm.
Even doing that gets very messy very fast. There is also a big desire for some sorts of randomization. I got so confused I mapped it out as a dummy form on Excel (pls see below).
Question 1 Does anything like this exist in jQuery or anywhere?
What I am coming up with is HORRIBLE and I hope someone out there has faced a similar task and come up with a good solution.
So this would be one of three linked forms.
Simple input would just be the top part. The three forms would all run at the same time. Say form one running for Mon and Weds days in the morning, form two for Wed and Fri afternoon then form three running for other days fixed days and times. Using start and stop dates the effects can be appear quite “randomized” (I am tempted to increase the number of schedule options.)
The more complicated part adds multiple messages a day and multiple times. The three forms could cascade with form one running for 3 days the form two for 4 days then form three running for x days and back to form 1 etc. If they cascade
there can be an initial start date but then the options have to run for xx days or it gets too complicated.
FINALLY - STORING THE SCHEDULE vs MAKING THE SCHEDULE
The scheduling is becoming horribly complex.In the first version I ran a CRON job every five mins to see if a message needed sending.
I am tempted to make a message stack that gets built every few hours and updated whenever a schedule is changed.
It will be a long time before this system has 100 therapists using the system and each therapist is unlikely to have more than about 10-15 patients wanting to receive texts so I am guessing a maximum of about 10,000 messages a day is unlikely to be hit for ages. I do want to build it as sensibly as poss in the first place but keep going back and forward between checking every five minute to see if any patient needs a message sending (ie checking all of the message instances - (the linked message/client/schedule nexus) for every patient) OR whether I should build an output stack and just run through that.
Thanks for any thoughts.
Finally here is the “data dictionary” in rough form.
Naming rules: FK "id"s become tableid eg clientid.
Table Description Type Keys etc
Field
THERAPIST
id smallint
therapist_name varchar(25) Unique
first varchar(25)
last varchar(25)
initials varchar(25)
phone_number varchar(25)
phone_type varchar(25)
country_code tinyint
? time_zone CURRENT TZ varchar(25) default pac/hon
x email varchar(25)
status Paid for etc varchar(25)
status2 Spare
CLIENT
id smallint
client_name varchar(25) Unique
therapistid smallint key with above
first varchar(25)
last varchar(25)
initials varchar(25)
phone_number varchar(25)
phone_type varchar(25)
country_code tinyint
? time_zone varchar(25) default pac/hon
x email varchar(25)
travelling varchar(25)
crisis_status varchar(25)
MESSAGE
id smallint
x text varchar(25)
image binary
MESSAGE_GROUP (group names unique for each therapist)
id smallint
x group_name varchar(25) Unique
therapistid smallint key with above
MESSAGE_INSTANCE
id??? smallint
clientid smallint FK
messageid smallint FK
groupid smallint FK/NULL
SCHEDULE_INSTANCE_1 PREPARED_SCHEDULE
id smallint
msginstid smallint messinstid
x days smtwhfa format* varchar(25) schedinstid????
start_date date *Thurs=h ans Sat=a
stop_date date
expired boolean
start_time time
stop_time time
period Minutes between texts smallint
numoftimes smallint
reminder date
linktoschedule tinyint
* days of week by one letter can be multiple days
SCHEDULE_INSTANCE_2
id
msginstid
x days
start_date
stop_date
expired
start_time
stop_time
period Minutes between texts
reminder
linktoschedule
SCHEDULE_INSTANCE_3
id
msginstid
x days
start_date
stop_date
expired
start_time
stop_time
period Minutes between texts
reminder
linktoschedule
SEND_LIST (one for EVERY msg due to go out in next xx )
id
messinstid
day
time
SENT_MESSAGES
id
text
number
time
day
timestamp
return_code