Преглед изворни кода

Merge branch 'xt_statistics_branch' of http://git.shengws.com/csx/XT_New into xt_statistics_branch

csx пре 4 година
родитељ
комит
53d84b3772

+ 4 - 4
controllers/base_api_controller.go Прегледај датотеку

@@ -79,7 +79,7 @@ func (this *BaseAuthAPIController) Prepare() {
79 79
 		userAdmin.ModifyTime = 1530786071
80 80
 		var subscibe models.ServeSubscibe
81 81
 		subscibe.ID = 1
82
-		subscibe.OrgId = 9841
82
+		subscibe.OrgId = 9726
83 83
 		subscibe.PeriodStart = 1538035409
84 84
 		subscibe.PeriodEnd = 1569571409
85 85
 		subscibe.State = 1
@@ -89,7 +89,7 @@ func (this *BaseAuthAPIController) Prepare() {
89 89
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
90 90
 		subscibes[4] = &subscibe
91 91
 		var adminUserInfo service.AdminUserInfo
92
-		adminUserInfo.CurrentOrgId = 9841
92
+		adminUserInfo.CurrentOrgId = 9726
93 93
 		adminUserInfo.CurrentAppId = 18
94 94
 		adminUserInfo.AdminUser = &userAdmin
95 95
 		adminUserInfo.Subscibes = subscibes
@@ -329,7 +329,7 @@ func (this *BaseServeAPIController) Prepare() {
329 329
 		userAdmin.ModifyTime = 1530786071
330 330
 		var subscibe models.ServeSubscibe
331 331
 		subscibe.ID = 1
332
-		subscibe.OrgId = 9841
332
+		subscibe.OrgId = 9726
333 333
 		subscibe.PeriodStart = 1538035409
334 334
 		subscibe.PeriodEnd = 1569571409
335 335
 		subscibe.State = 1
@@ -339,7 +339,7 @@ func (this *BaseServeAPIController) Prepare() {
339 339
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
340 340
 		subscibes[4] = &subscibe
341 341
 		var adminUserInfo service.AdminUserInfo
342
-		adminUserInfo.CurrentOrgId = 9841
342
+		adminUserInfo.CurrentOrgId = 9726
343 343
 		adminUserInfo.CurrentAppId = 18
344 344
 		adminUserInfo.AdminUser = &userAdmin
345 345
 		adminUserInfo.Subscibes = subscibes

+ 2 - 2
controllers/new_mobile_api_controllers/common_api_controller.go Прегледај датотеку

@@ -917,7 +917,7 @@ func (this *CommonApiController) GetFirstQuarter() {
917 917
 	startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
918 918
 	fmt.Println("parseDateErr", parseDateErr)
919 919
 	statime := startDate.Unix()
920
-	fmt.Println("开始时间", statime)
920
+	fmt.Println("开始时间=====================================", statime)
921 921
 	endtime := this.GetString("endtime")
922 922
 	fmt.Println("endtime", endtime)
923 923
 	endTimeYMDHmsStr := endtime + " 23:59:59"
@@ -1210,7 +1210,7 @@ func (this *CommonApiController) GetPatientscontrol() {
1210 1210
 	limit, _ := this.GetInt64("limit")
1211 1211
 	fmt.Println("limit", limit)
1212 1212
 	patients, total, err := service.GetPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix, page, limit)
1213
-
1213
+	fmt.Println("============================================================")
1214 1214
 	control, err := service.GetLastPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
1215 1215
 	//获取最后一次数据
1216 1216
 

+ 9 - 13
controllers/new_mobile_api_controllers/new_dialysis_api_controller.go Прегледај датотеку

@@ -1243,8 +1243,8 @@ func (this *NewDialysisApiController) UpdatedPatient() {
1243 1243
 	fmt.Print("透析号", dialysis)
1244 1244
 	patientsoure := int64(dataBody["patientsoure"].(float64))
1245 1245
 	fmt.Print("患者来源", patientsoure)
1246
-	lapseto := int64(dataBody["lapseto"].(float64))
1247
-	fmt.Print("留置状态", lapseto)
1246
+	//lapseto := int64(dataBody["lapseto"].(float64))
1247
+	//fmt.Print("留置状态", lapseto)
1248 1248
 	contagions := dataBody["resultTwo"].([]interface{})
1249 1249
 	fmt.Print("传染病", contagions)
1250 1250
 	ids := make([]int64, 0)
@@ -1347,7 +1347,6 @@ func (this *NewDialysisApiController) UpdatedPatient() {
1347 1347
 			Birthday:          birth,
1348 1348
 			Age:               ages,
1349 1349
 			Phone:             phone,
1350
-			Lapseto:           lapseto,
1351 1350
 			AdmissionNumber:   adminssionNumber,
1352 1351
 			FirstDialysisDate: fisttime,
1353 1352
 			Diagnose:          diagonse,
@@ -1361,12 +1360,12 @@ func (this *NewDialysisApiController) UpdatedPatient() {
1361 1360
 			IsInfectious:      is_infectious,
1362 1361
 		}
1363 1362
 		err = service.UpdatedPatient(patients, patient.BloodId)
1364
-		patientLapseto := models.PatientLapseto{
1365
-			LapsetoType: lapseto,
1366
-			LapsetoTime: time.Now().Unix(),
1367
-			UpdatedTime: time.Now().Unix(),
1368
-		}
1369
-		err = service.UpdatePatientLapseto(patient.BloodId, patientLapseto)
1363
+		//patientLapseto := models.PatientLapseto{
1364
+		//	LapsetoType: lapseto,
1365
+		//	LapsetoTime: time.Now().Unix(),
1366
+		//	UpdatedTime: time.Now().Unix(),
1367
+		//}
1368
+		//err = service.UpdatePatientLapseto(patient.BloodId, patientLapseto)
1370 1369
 		fmt.Println("编辑转归失败", err)
1371 1370
 		patientsNew := models.XtPatientsNew{
1372 1371
 			ID:                id,
@@ -1375,7 +1374,6 @@ func (this *NewDialysisApiController) UpdatedPatient() {
1375 1374
 			Birthday:          birth,
1376 1375
 			Age:               ages,
1377 1376
 			Phone:             phone,
1378
-			Lapseto:           lapseto,
1379 1377
 			AdmissionNumber:   adminssionNumber,
1380 1378
 			FirstDialysisDate: fisttime,
1381 1379
 			Diagnose:          diagonse,
@@ -1427,7 +1425,6 @@ func (this *NewDialysisApiController) UpdatedPatient() {
1427 1425
 			Birthday:          birth,
1428 1426
 			Age:               ages,
1429 1427
 			Phone:             phone,
1430
-			Lapseto:           lapseto,
1431 1428
 			AdmissionNumber:   adminssionNumber,
1432 1429
 			FirstDialysisDate: fisttime,
1433 1430
 			Diagnose:          diagonse,
@@ -1480,7 +1477,6 @@ func (this *NewDialysisApiController) UpdatedPatient() {
1480 1477
 			Birthday:          birth,
1481 1478
 			Age:               ages,
1482 1479
 			Phone:             phone,
1483
-			Lapseto:           lapseto,
1484 1480
 			AdmissionNumber:   adminssionNumber,
1485 1481
 			FirstDialysisDate: fisttime,
1486 1482
 			Diagnose:          diagonse,
@@ -1533,7 +1529,7 @@ func (this *NewDialysisApiController) GetAllProjectName() {
1533 1529
 	patient, _ := service.GetNewPatient(paientids)
1534 1530
 	orgid := this.GetMobileAdminUserInfo().Org.Id
1535 1531
 	projectName, err := service.GetAllProjectName(ids, orgid, patient.BloodId)
1536
-	fmt.Println("projectname----------------------------------", err)
1532
+	fmt.Println("projectname", err)
1537 1533
 	if err != nil {
1538 1534
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1539 1535
 		return

+ 8 - 12
controllers/patient_api_controller.go Прегледај датотеку

@@ -467,16 +467,14 @@ func (c *PatientApiController) EditPatient() {
467 467
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdatePatient)
468 468
 		return
469 469
 	}
470
-	//更新转归状态
471
-
472
-	fmt.Println("病人id--------------------------------------------------------------", patient.ID)
473
-	lapseto := models.PatientLapseto{
474
-		LapsetoType: patient.Lapseto,
475
-		LapsetoTime: time.Now().Unix(),
476
-		UpdatedTime: time.Now().Unix(),
477
-	}
478
-	err = service.UpdatePatientLapseto(patient.ID, lapseto)
479
-	fmt.Println("更新转归失败", err)
470
+	////更新转归状态
471
+	//lapseto := models.PatientLapseto{
472
+	//	LapsetoType: patient.Lapseto,
473
+	//	LapsetoTime: time.Now().Unix(),
474
+	//	UpdatedTime: time.Now().Unix(),
475
+	//}
476
+	//err = service.UpdatePatientLapseto(patient.ID, lapseto)
477
+	//fmt.Println("更新转归失败", err)
480 478
 	if err != nil {
481 479
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdatePatient)
482 480
 		return
@@ -489,7 +487,6 @@ func (c *PatientApiController) EditPatient() {
489 487
 		DialysisNo:                patient.DialysisNo,
490 488
 		AdmissionNumber:           patient.AdmissionNumber,
491 489
 		Source:                    patient.Source,
492
-		Lapseto:                   patient.Lapseto,
493 490
 		PartitionId:               patient.PartitionId,
494 491
 		BedId:                     patient.BedId,
495 492
 		Name:                      patient.Name,
@@ -560,7 +557,6 @@ func (c *PatientApiController) EditPatient() {
560 557
 	}
561 558
 	//	//更新病人ID获取新表病人ID
562 559
 	err = service.UpdatepatientTwo(&patientsNew, id)
563
-	fmt.Println("更新病人失败---------------------------------------", err)
564 560
 
565 561
 	if len(record_date) > 0 {
566 562
 		var recordTime int64

+ 6 - 0
models/common_models.go Прегледај датотеку

@@ -304,6 +304,12 @@ type InspectionReferenceMaps struct {
304 304
 	CheckConfiguration []CheckConfiguration `gorm:"-" json:"inspection_reference" form:"inspection_reference"`
305 305
 }
306 306
 
307
+type VmPatientInspectionTwo struct {
308
+	ItemId int64 `gorm:"column:item_id" json:"item_id" form:"item_id"`
309
+	Total  int64
310
+	Count  int64
311
+}
312
+
307 313
 type VmPatientInspection struct {
308 314
 	ID           int64  `gorm:"column:id" json:"id" form:"id"`
309 315
 	PatientId    int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`

+ 7 - 7
service/common_service.go Прегледај датотеку

@@ -781,17 +781,17 @@ func GetFirstQuarter(orgid int64, startime int64, endtime int64) (inspection []*
781 781
 	return inspection, err
782 782
 }
783 783
 
784
-func GetQuarterTotalCount(orgid int64, startime int64, endtime int64, lapseto int64) (inspection []*models.VmPatientInspection, err error) {
784
+func GetQuarterTotalCount(orgid int64, startime int64, endtime int64, lapseto int64) (inspection []*models.VmPatientInspectionTwo, err error) {
785 785
 
786 786
 	db := XTReadDB().Table("xt_inspection as x ").Where("x.status = 1")
787 787
 	table := XTReadDB().Table("xt_inspection_reference as r")
788 788
 	fmt.Println(table)
789 789
 	d := XTReadDB().Table("xt_patients as s")
790 790
 	fmt.Println(d)
791
-	d2 := XTReadDB().Table("xt_quality_control_standard as p")
792
-	fmt.Println(d2)
791
+	//d2 := XTReadDB().Table("xt_quality_control_standard as p")
792
+	//fmt.Println(d2)
793 793
 	if orgid > 0 {
794
-		db = db.Where("x.org_id = ?", orgid)
794
+		db = db.Where("x.org_id = ? and x.inspect_value <> 0", orgid)
795 795
 	}
796 796
 	if startime > 0 {
797 797
 		db = db.Where("x.inspect_date >=?", startime)
@@ -805,7 +805,7 @@ func GetQuarterTotalCount(orgid int64, startime int64, endtime int64, lapseto in
805 805
 	if lapseto > 0 {
806 806
 		db = db.Where("s.lapseto = ?", lapseto)
807 807
 	}
808
-	err = db.Group("x.item_id").Select("sum(case when x.inspect_date >=? and x.inspect_date<=? then 1 else 0 end) as total,sum(case when x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 and x.inspect_date >=? and x.inspect_date <=? then 1 else 0 end) as count,x.id,x.patient_id,x.org_id,x.project_id,x.item_id,x.item_name,x.project_name,x.inspect_value,x.inspect_date,r.range_min,r.range_max,p.sort", startime, endtime, startime, endtime).Joins("left join xt_inspection_reference as r on r.id = x.item_id").Joins("left join xt_patients as  s on s.id = x.patient_id").Joins("left join xt_quality_control_standard as p on p.inspection_minor = x.item_id").Order("p.sort asc").Scan(&inspection).Error
808
+	err = db.Group("x.item_id").Select("sum(case when x.inspect_date >=? and x.inspect_date<=? then 1 else 0 end) as total,sum(case when x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 and x.inspect_date >=? and x.inspect_date <=? then 1 else 0 end) as count,x.item_id", startime, endtime, startime, endtime).Joins("left join xt_inspection_reference as r on ( r.item_id = x.item_id AND r.org_id > 0) OR ( x.item_id = r.id AND r.org_id = 0 ) ").Joins("left join xt_patients as  s on s.id = x.patient_id").Scan(&inspection).Error
809 809
 	return inspection, err
810 810
 }
811 811
 
@@ -1583,7 +1583,7 @@ func GetPatientsControl(orgid int64, lapstor int64, startime int64, endtime int6
1583 1583
 		db = db.Where("x.inspect_date <=?", endtime)
1584 1584
 	}
1585 1585
 	offset := (page - 1) * limit
1586
-	err = db.Select("x.id,x.patient_id,s.name,s.dialysis_no").Joins("left join xt_patients as s on s.id = x.patient_id").Joins("left join xt_inspection_reference as r on r.id = x.item_id").Group("x.patient_id").Count(&total).Offset(offset).Limit(limit).Scan(&inspection).Error
1586
+	err = db.Select("x.id,x.patient_id,s.name,s.dialysis_no,x.inspect_date").Joins("left join xt_patients as s on s.id = x.patient_id").Joins("left join xt_inspection_reference as r on r.item_id = x.item_id AND r.org_id > 0 OR ( x.item_id = r.id AND r.org_id = 0 )").Group("x.inspect_date").Count(&total).Offset(offset).Limit(limit).Scan(&inspection).Error
1587 1587
 
1588 1588
 	return inspection, total, err
1589 1589
 }
@@ -1598,7 +1598,7 @@ func GetLastPatientsControl(orgid int64, lapstor int64, startime int64, endtime
1598 1598
 	d2 := readDb.Table("xt_quality_control_standard as d")
1599 1599
 	fmt.Println("d2", d2)
1600 1600
 	if orgid > 0 {
1601
-		db = db.Where("x.org_id = ?", orgid)
1601
+		db = db.Where("x.org_id = ? and x.inspect_value <> 0", orgid)
1602 1602
 	}
1603 1603
 	if lapstor == 0 {
1604 1604
 		table = table.Where("s.lapseto = 1 or s.lapseto = 2")

+ 2 - 2
service/patient_service.go Прегледај датотеку

@@ -277,8 +277,8 @@ func CreatePatientsNew(patientsNew *models.XtPatientsNew) error {
277 277
 
278 278
 func EditPatientLapseto(patient *models.Patients, lapseto *models.PatientLapseto) (err error) {
279 279
 	utx := writeDb.Begin()
280
-	//err = utx.Model(&models.Patients{}).Where("id=?", patient.ID).Update(map[string]interface{}{"Lapseto": patient.Lapseto}).Error
281
-	err = utx.Model(&models.PatientLapseto{}).Where("id=?", patient.ID).Update(map[string]interface{}{"lapseto_type": patient.Lapseto, "lapseto_time": time.Now().Unix(), "updated_time": time.Now().Unix()}).Error
280
+	err = utx.Model(&models.Patients{}).Where("id=?", patient.ID).Update(map[string]interface{}{"Lapseto": patient.Lapseto}).Error
281
+	//err = utx.Model(&models.PatientLapseto{}).Where("id=?", patient.ID).Update(map[string]interface{}{"lapseto_type": patient.Lapseto, "lapseto_time": time.Now().Unix(), "updated_time": time.Now().Unix()}).Error
282 282
 	if err != nil {
283 283
 		utx.Rollback()
284 284
 		return