XMLWAN 4 years ago
parent
commit
4ce41288ee

+ 36 - 40
controllers/new_mobile_api_controllers/common_api_controller.go View File

89
 	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
89
 	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
90
 	fmt.Println("err", err)
90
 	fmt.Println("err", err)
91
 	inspectionmajor := int64(dataBody["inspectionMajor"].(float64))
91
 	inspectionmajor := int64(dataBody["inspectionMajor"].(float64))
92
-	fmt.Println("大项", inspectionmajor)
92
+	//fmt.Println("大项", inspectionmajor)
93
 	inspectionMinor := int64(dataBody["inspectionMinor"].(float64))
93
 	inspectionMinor := int64(dataBody["inspectionMinor"].(float64))
94
-	fmt.Println("小项", inspectionMinor)
94
+	//fmt.Println("小项", inspectionMinor)
95
 	minrange := dataBody["min_range"].(string)
95
 	minrange := dataBody["min_range"].(string)
96
-	fmt.Println("minragne", minrange)
96
+	//fmt.Println("minragne", minrange)
97
 	largerange := dataBody["large_range"].(string)
97
 	largerange := dataBody["large_range"].(string)
98
 	fmt.Println("largerange", largerange)
98
 	fmt.Println("largerange", largerange)
99
 	sort := dataBody["sort"].(string)
99
 	sort := dataBody["sort"].(string)
100
 	sorts, err := strconv.ParseInt(sort, 10, 64)
100
 	sorts, err := strconv.ParseInt(sort, 10, 64)
101
-	fmt.Println("sort", sort)
101
+	//fmt.Println("sort", sort)
102
 	checktype := int64(dataBody["check_type"].(float64))
102
 	checktype := int64(dataBody["check_type"].(float64))
103
-	fmt.Println("检查类型", checktype)
103
+	//fmt.Println("检查类型", checktype)
104
 	rangvalue := dataBody["range_value"].(string)
104
 	rangvalue := dataBody["range_value"].(string)
105
-	fmt.Println("rangvalue", rangvalue)
105
+	//fmt.Println("rangvalue", rangvalue)
106
 	if rangvalue == "0" {
106
 	if rangvalue == "0" {
107
 		rangvalue = ""
107
 		rangvalue = ""
108
 	}
108
 	}
154
 
154
 
