コード例 #1
0
CValue::setSession("praticien_id", $praticien_id);
$sejour = new CSejour();
$ds = $sejour->getDS();
$where = array("praticien_id" => $ds->prepareIn($praticien_id));
if ($date_min) {
    $where["sortie"] = $ds->prepare("BETWEEN ?1 AND ?2", $date_min, $date_max);
} else {
    $where["sortie"] = $ds->prepare("< ?", $date_max);
}
/** @var CSejour[] $sejours */
$sejours = $sejour->loadList($where, "sortie ASC", "{$start},{$step}");
foreach ($sejours as $_sejour) {
    $_sejour->makePDFarchive();
    CAppUI::stepAjax("Archive créée pour le %s du patient '%s'", UI_MSG_OK, $_sejour->_view, $_sejour->loadRefPatient()->_view);
    if (CModule::getActive("dPprescription")) {
        $prescriptions = $_sejour->loadRefsPrescriptions();
        foreach ($prescriptions as $_type => $_prescription) {
            if ($_prescription->_id && in_array($_type, array("pre_admission", "sortie"))) {
                if ($_prescription->countBackRefs("prescription_line_medicament") > 0 || $_prescription->countBackRefs("prescription_line_element") > 0 || $_prescription->countBackRefs("prescription_line_comment") > 0 || $_prescription->countBackRefs("prescription_line_mix") > 0 || $_prescription->countBackRefs("prescription_line_dmi") > 0) {
                    $query = array("m" => "prescription", "raw" => "print_prescription", "prescription_id" => $_prescription->_id, "dci" => 0, "in_progress" => 0, "preview" => 0);
                    $base = $_SERVER["SCRIPT_NAME"] . "?" . http_build_query($query, "", "&");
                    CApp::serverCall("http://127.0.0.1{$base}");
                    CAppUI::stepAjax("Archive créée pour la prescription de %s", UI_MSG_OK, CAppUI::tr("CPrescription.type.{$_type}"));
                }
            }
        }
    }
}
if (count($sejours)) {
    CAppUI::js("nextStepSejours()");
}
コード例 #2
0
ファイル: CSejour.class.php プロジェクト: fbone/mediboard4
 /**
  * Make a PDF document archive of the sejour (based on soins/print_dossier_soins)
  *
  * @param string $title   File title
  * @param bool   $replace Replace existing file
  *
  * @return bool
  * @throws CMbException
  */
 function makePDFarchive($title = "Dossier complet", $replace = false)
 {
     if (!CModule::getActive("soins")) {
         return false;
     }
     $query = array("m" => "soins", "a" => "print_dossier_soins", "sejour_id" => $this->_id, "dialog" => 1, "offline" => 1, "limit" => 10000, "_aio" => 1, "_aio_ignore_scripts" => 1);
     $base = $_SERVER["SCRIPT_NAME"] . "?" . http_build_query($query, "", "&");
     $result = CApp::serverCall("http://127.0.0.1{$base}");
     $content = $result["body"];
     $file = new CFile();
     $file->setObject($this);
     $file->file_name = "{$title}.pdf";
     $file->file_type = "application/pdf";
     /*if ($file->loadMatchingObject()) {
           if ($replace) {
             $file->delete();
     
             // New file
             $file = new CFile();
             $file->setObject($this);
             $file->file_name = "$title.pdf";
             $file->file_type = "application/pdf";
           }
         }*/
     $file->fillFields();
     $file->updateFormFields();
     $file->forceDir();
     $file->author_id = CAppUI::$user->_id;
     $compte_rendu = new CCompteRendu();
     $compte_rendu->_orientation = "portrait";
     $format = CCompteRendu::$_page_formats["a4"];
     $page_width = round(72 / 2.54 * $format[0], 2);
     $page_height = round(72 / 2.54 * $format[1], 2);
     $compte_rendu->_page_format = array(0, 0, $page_width, $page_height);
     $content = str_replace("<!DOCTYPE html>", "", $content);
     CHtmlToPDFConverter::init("CWkHtmlToPDFConverter");
     //CHtmlToPDFConverter::init("CPrinceXMLConverter");
     $pdf = CHtmlToPDFConverter::convert($content, $compte_rendu->_page_format, $compte_rendu->_orientation);
     $file->putContent($pdf);
     if ($msg = $file->store()) {
         throw new CMbException($msg);
     }
     return true;
 }