|
|
|
|
13
|
return inspection, err
|
13
|
return inspection, err
|
14
|
}
|
14
|
}
|
15
|
|
15
|
|
16
|
-func GetInspectionMinor(projectid int64) (inspection []*models.XtInspectionReference, err error) {
|
|
|
|
|
16
|
+func GetInspectionMinor(projectid int64, orgid int64) (inspection []*models.XtInspectionReference, err error) {
|
17
|
|
17
|
|
18
|
- err = XTReadDB().Model(&inspection).Where("project_id = ? and status = 1", projectid).Find(&inspection).Error
|
|
|
|
|
18
|
+ err = XTReadDB().Model(&inspection).Where("project_id = ? and status = 1 and org_id = ?", projectid, orgid).Find(&inspection).Error
|
19
|
return inspection, err
|
19
|
return inspection, err
|
20
|
}
|
20
|
}
|
21
|
|
21
|
|
|
|
|
|
160
|
return err
|
160
|
return err
|
161
|
}
|
161
|
}
|
162
|
|
162
|
|
163
|
-func GetDialysiTotal(startime int64, endtime int64, orgid int64) (prescription []*models.DialysisPrescription, total int64, err error) {
|
|
|
164
|
- err = XTReadDB().Model(&prescription).Where("record_date >= ? and record_date<=? and user_org_id = ?", startime, endtime, orgid).Count(&total).Find(&prescription).Error
|
|
|
165
|
- return prescription, total, err
|
|
|
|
|
163
|
+func GetDialysiTotal(startime int64, endtime int64, orgid int64) (order []*models.DialysisOrder, total int64, err error) {
|
|
|
164
|
+ err = XTReadDB().Model(&order).Where("dialysis_date >= ? and dialysis_date<=? and user_org_id = ?", startime, endtime, orgid).Count(&total).Find(&order).Error
|
|
|
165
|
+ return order, total, err
|
|
|
166
|
+
|
166
|
}
|
167
|
}
|
167
|
|
168
|
|
168
|
func GetDialysisCountMode(starttime int64, endtime int64, orgid int64) (counts []*models.PatientPrescriptionCountStruct, err error) {
|
169
|
func GetDialysisCountMode(starttime int64, endtime int64, orgid int64) (counts []*models.PatientPrescriptionCountStruct, err error) {
|
169
|
- err = readDb.Table("xt_dialysis_prescription as p").Where("p.record_date>= ? and p.record_date<=? and p.user_org_id=?", starttime, endtime, orgid).Select("p.mode_id,count(p.mode_id) as count").Group("p.mode_id").Scan(&counts).Error
|
|
|
|
|
170
|
+ //err = readDb.Table("xt_dialysis_prescription as p").Where("p.record_date>= ? and p.record_date<=? and p.user_org_id=?", starttime, endtime, orgid).Select("p.mode_id,count(p.mode_id) as count").Group("p.mode_id").Scan(&counts).Error
|
|
|
171
|
+ //return counts, err
|
|
|
172
|
+
|
|
|
173
|
+ err = readDb.Table("xt_dialysis_order as o left join xt_schedule as s on s.patient_id = o.patient_id").Where("s.schedule_date = o.dialysis_date and o.dialysis_date>=? and o.dialysis_date<=? and o.user_org_id = ? and o.status = 1 and s.status = 1", starttime, endtime, orgid).Select("s.mode_id,count(s.mode_id) as count").Group("s.mode_id").Scan(&counts).Error
|
170
|
return counts, err
|
174
|
return counts, err
|
|
|
175
|
+
|
171
|
}
|
176
|
}
|
172
|
|
177
|
|
173
|
func GetTotalRollOut(starttime int64, endtime int64, orgid int64) (counts []*models.PatientLapseto, total int64, err error) {
|
178
|
func GetTotalRollOut(starttime int64, endtime int64, orgid int64) (counts []*models.PatientLapseto, total int64, err error) {
|
|
|
|
|
225
|
// return counts, err
|
230
|
// return counts, err
|
226
|
//}
|
231
|
//}
|
227
|
|
232
|
|
228
|
-func GetPatientInfectiousCount(orgid int64) (counts []*models.PatientContagionsCountStruct, err error) {
|
|
|
|
|
233
|
+func GetPatientInfectiousCount(orgid int64, startime int64, endtime int64) (counts []*models.PatientContagionsCountStruct, err error) {
|
229
|
|
234
|
|
230
|
- err = readDb.Table("xt_patients_infectious_diseases as x").Joins("join xt_patients as s on s.id = x.patient_id").Where("s.user_org_id = ? and s.status = 1 and s.is_infectious = 2", orgid).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
|
|
|
|
|
235
|
+ err = readDb.Table("xt_patients_infectious_diseases as x").Joins("join xt_patients as s on s.id = x.patient_id").Where("s.user_org_id = ? and s.status = 1 and s.is_infectious = 2 and s.created_time>=? and s.created_time<=?", orgid, startime, endtime).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
|
231
|
return counts, err
|
236
|
return counts, err
|
232
|
}
|
237
|
}
|
233
|
|
238
|
|
|
|
|
|
242
|
readDb.Raw(`SELECT nnd AS 'age',COUNT(*) AS 'count' FROM(
|
247
|
readDb.Raw(`SELECT nnd AS 'age',COUNT(*) AS 'count' FROM(
|
243
|
SELECT
|
248
|
SELECT
|
244
|
CASE
|
249
|
CASE
|
245
|
- WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + ( DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )<=20 THEN '20'
|
|
|
246
|
- WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + ( FROM_UNIXTIME(birthday, '%m%d') <= DATE_FORMAT(NOW(), '%m%d') )>20 AND (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + ( FROM_UNIXTIME(birthday, '%m%d') <= DATE_FORMAT(NOW(), '%m%d') )<=40 THEN '40'
|
|
|
247
|
- WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + ( FROM_UNIXTIME(birthday, '%m%d') <= DATE_FORMAT(NOW(), '%m%d') )>40 AND (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + ( FROM_UNIXTIME(birthday, '%m%d') <= DATE_FORMAT(NOW(), '%m%d') )<=60 THEN '60'
|
|
|
248
|
- WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + ( FROM_UNIXTIME(birthday, '%m%d') <= DATE_FORMAT(NOW(), '%m%d') )>60 AND (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + ( FROM_UNIXTIME(birthday, '%m%d') <= DATE_FORMAT(NOW(), '%m%d') )<=80 THEN '80'
|
|
|
249
|
- WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + ( FROM_UNIXTIME(birthday, '%m%d') <= DATE_FORMAT(NOW(), '%m%d') )>80 AND (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + ( FROM_UNIXTIME(birthday, '%m%d') <= DATE_FORMAT(NOW(), '%m%d') )<=150 THEN '150'
|
|
|
250
|
- ELSE '-1'
|
|
|
|
|
250
|
+ WHEN ( substring( now( ), 1, 4 ) - substring( id_card_no, 7, 4 ) ) - ( substring( id_card_no, 11, 4 ) - date_format( now( ), '%m%d' ) > 0 )<=20 THEN '20'
|
|
|
251
|
+ WHEN ( substring( now( ), 1, 4 ) - substring( id_card_no, 7, 4 ) ) - ( substring( id_card_no, 11, 4 ) - date_format( now( ), '%m%d' ) > 0 )<=40 THEN '40'
|
|
|
252
|
+ WHEN ( substring( now( ), 1, 4 ) - substring( id_card_no, 7, 4 ) ) - ( substring( id_card_no, 11, 4 ) - date_format( now( ), '%m%d' ) > 0 )<=60 THEN '60'
|
|
|
253
|
+ WHEN ( substring( now( ), 1, 4 ) - substring( id_card_no, 7, 4 ) ) - ( substring( id_card_no, 11, 4 ) - date_format( now( ), '%m%d' ) > 0 )<=80 THEN '80'
|
|
|
254
|
+ ELSE '150'
|
251
|
END
|
255
|
END
|
252
|
AS nnd FROM xt_patients as s where s.user_org_id=? and s.status=1
|
256
|
AS nnd FROM xt_patients as s where s.user_org_id=? and s.status=1
|
253
|
)a GROUP BY nnd`, orgid).Scan(&counts)
|
257
|
)a GROUP BY nnd`, orgid).Scan(&counts)
|
|
|
|
|
320
|
err = readDb.Raw(countSQL, countParams...).Scan(&counts).Error
|
324
|
err = readDb.Raw(countSQL, countParams...).Scan(&counts).Error
|
321
|
return
|
325
|
return
|
322
|
|
326
|
|
|
|
327
|
+ //readDb.Raw(`SELECT nnd AS 'age',COUNT(*) AS 'count' FROM(
|
|
|
328
|
+ // SELECT
|
|
|
329
|
+ // CASE
|
|
|
330
|
+ // WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) >= 0
|
|
|
331
|
+ // WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) <= 12 THEN '0~12' WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) > 12
|
|
|
332
|
+ // WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) <= 36 THEN '12~36' WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) > 36
|
|
|
333
|
+ // WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) <= 60 THEN '36~60' WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) > 60
|
|
|
334
|
+ // ELSE '150'
|
|
|
335
|
+ // END
|
|
|
336
|
+ // AS nnd FROM xt_patients as p where p.user_org_id=? and p.status=1
|
|
|
337
|
+ // )a GROUP BY nnd`, orgID).Scan(&counts)
|
|
|
338
|
+ //return
|
|
|
339
|
+
|
323
|
}
|
340
|
}
|
324
|
|
341
|
|
325
|
func GetCurentOrgPatients(orgid int64) (patients []*models.XtPatients, err error) {
|
342
|
func GetCurentOrgPatients(orgid int64) (patients []*models.XtPatients, err error) {
|