/** * @see parent::store() */ function store() { // S'il ne reste plus qu'un seul champ et que sa valeur est passée à vide, // alors on supprime la constante. if ($this->_id && ($this->fieldModified("taille") || $this->fieldModified("poids")) || !$this->_id && ($this->taille || $this->poids)) { $this->completeField("patient_id"); DSHM::remKeys("alertes-*-CPatient-" . $this->patient_id); } if ($this->_id) { $this->loadOldObject(); /* Pour permettre la suppression du poids et de _poids_g */ if (!$this->_poids_g && $this->_old->poids) { $this->poids = $this->_poids_g; } if (!$this->poids && $this->_old->poids) { $this->_poids_g = $this->poids; } if ($this->poids != $this->_old->poids && $this->_poids_g != $this->poids * 1000) { $this->_poids_g = $this->poids * 1000; } } if (!$this->_id) { if (!$this->user_id) { $this->user_id = CMediusers::get()->_id; } if (!$this->creation_date) { $this->creation_date = CMbDT::dateTime(); } if ($this->datetime == 'now') { $this->datetime = $this->creation_date; } } if (!$this->_id && !$this->_new_constantes_medicales) { $this->updatePlainFields(); $constante = new CConstantesMedicales(); $constante->patient_id = $this->patient_id; $constante->context_class = $this->context_class; $constante->context_id = $this->context_id; if ($constante->loadMatchingObject()) { foreach (CConstantesMedicales::$list_constantes as $type => $params) { if (empty($this->{$type}) && !empty($constante->{$type})) { $this->{$type} = $constante->{$type}; } } $this->_id = $constante->_id; } } return parent::store(); }
/** * Get segement OBX * * @param DOMNode $node Node * @param CMbObject $object Object * @param array $data Data * * @return void */ function getOBX(DOMNode $node, CMbObject $object, $data) { $type = $this->queryTextNode("OBX.3/CE.2", $node); $value = floatval($this->queryTextNode("OBX.5", $node)); $constante_medicale = new CConstantesMedicales(); if ($object instanceof CSejour) { $constante_medicale->context_class = "CSejour"; $constante_medicale->context_id = $object->_id; $constante_medicale->patient_id = $object->patient_id; } else { if ($object instanceof CPatient) { $constante_medicale->context_class = "CPatient"; $constante_medicale->context_id = $object->_id; $constante_medicale->patient_id = $object->_id; } } $constante_medicale->datetime = $this->queryTextNode("EVN.2/TS.1", $data["EVN"]); $constante_medicale->loadMatchingObject(); switch ($type) { case "WEIGHT": $constante_medicale->poids = $value; break; case "HEIGHT": $constante_medicale->taille = $value; break; default: } $constante_medicale->_new_constantes_medicales = true; // Pour le moment pas de retour d'erreur dans l'acquittement $constante_medicale->store(); }