/**
  * Check anti-CSRF protection
  */
 static function checkProtection()
 {
     if (!CAppUI::conf("csrf_protection") || strtoupper($_SERVER['REQUEST_METHOD']) != 'POST') {
         return;
     }
     if (!isset($_POST["csrf"])) {
         CAppUI::setMsg("CCSRF-no_token", UI_MSG_ERROR);
         return;
     }
     if (array_key_exists($_POST['csrf'], $_SESSION["tokens"])) {
         $token = $_SESSION['tokens'][$_POST['csrf']];
         if ($token["lifetime"] >= time()) {
             foreach ($token["fields"] as $_field => $_value) {
                 if (CValue::read($_POST, $_field) != $_value) {
                     CAppUI::setMsg("CCSRF-form_corrupted", UI_MSG_ERROR);
                     unset($_SESSION['tokens'][$_POST['csrf']]);
                     return;
                 }
             }
             //mbTrace("Le jeton est accepté !");
             unset($_SESSION['tokens'][$_POST['csrf']]);
         } else {
             CAppUI::setMsg("CCSRF-token_outdated", UI_MSG_ERROR);
             unset($_SESSION['tokens'][$_POST['csrf']]);
         }
         return;
     }
     CAppUI::setMsg("CCSRF-token_does_not_exist", UI_MSG_ERROR);
     return;
 }
 /**
  * @see parent::getHtmlValue()
  */
 function getHtmlValue($object, $smarty = null, $params = array())
 {
     $value = $object->{$this->fieldName};
     // Empty value: no paragraph
     if (!$value) {
         return "";
     }
     // Truncate case: no breakers but inline bullets instead
     if ($truncate = CValue::read($params, "truncate")) {
         $value = CMbString::truncate($value, $truncate === true ? null : $truncate);
         $value = CMbString::nl2bull($value);
         return CMbString::htmlSpecialChars($value);
     }
     // Markdown case: full delegation
     if ($this->markdown) {
         // In order to prevent from double escaping
         $content = CMbString::markdown(html_entity_decode($value));
         return "<div class='markdown'>{$content}</div>";
     }
     // Standard case: breakers and paragraph enhancers
     $text = "";
     $value = str_replace(array("\r\n", "\r"), "\n", $value);
     $paragraphs = preg_split("/\n{2,}/", $value);
     foreach ($paragraphs as $_paragraph) {
         if (!empty($_paragraph)) {
             $_paragraph = nl2br(CMbString::htmlSpecialChars($_paragraph));
             $text .= "<p>{$_paragraph}</p>";
         }
     }
     return $text;
 }
 function toMB($value, CHL7v2Field $field)
 {
     $parsed = $this->parseHL7($value, $field);
     // empty value
     if ($parsed === "") {
         return "";
     }
     // invalid value
     if ($parsed === false) {
         return;
     }
     return CValue::read($parsed, "hour", "00") . ":" . CValue::read($parsed, "minute", "00") . ":" . CValue::read($parsed, "second", "00");
 }
 function toHL7($value, CHL7v2Field $field)
 {
     $parsed = $this->parseMB($value, $field);
     // empty value
     if ($parsed === "") {
         return "";
     }
     // invalid value
     if ($parsed === false) {
         return;
     }
     return CValue::read($parsed, "year") . (CValue::read($parsed, "month") === "00" ? "" : CValue::read($parsed, "month")) . (CValue::read($parsed, "day") === "00" ? "" : CValue::read($parsed, "day")) . CValue::read($parsed, "hour") . CValue::read($parsed, "minute") . CValue::read($parsed, "second");
 }
 function toMB($value, CHL7v2Field $field)
 {
     $parsed = $this->parseHL7($value, $field);
     // empty value
     if ($parsed === "") {
         return "";
     }
     // invalid value
     if ($parsed === false) {
         return;
     }
     return CValue::read($parsed, "year") . "-" . CValue::read($parsed, "month", "00") . "-" . CValue::read($parsed, "day", "00");
 }
