123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- <?php
- declare (strict_types=1);
- namespace app\admin\servies;
- use app\zskk\model\HospitalHrpatient;
- use app\zskk\model\HrRecord;
- use app\zskk\servies\PatientServies;
- class HrpatientServies
- {
- private $hrpatientModel = null;
- private $patientServies = null;
- private $hrRecordModel = null;
- public function __construct(
- PatientServies $patientServies,
- HospitalHrpatient $hrpatientModel,
- HrRecord $hrRecordModel
- )
- {
- // parent::__construct();
- $this->patientServies = $patientServies;
- $this->hrpatientModel = $hrpatientModel;
- $this->hrRecordModel = $hrRecordModel;
- }
- public function getMyHrpatientDetails($params): array {
- $hrModel = $this->hrpatientModel;
- $patientServies = $this->patientServies;
- $HR_CODE = $params['HR_CODE'] ?? '';
- $PATIENT_CODE = $params['PATIENT_CODE'] ?? false;
- if(!$PATIENT_CODE) {
- $hrpatient = $hrModel->where('HR_CODE', $HR_CODE)->find();
- $PATIENT_CODE = $hrpatient['PATIENT_CODE'];
- }
- $hrpatients = $hrModel->where('PATIENT_CODE', $PATIENT_CODE)->select();
- $data = $patientServies->getPatient(['PATIENT_CODE'=> $PATIENT_CODE]);
- $details = [];
- foreach($hrpatients as $hrpatient) {
- $details[] = $this->_getHrpatientDetail($hrpatient);
- }
- return [
- "data" => $data,
- "details" => $details
- ];
- }
- public function getOtherHrpatientDetail($params): array {
- $hrModel = $this->hrpatientModel;
- $patientServies = $this->patientServies;
- $HR_CODE = $params['HR_CODE'] ?? '';
- $hrpatient = $hrModel->where('HR_CODE', $HR_CODE)->find();
- $PATIENT_CODE = $hrpatient['PATIENT_CODE'];
- $data = $patientServies->getPatient(['PATIENT_CODE'=> $PATIENT_CODE]);
- $detail = $this->_getHrpatientDetail($hrpatient);
-
- return [
- "data" => $data,
- "detail" => $detail
- ];
- }
- public function getHrpatientList($params): array {
- $hrModel = $this->hrpatientModel;
- $ID = $params['ID'] ?? false;
- // $timestamp = strtotime(date('Y-m-d', time()));
- // $timestamp = 1575728488;
- $where = [
- // ['create_time', '>=', $timestamp],
- ['create_time', '>=', date('Y-m-d 00:00:00')],
- ];
- if($ID) {
- $where[] = ['ID', '>', (int)$ID];
- }
- $list = $hrModel
- ->field('ID, create_time, ORGNAME, HRORGNAME, NAME, LAB_ITEMNAME, EXAM_ITEMNAME')
- ->where($where)
- ->order('ID ASC')
- ->select();
- $count = count($list);
- $lastId = 0;
- if($count > 0 ) {
- $lastId = $list[$count - 1]['ID'];
- }
- return [
- 'list' => $list,
- 'total' => count($list),
- 'lastId' => $lastId
- ];
- }
- public function _getHrpatientDetailByPATIENT_CODE($PATIENT_CODE, $HRORGCODE) {
- $where = [
- 'PATIENT_CODE' => $PATIENT_CODE,
- 'HRORGCODE' => $HRORGCODE,
- ];
- $hr_records = $this->hrRecordModel->field(['REPORTID','ORGNAME','ORGCODE','HRORGNAME','HRORGCODE','ITEMNAME','ITEMNAMECODE','ITEMNAMETYPE','HR_STATUS','BHR_CODE','BHR_REASON'])->where($where)->select();
- return $hr_records;
- }
-
- public function _getHrpatientDetail($hrpatient): array {
- $hrRecordModel = $this->hrRecordModel;
- $where = [
- 'PATIENT_CODE' => $hrpatient['PATIENT_CODE'],
- 'ORGCODE' => $hrpatient['ORGCODE'],
- 'HRORGCODE' => $hrpatient['HRORGCODE'],
- ];
- $hr_records = $hrRecordModel->field('ORGCODE, HRORGCODE, update_time, create_time, ITEMNAME, ITEMNAMECODE, HR_STATUS, BHR_CODE, ITEMNAMETYPE')->where($where)->select();
- return [
- "MPI" => $hrpatient['MPI'],
- "NAME" => $hrpatient['NAME'],
- "GENDER" => $hrpatient['GENDER'],
- "ORGNAME" => $hrpatient['ORGNAME'],
- "HRORGNAME" => $hrpatient['HRORGNAME'],
- "ORGCODE" => $hrpatient['ORGCODE'],
- "HRORGCODE" => $hrpatient['HRORGCODE'],
- "AGE" => $hrpatient['AGE'],
- "ENCOUNTER_DATE" => $hrpatient['ENCOUNTER_DATE'],
- "DIAGNOSENAME" => $hrpatient['DIAGNOSENAME'],
- "CHIEFCOMPLAINT" => $hrpatient['CHIEFCOMPLAINT'],
- "hr_records" => $hr_records,
- ];
- }
- }
|