|
@@ -2,6 +2,7 @@ package service
|
2
|
2
|
|
3
|
3
|
import (
|
4
|
4
|
"XT_New/models"
|
|
5
|
+ "XT_New/utils"
|
5
|
6
|
"encoding/json"
|
6
|
7
|
"fmt"
|
7
|
8
|
"strconv"
|
|
@@ -12,7 +13,7 @@ import (
|
12
|
13
|
)
|
13
|
14
|
|
14
|
15
|
// GetPatientList 返回患者的列表
|
15
|
|
-func GetPatientList(orgID int64, keywords string, page, limit, schedulType, bindingState, lapseto, source, startTime, endTime, contagion, reimbursementWay, isscheduling, isprescription int64, isStartTime, isEndTime bool, patientSoureType int64) (patients []*models.Patients, total int64, err error) {
|
|
16
|
+func GetPatientList(orgID int64, keywords string, page, limit, schedulType, bindingState, lapseto, source, startTime, endTime, contagion, reimbursementWay, isscheduling, isprescription int64, isStartTime, isEndTime bool, patientSoureType int64, nurse int64) (patients []*models.Patients, total int64, err error) {
|
16
|
17
|
|
17
|
18
|
db := readDb.Table("xt_patients as p").Where("p.status=1")
|
18
|
19
|
if orgID > 0 {
|
|
@@ -68,6 +69,9 @@ func GetPatientList(orgID int64, keywords string, page, limit, schedulType, bind
|
68
|
69
|
if patientSoureType > 0 {
|
69
|
70
|
db = db.Where("p.patient_source =?", patientSoureType)
|
70
|
71
|
}
|
|
72
|
+ if nurse > 0 {
|
|
73
|
+ db = db.Where("p.head_nurse_id = ?", nurse)
|
|
74
|
+ }
|
71
|
75
|
|
72
|
76
|
offset := (page - 1) * limit
|
73
|
77
|
if lapseto == 2 || lapseto == 3 {
|
|
@@ -75,7 +79,13 @@ func GetPatientList(orgID int64, keywords string, page, limit, schedulType, bind
|
75
|
79
|
|
76
|
80
|
}
|
77
|
81
|
if lapseto != 2 && lapseto != 3 {
|
78
|
|
- err = db.Order("p.id desc").Select(" p.id, p.user_org_id, p.user_id, p.patient_type, p.dialysis_no, p.admission_number, p.source, p.lapseto, p.partition_id, p.bed_id, p.name, p.alias, p.gender, p.marital_status, p.id_card_no, p.birthday, p.reimbursement_way_id, p.health_care_type, p.health_care_no, p.health_care_due_date, p.height, p.blood_type, p.rh, p.health_care_due_alert_date, p.education_level, p.profession, p.phone, p.home_telephone, p.relative_phone, p.relative_relations, p.home_address, p.work_unit, p.unit_address, p.children, p.receiving_date, p.is_hospital_first_dialysis, p.first_dialysis_date, p.first_dialysis_hospital, p.induction_period, p.initial_dialysis, p.total_dialysis, p.attending_doctor_id, p.head_nurse_id, p.evaluate, p.diagnose, p.remark, p.registrars_id, p.registrars, p.qr_code, p.binding_state, p.status, p.created_time, p.updated_time,p.user_sys_before_count,p.out_reason,p.death_time,p.is_infectious").Group("p.id").Count(&total).Offset(offset).Limit(limit).Find(&patients).Error
|
|
82
|
+ if orgID != 10579 {
|
|
83
|
+ err = db.Order("p.id desc").Select(" p.id, p.user_org_id, p.user_id, p.patient_type, p.dialysis_no, p.admission_number, p.source, p.lapseto, p.partition_id, p.bed_id, p.name, p.alias, p.gender, p.marital_status, p.id_card_no, p.birthday, p.reimbursement_way_id, p.health_care_type, p.health_care_no, p.health_care_due_date, p.height, p.blood_type, p.rh, p.health_care_due_alert_date, p.education_level, p.profession, p.phone, p.home_telephone, p.relative_phone, p.relative_relations, p.home_address, p.work_unit, p.unit_address, p.children, p.receiving_date, p.is_hospital_first_dialysis, p.first_dialysis_date, p.first_dialysis_hospital, p.induction_period, p.initial_dialysis, p.total_dialysis, p.attending_doctor_id, p.head_nurse_id, p.evaluate, p.diagnose, p.remark, p.registrars_id, p.registrars, p.qr_code, p.binding_state, p.status, p.created_time, p.updated_time,p.user_sys_before_count,p.out_reason,p.death_time,p.is_infectious").Group("p.id").Count(&total).Offset(offset).Limit(limit).Find(&patients).Error
|
|
84
|
+ }
|
|
85
|
+
|
|
86
|
+ if orgID == 10579 {
|
|
87
|
+ err = db.Order("p.dialysis_no asc").Select(" p.id, p.user_org_id, p.user_id, p.patient_type, p.dialysis_no, p.admission_number, p.source, p.lapseto, p.partition_id, p.bed_id, p.name, p.alias, p.gender, p.marital_status, p.id_card_no, p.birthday, p.reimbursement_way_id, p.health_care_type, p.health_care_no, p.health_care_due_date, p.height, p.blood_type, p.rh, p.health_care_due_alert_date, p.education_level, p.profession, p.phone, p.home_telephone, p.relative_phone, p.relative_relations, p.home_address, p.work_unit, p.unit_address, p.children, p.receiving_date, p.is_hospital_first_dialysis, p.first_dialysis_date, p.first_dialysis_hospital, p.induction_period, p.initial_dialysis, p.total_dialysis, p.attending_doctor_id, p.head_nurse_id, p.evaluate, p.diagnose, p.remark, p.registrars_id, p.registrars, p.qr_code, p.binding_state, p.status, p.created_time, p.updated_time,p.user_sys_before_count,p.out_reason,p.death_time,p.is_infectious").Group("p.id").Count(&total).Offset(offset).Limit(limit).Find(&patients).Error
|
|
88
|
+ }
|
79
|
89
|
|
80
|
90
|
}
|
81
|
91
|
|
|
@@ -2925,17 +2935,30 @@ func UpdateDialysisBefor(dislysis models.XtAssessmentBeforeDislysis, id int64) e
|
2925
|
2935
|
|
2926
|
2936
|
func GetAllSchedulesByPatientInfo(org_id int64, patient_id int64, mode_id int64) ([]Schedule, error) {
|
2927
|
2937
|
var record []Schedule
|
2928
|
|
- loc, _ := time.LoadLocation("Local")
|
2929
|
|
- date, _ := time.ParseInLocation("2006-01-02 15:04:05", time.Now().Format("2006-01-02")+" 00:00:00", loc)
|
2930
|
|
-
|
2931
|
|
- err := readDb.Model(&Schedule{}).Where("status = 1 AND schedule_date >= ? AND patient_id = ? AND user_org_id = ? AND mode_id= ?", date, patient_id, org_id, mode_id).Find(&record).Error
|
2932
|
|
- if err != nil {
|
2933
|
|
- if err == gorm.ErrRecordNotFound {
|
2934
|
|
- return nil, nil
|
2935
|
|
- } else {
|
2936
|
|
- return nil, err
|
|
2938
|
+ if org_id == 10597 {
|
|
2939
|
+ timeNowStr := time.Now().Format("2006-01-02")
|
|
2940
|
+ timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
|
|
2941
|
+ err := readDb.Model(&Schedule{}).Where("status = 1 AND schedule_date >? AND patient_id = ? AND user_org_id = ? AND mode_id= ?", timeNewDate.Unix(), patient_id, org_id, mode_id).Find(&record).Error
|
|
2942
|
+ if err != nil {
|
|
2943
|
+ if err == gorm.ErrRecordNotFound {
|
|
2944
|
+ return nil, nil
|
|
2945
|
+ } else {
|
|
2946
|
+ return nil, err
|
|
2947
|
+ }
|
|
2948
|
+ }
|
|
2949
|
+ } else {
|
|
2950
|
+ timeNowStr := time.Now().Format("2006-01-02")
|
|
2951
|
+ timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
|
|
2952
|
+ err := readDb.Model(&Schedule{}).Where("status = 1 AND schedule_date >= ? AND patient_id = ? AND user_org_id = ? AND mode_id= ?", timeNewDate.Unix(), patient_id, org_id, mode_id).Find(&record).Error
|
|
2953
|
+ if err != nil {
|
|
2954
|
+ if err == gorm.ErrRecordNotFound {
|
|
2955
|
+ return nil, nil
|
|
2956
|
+ } else {
|
|
2957
|
+ return nil, err
|
|
2958
|
+ }
|
2937
|
2959
|
}
|
2938
|
2960
|
}
|
|
2961
|
+
|
2939
|
2962
|
return record, nil
|
2940
|
2963
|
}
|
2941
|
2964
|
|
|
@@ -3285,3 +3308,10 @@ func GetPatientDetailInformedConsent(patient_id int64, org_id int64) (models.XtP
|
3285
|
3308
|
err := XTReadDB().Where("id = ? and status=1 and user_org_id =?", patient_id, org_id).Find(&patients).Error
|
3286
|
3309
|
return patients, err
|
3287
|
3310
|
}
|
|
3311
|
+
|
|
3312
|
+func GetAllPrescriptionList(org_id int64) (prescription []*models.DialysisPrescription, err error) {
|
|
3313
|
+
|
|
3314
|
+ err = XTReadDB().Where("user_org_id = ? and status =1", org_id).Find(&prescription).Error
|
|
3315
|
+
|
|
3316
|
+ return prescription, err
|
|
3317
|
+}
|