-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathup_centros.php
147 lines (136 loc) · 3.91 KB
/
up_centros.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
<?php
set_time_limit(1000);
ini_set('memory_limit','128M');
?>
<!DOCTYPE html>
<html>
<body>
<div class="line"></div>
<div class="wrapper">
<div class="widget">
<form action="up_centros.php" method="POST" enctype="multipart/form-data">
<fieldset>
<table cellpadding="0" cellspacing="0" width="100%" class="sTable">
<tr>
<td>Seleccione archivo:</td>
<td><input type="file" name="archivoCSV" /></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td colspan="2" align="right">
<input type="submit" value="Aceptar" name="cargarCSV" />
</td>
</tr>
</table>
</fieldset>
</form>
</div>
</div>
<p> </p>
<table border="1" cellspacing="0" cellpadding="3" width="100%">
<tr>
</tr>
<?php
if(isset($_POST)||isset($_FILES)){
$username="root";
$password="r1r7C1h6ZG4ZVWF";
$database="cohorte";
$i=1;
mysql_connect(localhost,$username,$password);
mysql_select_db($database) or die( "Unable to select database");
if ($_FILES["archivoCSV"]["error"] == 0 && $_FILES["archivoCSV"]["size"] > 0) {
if (($handle = fopen($_FILES["archivoCSV"]["tmp_name"], "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
for ($c=0; $c < $num; $c++) {
$tmp = explode(";", $data[$c]);
$codigo = trim(strtoupper($tmp[0]));
$numero = trim(strtoupper($tmp[1]));
$fecha = trim(strtoupper($tmp[2]));
if($fecha==''){
$fecha="NULL";
}else{
$fecha="'$fecha'";
}
$sexo = trim(strtoupper($tmp[2]));
$d2 = trim(strtoupper($tmp[4]));
$d3 = trim(strtoupper($tmp[5]));
$d4 = trim(strtoupper($tmp[6]));
$d5 = trim(strtoupper($tmp[7]));
$d6 = trim(strtoupper($tmp[8]));
$nocontinua = trim(strtoupper($tmp[9]));
$geno=trim(strtoupper($tmp[13]));
$geno_fecha=trim(strtoupper($tmp[14]));
$fecha_termino=trim(strtoupper($tmp[12]));
$causaTermino=trim(strtoupper($tmp[10]));
$razonToxicidad=trim(strtoupper($tmp[11]));
if($geno=="TRUE"||$geno=="SI"){
$geno="SI";
}else{
$geno="NO";
}
if($geno_fecha==''){
$geno_fecha="NULL";
}else{
$geno_fecha="'$geno_fecha'";
}
if($fecha_termino==''){
$fecha_termino="NULL";
}else{
$fecha_termino="'$fecha_termino'";
}
switch($sexo){
case 'M':
case 'MASCULINO':
$sexo="2";
break;
case 'F':
case 'FEMENINO':
$sexo="1";
break;
default:
$sexo="3";
}
if($sexo=="3"){
//continue;
}
echo "<tr>";
echo "<td>".($i++)."</td>";
$query = "SELECT ID, Codigo, CentroID, SexoID from Paciente WHERE TRIM(UPPER(Codigo))='$codigo' AND (SexoID IS NULL OR SexoID='' OR CentroID IS NULL OR CentroID='')";
$result = mysql_query($query);
if(mysql_num_rows($result)>0){
$row = mysql_fetch_array($result);
if($row['ID']!=null&&$row['ID']!=""){
echo "<td style=\"background-color:green;color:white;\">$codigo / {$row['Codigo']} / ".mysql_num_rows($result)."</td>";
}else{
echo "<td style=\"background-color:yellow;color:black;\">$codigo</td>";
}
if($row['CentroID']==null||$row['CentroID']==""){
echo "<td>NO Centro</td>";
}
/*if(($row['SexoID']==null||$row['SexoID']=="")&&$sexo!="3"){
mysql_query("update Paciente set SexoID=$sexo WHERE ID={$row['ID']}");
}*/
//$query2 = "SELECT ID, PacienteID, NumeroTar from Terapia WHERE PacienteID={$row['ID']} AND NumeroTar=$numero;";
//$result2 = mysql_query($query2);
}else{
echo "<td style=\"background-color:red;color:white;\">$codigo</td>";
}
echo "</tr>";
}
}
}
}
mysql_close();
}
?>
</table>
</body>
</html>