rsammy Posted March 9, 2007 Share Posted March 9, 2007 these are the records in my admission table... fields: id, admit_loc, room#, pat_id, status, reason, admit_date , discharge_date, encounter 422, "MVH", 118, 359, "Do Not Follow", "", "2007-02-01", "2007-02-08", 7 423, "MVH", 111, 359, "Do Not Follow", "", "2007-02-09", "2007-02-12", 3 424, "", 0, 359, "Do Not Follow", "", "2007-02-16", "2007-02-16", 1 425, "MVH", 112, 359, "Do Not Follow", "", "2007-02-18", "2007-02-20", 2 426, "MVH", 115, 359, "Do Not Follow", "", "2007-02-22", "2007-02-22", 2 427, "MVH", 114, 359, "Follow", "", "2007-02-24", "0000-00-00", 4 each entry into this table is an encounter. if the patient is in follow state, then discharge_date is shown as "0000-00-00". this field is updated when patient status chagnes to "Do not follow". so if patient is discharged/released on 02/25, then status changes to "do not follow", discharge_date becomes "2007/02/25" and encounter is incremented and shows "5". now, suppose an entry is madeto this list today, for a visit on 02/05/2007 (that was somehow not entered earlier), with a status as "follow", it should (technically) fall in the first chain right at the top and encounter should get incremented to "8". suppose there is an encounter(visit) on 02/19/2007 with a "follow' status, then it should fall in the 4th chain in the table above and encounter shud show up as "3". with my current logic, the last record (id=427) gets updated(encounter gets incremented) regardless of what the admit date is! how can i stop this? THE ID field in teh table is set to auto_increment. my current logic is... $queryz=("SELECT * FROM admit_stat where admit_pat_id ='$pat_id'"); $resultz=mysql_query($queryz); if (! $resultz) { $error="Error 333b"; } $num_rowsz = mysql_num_rows($resultz); $admit_id=$num_rowsz["admit_id"]; if ($admit_status == 'Follow') { if($num_rowsz == 0) { //EXISTING PATIENT - NO ENTRY IN admit_stat TABLE //IF PATIENT IS RE-ADMITTED AFTER BEING DISCHARGED EARLIER - NO ENTRY IS AVAILABLE IN admit_stat FOR THIS PATIENT ID!!! $admissionquery=("Insert into admission(admit_phy_id, pat_id, admit_status, admit_loc, admit_date, admit_room_no, admit_id, admission_client_id, admit_encounter) VALUES ('$phy_id', '$pat_id', '$admit_status', '$location', '$visit_date_reformat', '$room_no', '$admit_id', '$client_id', '1')"); // echo "$admissionquery"; $resultadmissionquery=mysql_query($admissionquery); if (! $resultadmissionquery) { $error="Error 334b"; } } //elseif($num_rowsz == 1) else { $admitidquery=("SELECT admit_id from admit_stat where admit_pat_id='$pat_id' "); //echo "$admitidquery"; $resultadmitquery=mysql_query($admitidquery); $rowadmitid=mysql_fetch_array($resultadmitquery); $admit_id=$rowadmitid["admit_id"]; $updateadmitstatusquery=("Update admit_stat set admit_status='$admit_status', admit_visit_loc='$location', admit_room_no='$room_no' WHERE admit_pat_id='$pat_id' AND admit_id='$admit_id'"); $resultupdateadmitstatusquery=mysql_query($updateadmitstatusquery); if (! $resultupdateadmitstatusquery) { $error="Error 333d"; } $updateencounterquery=("Update admission set admit_encounter= admit_encounter + 1, admit_status='$admit_status' WHERE pat_id='$pat_id' AND admit_id='$admit_id'"); //echo "$updateencounterquery"; $resultupdateencounterquery=mysql_query($updateencounterquery); if (!$resultupdateencounterquery) { $error= "Error 334c"; } } } HOW DO I CHANGE THIS TO MAKE IT WORK THE WAY I WANT IT TO?! HELLLLLLLLLLLLLPPPPP PLEEEEEEEEEEEEEAAAAAAAAAAASE... Link to comment https://forums.phpfreaks.com/topic/42022-solved-help-with-dates-pleeeeeaaaaaase/ Share on other sites More sharing options...
rsammy Posted March 9, 2007 Author Share Posted March 9, 2007 anyone? Link to comment https://forums.phpfreaks.com/topic/42022-solved-help-with-dates-pleeeeeaaaaaase/#findComment-203938 Share on other sites More sharing options...
rsammy Posted March 13, 2007 Author Share Posted March 13, 2007 figured it out myself! solved! Link to comment https://forums.phpfreaks.com/topic/42022-solved-help-with-dates-pleeeeeaaaaaase/#findComment-206611 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.