public function selectedrequestcovenantAction()
 {
     $responce = new stdClass();
     $cdrequest = $_POST["idrequest"];
     $requestModel = new RequestModel();
     $clientCovenant = $requestModel->fetchRow($requestModel->getClientCovenantForward($cdrequest));
     if ($clientCovenant['dtbirth'] != '') {
         $dtbirth = new Zend_Date($clientCovenant['dtbirth'], 'dd-MM-YYYY');
         $year = $dtbirth->toString('YYYY');
         $month = $dtbirth->toString('MM');
         $day = $dtbirth->toString('dd');
         $today = new Zend_Date();
         $tdYear = $today->toString('YYYY');
         $tdMonth = $today->toString('MM');
         $tdDay = $today->toString('dd');
         $nrage = 0;
         $nrage = GslabUtils::calcAgeDifferenceShort($clientCovenant['dtbirth']);
         if ($tdMonth < $month || $tdMonth == $month && $tdDay < $day) {
             $nrage--;
         }
     } else {
         $nrage = " ";
     }
     $responce->forward = $clientCovenant['nmforward'];
     $responce->covenant = $clientCovenant['nmcovenant'];
     $responce->client = $clientCovenant['nmclient'];
     $responce->fgsex = $clientCovenant['fgsex'];
     $responce->age = $nrage;
     $responce = json_encode($responce);
     print_r($responce);
     return $responce;
 }
 public function saveAction()
 {
     parent::saveAction();
     $columns = $this->_model->info(Zend_Db_Table_Abstract::COLS);
     $array = array();
     $this->_model->getAdapter()->beginTransaction();
     $message = '';
     foreach ($_POST as $Ncampo => $valor) {
         $valueopt = $_POST['value'];
     }
     try {
         foreach ($this->_values as $id => $value) {
             if (isset($value) && $value != '' && in_array($id, $columns)) {
                 if ($this->_values['fgdatatype'] == 4) {
                     if (isset($this->_values["dtminvalue"]) && $this->_values["dtminvalue"] != '') {
                         $dtminvalue = GslabUtils::dateToDatabaseFormat($this->_values["dtminvalue"]);
                     }
                     if (isset($this->_values["dtmaxvalue"]) && $this->_values["dtmaxvalue"] != '') {
                         $dtmaxvalue = GslabUtils::dateToDatabaseFormat($this->_values["dtmaxvalue"]);
                     }
                     $array = array('idattribute' => $_POST['idattribute'], 'nmattribute' => $_POST['nmattribute'], 'fgdatatype' => $_POST['fgdatatype'], 'dtminvalue' => $dtminvalue, 'dtmaxvalue' => $dtmaxvalue);
                 } else {
                     $array[$id] = addslashes($value);
                 }
             }
         }
         $this->_model->insert($array);
         if ($this->_values['fgdatatype'] == '5') {
             $cdattribute = $this->_model->getAdapter()->lastInsertId();
             $this->saveOptionsAction($valueopt, $cdattribute);
         }
         $this->_model->getAdapter()->commit();
     } catch (Exception $e) {
         $this->_model->getAdapter()->rollBack();
         $message = "Erro na inserção dos dados!" . $e->getMessage();
     }
     $message = "Cadastro realizado com sucesso.";
     $this->view->message = $message;
 }
