/** * @see parent::store() */ function store() { $this->completeField("patient_link_id"); if ($this->_id && $this->_id == $this->patient_link_id) { $this->patient_link_id = ""; } // Création d'un patient en mode cabinets distincts if (CAppUI::conf('dPpatients CPatient function_distinct') && !$this->_id) { $this->function_id = CMediusers::get()->function_id; } if ($this->fieldModified("naissance") || $this->fieldModified("sexe")) { // _guid is not valued yet !! DSHM::remKeys("alertes-*-CPatient-" . $this->_id); } // Si changement de sexe on essaie de retrouver la civilité if ($this->fieldModified("sexe") && !$this->fieldModified("civilite")) { $this->civilite = "guess"; } $this->_anonyme = $this->checkAnonymous(); if ($state = CPatientState::getState($this)) { $this->status = $state; } // Standard store if ($msg = parent::store()) { return $msg; } if ($this->_anonyme) { $this->nom = $this->_id; $this->store(); } CPatientState::storeState($this); // Vitale if (CModule::getActive("fse")) { $cv = CFseFactory::createCV(); if ($cv) { if ($msg = $cv->bindVitale($this)) { return $msg; } } } // Génération de l'IPP ? if ($this->_generate_IPP) { if ($msg = $this->generateIPP()) { return $msg; } } if ($this->_vitale_nir_certifie) { if ($msg = CINSPatient::createINSC($this)) { return $msg; } } return null; }
/** * Sauvegarde des INSC * * @param CPatient $patient Patient * @param DOMNode $node Elément NumeroIdentifiantSante * * @return void */ function storeINSC(CPatient $patient, DOMNode $node) { $xpath = new CHPrimXPath($node->ownerDocument); $list_insc = $xpath->query("insC", $node); $insc = new CINSPatient(); $insc->type = "C"; $insc->patient_id = $patient->_id; foreach ($list_insc as $_insc) { $ins = $xpath->queryTextNode("valeur", $_insc); $date = $xpath->queryTextNode("dateEffet", $_insc); if (!$ins) { continue; } $insc->ins_patient_id = null; $insc->date = null; $insc->provider = null; $insc->ins = $ins; $insc->loadMatchingObject(); if ($insc->date < $date) { $insc->date = $date; $insc->provider = $this->_ref_sender->nom; } $insc->store(); } }
/** * Récupère les INS du patient * * @param DOMNode $node PID3 * @param CPatient $patient Patient * * @return void */ function getINS(DOMNode $node, CPatient $patient) { if (!$patient->_id) { return; } $list_ins = $this->query("PID.3[CX.5[text() = 'INS-C' or text() = 'INS-A']]", $node); $ins = new CINSPatient(); $ins->patient_id = $patient->_id; foreach ($list_ins as $_ins) { $ins->ins_patient_id = null; $ins->date = null; $ins->provider = null; $valeur = $this->queryTextNode("CX.1", $_ins); $date = $this->queryTextNode("CX.7", $_ins); $type = $this->queryTextNode("CX.5", $_ins); if (!$valeur) { continue; } $type = substr($type, -1); $ins->ins = $valeur; $ins->type = $type; $ins->loadMatchingObject(); if ($date && $ins->date < $date) { $ins->date = CMbDT::dateTime($date); $ins->provider = $this->_ref_sender->nom; } $ins->store(); } }
<?php /** * $Id$ * * @category CDA * @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 */ $list_person = CValue::get("listPerson"); $list_person = json_decode(stripslashes($list_person)); foreach ($list_person as $_person) { $birthDate = $_person->date; $firstName = CINSPatient::formatString($_person->prenom); if (!$_person->nirCertifie) { $_person->insc = "Impossible de calculer"; continue; } list($nir, $nirKey) = explode(" ", $_person->nirCertifie); $_person->insc = CINSPatient::calculInsc($nir, $nirKey, $firstName, $birthDate); } $smarty = new CSmartyDP(); $smarty->assign("list_person", $list_person); $smarty->display("ins/inc_test_insc_manuel.tpl");
/** * Create INSC * * @param CPatient $patient patient * * @return null|string */ static function createINSC(CPatient $patient) { if (!$patient->_vitale_nir_certifie) { return "Ce patient ne possède pas de numéro de sécurité sociale qui lui est propre"; } list($nir_carte, $nir_carte_key) = explode(" ", $patient->_vitale_nir_certifie); $name_carte = mb_strtoupper(CMbString::removeAccents($patient->_vitale_lastname)); $prenom_carte = mb_strtoupper(CMbString::removeAccents($patient->_vitale_firstname)); $name_patient = mb_strtoupper(CMbString::removeAccents($patient->nom)); $prenom_patient = mb_strtoupper(CMbString::removeAccents($patient->prenom)); if ($name_carte !== $name_patient || $prenom_carte !== $prenom_patient) { return "Le bénéficiaire de la carte vitale ne correspond pas au patient en cours"; } $firstName = self::formatString($patient->_vitale_firstname); $insc = self::calculInsc($nir_carte, $nir_carte_key, $firstName, $patient->_vitale_birthdate); if (strlen($insc) !== 22) { return "Problème lors du calcul de l'INSC"; } if (!$insc) { return "Impossible de calculer l'INSC"; } $last_ins = $patient->loadLastINS(); if ($last_ins && $last_ins->ins === $insc) { return null; } $ins = new CINSPatient(); $ins->patient_id = $patient->_id; $ins->ins = $insc; $ins->type = "C"; $ins->date = "now"; $ins->provider = "Mediboard"; if ($msg = $ins->store()) { return $msg; } return null; }
<?php /** * $Id$ * * @category CDA * @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 */ $patient_id = CValue::get("patient_id"); $ins_patient = new CINSPatient(); $ins_patient->patient_id = $patient_id; $list_ins = $ins_patient->loadMatchingList("date desc", null, "ins_patient_id"); $smarty = new CSmartyDP(); $smarty->assign("list_ins", $list_ins); $smarty->display("inc_history_ins.tpl");