/** * Build A37 event * * @param CPatient $patient Person * * @see parent::build() * * @return void */ function build($patient) { parent::build($patient); // Patient Identification $this->addPID($patient); /* @toto old ? */ $patient_link = new CPatient(); $patient_link->load($patient->_old->patient_link_id); // Patient link Identification $this->addPID($patient_link); }
/** * Build A44 event * * @param CSejour $sejour Admit * * @see parent::build() * * @return void */ function build($sejour) { parent::build($sejour); $patient = $sejour->_ref_patient; // Patient Identification $this->addPID($patient, $sejour); // Patient Additional Demographic $this->addPD1($patient); $old_patient = new CPatient(); $old_patient->load($sejour->_old->patient_id); // Merge Patient Information $this->addMRG($old_patient); }
* @package Mediboard * @subpackage Patients * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ */ CCanDo::checkAdmin(); $idex = new CIdSante400(); $idex->object_class = "CPatient"; $idex->tag = CAppUI::conf("dPpatients CPatient tag_conflict_ipp") . CAppUI::conf("dPpatients CPatient tag_ipp"); /** @var CIdSante400[] $ipp_conflicts */ $ipp_conflicts = $idex->loadMatchingList(); $conflicts = array(); foreach ($ipp_conflicts as $_conflict) { $patient_conflict = new CPatient(); $patient_conflict->load($_conflict->object_id); $patient_conflict->loadIPP(); $IPP = new CIdSante400(); $IPP->object_class = "CPatient"; $IPP->tag = CAppUI::conf("dPpatients CPatient tag_ipp"); $IPP->id400 = $_conflict->id400; $IPP->loadMatchingObject(); $patient = new CPatient(); $patient->load($IPP->object_id); $patient->loadIPP(); $conflicts[] = array("patient" => $patient, "patient_conflict" => $patient_conflict); } // Création du template $smarty = new CSmartyDP(); $smarty->assign("conflicts", $conflicts); $smarty->display("inc_ipp_conflicts.tpl");
/** * 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); }
/** * Handle receive order message * * @param CHL7v2ReceiveOrderMessageResponse $ack Acknowledgment * @param CPatient $patient Person * @param array $data Data * * @return string|void */ function handle(CHL7v2ReceiveOrderMessageResponse $ack, CPatient $patient, $data) { $exchange_hl7v2 = $this->_ref_exchange_hl7v2; $sender = $exchange_hl7v2->_ref_sender; $sender->loadConfigValues(); $this->_ref_sender = $sender; $patientPI = CValue::read($data['personIdentifiers'], "PI"); if (!$patientPI) { return $exchange_hl7v2->setORRError($ack, "E007"); } $IPP = CIdSante400::getMatch("CPatient", $sender->_tag_patient, $patientPI); // Patient non retrouvé par son IPP if (!$IPP->_id) { return $exchange_hl7v2->setORRError($ack, "E105"); } $patient->load($IPP->object_id); $venueAN = $this->getVenueAN($sender, $data); $NDA = CIdSante400::getMatch("CSejour", $sender->_tag_sejour, $venueAN); // Séjour non retrouvé par son NDA if (!$NDA->_id) { return $exchange_hl7v2->setORRError($ack, "E205"); } $sejour = new CSejour(); $sejour->load($NDA->object_id); // Common order - ORC $orc = $data["ORC"]; $obr = $data["OBR"]; $event_request = $this->getEventRequest($orc); $consultation = new CConsultation(); $placer_id = $this->getPlacerNumber($orc); $filler_id = $this->getFillerNumber($orc); switch ($event_request) { // new order case "SN": $datetime = $this->getDate($orc); $orc12 = $this->getDoctorNode($orc, $data); $mediuser = new CMediusers(); $medisuer_id = $this->getDoctor($orc12, $mediuser); if (!$medisuer_id) { return $exchange_hl7v2->setORRError($ack, "E801"); } $consultation->createByDatetime($datetime, $medisuer_id, $patient->_id); if (!$consultation->_id) { return $exchange_hl7v2->setORRError($ack, "E802"); } $idex = new CIdSante400(); $idex->id400 = $filler_id; $idex->tag = $sender->_tag_consultation; $idex->setObject($consultation); $idex->store(); break; //Modification //Modification case "SC": $consultation->load($placer_id); $status_code = $this->getStatusCode($orc); switch ($status_code) { case "CM": $status = CConsultation::TERMINE; break; case "OD": $status = CConsultation::PLANIFIE; break; case "IP": $status = CConsultation::EN_COURS; break; default: return $exchange_hl7v2->setORRError($ack, "E803"); } $consultation->chrono = $status; if ($msg = $consultation->store()) { return $exchange_hl7v2->setORRError($ack, "E804", $msg); } $obr4 = $this->getExamen("OBR.4", $obr, $data); //Identifiant de l'élément de prescription $examen_id = $this->getExamenID($obr4); $examen_name = $this->getExamenName($obr4); //todo gérer avec l'élément de prescription break; // cancel order request // cancel order request case "OC": $consultation->annule = "1"; if ($msg = $consultation->store()) { return $exchange_hl7v2->setORRError($ack, "E804", $msg); } $idex = CIdSante400::getMatchFor($consultation, $sender->_tag_consultation); $idex->id400 = "trash_{$idex->id400}"; if ($msg = $idex->store()) { return $exchange_hl7v2->setORRError($ack, "E805", $msg); } break; default: return $exchange_hl7v2->setORRError($ack, "E205"); } return $exchange_hl7v2->setORRSuccess($ack); }
} elseif ($dialog) { $this->redirectStore .= "&name=" . $this->_obj->nom . "&firstname=" . $this->_obj->prenom; } } } $do = new CDoPatientMerge(); $patient1_id = CValue::post("patient1_id"); $patient2_id = CValue::post("patient2_id"); $base_object_id = CValue::post("_base_object_id"); // Erreur sur les ID du patient $patient1 = new CPatient(); if (!$patient1->load($patient1_id)) { $do->errorRedirect("Patient 1 n'existe pas ou plus"); } $patient2 = new CPatient(); if (!$patient2->load($patient2_id)) { $do->errorRedirect("Patient 2 n'existe pas ou plus"); } if (intval(CValue::post("del"))) { $do->errorRedirect("Fusion en mode suppression impossible"); } $patients = array($patient1, $patient2); if ($base_object_id) { $do->_obj->load($base_object_id); foreach ($patients as $key => $patient) { if ($base_object_id == $patient->_id) { unset($patients[$key]); unset($_POST["_merging"][$base_object_id]); } } }
/** * $Id: vw_idx_patients.php 26857 2015-01-21 14:44:41Z rhum1 $ * * @package Mediboard * @subpackage Patients * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision: 26857 $ */ CCanDo::checkRead(); $mediuser = CMediusers::get(); // Chargement du patient sélectionné $patient_id = CValue::getOrSession("patient_id"); $patient = new CPatient(); if ($new = CValue::get("new")) { $patient->load(null); CValue::setSession("patient_id", null); CValue::setSession("selClass", null); CValue::setSession("selKey", null); } else { $patient->load($patient_id); } $patient_nom = trim(CValue::getOrSession("nom")); $patient_prenom = trim(CValue::getOrSession("prenom")); $patient_ville = CValue::get("ville"); $patient_cp = CValue::get("cp"); $patient_day = CValue::getOrSession("Date_Day"); $patient_month = CValue::getOrSession("Date_Month"); $patient_year = CValue::getOrSession("Date_Year"); $patient_naissance = "{$patient_year}-{$patient_month}-{$patient_day}"; $patient_ipp = CValue::get("patient_ipp");
$request_b->addTable("patients"); $request_b->addOrder("patients.nom ASC"); } $request_b->addLJoin($ljoin); $request_b->addRJoin($rjoinMix); $request_b->addWhere($where); $request_b->addWhere($whereMix); if (!$export) { $request_b->setLimit("{$start},30"); } $results = array_merge($results, $ds->loadList($request_b->makeSelect())); } foreach ($results as $_result) { $_patient_id = $_result["patient_id"]; $pat = new CPatient(); $pat->load($_patient_id); // Recherche sur un antécédent if (isset($_result["antecedent_id"])) { $_atcd = new CAntecedent(); $_atcd->load($_result["antecedent_id"]); $pat->_ref_antecedent = $_atcd; } else { // On affiche tous les antécédents du patient $dossier_medical = $pat->loadRefDossierMedical(false); $pat->_refs_antecedents = $dossier_medical->loadRefsAntecedents(); $pat->_refs_allergies = $dossier_medical->loadRefsAllergies(); $pat->_ext_codes_cim = $dossier_medical->_ext_codes_cim; } if (isset($_result["prescription_line_medicament_id"])) { $line = new CPrescriptionLineMedicament(); $line->load($_result["prescription_line_medicament_id"]);
$chir_id = CAppUI::conf("dPcabinet keepchir") ? CValue::getOrSession("chir_id") : CValue::get("chir_id"); // Nouvelle consultation if (!$consultation_id) { if ($plageconsult_id) { // On a fourni une plage de consultation $plageConsult->load($plageconsult_id); } else { if ($chir_id) { $chir = new CMediusers(); $chir->load($chir_id); } } // assign patient if defined in get if ($pat_id = CValue::get("pat_id")) { // On a fourni l'id du patient $pat->load($pat_id); } if ($date_planning) { // On a fourni une date $consult->_date = $date_planning; } if ($heure) { // On a fourni une heure $consult->heure = $heure; $consult->plageconsult_id = $plageconsult_id; $chir->load($plageConsult->chir_id); } // grossesse if (!$consult->grossesse_id && $grossesse_id) { $consult->grossesse_id = $grossesse_id; }
/** * Handle event A45 - move visit information - visit number * * @param CHL7Acknowledgment $ack Acknowledgment * @param CPatient $newPatient Person * @param array $data Datas * * @return string */ function handleA45(CHL7Acknowledgment $ack, CPatient $newPatient, $data) { $exchange_hl7v2 = $this->_ref_exchange_hl7v2; $sender = $exchange_hl7v2->_ref_sender; // On considère que l'on a qu'un changement à faire if (count($data["merge"]) > 1) { return $exchange_hl7v2->setAckAR($ack, "E701", null, $newPatient); } $merge = CValue::read($data["merge"], 0); $keep_patient = new CPatient(); $patientPI = CValue::read($data['personIdentifiers'], "PI"); // Acquittement d'erreur : identifiants RI et PI non fournis if (!$patientPI) { return $exchange_hl7v2->setAckAR($ack, "E100", null, $newPatient); } // Chargement du patient $idexPatient = CIdSante400::getMatch("CPatient", $sender->_tag_patient, $patientPI); $keep_patient->load($idexPatient->object_id); if (!$keep_patient->_id) { return $exchange_hl7v2->setAckAR($ack, "E702", null, $keep_patient); } // MRG-1 Ancien numéro du patient // Chargement du séjour pour ce patient $MRG_1 = $this->queryTextNode("MRG.1/CX.1", $merge["MRG"]); $idex = new CIdSante400(); $idex->object_class = "CPatient"; $idex->id400 = $MRG_1; $idex->tag = $sender->_tag_patient; /** @var CPatient $patient_removing */ $patient_removing = $idex->getMbObject(); if (!$patient_removing || !$patient_removing->_id) { return $exchange_hl7v2->setAckAR($ack, "E703", null, $newPatient); } // MRG-5 Numéro de dossier // Chargement du dossier par le numéro de séjour $MRG_5 = $this->queryTextNode("MRG.5/CX.1", $merge["MRG"]); $idex = new CIdSante400(); $idex->object_class = "CSejour"; $idex->id400 = $MRG_5; $idex->tag = $sender->_tag_sejour; /** @var CSejour $venue */ $venue = $idex->getMbObject(); if (!$venue || !$venue->_id) { return $exchange_hl7v2->setAckAR($ack, "E704", null, $newPatient); } // Si le patient du séjour retrouvé est différent de celui que l'on doit "supprimer" if ($venue->patient_id != $patient_removing->_id) { return $exchange_hl7v2->setAckAR($ack, "E705", null, $venue); } // Réattribution du patient_id sur le séjour // Impossibilité dans Mediboard de modifier le patient d'un séjour ayant une entrée réelle if (CAppUI::conf("dPplanningOp CSejour patient_id") == 2 && $venue->entree_reelle) { return $exchange_hl7v2->setAckAR($ack, "E706", null, $venue); } $venue->patient_id = $keep_patient->_id; // Notifier les autres destinataires autre que le sender $venue->_eai_sender_guid = $sender->_guid; if ($msg = $venue->store()) { return $exchange_hl7v2->setAckAR($ack, "E707", $msg, $venue); } $comment = CEAISejour::getComment($venue); return $exchange_hl7v2->setAckAA($ack, "I700", $comment, $venue); }
$naissance = new CNaissance(); $naissance->load($naissance_id); $naissance->rang = $rang; $naissance->hors_etab = $hors_etab; $naissance->num_naissance = $num_naissance; $naissance->fausse_couche = $fausse_couche; $naissance->rques = $rques; if (!$naissance->date_time && $date_time) { $validation_naissance = true; $naissance->operation_id = $operation_id; } $naissance->date_time = $date_time; storeObject($naissance); $sejour = $naissance->loadRefSejourEnfant(); $patient = new CPatient(); $patient->load($sejour->patient_id); $patient->nom = $nom; $patient->prenom = $prenom; $patient->nom = $nom; $patient->sexe = $sexe; $patient->naissance = $date_naissance; storeObject($patient); $sejour_enfant = new CSejour(); $sejour_enfant->load($naissance->sejour_enfant_id); $sejour_enfant->praticien_id = $praticien_id; $sejour_enfant->_naissance = true; storeObject($sejour_enfant); // Effectuer l'admission si nécessaire (si issu d'un dossier provisoire) if ($validation_naissance) { // On passe la date de naissance du bébé au jour courant $patient->naissance = CMbDT::date();
/** * Fusion and recording a patient with an IPP in the system * * @param CHPrimXMLAcquittementsPatients $dom_acq Acquittement * @param CPatient $newPatient Patient * @param array $data Datas * * @return string acquittement **/ function fusionPatient(CHPrimXMLAcquittementsPatients $dom_acq, CPatient $newPatient, $data) { $echg_hprim = $this->_ref_echange_hprim; $commentaire = $avertissement = ""; $codes = array(); $sender = $echg_hprim->_ref_sender; $sender->loadConfigValues(); $this->_ref_sender = $sender; // Si CIP if (!CAppUI::conf('sip server')) { $mbPatientElimine = new CPatient(); $mbPatient = new CPatient(); $sender = $echg_hprim->_ref_sender; // Acquittement d'erreur : identifiants source et cible non fournis pour le patient / patientElimine if (!$data['idSourcePatient'] && !$data['idCiblePatient'] && !$data['idSourcePatientElimine'] && !$data['idCiblePatientElimine']) { return $echg_hprim->setAckError($dom_acq, "E005", $commentaire, $newPatient); } $idexPatient = CIdSante400::getMatch("CPatient", $sender->_tag_patient, $data['idSourcePatient']); if ($mbPatient->load($data['idCiblePatient'])) { if ($mbPatient->_id != $idexPatient->object_id) { $commentaire = "L'identifiant source fait référence au patient : {$idexPatient->object_id} et l'identifiant cible"; $commentaire .= "au patient : {$mbPatient->_id}."; return $echg_hprim->setAckError($dom_acq, "E004", $commentaire, $newPatient); } } if (!$mbPatient->_id) { $mbPatient->load($idexPatient->object_id); } $idexPatientElimine = CIdSante400::getMatch("CPatient", $sender->_tag_patient, $data['idSourcePatientElimine']); if ($mbPatientElimine->load($data['idCiblePatientElimine'])) { if ($mbPatientElimine->_id != $idexPatientElimine->object_id) { $commentaire = "L'identifiant source fait référence au patient : {$idexPatientElimine->object_id} et l'identifiant cible"; $commentaire .= "au patient : {$mbPatientElimine->_id}."; return $echg_hprim->setAckError($dom_acq, "E041", $commentaire, $newPatient); } } if (!$mbPatientElimine->_id) { $mbPatientElimine->load($idexPatientElimine->object_id); } if (!$mbPatient->_id || !$mbPatientElimine->_id) { $commentaire = !$mbPatient->_id ? "Le patient {$mbPatient->_id} est inconnu dans Mediboard." : "Le patient {$mbPatientElimine->_id} est inconnu dans Mediboard."; return $echg_hprim->setAckError($dom_acq, "E012", $commentaire, $newPatient); } // Passage en trash de l'IPP du patient a éliminer $idexPatientElimine->tag = CAppUI::conf('dPpatients CPatient tag_ipp_trash') . $sender->_tag_patient; $idexPatientElimine->store(); $avertissement = null; $patientsElimine_array = array($mbPatientElimine); $first_patient_id = $mbPatient->_id; $checkMerge = $mbPatient->checkMerge($patientsElimine_array); // Erreur sur le check du merge if ($checkMerge) { $commentaire = "La fusion de ces deux patients n'est pas possible à cause des problèmes suivants : {$checkMerge}"; return $echg_hprim->setAckError($dom_acq, "E010", $commentaire, $newPatient); } $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"); $msg = $mbPatient->merge($patientsElimine_array); $commentaire = CEAIPatient::getComment($newPatient, $mbPatientElimine); $codes = array($msg ? "A010" : "I010"); if ($msg) { $avertissement = $msg . " "; } } return $echg_hprim->setAck($dom_acq, $codes, $avertissement, $commentaire, $newPatient); }
/** * merge the patient * * @param String $identifier identifier * @param String $tag tag * @param CPatient $patient patient * * @return null|CHPrimSanteError */ function mergePatient($identifier, $tag, CPatient $patient) { $idex = CIdSante400::getMatch("CPatient", $tag, $identifier["identifier"]); if (!$idex->_id) { return new CHPrimSanteError($this->_ref_exchange_hpr, "P", "02", array("P", $this->loop, $this->identifier_patient), "8.3.1"); } $idex2 = CIdSante400::getMatch("CPatient", $tag, $identifier["identifier_merge"]); if (!$idex2->_id) { return new CHPrimSanteError($this->_ref_exchange_hpr, "P", "02", array("P", $this->loop, $this->identifier_patient), "8.3.2"); } $patient->load($idex->object_id); $patient2 = new CPatient(); $patient2->load($idex2->object_id); $patientsElimine_array = array($patient2); $first_patient_id = $patient->_id; // Erreur sur le check du merge if ($checkMerge = $patient->checkMerge($patientsElimine_array)) { return new CHPrimSanteError($this->_ref_exchange_hpr, "P", "12", array("P", $this->loop, $this->identifier_patient), "8.3.3", $checkMerge); } $mbPatientElimine_id = $patient2->_id; /** @todo mergePlainFields resets the _id */ $patient->_id = $first_patient_id; // Notifier les autres destinataires $patient->_eai_sender_guid = $this->_ref_sender->_guid; $patient->_merging = CMbArray::pluck($patientsElimine_array, "_id"); if ($msg = $patient->merge($patientsElimine_array)) { return new CHPrimSanteError($this->_ref_exchange_hpr, "P", "12", array("P", $this->loop, $this->identifier_patient), "8.3.3", $msg); } $patient->_mbPatientElimine_id = $mbPatientElimine_id; return null; }
/** * Trigger after event store * * @param CMbObject $mbObject Object * * @return void */ function onAfterStore(CMbObject $mbObject) { if (!$this->isHandled($mbObject)) { return false; } /** @var CInteropReceiver $receiver */ $receiver = $mbObject->_receiver; $receiver->getInternationalizationCode($this->transaction); $code = null; // Création/MAJ d'un correspondant patient if ($mbObject instanceof CCorrespondantPatient) { if (!$mbObject->patient_id) { return; } $mbObject = $mbObject->loadRefPatient(); $mbObject->_receiver = $receiver; $code = "A31"; } elseif ($mbObject instanceof CIdSante400) { $idex = $mbObject; // Concerne pas les patients / Pas en mode modification if ($idex->object_class != "CPatient" || !$idex->_old->_id) { return; } // Pas un tag IPP if ($idex->tag != CPatient::getTagIPP()) { return; } // Vraiment une modif de l'idex ? if ($idex->id400 == $idex->_old->id400) { return; } $code = "A47"; $patient = new CPatient(); $patient->load($idex->object_id); $patient->_receiver = $receiver; $patient->_patient_elimine = clone $patient; // Affecte le nouvel IPP au patient $patient->_IPP = $idex->id400; // Affecte l'ancien IPP au "patient éliminé" $patient->_patient_elimine->_IPP = $idex->_old->id400; if (!$this->isMessageSupported($this->transaction, $this->message, $code, $receiver)) { return; } $this->sendITI($this->profil, $this->transaction, $this->message, $code, $patient); return; } else { if ($mbObject->_naissance) { return; } switch ($mbObject->_ref_current_log->type) { case "create": $code = "A28"; break; case "store": // Patient lié if ($mbObject->fieldModified("patient_link_id")) { $code = "A24"; break; } // Annulation de la liaison avec le patient lié if ($mbObject->_old->patient_link_id && !$mbObject->patient_link_id) { $code = "A37"; break; } if ($receiver->_configs["send_patient_with_visit"]) { /** @var CPatient $mbObject */ $sejour = $mbObject->loadRefsSejours(array("entree_reelle" => "IS NOT NULL")); if (count($sejour) < 1) { $code = null; break; } } if ($receiver->_configs["send_patient_with_current_admit"]) { // On charge seulement le séjour courant pour le patient $sejours = $mbObject->getCurrSejour(null, $receiver->group_id); if (!$sejours) { break; } $sejour = reset($sejours); if (!$sejour->_id) { break; } $mbObject->_ref_sejour = $sejour; } // Dans tous les autres cas il s'agit d'une modification $code = $receiver->_configs["send_update_patient_information"] == "A08" ? "A08" : "A31"; break; default: $code = null; } } if (!$code) { return; } $patient = $mbObject; if (!$this->isMessageSupported($this->transaction, $this->message, $code, $receiver)) { return; } if (!$patient->_IPP) { // Génération de l'IPP dans le cas de la création, ce dernier n'était pas créé if ($msg = $patient->generateIPP()) { CAppUI::setMsg($msg, UI_MSG_ERROR); } if (!$patient->_IPP) { $IPP = new CIdSante400(); $IPP->loadLatestFor($patient, $receiver->_tag_patient); $patient->_IPP = $IPP->id400; } } // Envoi pas les patients qui n'ont pas d'IPP if (!$receiver->_configs["send_all_patients"] && !$patient->_IPP) { return; } $this->sendITI($this->profil, $this->transaction, $this->message, $code, $patient); $patient->_IPP = null; }
<?php /** * $Id$ * * @package Mediboard * @subpackage Patients * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ */ $objects_id = CValue::post('objects_id'); if (!is_array($objects_id)) { $objects_id = explode("-", $objects_id); } if (count($objects_id) != 2) { CAppUI::stepAjax("Trop d'objet pour réaliser une association", UI_MSG_ERROR); } if (class_exists("CPatient") && count($objects_id)) { $patient1 = new CPatient(); $patient2 = new CPatient(); if (!$patient1->load($objects_id[0]) || !$patient2->load($objects_id[1])) { CAppUI::stepAjax("Chargement impossible du patient", UI_MSG_ERROR); } $patient1->_doubloon_ids = array($patient2->_id); if ($msg = $patient1->store()) { CAppUI::stepAjax("Association du patient impossible : {$msg}", UI_MSG_ERROR); } CAppUI::stepAjax("{$patient1->_view} associé avec {$patient2->_view}"); } CApp::rip();
$intervention->cote = CValue::get("intervention_cote", CValue::post("intervention_cote")); $intervention->horaire_voulu = CValue::get("intervention_horaire_souhaite", CValue::post("intervention_horaire_souhaite")); $intervention->codes_ccam = CValue::get("intervention_codes_ccam", CValue::post("intervention_codes_ccam")); $intervention->materiel = CValue::get("intervention_materiel", CValue::post("intervention_materiel")); $intervention->rques = CValue::get("intervention_remarques", CValue::post("intervention_remarques")); $msg_error = null; $list_fields = array(); $patient_existant = new CPatient(); $patient_resultat = new CPatient(); $sejour_existant = new CSejour(); $sejour_resultat = new CSejour(); $patient_ok = false; $sejour_ok = false; $intervention_ok = false; if ($patient_id) { $patient_resultat->load($patient_id); if ($patient_resultat->_id) { $patient = $patient_resultat; $patient_ok = true; } } if ($praticien_id && (!$patient_ok || $sejour_id)) { if (!$sejour_id) { // Recherche d'un patient existant $patient_existant = clone $patient; $patient_existant->loadMatchingPatient(); // S'il n'y est pas, on le store if (!$patient_existant->_id) { if (!($msg_error = $patient->check())) { $patient->store(); $patient_ok = true;
/** * Handle event A47 * * @param CHL7Acknowledgment $ack Acknowledgment * @param CPatient $patient Person * @param array $data Data * * @return string */ function handleA47(CHL7Acknowledgment $ack, CPatient $patient, $data) { $exchange_hl7v2 = $this->_ref_exchange_hl7v2; $sender = $exchange_hl7v2->_ref_sender; $sender->loadConfigValues(); $this->_ref_sender = $sender; $incorrect_identifier = null; // Traitement du mode simple, cad if (CHL7v2Message::$handle_mode == "simple") { $MRG_4 = $this->queryNodes("MRG.4", $data["MRG"])->item(0); $incorrect_identifier = $this->queryTextNode("CX.1", $MRG_4); $patient->load($incorrect_identifier); // ID non connu (non fourni ou non retrouvé) if (!$incorrect_identifier || !$patient->_id) { return $exchange_hl7v2->setAckAR($ack, "E141", null, $patient); } } else { $MRG_1 = $this->queryNodes("MRG.1", $data["MRG"])->item(0); if ($this->queryTextNode("CX.5", $MRG_1) == "PI") { $incorrect_identifier = $this->queryTextNode("CX.1", $MRG_1); } // Chargement de l'IPP $IPP_incorrect = new CIdSante400(); if ($incorrect_identifier) { $IPP_incorrect = CIdSante400::getMatch("CPatient", $sender->_tag_patient, $incorrect_identifier); } // PI non connu (non fourni ou non retrouvé) if (!$incorrect_identifier || !$IPP_incorrect->_id) { return $exchange_hl7v2->setAckAR($ack, "E141", null, $patient); } $patient->load($IPP_incorrect->object_id); // Passage en trash de l'IPP du patient a éliminer if ($msg = $patient->trashIPP($IPP_incorrect)) { return $exchange_hl7v2->setAckAR($ack, "E140", $msg, $patient); } } // Sauvegarde du nouvel IPP $IPP = new CIdSante400(); $IPP->object_id = $patient->_id; $IPP->object_class = "CPatient"; $IPP->id400 = $data['personIdentifiers']["PI"]; $IPP->tag = $sender->_tag_patient; $IPP->last_update = CMbDT::dateTime(); if ($msg = $IPP->store()) { return $exchange_hl7v2->setAckAR($ack, "E140", $msg, $patient); } return $exchange_hl7v2->setAckAA($ack, "I140", null, $patient); }
} if (!empty($naissance["day"])) { $query .= ", DATE_FORMAT(`naissance`, '%d')"; } $query .= " \r\n )) AS `hash`\r\n FROM `patients`\r\n GROUP BY `hash`\r\n HAVING `total` > 1"; $res = $ds->query($query); CAppUI::stepAjax(intval($ds->numRows($res)) . " patients identiques"); $patient_siblings = array(); if (!$do_merge) { $n = 100; while ($n-- && ($l = $ds->fetchAssoc($res))) { $patient_ids = explode("|", $l["ids"]); $patients = array(); foreach ($patient_ids as $_id) { $_patient = new CPatient(); $_patient->load($_id); $patients[] = $_patient; } $patient_siblings[] = array("siblings" => $patients, "hash" => $l["hash"]); } } /* else { while($l = $ds->fetchAssoc($res)){ $patient_ids = explode("|", $l["ids"]); $patients = array(); foreach($patient_ids as $id) { $p = new CPatient; $p->load($id); $patients[$id] = $p;
/** * Handle all ITI-30 events * * @param CHL7Acknowledgment $ack Acknowledgement * @param CPatient $newPatient Person * @param array $data Nodes data * * @return null|string */ function handleAll(CHL7Acknowledgment $ack, CPatient $newPatient, $data) { // Traitement du message des erreurs $_modif_patient = false; $exchange_hl7v2 = $this->_ref_exchange_hl7v2; $sender = $this->_ref_sender; $patientRI = CValue::read($data['personIdentifiers'], "RI"); $patientRISender = CValue::read($data['personIdentifiers'], "RI_Sender"); $patientPI = CValue::read($data['personIdentifiers'], "PI"); $IPP = new CIdSante400(); if ($patientPI) { $IPP = CIdSante400::getMatch("CPatient", $sender->_tag_patient, $patientPI); } // PI non connu (non fourni ou non retrouvé) if (!$patientPI || !$IPP->_id) { // RI fourni if ($patientRI) { // Recherche du patient par son RI if ($newPatient->load($patientRI)) { $recoveredPatient = clone $newPatient; // Mapping primaire du patient $this->primaryMappingPatient($data, $newPatient); // Le patient retrouvé est-il différent que celui du message ? if (!$this->checkSimilarPatient($recoveredPatient, $newPatient)) { $commentaire = "Le nom ({$newPatient->nom} / {$recoveredPatient->nom}) " . "et/ou le prénom ({$newPatient->prenom} / {$recoveredPatient->prenom}) sont très différents."; return $exchange_hl7v2->setAckAR($ack, "E123", $commentaire, $newPatient); } // On store le patient if ($msgPatient = CEAIPatient::storePatient($newPatient, $sender)) { return $exchange_hl7v2->setAckAR($ack, "E101", $msgPatient, $newPatient); } $code_IPP = "I121"; $_modif_patient = true; } else { $code_IPP = "I120"; } } else { // Aucun IPP fourni if (!$patientPI) { $code_IPP = "I125"; } else { $code_IPP = "I122"; } } if (!$newPatient->_id) { // Mapping primaire du patient $this->primaryMappingPatient($data, $newPatient); // Patient retrouvé if ($newPatient->loadMatchingPatient()) { // Mapping primaire du patient $this->primaryMappingPatient($data, $newPatient); $code_IPP = "A121"; $_modif_patient = true; } // On store le patient $newPatient->_IPP = $IPP->id400; if ($msgPatient = CEAIPatient::storePatient($newPatient, $sender)) { return $exchange_hl7v2->setAckAR($ack, "E101", $msgPatient, $newPatient); } } $newPatient->_generate_IPP = false; // Mapping secondaire (correspondants, médecins) du patient if ($msgPatient = $this->secondaryMappingPatient($data, $newPatient)) { return $exchange_hl7v2->setAckAR($ack, "E101", $msgPatient, $newPatient); } if ($msgIPP = CEAIPatient::storeIPP($IPP, $newPatient, $sender)) { return $exchange_hl7v2->setAckAR($ack, "E102", $msgIPP, $newPatient); } $codes = array($_modif_patient ? "I102" : "I101", $code_IPP); $comment = CEAIPatient::getComment($newPatient); $comment .= CEAIPatient::getComment($IPP); } else { $newPatient->load($IPP->object_id); $recoveredPatient = clone $newPatient; // Mapping primaire du patient $this->primaryMappingPatient($data, $newPatient); // Le patient retrouvé est-il différent que celui du message ? if (!$this->checkSimilarPatient($recoveredPatient, $newPatient)) { $commentaire = "Le nom ({$newPatient->nom} / {$recoveredPatient->nom}) " . "et/ou le prénom ({$newPatient->prenom} / {$recoveredPatient->prenom}) sont très différents."; return $exchange_hl7v2->setAckAR($ack, "E124", $commentaire, $newPatient); } // RI non fourni if (!$patientRI) { $code_IPP = "I123"; } else { $tmpPatient = new CPatient(); // RI connu if ($tmpPatient->load($patientRI)) { if ($tmpPatient->_id != $IPP->object_id) { $comment = "L'identifiant source fait référence au patient : {$IPP->object_id}" . "et l'identifiant cible au patient : {$tmpPatient->_id}."; return $exchange_hl7v2->setAckAR($ack, "E101", $comment, $newPatient); } $code_IPP = "I124"; } else { $code_IPP = "A120"; } } // On store le patient if ($msgPatient = CEAIPatient::storePatient($newPatient, $sender)) { return $exchange_hl7v2->setAckAR($ack, "E101", $msgPatient, $newPatient); } // Mapping secondaire (correspondants, médecins) du patient if ($msgPatient = $this->secondaryMappingPatient($data, $newPatient)) { return $exchange_hl7v2->setAckAR($ack, "E101", $msgPatient, $newPatient); } $codes = array("I102", $code_IPP); $comment = CEAIPatient::getComment($newPatient); } if ($patientRISender) { CEAIPatient::storeRISender($patientRISender, $newPatient, $sender); } if ($sender->_configs["ins_integrated"]) { $this->getINS($data["PID"], $newPatient); } return $exchange_hl7v2->setAckAA($ack, $codes, $comment, $newPatient); }
/** * Enregistrement des interventions * * @param CHPrimXMLAcquittementsServeurActivitePmsi $dom_acq DOM Acquittement * @param CMbObject $mbObject Object * @param array $data Data that contain the nodes * * @return string Acquittement **/ function handle(CHPrimXMLAcquittementsServeurActivitePmsi $dom_acq, CMbObject $mbObject, $data) { $operation = $mbObject; $exchange_hprim = $this->_ref_echange_hprim; $sender = $exchange_hprim->_ref_sender; $sender->loadConfigValues(); $this->_ref_sender = $sender; $warning = null; $comment = null; // Acquittement d'erreur : identifiants source du patient / séjour non fournis if (!$data['idSourcePatient'] || !$data['idSourceVenue']) { return $exchange_hprim->setAckError($dom_acq, "E206", null, $mbObject); } // IPP non connu => message d'erreur $IPP = CIdSante400::getMatch("CPatient", $sender->_tag_patient, $data['idSourcePatient']); if (!$IPP->_id) { return $exchange_hprim->setAckError($dom_acq, "E013", null, $mbObject); } // Chargement du patient $patient = new CPatient(); $patient->load($IPP->object_id); // Num dossier non connu => message d'erreur $NDA = CIdSante400::getMatch("CSejour", $sender->_tag_sejour, $data['idSourceVenue']); if (!$NDA->_id) { return $exchange_hprim->setAckError($dom_acq, "E014", null, $mbObject); } // Chargement du séjour $sejour = new CSejour(); $sejour->load($NDA->object_id); // Si patient H'XML est différent du séjour if ($sejour->patient_id != $patient->_id) { return $exchange_hprim->setAckError($dom_acq, "E015", null, $mbObject); } // Chargement du patient du séjour $sejour->loadRefPatient(); $operation->sejour_id = $sejour->_id; // Mapping du séjour $sejour = $this->mappingVenue($data['venue'], $sejour); // Notifier les autres destinataires autre que le sender $sejour->_eai_sender_guid = $sender->_guid; /* TODO Supprimer ceci après l'ajout des times picker */ $sejour->_hour_entree_prevue = null; $sejour->_min_entree_prevue = null; $sejour->_hour_sortie_prevue = null; $sejour->_min_sortie_prevue = null; if ($msgVenue = $sejour->store()) { return $exchange_hprim->setAck($dom_acq, "A102", $msgVenue, null, $sejour); } // idex de l'intervention $idex = CIdSante400::getMatch("COperation", $sender->_tag_hprimxml, $data['idSourceIntervention']); if ($idex->_id) { $operation_source = new COperation(); $operation_source->load($idex->object_id); if ($operation_source->sejour_id != $sejour->_id) { return $exchange_hprim->setAckError($dom_acq, "E204", null, $mbObject); } $operation = $operation_source; } // ID Mediboard de l'intervention if ($data['idCibleIntervention']) { $operation_source = new COperation(); $operation_source->load($data['idCibleIntervention']); if ($operation_source->sejour_id != $sejour->_id) { return $exchange_hprim->setAckError($dom_acq, "E204", null, $mbObject); } if ($idex->_id && $operation->_id != $operation_source->_id) { return $exchange_hprim->setAckError($dom_acq, "E205", null, $mbObject); } $operation = $operation_source; } // Recherche de la salle $salle = $this->getSalle($data['intervention'], $sejour); if ($salle->nom && !$salle->_id) { $comment = "Salle '{$salle->nom}' inconnue dans l'infrastructure de l'établissement"; return $exchange_hprim->setAckError($dom_acq, "E202", $comment, $mbObject); } $operation->salle_id = $salle->_id; // Mapping du chirurgien $mediuser = $this->getParticipant($data['intervention'], $sejour); if ($mediuser->adeli && !$mediuser->_id || !$mediuser->adeli) { $comment = $mediuser->adeli ? "Participant '{$mediuser->adeli}' inconnu" : "Le code ADELI n'est pas renseigné"; return $exchange_hprim->setAckError($dom_acq, "E203", $comment, $mbObject); } $operation->chir_id = $mediuser->_id; // Mapping de la plage $this->mappingPlage($data['intervention'], $operation); $plageop_id = $operation->plageop_id; // Recherche d'une intervention existante sinon création if (!$operation->_id) { $operation->loadMatchingObject(); } // Si pas trouvé on recherche en hors plage if (!$operation->_id) { $operation->loadRefPlageOp(); $operation->plageop_id = null; $operation->temp_operation = null; $operation->time_operation = null; $operation->date = $operation->_ref_plageop->_id ? $operation->_ref_plageop->date : $operation->date; if ($operation->countMatchingList() == 1) { $operation->loadMatchingObject(); } if (!$operation->_id && $plageop_id) { $operation->plageop_id = $plageop_id; $operation->date = null; } } // Mapping de l'intervention $this->mappingIntervention($data, $operation); // Store de l'intervention // Notifier les autres destinataires autre que le sender $operation->_eai_sender_guid = $sender->_guid; $msgInterv = $operation->store(); CEAIMbObject::storeIdex($idex, $operation, $sender); $modified_fields = CEAIMbObject::getModifiedFields($operation); $codes = array($msgInterv ? "A201" : "I201"); if ($msgInterv) { $warning .= $msgInterv . " "; } else { $comment .= "Intervention : {$operation->_id}."; $comment .= $modified_fields ? " Les champs mis à jour sont les suivants : {$modified_fields}." : null; } return $exchange_hprim->setAck($dom_acq, $codes, $warning, $comment, $operation); }
* @subpackage patients * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ * @link http://www.mediboard.org */ CCanDo::checkRead(); $patient_id = CValue::post('patient_id'); $vitale_data = json_decode(stripslashes(CValue::post('vitale_data'))); $update_patient_fields = array('administrative' => array('nom', 'prenom', 'sexe', 'naissance', 'rang_naissance', 'matricule', 'adresse', 'cp', 'ville'), 'assure' => array('assure_nom', 'assure_prenom', 'assure_naissance', 'assure_sexe', 'assure_matricule', 'assure_adresse', 'assure_cp', 'assure_ville', 'code_exo', 'code_regime', 'caisse_gest', 'centre_gest', 'code_gestion', 'deb_amo', 'fin_amo', 'cmu')); $patient_vitale = new CPatient(); foreach ($vitale_data as $_field => $_data) { $patient_vitale->{$_field} = $_data; } $patient_mb = new CPatient(); $patient_mb->load($patient_id); $patient_fields = array(); if ($patient_mb->_id) { foreach ($update_patient_fields as $_type => $_fields) { $patient_fields[$_type] = array(); foreach ($_fields as $_field) { $patient_fields[$_type][$_field] = strtolower($patient_mb->{$_field}) == strtolower($patient_vitale->{$_field}); } } } $smarty = new CSmartyDP('modules/dPpatients'); $smarty->assign('patient_vitale', $patient_vitale); $smarty->assign('patient_mb', $patient_mb); $smarty->assign('fields', $patient_fields); $smarty->assign('patient_id', $patient_id); $smarty->display('update_patient_from_vitale.tpl');
/** * @see parent::onBeforeMerge */ function onBeforeMerge(CMbObject $mbObject) { if (!parent::onBeforeMerge($mbObject)) { return; } // Si pas en mode alternatif if (!CAppUI::conf("alternative_mode")) { throw new CMbException("no_alternative_mode"); } $patient = $mbObject; $patient_elimine = new CPatient(); $patient_elimine->load(reset($mbObject->_merging)); // Si Client if (!CAppUI::conf('sip server')) { $mbObject->_fusion = array(); foreach (CGroups::loadGroups() as $_group) { /** @var CInteropSender $sender */ $sender = $mbObject->_eai_sender_guid ? CMbObject::loadFromGuid($mbObject->_eai_sender_guid) : null; if ($sender && $sender->group_id == $_group->_id) { continue; } $patient->_IPP = null; $patient->loadIPP($_group->_id); $patient1_ipp = $patient->_IPP; $patient_elimine->_IPP = null; $patient_elimine->loadIPP($_group->_id); $patient2_ipp = $patient_elimine->_IPP; // Passage en trash des IPP des patients $tap_IPP = CPatient::getTagIPP($_group->_id); if (!$tap_IPP) { continue; } $idexPatient = new CIdSante400(); $idexPatient->tag = $tap_IPP; $idexPatient->object_class = "CPatient"; $idexPatient->object_id = $patient->_id; $idexsPatient = $idexPatient->loadMatchingList(); $idexPatientElimine = new CIdSante400(); $idexPatientElimine->tag = $tap_IPP; $idexPatientElimine->object_class = "CPatient"; $idexPatientElimine->object_id = $patient_elimine->_id; $idexsPatientElimine = $idexPatientElimine->loadMatchingList(); $idexs = array_merge($idexsPatient, $idexsPatientElimine); $idexs_changed = array(); if (count($idexs) > 1) { foreach ($idexs as $_idex) { // On continue pour ne pas mettre en trash l'IPP du patient que l'on garde if ($_idex->id400 == $patient1_ipp) { continue; } $old_tag = $_idex->tag; $_idex->tag = CAppUI::conf('dPpatients CPatient tag_ipp_trash') . $tap_IPP; $_idex->last_update = CMbDT::dateTime(); if (!($msg = $_idex->store())) { if ($_idex->object_id == $patient_elimine->_id) { $idexs_changed[$_idex->_id] = $old_tag; } } } } if (!$patient1_ipp && !$patient2_ipp) { continue; } $mbObject->_fusion[$_group->_id] = array("patientElimine" => $patient_elimine, "patient1_ipp" => $patient1_ipp, "patient2_ipp" => $patient2_ipp, "idexs_changed" => $idexs_changed); } } $this->sendFormatAction("onBeforeMerge", $mbObject); }
<?php /** * $Id$ * * @package Mediboard * @subpackage Patients * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ */ $patient_id = CValue::post('patient_id'); $patient = new CPatient(); if (!$patient->load($patient_id)) { CAppUI::stepAjax("Chargement impossible du patient", UI_MSG_ERROR); } $patient->patient_link_id = ""; if ($msg = $patient->store()) { CAppUI::stepAjax("Association du patient impossible : {$msg}", UI_MSG_ERROR); } CAppUI::stepAjax("{$patient->_view} désassocié"); CApp::rip();
<?php /** * $Id$ * * @category Maternité * @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 */ CCanDo::checkRead(); $allaitement_id = CValue::get("allaitement_id"); $patient_id = CValue::getOrSession("patient_id"); $allaitement = new CAllaitement(); $allaitement->load($allaitement_id); if (!$allaitement->_id) { $allaitement->patient_id = $patient_id; } $patient = new CPatient(); $patient->load($allaitement->patient_id); $grossesses = $patient->loadRefsGrossesses(); $smarty = new CSmartyDP(); $smarty->assign("allaitement", $allaitement); $smarty->assign("grossesses", $grossesses); $smarty->display("inc_edit_allaitement.tpl");
/** * Enregistrement des actes CCAM * * @param CHPrimXMLAcquittementsServeurActivitePmsi $dom_acq DOM Acquittement * @param CMbObject $mbObject Object * @param array $data Data that contain the nodes * * @return string Acquittement **/ function handle(CHPrimXMLAcquittementsServeurActivitePmsi $dom_acq, CMbObject $mbObject, $data) { /** @var COperation $mbObject */ $exchange_hprim = $this->_ref_echange_hprim; $sender = $exchange_hprim->_ref_sender; $sender->loadConfigValues(); $this->_ref_sender = $sender; // Acquittement d'erreur : identifiants source du patient / séjour non fournis if (!$data['idSourcePatient'] || !$data['idSourceVenue']) { return $exchange_hprim->setAckError($dom_acq, "E206", null, $mbObject, $data); } // IPP non connu => message d'erreur $IPP = CIdSante400::getMatch("CPatient", $sender->_tag_patient, $data['idSourcePatient']); if (!$IPP->_id) { return $exchange_hprim->setAckError($dom_acq, "E013", null, $mbObject, $data); } // Chargement du patient $patient = new CPatient(); $patient->load($IPP->object_id); // Num dossier non connu => message d'erreur $NDA = CIdSante400::getMatch("CSejour", $sender->_tag_sejour, $data['idSourceVenue']); if (!$NDA->_id) { return $exchange_hprim->setAckError($dom_acq, "E014", null, $mbObject, $data); } // Chargement du séjour $sejour = new CSejour(); $sejour->load($NDA->object_id); // Si patient H'XML est différent du séjour if ($sejour->patient_id != $patient->_id) { return $exchange_hprim->setAckError($dom_acq, "E015", null, $mbObject, $data); } // Chargement du patient du séjour $sejour->loadRefPatient(); //Mapping actes CCAM $actes = array("CCAM" => $this->mappingActesCCAM($data), "NGAP" => $this->mappingActesNGAP($data)); $codes = array(); $warning = array(); foreach ($actes as $type => $_actes) { foreach ($_actes as $_key => $_acte) { $return = $this->storeActe($_acte, $type, $sejour, $patient, $sender->_tag_hprimxml); $number = $type == "CCAM" ? "0" : "1"; //Cas d'une erreur lors de l'ajoutement if (!is_object($return)) { $warning["A401"][] = $return; $codes[$_acte["idSourceActe{$type}"]] = array("code" => "A4{$number}1", "commentaires" => $return); $actes[$type][$_key]["statut"] = "avt"; continue; } $actes[$type][$_key]["statut"] = "ok"; //Cas d'une modification ou d'un ajout if ($return->_id) { $codes[$_acte["idSourceActe{$type}"]] = array("code" => "I4{$number}1", "commentaires" => null); continue; } //Cas de la suppression $codes[$_acte["idSourceActe{$type}"]] = array("code" => "I4{$number}2", "commentaires" => null); } } return $exchange_hprim->setAck($dom_acq, $codes, $warning, null, $sejour, $actes); }
/** * @see parent::store() */ function store() { $this->completeField("entree_reelle", "entree", "patient_id", "type_pec", "grossesse_id", "mode_sortie"); /** @var CSejour $old */ $old = $this->loadOldObject(); // Vérification de la validité des codes CIM if ($this->DP != null) { $dp = CCodeCIM10::get($this->DP); if (!$dp->exist) { CAppUI::setMsg("Le code CIM saisi n'est pas valide", UI_MSG_WARNING); $this->DP = ""; } } if ($this->DR != null) { $dr = CCodeCIM10::get($this->DR); if (!$dr->exist) { CAppUI::setMsg("Le code CIM saisi n'est pas valide", UI_MSG_WARNING); $this->DR = ""; } } // Mode de sortie normal par défaut si l'autorisation de sortie est réalisée if ($this->conf("specified_output_mode") && !$this->mode_sortie && $this->fieldModified("confirme")) { $this->mode_sortie = "normal"; } // Annulation de l'établissement de transfert si le mode de sortie n'est pas transfert if (null !== $this->mode_sortie) { if ("transfert" != $this->mode_sortie) { $this->etablissement_sortie_id = ""; } if ("mutation" != $this->mode_sortie) { $this->service_sortie_id = ""; } } // Mise à jour du type PEC si vide if (!$this->_id && !$this->type_pec) { $this->type_pec = $this->grossesse_id ? "O" : "M"; } // Annulation de la sortie réelle si on annule le mode de sortie if ($this->mode_sortie === "") { $this->sortie_reelle = ""; } // Annulation de l'établissement de provenance si le mode d'entrée n'est pas transfert if ($this->fieldModified("mode_entree")) { if ("7" != $this->mode_entree) { $this->etablissement_entree_id = ""; } if ("6" != $this->mode_entree) { $this->service_entree_id = ""; } } // Passage au mode transfert si on value un établissement de provenance if ($this->fieldModified("etablissement_entree_id")) { if ($this->etablissement_entree_id != null) { $this->mode_entree = 7; } } // Passage au mode mutation si on value un service de provenance if ($this->fieldModified("service_entree_id")) { if ($this->service_entree_id != null) { $this->mode_entree = 6; } } $patient_modified = $this->fieldModified("patient_id"); // Si le patient est modifié et qu'il y a des consultations, on cascade les consultations if (!$this->_forwardRefMerging && $this->sejour_id && $patient_modified) { /** @var CConsultation[] $consultations */ $consultations = $this->loadBackRefs("consultations"); foreach ($consultations as $_consult) { $_consult->_sync_consults_from_sejour = true; $_consult->patient_id = $this->patient_id; if ($msg = $_consult->store()) { return $msg; } } } // Pour un séjour non annulé, mise à jour de la date de décès du patient // suivant le mode de sortie if (!$this->annule) { $patient = new CPatient(); $patient->load($this->patient_id); if ($this->fieldModified("mode_sortie")) { if ("deces" == $this->mode_sortie) { $patient->deces = $this->_date_deces; } else { if ($this->_old->mode_sortie == "deces") { $patient->deces = ""; } } } // On verifie que le champ a été modifié pour faire le store (sinon probleme lors de la fusion de patients) if ($patient->fieldModified("deces")) { // Ne pas faire de return $msg ici, car ce n'est pas "bloquant" $patient->store(); } } // Si annulation possible que par le chef de bloc if (CAppUI::conf("dPplanningOp COperation cancel_only_for_resp_bloc") && $this->fieldModified("annule", 1) && $this->entree_reelle && !CModule::getCanDo("dPbloc")->edit) { foreach ($this->loadRefsOperations() as $_operation) { if ($_operation->rank) { CAppUI::setMsg("Impossible de sauvegarder : une des interventions du séjour est validée.\nContactez le responsable de bloc", UI_MSG_ERROR); return null; } } } // On fixe la récusation si pas définie pour un nouveau séjour if (!$this->_id && ($this->recuse === "" || $this->recuse === null)) { $this->recuse = CAppUI::conf("dPplanningOp CSejour use_recuse") ? -1 : 0; } // no matter of config, if sejour is "urgence" type: recusation 0 if ($this->type == "urg") { $this->recuse = 0; } // Si gestion en mode expert de l'isolement if (CAppUI::conf("dPplanningOp CSejour systeme_isolement") == "expert") { $this->isolement_date = $this->_isolement_date !== $this->entree && $this->isolement ? $this->_isolement_date : ""; if (!$this->isolement) { $this->isolement_fin = ""; } } $facture = null; if (CModule::getActive("dPfacturation") && CAppUI::conf("dPplanningOp CFactureEtablissement use_facture_etab")) { // Création de la facture de sejour $this->loadRefsFactureEtablissement(); $facture = $this->_ref_last_facture; if (!$facture->_id) { $facture->ouverture = CMbDT::date(); } if (CAppUI::conf("dPfacturation CFactureEtablissement use_temporary_bill")) { $facture->temporaire = 1; } $facture->group_id = $this->group_id; $facture->patient_id = $this->patient_id; $facture->praticien_id = $this->praticien_id; $facture->type_facture = $this->_type_sejour; $facture->dialyse = $this->_dialyse; $facture->cession_creance = $this->_cession_creance; $facture->statut_pro = $this->_statut_pro; $facture->assurance_maladie = $this->_assurance_maladie; $facture->assurance_accident = $this->_assurance_accident; $facture->rques_assurance_accident = $this->_rques_assurance_accident; $facture->rques_assurance_maladie = $this->_rques_assurance_maladie; //Store de la facture if ($msg = $facture->store()) { return $msg; } } $this->completeField("mode_entree_id"); if ($this->mode_entree_id) { /** @var CModeEntreeSejour $mode */ $mode = $this->loadFwdRef("mode_entree_id"); $this->mode_entree = $mode->mode; } $this->completeField("mode_sortie_id"); if ($this->mode_sortie_id) { /** @var CModeSortieSejour $mode */ $mode = $this->loadFwdRef("mode_sortie_id"); $this->mode_sortie = $mode->mode; } // Gestion du tarif et precodage des actes if ($this->_bind_tarif && $this->_id) { $this->getActeExecution(); if ($msg = $this->bindTarif()) { return $msg; } } // Si on change la grossesse d'un séjour, il faut remapper les naissances éventuelles $change_grossesse = $this->fieldModified("grossesse_id"); /** @var CNaissance[] $naissances */ $naissances = array(); if ($change_grossesse) { $naissances = $old->loadRefGrossesse()->loadRefsNaissances(); } // Sectorisation Rules $this->getServiceFromSectorisationRules(); if ($this->fieldModified("completion_sortie") && $this->completion_sortie && !$this->reception_sortie) { $this->reception_sortie = $this->completion_sortie; } if ($this->fieldModified("reception_sortie", "") && !$this->completion_sortie) { $this->completion_sortie = ""; } $this->getUFs(); $eai_sender_guid = $this->_eai_sender_guid; // On fait le store du séjour if ($msg = parent::store()) { return $msg; } $this->_eai_sender_guid = $eai_sender_guid; if ($change_grossesse) { foreach ($naissances as $_naissance) { $_naissance->grossesse_id = $this->grossesse_id; if ($msg = $_naissance->store()) { return $msg; } } } // Changement des liaisons de prestations si besoin // Seulement par rapport à l'entrée if (CAppUI::conf("dPhospi prestations systeme_prestations", CGroups::loadCurrent()) == "expert") { $decalage = CMbDT::daysRelative($old->entree, $this->entree); if ($decalage != 0) { $liaisons = $this->loadBackRefs("items_liaisons"); foreach ($liaisons as $_liaison) { $_liaison->date = CMbDT::date("{$decalage} days", $_liaison->date); if ($msg = $_liaison->store()) { return $msg; } } } } if (CModule::getActive("dPfacturation") && CAppUI::conf("dPplanningOp CFactureEtablissement use_facture_etab")) { if (count($this->_ref_factures) == 0) { $liaison = new CFactureLiaison(); $liaison->object_id = $this->_id; $liaison->object_class = $this->_class; $liaison->facture_id = $facture->_id; $liaison->facture_class = "CFactureEtablissement"; //Store de la table de liaison entre facture et séjour if ($msg = $liaison->store()) { return $msg; } } } if ($patient_modified) { $list_backrefs = array("contextes_constante", "deliveries", "consultations"); foreach ($list_backrefs as $_backname) { /** @var CConstantesMedicales[]|CProductDelivery[]|CConsultation[] $backobjects */ $backobjects = $this->loadBackRefs($_backname); if (!$backobjects) { continue; } foreach ($backobjects as $_object) { if ($_object->patient_id == $this->patient_id) { continue; } $_object->patient_id = $this->patient_id; if ($_object instanceof CConsultation) { $_object->_skip_count = true; } if ($msg = $_object->store()) { CAppUI::setMsg($msg, UI_MSG_WARNING); } } } } // Cas d'une annulation de séjour if ($this->annule) { // Suppression des affectations if ($msg = $this->delAffectations()) { return $msg; } // Suppression des opérations if ($msg = $this->cancelOperations()) { return $msg; } // Annulation des mouvements if ($msg = $this->cancelMovements()) { return $msg; } } // Synchronisation des affectations if (!$this->_no_synchro && !($this->type == "seances")) { $this->loadRefsAffectations(); $firstAff =& $this->_ref_first_affectation; $lastAff =& $this->_ref_last_affectation; // Cas où on a une premiere affectation différente de l'heure d'admission if ($firstAff->_id && $firstAff->entree != $this->_entree) { $firstAff->entree = $this->_entree; $firstAff->_no_synchro = 1; $firstAff->store(); } // Cas où on a une dernière affectation différente de l'heure de sortie if ($lastAff->_id && $lastAff->sortie != $this->_sortie) { $lastAff->sortie = $this->_sortie; $lastAff->_no_synchro = 1; $lastAff->store(); } //si le sejour a une sortie ==> compléter le champ effectue de la derniere affectation if ($lastAff->_id) { $this->_ref_last_affectation->effectue = $this->sortie_reelle ? 1 : 0; $this->_ref_last_affectation->store(); } } // try to assign an affectation $this->createAffectationLitUnique(); $this->createAffectationService(); // Génération du NDA ? if ($this->_generate_NDA) { // On ne synchronise pas un séjour d'urgences qui est un reliquat $rpu = $this->loadRefRPU(); if ($rpu && $rpu->mutation_sejour_id && $rpu->sejour_id != $rpu->mutation_sejour_id) { return null; } if ($msg = $this->generateNDA()) { return $msg; } } return null; }
<?php /** * $Id$ * * @package Mediboard * @subpackage Labo * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ */ CCanDo::checkRead(); $examen = new CExamenLabo(); $examen->load(CValue::get("examen_id")); $patient = new CPatient(); $patient->load(CValue::get("patient_id")); $item = new CPrescriptionLaboExamen(); $resultats = $item->loadResults($patient->_id, $examen->_id, 20); // Création du graph $graph = new CResultatsLaboGraph($patient, $examen, $resultats); $graph->Stroke();
<?php /** * $Id$ * * @category Maternité * @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 */ CCanDo::checkRead(); $parturiente_id = CValue::get("parturiente_id"); $large_icon = CValue::get("large_icon"); $submit = CValue::get("submit"); $modify_grossesse = CValue::get("modify_grossesse"); $parturiente = new CPatient(); $parturiente->load($parturiente_id); $parturiente->loadLastGrossesse(); $smarty = new CSmartyDP(); $smarty->assign("object", $parturiente); $smarty->assign("patient", $parturiente); $smarty->assign("large_icon", $large_icon); $smarty->assign("submit", $submit); $smarty->assign("modify_grossesse", $modify_grossesse); $smarty->display("inc_input_grossesse.tpl");
/** * $Id: ajax_list_assurances.php 19840 2013-07-09 19:36:14Z phenxdesign $ * * @package Mediboard * @subpackage PlanningOp * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision: 19840 $ */ CCanDo::checkRead(); $sejour_id = CValue::get("sejour_id"); $patient_id = CValue::get("patient_id"); // Chargement du patient $patient = new CPatient(); $patient->load($patient_id); $patient->loadRefsCorrespondantsPatient(); // On récupére le séjour $sejour = new CSejour(); if ($sejour_id) { $sejour->load($sejour_id); // On vérifie que l'utilisateur a les droits sur le sejour if (!$sejour->_canRead) { global $m, $tab; CAppUI::setMsg("Vous n'avez pas accés à ce séjour", UI_MSG_WARNING); CAppUI::redirect("m={$m}&tab={$tab}&sejour_id=0"); } $patient = $sejour->_ref_patient; } else { $sejour->patient_id = $patient->_id; $sejour->_ref_patient = $patient;
/** * Recording a patient with an IPP in the system * * @param CHPrimXMLAcquittementsPatients $dom_acq Acquittement * @param CPatient &$newPatient Patient * @param array $data Datas * * @return CHPrimXMLAcquittementsPatients $msgAcq **/ function enregistrementPatient($dom_acq, &$newPatient, $data) { // Traitement du message des erreurs $codes = array(); $commentaire = $avertissement = $msgID400 = $msgIPP = ""; $_modif_patient = false; $echg_hprim = $this->_ref_echange_hprim; $sender = $echg_hprim->_ref_sender; $sender->loadConfigValues(); $this->_ref_sender = $sender; if ($msg = $this->check($dom_acq, $newPatient, $data)) { return $msg; } $idSourcePatient = $data['idSourcePatient']; $idCiblePatient = $data['idCiblePatient']; // Si CIP if (!CAppUI::conf('sip server')) { $IPP = CIdSante400::getMatch("CPatient", $sender->_tag_patient, $idSourcePatient); // idSource non connu if (!$IPP->_id) { // idCible fourni if ($idCiblePatient) { if ($newPatient->load($idCiblePatient)) { // Le patient trouvé est-il différent ? if ($commentaire = $this->checkSimilarPatient($newPatient, $data['patient'])) { return $echg_hprim->setAckError($dom_acq, "E016", $commentaire, $newPatient); } // Mapping du patient $newPatient = $this->mappingPatient($data['patient'], $newPatient); // On store le patient $msgPatient = CEAIPatient::storePatient($newPatient, $sender); $commentaire = CEAIPatient::getComment($newPatient); $_code_IPP = "I021"; $_modif_patient = true; } else { $_code_IPP = "I020"; } } else { $_code_IPP = "I022"; } // Mapping du patient $newPatient = $this->mappingPatient($data['patient'], $newPatient); if (!$newPatient->_id) { // Patient retrouvé if ($newPatient->loadMatchingPatient()) { // Mapping du patient $newPatient = $this->mappingPatient($data['patient'], $newPatient); // On store le patient $msgPatient = CEAIPatient::storePatient($newPatient, $sender); $commentaire = CEAIPatient::getComment($newPatient); $_code_IPP = "A021"; $_modif_patient = true; } else { // On store le patient $msgPatient = CEAIPatient::storePatient($newPatient, $sender); $commentaire = CEAIPatient::getComment($newPatient); } } $msgIPP = CEAIPatient::storeIPP($IPP, $newPatient, $sender); $codes = array($msgPatient ? $_modif_patient ? "A003" : "A002" : ($_modif_patient ? "I002" : "I001"), $msgIPP ? "A005" : $_code_IPP); if ($msgPatient || $msgIPP) { $avertissement = $msgPatient . " " . $msgIPP; } else { $commentaire .= "IPP créé : {$IPP->id400}."; } } else { $newPatient->load($IPP->object_id); if ($commentaire = $this->checkSimilarPatient($newPatient, $data['patient'])) { return $echg_hprim->setAckError($dom_acq, "E016", $commentaire, $newPatient); } // Mapping du patient $newPatient = $this->mappingPatient($data['patient'], $newPatient); // idCible non fourni if (!$idCiblePatient) { $_code_IPP = "I023"; } else { $tmpPatient = new CPatient(); // idCible connu if ($tmpPatient->load($idCiblePatient)) { if ($tmpPatient->_id != $IPP->object_id) { $commentaire = "L'identifiant source fait référence au patient : {$IPP->object_id} "; $commentaire .= "et l'identifiant cible au patient : {$tmpPatient->_id}."; return $echg_hprim->setAckError($dom_acq, "E004", $commentaire, $newPatient); } $_code_IPP = "I024"; } else { $_code_IPP = "A020"; } } // On store le patient $msgPatient = CEAIPatient::storePatient($newPatient, $sender); $commentaire = CEAIPatient::getComment($newPatient); if ($newPatient->_id && $sender->_configs["insc_integrated"]) { $this->storeINSC($newPatient, $data["numeroSante"]); } $codes = array($msgPatient ? "A003" : "I002", $_code_IPP); if ($msgPatient) { $avertissement = $msgPatient . " "; } } } return $echg_hprim->setAck($dom_acq, $codes, $avertissement, $commentaire, $newPatient); }