155
 func (this *CommonApiController) GetConfigurationDetail() {
155
 func (this *CommonApiController) GetConfigurationDetail() {
156
 	id, _ := this.GetInt64("id")
156
 	id, _ := this.GetInt64("id")
157
-	fmt.Println("id是", id)
157
+	//fmt.Println("id是", id)
158
 	detail, err := service.GetConfigurationDetail(id)
158
 	detail, err := service.GetConfigurationDetail(id)
159
 	if err != nil {
159
 	if err != nil {
160
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
160
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
179
 
179
 
180
 func (this *CommonApiController) UpdateConfiguration() {
180
 func (this *CommonApiController) UpdateConfiguration() {
181
 	id, _ := this.GetInt64("id")
181
 	id, _ := this.GetInt64("id")
182
-	fmt.Println("id", id)
182
+	//fmt.Println("id", id)
183
 	dataBody := make(map[string]interface{}, 0)
183
 	dataBody := make(map[string]interface{}, 0)
184
 	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
184
 	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
185
-	fmt.Println("err", err)
185
+	//fmt.Println("err", err)
186
 	inspectionmajor := int64(dataBody["inspectionMajor"].(float64))
186
 	inspectionmajor := int64(dataBody["inspectionMajor"].(float64))
187
-	fmt.Println("大项", inspectionmajor)
187
+	//fmt.Println("大项", inspectionmajor)
188
 	inspectionMinor := int64(dataBody["inspectionMinor"].(float64))
188
 	inspectionMinor := int64(dataBody["inspectionMinor"].(float64))
189
-	fmt.Println("小项", inspectionMinor)
189
+	//fmt.Println("小项", inspectionMinor)
190
 	minrange := dataBody["min_range"].(string)
190
 	minrange := dataBody["min_range"].(string)
191
-	fmt.Println("minragne", minrange)
191
+	//fmt.Println("minragne", minrange)
192
 	largerange := dataBody["large_range"].(string)
192
 	largerange := dataBody["large_range"].(string)
193
-	fmt.Println("largerange", largerange)
193
+	//fmt.Println("largerange", largerange)
194
 	sort := int64(dataBody["sort"].(float64))
194
 	sort := int64(dataBody["sort"].(float64))
195
-	fmt.Println("排序", sort)
195
+	//fmt.Println("排序", sort)
196
 	rangvalue := dataBody["range_value"].(string)
196
 	rangvalue := dataBody["range_value"].(string)
197
-	fmt.Println("范围", rangvalue)
197
+	//fmt.Println("范围", rangvalue)
198
 	if rangvalue == "0" {
198
 	if rangvalue == "0" {
199
 		rangvalue = ""
199
 		rangvalue = ""
200
 	}
200
 	}
279
 	adminUser := this.GetAdminUserInfo()
279
 	adminUser := this.GetAdminUserInfo()
280
 	orgid := adminUser.CurrentOrgId
280
 	orgid := adminUser.CurrentOrgId
281
 	inspectionmajor := int64(dataBody["inspectionMajor"].(float64))
281
 	inspectionmajor := int64(dataBody["inspectionMajor"].(float64))
282
-	fmt.Println("大项", inspectionmajor)
282
+	//fmt.Println("大项", inspectionmajor)
283
 	frequency := dataBody["frequency"].(string)
283
 	frequency := dataBody["frequency"].(string)
284
-	fmt.Println("凭次", frequency)
284
+	//fmt.Println("凭次", frequency)
285
 	sort := dataBody["sort"].(string)
285
 	sort := dataBody["sort"].(string)
286
 	sorts, err := strconv.ParseInt(sort, 10, 64)
286
 	sorts, err := strconv.ParseInt(sort, 10, 64)
287
-	fmt.Println("sort", sort)
287
+	//fmt.Println("sort", sort)
288
 	_, errcode := service.GetInspectionMajorById(inspectionmajor, orgid)
288
 	_, errcode := service.GetInspectionMajorById(inspectionmajor, orgid)
289
 	if errcode == gorm.ErrRecordNotFound {
289
 	if errcode == gorm.ErrRecordNotFound {
290
 		configuration := models.XtCheckConfiguration{
290
 		configuration := models.XtCheckConfiguration{
312
 func (this *CommonApiController) GetAllCheckList() {
312
 func (this *CommonApiController) GetAllCheckList() {
313
 	adminUser := this.GetAdminUserInfo()
313
 	adminUser := this.GetAdminUserInfo()
314
 	orgid := adminUser.CurrentOrgId
314
 	orgid := adminUser.CurrentOrgId
315
-	fmt.Println("org", orgid)
315
+	//fmt.Println("org", orgid)
316
 	page, _ := this.GetInt64("page")
316
 	page, _ := this.GetInt64("page")
317
 	limit, _ := this.GetInt64("limit")
317
 	limit, _ := this.GetInt64("limit")
318
 	checkList, total, err := service.GetAllCheckList(orgid, page, limit)
318
 	checkList, total, err := service.GetAllCheckList(orgid, page, limit)
346
 	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
346
 	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
347
 	fmt.Println(err)
347
 	fmt.Println(err)
348
 	inspectionmajor := int64(dataBody["inspectionMajor"].(float64))
348
 	inspectionmajor := int64(dataBody["inspectionMajor"].(float64))
349
-	fmt.Println("大项", inspectionmajor)
349
+	//fmt.Println("大项", inspectionmajor)
350
 	frequency := dataBody["frequency"].(string)
350
 	frequency := dataBody["frequency"].(string)
351
-	fmt.Println("凭次", frequency)
351
+	//fmt.Println("凭次", frequency)
352
 	sort := int64(dataBody["sort"].(float64))
352
 	sort := int64(dataBody["sort"].(float64))
353
-	fmt.Println("sort", sort)
353
+	//fmt.Println("sort", sort)
354
 	adminInfo := this.GetAdminUserInfo()
354
 	adminInfo := this.GetAdminUserInfo()
355
 	orgId := adminInfo.CurrentOrgId
355
 	orgId := adminInfo.CurrentOrgId
356
 	Inspection, err := service.GetInspectionMajorByIdTwo(inspectionmajor, orgId)
356
 	Inspection, err := service.GetInspectionMajorByIdTwo(inspectionmajor, orgId)
393
 	loc, _ := time.LoadLocation("Local")
393
 	loc, _ := time.LoadLocation("Local")
394
 	startime := this.GetString("startime")
394
 	startime := this.GetString("startime")
395
 	endtime := this.GetString("endtime")
395
 	endtime := this.GetString("endtime")
396
-	fmt.Println("endtime", endtime)
396
+	//fmt.Println("endtime", endtime)
397
 	startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", startime+" 00:00:00", loc)
397
 	startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", startime+" 00:00:00", loc)
398
 	startimes := startTimes.Unix()
398
 	startimes := startTimes.Unix()
399
 	// fmt.Println("startime",startimes)
399
 	// fmt.Println("startime",startimes)
424
 	startime := this.GetString("startime")
424
 	startime := this.GetString("startime")
425
 	startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", startime+" 00:00:00", loc)
425
 	startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", startime+" 00:00:00", loc)
426
 	startnunix := startTimes.Unix()
426
 	startnunix := startTimes.Unix()
427
-	//fmt.Println("开始时间==========",startnunix)
427
+	fmt.Println("开始时间---------------", startnunix)
428
 	endtime := this.GetString("endtime")
428
 	endtime := this.GetString("endtime")
429
 	endtimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", endtime+" 23:59:59", loc)
429
 	endtimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", endtime+" 23:59:59", loc)
430
 	endunix := endtimes.Unix()
430
 	endunix := endtimes.Unix()
431
-	//fmt.Println("结束日期========",endunix)
432
-	//统计一个月内转出的病人
433
-	//patients, total, err := service.GetTotalRollOut(startime, endtime, orgid)
431
+	fmt.Println("endunix==========", endunix)
434
 	//统计该机构的转出人数
432
 	//统计该机构的转出人数
435
 	patients, err := service.GetTotalRollOutPatients(orgid, startnunix, endunix)
433
 	patients, err := service.GetTotalRollOutPatients(orgid, startnunix, endunix)
436
 	//统计该机构转出病人
434
 	//统计该机构转出病人
437
 	patienttwo, err := service.GetTotalRollOutPatientsTwo(orgid, startnunix, endunix)
435
 	patienttwo, err := service.GetTotalRollOutPatientsTwo(orgid, startnunix, endunix)
438
-	//统计总共病人
439
-	//	_, count, _ := service.GetPatientTotalCountTwo(orgid, startime, endtime)
440
 	count := service.GetPatientTotalCount(orgid)
436
 	count := service.GetPatientTotalCount(orgid)
441
 	if err != nil {
437
 	if err != nil {
442
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
438
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
682
 	endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
678
 	endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
683
 
679
 
684
 	entime := endDate.Unix()
680
 	entime := endDate.Unix()
685
-	fmt.Println("开始时间", statime)
686
-	fmt.Println(endtime)
681
+	//fmt.Println("开始时间", statime)
682
+	//fmt.Println(endtime)
687
 	limit, _ := this.GetInt64("limit")
683
 	limit, _ := this.GetInt64("limit")
688
-	fmt.Println("limit", limit)
684
+	//fmt.Println("limit", limit)
689
 	page, _ := this.GetInt64("page")
685
 	page, _ := this.GetInt64("page")
690
-	fmt.Println("page", page)
686
+	//fmt.Println("page", page)
691
 	patient, total, err := service.GetPrescritionByName(orgId, patientid, statime, entime, limit, page)
687
 	patient, total, err := service.GetPrescritionByName(orgId, patientid, statime, entime, limit, page)
692
 	if err != nil {
688
 	if err != nil {
693
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
689
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
702
 func (this *CommonApiController) GetStatistics() {
698
 func (this *CommonApiController) GetStatistics() {
703
 	adminUser := this.GetAdminUserInfo()
699
 	adminUser := this.GetAdminUserInfo()
704
 	orgId := adminUser.CurrentOrgId
700
 	orgId := adminUser.CurrentOrgId
705
-	fmt.Println("orgid", orgId)
701
+	//fmt.Println("orgid", orgId)
706
 	startime := this.GetString("start_time")
702
 	startime := this.GetString("start_time")
707
-	fmt.Println(startime)
703
+	//fmt.Println(startime)
708
 	endtime := this.GetString("end_time")
704
 	endtime := this.GetString("end_time")
709
 	startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
705
 	startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
710
 	fmt.Println("parseDateErr", parseDateErr)
706
 	fmt.Println("parseDateErr", parseDateErr)
711
 	statime := startDate.Unix()
707
 	statime := startDate.Unix()
712
-	fmt.Println("开始时间", statime)
708
+	//fmt.Println("开始时间", statime)
713
 	endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
709
 	endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
714
 	entime := endDate.Unix()
710
 	entime := endDate.Unix()
715
-	fmt.Println("结束日期", entime)
711
+	//fmt.Println("结束日期", entime)
716
 	value, _ := this.GetInt64("value")
712
 	value, _ := this.GetInt64("value")
717
-	fmt.Println("value", value)
713
+	//fmt.Println("value", value)
718
 	limit, _ := this.GetInt64("limit")
714
 	limit, _ := this.GetInt64("limit")
719
-	fmt.Println("limit", limit)
715
+	//fmt.Println("limit", limit)
720
 	page, _ := this.GetInt64("page")
716
 	page, _ := this.GetInt64("page")
721
-	fmt.Println("page", page)
717
+	//fmt.Println("page", page)
722
 	modeId, _ := this.GetInt64("mode_id")
718
 	modeId, _ := this.GetInt64("mode_id")
723
 	treatinfo, total, err := service.GetTreateInfo(orgId, statime, entime, value, limit, page)
719
 	treatinfo, total, err := service.GetTreateInfo(orgId, statime, entime, value, limit, page)
724
 	statistics, ttd, _ := service.GetStatistics(orgId, statime, entime, modeId)
720
 	statistics, ttd, _ := service.GetStatistics(orgId, statime, entime, modeId)

+ 5 - 5
service/common_service.go View File

188
 func GetTotalRollOutPatients(orgid int64, startime int64, endtime int64) (patients []*models.XtPatients, err error) {
188
 func GetTotalRollOutPatients(orgid int64, startime int64, endtime int64) (patients []*models.XtPatients, err error) {
189
 
189
 
190
 	db := XTReadDB().Table("x.patients as x")
190
 	db := XTReadDB().Table("x.patients as x")
191
-	err = db.Raw("select x.id,x.`name`,s.lapseto_type,s.lapseto_time from xt_patients as x left join xt_patient_lapseto AS s ON s.patient_id = x.id where s.lapseto_time >=? and s.lapseto_time <=? and x.user_org_id = ? and s.lapseto_type = 1 and x.status = 1 group by s.patient_id", startime, endtime, orgid).Scan(&patients).Error
191
+	err = db.Raw("select x.id,x.`name`,s.lapseto_type,s.lapseto_time from xt_patients as x left join xt_patient_lapseto AS s ON s.patient_id = x.id where s.lapseto_time >=? and s.lapseto_time <=? and x.user_org_id = ? and s.lapseto_type = 1 and x.status = 1", startime, endtime, orgid).Scan(&patients).Error
192
 	return patients, err
192
 	return patients, err
193
 }
193
 }
194
 
194
 
195
 func GetTotalRollOutPatientsTwo(orgid int64, startime int64, endtime int64) (patients []*models.XtPatients, err error) {
195
 func GetTotalRollOutPatientsTwo(orgid int64, startime int64, endtime int64) (patients []*models.XtPatients, err error) {
196
 
196
 
197
 	db := XTReadDB().Table("x.patients as x")
197
 	db := XTReadDB().Table("x.patients as x")
198
-	err = db.Raw("select x.id,x.`name`,s.lapseto_type,s.lapseto_time from xt_patients as x left join xt_patient_lapseto AS s ON s.patient_id = x.id where s.lapseto_time >=? and s.lapseto_time <=? and x.user_org_id = ? and s.lapseto_type = 2 and x.status = 1 group by s.patient_id", startime, endtime, orgid).Scan(&patients).Error
198
+	err = db.Raw("select x.id,x.`name`,s.lapseto_type,s.lapseto_time from xt_patients as x left join xt_patient_lapseto AS s ON s.patient_id = x.id where s.lapseto_time >=? and s.lapseto_time <=? and x.user_org_id = ? and s.lapseto_type = 2 and x.status = 1", startime, endtime, orgid).Scan(&patients).Error
199
 	return patients, err
199
 	return patients, err
200
 }
200
 }
201
 
201
 
233
 
233
 
234
 func GetPatientInfectiousCount(orgid int64, startime int64, endtime int64) (counts []*models.PatientContagionsCountStruct, err error) {
234
 func GetPatientInfectiousCount(orgid int64, startime int64, endtime int64) (counts []*models.PatientContagionsCountStruct, err error) {
235
 
235
 
236
-	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
236
+	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 x.status = 1 and x.updated_time>=? and x.updated_time<=?", orgid, startime, endtime).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
237
 	return counts, err
237
 	return counts, err
238
 }
238
 }
239
 
239
 
1159
 			" WHEN x.inspect_date>=? AND  x.inspect_date<=? AND x.inspect_value = r.range_value THEN '第三季度'" +
1159
 			" WHEN x.inspect_date>=? AND  x.inspect_date<=? AND x.inspect_value = r.range_value THEN '第三季度'" +
1160
 			" WHEN x.inspect_date>=? AND  x.inspect_date<=? AND x.inspect_value = r.range_value THEN '第四季度'" +
1160
 			" WHEN x.inspect_date>=? AND  x.inspect_date<=? AND x.inspect_value = r.range_value THEN '第四季度'" +
1161
 			" ELSE '其他'" +
1161
 			" ELSE '其他'" +
1162
-			"END AS nnd FROM xt_inspection as x  left join xt_quality_control_standard as  r on (r.inspection_minor = x.item_id AND r.user_org_id > 0) OR ( x.item_id = r.inspection_minor AND r.user_org_id = 0) left join xt_patients as s on s.id = x.patient_id  WHERE x.status=1 and (s.lapseto = 1 or s.lapseto = 2) and (x.inspect_value = r.range_value)"
1162
+			"END AS nnd FROM xt_inspection as x  left join xt_quality_control_standard as  r on (r.inspection_minor = x.item_id AND r.user_org_id > 0) OR ( x.item_id = r.inspection_minor AND r.user_org_id = 0) left join xt_patients as s on s.id = x.patient_id  WHERE x.status=1 and (s.lapseto = 1 or s.lapseto = 2) and (x.inspect_value = r.range_value) and r.status = 1"
1163
 		countParams := make([]interface{}, 0)
1163
 		countParams := make([]interface{}, 0)
1164
 		countParams = append(countParams, firststart)
1164
 		countParams = append(countParams, firststart)
1165
 		countParams = append(countParams, firstend)
1165
 		countParams = append(countParams, firstend)
1217
 			" WHEN x.inspect_date>=? AND  x.inspect_date<=? AND x.inspect_value = r.range_value THEN '第三季度'" +
1217
 			" WHEN x.inspect_date>=? AND  x.inspect_date<=? AND x.inspect_value = r.range_value THEN '第三季度'" +
1218
 			" WHEN x.inspect_date>=? AND  x.inspect_date<=? AND x.inspect_value = r.range_value THEN '第四季度'" +
1218
 			" WHEN x.inspect_date>=? AND  x.inspect_date<=? AND x.inspect_value = r.range_value THEN '第四季度'" +
1219
 			" ELSE '其他'" +
1219
 			" ELSE '其他'" +
1220
-			"END AS nnd FROM xt_inspection as x  left join xt_quality_control_standard as  r on (r.inspection_minor = x.item_id AND r.user_org_id > 0) OR ( x.item_id = r.inspection_minor AND r.user_org_id = 0) left join xt_patients as s on s.id = x.patient_id  WHERE x.status=1 and (s.lapseto = 2) and (x.inspect_value = r.range_value)"
1220
+			"END AS nnd FROM xt_inspection as x  left join xt_quality_control_standard as  r on (r.inspection_minor = x.item_id AND r.user_org_id > 0) OR ( x.item_id = r.inspection_minor AND r.user_org_id = 0) left join xt_patients as s on s.id = x.patient_id  WHERE x.status=1 and (s.lapseto = 2) and (x.inspect_value = r.range_value) and r.status = 1"
1221
 		countParams := make([]interface{}, 0)
1221
 		countParams := make([]interface{}, 0)
1222
 		countParams = append(countParams, firststart)
1222
 		countParams = append(countParams, firststart)
1223
 		countParams = append(countParams, firstend)
1223
 		countParams = append(countParams, firstend)