Пример #3
0
 public static function calcAgeDifferenceShort($start_date, $end_date = null)
 {
     $day = array(" dias", " dia");
     $month = array(" meses", " mês");
     $year = array(" anos", " ano");
     $chars = array(" de idade", "e", ",");
     $fullDate = GslabUtils::calcAgeDifference($start_date, $end_date);
     if (strcasecmp($fullDate, "hoje") == 0) {
         return $fullDate;
     }
     $shortDate = str_replace($day, "d", $fullDate);
     $shortDate = str_replace($month, "m", $shortDate);
     $shortDate = str_replace($year, "a", $shortDate);
     $shortDate = str_replace($chars, "", $shortDate);
     return $shortDate;
 }
 function patientsearchAction()
 {
     $nmclient = $this->_request->getParam('term');
     echo "" . GslabUtils::autoCompletePatientSearch($nmclient);
 }
    public function generateprotocolAction($cdrequest = 1)
    {
        require_once 'fpdf/pdf_protocol.php';
        $gslabSession = Zend_Session::namespaceGet('Gslab_Session');
        $cdcompany = $gslabSession['user']->cdcompany;
        $companyModel = new CompanyModel();
        $requestModel = new RequestModel();
        $sampleModel = new RequestexaminationsampleModel();
        $clientModel = new ClientModel();
        $covenantModel = new CovenantModel();
        $forwardModel = new ForwardModel();
        $examinationModel = new RequestexaminationModel();
        $companyData = $companyModel->fetchRow('cdcompany = ' . $cdcompany);
        $requestData = $requestModel->fetchRow('cdrequest = ' . $cdrequest);
        $sampleData = $sampleModel->fetchRow('cdrequest = ' . $cdrequest);
        $clientData = $clientModel->fetchRow('cdclient = ' . $requestData->cdclient);
        $covenantData = $covenantModel->fetchRow('cdcovenant = ' . $requestData->cdcovenant);
        $forwardData = $forwardModel->fetchRow('cdforward = ' . $requestData->cdforward);
        $dtbirth = new Zend_Date($clientData->dtbirth, 'dd-MM-YYYY');
        $dtrequest = new Zend_Date($requestData->dtrequest, 'dd-MM-YYYY HH:mm');
        $dtdeadline = new Zend_Date($requestData->dtdeadline, 'dd-MM-YYYY HH:mm');
        $year = $dtbirth->toString('YYYY');
        $month = $dtbirth->toString('MM');
        $day = $dtbirth->toString('dd');
        $today = new Zend_Date();
        $tdYear = $today->toString('YYYY');
        $tdMonth = $today->toString('MM');
        $tdDay = $today->toString('dd');
        $nrage = 0;
        $nrage = GslabUtils::calcAgeDifferenceShort($clientData->dtbirth);
        $idade = GslabUtils::calcula_idade($clientData->dtbirth);
        if ($clientData->fgsex == 1) {
            $sexo = 'M';
        } else {
            $sexo = 'F';
        }
        if ($tdMonth < $month || $tdMonth == $month && $tdDay < $day) {
            $nrage--;
        }
        $pdf = new PDF_PROTOCOL();
        $pdf->AddPage();
        $pdf->SetFont('Courier', 'B', 11);
        $pdf->ln(55);
        $pdf->Cell(0, 0, utf8_decode(strtoupper($companyData->nmcompany)), 0, 1, 'C');
        $pdf->Cell(0, 8, utf8_decode('LABORATÓRIO DE ANÁLISES CLÍNICAS'), 0, 2, 'C');
        $pdf->Cell(0, -5, str_repeat('_', 81), 0, 1, 'L');
        $pdf->ln(8);
        $pdf->SetFont('Helvetica', '', 9);
        $pdf->Cell(0, 0, utf8_decode(strtoupper($companyData->nmstreet) . ', ' . $companyData->nrnumber), 0, 1, 'L');
        $pdf->ln(4);
        $pdf->Cell(0, 0, 'COMPROVANTE DE COLETA', 0, 1, 'L');
        $pdf->Cell(0, 0, utf8_decode(strtoupper($companyData->nmneighborhood)) . ' - Fone: (47) 3427-3668', 0, 1, 'R');
        //ADICIONAR TELEFONE NA BASE
        $pdf->ln(4);
        $pdf->Cell(0, 0, utf8_decode('Ficha: ') . $requestData->cdcompany . "-" . $requestData->cdrequest, 0, 1, 'L');
        $pdf->Cell(0, 0, 'Senha: 2301', 0, 1, 'R');
        $pdf->ln(8);
        $pdf->Cell(0, 0, utf8_decode('PRONTUÁRIO'), 0, 1, 'L');
        $pdf->ln(4);
        $pdf->SetFont('Helvetica', '', 10);
        $pdf->Cell(15, 5, utf8_decode('Amostra: '), 0, 0, 'L');
        $pdf->Cell(0, 5, $pdf->SetFont('Helvetica', 'BU', 10) . $sampleData->nmbarcodesample, 0, 1, 'L');
        $pdf->ln(4);
        $pdf->SetFont('Helvetica', 'BU', 10);
        $pdf->Write(0, utf8_decode(strtoupper($clientData->nmclient)));
        $pdf->SetFont('Helvetica', '', 10);
        $pdf->ln(8);
        $pdf->Write(0, utf8_decode('Idade: ' . $nrage));
        $pdf->Write(0, utf8_decode(' Sexo: ' . $sexo));
        $pdf->ln(6);
        $pdf->Write(0, utf8_decode('Convênio: ' . $covenantData->nmcovenant));
        $pdf->ln(6);
        $pdf->Write(0, utf8_decode('Médico: ' . $forwardData->idmaincrm . ' - ' . $forwardData->nmforward));
        $pdf->ln(6);
        $pdf->Write(0, utf8_decode('Coleta: ' . strtoupper($companyData->cdcompany . ' - ' . $companyData->nmfantasyname)));
        $pdf->ln(6);
        $pdf->Write(0, utf8_decode('Data e Hora: ') . $dtrequest);
        $pdf->ln(4);
        $pdf->SetFont('Courier', 'B', 11);
        $pdf->Cell(0, 0, str_repeat('_', 81), 0, 1, 'L');
        /* CAIXA LATERAL */
        $pdf->SetFont('Helvetica', '', 10);
        $pdf->SetY(89);
        $pdf->SetX(90);
        $pdf->drawTextBox(utf8_decode('Provável local e data da entrega:
Local: ' . strtoupper($companyData->nmfantasyname) . '
Data: ' . $dtdeadline . '
Salvo quando ocorrer:
    1-	Imprevistos técnicos
    2-	Bloqueio de resultado pelo controle de qualidade
    3-	Atraso no fornecimento de reagentes
Autorizo a coleta do(s) exame(s) acima citado(s) e declaro estar ciente dos riscos quanto ao surgimento de possíveis hematomas no local da punção.
Assinatura do cliente e/ou responsável:__________________________________________'), 109, 50, 'L', 'M');
        /* doze exames */
        $Exames = $examinationModel->fetchAll($examinationModel->getExaminationProtocol($cdrequest));
        $pdf->ln(13);
        // Exames
        $pdf->SetFont('Helvetica', 'B', 9);
        $pdf->SetWidths(array(50, 23, 18));
        $pdf->SetX(10);
        $pdf->Row(array(utf8_decode('Exames'), utf8_decode('Material'), utf8_decode('Status')));
        $pdf->SetFont('Helvetica', '', 9);
        $i = 0;
        foreach ($Exames as $examination) {
            if ($examination['nmmaterial'] == 2) {
                $status = 'Faltante';
            } else {
                $status = 'OK';
            }
            if ($i == 11) {
                $pdf->SetY(148);
            }
            $pdf->SetX(10);
            $pdf->Row(array(utf8_decode($examination['nmexamination']), utf8_decode($examination['nmmaterial']), $status));
            $i++;
        }
        $pdf->ln(5);
        /* -------------------------------------------------------------- */
        /* PESQUISA DE SATISFAÇÃO */
        $pdf->SetFont('Helvetica', '', 7);
        $pdf->SetY(205);
        $pdf->Cell(0, 0, str_repeat(' -', 125), 0, 1, 'L');
        $pdf->SetX(10);
        $pdf->Write(5, utf8_decode('Prezado cliente: com o objetivo de melhorarmos cada vez mais a'));
        $pdf->ln(3);
        $pdf->SetX(10);
        $pdf->Write(5, utf8_decode('qualidade dos nossos serviços e o atendimento à você, solicitamos'));
        $pdf->ln(3);
        $pdf->SetX(10);
        $pdf->Write(5, utf8_decode('a sua gentileza preenchendo o formulário abaixo.'));
        $pdf->ln(5);
        $pdf->SetFont('Helvetica', 'B', 7);
        $pdf->SetWidths(array(30, 13, 13, 13, 13));
        $pdf->SetX(10);
        $pdf->Row(array(utf8_decode('Assinale sua opinião'), utf8_decode('Ótimo'), 'Bom', 'Regular', 'Ruim'));
        $pdf->SetFont('Helvetica', '', 7);
        $pdf->SetX(10);
        $pdf->Row(array(utf8_decode('1. Como foi o atendimento ao telefone?'), '', '', '', ''));
        $pdf->SetX(10);
        $pdf->Row(array(utf8_decode('2. Como foi o atendimento da recepção?'), '', '', '', ''));
        $pdf->SetX(10);
        $pdf->Row(array(utf8_decode('3. Quanto ao conforto e bem estar na sala de espera?'), '', '', '', ''));
        $pdf->SetX(10);
        $pdf->Row(array(utf8_decode('4. Quanto à coleta do material para o exame?'), '', '', '', ''));
        $pdf->SetX(10);
        $pdf->Row(array(utf8_decode('5. Quanto ao prazo e entrega dos resultados?'), '', '', '', ''));
        $pdf->SetY(215);
        $pdf->SetX(117);
        $pdf->Write(5, utf8_decode('6. Como conheceu o Laboratório? _______________________________'));
        $pdf->ln(7);
        $pdf->SetX(117);
        $pdf->Write(5, utf8_decode('7. Você indicaria o laboratório para outras pessoas?  (  ) Sim   (  ) Não'));
        $pdf->ln(7);
        $pdf->SetX(117);
        $pdf->Write(5, utf8_decode('Se NÃO, por quê?____________________________________________'));
        $pdf->ln(7);
        $pdf->SetX(117);
        $pdf->Write(5, utf8_decode('8. Conhece nosso '));
        $pdf->SetFont('Helvetica', 'BU', 7);
        $pdf->Write(5, utf8_decode('Programa de Coleta Domiciliar'));
        $pdf->SetFont('Helvetica', '', 7);
        $pdf->Write(5, utf8_decode(' (tel: 3433-2127)?'));
        $pdf->ln(7);
        $pdf->SetX(117);
        $pdf->Write(5, utf8_decode('(  ) Sim   (  ) Não'));
        $pdf->ln(7);
        $pdf->SetX(117);
        $pdf->Write(5, utf8_decode('9. Sugestões e críticas:_______________________________________'));
        $pdf->ln(7);
        $pdf->SetX(117);
        $pdf->Write(5, utf8_decode('__________________________________________________________'));
        $pdf->ln(7);
        $pdf->SetX(117);
        $pdf->Write(5, utf8_decode('__________________________________________________________'));
        $pdf->Output();
        //IMPRIME O PDF NA TELA
        $pdf->Output('teste_pro.pdf', "D");
        //IMPRIME O PDF NO ARQUIVO
    }
 public function printviewAction()
 {
     require_once 'fpdf/pdf.php';
     $cdrequest = $_GET["cdrequest"];
     $Request = new RequestModel();
     $Attribute = new AttributeModel();
     $AttributeExaminationMaterial = new AppraisalcontrolModel();
     $Factor = new FactorModel();
     $array = array();
     $req = $Request->fetchAll($Request->getAllRequestData($cdrequest));
     if (count($req) <= 0) {
         die;
     }
     foreach ($req as $row) {
         $dtbirth = new Zend_Date($row['dtbirth'], 'dd-MM-YYYY');
         $dtrequest = new Zend_Date($row['dtrequest'], 'dd-MM-YYYY HH:mm:ss');
         $year = $dtbirth->toString('YYYY');
         $month = $dtbirth->toString('MM');
         $day = $dtbirth->toString('dd');
         $today = new Zend_Date();
         $tdYear = $today->toString('YYYY');
         $tdMonth = $today->toString('MM');
         $tdDay = $today->toString('dd');
         $nrage = 0;
         $nrage = GslabUtils::calcAgeDifference($row['dtbirth']);
         $idade = GslabUtils::calcula_idade($row['dtbirth']);
         if ($tdMonth < $month || $tdMonth == $month && $tdDay < $day) {
             $nrage--;
         }
         if ($row['fgsex'] == 1) {
             $fgsex = "Masculino";
         } else {
             $fgsex = "Feminino";
         }
         $array['nmclient'] = $row['nmclient'];
         $array['nmforward'] = $row['nmforward'];
         $array['nmcompany'] = $row['nmcompany'];
         $array['nmbarcodesample'] = $row['nmbarcodesample'];
         $array['nmcovenant'] = $row['nmcovenant'];
         $array['dtrequest'] = $dtrequest;
         $array['idade'] = $nrage;
         $array['sexo'] = $fgsex;
     }
     $GLOBALS = $array;
     $ano = explode(" ", $nrage);
     $pdf = new PDF();
     $pdf->AddPage();
     $pdf->ln(30);
     $pdf->AliasNbPages('{total}');
     $req2 = $Request->fetchAll($Request->getAllRequestData($cdrequest));
     $appraisalCommon = AppraisalCommon::getInstance($this);
     foreach ($req2 as $rows) {
         $fgstatus = true;
         /* NOME DO EXAME */
         $pdf->SetFont('Courier', 'BI', 11);
         $pdf->Cell(0, 10, strtoupper(utf8_decode($rows['nmexamination'])), 0, 2, 'L');
         $pdf->SetFont('Courier', '', 9);
         $pdf->Cell(0, 0, utf8_decode("Material: " . strtoupper($rows['nmmaterial'])), 0, 0, 'L');
         $pdf->Cell(-30, 0, utf8_decode("Método: Automação CELL-DYN 3000/3500"), 0, 2, 'R');
         $pdf->ln(2);
         // $pdf->Cell(250, 5, utf8_decode("Valores referenciais"), 0, 1, 'C');
         $pdf->ln(2);
         $sons = $this->getExamSons($rows['cdexamination']);
         if (count($sons) > 0) {
             for ($aux_i = 0; $aux_i < count($sons); $aux_i++) {
                 $pdf->SetFont('Courier', '', 10);
                 $pdf->Cell(-360, 5, strtoupper(utf8_decode($sons[$aux_i]['nmexamination'])), 0, 0, 'L');
                 /* NOME DO ATRIBUTO E VALOR */
                 $attributes = $appraisalCommon->getExamAttribs($sons[$aux_i]['cdexaminationmaterial']);
                 //print_r($attributes);
                 $fgstatus = true;
                 foreach ($attributes as $attr) {
                     $vlattr = '';
                     $cdattr = '';
                     $obj = new stdClass();
                     $obj->cdexaminationmaterial = $sons[$aux_i]['cdexaminationmaterial'];
                     $obj->cdrequest = $cdrequest;
                     $obj->cdexamination = $rows['cdexamination'];
                     $obj->cdattribute = $attr['cdattribute'];
                     $vlattribute = $appraisalCommon->getAppraisalAttributeValue($obj);
                     foreach ($vlattribute as $kAttr => $vAttr) {
                         if ($kAttr == 'vlattribute') {
                             $vlattr = $vAttr['vlattribute'];
                         }
                         if ($kAttr == 'cdattribute') {
                             $cdattr = $vAttr['cdattribute'];
                         }
                     }
                     $AttributeData = $Attribute->fetchAll($Attribute->getAtributeNotation($cdattr));
                     foreach ($AttributeData as $key => $value) {
                         if ($key == 'idnotation') {
                             $idnotation = $value['idnotation'];
                         }
                     }
                     $pdf->SetFont('Courier', '', 10);
                     $pdf->ln();
                     $pdf->Cell(40, 5, "    " . str_pad(utf8_decode($attr['nmattribute']), 15, "."), 0, 0, 'L');
                     $pdf->SetFont('Courier', 'B', 10);
                     $pdf->Cell(65, 5, str_pad($vlattr . " " . $idnotation, 15, ".", STR_PAD_LEFT), 0, 0, 'L');
                     $ref = $appraisalCommon->getExamFactors($sons[$aux_i]['cdexaminationmaterial'], $cdattr);
                     foreach ($ref as $vlref) {
                         if ($vlref['fgfactor'] == 1) {
                             $fator = "Idade            Valores referenciais";
                         } else {
                             if ($vlref['fgfactor'] == 2) {
                                 $fator = "Masculino                    Feminino";
                             } else {
                                 if ($vlref['fgfactor'] == 3) {
                                     $fator = "Idade       Masculino        Feminino";
                                 }
                             }
                         }
                     }
                     if ($fgstatus == true) {
                         $pdf->Cell(-1);
                         $pdf->Cell(1, -5, $fator, 0, 0, 'L');
                         $fgstatus = false;
                     }
                     /* VALORES DE REFERÊNCIA */
                     foreach ($ref as $vlref) {
                         /*
                          * AQUI SÃO DEFINIDAS AS REGRAS DE EXIBIÇÃO DO PDF, COLUNAS POR IDADE, SEXO OU AMBOS:
                          * 
                          * fgfactor = 1
                          * ATRIBUTO........VALOR        IDADE    REFERÊNCIA
                          * 
                          * fgfactor = 2
                          * ATRIBUTO........VALOR        MASCULINO    FEMININO
                          * 
                          * fgfactor = 3
                          * ATRIBUTO........VALOR        IDADE    MASCULINO    FEMININO
                          * 
                          */
                         $pdf->SetFont('Courier', '', 9);
                         /* DEFINE QUAL CAMPO DA TABELA ESTÁ PREENCHIDO (VALOR OU NUMÉRICO) E ALOCA À UMA VARIÁVEL */
                         if ($vlref['nrminvalue'] == '' && $vlref['nrmaxvalue'] == '' && $vlref['vlminvalue'] != '' && $vlref['vlmaxvalue'] != '') {
                             $minvalue = $vlref['vlminvalue'];
                             $maxvalue = $vlref['vlmaxvalue'];
                         } else {
                             if ($vlref['nrminvalue'] != '' && $vlref['nrmaxvalue'] != '' && $vlref['vlminvalue'] == '' && $vlref['vlmaxvalue'] == '') {
                                 $minvalue = $vlref['nrminvalue'];
                                 $maxvalue = $vlref['nrmaxvalue'];
                             }
                         }
                         if ($vlref['fgfactor'] == 1) {
                             //SEPARADOS PELA IDADE, DEFINE UMA COLUNA DE RESULTADOS
                             if ($vlref['nrminage'] <= $ano[0] && $vlref['nrmaxage'] >= $ano[0]) {
                                 $pdf->Cell(12, 5, utf8_decode($vlref['nrminage'] . " à " . $vlref['nrmaxage'] . " " . $vlref['nmtimetype']), 0, 0, 'R');
                                 $pdf->Cell(67, 5, utf8_decode($minvalue . " à " . $maxvalue), 0, 0, 'R');
                             }
                         } else {
                             if ($vlref['fgfactor'] == 2) {
                                 //SEPARADOS PELO SEXO, DEFINE DUAS COLUNAS DE RESULTADOS
                                 if ($vlref['fggender'] == 1) {
                                     // MASCULINO
                                     $pdf->Cell(20, 5, utf8_decode($vlref['vlminvalue'] . " à " . $vlref['vlmaxvalue']), 0, 0, 'R');
                                 } else {
                                     if ($vlref['fggender'] == 2) {
                                         // FEMININO
                                         $pdf->Cell(60, 5, utf8_decode($vlref['vlminvalue'] . " à " . $vlref['vlmaxvalue']), 0, 1, 'R');
                                     }
                                 }
                             } else {
                                 if ($vlref['fgfactor'] == 3) {
                                     //SEPARADOS PELO SEXO E IDADE, DEFINE TRÊS COLUNAS DE RESULTADOS
                                     if ($vlref['fggender'] == 1) {
                                         // MASCULINO
                                         $pdf->Cell(12, 5, utf8_decode($vlref['nrminage'] . " à " . $vlref['nrmaxage'] . " " . $vlref['nmtimetype']), 0, 0, 'R');
                                         $pdf->Cell(33, 5, utf8_decode($vlref['vlminvalue'] . " à " . $vlref['vlmaxvalue']), 0, 0, 'R');
                                     } else {
                                         if ($vlref['fggender'] == 2) {
                                             // FEMININO
                                             $pdf->Cell(35, 5, utf8_decode($vlref['vlminvalue'] . " à " . $vlref['vlmaxvalue']), 0, 1, 'R');
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     unset($obj);
                 }
                 $pdf->ln();
                 $pdf->ln();
             }
         }
     }
     $pdf->Output();
     //IMPRIME O PDF NA TELA
     $pdf->Output("teste.pdf");
     //IMPRIME O PDF NO ARQUIVO
 }
 public function saveAction()
 {
     $bootstrap = $this->getInvokeArg('bootstrap');
     $gslab_db = $bootstrap->getResource('db');
     $deliveryModel = new AppraisaldeliveryModel();
     $modelRequest = new RequestexaminationModel();
     $gslab_db->beginTransaction();
     $paramApp = $this->_request->getParam('data');
     $request = $this->_request->getParam('request');
     $delivery = $this->_request->getParam('delivery');
     $date = $this->_request->getParam('date');
     $time = $this->_request->getParam('time');
     $dtdelivery = GslabUtils::dateToDatabaseFormat($date);
     $datahora = substr($dtdelivery, 0, -8);
     try {
         $paramAppArray = array('cdrequest' => $request, 'nmdeliveryperson' => $delivery, 'dtappraisaldelivery' => $datahora . $time . ":00");
         $deliveryModel->insert($paramAppArray);
         $message = 'Cadastro efetuado com sucesso';
         $gslab_db->commit();
     } catch (Exception $e) {
         $message = "Erro na inserção dos dados." + $e->getMessage();
         $this->_model->getAdapter()->rollBack();
     }
     $this->view->message = $message;
     $RequestArray = array('fgstatus' => 6);
     $modelRequest->update($RequestArray, "cdrequest = " . $request . " AND fgstatus = 5");
 }
Пример #8
0
 public function getRequestsData($array, $allowedstatus)
 {
     //PESQUISA POR PACIENTE
     $sector = $array['sector'];
     if ($sector == '-1') {
         $sector = null;
     }
     $select = $this->select()->from($this->_name)->join("requestexaminationsample", "requestexaminationsample.cdrequest = request.cdrequest")->join("mapsample", "requestexaminationsample.cdrequestexaminationsample = mapsample.cdrequestexaminationsample", array("cdmap", "nrmappage"))->join("map", "mapsample.cdmap = map.cdmap", array("cddepartment", "dtmaprendering"))->join("requestexamination", "requestexaminationsample.cdrequestexamination = requestexamination.cdrequestexamination", array("cdrequestexamination", "fgstatus"))->join("forward", "request.cdforward = forward.cdforward", "forward.nmforward", array())->join("company", "request.cdcompany = company.cdcompany", array())->join("client", "request.cdclient = client.cdclient")->join("covenantpricing", "requestexamination.cdexamination = covenantpricing.cdexamination")->join("covenant", "covenantpricing.cdcovenant = covenant.cdcovenant", array())->join("examinationmaterialrequest", "requestexamination.cdrequestexamination = examinationmaterialrequest.cdrequestexamination")->join("examinationmaterial", "examinationmaterialrequest.cdexaminationmaterial = examinationmaterial.cdexaminationmaterial")->join("material", "examinationmaterial.cdmaterial = material.cdmaterial")->join("examination", "covenantpricing.cdexamination = examination.cdexamination")->join("department", "examinationmaterial.cddepartment = department.cddepartment")->where("request.cdcovenant = covenant.cdcovenant")->where("requestexamination.fgstatus IN (?)", $allowedstatus)->group("mapsample.cdrequestexaminationsample")->setIntegrityCheck(false);
     if (isset($array['sidx']) && isset($array['sord'])) {
         $select->order(array($array['sidx'] . " " . $array['sord'], ""));
     }
     if (isset($array['page'])) {
         $select->limit($array['page'], 1);
     }
     if (isset($array['page']) && isset($array['rows'])) {
         $select->limitpage($array['page'], $array['rows']);
     }
     if (isset($array['cdpatient']) && $array['cdpatient'] != null) {
         $select->where("client.cdclient = ?", $array['cdpatient']);
         if (isset($array['cdrequest']) && $array['cdrequest'] != null) {
             $select->where("request.cdrequest = ?", $array['cdrequest']);
         }
         if (isset($array['nrsample']) && $array['nrsample'] != null) {
             $select->where("requestexaminationsample.nmbarcodesample LIKE ?", '%' . $array['nrsample'] . '%');
         }
         if (isset($array['sector']) && $array['sector'] != null) {
             $sector = explode(",", $array['sector']);
             $select->where("department.cddepartment in (?)", $sector);
         }
         if (isset($array['startdate']) && $array['startdate'] != null) {
             $startDate = GslabUtils::dateToDatabaseFormat($array['startdate']);
             $select->where("request.dtrequest >= ?", $startDate);
         }
         if (isset($array['enddate']) && $array['enddate'] != null) {
             $enddate = GslabUtils::dateToDatabaseFormat($array['enddate']);
             $select->where("request.dtrequest <= ?", $enddate);
         }
     }
     $select->where("examinationmaterial.cdexaminationmaterialparent is null");
     //PESQUISA POR MAPA
     if (isset($array['cdmap']) && $array['cdmap'] != null) {
         $select->where("mapsample.cdmap LIKE ?", "%" . $array['cdmap'] . "%");
         if (isset($array['sector2']) && $array['sector2'] != null && $array['sector2'] != "-1") {
             $select->where("map.cddepartment IN (?)", $array['sector2']);
         }
         //            if (isset($array['homepage']) && $array['homepage'] != null) {
         //                $select->where("mapsample.nrmappage > ?", $array['homepage']);
         //            }
         //            if (isset($array['lastpage']) && $array['lastpage'] != null) {
         //                $select->where("mapsample.nrmappage < ?", $array['lastpage']);
         //            }
         if (isset($array['dtfirstmaps']) && $array['dtfirstmaps'] != null) {
             $startdate = GslabUtils::dateToDatabaseFormat($array['dtfirstmaps']);
             $select->where("map.dtmaprendering >= ?", $startdate);
         }
         if (isset($array['dtendmaps']) && $array['dtendmaps'] != null) {
             $enddate = GslabUtils::dateToDatabaseFormat($array['dtendmaps']);
             $select->where("map.dtmaprendering <= ?", $enddate);
         }
     }
     // PESQUISA PELOS ÚLTIMOS RESULTADOS
     if (!isset($array['cdmap']) && !isset($array['cdpatient']) && (isset($array['startTime']) || isset($array['endTime']))) {
         if (isset($array['startDate']) && $array['startDate'] != null) {
             $date = $array['startDate'] . " " . $array['startTime'];
             $startDate = GslabUtils::dateToDatabaseFormat($date);
             $select->where("request.dtrequest >= ?", $startDate);
         }
         if (isset($array['endDate']) && $array['endDate'] != null) {
             $date = $array['endDate'] . " " . $array['endTime'];
             $enddate = GslabUtils::dateToDatabaseFormat($array['endDate'] . " " . $array['endTime']);
             $select->where("request.dtrequest <= ?", $enddate);
         }
     }
     return $select;
 }
 public function saveAction()
 {
     parent::saveAction();
     // Pega parâmetros passados por intermédio do request
     $array = array();
     $values = $this->_request->getParams();
     $cdexamination = $this->_request->getParam('cdexamination');
     $idexamination = $this->_request->getParam('idexamination');
     $nmexamination = $this->_request->getParam('nmexamination');
     $nrminage = $this->_request->getParam('nrminage');
     $fgtypeagemin = $this->_request->getParam('fgtypeagemin');
     $nrmaxage = $this->_request->getParam('nrmaxage');
     $cddepartment = $this->_request->getParam('cddepartment');
     $fgtypeagemax = $this->_request->getParam('fgtypeagemax');
     $qtdsamples = $this->_request->getParam('qtdsamples');
     $fgsex = $this->_request->getParam('fgsex');
     $allowpartialsave = $this->_request->getParam('allowpartialsave');
     $dsdiagnosis = $this->_request->getParam('dsdiagnosis');
     $dsinterference = $this->_request->getParam('dsinterference');
     $departments = $this->_request->getParam('departments');
     $mapattrib = $this->_request->getParam('fgmapattrib');
     $departments = json_decode($departments);
     $synonyms = $this->_request->getParam('synonyms');
     $synonyms = json_decode($synonyms);
     $materials = $this->_request->getParam('materials');
     $materials = json_decode($materials);
     $examinationModel = new ExaminationModel();
     $examinationModel->getAdapter()->beginTransaction();
     /*
     var_dump($values);
     
     var_dump($this->view->controller);
     var_dump($this->view->action);
     die();
     */
     try {
         /*  Salva dados na tabela 'examination' */
         $examination = array();
         $examination['idexamination'] = $idexamination;
         $examination['nmexamination'] = $nmexamination;
         $examination['fgsex'] = $fgsex;
         $examination['nrsamplelimit'] = $qtdsamples;
         $examination['fgparcialsave'] = $allowpartialsave;
         $examination['dsdiagnosis'] = $dsdiagnosis;
         $examination['dsinterference'] = $dsinterference;
         $examination['nrminage'] = $nrminage;
         $examination['nrmaxage'] = $nrmaxage;
         $examination['cdtimeframeminage'] = $fgtypeagemin;
         $examination['cdtimeframemaxage'] = $fgtypeagemax;
         // Passar para ExaminationMaterial
         //$examination['cddepartment'] = $cddepartment;
         // Mostragem dos atributos no mapa
         if (isset($mapattrib)) {
             if ($mapattrib) {
                 $examination['fgmapattrib'] = 1;
             } else {
                 $examination['fgmapattrib'] = 2;
             }
         }
         $previousAction = GslabUtils::getPreviousAction($this->view);
         if (strcmp($previousAction, "edit") == 0) {
             $examinationModel->update($examination, 'examination.cdexamination = ' . $cdexamination);
         } else {
             $examinationModel->insert($examination);
             $cdexamination = $examinationModel->getAdapter()->lastInsertId();
         }
         /* Salva dados na tabela 'examinationdepartment' */
         $examinationPermissionModel = new ExaminationpermissionModel();
         foreach ($departments as $singleDepartment) {
             // Salva dados na tabela 'examinationpermission'
             $departmentPrintPermission = array('cddepartment' => $singleDepartment->cddepartment, 'cdexamination' => $cdexamination, 'fgprintmap' => $singleDepartment->map, 'fgprintsampleprotocol' => $singleDepartment->protocol, 'fgprintappraisal' => $singleDepartment->appraisal);
             $examinationPermissionModel->insert($departmentPrintPermission);
         }
         /* Salva dados na tabela 'examinationmaterial' */
         $examinationMaterialModel = new ExaminationmaterialModel();
         foreach ($materials as $singleMaterial) {
             $examinationMaterial = array('cdexamination' => $cdexamination, 'cdmaterial' => $singleMaterial->cdmaterial, 'fgdefault' => $singleMaterial->select);
             $examinationMaterialModel->insert($examinationMaterial);
         }
         /* Salva dados na tabela 'synonym' - Criando os registros */
         $synonymModel = new SynonymModel();
         $examinationSynonymModel = new ExaminationsynonymModel();
         foreach ($synonyms as $singleSynonym) {
             $synonym = array('nmsynonym' => $singleSynonym->nmsynonym, 'fgdefault' => $singleSynonym->select);
             $synonymModel->insert($synonym);
             $cdsynonym = $synonymModel->getAdapter()->lastInsertId();
             // Salva dados na tabela 'examinationsynonym' - ligando os sinonimias ao exame
             $examinationSynonym = array('cdexamination' => $cdexamination, 'cdsynonym' => $cdsynonym);
             $examinationSynonymModel->insert($examinationSynonym);
         }
         $examinationrevisionModel = new ExaminationrevisionModel();
         $columns = $examinationrevisionModel->info(Zend_Db_Table_Abstract::COLS);
         foreach ($values as $id => $value) {
             if (isset($value) && $value != '' && in_array($id, $columns)) {
                 $array[$id] = addslashes($value);
             }
         }
         //var_dump($values);
         //die();
         $examinationrevisionModel->insert($array);
         //$this->_model->getAdapter()->commit();
         // Avisa que o cadastro foi bem sucedido e retorna para o modo de inclusão de exames para um novo cadastro.
         $message = "Cadastro efetuado com sucesso.";
     } catch (Exception $e) {
         $message = "Erro na inserção dos dados. <br> Por favor, entre em contato e informe a mensagem a seguir: </br>";
         $this->_model->getAdapter()->rollBack();
     }
     $this->view->message = $message;
 }
 private function getAppraisalRequestData($cdrequest = null, $cdmap = null, $array = null)
 {
     $query = "\r\n            SELECT\r\n                /* examination */\r\n                examination.cdexamination,\r\n                examination.nmexamination,\r\n\r\n                /* examinationmaterial */\r\n                examinationmaterial.cdexaminationmaterial,\r\n                examinationmaterial.cdexaminationmaterialparent,\r\n\r\n                /* requestexamination */\r\n                requestexamination.cdrequestexamination,\r\n\r\n                /* request */\r\n                request.cdrequest,\r\n\r\n                /* requestexaminationsample */\r\n                requestexaminationsample.nmbarcodesample,\r\n                requestexaminationsample.cdrequestexaminationsample,\r\n                \r\n                /* mapsample */\r\n                mapsample.*,    \r\n                \r\n                /* map */\r\n                map.*,\r\n                \r\n                /* clinet */\r\n                client.nmclient,\r\n                client.dtbirth,\r\n\r\n                /* forward */\r\n                forward.nmforward,\r\n\r\n                /* material */\r\n                material.idmaterial,\r\n                material.nmmaterial,\r\n\r\n                /* requestexamination */\r\n                requestexamination.fgstatus,\r\n                requestexamination.dtcollection,\r\n                \r\n                /* method */\r\n                method.nmmethod\r\n\r\n            from\r\n                request,\r\n                examination,\r\n                examinationmaterial,\r\n                requestexamination,\r\n                examinationmaterialrequest,\r\n                requestexaminationsample,\r\n                mapsample,\r\n                map,\r\n                client,\r\n                forward,\r\n                material,\r\n                method,\r\n                department,\r\n                covenant\r\n                /*\r\n                attribute,\r\n                attributeexaminationmaterial,\r\n                vlrefattribexammaterial,\r\n                factor,\r\n                measurementunit\r\n                */\r\n                \r\n            where\r\n                requestexamination.cdrequest = request.cdrequest \r\n                and examination.cdexamination = examinationmaterial.cdexamination\r\n                and examinationmaterialrequest.cdrequestexamination = requestexamination.cdrequestexamination \r\n                and examinationmaterialrequest.cdexaminationmaterial = examinationmaterial.cdexaminationmaterial \r\n                and requestexaminationsample.cdrequest = request.cdrequest \r\n                and requestexaminationsample.cdrequestexamination = requestexamination.cdrequestexamination \r\n                and requestexaminationsample.cdrequestexaminationsample = mapsample.cdrequestexaminationsample\r\n                and mapsample.cdmap = map.cdmap\r\n                and client.cdclient = request.cdclient \r\n                and forward.cdforward = request.cdforward \r\n                and examinationmaterial.cdmaterial = material.cdmaterial \r\n                and method.cdmethod = examinationmaterial.cdmethod\r\n                and examinationmaterial.cddepartment = department.cddepartment\r\n                and request.cdcovenant = covenant.cdcovenant\r\n                and requestexamination.fgstatus IN (1,2,3)    \r\n                \r\n                /* Attribute table keys \r\n                and attribute.cdattribute = factor.cdattribute\r\n                and attribute.cdattribute = attributeexaminationmaterial.cdattribute\r\n                and attribute.cdmeasurementunit = measurementunit.cdmeasurementunit\r\n\r\n                and attributeexaminationmaterial.cdattribute = vlrefattribexammaterial.cdattributeexaminationmaterial\r\n                and attributeexaminationmaterial.cdattribute = factor.cdattribute\r\n                and attributeexaminationmaterial.cdexaminationmaterial = examinationmaterial.cdexaminationmaterial\r\n\r\n                and vlrefattribexammaterial.cdfactor = factor.cdfactor\r\n                */\r\n        ";
     //Aqui é tratada o tipo de busca, pois em uma busca por mapa não é necessário filtrar a request
     if ($cdrequest != null && $cdmap == null) {
         $cdrequest = implode(",", $cdrequest);
         $query .= " and request.cdrequest in ({$cdrequest})";
         if (isset($array['nmsample']) && $array['nmsample'] != null) {
             $query .= " and requestexaminationsample.nmbarcodesample LIKE '%" . $array['nmsample'] . "%'";
         }
         if (isset($array['startdtrequest']) && $array['startdtrequest'] != null) {
             $startdtrequest = GslabUtils::dateToDatabaseFormat($array['startdtrequest']);
             $query .= " and request.dtrequest >= " . $startdtrequest;
         }
         if (isset($array['enddtrequest']) && $array['enddtrequest'] != null) {
             $enddtrequest = GslabUtils::dateToDatabaseFormat($array['enddtrequest']);
             $query .= " and request.dtrequest <= " . $enddtrequest;
         }
     } else {
         if ($cdmap != null) {
             $query .= " and mapsample.cdmap = {$cdmap} ";
             if (isset($array['startpage']) && $array['startpage'] != null) {
                 $query .= " and mapsample.nrmappage >= " . $array['startpage'];
             }
             if (isset($array['endpage']) && $array['endpage'] != null) {
                 $query .= " and mapsample.nrmappage <= " . $array['endpage'];
             }
             if (isset($array['startdtmaprendering']) && $array['startdtmaprendering'] != null) {
                 $startdtmaprendering = GslabUtils::dateToDatabaseFormat($array['startdtmaprendering']);
                 $query .= " and map.dtmaprendering >= " . $startdtmaprendering;
             }
             if (isset($array['enddtmaprendering']) && $array['enddtmaprendering'] != null) {
                 $enddtmaprendering = GslabUtils::dateToDatabaseFormat($array['enddtmaprendering']);
                 $query .= " and map.dtmaprendering <= " . $enddtmaprendering;
             }
         }
     }
     // Agrupamento pelo código da amostra para evitar duplicidades
     //  por número da página em que a amostra se encontra no mapa
     $query .= " group by mapsample.cdrequestexaminationsample";
     //$query .= " GROUP BY examination.cdexamination";
     //        echo "query: $query <br />";
     //        die();
     $bootstrap = $this->getInvokeArg('bootstrap');
     $gslab_db = $bootstrap->getResource('db');
     $query = $gslab_db->query($query);
     $result = $query->fetchAll();
     return $result;
 }
Пример #11
0
 public function editAction()
 {
     $cdclient = $this->_request->getParam("cdclient");
     $addressTypeModel = new AddresstypeModel();
     $this->view->addressTypeData = $addressTypeModel->getAllAddressType();
     $clientModel = new ClientModel();
     $clientadressModel = new ClientaddressModel();
     $clientphoneModel = new ClientphonenumberModel();
     $clientaddressData = $clientadressModel->fetchRow();
     $client = $clientModel->fetchRow('cdclient = ' . $cdclient);
     $this->view->client = $client;
     $age = $this->view->client->dtbirth;
     $data = new Zend_Date($this->view->client->dtbirth, "YYYY-MM-dd HH:mm:ss");
     $this->view->client->dtbirth = $data->toString('dd-MM-YYYY');
     $this->view->nrage = GslabUtils::calcAgeDifferenceShort($age);
     $this->view->address = $clientadressModel->fetchRow($clientadressModel->getStateById($clientaddressData['idstate'], $cdclient));
     $clientphoneData = $clientphoneModel->fetchRow('cdclient = ' . $cdclient);
     $this->view->phone = $clientphoneData;
     if ($client['dtdum'] != '') {
         $client['dtdum'] = new Zend_Date($this->view->client->dtdum, "YYYY-MM-dd HH:mm:ss");
         $this->view->dtdum = $client['dtdum']->toString('dd-MM-YYYY');
     } else {
         $this->view->dtdum = '';
     }
     if ($clientphoneData['cdclientphonenumber'] != '') {
         $cdclientphonenumber = $clientphoneData['cdclientphonenumber'];
         if ($clientphoneData['nrphonenumber'] != '') {
             $phonenumber = $clientphoneData['nrphonenumber'];
             $dddphonenumber = $clientphoneData['nrdddphone'];
         } else {
             $phonenumber = '';
             $dddphonenumber = '';
         }
         if ($clientphoneData['nrcellphonenumber'] != '') {
             $cellphonenumber = $clientphoneData['nrcellphonenumber'];
             $dddcellphonenumber = $clientphoneData['nrdddcellphone'];
         } else {
             $cellphonenumber = '';
             $dddcellphonenumber = '';
         }
     } else {
         $phonenumber = '';
         $dddphonenumber = '';
         $cdclientphonenumber = '';
         $cellphonenumber = '';
         $dddcellphonenumber = '';
     }
     $this->view->nrphonenumber = $phonenumber;
     $this->view->nrcellphonenumber = $cellphonenumber;
     $this->view->nrdddphone = $dddphonenumber;
     $this->view->nrdddcellphone = $dddcellphonenumber;
     $this->view->cdclientphonenumber = $cdclientphonenumber;
 }