public function Save() { if ($this->clari_notes_record_number != null) { $this->Load("clari_notes_record_number = '{$this->clari_notes_record_number}'"); } else { $this->clari_notes_record_number = shn_create_uuid('clari_notes'); parent::Save(); } }
public static function saveLogDetails($entity, $record_number, $action, $description = null, $query = null, $module = null, $username = null) { $log = new Log(); $log->log_record_number = shn_create_uuid('log'); $log->entity = $entity; if ($module) { $log->module = $module; } else { $log->module = $_GET['mod']; } //var_dump($_GET); if (isset($_GET['eid'])) { $mrn = $_GET['eid']; } else { if (isset($_GET['pid'])) { $mrn = $_GET['pid']; } else { if (isset($_GET['person_id'])) { $mrn = $_GET['person_id']; } else { if (isset($_GET['doc_id'])) { $mrn = $_GET['doc_id']; } else { $mrn = $record_number; } } } } $log->module_record_number = $mrn; $log->record_number = $record_number; $log->action = $action; $log->description = $description; $log->query = $query; if ($username) { $log->username = $username; } else { $log->username = $_SESSION['username']; } $log->Save(); }
function savePosition(&$p) { global $global; if (!isset($p->pos_id)) { //generate a new id require_once $global['approot'] . "/inc/lib_uuid.inc"; $p->pos_id = shn_create_uuid(); //create a new position $this->execute("INSERT INTO vm_position (pos_id, proj_id, ptype_id, title, slots, description,payrate)\n\t\t\t\t\t\t\tvalues ('{$p->pos_id}', '{$p->proj_id}', '{$p->ptype_id}', '{$p->title}', '{$p->numSlots}', '{$p->description}', '{$p->payrate}')"); } else { //update existing position information $this->execute("UPDATE vm_position SET proj_id = '{$p->proj_id}', ptype_id = '{$p->ptype_id}', title = '{$p->title}', slots = '{$p->numSlots}', description = '{$p->description}', payrate = '{$p->payrate}'\n \t\t\t\t\twhere pos_id = '{$p->pos_id}'"); } }
public function act_new_document() { global $conf; $document_form = document_form('new'); $this->document_form = $document_form; if (isset($_POST['save'])) { $status = shn_form_validate($this->document_form); if (!$status) { return; } unset($document_form['doc_id']); $supporting_docs = new SupportingDocs(); $supporting_docs_meta = new SupportingDocsMeta(); $type = null; $uri = shn_files_store('choose_file_upload', null, $type); //"http://test"; if ($uri == null) { $uri = ''; } $doc_uuid = shn_create_uuid('doc'); $supporting_docs->doc_id = $doc_uuid; $supporting_docs_meta->doc_id = $doc_uuid; $supporting_docs->uri = $uri; form_objects($document_form, $supporting_docs); form_objects($document_form, $supporting_docs_meta); $supporting_docs_meta->format = $type; $supporting_docs->Save(); $supporting_docs_meta->SaveAll(); $this->supporting_docs = $supporting_docs; $this->supporting_docs_meta = $supporting_docs_meta; set_url_args('doc_id', $this->supporting_docs_meta->doc_id); change_tpl('add_document_finish'); set_redirect_header('docu', 'view_document'); exit; } }
function get_data_array() { global $dataFile, $dataCols, $fields, $lists, $docsCount, $biosCount; if (($handle = fopen($dataFile, "r")) === FALSE) { return array(); } $results = array(); $j = 0; while (($cols = fgetcsv($handle, 0, "\t")) !== FALSE) { $glData = array(); $row = array(); if ($cols && $cols[1]) { //var_dump($cols);exit; foreach ($cols as $key => $val) { $val = trim($val, '"'); $val = trim($val); $row[$key] = $val; $entityField = $dataCols[$key]; if ($entityField) { $ent = $entityField["ent"]; $list_code = $entityField['list_code']; $type = $entityField['field_type']; $mlt = trim($entityField['is_repeat']) == 'Y' || trim($entityField['is_repeat']) == 'y' ? true : false; if ($list_code == 39) { if ($val == "M") { $val = "Hombre"; } elseif ($val == "F") { $val = "Mujer"; } } if ($list_code && !$lists[$list_code]) { $options = array(); $data_array = MtFieldWrapper::getMTList($list_code); $size = count($data_array); for ($i = 0; $i < $size; $i++) { $options[$data_array[$i]['vocab_number']] = strtolower($data_array[$i]['label']); } $lists[$list_code] = $options; } if ($list_code) { if ($mlt) { $val2 = explode(";", $val); $val = array(); foreach ($val2 as $v) { $v = trim($v); $vocab_number = array_search(strtolower($v), $lists[$list_code]); if ($vocab_number) { $val[] = $vocab_number; } } } else { $vocab_number = array_search(strtolower($val), $lists[$list_code]); if ($vocab_number) { $val = $vocab_number; } else { $val = null; } } } if ($type == "date") { if ($val) { $d = date_create_from_format("m/d/Y", $val); if ($d) { $val = date_format($d, 'Y-m-d'); } else { $val = null; } } else { $val = null; } } elseif ($type == "location") { $val2 = explode(",", $val); //$row[$entityField['field_name'] . "_latitude"] = -floatval($val2[0]); //$row[$entityField['field_name'] . "_longitude"] = -floatval($val2[1]); $glData[$ent][$entityField['field_name'] . "_latitude"] = -floatval($val2[0]); $glData[$ent][$entityField['field_name'] . "_longitude"] = -floatval($val2[1]); $val = null; } elseif ($type == "radio") { if ($val == "NO" || $val == "no") { $val = "n"; } elseif ($val == "SÍ" || $val == "sí") { $val = "y"; } else { $val = null; } } if (!is_null($val)) { //$row[$entityField['field_name']] = $val; $glData[$ent][$entityField['field_name']] = $val; } } } if (!$glData['act']['ubicacto']) { $v = $row[25]; $vocab_number = array_search(strtolower($v), $lists[71]); if ($vocab_number) { $glData['act']['ubicacto'] = $vocab_number; } } if (!$glData['act']['ubicacto']) { $v = $row[24]; $vocab_number = array_search(strtolower($v), $lists[71]); if ($vocab_number) { $glData['act']['ubicacto'] = $vocab_number; } } $browse = new Browse(); $rows = $browse->ExecuteQuery("select event_record_number as id from event where event_title='" . $glData['event']['event_title'] . "'"); if ($rows && $rows[0]['id']) { $event = new Event(); $event->LoadFromRecordNumber($rows[0]['id']); } else { $form = event_form('new'); $event = new Event(); $event->event_record_number = shn_create_uuid('event'); form_objects($form, $event, $glData['event']); $event->SaveAll(); } $browse = new Browse(); $person = null; if ($glData['person']['person_name'] != "NN") { $rows = $browse->ExecuteQuery("select person_record_number as id from person where person_name='" . $glData['person']['person_name'] . "' \n\t\t\t\tand other_names='" . $glData['person']['other_names'] . "' "); if ($rows && $rows[0]['id']) { $person = new Person(); $person->LoadFromRecordNumber($rows[0]['id']); } } if (!$person) { $person_form = person_form('new'); $person = new Person(); form_objects($person_form, $person, $glData['person']); $person->deceased = $person->deceased == 'on' ? 'y' : 'n'; if (isset($person->number_of_persons_in_group) && !$person->number_of_persons_in_group) { $person->number_of_persons_in_group = Null; } if (isset($person->dependants) && !$person->dependants) { $person->dependants = Null; } $person->SaveAll(); } $victim = $person; $act_form = act_form('new'); $act = new Act(); $act->act_record_number = shn_create_uuid('act'); $glData['act']['victim'] = $victim->person_record_number; form_objects($act_form, $act, $glData['act']); $act->event = $event->event_record_number; $act->SaveAll(); if ($glData['perpetrator']['person_name']) { $browse = new Browse(); $rows = $browse->ExecuteQuery("select person_record_number as id from person where person_name='" . $glData['perpetrator']['person_name'] . "' "); if ($rows && $rows[0]['id']) { $person = new Person(); $person->LoadFromRecordNumber($rows[0]['id']); } else { $person_form = person_form('new'); $person = new Person(); form_objects($person_form, $person, $glData['perpetrator']); $person->deceased = $person->deceased == 'on' ? 'y' : 'n'; if (isset($person->number_of_persons_in_group) && !$person->number_of_persons_in_group) { $person->number_of_persons_in_group = Null; } if (isset($person->dependants) && !$person->dependants) { $person->dependants = Null; } $person->SaveAll(); } $perpetrator = $person; $inv = new Involvement(); $inv->involvement_record_number = shn_create_uuid('inv'); $inv->degree_of_involvement = "54010101001921"; //placeholder $inv->event = $event->event_record_number; $inv->act = $act->act_record_number; $inv->perpetrator = $perpetrator->person_record_number; $inv->SaveAll(); } $supporting_documents = array(); if (trim($row[9])) { $document_form = document_form('new'); unset($document_form['doc_id']); $supporting_docs = new SupportingDocs(); $supporting_docs_meta = new SupportingDocsMeta(); $type = null; $doc_uuid = shn_create_uuid('doc'); $supporting_docs->doc_id = $doc_uuid; $supporting_docs_meta->doc_id = $doc_uuid; $supporting_docs->uri = ''; form_objects($document_form, $supporting_docs, array('title' => $row[9])); form_objects($document_form, $supporting_docs_meta, array('title' => $row[9])); $supporting_docs_meta->format = $type; $supporting_docs->Save(); $supporting_docs_meta->Save(); $supporting_documents[] = $doc_uuid; } for ($j = 1; $j <= $docsCount; $j++) { if ($glData["supporting_docs_meta" . $j]) { if (!$glData["supporting_docs_meta" . $j]['title']) { continue; } $document_form = document_form('new'); unset($document_form['doc_id']); $supporting_docs = new SupportingDocs(); $supporting_docs_meta = new SupportingDocsMeta(); $type = null; $doc_uuid = shn_create_uuid('doc'); $supporting_docs->doc_id = $doc_uuid; $supporting_docs_meta->doc_id = $doc_uuid; $supporting_docs->uri = ''; form_objects($document_form, $supporting_docs, $glData["supporting_docs_meta" . $j]); form_objects($document_form, $supporting_docs_meta, $glData["supporting_docs_meta" . $j]); $supporting_docs_meta->format = $type; $supporting_docs->Save(); $supporting_docs_meta->SaveAll(); $supporting_documents[] = $doc_uuid; } } if ($supporting_documents) { $act->supporting_documents = $supporting_documents; $act->SaveDocs(); } $bio_details = array(); for ($j = 1; $j <= $biosCount; $j++) { if ($glData["bio_details" . $j] && $glData["bio_details" . $j]["type_of_relationship"]) { $browse = new Browse(); $rows = $browse->ExecuteQuery("select person_record_number as id from person where person_name='" . $glData["bio_details" . $j]['person_name'] . "' \n\t\t\t\t\tand other_names='" . $glData['bio_details']['other_names'] . "' "); if ($rows && $rows[0]['id']) { $person = new Person(); $person->LoadFromRecordNumber($rows[0]['id']); } else { $person_form = person_form('new'); $person = new Person(); form_objects($person_form, $person, $glData["bio_details" . $j]); $person->deceased = $person->deceased == 'on' ? 'y' : 'n'; if (isset($person->number_of_persons_in_group) && !$person->number_of_persons_in_group) { $person->number_of_persons_in_group = Null; } if (isset($person->dependants) && !$person->dependants) { $person->dependants = Null; } $person->SaveAll(); } if ($glData["bio_details" . $j]["phone"] || $glData["bio_details" . $j]["email"]) { $address = new Address(); $address_form = address_form('new'); form_objects($address_form, $address, $glData["bio_details" . $j]); $address->person = $person->person_record_number; $address->Save(); } $biography_form = biographic_form('new'); $biography = new BiographicDetail(); //$biography->LoadfromRecordNumber(); $biography->biographic_details_record_number = shn_create_uuid('biography'); $glData["bio_details" . $j]['person_id'] = $person->person_record_number; form_objects($biography_form, $biography, $glData["bio_details" . $j]); $biography->person = $victim->person_record_number; $biography->related_person = $person->person_record_number; if ($biography->related_person == '') { $biography->related_person = null; } $biography->SaveAll(); } } } $results[] = $row; $j++; } return $results; }
/** initializes some values for a new instance (instead of when we load a previous instance) */ public function init() { // update sequences $this->co_id = shn_create_uuid("edxl_co_header"); $this->de_id = shn_create_uuid("edxl_de_header"); }
public function parseXml() { global $global; require_once($global['approot']."inc/lib_uuid.inc"); // save xml for debugging? if($global['debugAndSaveXmlToFile'] == true) { $filename = date("Y_md_H-i-s.".getMicrotimeComponent())."___".mt_rand().".xml"; // 2012_0402_17-50-33.454312___437849328789.xml $path = $global['debugAndSaveXmlToFilePath'].$filename; file_put_contents($path, $this->theString); } // is this a supported XML type? if(!in_array((string)trim($this->xmlFormat), $global['enumXmlFormats'])) { return (int)400; } //$a = xml2array($this->theString); $aa = new XMLParser(); $aa->rawXML = $this->theString; $aa->parse(); if($aa->getError()) { return (int)403; // error code for failed to parse xml } $a = $aa->getArray(); // parse REUNITE4 XML if($this->xmlFormat == "REUNITE4") { $this->createUUID(); $this->arrival_reunite = true; $this->given_name = isset($a['person']['givenName']) ? $a['person']['givenName'] : null; $this->family_name = isset($a['person']['familyName']) ? $a['person']['familyName'] : null; $this->expiry_date = isset($a['person']['expiryDate']) ? $a['person']['expiryDate'] : null; $this->opt_status = isset($a['person']['status']) ? $a['person']['status'] : null; $this->last_updated = date('Y-m-d H:i:s'); $datetime = isset($a['person']['dateTimeSent']) ? $a['person']['dateTimeSent'] : null; $timezoneUTC = new DateTimeZone("UTC"); $timezoneLocal = new DateTimeZone(date_default_timezone_get()); $datetime2 = new DateTime(); $datetime2->setTimezone($timezoneUTC); $datetime2->setTimestamp(strtotime($datetime)); $datetime2->setTimezone($timezoneLocal); $this->creation_time = $datetime2->format('Y-m-d H:i:s'); $this->opt_gender = isset($a['person']['gender']) ? $a['person']['gender'] : null; $this->years_old = isset($a['person']['estimatedAge']) ? $a['person']['estimatedAge'] : null; $this->minAge = isset($a['person']['minAge']) ? $a['person']['minAge'] : null; $this->maxAge = isset($a['person']['maxAge']) ? $a['person']['maxAge'] : null; $this->other_comments = isset($a['person']['note']) ? $a['person']['note'] : null; // TEMP HACK KLUGE to stuff person location data into the person_status last_known_location field $kluge = ""; $kluge .= isset($a['person']['location']['street1']) ? $a['person']['location']['street1']."\n" : ""; $kluge .= isset($a['person']['location']['street2']) ? $a['person']['location']['street2']."\n" : ""; $kluge .= isset($a['person']['location']['neighborhood']) ? $a['person']['location']['neighborhood']."\n" : ""; $kluge .= isset($a['person']['location']['city']) ? $a['person']['location']['city']."\n" : ""; $kluge .= isset($a['person']['location']['region']) ? $a['person']['location']['region']."\n" : ""; $kluge .= isset($a['person']['location']['postalCode']) ? $a['person']['location']['postalCode']."\n" : ""; $kluge .= isset($a['person']['location']['country']) ? $a['person']['location']['country']."\n" : ""; if(trim($kluge) != "") { $this->last_seen = $kluge; } // only update the incident_id if not already set if($this->incident_id === null) { $q = " SELECT * FROM incident WHERE shortname = '".mysql_real_escape_string((string)$a['person']['eventShortname'])."'; "; $result = $this->db->Execute($q); if($result === false) { daoErrorLog(__FILE__, __LINE__, __METHOD__, __CLASS__, __FUNCTION__, $this->db->ErrorMsg(), "person get incident ((".$q."))"); } $this->incident_id = $result->fields["incident_id"]; } if(isset($a['person']['photos']['photo'])) { foreach($a['person']['photos'] as $photo) { if(trim($photo['data']) != "") { $i = new personImage(); $i->init(); $i->p_uuid = $this->p_uuid; $i->fileContentBase64 = $photo['data']; if(isset($photo['tags'])) { foreach($photo['tags'] as $tag) { $t = new personImageTag(); $t->init(); $t->image_id = $i->image_id; $t->tag_x = $tag['x']; $t->tag_y = $tag['y']; $t->tag_w = $tag['w']; $t->tag_h = $tag['h']; $t->tag_text = $tag['text']; $i->tags[] = $t; } } $this->images[] = $i; } } } // if there is actual voicenote data, save process it... if(isset($a['person']['voiceNote']['data']) && trim($a['person']['voiceNote']['data']) != "") { $v = new voiceNote(); $v->init(); // reserves a voicenote id for this note $v->p_uuid = $this->p_uuid; $v->dataBase64 = $a['person']['voiceNote']['data']; $v->length = $a['person']['voiceNote']['length']; $v->format = $a['person']['voiceNote']['format']; $v->sample_rate = $a['person']['voiceNote']['sampleRate']; $v->channels = $a['person']['voiceNote']['numberOfChannels']; $v->speaker = $a['person']['voiceNote']['speaker']; $this->voice_note = $v; } // check for p_uuid collision with already present data, return 401 error if p_uuid already exists $q = " SELECT count(*) FROM person_uuid WHERE p_uuid = '".mysql_real_escape_string((string)$this->p_uuid)."'; "; $result = $this->db->Execute($q); if($result === false) { daoErrorLog(__FILE__, __LINE__, __METHOD__, __CLASS__, __FUNCTION__, $this->db->ErrorMsg(), "person check p_uuid collision ((".$q."))"); } if(!$this->ignoreDupeUuid && (int)$result->fields['count(*)'] > 0 ) { return (int)401; } // check if reported p_uuid is valid (in range of sequence) ~ 402 error if not if(!shn_is_p_uuid_valid($this->p_uuid)) { return (int)402; } // check if the event is closed to reporting... if(!$this->isEventOpen()) { return (int)405; } // no errors return (int)$this->ecode; // parse REUNITE3 XML } elseif($this->xmlFormat == "REUNITE3") { $this->arrival_reunite = true; $this->p_uuid = $a['person']['p_uuid']; $this->given_name = $a['person']['givenName']; $this->family_name = $a['person']['familyName']; $this->expiry_date = $a['person']['expiryDate']; $this->opt_status = $a['person']['status']; $this->last_updated = date('Y-m-d H:i:s'); $this->creation_time = $a['person']['dateTimeSent']; $this->opt_gender = $a['person']['gender']; $this->years_old = $a['person']['estimatedAge']; $this->minAge = $a['person']['minAge']; $this->maxAge = $a['person']['maxAge']; $this->other_comments = $a['person']['note']; // only update the incident_id if not already set if($this->incident_id === null) { $this->incident_id = $a['person']['eventId']; } foreach($a['person']['photos'] as $photo) { if(trim($photo['data']) != "") { $i = new personImage(); $i->init(); $i->p_uuid = $this->p_uuid; $i->fileContentBase64 = $photo['data']; foreach($photo['tags'] as $tag) { $t = new personImageTag(); $t->init(); $t->image_id = $i->image_id; $t->tag_x = $tag['x']; $t->tag_y = $tag['y']; $t->tag_w = $tag['w']; $t->tag_h = $tag['h']; $t->tag_text = $tag['text']; $i->tags[] = $t; } if(!$i->invalid) { $this->images[] = $i; $this->ecode = 419; } } } // if there is actual voicenote data, save process it... if(trim($a['person']['voiceNote']['data']) != "") { $v = new voiceNote(); $v->init(); // reserves a voicenote id for this note $v->p_uuid = $this->p_uuid; $v->dataBase64 = $a['person']['voiceNote']['data']; $v->length = $a['person']['voiceNote']['length']; $v->format = $a['person']['voiceNote']['format']; $v->sample_rate = $a['person']['voiceNote']['sampleRate']; $v->channels = $a['person']['voiceNote']['numberOfChannels']; $v->speaker = $a['person']['voiceNote']['speaker']; $this->voice_note = $v; } // check for p_uuid collision with already present data, return 401 error if p_uuid already exists $q = " SELECT count(*) FROM person_uuid WHERE p_uuid = '".mysql_real_escape_string((string)$this->p_uuid)."'; "; $result = $this->db->Execute($q); if($result === false) { daoErrorLog(__FILE__, __LINE__, __METHOD__, __CLASS__, __FUNCTION__, $this->db->ErrorMsg(), "person check p_uuid collision ((".$q."))"); } if(!$this->ignoreDupeUuid && (int)$result->fields['count(*)'] > 0 ) { return (int)401; } // check if reported p_uuid is valid (in range of sequence) ~ 402 error if not if(!shn_is_p_uuid_valid($this->p_uuid)) { return (int)402; } // check if the event is closed to reporting... if(!$this->isEventOpen()) { return (int)405; } // no errors return (int)$this->ecode; // parse REUNITE2 XML } elseif($this->xmlFormat == "REUNITE2") { $this->arrival_reunite = true; // figure out the incident_id $shortName = strtolower($a['lpfContent']['person']['eventShortName']); $q = " SELECT * FROM incident WHERE shortname = '".mysql_real_escape_string((string)$shortName)."'; "; $result = $this->db->Execute($q); if($result === false) { daoErrorLog(__FILE__, __LINE__, __METHOD__, __CLASS__, __FUNCTION__, $this->db->ErrorMsg(), "person get incident ((".$q."))"); } if($result != NULL && !$result->EOF) { $this->incident_id = $result->fields['incident_id']; } else { return (int)406; } // extract other xml data $this->createUUID(); $this->given_name = $a['lpfContent']['person']['firstName']; $this->family_name = $a['lpfContent']['person']['familyName']; $this->opt_status = substr(strtolower($a['lpfContent']['person']['status']['healthStatus']), 0, 3); $this->last_updated = date('Y-m-d H:i:s'); $this->creation_time = $a['lpfContent']['person']['dateTimeSent']; $this->opt_gender = substr(strtolower($a['lpfContent']['person']['gender']), 0, 3); $this->years_old = $a['lpfContent']['person']['estimatedAgeInYears']; $this->minAge = $a['lpfContent']['person']['ageGroup']['minAge']; $this->maxAge = $a['lpfContent']['person']['ageGroup']['maxAge']; $this->other_comments = $a['lpfContent']['person']['notes']; // check if the event is closed to reporting... if(!$this->isEventOpen()) { return (int)405; } // no errors return (int)0; // parse TRIAGEPIC1 XML } elseif($this->xmlFormat == "TRIAGEPIC1") { $this->arrival_triagepic = true; $this->edxl = new personEdxl(); $this->edxl->init(); // when we have more than 1 contentObject, they are renamed to 0...x if(isset($a['EDXLDistribution'][0])) { $ix = 0; // when there is only 1 contentObject, we go by name } elseif(isset($a['EDXLDistribution']['contentObject'])) { $ix = "contentObject"; // all else, we fail and quit } else { return (int)403; // error code for failed to parse xml } $this->createUUID(); $this->family_name = $a['EDXLDistribution'][$ix]['xmlContent']['lpfContent']['person']['lastName']; $this->given_name = $a['EDXLDistribution'][$ix]['xmlContent']['lpfContent']['person']['firstName']; $eventName = $a['EDXLDistribution'][$ix]['xmlContent']['lpfContent']['person']['eventName']; $q = " SELECT * FROM incident WHERE shortname = '".mysql_real_escape_string((string)$eventName)."'; "; $result = $this->db->Execute($q); if($result === false) { daoErrorLog(__FILE__, __LINE__, __METHOD__, __CLASS__, __FUNCTION__, $this->db->ErrorMsg(), "person get incident ((".$q."))"); } $this->incident_id = $result->fields["incident_id"]; $b = $a['EDXLDistribution'][$ix]['xmlContent']['lpfContent']['person']['triageCategory']; if(($b == "Green") || ($b == "BH Green")) { $this->opt_status = "ali"; } elseif(($b == "Yellow") || ($b == "Red") || ($b == "Gray")) { $this->opt_status = "inj"; } elseif($b == "Black") { $this->opt_status = "dec"; } else { $this->opt_status = "unk"; } $this->last_updated = date('Y-m-d H:i:s'); // <dateTimeSent>2011-03-28T07:52:17Z</dateTimeSent> $datetime = $a['EDXLDistribution']['dateTimeSent']; $timezoneUTC = new DateTimeZone("UTC"); $timezoneLocal = new DateTimeZone(date_default_timezone_get()); $datetime2 = new DateTime(); $datetime2->setTimezone($timezoneUTC); $datetime2->setTimestamp(strtotime($datetime)); $datetime2->setTimezone($timezoneLocal); $this->creation_time = $datetime2->format('Y-m-d H:i:s'); $this->opt_gender = $a['EDXLDistribution'][$ix]['xmlContent']['lpfContent']['person']['gender']; $peds = $a['EDXLDistribution'][$ix]['xmlContent']['lpfContent']['person']['peds']; if($peds == "Y") { $this->minAge = 0; $this->maxAge = 17; } elseif($peds == "N") { $this->minAge = 18; $this->maxAge = 150; } elseif($peds == "Y,N") { $this->minAge = 0; $this->maxAge = 150; } $this->other_comments = $a['EDXLDistribution'][$ix]['contentDescription']; $orgId = $a['EDXLDistribution'][$ix]['xmlContent']['lpfContent']['person']['organization']['orgId']; $q = " SELECT * FROM hospital WHERE npi = '".mysql_real_escape_string((string)$orgId)."'; "; $result = $this->db->Execute($q); if($result === false) { daoErrorLog(__FILE__, __LINE__, __METHOD__, __CLASS__, __FUNCTION__, $this->db->ErrorMsg(), "person get hospital ((".$q."))"); } $this->hospital_uuid = $result->fields["hospital_uuid"]; $this->last_seen = $result->fields["name"]." Hospital"; $this->edxl->content_descr = $a['EDXLDistribution'][$ix]['contentDescription']; $this->edxl->p_uuid = $this->p_uuid; $this->edxl->schema_version = $a['EDXLDistribution'][$ix]['xmlContent']['lpfContent']['version']; $this->edxl->login_machine = "n/a"; //null; HACK! cant be null $this->edxl->login_account = $a['EDXLDistribution'][$ix]['xmlContent']['lpfContent']['login']['userName']; $this->edxl->person_id = $a['EDXLDistribution'][$ix]['xmlContent']['lpfContent']['person']['personId']; $this->edxl->event_name = $a['EDXLDistribution'][$ix]['xmlContent']['lpfContent']['person']['eventName']; $this->edxl->event_long_name = $a['EDXLDistribution'][$ix]['xmlContent']['lpfContent']['person']['eventLongName']; $this->edxl->org_name = $a['EDXLDistribution'][$ix]['xmlContent']['lpfContent']['person']['organization']['orgName']; $this->edxl->org_id = $a['EDXLDistribution'][$ix]['xmlContent']['lpfContent']['person']['organization']['orgId']; $this->edxl->last_name = $a['EDXLDistribution'][$ix]['xmlContent']['lpfContent']['person']['lastName']; $this->edxl->first_name = $a['EDXLDistribution'][$ix]['xmlContent']['lpfContent']['person']['firstName']; $this->edxl->gender = $a['EDXLDistribution'][$ix]['xmlContent']['lpfContent']['person']['gender']; $this->edxl->peds = $a['EDXLDistribution'][$ix]['xmlContent']['lpfContent']['person']['peds']; $this->edxl->triage_category = $a['EDXLDistribution'][$ix]['xmlContent']['lpfContent']['person']['triageCategory']; $this->edxl->when_sent = $this->last_updated; $this->edxl->sender_id = $a['EDXLDistribution']['senderID']; $this->edxl->distr_id = $a['EDXLDistribution']['distributionID']; $this->edxl->distr_status = $a['EDXLDistribution']['distributionStatus']; $this->edxl->distr_type = $a['EDXLDistribution']['distributionType']; $this->edxl->combined_conf = $a['EDXLDistribution']['combinedConfidentiality']; $this->edxl->language = null; $this->edxl->when_here = $this->creation_time; $this->edxl->inbound = 1; //null; HACK! cant be null $this->edxl->type = "lpf"; $this->cleanInput(); // parse all images for($n = 0; $n < sizeof($a['EDXLDistribution']); $n++) { if(isset($a['EDXLDistribution'][$n]['nonXMLContent']) && $a['EDXLDistribution'][$n]['nonXMLContent'] != null) { $imageNode = $a['EDXLDistribution'][$n]['nonXMLContent']; $cd = $a['EDXLDistribution'][$n]['contentDescription']; $cd = str_replace($a['EDXLDistribution'][$ix]['xmlContent']['lpfContent']['person']['personId'], "", $cd); // remove patient id from the string $cd = str_replace($this->edxl->triage_category, "", $cd); // remove triage category from the string $cd = trim($cd); // remove preceding and trailing whitespace(s) // what we should now have left is in the format: "" or "sX" or "sX - caption" or "- caption" // primary no caption if($cd === "") { $primary = true; $caption = null; // secondary no caption } elseif(strpos($cd, "-") === false) { $primary = false; $caption = null; // has caption } else { $ecd = explode("-", $cd); // primary with caption if(trim($ecd[0]) == "") { $primary = true; $caption = $ecd[1]; // secondary with caption } else { $primary = false; $caption = trim($ecd[1]); } } // create sahana image if(trim($imageNode['contentData']) != "") { $i = new personImage(); $i->init(); $i->p_uuid = $this->p_uuid; $i->fileContentBase64 = $imageNode['contentData']; $i->decode(); $xmlSha1 = $imageNode['digest']; $realSha1 = sha1($i->fileContent); if(strcasecmp($realSha1, $xmlSha1) != 0) { //error_log("420 ERROR!! realSha1(".$realSha1.") xmlSha1(".$xmlSha1.")"); $i->invalid = true; $this->ecode = 420; } else { //error_log("strings match! realSha1(".$realSha1.") xmlSha1(".$xmlSha1.")"); } $i->original_filename = $imageNode['uri']; if($primary) { $i->principal = 1; } if($caption != null) { $t = new personImageTag(); $t->init(); $t->image_id = $i->image_id; $t->tag_x = 0; $t->tag_y = 0; $t->tag_w = 10; $t->tag_h = 10; $t->tag_text = $caption; $i->tags[] = $t; } if(!$i->invalid) { $this->images[] = $i; } } // create edxl image $this->edxl->mimeTypes[] = $imageNode['mimeType']; $this->edxl->uris[] = $imageNode['uri']; $this->edxl->contentDatas[] = $imageNode['contentData']; $this->edxl->image_ids[] = isset($i->image_id) ? $i->image_id : null; $this->edxl->image_sha1[] = isset($realSha1) ? $realSha1 : null; $this->edxl->image_co_ids[] = shn_create_uuid("edxl_co_header"); } } // check if the event is closed to reporting... if(!$this->isEventOpen()) { return (int)405; } // exit with success return (int)$this->ecode; // parse TRIAGEPIC0 XML } elseif($this->xmlFormat == "TRIAGEPIC0") { $this->arrival_triagepic = true; $this->edxl = new personEdxl(); $this->edxl->init(); $this->createUUID(); $this->family_name = $a['EDXLDistribution']['contentObject']['xmlContent']['embeddedXMLContent']['lpfContent']['person']['lastName']; $this->given_name = $a['EDXLDistribution']['contentObject']['xmlContent']['embeddedXMLContent']['lpfContent']['person']['firstName']; $eventName = $a['EDXLDistribution']['contentObject']['xmlContent']['embeddedXMLContent']['lpfContent']['person']['eventName']; $q = " SELECT * FROM incident WHERE shortname = '".mysql_real_escape_string((string)$eventName)."'; "; $result = $this->db->Execute($q); if($result === false) { daoErrorLog(__FILE__, __LINE__, __METHOD__, __CLASS__, __FUNCTION__, $this->db->ErrorMsg(), "person get incident ((".$q."))"); } $this->incident_id = $result->fields["incident_id"]; $b = $a['EDXLDistribution']['contentObject']['xmlContent']['embeddedXMLContent']['lpfContent']['person']['triageCategory']; if(($b == "Green") || ($b == "BH Green")) { $this->opt_status = "ali"; } elseif(($b == "Yellow") || ($b == "Red") || ($b == "Gray")) { $this->opt_status = "inj"; } elseif($b == "Black") { $this->opt_status = "dec"; } else { $this->opt_status = "unk"; } $this->last_updated = date('Y-m-d H:i:s'); // <dateTimeSent>2011-03-28T07:52:17Z</dateTimeSent> $datetime = $a['EDXLDistribution']['dateTimeSent']; $timezoneUTC = new DateTimeZone("UTC"); $timezoneLocal = new DateTimeZone(date_default_timezone_get()); $datetime2 = new DateTime(); $datetime2->setTimezone($timezoneUTC); $datetime2->setTimestamp(strtotime($datetime)); $datetime2->setTimezone($timezoneLocal); $this->creation_time = $datetime2->format('Y-m-d H:i:s'); $this->opt_gender = $a['EDXLDistribution']['contentObject']['xmlContent']['embeddedXMLContent']['lpfContent']['person']['gender']; $peds = $a['EDXLDistribution']['contentObject']['xmlContent']['embeddedXMLContent']['lpfContent']['person']['peds']; if($peds == "Y") { $this->minAge = 0; $this->maxAge = 17; } elseif($peds == "N") { $this->minAge = 18; $this->maxAge = 150; } elseif($peds == "Y,N") { $this->minAge = 0; $this->maxAge = 150; } $this->other_comments = $a['EDXLDistribution']['contentObject']['contentDescription']; $orgId = $a['EDXLDistribution']['contentObject']['xmlContent']['embeddedXMLContent']['lpfContent']['person']['organization']['orgId']; $q = " SELECT * FROM hospital WHERE npi = '".mysql_real_escape_string((string)$orgId)."'; "; $result = $this->db->Execute($q); if($result === false) { daoErrorLog(__FILE__, __LINE__, __METHOD__, __CLASS__, __FUNCTION__, $this->db->ErrorMsg(), "person get hospital ((".$q."))"); } $this->hospital_uuid = $result->fields["hospital_uuid"]; $this->last_seen = $result->fields["name"]." Hospital"; $this->edxl->content_descr = $a['EDXLDistribution']['contentObject']['contentDescription']; $this->edxl->p_uuid = $this->p_uuid; $this->edxl->schema_version = $a['EDXLDistribution']['contentObject']['xmlContent']['embeddedXMLContent']['lpfContent']['version']; $this->edxl->login_machine = "n/a"; //null; HACK! cant be null $this->edxl->login_account = $a['EDXLDistribution']['contentObject']['xmlContent']['embeddedXMLContent']['lpfContent']['login']['username']; $this->edxl->person_id = $a['EDXLDistribution']['contentObject']['xmlContent']['embeddedXMLContent']['lpfContent']['person']['personId']; $this->edxl->event_name = $a['EDXLDistribution']['contentObject']['xmlContent']['embeddedXMLContent']['lpfContent']['person']['eventName']; $this->edxl->event_long_name = $a['EDXLDistribution']['contentObject']['xmlContent']['embeddedXMLContent']['lpfContent']['person']['eventLongName']; $this->edxl->org_name = $a['EDXLDistribution']['contentObject']['xmlContent']['embeddedXMLContent']['lpfContent']['person']['organization']['orgName']; $this->edxl->org_id = $a['EDXLDistribution']['contentObject']['xmlContent']['embeddedXMLContent']['lpfContent']['person']['organization']['orgId']; $this->edxl->last_name = $a['EDXLDistribution']['contentObject']['xmlContent']['embeddedXMLContent']['lpfContent']['person']['lastName']; $this->edxl->first_name = $a['EDXLDistribution']['contentObject']['xmlContent']['embeddedXMLContent']['lpfContent']['person']['firstName']; $this->edxl->gender = $a['EDXLDistribution']['contentObject']['xmlContent']['embeddedXMLContent']['lpfContent']['person']['gender']; $this->edxl->peds = $a['EDXLDistribution']['contentObject']['xmlContent']['embeddedXMLContent']['lpfContent']['person']['peds']; $this->edxl->triage_category = $a['EDXLDistribution']['contentObject']['xmlContent']['embeddedXMLContent']['lpfContent']['person']['triageCategory']; $this->edxl->when_sent = $this->last_updated; $this->edxl->sender_id = $a['EDXLDistribution']['senderID']; $this->edxl->distr_id = $a['EDXLDistribution']['distributionID']; $this->edxl->distr_status = $a['EDXLDistribution']['distributionStatus']; $this->edxl->distr_type = $a['EDXLDistribution']['distributionType']; $this->edxl->combined_conf = $a['EDXLDistribution']['combinedConfidentiality']; $this->edxl->language = null; $this->edxl->when_here = $this->creation_time; $this->edxl->inbound = 1; //null; HACK! cant be null $this->edxl->type = "lpf"; $this->cleanInput(); // check if the event is closed to reporting... if(!$this->isEventOpen()) { return (int)405; } // exit with success return (int)0; // how did we get here? } else { return (int)9999; } }
public function init() { $this->tag_id = shn_create_uuid("image_tag"); }
public function act_save_query() { include_once APPROOT . 'inc/lib_uuid.inc'; if ($_GET['actions'] == 'save_org_sql') { unset($_GET['shuffle_results']); } if (isset($_GET['query_save'])) { $saveQuery = new SaveQuery(); $saveQuery->save_query_record_number = shn_create_uuid('query'); $saveQuery->name = Reform::HtmlEncode($_GET['query_name']); $saveQuery->description = Reform::HtmlEncode($_GET['query_desc']); $saveQuery->created_date = date("Y-m-d"); $saveQuery->created_by = $_SESSION['username']; $query = isset($_GET['query']) ? $_GET['query'] : analysis_get_query(); $query_type = isset($_GET['query']) ? 'advanced' : 'basic'; $saveQuery->query = $query; $saveQuery->query_type = $query_type; $saveQuery->Save(); if ($_GET['stream'] == 'text') { echo "{'success':true}"; } else { shnMessageQueue::addInformation(_t('QUERY_WAS_SAVED_SUCCESSFULLY_')); } } }
function get_data_array() { global $dataFile, $dataCols, $fields, $lists, $docsCount, $biosCount; if (($handle = fopen($dataFile, "r")) === FALSE) { return array(); } $results = array(); $i = 0; while (($cols = fgetcsv($handle, 0, "\t")) !== FALSE) { $glData = array(); $row = array(); if ($cols && $cols[1]) { foreach ($cols as $key => $val) { $val = trim($val, '"'); $val = trim($val); $row[$key] = $val; $entityField = $dataCols[$key]; if ($entityField) { $ent = $entityField["ent"]; $list_code = $entityField['list_code']; $type = $entityField['field_type']; $mlt = trim($entityField['is_repeat']) == 'Y' || trim($entityField['is_repeat']) == 'y' ? true : false; if ($list_code == 39) { if ($val == "M") { $val == "Hombre"; } elseif ($val == "F") { $val == "Mujer"; } } if ($list_code && !$lists[$list_code]) { $options = array(); $data_array = MtFieldWrapper::getMTList($list_code); $size = count($data_array); for ($i = 0; $i < $size; $i++) { $options[$data_array[$i]['vocab_number']] = strtolower($data_array[$i]['label']); } $lists[$list_code] = $options; } if ($list_code) { if ($mlt) { $val2 = explode(";", $val); $val = array(); foreach ($val2 as $v) { $vocab_number = array_search(strtolower($v), $lists[$list_code]); if ($vocab_number) { $val[] = $vocab_number; } } } else { $vocab_number = array_search(strtolower($val), $lists[$list_code]); if ($vocab_number) { $val = $vocab_number; } else { $val = null; } } } if ($type == "date") { if ($val) { $d = date_create_from_format("m/d/Y", $val); if ($d) { $val = date_format($d, 'Y-m-d'); } else { $val = null; } } else { $val = null; } } elseif ($type == "location") { $val2 = explode(",", $val); //$row[$entityField['field_name'] . "_latitude"] = -floatval($val2[0]); //$row[$entityField['field_name'] . "_longitude"] = -floatval($val2[1]); $glData[$ent][$entityField['field_name'] . "_latitude"] = -floatval($val2[0]); $glData[$ent][$entityField['field_name'] . "_longitude"] = -floatval($val2[1]); $val = null; } elseif ($type == "radio") { if ($val == "NO") { $val = "n"; } elseif ($val == "SÍ") { $val = "y"; } else { $val = null; } } if ($val) { //$row[$entityField['field_name']] = $val; $glData[$ent][$entityField['field_name']] = $val; } } } //var_dump($glData);exit; $browse = new Browse(); $rows = $browse->ExecuteQuery("select event_record_number as id from event where event_title='" . $glData['event']['event_title'] . "'"); if ($rows && $rows[0]['id']) { $event = new Event(); $event->LoadFromRecordNumber($rows[0]['id']); $event->LoadRelationships(); } else { continue; } if ($event->supporting_documents) { $supporting_documents = $event->supporting_documents; } else { $supporting_documents = array(); } for ($j = 1; $j <= $docsCount; $j++) { if ($glData["supporting_docs_meta" . $j]) { if (!$glData["supporting_docs_meta" . $j]['title']) { continue; } $document_form = document_form('new'); unset($document_form['doc_id']); $supporting_docs = new SupportingDocs(); $supporting_docs_meta = new SupportingDocsMeta(); $type = null; $doc_uuid = shn_create_uuid('doc'); $supporting_docs->doc_id = $doc_uuid; $supporting_docs_meta->doc_id = $doc_uuid; $supporting_docs->uri = ''; form_objects($document_form, $supporting_docs, $glData["supporting_docs_meta" . $j]); form_objects($document_form, $supporting_docs_meta, $glData["supporting_docs_meta" . $j]); $supporting_docs_meta->format = $type; $supporting_docs->Save(); $supporting_docs_meta->SaveAll(); $supporting_documents[] = $doc_uuid; } } if ($supporting_documents) { $event->supporting_documents = $supporting_documents; $event->SaveDocs(); } } $results[] = $row; $i++; } return $results; }
public function SavePicture() { if ($this->picture_doc == true && is_uploaded_file($_FILES['picture']['tmp_name'])) { $type = null; $uri = shn_files_store('picture', null, $type); if ($uri == null) { $uri = ''; } $document_form = document_form('new'); $supporting_docs = new SupportingDocs(); $supporting_docs_meta = new SupportingDocsMeta(); $pictureDoc = new SupportingDocEntity(SupportingDocEntity::generateTableName('picture')); $pictureDoc->record_number = $this->person_record_number; if ($_POST['picture_id'] != null) { $picture_id = $_POST['picture_id']; if ($uri != '') { $supporting_docs->doc_id = $picture_id; $supporting_docs->uri = $uri; $supporting_docs->_saved = true; form_objects($document_form, $supporting_docs); //$supporting_docs->Delete(); $supporting_docs->Save(); form_objects($document_form, $supporting_docs_meta); $supporting_docs_meta->title = "Picture"; $supporting_docs_meta->doc_id = $picture_id; $supporting_docs_meta->format = $type; $supporting_docs_meta->_saved = true; $supporting_docs_meta->Save(); $pictureDoc->doc_id = $picture_id; $pictureDoc->_saved = true; $pictureDoc->linked_by = $_SESSION['username']; $pictureDoc->Save(); } } else { $picture_id = shn_create_uuid('picture'); $supporting_docs->doc_id = $picture_id; $supporting_docs->uri = $uri; form_objects($document_form, $supporting_docs); $supporting_docs->Save(); form_objects($document_form, $supporting_docs_meta); $supporting_docs_meta->title = "Picture"; $supporting_docs_meta->doc_id = $picture_id; $supporting_docs_meta->format = $type; $supporting_docs_meta->Save(); $pictureDoc->doc_id = $picture_id; $pictureDoc->linked_by = $_SESSION['username']; $pictureDoc->Save(); } } }
/** * save() * Save the data in the VMPicture object, including image data, to the database. */ function save() { global $global; // generate a new UUID, if we need it if (empty($this->img_uuid)) { require_once $global['approot'] . 'inc/lib_uuid.inc'; $this->img_uuid = shn_create_uuid(); } Model::Model(); $this->dao->saveVMPicture($this); }
protected function save_intervention() { $intervention_form = intervention_form('new'); $intv = new Intervention(); $intv->intervention_record_number = shn_create_uuid('intv'); form_objects($intervention_form, $intv); if (trim($intv->victim) == '') { $intv->victim = null; } //var_dump($intv); $intv->SaveAll(); return $intv; }
public function init() { $this->image_id = shn_create_uuid("image"); }
public function init() { $this->voice_note_id = shn_create_uuid("voice_note"); }
function act_supporting_doc() { include_once APPROOT . 'inc/lib_form_util.inc'; include_once APPROOT . 'inc/lib_uuid.inc'; $this->supporting_doc_form = $supporting_doc_form; $this->pid = isset($_GET['pid']) && $_GET['pid'] != null ? $_GET['pid'] : $_SESSION['pid']; if ($this->pid != null) { $person_form = person_form('new'); $this->person_form = $person_form; $this->person = $this->person_information($this->pid, $this->person_form); $_SESSION['ppid'] = $this->pid; } if (isset($_POST['save'])) { $status = shn_form_validate($supporting_doc_form); if ($status) { $supporting_doc = new SupportingDocs(); $supporting_doc->doc_id = shn_create_uuid('document'); $supporting_doc->uri = 'www.respere.com'; $supporting_doc->Save(); $supporting_docmeta = new SupportingDocsMeta(); $supporting_docmeta->doc_id = $supporting_doc->doc_id; form_objects($supporting_doc_form, $supporting_docmeta); $supporting_docmeta->format = $this->findexts($_FILES['document']['name']); $supporting_docmeta->Save(); } } }
public function SaveGeometries() { if ($this->supporting_geometry == true) { $this->DeleteGeometries(); $this->loadGeometriesFromPost(); if (is_array($this->geometries)) { //$this->geometries = array_unique($this->geometries); foreach ($this->geometries as $key => $geometries) { $geometries = array_unique($geometries); foreach ($geometries as $geometry) { $geometryObject = new Geometry($this->entity); $geometryObject->geometry_record_number = shn_create_uuid('mlt_geometry'); $geometryObject->entity_id = $this->{$this->keyName}; //$field = Browse::getFieldByName($this->entity,$key); $geometryObject->field_name = $key; $geometryObject->geometry = $geometry; $geometryObject->Save(); } } } } }