Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
курсовий_КПЗ.doc
Скачиваний:
0
Добавлен:
01.07.2025
Размер:
1.3 Mб
Скачать

FunctionForDiagnoz.Php

<?

function is_diagnoz($connect){

$textQueryIsDiagnoz = "select count(`id`) as `is` from `diagnoz`";

if($queryIsDiagnoz = mysql_query($textQueryIsDiagnoz, $connect)){

$resultIsDiagnoz = mysql_fetch_array($queryIsDiagnoz);

if($resultIsDiagnoz['is'] == 0)

return false;

else

return true;

}

}

function diagnozList($connect){

$textQueryDiagnozList = "select * from `diagnoz`";

if($queryDiagnozList = mysql_query($textQueryDiagnozList, $connect)){

return $queryDiagnozList;

}

}

function selectAllInfoDiagnoz($page, $connect){

$start = 0;

$finish = 10;

if($page > 1){

$start = ($page-1)*$finish;

$finish = $page*$finish;

}

$textQueryViewDiagnoz = "SELECT * FROM `diagnoz` LIMIT ".$start." , ".$finish;

if($queryViewDiagnoz = mysql_query($textQueryViewDiagnoz)){

return $queryViewDiagnoz;

}

}

function selectIdInfoDiagnoz($id, $connect){

$textQueryViewDiagnoz = "SELECT * FROM `diagnoz` WHERE `id`=".$id;

if($queryViewDiagnoz = mysql_query($textQueryViewDiagnoz)){

return $queryViewDiagnoz;

}

}

function insertDiagnoz($connect, $titleDiagnoz){

$textQueryIsDiagnozTitle = "select count(*) as `is` from `diagnoz` where UPPER(`title`)=UPPER('".$titleDiagnoz."')";

if($queryIsDiagnozTitle = mysql_query($textQueryIsDiagnozTitle, $connect)){

$resultIsDiagnozTitle = mysql_fetch_array($queryIsDiagnozTitle);

if($resultIsDiagnozTitle['is'] == 0){

$textQueryInsertDiagnoz = "insert into `diagnoz` values(null, '".$titleDiagnoz."')";

if(mysql_query($textQueryInsertDiagnoz, $connect)){

alert("Дані успішно додані");

}

else

alert("Помилка бази даних");

}

else {

alert("В таблиці 'Діагнози' вже існує такий діагноз");

}

}

redirect($_SERVER['HTTP_REFERER']);

}

function updateDiagnoz($connect, $id, $title, $src){

$textQueryIsDiagnozTitle = "select count(*) as `is` from `diagnoz` where UPPER(`title`)=UPPER('".$title."')";

if($queryIsDiagnozTitle = mysql_query($textQueryIsDiagnozTitle, $connect)){

$resultQueryIsDiagnozTitle = mysql_fetch_array($queryIsDiagnozTitle);

if($resultQueryIsDiagnozTitle['is'] == 0){

$textQueryUpdateDiagnoz = 'update `diagnoz` set `title`="'.$title.'" where `id`='.$id;

if(mysql_query($textQueryUpdateDiagnoz, $connect))

alert('Дані успішно змінені');

}

else {

alert('Діагноз з такою назвою вже існує');

}

}

redirect($src);

}

function deleteDiagnoz($connect, $id){

$textQueryDeleteDiagnoz = "delete from `diagnoz` where `id` = ".$id;

if(!mysql_query($textQueryDeleteDiagnoz, $connect)){

alert("Помилка при видаленні з таблиці 'Діагнози'");

}

redirect($_SERVER['HTTP_REFERER']);

}

?>

FunctionForPatient.Php

<?

function is_patient($connect){

$textQueryIsPatient = "select count(`id`) as `is` from `patient`";

if($queryIsPatient = mysql_query($textQueryIsPatient, $connect)){

$resultIsPatient = mysql_fetch_array($queryIsPatient);

if($resultIsPatient['is'] == 0)

return false;

else

return true;

}

}

function patientList($connect){

$textQueryPatientList = "select *, concat( `lastname`, space(1), LEFT(`name` , 1 ) , '. ', LEFT(`father` , 1 ) , '.' ) as `pib` from `patient`";

if($queryPatientList = mysql_query($textQueryPatientList, $connect)){

return $queryPatientList;

}

}

function selectAllInfoPatient($page, $connect){

$start = 0;

$finish = 10;

if($page > 1){

$start = ($page-1)*$finish;

$finish = $page*$finish;

}

$textQueryViewPatient = "SELECT * FROM `patient` LIMIT ".$start." , ".$finish;

if($queryViewPatient = mysql_query($textQueryViewPatient)){

return $queryViewPatient;

}

}

function selectIdInfoPatient($id, $connect){

$textQueryViewPatient = "SELECT * , DAYOFMONTH(`birthday`) as `day`, MONTH(`birthday`) as `month`, YEAR(`birthday`) as `year` FROM `patient` WHERE `id`=".$id;

if($queryViewPatient = mysql_query($textQueryViewPatient)){

return $queryViewPatient;

}

}

function insertPatient($connect, $name, $lastname, $father, $birthday, $address){

$name = upperLowerStr($name);

$lastname = upperLowerStr($lastname);

$father = upperLowerStr($father);

$textQueryInsertPatient = "insert into `patient` values(null, '".$name."', '".$lastname."', '".$father."', '".$birthday."', '".$address."')";

if(mysql_query($textQueryInsertPatient, $connect)){

alert("Дані занесено успішно");

}

else

alert("Помилка при додаванні даних");

redirect($_SERVER['HTTP_REFERER']);

}

function updatePatient($connect, $src, $id, $name, $lastname, $father, $birthday, $address){

$name = upperLowerStr($name);

$lastname = upperLowerStr($lastname);

$father = upperLowerStr($father);

$textQueryUpdatePatient = "UPDATE `patient` SET `name`='".$name."', `lastname`='".$lastname."', `father`='".$father."', `birthday`='".$birthday."', `address`='".$address."' WHERE `id`=".$id;

if(!mysql_query($textQueryUpdatePatient, $connect)){

alert('Помилка при оновленні даних');

}

redirect($src);

}

function deletePatient($connect, $id){

$textQueryDeletePatient = "delete from `patient` where `id` = ".$id;

if(!mysql_query($textQueryDeletePatient, $connect)){

alert("Помилка при видаленні з таблиці 'Пацієнти'");

}

redirect($_SERVER['HTTP_REFERER']);

}

?>