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;
 }
 public function editexaminationdataAction()
 {
     $values = $this->_request->getParams();
     if (isset($values['dtcollection']) != '') {
         $values['dtcollection'] = GslabUtils::dateToDatabaseFormat($values['dtcollection']);
         $values['fgstatus'] = 1;
     } else {
         $values['fgstatus'] = 2;
     }
     if (isset($values['dtresult']) != '') {
         $values['dtresult'] = GslabUtils::dateToDatabaseFormat($values['dtresult']);
     }
     $array = array();
     $requestExaminationModel = new RequestexaminationModel();
     $examinationMaterialRequestModel = new ExaminationmaterialrequestModel();
     $columns = $requestExaminationModel->info(Zend_Db_Table_Abstract::COLS);
     $requestExaminationModel->getAdapter()->beginTransaction();
     try {
         foreach ($values as $id => $value) {
             if (isset($value) && $value != '' && $value != '0' && in_array($id, $columns)) {
                 $array[$id] = addslashes($value);
             } else {
                 if (in_array($id, $columns)) {
                     $array[$id] = null;
                 }
             }
         }
         if (isset($values['fgpriority'])) {
             if ($values['fgpriority'] == 'Sim') {
                 $array['fgpriority'] = 1;
             } else {
                 $array['fgpriority'] = 2;
             }
         }
         if (empty($array) && $values['oper'] != 'del') {
             throw new Exception('Dados Incorretos. Confira seus dados e Tente Novamente.');
         } else {
             if ($values['oper'] != 'del') {
                 $requestExaminationModel->update($array, "cdrequestexamination = " . $values['cdrequestexamination']);
             } else {
                 // Apenas altera o status da amostra para "Inativo" no lugar de DELETA-LO do banco de dados
                 $requestExaminationModel->update(array("fgstatus" => 0), "cdrequestexamination = " . $values['id']);
                 //                $examinationMaterialRequestModel->delete("cdrequestexamination = ".$values['id']);
                 //                $requestExaminationModel->delete("cdrequestexamination = ".$values['id']);
             }
         }
         $requestExaminationModel->getAdapter()->commit();
     } catch (exception $e) {
         $requestExaminationModel->getAdapter()->rollback();
         $this->addMessage($e->getMessage());
     }
 }
 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");
 }
Exemplo n.º 4
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;
 }
 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;
 }
