I'm doing a system with Codeigniter , this is my first system with CI, and i'm also novice to PHP too.
I'm doing this for a hospital, in this i have the following problem
junior doctor first check the 1st visit patients and then if he can't handle them he refer them to the senior doctor
from registration room some patients are send to the eye checking room to check their eyes and then they go to the junior doctor
like wise i have temporary data to be kept on the system, references from one room to another and so on...
i need to get this details to the main GUI of the each person; for example in the Senior doctors UI there will be a tab named 1St time patients, in that the patients that was referred by the junior doctor will be shown to him! so i need to refer to the patients that was sent to senior doctor from the junior doctor and show them in the senior doctor's UI.
so my problem is how can i keep this temporary data to be referenced by the system? keeping them in the tables is not appropriate as i think because at the end of the day these data is not stored any where, only the patient table and few other tables will be keeping the data.
guys how can i achieve this kind of thing? any method of achieving this? technology that is easier to master that will allow me to keep temporary data?please give me some references or help by code to over come this problem.
regards,
Rangana
If the data is truly temporary, and has to be used by only one user at a time you need to stick it in session.
An entry level tuorial is here:
http://www.w3schools.com/PHP/php_sessions.asp
However if data is accessed by different users, but is simply not needed on following days, or you are storing a significant amount of data, you should probably keep it in the DB.
The DB should be able to store lots of data, so on a smallish app there is not much reason to keep clearing it out, but you could also include a housekeeping function that clears data that is old or irrelevant.
However when working with medical data, it may be a good idea to hang on to everything.
everything will do with ajax (or something that always refresh the browser for number of time like meta refresh tag) that will notify senior / junior doctor if any patient referred to them.
you need to add a flag at database if the doctor already retrieve the notification so it will not notify the doctor twice.
for example your database table :
Name of patient | referral | referrer | flag_retrieved
you need to specify referral doctor at the session so it can retrieve the correct record and then notify the doctor
then your system should :
request to database if any doctor to
refer patient to them over time (you can use ajax or meta tag)
database will check if any record match and not yet retrieved
send request to browser, than notify the doctor if any referred patient.
if you need to clean up the database, you can use cron every end of day for deleting any record at the table.
Related
I am writing a hotel booking software using PHP and MySQL. I am pretty much done with it but I ran into a race condition problem. For example there is only one standard room left and when 2 guests both select it it shows available to both of them. I tried fixing it by checking the room again when the guest clicks confirm before payment but that still has issues. I also tried making the room status to pending when whoever clicks the confirm first but I can't figure out how to change it back to available if the guest decides not to pay or just closes the browser. I searched SO for answers but I didn't really find a definitive answer. Thanks in advance
One solution is to add two columns to a table in the database. One column is the session ID or user ID or whatever of the user that is being offered the room. The second column is a timestamp indicating when that offer will expire.
Then, in your app, only show rooms that have an expired timestamp in the hold column. (Set the initial timestamp to 0 so that it starts out expired.) When a room is selected, check the column again. If there's an unexpired timestamp there, the user gets a "sorry, you were too slow" message. Otherwise, put a timestamp there for 15 minutes into the future or whatever, and proceed.
You see this on travel sites and ticket-purchasing sites a lot where it says something like "We're holding these seats for you for another 14 minutes. Please complete the transaction by then or it will be released blah blah blah."
I would also go with the pending state. You could save the state together with the session id of this user and have a cronjob that deletes all pending states that have expired session ids associated to them.
I'll try and cover most of the important details here...
I'm currently working on a booking system for a transport provider. I am using Laravel and originally started by having the Booking model attached to a User.
The client now however wants them to not have to login or register until the last step of the booking process. I have done carts etc in Session / Local Storage before but I thought before I start I would get some input from the friendly folks over at StackOverflow!
The most ideal way for me at this point would be to make the user_id on the Booking model nullable, but then when the visitor returns to the site how will I then know which booking is theirs?
I hope this makes sense & I hope someone out there has dealt with a similar problem to this one and can shed some light on the best strategy going forward!
I created something similar to what you say in a company that has been working for some time, I indicate how I proposed it, to see if it can help you achieve what you want to achieve in the most optimal way.
As you indicated, I created the reservations with the nullable user_id, as it usually happens in almost all reserve applications, they are not eternal, so I added a field (max_datetime) of maximum time that reservation would last and a field (token) with code only for the reservation, in addition to a field (ip) for the ip of the session. (In the application that I made, the reservation was maintained 12 hours maximum or until 11:59 pm on the same day, which may be less than 12 hours).
Then create a Task Scheduling for a custom Artisan Console. What it did was eliminate the reserves that fulfilled the condition to be eliminated.
When the reservation was completed it was associated with the user_id and the other fields with null (max_datetime, token, ip). Ah! Yes and a field (confirmed) to confirm with "true" that the reservation has been completed, by default to "false".
I used session to check the "ip" and the "token", and if not, I asked that if they had the token, to indicate it.
The system allowed you to obtain the "token" in case you did not want to continue at that moment, warning you of the time the reservation was kept.
I do not have access to the code since it was from a company and I only kept the idea. I hope it helps you. A cordial greeting.
I'm developing a web page where students, after registering, can introduce their school schedule, mark test and calculate averages. My problem is:
how do I do for each user to have their own schedule, calendar etc. I could be simple for you but I'm having difficulties solving this.
This is how I want schedules menu to look
all the data introduced for the schedule will show up on the table
You have to look at how a relational database works.
Everything you're trying to do is use a foreign key.
IMHO best way to achieve this is to register user ID+name in $_SESSION then, when he reaches the page, retrieve schedule from where it's stored. Depends also on the schedule/calendar format
So I'm planning to create a code that will save in my database. (I have no problem in saving to my database thou.)
But I'm having a bit problem. The problem is to avoid having the same seat information displayed for the specific customer.
Something like this? (Sorry for the sample data that I will be doing.) The case is both are doing their inputs for their reservation at the same time.
[X] = taken data, [0] = blank data, [R] = customer data
1st viewing customer (having 2 data to be stored)
[X][X][X][R][R]
[0][0][0][0][0]
[0][0][0][0][0]
2nd viewing customer (having 1 data to be stored, and must be showed for this customer)
[X][X][X][X][X]
[R][0][0][0][0]
[0][0][0][0][0]
What the 2nd viewing customer actually sees. Which the customer mustn't encounter. And so on if there are other more customers are doing their inputs.
[X][X][X][R][0]
[0][0][0][0][0]
[0][0][0][0][0]
My first tactical plan is to create two database tables, one database table will serve as a dummy and the other will serve as the main database table. The logic is the dummy table will always update if there are customers making their inputs (which will have a problem by the time the customer closes the browser or didn't finish the transaction, the data stored at the dummy will still remain even after other customer accessed it again - which must not happen). And the main table will only update when the customer completed the whole transaction.
I know from the way I typed it is a bit confusing. But I really need some help in creating a logic to avoid this conflict the customer will see in my program. Or some tips if this kind of plan will not work. Like giving a note that (same sample above with 1st and 2nd customer) "This data is just a sample and sometimes will not be followed or the same with the e-mail sent to your registered e-mail addressed from this website."
Thank you in advance for your responses.
Well I don't think it's a good idea to save all clicks in final seat info table. Instead of that you can make something like temporary_seats base which will keep temporary information about reserved seats. In this table you would include information about seats that customers wishes to reserve.
Then you need to create javascript code querying API and getting all reserved (from destination table) and temporary reserved (from tmp table) and mark those seats free/occupied. You can do it constantly or check seat availability only when t
I am making a doctor appointment slot booking mechanism,where in doctor appointment slots will be divided into 30 mins slot each...i have achieved all the working code.. 1 problem i am facing is that..this booking is made at 2 places i.e 2 receptions..so when 1 selects a slot(radio button) not yet confirmed and saved in DB.other reception must not be able to select .how do i do it.any help on this...how do i go abt it.
This is a case of accessing "shared data". You'll need thread to make sure that only one thread has access to the data at a time to ensure it's integrity. The following might provide some ideas
http://www.alternateinterior.com/2007/05/communicating-with-threads-in-php.html
I would use some AJAX/AJAJ functions to periodically refresh data about free slots, or I would do that much more simple - when saving the appointment, just check it, if the slot will be taken, your app redirects user back to form to choose another slot.
In essence,
I will just ask for the slot timings upfront and the remaining details later.
In case the slot is available, it sends a request to the server to lock it, so that the other client cannot use it.
In case, it is not available, it will receive a small notification that this slot is unavailable, click to see available slots.
I would go with AJAX (if this is a web app). This is a distributed systems problem which resembles Blue Army - White Army problem.
Add a "Locked By" field to the table.
When booking a slot, do something like:
UPDATE tablename
SET LockedBy = userid, ...
WHERE LockedBy IS NULL
After the update, you can select to see if LockedBy is set to your userid.
If not, then someone else must have beaten you to the punch, and you need to tell the user to pick a different slot.