Exemple #6
0
 /**
  * Changes check list categories
  *
  * @param array $category_changes Categories changes
  *
  * @return void
  */
 private function changeCheckListCategories($category_changes)
 {
     // reverse because of the title changes
     $category_changes = array_reverse($category_changes);
     // Category changes
     foreach ($category_changes as $_change) {
         $cat_class = $_change[0];
         $cat_type = $_change[1];
         $cat_title = $_change[2];
         $cat_new_title = addslashes($_change[3]);
         $cat_new_desc = addslashes(CValue::read($_change, 4, null));
         $query = "UPDATE `daily_check_item_category` SET\r\n        `daily_check_item_category`.`title` = '{$cat_new_title}' ";
         if (isset($cat_new_desc)) {
             $query .= ", `daily_check_item_category`.`desc` = '{$cat_new_desc}' ";
         }
         $query .= "WHERE\r\n        `daily_check_item_category`.`target_class` = '{$cat_class}' AND\r\n        `daily_check_item_category`.`type` = '{$cat_type}' AND\r\n        `daily_check_item_category`.`title` = '{$cat_title}'";
         $this->addQuery($query);
     }
 }
 /**
  * Handle link/unlink patients message
  *
  * @param CHL7Acknowledgment $ack     Acknowledgment
  * @param CPatient           $patient Person
  * @param array              $data    Data
  *
  * @return string|void
  */
 function handle(CHL7Acknowledgment $ack, CPatient $patient, $data)
 {
     $exchange_hl7v2 = $this->_ref_exchange_hl7v2;
     $sender = $exchange_hl7v2->_ref_sender;
     $sender->loadConfigValues();
     $this->_ref_sender = $sender;
     if (count($data["PID"]) != 2) {
         return $exchange_hl7v2->setAckAR($ack, "E500", null, $patient);
     }
     foreach ($data["PID"] as $_PID) {
         $patientPI = CValue::read($_PID['personIdentifiers'], "PI");
         // Acquittement d'erreur : identifiants PI non fournis
         if (!$patientPI) {
             return $exchange_hl7v2->setAckAR($ack, "E100", null, $patient);
         }
     }
     $patient_1_PI = CValue::read($data["PID"][0]['personIdentifiers'], "PI");
     $patient_2_PI = CValue::read($data["PID"][1]['personIdentifiers'], "PI");
     $patient_1 = new CPatient();
     $patient_1->_IPP = $patient_1_PI;
     $patient_1->loadFromIPP($sender->group_id);
     // PI non connu (non fourni ou non retrouvé)
     if (!$patient_1->_id) {
         return $exchange_hl7v2->setAckAR($ack, "E501", null, $patient_1);
     }
     $patient_2 = new CPatient();
     $patient_2->_IPP = $patient_2_PI;
     $patient_2->loadFromIPP($sender->group_id);
     // PI non connu (non fourni ou non retrouvé)
     if (!$patient_2->_id) {
         return $exchange_hl7v2->setAckAR($ack, "E501", null, $patient_2);
     }
     $function_handle = "handle{$exchange_hl7v2->code}";
     if (!method_exists($this, $function_handle)) {
         return $exchange_hl7v2->setAckAR($ack, "E006", null, $patient);
     }
     return $this->{$function_handle}($ack, $patient_1, $patient_2, $data);
 }
 /**
  * Récupération de l'assuré
  *
  * @param DOMNode  $node      Node
  * @param CPatient $mbPatient Patient
  *
  * @return CPatient
  */
 static function getAssure(DOMNode $node, CPatient $mbPatient)
 {
     $xpath = new CHPrimXPath($node->ownerDocument);
     $immatriculation = $xpath->queryTextNode("hprim:immatriculation", $node);
     $mbPatient->matricule = $immatriculation;
     $mbPatient->assure_matricule = $immatriculation;
     $personne = $xpath->queryUniqueNode("hprim:personne", $node);
     if (!$personne) {
         return $mbPatient;
     }
     $sexe = $xpath->queryAttributNode("hprim:personne", $node, "sexe");
     $sexeConversion = array("M" => "m", "F" => "f");
     $mbPatient->assure_sexe = $sexeConversion[$sexe];
     $mbPatient->assure_nom = $xpath->queryTextNode("hprim:nomUsuel", $personne);
     $prenoms = $xpath->getMultipleTextNodes("hprim:prenoms/*", $personne);
     $mbPatient->assure_prenom = CMbArray::get($prenoms, 0);
     $mbPatient->assure_prenom_2 = CMbArray::get($prenoms, 1);
     $mbPatient->assure_prenom_3 = CMbArray::get($prenoms, 2);
     $mbPatient->assure_naissance = $xpath->queryTextNode("hprim:naissance", $personne);
     $elementDateNaissance = $xpath->queryUniqueNode("hprim:dateNaissance", $personne);
     $mbPatient->assure_naissance = $xpath->queryTextNode("hprim:date", $elementDateNaissance);
     $mbPatient->rang_beneficiaire = $xpath->queryTextNode("hprim:lienAssure", $node);
     $mbPatient->qual_beneficiaire = CValue::read(CPatient::$rangToQualBenef, $mbPatient->rang_beneficiaire);
     return $mbPatient;
 }
 /**
  * Get HL7 error code
  *
  * @return mixed
  */
 function getHL7Code()
 {
     return CValue::read(self::$errorMap, $this->code, 207);
 }
 /**
  * Get events for an object
  *
  * @param CMbObject|string $object                     Object or GUID
  * @param string           $event_name                 Event name
  * @param string           $type                       Type: required, disabled or conditional
  * @param array            $exclude_ex_class_event_ids List of class events' ids
  *
  * @return CExClassEvent[]
  */
 static function getForObject($object, $event_name, $type = "required", $exclude_ex_class_event_ids = array())
 {
     static $events_cache = array();
     if (is_string($object)) {
         $object = CMbObject::loadFromGuid($object);
     }
     if ($type == "required" && !CValue::read($object->_spec->events[$event_name], "auto", false)) {
         return array();
     }
     $ex_class_event = new self();
     $group_id = CGroups::loadCurrent()->_id;
     $ds = $ex_class_event->_spec->ds;
     $key = "{$object->_class}/{$event_name}/{$group_id}/{$type}";
     if (isset($events_cache[$key])) {
         $ex_class_events = $events_cache[$key];
     } else {
         $where = array("ex_class_event.host_class" => $ds->prepare("=%", $object->_class), "ex_class_event.event_name" => $ds->prepare("=%", $event_name), "ex_class_event.disabled" => $ds->prepare("=%", 0), "ex_class.conditional" => $ds->prepare("=%", 0), $ds->prepare("ex_class.group_id = % OR group_id IS NULL", $group_id));
         $ljoin = array("ex_class" => "ex_class.ex_class_id = ex_class_event.ex_class_id");
         switch ($type) {
             case "disabled":
                 $where["ex_class_event.disabled"] = 1;
                 break;
             case "conditional":
                 $where["ex_class.conditional"] = 1;
                 break;
         }
         /** @var CExClassEvent[] $ex_class_events */
         $ex_class_events = $ex_class_event->loadList($where, null, null, null, $ljoin);
         $events_cache[$key] = $ex_class_events;
     }
     foreach ($ex_class_events as $_id => $_ex_class_event) {
         if (isset($exclude_ex_class_event_ids[$_id]) || !$_ex_class_event->checkConstraints($object)) {
             unset($ex_class_events[$_id]);
         } else {
             $_ex_class_event->_host_object = $object;
         }
     }
     return $ex_class_events;
 }
Exemple #11
0
 /**
  * @see parent::onAfterInstanciation()
  */
 function onAfterInstanciation()
 {
     $_ex_class_id = CValue::read($this->request, "_ex_class_id");
     $this->_obj->setExClass($_ex_class_id);
     $this->_old->setExClass($_ex_class_id);
 }
 /**
  * Fill other identifiers
  *
  * @param array         &$identifiers Identifiers
  * @param CPatient      $patient      Person
  * @param CInteropActor $actor        Interop actor
  *
  * @return null
  */
 function fillOtherIdentifiers(&$identifiers, CPatient $patient, CInteropActor $actor = null)
 {
     if (CValue::read($actor->_configs, "send_own_identifier")) {
         $identifiers[] = array($patient->_id, null, null, $this->getAssigningAuthority("mediboard"), "RI");
     }
     if (!CValue::read($actor->_configs, "send_self_identifier")) {
         return;
     }
     if (!($idex_actor = $actor->getIdex($patient)->id400)) {
         return;
     }
     $identifiers[] = array($idex_actor, null, null, $this->getAssigningAuthority("actor", null, $actor));
 }
