|
@@ -2,54 +2,150 @@ package service
|
2
|
2
|
|
3
|
3
|
import (
|
4
|
4
|
"XT_Admin_Api/models/function_models"
|
|
5
|
+ "fmt"
|
5
|
6
|
)
|
6
|
7
|
|
7
|
|
-func GetTodayInfo(to int64,ctime int64,page int64,limit int64)(patients []function_models.XtPatients,total int64,err error) {
|
8
|
|
- db := readDb.Table("xt_patients as p").Where("p.status = 1")
|
|
8
|
+//病人管理
|
|
9
|
+func GetTodayInfo(to int64,ctime int64,page int64,limit int64)(patientinfo []function_models.PatientInfo,total int64,err error) {
|
|
10
|
+
|
|
11
|
+ offset := (page - 1) * limit
|
|
12
|
+ err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u join sgj_xt.xt_patients as x on x.user_org_id = u.id where x.created_time >= ? AND x.created_time <= ?",to,ctime).Scan(&patientinfo).Error
|
|
13
|
+ rows, err := readUserDb.Offset(offset).Limit(limit).Raw("select Count(1) from sgj_users.sgj_user_org as u join sgj_xt.xt_patients as x on x.user_org_id = u.id where x.created_time >= ? AND x.created_time <= ?", to, ctime).Rows()
|
|
14
|
+ fmt.Println("rows是什么",rows)
|
|
15
|
+ if rows.Next() {
|
|
16
|
+ rows.Scan(&total)
|
|
17
|
+ }
|
|
18
|
+ fmt.Println("&total是什么",total)
|
|
19
|
+ return patientinfo,total,err
|
|
20
|
+}
|
|
21
|
+
|
|
22
|
+ //透析处方
|
|
23
|
+func GetTodayDialysisPatientsInfo(to int64,ctime int64,page int64,limit int64)(patientinfo []function_models.PatientInfo,total int64,err error) {
|
|
24
|
+
|
|
25
|
+ offset := (page - 1) * limit
|
|
26
|
+ err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u join sgj_xt.xt_dialysis_prescription as x on x.user_org_id = u.id JOIN sgj_xt.xt_patients as p On p.id = x.patient_id where x.created_time >= ? AND x.created_time <= ?",to,ctime).Scan(&patientinfo).Error
|
|
27
|
+ rows, err := readUserDb.Offset(offset).Limit(limit).Raw("select Count(1) from sgj_users.sgj_user_org as u join sgj_xt.xt_dialysis_prescription as x on x.user_org_id = u.id where x.created_time >= ? AND x.created_time <= ?", to, ctime).Rows()
|
|
28
|
+ if rows.Next() {
|
|
29
|
+ rows.Scan(&total)
|
|
30
|
+ }
|
|
31
|
+
|
|
32
|
+ return patientinfo,total,err
|
|
33
|
+}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+ //接诊评估
|
|
37
|
+func GetTodayReceivePatientsInfo(to int64,ctime int64,page int64,limit int64)(patientinfo []function_models.PatientInfo,total int64,err error) {
|
|
38
|
+
|
|
39
|
+ offset := (page - 1) * limit
|
|
40
|
+ err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u join sgj_xt.xt_receive_treatment_asses as x on x.user_org_id = u.id JOIN sgj_xt.xt_patients as p On p.id = x.patient_id where x.created_time >= ? AND x.created_time <= ?",to,ctime).Scan(&patientinfo).Error
|
|
41
|
+ rows, err := readUserDb.Offset(offset).Limit(limit).Raw("select Count(1) from sgj_users.sgj_user_org as u join sgj_xt.xt_receive_treatment_asses as x on x.user_org_id = u.id where x.created_time >= ? AND x.created_time <= ?", to, ctime).Rows()
|
|
42
|
+ if rows.Next() {
|
|
43
|
+ rows.Scan(&total)
|
|
44
|
+ }
|
|
45
|
+
|
|
46
|
+ return patientinfo,total,err
|
|
47
|
+}
|
|
48
|
+// 透前评估
|
|
49
|
+func GetTodayBeforDislysisInfo(to int64,ctime int64,page int64,limit int64)(patientinfo []function_models.PatientInfo,total int64,err error) {
|
|
50
|
+ offset := (page - 1) * limit
|
|
51
|
+ err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u join sgj_xt.xt_assessment_before_dislysis as x on x.user_org_id = u.id JOIN sgj_xt.xt_patients as p On p.id = x.patient_id where x.created_time >= ? AND x.created_time <= ?",to,ctime).Scan(&patientinfo).Error
|
|
52
|
+ rows, err := readUserDb.Offset(offset).Limit(limit).Raw("select Count(1) from sgj_users.sgj_user_org as u join sgj_xt.xt_assessment_before_dislysis as x on x.user_org_id = u.id where x.created_time >= ? AND x.created_time <= ?", to, ctime).Rows()
|
|
53
|
+ if rows.Next() {
|
|
54
|
+ rows.Scan(&total)
|
|
55
|
+ }
|
|
56
|
+
|
|
57
|
+ return patientinfo,total,err
|
|
58
|
+}
|
|
59
|
+
|
|
60
|
+ //零食医嘱
|
|
61
|
+func GetTodayDoctorsOrderInfo(to int64,ctime int64,page int64,limit int64)(patientinfo []function_models.PatientInfo,total int64,err error) {
|
|
62
|
+
|
|
63
|
+
|
9
|
64
|
offset := (page - 1) * limit
|
10
|
|
- err = db.Where("status <> 0 AND created_time >= ? AND created_time <= ?", to, ctime).
|
11
|
|
- Count(&total).Order("p.created_time desc").Offset(offset).Limit(limit).
|
12
|
|
- 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").
|
13
|
|
- Find(&patients).Error
|
14
|
|
- return patients,total,err
|
|
65
|
+ err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u join sgj_xt.xt_doctor_advice as x on x.user_org_id = u.id JOIN sgj_xt.xt_patients as p On p.id = x.patient_id where x.created_time >= ? AND x.created_time <= ?",to,ctime).Scan(&patientinfo).Error
|
|
66
|
+ rows, err := readUserDb.Offset(offset).Limit(limit).Raw("select Count(1) from sgj_users.sgj_user_org as u join sgj_xt.xt_doctor_advice as x on x.user_org_id = u.id where x.created_time >= ? AND x.created_time <= ?", to, ctime).Rows()
|
|
67
|
+ if rows.Next() {
|
|
68
|
+ rows.Scan(&total)
|
|
69
|
+ }
|
|
70
|
+
|
|
71
|
+ return patientinfo,total,err
|
15
|
72
|
}
|
|
73
|
+//双人核对
|
|
74
|
+func GetTodayDoubleCheckInfo(to int64,ctime int64,page int64,limit int64)(patientinfo []function_models.PatientInfo,total int64,err error) {
|
16
|
75
|
|
17
|
|
-func GetTodayDialysisPatientsInfo(to int64,ctime int64,page int64,limit int64)(patients []function_models.XtPatients,total int64,err error) {
|
18
|
|
- db := readDb.Table("xt_patients as p").Where("p.status = 1")
|
19
|
76
|
offset := (page - 1) * limit
|
20
|
|
- err = db.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").
|
21
|
|
- Joins("join xt_dialysis_prescription as x On x.patient_id = p.id").Where("x.created_time >= ? AND x.created_time <= ?", to, ctime).Count(&total).Order("p.created_time desc").Offset(offset).Limit(limit).Find(&patients).Error
|
22
|
|
- return patients,total,err
|
|
77
|
+ err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u join sgj_xt.xt_double_check as x on x.user_org_id = u.id JOIN sgj_xt.xt_patients as p On p.id = x.patient_id where x.created_time >= ? AND x.created_time <= ?",to,ctime).Scan(&patientinfo).Error
|
|
78
|
+ rows, err := readUserDb.Offset(offset).Limit(limit).Raw("select Count(1) from sgj_users.sgj_user_org as u join sgj_xt.xt_double_check as x on x.user_org_id = u.id where x.created_time >= ? AND x.created_time <= ?", to, ctime).Rows()
|
|
79
|
+ if rows.Next() {
|
|
80
|
+ rows.Scan(&total)
|
|
81
|
+ }
|
|
82
|
+
|
|
83
|
+ return patientinfo,total,err
|
23
|
84
|
}
|
|
85
|
+//透析上机
|
|
86
|
+func GetTodayDialysisMachinek(to int64,ctime int64,page int64,limit int64)(patientinfo []function_models.PatientInfo,total int64,err error) {
|
24
|
87
|
|
25
|
|
-func GetTodayReceivePatientsInfo(to int64,ctime int64,page int64,limit int64)(patients []function_models.XtPatients,total int64,err error) {
|
26
|
|
- db := readDb.Table("xt_patients as p").Where("p.status = 1")
|
27
|
88
|
offset := (page - 1) * limit
|
28
|
|
- err = db.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").
|
29
|
|
- Joins("join xt_receive_treatment_asses as x On x.patient_id = p.id").Where("x.created_time >= ? AND x.created_time <= ?", to, ctime).Count(&total).Order("p.created_time desc").Offset(offset).Limit(limit).Find(&patients).Error
|
30
|
|
- return patients,total,err
|
|
89
|
+ err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u join sgj_xt.xt_dialysis_order as x on x.user_org_id = u.id JOIN sgj_xt.xt_patients as p On p.id = x.patient_id where x.created_time >= ? AND x.created_time <= ?",to,ctime).Scan(&patientinfo).Error
|
|
90
|
+ rows, err := readUserDb.Offset(offset).Limit(limit).Raw("select Count(1) from sgj_users.sgj_user_org as u join sgj_xt.xt_dialysis_order as x on x.user_org_id = u.id where x.created_time >= ? AND x.created_time <= ?", to, ctime).Rows()
|
|
91
|
+ if rows.Next() {
|
|
92
|
+ rows.Scan(&total)
|
|
93
|
+ }
|
|
94
|
+
|
|
95
|
+ return patientinfo,total,err
|
31
|
96
|
}
|
32
|
97
|
|
33
|
|
-func GetTodayDoctorsOrderInfo(to int64,ctime int64,page int64,limit int64)(patients []function_models.XtPatients,total int64,err error) {
|
34
|
|
- db := readDb.Table("xt_patients as p").Where("p.status = 1")
|
|
98
|
+//透析检测
|
|
99
|
+func GetTodayDialysisExamination(to int64,ctime int64,page int64,limit int64)(patientinfo []function_models.PatientInfo,total int64,err error) {
|
|
100
|
+
|
35
|
101
|
offset := (page - 1) * limit
|
36
|
|
- err = db.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").
|
37
|
|
- Joins("join xt_doctor_advice as x On x.patient_id = p.id").Where("x.created_time >= ? AND x.created_time <= ?", to, ctime).Count(&total).Order("p.created_time desc").Offset(offset).Limit(limit).Find(&patients).Error
|
38
|
|
- return patients,total,err
|
|
102
|
+ err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u join sgj_xt.xt_monitoring_record as x on x.user_org_id = u.id JOIN sgj_xt.xt_patients as p On p.id = x.patient_id where x.created_time >= ? AND x.created_time <= ?",to,ctime).Scan(&patientinfo).Error
|
|
103
|
+ rows, err := readUserDb.Offset(offset).Limit(limit).Raw("select Count(1) from sgj_users.sgj_user_org as u join sgj_xt.xt_monitoring_record as x on x.user_org_id = u.id where x.created_time >= ? AND x.created_time <= ?", to, ctime).Rows()
|
|
104
|
+ if rows.Next() {
|
|
105
|
+ rows.Scan(&total)
|
|
106
|
+ }
|
|
107
|
+
|
|
108
|
+ return patientinfo,total,err
|
39
|
109
|
}
|
40
|
110
|
|
41
|
|
-func GetTodayDoubleCheckInfo(to int64,ctime int64,page int64,limit int64)(patients []function_models.XtPatients,total int64,err error) {
|
42
|
|
- db := readDb.Table("xt_patients as p").Where("p.status = 1")
|
|
111
|
+//透析下机
|
|
112
|
+func GetTodayBeforOrpenetration(to int64,ctime int64,page int64,limit int64)(patientinfo []function_models.PatientInfo,total int64,err error) {
|
|
113
|
+
|
43
|
114
|
offset := (page - 1) * limit
|
44
|
|
- err = db.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").
|
45
|
|
- Joins("join xt_double_check as x On x.patient_id = p.id").Where("x.created_time >= ? AND x.created_time <= ?", to, ctime).Count(&total).Order("p.created_time desc").Offset(offset).Limit(limit).Find(&patients).Error
|
46
|
|
- return patients,total,err
|
|
115
|
+ err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u join sgj_xt.xt_dialysis_order as x on x.user_org_id = u.id JOIN sgj_xt.xt_patients as p On p.id = x.patient_id where x.created_time >= ? AND x.created_time <= ?",to,ctime).Scan(&patientinfo).Error
|
|
116
|
+ rows, err := readUserDb.Offset(offset).Limit(limit).Raw("select Count(1) from sgj_users.sgj_user_org as u join sgj_xt.xt_dialysis_order as x on x.user_org_id = u.id where x.created_time >= ? AND x.created_time <= ?", to, ctime).Rows()
|
|
117
|
+ if rows.Next() {
|
|
118
|
+ rows.Scan(&total)
|
|
119
|
+ }
|
|
120
|
+
|
|
121
|
+ return patientinfo,total,err
|
47
|
122
|
}
|
48
|
123
|
|
49
|
|
-func GetTodayDialysisMachinek(to int64,ctime int64,page int64,limit int64)(patients []function_models.XtPatients,total int64,err error) {
|
50
|
|
- db := readDb.Table("xt_patients as p").Where("p.status = 1")
|
|
124
|
+//透后评估
|
|
125
|
+func GetTodayPostAssessment(to int64,ctime int64,page int64,limit int64)(patientinfo []function_models.PatientInfo,total int64,err error) {
|
51
|
126
|
offset := (page - 1) * limit
|
52
|
|
- err = db.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").
|
53
|
|
- Joins("join xt_double_check as x On x.patient_id = p.id").Where("x.created_time >= ? AND x.created_time <= ?", to, ctime).Count(&total).Order("p.created_time desc").Offset(offset).Limit(limit).Find(&patients).Error
|
54
|
|
- return patients,total,err
|
|
127
|
+ err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u join sgj_xt.xt_assessment_after_dislysis as x on x.user_org_id = u.id JOIN sgj_xt.xt_patients as p On p.id = x.patient_id where x.created_time >= ? AND x.created_time <= ?",to,ctime).Scan(&patientinfo).Error
|
|
128
|
+ rows, err := readUserDb.Offset(offset).Limit(limit).Raw("select Count(1) from sgj_users.sgj_user_org as u join sgj_xt.xt_assessment_after_dislysis as x on x.user_org_id = u.id where x.created_time >= ? AND x.created_time <= ?", to, ctime).Rows()
|
|
129
|
+ if rows.Next() {
|
|
130
|
+ rows.Scan(&total)
|
|
131
|
+ }
|
|
132
|
+
|
|
133
|
+ return patientinfo,total,err
|
55
|
134
|
}
|
|
135
|
+
|
|
136
|
+func GetTodayEntrylist(to int64,ctime int64,limit int64,page int64)(patientinfo []function_models.PatientInfo,total int64, err error) {
|
|
137
|
+ offset := (page - 1) * limit
|
|
138
|
+ err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u join sgj_xt.xt_warehouse as x on x.org_id = u.id JOIN sgj_xt.xt_patients as p On p.id = x.creater where x.warehousing_time >= ? AND x.warehousing_time<= ?",to,ctime).Scan(&patientinfo).Error
|
|
139
|
+ rows, err := readUserDb.Offset(offset).Limit(limit).Raw("select Count(1) from sgj_users.sgj_user_org as u join sgj_xt.xt_warehouse as x on x.org_id = u.id where x.warehousing_time >= ? AND x.warehousing_time <= ?", to, ctime).Rows()
|
|
140
|
+ if rows.Next() {
|
|
141
|
+ rows.Scan(&total)
|
|
142
|
+ }
|
|
143
|
+
|
|
144
|
+ return patientinfo,total,err
|
|
145
|
+}
|
|
146
|
+
|
|
147
|
+//func GetTodayLogout(apptype int64,oppratetype int64)(userorg []function_models.SgjUserOrg,err error) {
|
|
148
|
+//
|
|
149
|
+// err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u join sgj_users.sgj_user_admin_login_log as l on l.org_id = u.id where l.operate_type = ? AND l.app_type = ?", oppratetype, apptype).Scan(&userorg).Error
|
|
150
|
+// return userorg,err
|
|
151
|
+//}
|