예제 #1
0
 public function actionSearch()
 {
     $persons = new stdClass();
     $persons->status = '';
     $kbp = (string) filter_input(INPUT_POST, 's');
     if ($kbp !== '') {
         // NGP::GetOFOMSObject() Функция подключается к порталу ОФОМС и возвращает объект с результатом или строку с ошибкой
         $ofoms_result = NGP::GetOFOMSObject('services/search-uri', '&s=' . $kbp . '&rtype=json');
         if (!is_string($ofoms_result)) {
             $person = new stdClass();
             $persons->general = array();
             if ($ofoms_result['status'] >= 0) {
                 if (isset($ofoms_result['persons'])) {
                     foreach ($ofoms_result['persons'] as $v1) {
                         foreach (array_keys($v1) as $k1) {
                             $str1 = 'ofoms_' . $k1;
                             $person->{$str1} = $v1[$k1];
                         }
                         array_push($persons->general, clone $person);
                     }
                 }
             } else {
                 $persons->status = $ofoms_result['message'];
             }
         } else {
             $persons->status = $ofoms_result;
         }
     } else {
         $persons->status = 'Отправлена пустая строка';
     }
     echo json_encode($persons);
 }
예제 #2
0
 public function Save()
 {
     if ($this->validate()) {
         $kbp = mb_substr($this->ofoms_fam, 0, 3, 'utf-8') . mb_substr($this->ofoms_im, 0, 1, 'utf-8') . mb_substr($this->ofoms_ot === '' ? ' ' : $this->ofoms_ot, 0, 1, 'utf-8') . mb_substr($this->ofoms_dr, 2, 2, 'utf-8');
         // NGP::GetOFOMSObject() Функция подключается к порталу ОФОМС и возвращает объект с результатом или строку с ошибкой
         $ofoms_result = NGP::GetOFOMSObject('services/attach-person', '&typemp=1&ffio=' . $kbp . '&policy=' . $this->ofoms_enp . '&doctor=' . $this->ofoms_doc_inn . '&rtype=json');
         if (!is_string($ofoms_result) && $ofoms_result['status'] !== 1) {
             throw new CHttpException(500, $ofoms_result['message']);
         }
     } else {
         throw new CHttpException(500, json_encode($this->getErrors()));
     }
 }