-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcntrl_Visit.php
160 lines (150 loc) · 5.43 KB
/
cntrl_Visit.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<?php require_once('Connections/HMS.php');
include('mdl_Visit.php');
include('mdl_Examination.php');
include('mdl_Prescription.php');
include('mdl_InvestigationTrx.php');
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6)
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType)
{
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$visit = new Visit();
if($_POST['formAction'] == "insert")
{
$visit->setDetails(GetSQLValueString($_POST['patientId'], "text"),
GetSQLValueString($_POST['registrationId'], "text"),
GetSQLValueString($_POST['consultingDoctorId'], "text"),
GetSQLValueString($_POST['visitNo'], "text"),
GetSQLValueString($_POST['visitDate'], "text"),
GetSQLValueString($_POST['referringDoctorId'], "text"));
$visitId = $visit->insertvisit();
if($visitId == NULL)
die(mysql_error());
else
{
$examination = new Examination();
$examination->setDetails(GetSQLValueString($visitId, "text"),
GetSQLValueString($_POST['examination'], "text"),
GetSQLValueString($_POST['habit'], "text"),
GetSQLValueString($_POST['pulse'], "text"),
GetSQLValueString($_POST['bpDia'], "text"),
GetSQLValueString($_POST['bpSys'], "text"),
GetSQLValueString($_POST['RR'], "text"),
GetSQLValueString($_POST['height'], "text"),
GetSQLValueString($_POST['weight'], "text"),
GetSQLValueString($_POST['finalDiagnosis'], "text"),
GetSQLValueString($_POST['patientComplain'], "text"),
GetSQLValueString($_POST['comments'], "text"));
if(!$examination->insertexamination())
die(mysql_error());
$prescription = new Prescription();
$count = $_POST['medicineCount'];
for($i=1;$i<=$count;$i++)
{
$medicineName = "medicine-".$i;
$dosage = "dosage-".$i;
$duration = "duration-".$i;
$instruction = "instruction-".$i;
/*if(!empty($_POST[$dosage]) or !empty($_POST[$instruction])or !empty($_POST[$duration]) )
{
if(empty($_POST[$medicineName]))
{
echo'not complete';
}
}
else
{*/
if(GetSQLValueString($_POST[$medicineName], "text") != "NULL")
{
$prescription->setDetails(GetSQLValueString($visitId, "text"),
GetSQLValueString($_POST[$medicineName], "text"),
GetSQLValueString($_POST[$dosage], "text"),
GetSQLValueString($_POST[$instruction], "text"),
GetSQLValueString($_POST[$duration], "text"),
GetSQLValueString($i,"text"));
if(!$prescription->insertprescription())
die(mysql_error());
}
}
$investigationTrx = new InvestigationTrx();
$count = $_POST['investigationCount'];
for($i=1;$i<=$count;$i++)
{
$investigationName = "investigationName-".$i;
$investigationId = "investigationId-".$i;
$classId = "classId-".$i;
$reportDate = "reportDate-".$i;
$institution = "institution-".$i;
$value = "value-".$i;
$results = "results-".$i;
if(GetSQLValueString($_POST[$investigationName], "text") != "NULL")
{
$investigationTrx->setDetails(GetSQLValueString($visitId, "text"),
GetSQLValueString($_POST['patientId'], "text"),
GetSQLValueString($_POST[$investigationId], "text"),
GetSQLValueString($_POST[$classId], "text"),
GetSQLValueString($_POST[$reportDate], "text"),
GetSQLValueString($_POST[$institution], "text"),
GetSQLValueString($_POST[$results], "text"),
GetSQLValueString($_POST[$value], "text"),
NULL,NULL);
if(!$investigationTrx->insertinvestigationtrx())
die(mysql_error());
}
}
header('Location: ViewVisits.php');
}
}
elseif($_POST['formAction'] == "update")
{
session_start();
$data = $visit->getDetails($_POST['visitId']);
$_SESSION['data'] = $data;
//echo "Hello update";
//var_dump($_SESSION['data']);
header('Location: AddVisit.php?Mode=update');
}
elseif($_POST['formAction'] == "commit")
{
$visit->setDetails(GetSQLValueString($_POST['patientId'], "text"),
GetSQLValueString($_POST['registrationId'], "text"),
GetSQLValueString($_POST['consultingDoctorId'], "text"),
GetSQLValueString($_POST['visitNo'], "text"),
GetSQLValueString($_POST['visitDate'], "text"),
GetSQLValueString($_POST['referringDoctorId'], "text"));
if(!$visit->updatevisit($_POST['visitId']))
die(mysql_error());
else
header('Location: ViewVisits.php');
}
elseif($_POST['formAction'] == "delete")
{
if(!$visit->deletevisit($_POST['visitId']))
die(mysql_error());
else
header('Location: ViewVisits.php');
}
?>