Exemple #13
0
    }
}
// Get the user's style
$uistyle = CAppUI::pref("UISTYLE");
if (!file_exists("style/{$uistyle}/templates/header.tpl")) {
    $uistyle = "mediboard";
}
CJSLoader::$files = array(CJSLoader::getLocaleFile(), "includes/javascript/usertiming.js", "includes/javascript/performance.js", "includes/javascript/printf.js", "includes/javascript/stacktrace.js", "lib/scriptaculous/lib/prototype.js", "lib/scriptaculous/src/scriptaculous.js", "includes/javascript/console.js", "lib/scriptaculous/src/builder.js", "lib/scriptaculous/src/effects.js", "lib/scriptaculous/src/dragdrop.js", "lib/scriptaculous/src/controls.js", "lib/scriptaculous/src/slider.js", "lib/scriptaculous/src/sound.js", "includes/javascript/prototypex.js", "includes/javascript/date.js", "lib/datepicker/datepicker.js", "lib/datepicker/datepicker-locale-fr_FR.js", "lib/livepipe/livepipe.js", "lib/livepipe/tabs.js", "lib/livepipe/window.js", "includes/javascript/treeview.js", "lib/flotr/flotr.js", "lib/flotr/lib/canvastext.js", "lib/jsExpressionEval/parser.js", "lib/store.js/store.js", "includes/javascript/common.js", "includes/javascript/functions.js", "includes/javascript/tooltip.js", "includes/javascript/controls.js", "includes/javascript/cookies.js", "includes/javascript/url.js", "includes/javascript/forms.js", "includes/javascript/checkForms.js", "includes/javascript/aideSaisie.js", "includes/javascript/exObject.js", "includes/javascript/tag.js", "includes/javascript/mbObject.js", "includes/javascript/bowser.min.js", "includes/javascript/configuration.js", "includes/javascript/plugin.js", "includes/javascript/xdr.js", "includes/javascript/usermessage.js", "includes/javascript/jscolor.js", "lib/requirejs/require.js", "lib/flot/jquery.min.js", "includes/javascript/no_conflicts.js", "lib/flot/jquery.flot.min.js", "lib/flot/jquery.flot.JUMlib.js", "lib/flot/jquery.flot.mouse.js", "lib/flot/jquery.flot.symbol.min.js", "lib/flot/jquery.flot.crosshair.min.js", "lib/flot/jquery.flot.resize.min.js", "lib/flot/jquery.flot.stack.min.js", "lib/flot/jquery.flot.bandwidth.js", "lib/flot/jquery.flot.gantt.js", "lib/flot/jquery.flot.time.min.js", "lib/flot/jquery.flot.pie.min.js");
$support = "modules/support/javascript/support.js";
if (file_exists($support) && CModule::getActive("support")) {
    CJSLoader::$files[] = $support;
}
$applicationVersion = CApp::getReleaseInfo();
// Check if we are logged in
if (!CAppUI::$instance->user_id) {
    $redirect = CValue::get("logout") ? "" : CValue::read($_SERVER, "QUERY_STRING");
    $_SESSION["locked"] = null;
    // HTTP 403 Forbidden header when RAW response expected
    if ($suppressHeaders && !$ajax) {
        header("HTTP/1.0 403 Forbidden");
        CApp::rip();
    }
    // Ajax login alert
    if ($ajax) {
        $tplAjax = new CSmartyDP("modules/system");
        $tplAjax->assign("performance", CApp::$performance);
        $tplAjax->display("ajax_errors.tpl");
    } else {
        $tplLogin = new CSmartyDP("style/{$uistyle}");
        $tplLogin->assign("localeInfo", $locale_info);
        // Favicon
 /**
  * Handle event
  *
  * @param CHL7Acknowledgment $ack        Acknowledgement
  * @param CPatient           $newPatient Person
  * @param array              $data       Nodes data
  *
  * @return null|string
  */
 function handle(CHL7Acknowledgment $ack, CPatient $newPatient, $data)
 {
     // Traitement du message des erreurs
     $comment = $warning = "";
     $exchange_hl7v2 = $this->_ref_exchange_hl7v2;
     $exchange_hl7v2->_ref_sender->loadConfigValues();
     $sender = $exchange_hl7v2->_ref_sender;
     foreach ($data["merge"] as $_data_merge) {
         $data = $_data_merge;
         $mbPatient = new CPatient();
         $mbPatientElimine = new CPatient();
         $patientPI = CValue::read($data['personIdentifiers'], "PI");
         $patientRI = CValue::read($data['personIdentifiers'], "RI");
         $patientEliminePI = CValue::read($data['personElimineIdentifiers'], "PI");
         $patientElimineRI = CValue::read($data['personElimineIdentifiers'], "RI");
         // Acquittement d'erreur : identifiants RI et PI non fournis
         if (!$patientRI && !$patientPI || !$patientElimineRI && !$patientEliminePI) {
             return $exchange_hl7v2->setAckAR($ack, "E100", null, $newPatient);
         }
         $idexPatient = CIdSante400::getMatch("CPatient", $sender->_tag_patient, $patientPI);
         if ($mbPatient->load($patientRI)) {
             if ($idexPatient->object_id && $mbPatient->_id != $idexPatient->object_id) {
                 $comment = "L'identifiant source fait référence au patient : {$idexPatient->object_id}";
                 $comment .= " et l'identifiant cible au patient : {$mbPatient->_id}.";
                 return $exchange_hl7v2->setAckAR($ack, "E130", $comment, $newPatient);
             }
         }
         if (!$mbPatient->_id) {
             $mbPatient->load($idexPatient->object_id);
         }
         $idexPatientElimine = CIdSante400::getMatch("CPatient", $sender->_tag_patient, $patientEliminePI);
         if ($mbPatientElimine->load($patientElimineRI)) {
             if ($idexPatientElimine->object_id && $mbPatientElimine->_id != $idexPatientElimine->object_id) {
                 $comment = "L'identifiant source fait référence au patient : {$idexPatientElimine->object_id}";
                 $comment .= "et l'identifiant cible au patient : {$mbPatientElimine->_id}.";
                 return $exchange_hl7v2->setAckAR($ack, "E131", $comment, $newPatient);
             }
         }
         if (!$mbPatientElimine->_id) {
             $mbPatientElimine->load($idexPatientElimine->object_id);
         }
         if (!$mbPatient->_id || !$mbPatientElimine->_id) {
             $comment = !$mbPatient->_id ? "Le patient {$mbPatient->_id} est inconnu dans Mediboard." : "Le patient {$mbPatientElimine->_id} est inconnu dans Mediboard.";
             return $exchange_hl7v2->setAckAR($ack, "E120", $comment, $newPatient);
         }
         // Passage en trash de l'IPP du patient a éliminer
         $newPatient->trashIPP($idexPatientElimine);
         if ($mbPatient->_id == $mbPatientElimine->_id) {
             return $exchange_hl7v2->setAckAA($ack, "I104", null, $newPatient);
         }
         $patientsElimine_array = array($mbPatientElimine);
         $first_patient_id = $mbPatient->_id;
         $checkMerge = $mbPatient->checkMerge($patientsElimine_array);
         // Erreur sur le check du merge
         if ($checkMerge) {
             $comment = "La fusion de ces deux patients n'est pas possible à cause des problèmes suivants : {$checkMerge}";
             return $exchange_hl7v2->setAckAR($ack, "E121", $comment, $newPatient);
         }
         $mbPatientElimine_id = $mbPatientElimine->_id;
         /** @todo mergePlainFields resets the _id */
         $mbPatient->_id = $first_patient_id;
         // Notifier les autres destinataires
         $mbPatient->_eai_sender_guid = $sender->_guid;
         $mbPatient->_merging = CMbArray::pluck($patientsElimine_array, "_id");
         if ($msg = $mbPatient->merge($patientsElimine_array)) {
             return $exchange_hl7v2->setAckAR($ack, "E103", $msg, $mbPatient);
         }
         $mbPatient->_mbPatientElimine_id = $mbPatientElimine_id;
         $comment = CEAIPatient::getComment($mbPatient, $mbPatientElimine);
     }
     return $exchange_hl7v2->setAckAA($ack, "I103", $comment, $mbPatient);
 }
<?php

/**
 * $Id$
 *
 * @package    Mediboard
 * @subpackage developpement
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
CCanDo::checkRead();
$locales = CAppUI::flattenCachedLocales(CAppUI::$lang);
$tabs = array();
foreach ($modules = CModule::getInstalled() as $module) {
    CAppUI::requireModuleFile($module->mod_name, "index");
    if (is_array($module->_tabs)) {
        foreach ($module->_tabs as $tab) {
            $tabs[$tab]["name"] = "mod-{$module->mod_name}-tab-{$tab}";
            $tabs[$tab]["locale"] = CValue::read($locales, $tabs[$tab]["name"]);
        }
    }
}
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("module", $modules);
$smarty->assign("tabs", $tabs);
$smarty->display("mnt_module_actions.tpl");
<?php

/**
 * $Id: ajax_edit_ex_constraint.php 17759 2013-01-14 11:27:24Z phenxdesign $
 *
 * @package    Mediboard
 * @subpackage forms
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision: 17759 $
 */
CCanDo::checkEdit();
$ex_constraint_id = CValue::get("ex_constraint_id");
$ex_class_event_id = CValue::get("ex_class_event_id");
$ex_constraint = new CExClassConstraint();
if (!$ex_constraint->load($ex_constraint_id)) {
    $ex_constraint->ex_class_event_id = $ex_class_event_id;
} else {
    $ex_constraint->loadRefsNotes();
}
$ex_constraint->loadTargetObject();
$event = $ex_constraint->loadRefExClassEvent();
$options = $event->getHostClassOptions();
$host_field_suggestions = CValue::read($options, "hostfield_sugg", array());
$list = $event->buildHostFieldsList();
$smarty = new CSmartyDP();
$smarty->assign("ex_constraint", $ex_constraint);
$smarty->assign("class_fields", $list);
$smarty->assign("host_field_suggestions", $host_field_suggestions);
$smarty->display("inc_edit_ex_constraint.tpl");
 /**
  * Build NK1 segement
  *
  * @param CHL7v2Event $event Event
  *
  * @return null
  */
 function build(CHL7v2Event $event)
 {
     parent::build($event);
     $correspondant = $this->correspondant;
     $message = $event->message;
     // NK1-1: Set ID - NK1 (SI)
     $data[] = $this->set_id;
     // NK1-2: NK Name (XPN) (optional repeating)
     $data[] = $this->getXPN($correspondant, $event->_receiver);
     // NK1-3: Relationship (CE) (optional)
     // Table 0063 - Relationship
     $relationships = array(CHL7v2TableEntry::mapTo("63", $correspondant->parente));
     if ($correspondant->parente == "autre") {
         $relationships[] = $correspondant->parente_autre;
     }
     $data[] = array($relationships);
     // NK1-4: Address (XAD) (optional repeating)
     $linesAdress = explode("\n", $correspondant->adresse, 2);
     $data[] = array(array(CValue::read($linesAdress, 0), str_replace("\n", $message->componentSeparator, CValue::read($linesAdress, 1)), $correspondant->ville, null, $correspondant->cp));
     // NK1-5: Phone Number (XTN) (optional repeating)
     // Table - 0201
     // ASN - Answering Service Number
     // BPN - Beeper Number
     // EMR - Emergency Number
     // NET - Network (email) Address
     // ORN - Other Residence Number
     // PRN - Primary Residence Number
     // VHN - Vacation Home Number
     // WPN - Work Number
     // Table - 0202
     // BP       - Beeper
     // CP       - Cellular Phone
     // FX       - Fax
     // Internet - Internet Address: Use Only If Telecommunication Use Code Is NET
     // MD       - Modem
     // PH       - Telephone
     // TDD      - Telecommunications Device for the Deaf
     // TTY      - Teletypewriter
     $phones = array();
     if ($correspondant->tel) {
         $phones[] = array(null, "PRN", "PH", null, null, null, null, null, null, null, null, $correspondant->tel);
     }
     if ($correspondant->mob) {
         $phones[] = array(null, "PRN", "CP", null, null, null, null, null, null, null, null, $correspondant->mob);
     }
     if ($correspondant->email) {
         $phones[] = array(null, "NET", "Internet", $correspondant->email);
     }
     $data[] = $phones;
     // NK1-6: Business Phone Number (XTN) (optional repeating)
     $data[] = null;
     // NK1-7: Contact Role (CE) (optional)
     // Table - 0131
     $data[] = array(array(CHL7v2TableEntry::mapTo("131", $correspondant->relation), $correspondant->relation == "autre" ? $correspondant->relation_autre : null));
     // NK1-8: Start Date (DT) (optional)
     $data[] = null;
     // NK1-9: End Date (DT) (optional)
     $data[] = null;
     // NK1-10: Next of Kin / Associated Parties Job Title (ST) (optional)
     $data[] = null;
     // NK1-11: Next of Kin / Associated Parties Job Code/Class (JCC) (optional)
     $data[] = null;
     // NK1-12: Next of Kin / Associated Parties Employee Number (CX) (optional)
     $data[] = null;
     // NK1-13: Organization Name - NK1 (XON) (optional repeating)
     $data[] = null;
     // NK1-14: Marital Status (CE) (optional)
     $data[] = null;
     // NK1-15: Administrative Sex (IS) (optional)
     $data[] = null;
     // NK1-16: Date/Time of Birth (TS) (optional)
     $data[] = null;
     // NK1-17: Living Dependency (IS) (optional repeating)
     $data[] = null;
     // NK1-18: Ambulatory Status (IS) (optional repeating)
     $data[] = null;
     // NK1-19: Citizenship (CE) (optional repeating)
     $data[] = null;
     // NK1-20: Primary Language (CE) (optional)
     $data[] = null;
     // NK1-21: Living Arrangement (IS) (optional)
     $data[] = null;
     // NK1-22: Publicity Code (CE) (optional)
     $data[] = null;
     // NK1-23: Protection Indicator (ID) (optional)
     $data[] = null;
     // NK1-24: Student Indicator (IS) (optional)
     $data[] = null;
     // NK1-25: Religion (CE) (optional)
     // Interdit IHE France
     $data[] = null;
     // NK1-26: Mother's Maiden Name (XPN) (optional repeating)
     $data[] = null;
     // NK1-27: Nationality (CE) (optional)
     $data[] = null;
     // NK1-28: Ethnic Group (CE) (optional repeating)
     // Interdit IHE France
     $data[] = null;
     // NK1-29: Contact Reason (CE) (optional repeating)
     $data[] = null;
     // NK1-30: Contact Person's Name (XPN) (optional repeating)
     $data[] = null;
     // NK1-31: Contact Person's Telephone Number (XTN) (optional repeating)
     $data[] = null;
     // NK1-32: Contact Person's Address (XAD) (optional repeating)
     $data[] = null;
     // NK1-33: Next of Kin/Associated Party's Identifiers (CX) (optional repeating)
     $data[] = null;
     // NK1-34: Job Status (IS) (optional)
     $data[] = null;
     // NK1-35: Race (CE) (optional repeating)
     // Interdit IHE France
     $data[] = null;
     // NK1-36: Handicap (IS) (optional)
     $data[] = null;
     // NK1-37: Contact Person Social Security Number (ST) (optional)
     $data[] = null;
     // NK1-38: Next of Kin Birth Place (ST) (optional)
     $data[] = null;
     // NK1-39: VIP Indicator (IS) (optional)
     $data[] = null;
     $this->fill($data);
 }
Exemple #18
0
$rpu = new CRPU();
$sejour = new CSejour();
$total = 0;
$data = array();
switch ($axe) {
    default:
        $axe = "age";
        // Sur le patient
    // Sur le patient
    case "age":
        $data[$axe] = array('options' => array('title' => utf8_encode('Par tranche d\'âge')), 'series' => array());
        $ljoin['patients'] = 'patients.patient_id = sejour.patient_id';
        $series =& $data[$axe]['series'];
        $age_areas = array(0, 1, 15, 75, 85);
        foreach ($age_areas as $key => $age) {
            $limits = array($age, CValue::read($age_areas, $key + 1));
            $label = $limits[1] ? "{$limits['0']} - " . ($limits[1] - 1) : ">= {$limits['0']}";
            $min = $limits[0] * 365.25;
            $max = $limits[1] * 365.25;
            $where[100] = "TO_DAYS(sejour.entree) - TO_DAYS(patients.naissance) >= {$min}";
            if ($limits[1] != null) {
                $where[101] = "TO_DAYS(sejour.entree) - TO_DAYS(patients.naissance) < {$max}";
            } else {
                unset($where[101]);
            }
            $series[$key] = array('data' => array(), 'label' => "{$label} ans");
            foreach ($dates as $i => $_date) {
                $_date_next = CMbDT::date("+1 {$period}", $_date);
                $where['sejour.entree'] = "BETWEEN '{$_date}' AND '{$_date_next}'";
                $count = $sejour->countList($where, null, $ljoin);
                $total += $count;
 /**
  * Get AN number
  *
  * @param CInteropSender $sender Sender
  * @param array          $data   Data
  *
  * @return string
  */
 function getVenueAN($sender, $data)
 {
     switch ($sender->_configs["handle_NDA"]) {
         case 'PV1_19':
             return CValue::read($data['admitIdentifiers'], "AN");
         default:
             return CValue::read($data['personIdentifiers'], "AN");
     }
 }
 $ds = $tag2->_spec->ds;
 $where = array("name" => $ds->prepare("=%", $line["tag_name_2"]), "object_class" => $ds->prepare("=%", $object_class));
 $tag2->loadObject($where);
 if (!$tag2->_id) {
     $tag2->name = $line["tag_name_2"];
     $tag2->object_class = $object_class;
     $tag2->parent_id = $tag1->_id;
     if ($msg = $tag2->store()) {
         CAppUI::setMsg("Ligne {$line_number} : {$msg}", UI_MSG_WARNING);
         continue;
     } else {
         CAppUI::setMsg("{$tag2->_class}-msg-create", UI_MSG_OK);
     }
 }
 // CONCEPT
 $concept_prop = CValue::read($prop_map, CMbString::lower($line["concept_type"]));
 if (!$concept_prop) {
     CAppUI::setMsg("Ligne {$line_number} : type de concept invalide : <strong>{$line['concept_type']}</strong>", UI_MSG_WARNING);
     continue;
 }
 // If list name provided, it needs to exist
 if ($line["list_name"]) {
     $_list = new CExList();
     $_list->name = $line["list_name"];
     if (!$_list->loadMatchingObject()) {
         CAppUI::setMsg("Ligne {$line_number} : nom de liste introuvable : <strong>{$line['list_name']}</strong>", UI_MSG_WARNING);
         continue;
     }
 }
 $concept = new CExConcept();
 $ds = $concept->_spec->ds;
 /**
  * Détermine la couleur à afficher en fonction des seuils d'alerte définis dans les paramètres
  *
  * @param float  $value         La valeur à vérifier
  * @param array  $params        Les paramètres concernés
  * @param string $default_color Couleur par défaut
  *
  * @return string
  */
 static function getColor($value, $params, $default_color = "#4DA74D")
 {
     $color = CValue::read($params, "color", $default_color);
     // Low value alert
     if (isset($params["alert_low"])) {
         list($_low, $_low_color) = $params["alert_low"];
         if ($value < $_low) {
             $color = $_low_color;
         }
     }
     // High value alert
     if (isset($params["alert_high"])) {
         list($_high, $_high_color) = $params["alert_high"];
         if ($value > $_high) {
             $color = $_high_color;
         }
     }
     return $color;
 }
 /**
  * Convert an external DB value to MB value
  *
  * @param array     $hash   The associative array containing all the data
  * @param string    $from   External DB field name
  * @param CMbObject $object The MB Object to get its specs
  *
  * @return string The value
  */
 function convertValue($hash, $from, $object)
 {
     $to = $this->_map[$from];
     $src = $this->convertEncoding($hash[$from]);
     if (is_array($to)) {
         return CValue::read($to[1], $src, CValue::read($to, 2));
     } else {
         $v = $src;
         $spec = $object->_specs[$to];
         switch (true) {
             case $spec instanceof CDateSpec:
             case $spec instanceof CBirthDateSpec:
                 return reset(explode(" ", $v));
             case $spec instanceof CTimeSpec:
                 return end(explode(" ", $v));
             case $spec instanceof CNumSpec:
             case $spec instanceof CNumcharSpec:
             case $spec instanceof CPhoneSpec:
                 return preg_replace("/[^0-9]/", "", $v);
         }
         return $v;
     }
 }
 /**
  * Recherche du séjour par différents identifiants possibles
  *
  * @param CSejour $newVenue Admit
  * @param array   $data     Datas
  *
  * @return bool
  */
 function admitFound(CSejour $newVenue, $data)
 {
     $sender = $this->_ref_sender;
     $venueRI = CValue::read($data['admitIdentifiers'], "RI");
     //$venueRISender = CValue::read($data['admitIdentifiers'], "RI_Sender");
     $venueVN = CValue::read($data['admitIdentifiers'], "VN");
     //$venueNPA      = CValue::read($data['admitIdentifiers'], "NPA");
     $venueAN = $this->getVenueAN($sender, $data);
     $NDA = new CIdSante400();
     if ($venueAN) {
         $NDA = CIdSante400::getMatch("CSejour", $sender->_tag_sejour, $venueAN);
     }
     if ($NDA->_id) {
         $newVenue->load($NDA->object_id);
         return true;
     }
     if ($newVenue->load($venueRI)) {
         // Si on retrouve le séjour par notre identifiant mais qu'on reçoit un NDA
         CEAISejour::storeNDA($NDA, $newVenue, $sender);
         return true;
     }
     if ($venueVN) {
         return $this->getSejourByVisitNumber($newVenue, $data);
     }
     return false;
 }
 /**
  * Compute stock balance
  *
  * @param CProduct[] $products Products
  * @param CService[] $services Services
  * @param int        $year     Year
  * @param int        $month    Month
  *
  * @return array
  */
 static function computeBalance(array $products, array $services, $year, $month = null)
 {
     $flows = array();
     // YEAR //////////
     $year_flows = array("in" => array(), "out" => array());
     $start = CMbDT::date(null, "{$year}-01-01");
     self::fillFlow($year_flows, $products, 12, $start, "MONTH", $services);
     $flows["year"] = array($year_flows, "%b", "Bilan annuel", "graph" => self::getFlowGraph($year_flows, "Bilan annuel", $services));
     // MONTH //////////
     if ($month) {
         $month_flows = array("in" => array(), "out" => array());
         $start = CMbDT::date(null, "{$year}-{$month}-01");
         self::fillFlow($month_flows, $products, CMbDT::transform("+1 MONTH -1 DAY", $start, "%d"), $start, "DAY", $services);
         $flows["month"] = array($month_flows, "%d", "Bilan mensuel", "graph" => self::getFlowGraph($month_flows, "Bilan mensuel", $services));
     }
     // Balance des stocks ////////////////
     $balance = array("in" => $flows["year"][0]["in"], "out" => array(), "diff" => array());
     $start = CMbDT::date(null, "{$year}-01-01");
     for ($i = 0; $i < 12; $i++) {
         $from = CMbDT::date("+{$i} MONTH", $start);
         $to = CMbDT::date("+1 MONTH", $from);
         $balance["in"][$from] = array(0, 0);
         $balance["out"][$from] = array(0, 0);
         $supply_multiple = self::getSupplyMultiple($products, $from, $to);
         $consum_multiple = self::getConsumptionMultipleProducts($products, $from, $to, null, false);
         /** @var CProduct $_product */
         foreach ($products as $_product) {
             $supply = CValue::read($supply_multiple, $_product->_id, 0);
             //$supply = $_product->getSupply($from, $to);
             $consum = CValue::read($consum_multiple, $_product->_id, 0);
             //$consum = $_product->getConsumption($from, $to, null, false);
             $coeff = 1;
             $ref = reset($_product->loadRefsReferences(true));
             if ($ref) {
                 $coeff = $ref->price;
             }
             $balance["in"][$from][0] += $supply;
             $balance["in"][$from][1] += $supply * $coeff;
             $balance["out"][$from][0] += $consum;
             $balance["out"][$from][1] += $consum * $coeff;
         }
     }
     $cumul = 0;
     $cumul_price = 0;
     foreach ($balance["in"] as $_date => $_balance) {
         $diff = $balance["in"][$_date][0] - $balance["out"][$_date][0];
         $diff_price = $balance["in"][$_date][1] - $balance["out"][$_date][1];
         $balance["diff"][$_date][0] = $diff + $cumul;
         $balance["diff"][$_date][1] = $diff_price + $cumul_price;
         $cumul += $diff;
         $cumul_price += $diff_price;
     }
     $balance = array_map_recursive(array("CProduct", "round2"), $balance);
     $options = CFlotrGraph::merge("bars", array("title" => "Rotation des stocks", "legend" => array("show" => true), "xaxis" => array("ticks" => array()), "yaxis" => array("min" => null, "title" => utf8_encode("Valeur (euro)")), "y2axis" => array("min" => null)));
     $graph = array("data" => array(), "options" => $options);
     $params = array("in" => array("label" => "Entrée", "color" => "#4DA74D"), "out" => array("label" => "Sortie", "color" => "#CB4B4B"), "diff" => array("label" => "Cumul", "color" => "#00A8F0"));
     foreach ($balance as $_type => $_data) {
         $data = array("data" => array(), "label" => utf8_encode($params[$_type]["label"]), "color" => $params[$_type]["color"]);
         if ($_type == "diff") {
             $data["lines"]["show"] = true;
             $data["bars"]["show"] = false;
             $data["points"]["show"] = true;
             $data["mouse"]["track"] = true;
             //$data["yaxis"] = 2;
         }
         if (empty($graph["options"]["xaxis"]["ticks"])) {
             foreach ($_data as $_date => $_values) {
                 if ($_date == "total") {
                     continue;
                 }
                 $graph["options"]["xaxis"]["ticks"][] = array(count($graph["options"]["xaxis"]["ticks"]), $_date);
             }
         }
         foreach ($_data as $_date => $_values) {
             if ($_date == "total") {
                 continue;
             }
             $v = $_type === "out" ? -$_values[1] : $_values[1];
             $data["data"][] = array(count($data["data"]), $v);
         }
         $graph["data"][] = $data;
     }
     $balance["graph"] = $graph;
     return array($flows, $balance, "flows" => $flows, "balance" => $balance);
 }
 /**
  * Build PV1 segement
  *
  * @param CHL7v2Event $event Event
  *
  * @return null
  */
 function build(CHL7v2Event $event)
 {
     parent::build($event);
     $receiver = $event->_receiver;
     $group = $receiver->_ref_group;
     $sejour = $this->sejour;
     $data = array();
     // PV1-1: Set ID - PV1 (SI) (optional)
     $data[] = $this->set_id;
     // PV1-2: Patient Class (IS)
     // Table - 0004
     // E - Emergency - Passage aux Urgences - Arrivée aux urgences
     // I - Inpatient - Hospitalisation
     // N - Not Applicable - Non applicable -
     // O - Outpatient - Actes et consultation externe
     // R - Recurring patient - Séances
     // Cas de la transaction ITI-30 "Patient Identity Field"
     if (!$sejour) {
         $data[] = "N";
         $this->fill($data);
         return;
     }
     $data[] = CHL7v2TableEntry::mapTo("4", $sejour->type);
     // PV1-3: Assigned Patient Location (PL) (optional)
     $data[] = $this->getPL($receiver, $sejour, $this->curr_affectation);
     // PV1-4: Admission Type (IS) (optional)
     // Table - 0007
     // C  - Confort (chirurgie esthétique)
     // L  - Accouchement maternité
     // N  - Nouveau né
     // R  - Routine (par défaut)
     // U  - Caractère d'urgence aigue du problème quel que soit le service d'entrée
     // RM - Rétrocession du médicament
     // IE - Prestation inter-établissements
     $naissance = new CNaissance();
     $naissance->sejour_enfant_id = $sejour->_id;
     $naissance->loadMatchingObject();
     // Cas d'une naissance
     if ($naissance->_id) {
         $data[] = "N";
     } elseif ($sejour->type_pec == "O") {
         $data[] = "L";
     } else {
         $data[] = "R";
     }
     // PV1-5: Preadmit Number (CX) (optional)
     if ($receiver->_configs["build_PV1_5"] == "none") {
         $data[] = null;
     } else {
         if (CHL7v2Message::$build_mode == "simple") {
             $data[] = array($sejour->_id);
         } else {
             $sejour->loadNPA($group->_id);
             $data[] = $sejour->_NPA ? array(array($sejour->_NPA, null, null, $this->getAssigningAuthority("FINESS", $group->finess), "RI")) : null;
         }
     }
     // PV1-6: Prior Patient Location (PL) (optional)
     $data[] = $this->getPreviousPL($receiver, $sejour);
     // PV1-7: Attending Doctor (XCN) (optional repeating)
     $sejour->loadRefPraticien();
     $data[] = $this->getXCN($sejour->_ref_praticien, $receiver);
     // PV1-8: Referring Doctor (XCN) (optional repeating)
     $data[] = $sejour->adresse_par_prat_id ? $this->getXCN($sejour->loadRefAdresseParPraticien(), $receiver) : null;
     // PV1-9: Consulting Doctor (XCN) (optional repeating)
     $data[] = null;
     // PV1-10: Hospital Service (IS) (optional)
     $data[] = $this->getPV110($receiver, $sejour, $this->curr_affectation);
     // PV1-11: Temporary Location (PL) (optional)
     if ($receiver->_configs["build_PV1_11"] == "uf_medicale") {
         $affectation_id = isset($this->curr_affectation->_id) ? $this->curr_affectation->_id : null;
         $ufs = $sejour->getUFs(null, $affectation_id);
         $uf_medicale = isset($ufs["medicale"]) ? $ufs["medicale"] : null;
         if (isset($uf_medicale->_id)) {
             $data[] = array(array($uf_medicale->code));
         } else {
             $data[] = null;
         }
     } else {
         $data[] = null;
     }
     // PV1-12: Preadmit Test Indicator (IS) (optional)
     $data[] = null;
     // PV1-13: Re-admission Indicator (IS) (optional)
     $data[] = null;
     // PV1-14: Admit Source (IS) (optional)
     $data[] = $this->getPV114($receiver, $sejour);
     // PV1-15: Ambulatory Status (IS) (optional repeating)
     $data[] = null;
     // PV1-16: VIP Indicator (IS) (optional)
     // Table - 0099
     // P - Public
     // I - Incognito
     $data[] = $sejour->loadRefPatient()->vip ? "I" : "P";
     // PV1-17: Admitting Doctor (XCN) (optional repeating)
     if ($receiver->_configs["build_PV1_17"] == "none") {
         $data[] = null;
     } else {
         $data[] = $this->getXCN($sejour->_ref_praticien, $receiver);
     }
     // PV1-18: Patient Type (IS) (optional)
     $data[] = null;
     // PV1-19: Visit Number (CX) (optional)
     $sejour->loadNDA($group->_id);
     $identifiers = array();
     $NDA = $sejour->_NDA;
     if (!$sejour->_NDA && !CValue::read($receiver->_configs, "send_not_master_NDA")) {
         $NDA = "===NDA_MISSING===";
     }
     if ($receiver->_configs["build_PV1_19"] == "simple") {
         $identifiers[] = $NDA;
     } else {
         if ($receiver->_configs["build_NDA"] == "PV1_19") {
             $identifiers[] = $NDA ? array($NDA, null, null, $this->getAssigningAuthority("FINESS", $group->finess), "AN") : array();
         } else {
             /* @todo Gestion des séances */
             $identifiers[] = array($sejour->_id, null, null, $this->getAssigningAuthority("mediboard"), "RI");
         }
         // Ajout des identifiants des acteurs d'intégration
         $this->fillActorsIdentifiers($identifiers, $sejour, $receiver);
     }
     $data[] = $identifiers;
     // PV1-20: Financial Class (FC) (optional repeating)
     $data[] = $sejour->loadRefPrestation()->code;
     // PV1-21: Charge Price Indicator (IS) (optional)
     // Table - 0032
     $data[] = $sejour->loadRefChargePriceIndicator()->code;
     // PV1-22: Courtesy Code (IS) (optional)
     // Table - 0045
     // Y - Demande de chambre particulière
     // N - Pas de demande de chambre particulière
     $data[] = $sejour->chambre_seule ? "Y" : "N";
     // PV1-23: Credit Rating (IS) (optional)
     $data[] = null;
     // PV1-24: Contract Code (IS) (optional repeating)
     $data[] = null;
     // PV1-25: Contract Effective Date (DT) (optional repeating)
     $data[] = null;
     // PV1-26: Contract Amount (NM) (optional repeating)
     $data[] = $this->getPV126($receiver, $sejour);
     // PV1-27: Contract Period (NM) (optional repeating)
     $data[] = null;
     // PV1-28: Interest Code (IS) (optional)
     $data[] = null;
     // PV1-29: Transfer to Bad Debt Code (IS) (optional)
     $data[] = null;
     // PV1-30: Transfer to Bad Debt Date (DT) (optional)
     $data[] = null;
     // PV1-31: Bad Debt Agency Code (IS) (optional)
     $data[] = null;
     // PV1-32: Bad Debt Transfer Amount (NM) (optional)
     $data[] = null;
     // PV1-33: Bad Debt Recovery Amount (NM) (optional)
     $data[] = null;
     // PV1-34: Delete Account Indicator (IS) (optional)
     $data[] = null;
     // PV1-35: Delete Account Date (DT) (optional)
     $data[] = null;
     // PV1-36: Discharge Disposition (IS) (optional)
     $sejour->loadRefsAffectations();
     $data[] = $this->getPV136($receiver, $sejour);
     // PV1-37: Discharged to Location (DLD) (optional)
     $data[] = $sejour->etablissement_sortie_id && ($event->code == "A03" || $event->code == "A16" || $event->code == "A21") ? array($sejour->loadRefEtablissementTransfert()->finess) : null;
     // PV1-38: Diet Type (CE) (optional)
     $data[] = null;
     // PV1-39: Servicing Facility (IS) (optional)
     $data[] = null;
     // PV1-40: Bed Status (IS) (optional)
     // Interdit par IHE France
     $data[] = null;
     // PV1-41: Account Status (IS) (optional)
     // Utilisation que pour les événements A03 et Z99
     // Table - 0117
     // D - C'était la dernière venue pour ce dossier administratif
     // N - Ce n'était pas la dernière venue pour ce dossier administratif
     if ($event->code == "A03" || $event->code == "Z99") {
         $data[] = $sejour->type != "seances" && $sejour->sortie_reelle ? "D" : "N";
     } else {
         $data[] = null;
     }
     // PV1-42: Pending Location (PL) (optional)
     $data[] = null;
     // PV1-43: Prior Temporary Location (PL) (optional)
     $data[] = null;
     // PV1-44: Admit Date/Time (TS) (optional)
     $data[] = $sejour->entree_reelle;
     // PV1-45: Discharge Date/Time (TS) (optional repeating)
     $data[] = $sejour->sortie_reelle;
     // PV1-46: Current Patient Balance (NM) (optional)
     $data[] = null;
     // PV1-47: Total Charges (NM) (optional)
     $data[] = null;
     // PV1-48: Total Adjustments (NM) (optional)
     $data[] = null;
     // PV1-49: Total Payments (NM) (optional)
     $data[] = null;
     // PV1-50: Alternate Visit ID (CX) (optional)
     // Cas de l'utilisation du rang
     if (CAppUI::conf("dPplanningOp CSejour use_dossier_rang")) {
         $sejour->loadNRA($group->_id);
         if (CHL7v2Message::$build_mode == "simple") {
             $data[] = array($sejour->_ref_NRA->id400);
         }
     } else {
         $data[] = null;
     }
     // PV1-51: Visit Indicator (IS) (optional)
     $data[] = null;
     // PV1-52: Other Healthcare Provider (XCN) (optional repeating)
     $data[] = null;
     $this->fill($data);
 }
/**
 * $Id: httpreq_vw_orders_list.php 19286 2013-05-26 16:59:04Z phenxdesign $
 *
 * @package    Mediboard
 * @subpackage Stock
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision: 19286 $
 */
CCanDo::checkRead();
$type = CValue::get('type');
$keywords = CValue::get('keywords');
$category_id = CValue::get('category_id');
$invoiced = CValue::get('invoiced');
$start = CValue::get('start', array());
$page = CValue::read($start, $type, 0);
$where = array();
if ($category_id) {
    $where["product.category_id"] = "= '{$category_id}'";
}
if ($type == "received" && !$invoiced) {
    $where["bill_number"] = "IS NULL";
}
// @todo faire de la pagination
$order = new CProductOrder();
$orders = $order->search($type, $keywords, "{$page}, 25", $where);
$count = $order->_search_count;
foreach ($orders as $_order) {
    //$_order->updateCounts();
    $_order->countRenewedItems();
    if ($_order->object_id) {
$PV2 = $xml->queryNode("PV2");
$ZBE = $xml->queryNode("ZBE");
$IPP = $NDA = null;
$data = array();
$data["personIdentifiers"] = $xml->getPersonIdentifiers("PID.3", $PID, $actor);
$data["admitIdentifiers"] = $xml->getAdmitIdentifiers($PV1, $actor);
$names = array("nom" => "", "nom_jeune_fille" => "");
$prenom = null;
$PID5 = $xml->query("PID.5", $PID);
foreach ($PID5 as $_PID5) {
    // Nom(s)
    getNames($xml, $_PID5, $PID5, $names);
    // Prenom(s)
    $prenom = getFirstNames($xml, $_PID5);
}
$queries = array("Message" => array("control_id" => $xml->queryTextNode("MSH.10", $MSH), "datetime" => CMbDT::dateToLocale($xml->queryTextNode("MSH.7/TS.1", $MSH))), "EVN" => array("planned_event" => CMbDT::dateToLocale($xml->queryTextNode("EVN.2/TS.1", $EVN)), "event_occurred" => CMbDT::dateToLocale($xml->queryTextNode("EVN.6/TS.1", $EVN))), "CPatient" => array("nom" => $names["nom"], "nom_jeune_fille" => $names["nom_jeune_fille"], "prenom" => $prenom, "naissance" => CMbDT::dateToLocale($xml->queryTextNode("PID.7", $PID)), "_IPP" => CValue::read($data["personIdentifiers"], "PI")), "CSejour" => array("type" => $xml->queryTextNode("PV1.2", $PV1), "entree_prevue" => CMbDT::dateToLocale($xml->queryTextNode("PV2.8/TS.1", $PV2)), "entree_reelle" => CMbDT::dateToLocale($xml->queryTextNode("PV1.44/TS.1", $PV1)), "sortie_prevue" => CMbDT::dateToLocale($xml->queryTextNode("PV2.9/TS.1", $PV2)), "sortie_reelle" => CMbDT::dateToLocale($xml->queryTextNode("PV1.45/TS.1", $PV1)), "_NDA" => CValue::read($data["personIdentifiers"], "AN")));
if ($ZBE) {
    $movement_id = null;
    foreach ($xml->queryNodes("ZBE.1", $ZBE) as $ZBE_1) {
        $movement_id .= $xml->queryTextNode("EI.1", $ZBE_1) . "\n";
    }
    $queries_ZBE = array("CMovement" => array("movement_id" => $movement_id, "start_of_movement" => CMbDT::dateToLocale($xml->queryTextNode("ZBE.2/TS.1", $ZBE))));
    $queries = array_merge($queries, $queries_ZBE);
}
function getNames(CHL7v2MessageXML $xml, DOMNode $node, DOMNodeList $PID5, &$names = array())
{
    $fn1 = $xml->queryTextNode("XPN.1/FN.1", $node);
    switch ($xml->queryTextNode("XPN.7", $node)) {
        case "D":
            $names["nom"] = $fn1;
            break;
<?php

/**
 * $Id$
 *  
 * @category dPplanningOp
 * @package  Mediboard
 * @author   SARL OpenXtrem <*****@*****.**>
 * @license  GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version  $Revision$
 * @link     http://www.mediboard.org
 */
$mode_class = CValue::get("mode_class");
$file = CValue::read($_FILES, "import");
$smarty = new CSmartyDP();
$smarty->assign("mode_class", $mode_class);
if (!$file) {
    $smarty->display("inc_import_mode_entree_sortie_sejour.tpl");
    CApp::rip();
}
$group_id = CGroups::loadCurrent()->_id;
$csv = new CCSVFile($file["tmp_name"], CCSVFile::PROFILE_EXCEL);
$csv->readLine();
while ($line = $csv->readLine()) {
    list($code, $libelle, $mode, $actif) = $line;
    /** @var CModeEntreeSejour|CModeSortieSejour $mode_entree_sortie */
    $mode_entree_sortie = new $mode_class();
    $mode_entree_sortie->code = $code;
    $mode_entree_sortie->libelle = $libelle;
    $mode_entree_sortie->mode = $mode;
    $mode_entree_sortie->group_id = $group_id;
 /**
  * Retrouve un paramètre dans un tableau
  *
  * @param string $name    nom du paramètre
  * @param object $default [optional] valeur par défaut, si non retrouvé
  *
  * @return string
  */
 function getParameter($name, $default = null)
 {
     return CValue::read($this->parameters, $name, $default);
 }
 /**
  * Get adresses
  *
  * @param DOMNode  $node       Node
  * @param CPatient $newPatient Person
  *
  * @return void
  */
 function getAdresses(DOMNode $node, CPatient $newPatient)
 {
     $PID11 = $this->query("PID.11", $node);
     $addresses = array();
     foreach ($PID11 as $_PID11) {
         $adress_type = $this->queryTextNode("XAD.7", $_PID11);
         /* @todo Ajouter la gestion des multi-lignes - SAD.2 */
         $addresses[$adress_type]["adresse"] = $this->queryTextNode("XAD.1", $_PID11);
         $addresses[$adress_type]["adresse_comp"] = $this->queryTextNode("XAD.2", $_PID11);
         $addresses[$adress_type]["ville"] = $this->queryTextNode("XAD.3", $_PID11);
         $addresses[$adress_type]["cp"] = $this->queryTextNode("XAD.5", $_PID11);
         $addresses[$adress_type]["pays_insee"] = $this->queryTextNode("XAD.6", $_PID11);
     }
     // Lieu de l'accouchement
     if (array_key_exists("BDL", $addresses)) {
         $newPatient->lieu_naissance = CValue::read($addresses["BDL"], "ville");
         $newPatient->cp_naissance = CValue::read($addresses["BDL"], "cp");
         if ($alpha_3 = CValue::read($addresses["BDL"], "pays_insee")) {
             $pays = CPaysInsee::getPaysByAlpha($alpha_3);
             $newPatient->pays_naissance_insee = $pays->numerique;
         }
         unset($addresses["BDL"]);
     }
     // Adresse de naissance == Lieu de l'accouchement
     if (array_key_exists("BR", $addresses)) {
         $newPatient->lieu_naissance = CValue::read($addresses["BR"], "ville");
         $newPatient->cp_naissance = CValue::read($addresses["BR"], "cp");
         if ($alpha_3 = CValue::read($addresses["BR"], "pays_insee")) {
             $pays = CPaysInsee::getPaysByAlpha($alpha_3);
             $newPatient->pays_naissance_insee = $pays->numerique;
         }
         unset($addresses["BR"]);
     }
     // Adresse
     if (array_key_exists("H", $addresses)) {
         $this->getAdress($addresses["H"], $newPatient);
     } else {
         foreach ($addresses as $_address) {
             $this->getAdress($_address, $newPatient);
         }
     }
 }