Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
caleboau2012 committed Jul 13, 2017
2 parents 8acdeb7 + 33a12ae commit cd618d8
Show file tree
Hide file tree
Showing 11 changed files with 384 additions and 260 deletions.
42 changes: 27 additions & 15 deletions _core/controller/PatientController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public function addPatient (
$surname, $firstname, $middlename, $regNo,
$home_address, $telephone, $sex, $height, $weight,
$birth_date, $nok_firstname, $nok_middlename,
$nok_surname, $nok_address, $nok_telephone, $nok_relationship,$citizenship, $religion, $family_position,
$mother_status, $father_status, $marital_status, $no_of_children, $occupation )
$nok_surname, $nok_address, $nok_telephone, $nok_relationship,$citizenship, $religion,
$marital_status, $occupation, $hmo, $registrationDate, $allergies, $surgical_history, $family_history, $tobacco_usage, $medical_history, $alcohol_usage)
{


Expand All @@ -58,13 +58,16 @@ public function addPatient (
PatientTable::nok_relationship => $nok_relationship,
PatientTable::citizenship => $citizenship,
PatientTable::religion => $religion,
PatientTable::family_position => $family_position,
PatientTable::mother_status => $mother_status,
PatientTable::father_status=> $father_status,
PatientTable::marital_status => $marital_status,
PatientTable::no_of_children =>$no_of_children,
PatientTable::occupation => $occupation

PatientTable::occupation => $occupation,
PatientTable::hmo => $hmo,
PatientTable::registration_date => $registrationDate,
PatientTable::allergies => $allergies,
PatientTable::surgical_history => $surgical_history,
PatientTable::family_history => $family_history,
PatientTable::tobacco_usage => $tobacco_usage,
PatientTable::medical_history => $medical_history,
PatientTable::alcohol_usage => $alcohol_usage,

);

Expand Down Expand Up @@ -103,11 +106,13 @@ public function EditPatientInfo (
$surname, $firstname, $middlename, $regNo,
$home_address, $telephone, $sex, $height, $weight,
$birth_date, $nok_firstname, $nok_middlename,
$nok_surname, $nok_address, $nok_telephone, $nok_relationship,$citizenship, $religion, $family_position,
$mother_status, $father_status, $marital_status, $no_of_children, $occupation, $patient_id ){
$nok_surname, $nok_address, $nok_telephone, $nok_relationship,$citizenship, $religion,
$marital_status, $occupation, $patient_id, $hmo, $registrationDate, $allergies, $surgical_history, $family_history, $tobacco_usage,
$medical_history, $alcohol_usage){

$data = array(

PatientTable::patient_id => $patient_id,
PatientTable::surname => $surname,
PatientTable::firstname => $firstname,
PatientTable::middlename => $middlename,
Expand All @@ -126,13 +131,16 @@ public function EditPatientInfo (
PatientTable::nok_relationship => $nok_relationship,
PatientTable::citizenship => $citizenship,
PatientTable::religion => $religion,
PatientTable::family_position => $family_position,
PatientTable::mother_status => $mother_status,
PatientTable::father_status=> $father_status,
PatientTable::marital_status => $marital_status,
PatientTable::no_of_children =>$no_of_children,
PatientTable::occupation => $occupation,
PatientTable::patient_id =>$patient_id
PatientTable::hmo => $hmo,
PatientTable::registration_date => $registrationDate,
PatientTable::allergies => $allergies,
PatientTable::surgical_history => $surgical_history,
PatientTable::family_history => $family_history,
PatientTable::tobacco_usage => $tobacco_usage,
PatientTable::medical_history => $medical_history,
PatientTable::alcohol_usage => $alcohol_usage,

);

Expand Down Expand Up @@ -172,4 +180,8 @@ public function getExistingPatientRegNos(){
public function regNoExists($regNo){
return $this->patient->isRegNumExisting($regNo);
}

public function getAllHMO(){
return $this->patient->getAvailableHMO();
}
}
8 changes: 8 additions & 0 deletions _core/global/DataTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ class PatientTable{
const modified_date = 'modified_date';
const active_fg = 'active_fg';
const occupation = 'occupation';
const registration_date = 'registration_date';
const hmo = 'hmo';
const allergies = 'allergies';
const medical_history = 'medical_history';
const alcohol_usage = 'alcohol_usage';
const tobacco_usage = 'tobacco_usage';
const family_history = 'family_history';
const surgical_history = 'surgical_history';
}

class PatientQueueTable {
Expand Down
27 changes: 14 additions & 13 deletions _core/global/SqlStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,11 @@ class PermissionRoleSqlStatement {

class PatientSqlStatement {
const ADD = 'INSERT INTO patient (surname, firstname, middlename, regNo, home_address, telephone, sex, height, weight, birth_date, nok_firstname, nok_middlename, nok_surname, nok_address, nok_telephone, nok_relationship,
citizenship, religion, family_position, mother_status, father_status, marital_status, no_of_children, occupation, created_date, modified_date )
citizenship, religion, marital_status, occupation, hmo, registration_date, allergies, surgical_history, family_history, tobacco_usage, medical_history, alcohol_usage,
created_date, modified_date )
VALUES (LOWER(:surname), LOWER(:firstname), LOWER(:middlename), :regNo, :home_address, :telephone, :sex, :height, :weight, :birth_date, :nok_firstname, :nok_middlename, :nok_surname, :nok_address, :nok_telephone, :nok_relationship,
:citizenship, :religion, :family_position, :mother_status, :father_status, :marital_status, :no_of_children, :occupation, NOW(), NOW() )';
:citizenship, :religion, :marital_status, :occupation, :hmo, :registration_date, :allergies, :medical_history, :alcohol_usage, :tobacco_usage,
:family_history, :surgical_history, NOW(), NOW() )';

const GET = 'SELECT * FROM patient WHERE patient_id = :patient_id';
const UPDATE_INFO = 'UPDATE patient SET surname = LOWER(:surname), firstname = LOWER(:firstname), middlename = LOWER(:middlename), regNo = :regNo, home_address = :home_address, telephone = :telephone, sex = :sex, height = :height, weight = :weight, birth_date = :birth_date, nok_firstname = :nok_firstname, nok_middlename = :nok_middlename, nok_surname = :nok_surname, nok_address = :nok_address, nok_telephone = :nok_telephone, nok_relationship = :nok_relationship, modified_date = NOW()';
Expand All @@ -121,13 +123,11 @@ class PatientSqlStatement {
regNo =:regNo, home_address =:home_address, telephone =:telephone, sex =:sex, height =:height, weight =:weight,
birth_date =:birth_date, nok_firstname =:nok_firstname, nok_middlename =:nok_middlename, nok_surname =:nok_surname,
nok_address =:nok_address, nok_telephone =:nok_telephone, nok_relationship =:nok_relationship, citizenship =:citizenship,
religion =:religion, family_position =:family_position, mother_status =:mother_status,
father_status =:father_status,
religion =:religion,
marital_status =:marital_status,
no_of_children =:no_of_children,
occupation =:occupation,
modified_date =NOW() WHERE patient_id =:patient_id
";
occupation =:occupation, hmo = :hmo, registration_date = :registration_date, allergies = :allergies, medical_history = :medical_history, alcohol_usage = :alcohol_usage,
tobacco_usage = :tobacco_usage, family_history = :family_history, surgical_history =:surgical_history,
modified_date =NOW() WHERE patient_id =:patient_id";

const GET_ALL = 'SELECT patient_id, surname, firstname, middlename, regNo, home_address, telephone, sex, height, weight, birth_date, nok_firstname, nok_middlename, nok_surname, nok_address, nok_telephone, nok_relationship, created_date, modified_date
FROM patient';
Expand Down Expand Up @@ -165,6 +165,8 @@ class PatientSqlStatement {

const GET_BY_TMT_ID = "SELECT surname, middlename, firstname, regNo, sex FROM patient WHERE patient_id IN (SELECT patient_id FROM treatment WHERE treatment_id = :treatment_id)";

const GET_AVAILABLE_HMO = "SELECT id, name, address FROM hmo";

}

class PatientQueueSqlStatement {
Expand Down Expand Up @@ -1003,16 +1005,15 @@ class TreatmentSqlStatement {

const END_TREATMENT = "UPDATE treatment SET treatment_status = 2 WHERE treatment_id = :treatment_id ";

const UNBILLED_TREATMENT = "SELECT p.surname, p.firstname, p.middlename, p.regNo, p.telephone, p.home_address, t.treatment_status, t.bill_status, t.treatment_id, t.modified_date
FROM treatment t
LEFT JOIN patient p
ON t.patient_id = p.patient_id
const UNBILLED_TREATMENT = "SELECT p.patient_id, p.surname, p.firstname, p.middlename, p.regNo, p.telephone, p.home_address, t.treatment_status, t.bill_status, t.treatment_id, hmo.name as hmo_name, hmo.id as hmo_id, t.modified_date
FROM treatment t LEFT JOIN patient p ON t.patient_id = p.patient_id LEFT JOIN hmo ON hmo.id = p.hmo
WHERE t.bill_status = 1";

const UNBILLED_ENCOUNTERS = "SELECT p.surname, p.firstname, p.middlename, p.regNo, p.telephone, p.home_address, e.status, e.bill_status, e.encounter_id, e.treatment_id, e.modified_date
const UNBILLED_ENCOUNTERS = "SELECT p.patient_id, p.surname, p.firstname, p.middlename, p.regNo, p.telephone, p.home_address, e.status, e.bill_status, e.encounter_id, e.treatment_id, hmo.name as hmo_name, hmo.id as hmo_id, e.modified_date
FROM encounter e
LEFT JOIN patient p
ON e.patient_id = p.patient_id
LEFT JOIN hmo ON hmo.id = p.hmo
WHERE e.bill_status = 1";

const DAYS_SPENT = "SELECT DATEDIFF(exit_date, entry_date) AS days_spent
Expand Down
4 changes: 4 additions & 0 deletions _core/model/PatientModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,8 @@ public function getPatientByTreatmentId($treatmentId){
$data = array(TreatmentTable::treatment_id => $treatmentId);
return $this->conn->fetch(PatientSqlStatement::GET_BY_TMT_ID, $data);
}

public function getAvailableHMO(){
return $this->conn->fetchAll(PatientSqlStatement::GET_AVAILABLE_HMO, array());
}
}
26 changes: 18 additions & 8 deletions _resource/pms_setup.sql
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ CREATE TABLE IF NOT EXISTS `parasitology_req` (

DROP TABLE IF EXISTS `patient`;
CREATE TABLE IF NOT EXISTS `patient` (
`patient_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`patient_id` int(11) UNSIGNED NOT NULL,
`surname` varchar(25) DEFAULT NULL,
`firstname` varchar(25) DEFAULT NULL,
`middlename` varchar(25) DEFAULT NULL,
Expand All @@ -697,17 +697,19 @@ CREATE TABLE IF NOT EXISTS `patient` (
`nok_relationship` int(10) UNSIGNED DEFAULT '9',
`citizenship` varchar(25) DEFAULT NULL,
`religion` varchar(25) DEFAULT NULL,
`family_position` int(11) DEFAULT NULL,
`mother_status` varchar(25) DEFAULT NULL,
`father_status` varchar(25) DEFAULT NULL,
`marital_status` varchar(25) DEFAULT NULL,
`no_of_children` int(11) DEFAULT NULL,
`occupation` varchar(100) DEFAULT NULL,
`registration_date` date DEFAULT NULL,
`hmo` int(11) DEFAULT NULL,
`allergies` text,
`medical_history` text,
`alcohol_usage` varchar(255) DEFAULT NULL,
`tobacco_usage` varchar(255) DEFAULT NULL,
`surgical_history` text,
`family_history` text,
`created_date` datetime DEFAULT NULL,
`modified_date` datetime DEFAULT NULL,
`active_fg` tinyint(1) DEFAULT '1',
PRIMARY KEY (`patient_id`),
KEY `fk_PatientNok` (`nok_relationship`)
`active_fg` tinyint(1) DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------
Expand Down Expand Up @@ -1631,3 +1633,11 @@ ALTER TABLE `xray_no`
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

CREATE TABLE `hmo` (
`id` int(11) NOT NULL,
`name` text NOT NULL,
`address` text,
`created_on` datetime NOT NULL,
`modified_on` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
2 changes: 1 addition & 1 deletion css/master.css
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ System setup
border-color: #eeeeee;
padding: 1em;
}
a#add-unit:hover, a#add-unit:focus, a#add-unit:active, {
a#add-unit:hover, a#add-unit:focus, a#add-unit:active {
text-decoration: none;
}
ol#units-list{
Expand Down
68 changes: 45 additions & 23 deletions js/admin/patients.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ function printDetails(e){
function prepareData(patientID){
$.get(host + "phase/arrival/phase_patient.php?intent=getPatient&patientId=" + patientID, function(data){
data = JSON.parse(data);
console.log(data.data);
name = data.data.surname + " " +
data.data.firstname + " " +
data.data.middlename;
Expand Down Expand Up @@ -110,11 +109,13 @@ function prepareData(patientID){
.replace('{{nok_relationship}}', relationship[data.data.nok_relationship])
.replace('{{citizenship}}', data.data.citizenship)
.replace('{{religion}}', data.data.religion)
.replace('{{family_position}}', data.data.family_position)
.replace('{{mother_status}}', data.data.mother_status)
.replace('{{father_status}}', data.data.father_status)
.replace('{{marital_status}}', data.data.marital_status)
.replace('{{no_of_children}}', data.data.no_of_children);
.replace('{{allergies}}', data.data.allergies)
.replace('{{registration_date}}', data.data.registration_date)
.replace('{{medical_history}}', data.data.medical_history)
.replace('{{alcohol_usage}}', data.data.alcohol_usage)
.replace('{{tobacco_usage}}', data.data.tobacco_usage)
.replace('{{family_history}}', data.data.family_history)
.replace('{{surgical_history}}', data.data.surgical_history);

printElem("Patients Details", printHTML, null);
});
Expand Down Expand Up @@ -155,15 +156,20 @@ function addPatient(form){
nok_relationship : form.nok_relationship.value,
citizenship : citizenship,
religion : form.religion.value,
family_position : form.family_position.value,
mother_status : form.mother_status.value,
father_status : form.father_status.value,
marital_status : form.marital_status.value,
no_of_children : form.no_of_children.value
registration_date : form.registration_date.value,
hmo : form.hmo.value,
allergies : form.allergies.value,
medical_history : form.medical_history.value,
alcohol_usage : form.alcohol_usage.value,
tobacco_usage : form.tobacco_usage.value,
surgical_history : form.surgical_history.value,
family_history : form.family_history.value

},
function(data){
data = JSON.parse(data);
console.log(data);
data = JSON.parse(data);
if(data.data){
$('#newPatientModal').modal('hide');
init();
Expand All @@ -181,7 +187,6 @@ function addPatient(form){
function manage(id){
var form = document.managePatientForm;
$.getJSON(host + "phase/arrival/phase_patient.php?intent=getPatient&patientId=" + $(id).attr('patientid'), function(data){
console.log(data);
if(data.status == 1){
data = data.data;
form.patient_id.value = data.patient_id;
Expand All @@ -204,16 +209,23 @@ function manage(id){
form.nok_relationship.value = data.nok_relationship;
form.citizenship.value = data.citizenship;
form.religion.value = data.religion;
form.family_position.value = data.family_position;
form.mother_status.value = data.mother_status;
form.father_status.value = data.father_status;
form.hmo.value = data.hmo;
form.registration_date.value = data.registration_date;
form.allergies.value = data.allergies;
form.medical_history.value = data.medical_history;
form.alcohol_usage.value = data.alcohol_usage;
form.tobacco_usage.value = data.tobacco_usage;
form.surgical_history.value = data.surgical_history;
form.family_history.value = data.family_history;
form.marital_status.value = data.marital_status;

$('#managePatientModal').modal({
backdrop: 'static'
}).modal('show').on('hidden.bs.modal', function (e) {
form.reset();
});
}else{
showAlert("Unable to update patient's profile. Try again later");
}
});

Expand Down Expand Up @@ -241,18 +253,28 @@ function manage(id){
nok_relationship : form.nok_relationship.value,
citizenship : form.citizenship.value,
religion : form.religion.value,
family_position : form.family_position.value,
mother_status : form.mother_status.value,
father_status : form.father_status.value,
marital_status : form.marital_status.value,
no_of_children : form.no_of_children.value
registration_date : form.registration_date.value,
hmo : form.hmo.value,
allergies : form.allergies.value,
medical_history : form.medical_history.value,
alcohol_usage : form.alcohol_usage.value,
tobacco_usage : form.tobacco_usage.value,
surgical_history : form.surgical_history.value,
family_history : form.family_history.value
},
function(data){
console.log(data);
showSuccess(data.message);
$('#managePatientModal').modal('hide');
init();
}, 'json').fail(function(){
if(data.status == 2){
showAlert(data.message);
}else{
$('#managePatientModal').modal('hide');
init();
ResponseModal.show('Patient updated successfully', true, false);
}

}, 'json').fail(function(data){
showAlert(data.message);
console.log('shing');
});
});
Expand Down
Loading

0 comments on commit cd618d8

Please sign in to comment.