/** * Redefinition du store * * @return void|string **/ function store() { if (!$this->_id && $this->object_class && $this->object_id) { $this->_ref_object = new $this->object_class(); $this->_ref_object->load($this->object_id); $this->_ref_object->loadRefPatient(); $this->_ref_object->loadRefPraticien(); $this->_ref_object->loadRefsObjects(); $this->_ref_object->loadRefsReglements(); $this->_ref_object->loadRefsRelances(); $this->date = CMbDT::date(); $this->du_patient = $this->_ref_object->_du_restant_patient + $this->_ref_object->_reglements_total_patient; $this->du_tiers = $this->_ref_object->_du_restant_tiers + $this->_ref_object->_reglements_total_tiers; $der_relance = $this->_ref_object->_ref_last_relance; if ($der_relance->_id) { if ($der_relance->statut == "inactive") { return "La derniere relance est inactive"; } if ($der_relance->etat != "regle") { $this->numero = $der_relance->numero + 1; $der_relance->etat = "renouvelle"; $der_relance->store(); } else { return "La derniere relance est reglee"; } } if (!$this->numero) { $this->numero = 1; } switch ($this->numero) { case "1": $this->du_patient += CAppUI::conf("dPfacturation CRelance add_first_relance"); $this->statut = "first"; break; case "2": $this->du_patient += CAppUI::conf("dPfacturation CRelance add_second_relance"); $this->statut = "second"; break; case "3": $this->du_patient += CAppUI::conf("dPfacturation CRelance add_third_relance"); $this->statut = "third"; break; } } // Standard store if ($msg = parent::store()) { return $msg; } }
if ($num_facture) { $where["facture_id"] = " = '{$num_facture}' "; } if ($numero && !CAppUI::conf("dPfacturation Other use_search_easy") && ($etat_relance || $search_easy == 7)) { $where["facture_relance.numero"] = " = '{$numero}'"; } if ($search_easy == 5) { $where["annule"] = " = '1'"; } if ($search_easy == 1) { $where["definitive"] = " = '1'"; } if ($xml_etat != "") { $where["facture"] = " = '{$xml_etat}' "; } $facture = new CFactureEtablissement(); $total_factures = $facture->countList($where, null, $ljoin); $factures = $facture->loadList($where, "ouverture ASC, numero", "{$page}, 25", "facture_id", $ljoin); //Affichage uniquement des factures qui contiennent des séjours foreach ($factures as $key => $_facture) { /** @var CFacture $_facture*/ $_facture->loadRefPatient(); $_facture->loadRefsItems(); $_facture->loadRefsObjects(); $nb_tarmed = count($_facture->_ref_actes_tarmed); $nb_caisse = count($_facture->_ref_actes_caisse); $nb_ngap = count($_facture->_ref_actes_ngap); $nb_ccam = count($_facture->_ref_actes_ccam); if (!count($_facture->_ref_sejours) && !count($_facture->_ref_consults)) { unset($factures[$key]); } elseif ($nb_tarmed == 0 && $nb_caisse == 0 && $nb_ngap == 0 && $nb_ccam == 0 && !$etat_cotation && $search_easy != 4 && $search_easy != 0) {
/** * Chargement du garant de la facture * * @param CFactureCabinet|CFactureEtablissement $facture la facture * * @return string */ function loadGarant($facture) { $patient = $facture->_ref_patient; $facture->loadRefAssurance(); if (strlen($patient->cp) > 4) { $patient->cp = substr($patient->cp, 1); } $assurance_patient = null; $view = "_longview"; $send_assur = !$facture->send_assur_base && $facture->type_facture == "maladie"; if ($facture->assurance_maladie && $send_assur && $facture->_ref_assurance_maladie->type_pec != "TG") { $assurance_patient = $facture->_ref_assurance_maladie; } elseif ($facture->assurance_accident && !$facture->send_assur_compl && $facture->type_facture == "accident") { $assurance_patient = $facture->_ref_assurance_accident->type_pec == "TG" ? $patient : $facture->_ref_assurance_accident; } else { $assurance_patient = $patient; $view = "_view"; } return $assurance_patient->{$view}; }
// Filtre sur les praticiens $chir_id = CValue::getOrSession("chir"); $listPrat = CConsultation::loadPraticiensCompta($chir_id); $where["facture_etablissement.praticien_id"] = CSQLDataSource::prepareIn(array_keys($listPrat)); // Initialisation du tableau de reglements $reglement = new CReglement(); $recapReglement["total"] = array("nb_sejours" => "0", "reste_patient" => "0", "reste_tiers" => "0", "du_patient" => "0", "du_tiers" => "0", "nb_reglement_patient" => "0", "nb_reglement_tiers" => "0", "nb_impayes_tiers" => "0", "nb_impayes_patient" => "0", "secteur1" => "0", "secteur2" => "0"); foreach (array_merge($reglement->_specs["mode"]->_list, array("")) as $_mode) { $recapReglement[$_mode] = array("du_patient" => "0", "du_tiers" => "0", "nb_reglement_patient" => "0", "nb_reglement_tiers" => "0"); } // Reglements via les factures d'établissement $where["cloture"] = "IS NOT NULL"; $where["facture_etablissement.patient_id"] = "IS NOT NULL"; $order = "ouverture, praticien_id"; //mbTrace(count($where)); $facture = new CFactureEtablissement(); $listFactures = $facture->loadGroupList($where, $order, null, "facture_id", $ljoin); $listPlages = array(); foreach ($listFactures as $_facture) { /** @var CFacture $_facture*/ $_facture->loadRefPatient(); $_facture->loadRefPraticien(); $_facture->loadRefsObjects(); $_facture->loadRefsReglements(); $_facture->loadRefsNotes(); // Ajout de reglements $_facture->_new_reglement_patient = new CReglement(); $_facture->_new_reglement_patient->setObject($_facture); $_facture->_new_reglement_patient->emetteur = "patient"; $_facture->_new_reglement_patient->montant = $_facture->_du_restant_patient; $_facture->_new_reglement_tiers = new CReglement();
/** * Fonction permettant de partir d'un numero de reference de retrouver la facture correspondante * * @param string $num_reference le numero de reference * * @return CFactureEtablissement **/ function findFacture($num_reference) { $facture = new CFactureEtablissement(); $facture->num_reference = $num_reference; $facture->loadMatchingObject(); return $facture; }
$filter = new CConsultation(); $filter->_date_min = CValue::getOrSession("_date_min", CMbDT::date()); $filter->_date_max = CValue::getOrSession("_date_max", CMbDT::date("+ 0 day")); // Filtre sur les praticiens $chir_id = CValue::getOrSession("chir"); $prat = new CMediusers(); $prat->load($chir_id); $listPrat = CConsultation::loadPraticiensCompta($chir_id); $where = array(); $where["cloture"] = "BETWEEN '{$filter->_date_min}' AND '{$filter->_date_max}'"; $where["praticien_id"] = CSQLDataSource::prepareIn(array_keys($listPrat)); if (CAppUI::conf("dPfacturation CFactureCabinet view_bill")) { $facture = new CFactureCabinet(); } if (CAppUI::conf("dPfacturation CFactureEtablissement view_bill")) { $facture = new CFactureEtablissement(); } $factures = $facture->loadList($where, "cloture, praticien_id"); $total_retrocession = 0; $total_montant = 0; foreach ($factures as $_facture) { $_facture->loadRefPatient(); $_facture->loadRefPraticien(); $_facture->loadRefsObjects(); $_facture->loadRefsReglements(); $_facture->updateMontantRetrocession(); $total_retrocession += $_facture->_montant_retrocession; $total_montant += $_facture->_montant_avec_remise; } // Création du template $smarty = new CSmartyDP();
/** * Edition du bas de la facture (partie BVR) * * @param int $montant_facture montant du BVR * * @return void */ function editBVR($montant_facture) { $group = CGroups::loadCurrent(); //le 01 sera fixe car il correspond à un "Codes des genres de justificatifs (BC)" ici :01 = BVR en CHF $genre = "01"; $montant = sprintf("%010s", $montant_facture * 100); $cle = $this->facture->getNoControle($genre . $montant); $num_adherent = $this->facture->loadNumAdherent($this->praticien->adherent); $this->adherent2 = $num_adherent["bvr"]; if (!$this->adherent) { $this->adherent = $num_adherent["compte"]; } $_num_reference = str_replace(' ', '', $this->facture->num_reference); $bvr = $genre . $montant . $cle . ">" . $_num_reference . "+ " . $this->adherent2 . ">"; // Dimensions du bvr $largeur_bvr = 210; $hauteur_bvr = 106; $haut_doc = 297 - $hauteur_bvr; // Une ligne = 1/6 pouce = 4.2333 mm $h_ligne = 4.2333; // $hauteur_bvr/25; // Une colonne = 1/10 pouce = 2.54 mm $l_colonne = 2.54; // $largeur_bvr/83; $left_offset = 84 * $l_colonne - $largeur_bvr; //Boucle utilisée pour dupliquer les Partie1 et 2 avec un décalage de colonnes for ($i = 0; $i <= 1; $i++) { $decalage = $i * 24 * $l_colonne + $left_offset; $h_add = !$this->fourn_presta["fct"] ? 3 : 4; //Adresse du patient $this->pdf->SetTextColor(0); $this->pdf->setFont($this->font, '', 8); $nom_auteur_conf = CAppUI::conf("dPfacturation CEditPdf home_nom", $group); $this->auteur["nom"] = $nom_auteur_conf ? $nom_auteur_conf : $this->auteur["nom"]; $banque = $this->praticien->loadRefBanque(); $etab_adresse1 = $banque->_id ? $banque->nom : CAppUI::conf("dPfacturation CEditPdf etab_adresse1", $group); $etab_adresse2 = $banque->_id ? $banque->cp . " " . $banque->ville : CAppUI::conf("dPfacturation CEditPdf etab_adresse2", $group); if ($etab_adresse1) { $this->pdf->Text($l_colonne + $decalage, $h_ligne * $h_add + $haut_doc, $etab_adresse1); $h_add++; if ($etab_adresse2) { $this->pdf->Text($l_colonne + $decalage, $h_ligne * $h_add + $haut_doc, $etab_adresse2); $h_add++; } $h_add++; } if (!$this->fourn_presta["fct"]) { $this->pdf->Text($l_colonne + $decalage, $h_ligne * $h_add + $haut_doc, $this->auteur["nom"]); } else { $this->pdf->Text($l_colonne + $decalage, $h_ligne * $h_add + $haut_doc, $this->auteur["nom"]); $h_add++; $this->pdf->Text($l_colonne + $decalage, $h_ligne * $h_add + $haut_doc, $this->fourn_presta["fct"]); } $h_add++; $this->pdf->Text($l_colonne + $decalage, $h_ligne * $h_add + $haut_doc, $this->auteur["adresse1"]); $h_add++; if ($this->auteur["adresse2"]) { $this->pdf->Text($l_colonne + $decalage, $h_ligne * $h_add + $haut_doc, $this->auteur["adresse2"]); $h_add++; } $this->pdf->Text($l_colonne + $decalage, $h_ligne * $h_add + $haut_doc, $this->auteur["cp"] . " " . $this->auteur["ville"]); //Numéro adhérent, CHF, Montant1 et Montant2 $this->pdf->Text($l_colonne * 11 + $decalage, $h_ligne * 10.75 + $haut_doc, $this->adherent); $this->pdf->setFont($this->font, '', 10); $placement_colonne = $l_colonne * (17 - strlen($montant_facture * 100)) + $decalage; $this->pdf->Text($placement_colonne, $h_ligne * 13 + $haut_doc, sprintf("%d", $montant_facture)); $cents = floor(sprintf("%.2f", $montant_facture - sprintf("%d", $montant_facture)) * 100); if ($cents < 10) { $cents = "0" . $cents; } $this->pdf->Text($l_colonne * 19 + $decalage, $h_ligne * 13 + $haut_doc, $cents); } $decalage = $left_offset; // 7.36 // 8; //Ecriture de la reference $num_reference = preg_replace('/(\\d{2})(\\d{5})(\\d{5})(\\d{5})(\\d{5})/', '\\1 \\2 \\3 \\4 \\5 \\6', $this->facture->num_reference); $this->pdf->setFont($this->font, '', 11); $this->pdf->Text(50 * $l_colonne, $h_ligne * 8.75 + $haut_doc, $num_reference); $this->pdf->setFont($this->font, '', 8); $this->pdf->Text($l_colonne + $decalage, $h_ligne * 15 + $haut_doc, $this->facture->num_reference); //Adresse du patient de la facture $this->pdf->Text($l_colonne + $decalage, $h_ligne * 16 + $haut_doc, $this->destinataire["nom"]); $this->pdf->Text(49 * $l_colonne + $decalage, $h_ligne * 12 + $haut_doc, $this->destinataire["nom"]); $this->pdf->Text($l_colonne + $decalage, $h_ligne * 17 + $haut_doc, $this->destinataire["adresse1"]); $this->pdf->Text(49 * $l_colonne + $decalage, $h_ligne * 13 + $haut_doc, $this->destinataire["adresse1"]); $j = 1; if ($this->destinataire["adresse2"]) { $this->pdf->Text($l_colonne + $decalage, $h_ligne * 18 + $haut_doc, $this->destinataire["adresse2"]); $this->pdf->Text(49 * $l_colonne + $decalage, $h_ligne * 14 + $haut_doc, $this->destinataire["adresse2"]); $j = 2; } $this->pdf->Text($l_colonne + $decalage, $h_ligne * (17 + $j) + $haut_doc, $this->destinataire["cp"]); $this->pdf->Text(49 * $l_colonne + $decalage, $h_ligne * (13 + $j) + $haut_doc, $this->destinataire["cp"]); //Ecriture du code bvr genere modulo10 recursif $this->pdf->setFont("ocrbb", '', 12); $w = (80 - strlen($bvr)) * $l_colonne - $decalage; $this->pdf->Text($w, $h_ligne * 21 + $haut_doc, $bvr); }
$where["date"] = "BETWEEN '{$date_min}' AND '{$date_max}'"; $where["object_class"] = " = 'CFactureEtablissement'"; $relance = new CRelance(); $journal_pdf->relances = $relance->loadList($where, "statut, poursuite"); foreach ($journal_pdf->relances as $_relance) { /** @var CRelance $_relance */ $fact = $_relance->loadRefFacture(); $fact->loadRefsObjects(); $fact->loadRefPatient(); $fact->loadRefPraticien(); $fact->loadRefsReglements(); $fact->isRelancable(); if (!$fact->_id) { unset($journal_pdf->relances[$_relance->_id]); } } } if ($type == "debiteur") { $where["cloture"] = "BETWEEN '{$date_min}' AND '{$date_max}'"; $facture = new CFactureEtablissement(); $journal_pdf->factures = $facture->loadList($where); foreach ($journal_pdf->factures as $fact) { /** @var CFacture $fact */ $fact->loadRefsObjects(); $fact->loadRefPatient(); $fact->loadRefPraticien(); $fact->loadRefsReglements(); $fact->isRelancable(); } } $journal_pdf->editJournal();
/** * @see parent::completeLabelFields() */ function completeLabelFields(&$fields, $params) { if (!isset($this->_from_op)) { $this->loadRefLastOperation()->_from_sejour = 1; $this->_ref_last_operation->completeLabelFields($fields, $params); } $this->loadRefPatient()->completeLabelFields($fields, $params); $this->loadRefPraticien(); $this->loadNDA(); $this->loadNRA(); $now = CMbDT::dateTime(); $affectation = $this->getCurrAffectation($this->entree > $now ? $this->entree : null); $affectation->loadView(); $affectation->loadRefService(); $souhaits = array(); if (CAppUI::conf("dPhospi prestations systeme_prestations", CGroups::loadCurrent()) == "expert") { /** @var CItemLiaison[] $items_liaisons */ $items_liaisons = $this->loadBackRefs("items_liaisons", "date"); CStoredObject::massLoadFwdRef($items_liaisons, "item_souhait_id"); CStoredObject::massLoadFwdRef($items_liaisons, "sous_item_id"); foreach ($items_liaisons as $_liaison) { $item_souhait = $_liaison->loadRefItem(); if ($item_souhait->object_class == "CPrestationPonctuelle") { continue; } $sous_item = $_liaison->loadRefSousItem(); $nom = $item_souhait; if ($sous_item->_id) { $nom = $sous_item->nom; } $souhaits[] = $nom; } } $meds_dispenses = array(); if (isset($params["debut_dispensation"]) && isset($params["fin_dispensation"])) { $from = $params["debut_dispensation"]; $to = $params["fin_dispensation"]; $delivery = new CProductDelivery(); $where = array("date_dispensation" => "BETWEEN '{$from}' AND '{$to}'", "sejour_id" => "= '{$this->_id}'"); $deliveries = $delivery->loadList($where); $stocks = CStoredObject::massLoadFwdRef($deliveries, "stock_id"); $products = CStoredObject::massLoadFwdRef($stocks, "product_id"); /** @var CProduct $_product */ foreach ($products as $_product) { $meds_dispenses[] = $_product->code . " " . $_product->name; } } $fields_sejour = array("DATE ENT" => CMbDT::dateToLocale(CMbDT::date($this->entree)), "HEURE ENT" => CMbDT::transform($this->entree, null, "%H:%M"), "DATE SORTIE" => CMbDT::dateToLocale(CMbDT::date($this->sortie)), "HEURE SORTIE" => CMbDT::transform($this->sortie, null, "%H:%M"), "PRAT RESPONSABLE" => $this->_ref_praticien->_view, "NDOS" => $this->_NDA, "NRA" => $this->_ref_NRA ? $this->_ref_NRA->id400 : "", "CODE BARRE NDOS" => "@BARCODE_" . $this->_NDA . "@", "CHAMBRE COURANTE" => $affectation->_view, "SERVICE COURANT" => $affectation->_ref_service->_view, "MEDICAMENTS DISPENSES" => implode("\n", $meds_dispenses)); if (CAppUI::conf("dPhospi prestations systeme_prestations", CGroups::loadCurrent()) == "expert") { $fields_sejour["PRESTATIONS SOUHAITEES"] = implode(" - ", $souhaits); } $fields = array_merge($fields, $fields_sejour); if (CAppUI::conf("ref_pays") == 2) { $fields["NATURE SEJOUR"] = $this->getFormattedValue("_type_sejour"); $fields["MODE TRT"] = $this->loadRefChargePriceIndicator()->code; $this->loadRefsFactureEtablissement(); if ($this->_ref_last_facture) { $this->_ref_last_facture->loadRefAssurance(); $fields["ASSUR MALADIE"] = $this->_ref_last_facture->_ref_assurance_maladie->nom; $fields["ASSUR ACCIDENT"] = $this->_ref_last_facture->_ref_assurance_accident->nom; } } }