Beispiel #1
0
		case 'delete':
			Delete($id);
			DisplaySubjectList($searchuid, $searchaltuid, $searchname, $searchgender, $searchdob, $searchactive);
			break;
		case 'obliterate':
			Obliterate($ids);
			DisplaySubjectList($searchuid, $searchaltuid, $searchname, $searchgender, $searchdob, $searchactive);
			break;
		case 'merge':
			DisplayMergeSubjects($mergeuids);
			break;
		case 'mergesubjects':
			DoMergeSubjects($selectedid, $name, $dob, $gender, $ethnicity1, $ethnicity2, $handedness, $education, $phone1, $email,$maritalstatus,$smokingstatus, $altuid, $guid, $cancontact);
			break;
		case 'enroll':
			EnrollSubject($id, $projectid);
			DisplaySubject($id);
			break;
		case 'confirmupdate':
			Confirm("update", $id, $encrypt, $lastname, $firstname, $dob, $gender, $ethnicity1, $ethnicity2, $handedness, $education, $phone, $email,$maritalstatus,$smokingstatus, $cancontact, $uid, $altuids, $enrollmentids, $guid);
			break;
		case 'confirmadd':
			Confirm("add", "", $encrypt, $lastname, $firstname, $dob, $gender, $ethnicity1, $ethnicity2, $handedness, $education, $phone, $email,$maritalstatus,$smokingstatus, $cancontact, "", $altuids, $enrollmentids, $guid);
			break;
		case 'update':
			UpdateSubject($id, $lastname, $firstname, $dob, $gender, $ethnicity1, $ethnicity2, $handedness, $education, $phone, $email,$maritalstatus,$smokingstatus, $cancontact, $uid, $altuids, $enrollmentids, $guid);
			DisplaySubjectList($searchuid, $searchaltuid, $searchname, $searchgender, $searchdob, $searchactive);
			break;
		case 'add':
			AddSubject($lastname, $firstname, $dob, $gender, $ethnicity1, $ethnicity2, $handedness, $education, $phone, $email,$maritalstatus,$smokingstatus, $cancontact, $altuid, $guid);
			DisplaySubjectList($searchuid, $searchaltuid, $searchname, $searchgender, $searchdob, $searchactive);
Beispiel #2
0
	function InsertMeasures($f, $projectRowID, $fileformat) {
	
		/* open the file and check some fields */
		$lines = file($f);

		$c=0;
		/* check if its the short format */
		if ($fileformat == "short") {
			for ($i=0;$i<count($lines);$i++) {
				$line = $lines[$i];
				$parts = str_getcsv($line);
				
				/* separate out the columns */
				$uid = mysql_real_escape_string(trim($parts[0]));
				$instrument = mysql_real_escape_string(trim($parts[1]));
				$measure = mysql_real_escape_string(trim($parts[2]));
				$value = mysql_real_escape_string(trim($parts[3]));
				
				/* ----- check each column ----- */
				/* get subjectID */
				$subjectRowID = GetSubjectRowID($uid);
				
				/* check if this enrollment exists, and if not, create it */
				$enrollmentRowID = EnrollSubject($subjectRowID, $projectRowID);
				
				$instrumentnameid = InsertInstrumentName($instrument);
				$measurenameid = InsertMeasureName($measure);
				
				$sqlstring = "insert ignore into measures (enrollment_id, measure_dateentered, measure_dateentered2, instrumentname_id, measurename_id, measure_type, measure_valuestring, measure_valuenum, measure_rater, measure_rater2, measure_isdoubleentered, measure_datecomplete) values ($enrollmentRowID, now(), now(), '$instrumentnameid', '$measurenameid', '$type', '$valuestring','$valuenum', 'Imported', 'Imported', 1, now())";
				//PrintSQL($sqlstring);
				$result = MySQLiQuery($sqlstring,__FILE__,__LINE__);
				
				$c++;
			}
		}
		/* otherwise its the long format */
		else {
			for ($i=0;$i<count($lines);$i++) {
				$line = $lines[$i];
				$parts = str_getcsv($line);
				
				//echo "<pre> PARTS:";
				//print_r($parts);
				//echo "</pre>";
				if ($i == 0) {
					/* get the first line, the instruments */
					$instruments = $parts;
					//array_shift($instruments);
					//echo "<pre> instruments:";
					//print_r($instruments);
					//echo "</pre>";
				}
				elseif ($i == 1) {
					/* get the second line, the measures */
					$measures = $parts;
					//array_shift($measures);
					//echo "<pre> measures:";
					//print_r($measures);
					//echo "</pre>";
				}
				else {
					/* otherwise, it should be a real line... with data */
					//echo "This is real data!";
					
					/* separate out the columns */
					$col=0;
					foreach ($parts as $part) {
						$value = mysql_real_escape_string(trim($part));
						
						//echo "Working on column $col<br>";
						if ($col == 0) {
							$uid = $value;
							/* get subjectID */
							$subjectRowID = GetSubjectRowID($uid);
							
							/* check if this enrollment exists, and if not, create it */
							$enrollmentRowID = EnrollSubject($subjectRowID, $projectRowID);
						}
						else {
							$instrument = $instruments[$col];
							$measure = $measures[$col];
							
							/* create the measures SQL string */
							if (is_numeric($value)) {
								$type = 'n';
								$valuestring = '';
								$valuenum = $value;
							}
							else {
								$type = 's';
								$valuestring = $value;
								$valuenum = '';
							}
							
							$instrumentnameid = InsertInstrumentName($instrument);
							$measurenameid = InsertMeasureName($measure);
							
							$sqlstring = "insert ignore into measures (enrollment_id, measure_dateentered, measure_dateentered2, instrumentname_id, measurename_id, measure_type, measure_valuestring, measure_valuenum, measure_rater, measure_rater2, measure_isdoubleentered, measure_datecomplete) values ($enrollmentRowID, now(), now(), '$instrumentnameid', '$measurenameid', '$type', '$valuestring','$valuenum', 'Imported', 'Imported', 1, now())";
							//PrintSQL($sqlstring);
							$result = MySQLQuery($sqlstring,__FILE__,__LINE__);
							$c++;
						}
						$col++;
					}
				}
			}
		}
		?>
		<li><span style="color: darkblue">Inserted <?php 
echo $c;
?>
 measure values</span>
		<?
	}