/**
  * Return a object concern praticien and a patient in date
  *
  * @param Date   $date         Date
  * @param String $praticien_id Praticien id
  * @param String $patient_id   Patient id
  *
  * @return CConsultation|COperation|null
  */
 function getObject($date, $praticien_id, $patient_id)
 {
     $intervention = new COperation();
     $where = array("plagesop.date" => "= '{$date}'", "operations.chir_id" => "= '{$praticien_id}'", "sejour.patient_id" => "= '{$patient_id}'");
     $leftjoin = array("plagesop" => "operations.plageop_id = plagesop.plageop_id", "sejour" => "operations.sejour_id = sejour.sejour_id");
     $intervention->loadObject($where, "plagesop.debut DESC", null, $leftjoin);
     $object = $intervention;
     if (!$object->_id) {
         $consultation = new CConsultation();
         $where = array("plageconsult.date" => "= '{$date}'", "plageconsult.chir_id" => "= '{$praticien_id}'", "consultation.patient_id" => "= '{$patient_id}'");
         $leftjoin = array("plageconsult" => "consultation.plageconsult_id = plageconsult.plageconsult_id");
         $consultation->loadObject($where, "consultation.heure DESC", null, $leftjoin);
         $object = $consultation;
         if (!$object->_id) {
             return null;
         }
     }
     return $object;
 }
コード例 #2
0
 /**
  * Récupération du séjour par le numéro de visite
  *
  * @param CSejour $newVenue Admit
  * @param array   $data     Datas
  *
  * @return bool
  */
 function getSejourByVisitNumber(CSejour $newVenue, $data)
 {
     $sender = $this->_ref_sender;
     $venueVN = CValue::read($data['admitIdentifiers'], "VN");
     $where = $ljoin = array();
     $where["id_sante400.tag"] = " = '{$sender->_tag_visit_number}'";
     $where["id_sante400.id400"] = " = '{$venueVN}'";
     switch ($this->queryTextNode("PV1.2", $data["PV1"])) {
         // Identifie la venue pour actes et consultation externe
         case 'O':
             $consultation = new CConsultation();
             $ljoin["id_sante400"] = "id_sante400.object_id = consultation.consultation_id";
             $where["id_sante400.object_class"] = " = 'CConsultation'";
             $where["consultation.type"] = " != 'chimio'";
             $consultation->loadObject($where, null, null, $ljoin);
             // Nécessaire pour savoir quel objet créé en cas de besoin
             $this->_object_found_by_vn = $consultation;
             if (!$consultation->_id) {
                 return false;
             }
             $newVenue->load($consultation->sejour_id);
             return true;
             // Identifie une séance
         // Identifie une séance
         case 'R':
             $consultation = new CConsultation();
             $ljoin["id_sante400"] = "id_sante400.object_id = consultation.consultation_id";
             $where["id_sante400.object_class"] = " = 'CConsultation'";
             $where["consultation.type"] = " = 'chimio'";
             $consultation->loadObject($where, null, null, $ljoin);
             // Nécessaire pour savoir quel objet créé en cas de besoin
             $this->_object_found_by_vn = $consultation;
             if (!$consultation->_id) {
                 return false;
             }
             $newVenue->load($consultation->sejour_id);
             return true;
             // Identifie le n° de passage aux urgences
         // Identifie le n° de passage aux urgences
         case 'E':
             $rpu = new CRPU();
             $ljoin["id_sante400"] = "id_sante400.object_id = rpu.rpu_id";
             $where["id_sante400.object_class"] = " = 'CRPU'";
             $rpu->loadObject($where, null, null, $ljoin);
             // Nécessaire pour savoir quel objet créé en cas de besoin
             $this->_object_found_by_vn = $rpu;
             if (!$rpu->_id) {
                 return false;
             }
             $newVenue->load($rpu->sejour_id);
             return true;
             // Identifie le séjour ou hospitalisation à domicile
         // Identifie le séjour ou hospitalisation à domicile
         default:
             $idexVisitNumber = CIdSante400::getMatch("CSejour", $sender->_tag_visit_number, $venueVN);
             $this->_object_found_by_vn = $newVenue;
             if (!$idexVisitNumber->_id) {
                 return false;
             }
             $newVenue->load($idexVisitNumber->object_id);
             $this->_object_found_by_vn = $newVenue;
             return true;
     }
 }
コード例 #3
0
 /**
  * @see parent::store()
  */
 function store()
 {
     $this->completeField("pour_compte_id", "chir_id");
     $change_pour_compte = $this->fieldModified("pour_compte_id");
     if ($msg = parent::store()) {
         return $msg;
     }
     if ($change_pour_compte) {
         $consults = $this->loadRefsConsultations();
         foreach ($consults as $_consult) {
             $facture = $_consult->loadRefFacture();
             $facture->praticien_id = $this->pour_compte_id ? $this->pour_compte_id : $this->chir_id;
             $facture->store();
         }
     }
     // pause
     if ($this->_update_pause && $this->_pause && $this->_pause_repeat_time) {
         $consult = new CConsultation();
         $where = array();
         $where["plageconsult_id"] = " = '{$this->_id}' ";
         $where["patient_id"] = " IS NULL";
         $consult->loadObject($where);
         $consult->plageconsult_id = $this->_id;
         $consult->heure = $this->_pause;
         $consult->duree = $this->_pause_repeat_time;
         $consult->chrono = 16;
         $consult->_hour = null;
         $consult->_min = null;
         if ($msg = $consult->store()) {
             CAppUI::stepAjax($msg, UI_MSG_WARNING);
         }
     }
     return null;
 }
