HrpatientServies.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php
  2. declare (strict_types=1);
  3. namespace app\admin\servies;
  4. use app\zskk\model\HospitalHrpatient;
  5. use app\zskk\model\HrRecord;
  6. use app\zskk\servies\PatientServies;
  7. class HrpatientServies
  8. {
  9. private $hrpatientModel = null;
  10. private $patientServies = null;
  11. private $hrRecordModel = null;
  12. public function __construct(
  13. PatientServies $patientServies,
  14. HospitalHrpatient $hrpatientModel,
  15. HrRecord $hrRecordModel
  16. )
  17. {
  18. // parent::__construct();
  19. $this->patientServies = $patientServies;
  20. $this->hrpatientModel = $hrpatientModel;
  21. $this->hrRecordModel = $hrRecordModel;
  22. }
  23. public function getMyHrpatientDetails($params): array {
  24. $hrModel = $this->hrpatientModel;
  25. $patientServies = $this->patientServies;
  26. $HR_CODE = $params['HR_CODE'] ?? '';
  27. $PATIENT_CODE = $params['PATIENT_CODE'] ?? false;
  28. if(!$PATIENT_CODE) {
  29. $hrpatient = $hrModel->where('HR_CODE', $HR_CODE)->find();
  30. $PATIENT_CODE = $hrpatient['PATIENT_CODE'];
  31. }
  32. $hrpatients = $hrModel->where('PATIENT_CODE', $PATIENT_CODE)->select();
  33. $data = $patientServies->getPatient(['PATIENT_CODE'=> $PATIENT_CODE]);
  34. $details = [];
  35. foreach($hrpatients as $hrpatient) {
  36. $details[] = $this->_getHrpatientDetail($hrpatient);
  37. }
  38. return [
  39. "data" => $data,
  40. "details" => $details
  41. ];
  42. }
  43. public function getOtherHrpatientDetail($params): array {
  44. $hrModel = $this->hrpatientModel;
  45. $patientServies = $this->patientServies;
  46. $HR_CODE = $params['HR_CODE'] ?? '';
  47. $hrpatient = $hrModel->where('HR_CODE', $HR_CODE)->find();
  48. $PATIENT_CODE = $hrpatient['PATIENT_CODE'];
  49. $data = $patientServies->getPatient(['PATIENT_CODE'=> $PATIENT_CODE]);
  50. $detail = $this->_getHrpatientDetail($hrpatient);
  51. return [
  52. "data" => $data,
  53. "detail" => $detail
  54. ];
  55. }
  56. public function getHrpatientList($params): array {
  57. $hrModel = $this->hrpatientModel;
  58. $ID = $params['ID'] ?? false;
  59. // $timestamp = strtotime(date('Y-m-d', time()));
  60. // $timestamp = 1575728488;
  61. $where = [
  62. // ['create_time', '>=', $timestamp],
  63. ['create_time', '>=', date('Y-m-d 00:00:00')],
  64. ];
  65. if($ID) {
  66. $where[] = ['ID', '>', (int)$ID];
  67. }
  68. $list = $hrModel
  69. ->field('ID, create_time, ORGNAME, HRORGNAME, NAME, LAB_ITEMNAME, EXAM_ITEMNAME')
  70. ->where($where)
  71. ->order('ID ASC')
  72. ->select();
  73. $count = count($list);
  74. $lastId = 0;
  75. if($count > 0 ) {
  76. $lastId = $list[$count - 1]['ID'];
  77. }
  78. return [
  79. 'list' => $list,
  80. 'total' => count($list),
  81. 'lastId' => $lastId
  82. ];
  83. }
  84. public function _getHrpatientDetailByPATIENT_CODE($PATIENT_CODE, $HRORGCODE) {
  85. $where = [
  86. 'PATIENT_CODE' => $PATIENT_CODE,
  87. 'HRORGCODE' => $HRORGCODE,
  88. ];
  89. $hr_records = $this->hrRecordModel->field(['REPORTID','ORGNAME','ORGCODE','HRORGNAME','HRORGCODE','ITEMNAME','ITEMNAMECODE','ITEMNAMETYPE','HR_STATUS','BHR_CODE','BHR_REASON'])->where($where)->select();
  90. return $hr_records;
  91. }
  92. public function _getHrpatientDetail($hrpatient): array {
  93. $hrRecordModel = $this->hrRecordModel;
  94. $where = [
  95. 'PATIENT_CODE' => $hrpatient['PATIENT_CODE'],
  96. 'ORGCODE' => $hrpatient['ORGCODE'],
  97. 'HRORGCODE' => $hrpatient['HRORGCODE'],
  98. ];
  99. $hr_records = $hrRecordModel->field('ORGCODE, HRORGCODE, update_time, create_time, ITEMNAME, ITEMNAMECODE, HR_STATUS, BHR_CODE, ITEMNAMETYPE')->where($where)->select();
  100. return [
  101. "MPI" => $hrpatient['MPI'],
  102. "NAME" => $hrpatient['NAME'],
  103. "GENDER" => $hrpatient['GENDER'],
  104. "ORGNAME" => $hrpatient['ORGNAME'],
  105. "HRORGNAME" => $hrpatient['HRORGNAME'],
  106. "ORGCODE" => $hrpatient['ORGCODE'],
  107. "HRORGCODE" => $hrpatient['HRORGCODE'],
  108. "AGE" => $hrpatient['AGE'],
  109. "ENCOUNTER_DATE" => $hrpatient['ENCOUNTER_DATE'],
  110. "DIAGNOSENAME" => $hrpatient['DIAGNOSENAME'],
  111. "CHIEFCOMPLAINT" => $hrpatient['CHIEFCOMPLAINT'],
  112. "hr_records" => $hr_records,
  113. ];
  114. }
  115. }