Jump to content

Recommended Posts

i have this table, admission with the following fields - id, admit_date, admit_location, admit_status, room_no, pat_id, encounter, discharge_date

 

i have admisssion info of the patient with a particular pat_id. the records are as follows:

 

234, 2007/02/01, abc medical  center, follow, 115, 298, 1, 0000-00-00

 

now this patient was admitted on feb 01. each visit by the doctor is an encounter and the encoutner field is incremented for each visit till the patient is discharged(status is do not follow).

 

this way, the doctor visited the patient on feb 02(two times), feb 03, feb 04, feb 06 and feb 08 when he was released  - that is a total of 7 encounters and the chain is closed there. any future visits by the doctor is a new encounter for a new record in the table.

 

now, suddenly, the doctor realizes that he visited the patient on feb 07. so he enters this in the system. how do i just edit the table by just incrementing the encounter field - it shud be 8 as against 7 for the same record/patient.

 

so i am trying to first sort the records for this patient and then see where the new record(feb 07) fits to be able to increment the encounter field.

the query i use to select from the table is...

								$selectadmissionquery=("SELECT pat_id, admit_status, admit_loc, Date_Format(admit_date, '%m/%d/%Y') as admit_date, Date_Format(discharge_date, '%m/%d/%Y') as discharge_date, admit_encounter 
													FROM admission WHERE (pat_id = '$pat_id') ORDER BY admit_date ASC");
							$resultselectadmissionquery=mysql_query($selectadmissionquery);
							if (! $resultselectadmissionquery)
							{
								$error= "Error 333b";
							}
							$num_rowsselectadmissionquery = mysql_num_rows($resultselectadmissionquery);

 

this is the query i am using to insert into the table...

 

						$admissionquery=("Insert into admission( pat_id, admit_status, admit_loc, admit_date, admit_room_no, admit_encounter) VALUES ('$phy_id', '$pat_id', '$admit_status', '$location', '$visit_date_reformat', '$room_no', '$admit_id', '$client_id', '1')");
						$resultadmissionquery=mysql_query($admissionquery);
						if (! $resultadmissionquery)
						{
							$error="Error 334";
						}

Link to comment
https://forums.phpfreaks.com/topic/41863-solved-edit-a-back-dated-record/
Share on other sites

For this you will have to update all the records after the date that you want to insert in the table in between existing records. Fetch all the history of the patient put it in an array with may be id as the key and encounter as the value. Perform your operation in the array by adding an item properly and then update the database with all these records.

 

FYI: from this it seems like you have not properly normalized your tables and have not properly designed your database.

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.