コード例 #4
0
 /**
  * Chargement de la consult de chirurgie avant l'intervention,
  * cad la dernière consultation pour le patient par le chirurgien avant l'internvention et hors du séjour
  *
  * @return CConsultation
  */
 public function loadRefConsultChir()
 {
     $sejour = $this->loadRefSejour();
     $entree = CMbDT::date($sejour->entree);
     $ljoin["plageconsult"] = "consultation.plageconsult_id = plageconsult.plageconsult_id";
     $where["patient_id"] = "= '{$sejour->patient_id}'";
     $where["chir_id"] = "= '{$this->chir_id}'";
     $where["date"] = "< '{$entree}'";
     $where[] = "sejour_id IS NULL OR sejour_id != '{$this->sejour_id}'";
     $order = "date DESC";
     $consult = new CConsultation();
     $consult->loadObject($where, $order, null, $ljoin);
     return $this->_ref_consult_chir = $consult;
 }
コード例 #5
0
 function findConsult($patient_id, $prat, $date, $store = true, $time = null)
 {
     // Trouver ou importer le patient
     $patient = $this->getOrImportObject($this->_patient_class, $patient_id);
     if (!$patient || !$patient->_id) {
         CAppUI::setMsg("Patient non retrouvé et non importé : {$patient_id}", UI_MSG_WARNING);
         return false;
     }
     // Trouver le praticien de la consult
     $mediuser = $this->getMbObjectByClass("CMediusers", $prat);
     if (!$mediuser->_id) {
         CAppUI::setMsg("Praticien de la consult non retrouvé : {$prat}", UI_MSG_WARNING);
         return false;
     }
     // Recherche d'une consult qui se passe entre 2 jours avant ou 1 jour apres
     $date_min = CMbDT::date("-2 DAYS", $date);
     $date_max = CMbDT::date("+1 DAYS", $date);
     $consult = new CConsultation();
     $ljoin = array("plageconsult" => "consultation.plageconsult_id = plageconsult.plageconsult_id");
     $where = array("consultation.patient_id" => "= '{$patient->_id}'", "plageconsult.chir_id" => "= '{$mediuser->_id}'", "plageconsult.date" => "BETWEEN '{$date_min}' AND '{$date_max}'");
     $consult->loadObject($where, null, null, $ljoin);
     if (!$consult->_id) {
         $consult = $this->makeConsult($patient->_id, $mediuser->_id, $date, $store, $time);
     }
     return $consult;
 }
コード例 #6
0
 /**
  * Return the object for attach the document
  *
  * @param String   $date         date
  * @param CPatient $patient      patient
  * @param String   $praticien_id praticien id
  * @param CSejour  $sejour       sejour
  *
  * @return CConsultation|COperation|CSejour
  */
 function getObjectWithDate($date, $patient, $praticien_id, $sejour)
 {
     //Recherche de la consutlation dans le séjour
     $date = CMbDT::date($date);
     $date_before = CMbDT::date("- 2 DAY", $date);
     $consultation = new CConsultation();
     $where = array("patient_id" => "= '{$patient->_id}'", "annule" => "= '0'", "plageconsult.date" => "BETWEEN '{$date_before}' AND '{$date}'", "plageconsult.chir_id" => "= '{$praticien_id}'", "sejour_id" => "= '{$sejour->_id}'");
     $leftjoin = array("plageconsult" => "consultation.plageconsult_id = plageconsult.plageconsult_id");
     $consultation->loadObject($where, "plageconsult.date DESC", null, $leftjoin);
     //Recherche d'une consultation qui pourrait correspondre
     if (!$consultation->_id) {
         unset($where["sejour_id"]);
         $consultation->loadObject($where, "plageconsult.date DESC", null, $leftjoin);
     }
     //Consultation trouvé dans un des deux cas
     if ($consultation->_id) {
         return $consultation;
     }
     //Recherche d'une opération dans le séjour
     $where = array("sejour.patient_id" => "= '{$patient->_id}'", "plagesop.date" => "BETWEEN '{$date_before}' AND '{$date}'", "operations.annulee" => "= '0'", "sejour.sejour_id" => "= '{$sejour->_id}'");
     if ($praticien_id) {
         $where["operations.chir_id"] = "= '{$praticien_id}'";
     }
     $leftjoin = array("plagesop" => "operations.plageop_id = plagesop.plageop_id", "sejour" => "operations.sejour_id = sejour.sejour_id");
     $operation = new COperation();
     $operation->loadObject($where, "plagesop.date DESC", null, $leftjoin);
     if ($operation->_id) {
         return $operation;
     }
     /*if (!$sejour) {
           $where = array(
             "patient_id" => "= '$patient->_id'",
             "annule"     => "= '0'",
           );
           $sejours = CSejour::loadListForDate($date, $where, null, 1);
           $sejour = reset($sejours);
     
           if (!$sejour) {
             return null;
           }
         }*/
     return $sejour;
 }