Exemplo n.º 6
0
 public function includeAction()
 {
     $clientModel = new ClientModel();
     $clientModel->getAdapter()->beginTransaction();
     $savetype = $this->_request->getParam("type");
     $covenantdata = $this->_request->getParam("covenantdata");
     $clientPhoneModel = new ClientphonenumberModel();
     $clientAdressModel = new ClientaddressModel();
     $clientcovenantModel = new ClientcovenantModel();
     $paramClientArray = array();
     $idcpf = $this->_request->getParam('idcpf');
     $idcep = $this->_request->getParam('idcep');
     //      *** Remove caracteres do CPF e RG ***
     $idcpf = str_replace(array(".", "-"), "", $idcpf);
     $idcep = str_replace("-", " ", $idcep);
     $paramClientArray = array('cdclient' => $this->_request->getParam('cdclient'), 'nmclient' => $this->_request->getParam('nmclient'), 'nmmail' => $this->_request->getParam('nmmail'), 'fgsex' => $this->_request->getParam('fgsex'), 'idrg' => $this->_request->getParam('idrg'), 'idcpf' => $idcpf, 'dtbirth' => $this->_request->getParam('dtbirth'), 'dtdum' => $this->_request->getParam('dtdum'), 'nmprofessional' => $this->_request->getParam('nmprofessional'), 'nrweight' => $this->_request->getParam('nrweight'), 'nrheight' => $this->_request->getParam('nrheight'), 'nmimage' => $this->_request->getParam('nmimage'), 'fgbloodtype' => $this->_request->getParam('fgbloodtype'), 'fgdufactor' => $this->_request->getParam('fgdufactor'), 'fgrhfactor' => $this->_request->getParam('fgrhfactor'), 'fgskincolor' => $this->_request->getParam('fgskincolor'), 'nrsonsnumber' => $this->_request->getParam('nrsonsnumber'), 'nmfather' => $this->_request->getParam('nmfather'), 'nmmother' => $this->_request->getParam('nmmother'), 'dsobservation' => $this->_request->getParam('dsobservation'), 'fgvip' => $this->_request->getParam('fgvip'), 'fgmailmkt' => $this->_request->getParam('fgmailmkt'), 'fgsmoker' => $this->_request->getParam('fgsmoker'), 'fgdiabetes' => $this->_request->getParam('fgdiabetes'), 'fgmaritalstatus' => $this->_request->getParam('fgmaritalstatus'), 'nrcardnumber' => $this->_request->getParam('nrcardnumber'));
     if (isset($paramClientArray["dtbirth"]) && $paramClientArray["dtbirth"] != '') {
         $paramClientArray["dtbirth"] = GslabUtils::dateToDatabaseFormat($paramClientArray["dtbirth"]);
     }
     if (isset($paramClientArray["dtdum"]) && $paramClientArray["dtdum"] != '') {
         $paramClientArray["dtdum"] = GslabUtils::dateToDatabaseFormat($paramClientArray["dtdum"]);
     }
     if ($savetype == 'edit') {
         $this->_model->update($paramClientArray, 'cdclient = ' . $this->_request->getParam('cdclient'));
         $cdclient = $this->_request->getParam('cdclient');
     } else {
         if ($savetype == 'add') {
             $cdclient = $this->_model->insert($paramClientArray);
         }
     }
     //*** Insere os dados do ClientAddress***
     $paramAddressArray = array('cdclient' => $cdclient, 'idcep' => $idcep, 'nmstreet' => $this->_request->getParam('nmstreet'), 'idaddresstype' => $this->_request->getParam('idaddresstype'), 'nmclientaddress' => $this->_request->getParam('nmclientaddress'), 'nrnumber' => $this->_request->getParam('nrnumber'), 'nmneighborhood' => $this->_request->getParam('nmneighborhood'), 'idcity' => $this->_request->getParam('idcity'), 'idstate' => $this->_request->getParam('fgstate'), 'idcomplement' => $this->_request->getParam('idcomplement'));
     if ($savetype == 'edit') {
         $clientAdressModel->update($paramAddressArray, 'cdclient = ' . $this->_request->getParam('cdclient'));
     } else {
         if ($savetype == 'add') {
             $clientAdressModel->insert($paramAddressArray);
         }
     }
     //*** Insere os dados do ClientPhoneNumber  ***
     if ($this->_request->getParam('nrphonenumber') != '' || $this->_request->getParam('nrcellphone') != '') {
         $paramPhoneArray = array('cdclient' => $cdclient, 'nrphonenumber' => $this->_request->getParam('nrphonenumber'), 'nrdddphone' => $this->_request->getParam('nrdddphone'), 'nrdddcellphone' => $this->_request->getParam('nrdddcellphone'), 'nrcellphonenumber' => $this->_request->getParam('nrcellphone'));
         if ($this->_request->getParam('cdclientphonenumber') != '') {
             $clientPhoneModel->update($paramPhoneArray, 'cdclientphonenumber = ' . $this->_request->getParam('cdclientphonenumber'));
         } else {
             $clientPhoneModel->insert($paramPhoneArray);
         }
     }
     if (!empty($covenantdata)) {
         $covenantdata = json_decode($covenantdata);
         $client = $this->_request->getParam("cdclient");
         if ($client != '') {
             $clientcovenantModel->delete('cdclient = ' . $client);
         }
         foreach ($covenantdata as $linha) {
             if ($linha->fgstatus == 0) {
                 $linha->fgstatus = 2;
             }
             $arrayCovenant = array('cdclient' => $cdclient, 'cdcovenant' => $linha->cdcovenant, 'idcovenantcard' => $linha->nrregistration, 'nmcardholder' => $linha->nmcardholder, 'dtreference' => date("Y-m-d H:i:s"), 'fgactive' => $linha->fgstatus);
             try {
                 $clientcovenantModel->insert($arrayCovenant);
             } catch (Exception $e) {
                 header("HTTP/1.0 406 Não foi possivel salvar os dados do paciente no sistema: Erro Interno -> " . $e->getMessage() . ".");
             }
             $arrayCovenant = '';
         }
     }
     echo 'tudo ok';
     $this->_model->getAdapter()->commit();
     //        $values = $this->_request->getParam("data");
     //        $values = explode("&", $values);
     //
     //        /*
     //         * Organiza em um array os dados recebidos
     //         */
     //        $formData = array();
     //        foreach($values as $value)
     //        {
     //            $value = explode("=", $value);
     //            $formData[ $value[0] ] = $value[1];
     //            $formData = str_replace("+", " ", $formData);
     //        }
     //
     //        $values = $formData;
     //
     //
     //        $savetype = $this->_request->getParam("type");
     //        $covenantdata = $this->_request->getParam("covenantdata");
     ////        $img = $_GET["img"];
     //
     //        $clientPhoneModel = new ClientphonenumberModel();
     //        $clientAdressModel = new ClientaddressModel();
     //        $clientcovenantModel = new ClientcovenantModel();
     //
     ////      *** Remove caracteres do CPF e RG ***
     //        $values["idcpf"] = str_replace(array(".", "-"), "", $values["idcpf"]);
     //        $values["nrheight"] = str_replace(",", ".", $values["nrheight"]);
     //
     //        $this->_model->getAdapter()->beginTransaction();
     //
     //        $paramClientArray = array();
     //
     //        try
     //        {
     //
     //            $idstate = GslabUtils::getBrazilianStatePrefix($values['idstate']);
     //            $nmclientaddress = GslabUtils::getLogradouroSaveDataBase($values['idaddresstype']);
     //
     //
     //
     //            $paramClientArray = array(
     //                'cdclient' => $values['cdclient'],
     //                'nmclient' => $values['nmclient'],
     //                'nmmail' => $values['nmmail'],
     //                'fgsex' => $fgsex,
     //                'idrg' => $values['idrg'],
     //                'idcpf' => $values['idcpf'],
     //                'dtbirth' => $values['dtbirth'],
     //                'nrweight' => $values['nrweight'],
     //                'nrheight' => $values['nrheight'],
     ////                'nmimage' => $img,
     //                'fgbloodtype' => $values['fgbloodtype'],
     //                'fgdufactor' => $values['fgdufactor'],
     //                'fgrhfactor' => $values['fgrhfactor'],
     //                'fgskincolor' => $values['fgskincolor'],
     //                'nrsonsnumber' => $values['nrsonsnumber'],
     //                'nmfather' => $values['nmfather'],
     //                'nmmother' => $values['nmmother'],
     //                'dsobservation' => $values['dsobservation'],
     //                'fgvip' => $fgvip,
     //                'fgmailmkt' => $fgmailmkt,
     //                'fgsmoker' => $fgsmoker,
     //                'fgdiabetes' => $fgdiabetes
     //            );
     //
     //            if (isset($paramClientArray["dtbirth"]) && $paramClientArray["dtbirth"] != '')
     //                $paramClientArray["dtbirth"] = GslabUtils::dateToDatabaseFormat($paramClientArray["dtbirth"]);
     //
     //            if ($savetype == 'edit')
     //                $this->_model->update($paramClientArray, 'cdclient = ' . $values['cdclient']);
     //            else if ($savetype == 'add')
     //                $values['cdclient'] = $this->_model->insert($paramClientArray);
     //
     //            //*** Insere os dados do ClientAddress***
     //            $paramAddressArray = array(
     //                'cdclient' => $values['cdclient'],
     //                'idcep' => $values['idcep'],
     //                'nmstreet' => $values['nmstreet'],
     //                'idaddresstype' => $values['idaddresstype'],
     //                'nmclientaddress' => $nmclientaddress,
     //                'nrnumber' => $values['nrnumber'],
     //                'nmneighborhood' => $values['nmneighborhood'],
     //                'idcity' => $values['idcity'],
     //                'idstate' => $values['idstate'],
     //                'idcomplement' => $values['idcomplement']
     //            );
     //
     //            if ($savetype == 'edit')
     //                $clientAdressModel->update($paramAddressArray, 'cdclient = ' . $values['cdclient']);
     //            else if ($savetype == 'add')
     //                $clientAdressModel->insert($paramAddressArray);
     //
     //
     //            //*** Insere os dados do ClientPhoneNumber  ***
     //            if (isset($values['nrcomercialphone']) && $values['nrcomercialphone'] != '')
     //            {
     //                $dddRes = 47;
     //                $numRes = $values['nrcomercialphone'];
     //
     //                $paramPhoneArray = array(
     //                    'cdclient' => $values['cdclient'],
     //                    'nrdddphone' => $dddRes,
     //                    'nrphonenumber' => $numRes,
     //                    'fgtypephone' => 1
     //                );
     //
     //
     //                if (count($clientPhoneModel->fetchAll('cdclient = ' . $values['cdclient'])) > 0)
     //                    $clientPhoneModel->update($paramPhoneArray, 'cdclient = ' . $values['cdclient']);
     //                else
     //                    $clientPhoneModel->insert($paramPhoneArray);
     //
     //            }
     //
     //            if (isset($values['nrphonenumber']) && $values['nrphonenumber'] != '')
     //            {
     //                $numeroCel = explode(" ", $values['nrphonenumber']);
     //                $dddCel = 47;
     //                $numCel = $values['nrphonenumber'];
     //
     //                $paramCelArray = array(
     //                    'cdclient' => $values['cdclient'],
     //                    'nrdddphone' => $dddCel,
     //                    'nrphonenumber' => $numCel,
     //                    'fgtypephone' => 3
     //                );
     //
     //                if (count($clientPhoneModel->fetchAll('cdclient = ' . $values['cdclient'])) > 0)
     //                    $clientPhoneModel->update($paramCelArray, 'cdclient = ' . $values['cdclient']);
     //                else
     //                    $clientPhoneModel->insert($paramCelArray);
     //            }
     //
     //            //$clientcovenantModel->delete('cdclient = ' . $values['cdclient']);
     //            //print_r('cdclient: '. $values['cdclient']);
     //            //die('here');
     //
     //            if(!empty($covenantdata))
     //            {
     //                $covenantdata = json_decode($covenantdata);
     //                foreach ($covenantdata as $linha)
     //                {
     //                    if ($linha->fgstatus == 0)
     //                        $linha->fgstatus = 2;
     //
     //                    $arrayCovenant = array(
     //                        'cdclient' => $values['cdclient'],
     //                        'cdcovenant' => $linha->cdcovenant,
     //                        'idcovenantcard' => $linha->nrregistration,
     //                        'nmcardholder' => $linha->nmcardholder,
     //                        'dtreference' => date("Y-m-d H:i:s"),
     //                        'fgactive' => $linha->fgstatus
     //                    );
     //
     //                    try
     //                    {
     //                        $clientcovenantModel->insert($arrayCovenant);
     //                    }
     //                    catch (Exception $e)
     //                    {
     //                        header("HTTP/1.0 406 Não foi possivel salvar os dados do paciente no sistema: Erro Interno -> ".$e->getMessage().".");
     //                    }
     //                    $arrayCovenant = '';
     //                }
     //                //print_r('covenantdata1: '. $arrayCovenant);
     //                //die();
     //
     //            }
     //
     //            echo 'tudo ok';
     //            $this->_model->getAdapter()->commit();
     //        }
     //        catch (Exception $e)
     //        {
     //            $this->_model->getAdapter()->rollBack();
     //            header("HTTP/1.0 406 Não foi possivel salvar os dados do paciente no sistema: Erro Interno -> ".$e->getMessage().".");
     //        }
 }