123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- <?php
- declare (strict_types=1);
- namespace app\zskk\controller;
- use app\common\controller\ZskkApiController;
- use app\common\library\Gm;
- use app\common\library\Handle;
- use app\zskk\model\Mapping;
- use think\Config;
- use think\db\exception\DataNotFoundException;
- use think\db\exception\DbException;
- use think\db\exception\ModelNotFoundException;
- use think\facade\Cache;
- use think\facade\Db;
- use think\Exception;
- use Throwable;
- use app\zskk\servies\PatientServies;
- class Patient extends ZskkApiController
- {
- /**
- * 后台初始化请求
- * @return void
- * @throws Throwable
- */
- public function addPatient(PatientServies $servies): void
- {
- set_time_limit(0);
- Db::startTrans();
- $params = $this->request->post();
- try{
- // var_dump($params['DATA']);die;
- $data = $servies->makeMappingData($params['DATA'],'DATA');
- $patientData = $data['PATIENT'];
- $medical = $data['MEDICAL_INFORMATION'];
- $application = $data['EXAM_APPLICATIONS'];
- $orders = $data['MEDICAL_ORDERS'];
- $exam = $data['EXAM_REPORTS'];
- $inspect = $data['INSPECT_REPORTS'];
- $diagnoses = $data['DIAGNOSES'];
- $mpiData = $servies->getMpi($patientData['ID_CARDNUM']);
- $mpiKey = $mpiData['MPI_KEY'] ?? '';
- $mpi = $mpiData['MPI'] ?? '';
- if(empty($mpiKey))
- {
- $mpiKey = Handle::makeMpiKey($patientData['ID_CARDNUM']);
- $mpi = Handle::makeMpi();
- $servies->saveMpi($mpi,$patientData['ID_CARDNUM'],$mpiKey);
- }
- // $patientCode = Handle::makePatientCode($medical['ORGCODE'],$medical['SERIESNUM']);
- $patientCode = Handle::makePatientCode($mpiKey, $medical['ORGCODE'],$medical['SERIESNUM']);
- $servies->savePatient($patientData,$mpi,$mpiKey,$patientCode); //患者表patient
- $servies->saveMedical($medical,$mpiKey,$patientCode); //medicalinformation表
- $servies->saveDiagnose($diagnoses,$patientCode); //diagnoses表
- $servies->saveApplication($application,$mpiKey,$patientCode); //examapplication表
- $servies->saveOrders($orders,$mpiKey,$patientCode); // 检验医嘱表 返回检验申请单标识
- // $servies->saveExamReport($exam,$mpiKey,$patientCode,$application['EXAM_ITEMNAME_CODE']); //检查报告表
- $servies->saveExamReport($exam,$mpiKey,$patientCode); //检查报告表
- $servies->saveInspectReport($inspect,$mpiKey,$patientCode); // 检验报告表
- // 管理后台-医院医院数据-患者信息表
- $servies->saveHospitalPatient($mpiKey, $mpi, $patientCode, $patientData, $medical, $diagnoses, $orders, $application);
- $servies->updateMiddleStatus($params['middleId'],['status'=>3]);
- Db::commit();
- }catch (\Exception $e)
- {
- // 9
- $servies->updateMiddleStatus($params['middleId'],['status'=>9]);
- Db::rollback();
- $this->error($e->getMessage());
- }
- $this->success('', 'success');
- }
- /**
- * @throws ModelNotFoundException
- * @throws DataNotFoundException
- * @throws DbException
- */
- public function getPatientInfo(PatientServies $servies): void
- {
- $params = $this->request->post();
- $patientCode = $params['PATIENT_CODE'];
- $data = $servies->getPatient(['PATIENT_CODE'=>$patientCode]);
- $this->success('',$data);
- }
- /**
- * 上传检查数据
- */
- public function postExamInfo(PatientServies $servies): void
- {
- try {
- $params = $this->request->post();
- $params = $this->getDecryptData($params['data']);
- $params = $servies->makeMappingData($params,'0','postExamInfo');
- $data = $servies->postExamInfo($params);
- $data = $this->makeEncryptData($data);
- $this->success($data,'');
- }catch (\Exception $e)
- {
- $this->error($e->getMessage());
- }
- }
- /**
- * 上传检查数据
- */
- public function postExamReport(PatientServies $servies): void
- {
- try {
- $params = $this->request->post();
- $params = $this->getDecryptData($params['data']);
- $params = $servies->makeMappingData($params,'0','postExamReport');
- $data = $servies->postExamReport($params);
- $data = $this->makeEncryptData($data);
- $this->success($data,'');
- }catch (\Exception $e)
- {
- $this->error($e->getMessage());
- }
- }
- /**
- * 上传检验数据
- */
- public function postLisReport(PatientServies $servies): void
- {
- try {
- $params = $this->request->post();
- $params = $this->getDecryptData($params['data']);
- $params = $servies->makeMappingData($params,'0','postLabReport');
- $data = $servies->postLabReport($params);
- $data = $this->makeEncryptData($data);
- $this->success($data,'');
- }catch (\Exception $e)
- {
- $this->error($e->getMessage());
- }
- }
- }
|