Bläddra i källkod

患者检验检查统计开发

XMLWAN 4 år sedan
förälder
incheckning
75087988e6

+ 88 - 0
controllers/new_mobile_api_controllers/common_api_controller.go Visa fil

@@ -1194,3 +1194,91 @@ func (this *CommonApiController) GetPatientscontrol() {
1194 1194
 		"control":  control,
1195 1195
 	})
1196 1196
 }
1197
+
1198
+func (this *CommonApiController) GetCartogramList() {
1199
+	adminUser := this.GetAdminUserInfo()
1200
+	orgid := adminUser.CurrentOrgId
1201
+	lapstor, _ := this.GetInt64("lapstor")
1202
+	fmt.Println("lapstor", lapstor)
1203
+	startime := this.GetString("startime")
1204
+	fmt.Println("开始时间", startime)
1205
+	startimeStr, _ := utils.ParseTimeStringToTime("2006-01-02", startime)
1206
+	startimeStrUnix := startimeStr.Unix()
1207
+	fmt.Println("时间搓", startimeStrUnix)
1208
+	endtime := this.GetString("endtime")
1209
+	fmt.Println("结束时间", endtime)
1210
+	endtimeStr := endtime + " 23:59:59"
1211
+	endtimeStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endtimeStr)
1212
+	endtimeStrsUnix := endtimeStrs.Unix()
1213
+	fmt.Println("结束时间搓", endtimeStrsUnix)
1214
+	limit, _ := this.GetInt64("limit")
1215
+	page, _ := this.GetInt64("page")
1216
+	cartogramlist, err := service.GetLastPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
1217
+	_, total, err := service.GetPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix, page, limit)
1218
+	if err != nil {
1219
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1220
+		return
1221
+	}
1222
+
1223
+	this.ServeSuccessJSON(map[string]interface{}{
1224
+		"cartogramlist": cartogramlist,
1225
+		"total":         total,
1226
+	})
1227
+}
1228
+
1229
+func (this *CommonApiController) GetPatientContor() {
1230
+
1231
+	adminUser := this.GetAdminUserInfo()
1232
+	orgid := adminUser.CurrentOrgId
1233
+	fmt.Println(orgid)
1234
+	lapstor, _ := this.GetInt64("lapstor")
1235
+	keyword := this.GetString("keyword")
1236
+	fmt.Println("keyword", keyword)
1237
+	startime := this.GetString("startime")
1238
+	fmt.Println("开始时间", startime)
1239
+	startimeStr, _ := utils.ParseTimeStringToTime("2006-01-02", startime)
1240
+	startimeStrUnix := startimeStr.Unix()
1241
+	fmt.Println("时间搓", startimeStrUnix)
1242
+	endtime := this.GetString("endtime")
1243
+	fmt.Println("结束时间", endtime)
1244
+	endtimeStr := endtime + " 23:59:59"
1245
+	endtimeStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endtimeStr)
1246
+	endtimeStrsUnix := endtimeStrs.Unix()
1247
+	fmt.Println("结束时间搓", endtimeStrsUnix)
1248
+
1249
+	patientcontorDetail, err := service.GetPatientContor(lapstor, orgid, keyword, startimeStrUnix, endtimeStrsUnix)
1250
+	patients, err := service.GetPatientNames(orgid, keyword)
1251
+	if err != nil {
1252
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1253
+		return
1254
+	}
1255
+
1256
+	this.ServeSuccessJSON(map[string]interface{}{
1257
+		"patientcontorDetail": patientcontorDetail,
1258
+		"name":                patients.Name,
1259
+	})
1260
+}
1261
+
1262
+func (this *CommonApiController) GetQualityControl() {
1263
+
1264
+	adminUser := this.GetAdminUserInfo()
1265
+	orgid := adminUser.CurrentOrgId
1266
+	fmt.Println(orgid)
1267
+	patientid, _ := this.GetInt64("patientid")
1268
+	startime, _ := this.GetInt64("startime")
1269
+	fmt.Println("startime", startime)
1270
+	endtime, _ := this.GetInt64("endtime")
1271
+	fmt.Println("endtime", endtime)
1272
+	itemid, _ := this.GetInt64("itemid")
1273
+	fmt.Println("itemid", itemid)
1274
+	list, err := service.GetQualityControlById(orgid, patientid, startime, endtime, itemid)
1275
+	if err != nil {
1276
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1277
+		return
1278
+	}
1279
+
1280
+	this.ServeSuccessJSON(map[string]interface{}{
1281
+
1282
+		"list": list,
1283
+	})
1284
+}

+ 3 - 0
controllers/new_mobile_api_controllers/common_api_router.go Visa fil

@@ -46,4 +46,7 @@ func CommonApiControllersRegisterRouters() {
46 46
 	beego.Router("/com/api/getprojectlist", &CommonApiController{}, "Get:GetProjectList")
47 47
 	beego.Router("/com/api/getmonthprojectlist", &CommonApiController{}, "Get:GetMonthProjectList")
48 48
 	beego.Router("/com/api/getpatientscontrol", &CommonApiController{}, "Get:GetPatientscontrol")
49
+	beego.Router("/com/api/getcartogramlist", &CommonApiController{}, "Get:GetCartogramList")
50
+	beego.Router("/com/api/getpatientcontor", &CommonApiController{}, "Get:GetPatientContor")
51
+	beego.Router("/com/api/getqualitycontrol", &CommonApiController{}, "Get:GetQualityControl")
49 52
 }

+ 92 - 0
controllers/new_mobile_api_controllers/new_common_api_controller.go Visa fil

@@ -739,3 +739,95 @@ func (this *NewCommonApiController) GetMobilePatientDetailCheck() {
739 739
 		"checkDetail": checkDetail,
740 740
 	})
741 741
 }
742
+
743
+func (this *NewCommonApiController) GetMobilePatientControl() {
744
+	adminInfo := this.GetMobileAdminUserInfo()
745
+	orgid := adminInfo.Org.Id
746
+	lapstor, _ := this.GetInt64("lapstor")
747
+	fmt.Println("lapstor", lapstor)
748
+	startime := this.GetString("startime")
749
+	fmt.Println("开始时间", startime)
750
+	startimeStr, _ := utils.ParseTimeStringToTime("2006-01-02", startime)
751
+	startimeStrUnix := startimeStr.Unix()
752
+	fmt.Println("时间搓", startimeStrUnix)
753
+	endtime := this.GetString("endtime")
754
+	fmt.Println("结束时间", endtime)
755
+	endtimeStr := endtime + " 23:59:59"
756
+	endtimeStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endtimeStr)
757
+	endtimeStrsUnix := endtimeStrs.Unix()
758
+	fmt.Println("结束时间搓", endtimeStrsUnix)
759
+	page, _ := this.GetInt64("page")
760
+	fmt.Println("page", page)
761
+	limit, _ := this.GetInt64("limit")
762
+	fmt.Println("limit", limit)
763
+	patients, total, err := service.GetPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix, page, limit)
764
+
765
+	control, err := service.GetLastPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
766
+	//获取最后一次数据
767
+
768
+	if err != nil {
769
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
770
+		return
771
+	}
772
+
773
+	this.ServeSuccessJSON(map[string]interface{}{
774
+		"patients": patients,
775
+		"total":    total,
776
+		"control":  control,
777
+	})
778
+}
779
+
780
+func (this *NewCommonApiController) GetMobileCartogramlist() {
781
+	adminInfo := this.GetMobileAdminUserInfo()
782
+	orgid := adminInfo.Org.Id
783
+	lapstor, _ := this.GetInt64("lapstor")
784
+	fmt.Println("lapstor", lapstor)
785
+	startime := this.GetString("startime")
786
+	fmt.Println("开始时间", startime)
787
+	startimeStr, _ := utils.ParseTimeStringToTime("2006-01-02", startime)
788
+	startimeStrUnix := startimeStr.Unix()
789
+	fmt.Println("时间搓", startimeStrUnix)
790
+	endtime := this.GetString("endtime")
791
+	fmt.Println("结束时间", endtime)
792
+	endtimeStr := endtime + " 23:59:59"
793
+	endtimeStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endtimeStr)
794
+	endtimeStrsUnix := endtimeStrs.Unix()
795
+	fmt.Println("结束时间搓", endtimeStrsUnix)
796
+	limit, _ := this.GetInt64("limit")
797
+	page, _ := this.GetInt64("page")
798
+	cartogramlist, err := service.GetLastPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
799
+	_, total, err := service.GetPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix, page, limit)
800
+	if err != nil {
801
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
802
+		return
803
+	}
804
+
805
+	this.ServeSuccessJSON(map[string]interface{}{
806
+		"cartogramlist": cartogramlist,
807
+		"total":         total,
808
+	})
809
+}
810
+
811
+func (this *NewCommonApiController) GetMobileQualityControl() {
812
+	adminInfo := this.GetMobileAdminUserInfo()
813
+	orgid := adminInfo.Org.Id
814
+	fmt.Println("orgd", orgid)
815
+	patientid, _ := this.GetInt64("patientid")
816
+	fmt.Println("patientid", patientid)
817
+	startime, _ := this.GetInt64("startime")
818
+	fmt.Println("startime", startime)
819
+	endtime, _ := this.GetInt64("endtime")
820
+	fmt.Println("endtime", endtime)
821
+	itemid, _ := this.GetInt64("itemid")
822
+	fmt.Println("itemid", itemid)
823
+	list, err := service.GetQualityControlById(orgid, patientid, startime, endtime, itemid)
824
+	if err != nil {
825
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
826
+		return
827
+	}
828
+
829
+	this.ServeSuccessJSON(map[string]interface{}{
830
+
831
+		"list": list,
832
+	})
833
+}

+ 3 - 0
controllers/new_mobile_api_controllers/new_common_api_router.go Visa fil

@@ -25,4 +25,7 @@ func NewCommonApiControllersRegisterRouters() {
25 25
 	beego.Router("/m/api/getallmobilemajorinspection", &NewCommonApiController{}, "Get:GetAllMobileMajorInspection")
26 26
 	beego.Router("/m/api/getmobilepatientlist", &NewCommonApiController{}, "Get:GetMobilePatient")
27 27
 	beego.Router("/m/api/getmobilepatientdetailcheck", &NewCommonApiController{}, "Get:GetMobilePatientDetailCheck")
28
+	beego.Router("/m/api/getmobilepatientcontrol", &NewCommonApiController{}, "Get:GetMobilePatientControl")
29
+	beego.Router("m/api/getmobilecartogramlist", &NewCommonApiController{}, "Get:GetMobileCartogramlist")
30
+	beego.Router("/m/api/getmobilequalitycontrol", &NewCommonApiController{}, "Get:GetMobileQualityControl")
28 31
 }

+ 2 - 0
models/common_models.go Visa fil

@@ -404,8 +404,10 @@ type PatientInspectionCount struct {
404 404
 	Name         string `gorm:"column:name" json:"name" form:"name"`
405 405
 	RangMax      string `gorm:"column:range_max" json:"range_max" form:"range_max"`
406 406
 	RangMin      string `gorm:"column:range_min" json:"range_min" form:"range_min"`
407
+	Unit         string `gorm:"column:unit" json:"unit" form:"unit"`
407 408
 	DialysisNo   string `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
408 409
 	RangeValue   string `gorm:"column:range_value" json:"range_value" form:"range_value"`
410
+	Sort         int64  `gorm:"column:sort" json:"sort" form:"sort"`
409 411
 }
410 412
 
411 413
 func (PatientInspectionCount) TableName() string {

+ 90 - 1
service/common_service.go Visa fil

@@ -1536,6 +1536,12 @@ func GetPatientsControl(orgid int64, lapstor int64, startime int64, endtime int6
1536 1536
 	if lapstor == 0 {
1537 1537
 		table = table.Where("s.lapseto = 1 or s.lapseto = 2")
1538 1538
 	}
1539
+	if lapstor == 1 {
1540
+		db = db.Where("s.lapseto = 1")
1541
+	}
1542
+	if lapstor == 2 {
1543
+		db = db.Where("s.lapseto = 2")
1544
+	}
1539 1545
 	if startime > 0 {
1540 1546
 		db = db.Where("x.inspect_date >=?", startime)
1541 1547
 	}
@@ -1555,6 +1561,45 @@ func GetLastPatientsControl(orgid int64, lapstor int64, startime int64, endtime
1555 1561
 	fmt.Println(table)
1556 1562
 	d := readDb.Table(" xt_inspection_reference as r")
1557 1563
 	fmt.Println(d)
1564
+	d2 := readDb.Table("xt_quality_control_standard as d")
1565
+	fmt.Println("d2", d2)
1566
+	if orgid > 0 {
1567
+		db = db.Where("x.org_id = ?", orgid)
1568
+	}
1569
+	if lapstor == 0 {
1570
+		table = table.Where("s.lapseto = 1 or s.lapseto = 2")
1571
+	}
1572
+
1573
+	if lapstor == 1 {
1574
+		table = table.Where("s.lapseto = 1")
1575
+	}
1576
+	if lapstor == 2 {
1577
+		table = table.Where("s.lapseto = 2")
1578
+	}
1579
+	if startime > 0 {
1580
+		db = db.Where("x.inspect_date >=?", startime)
1581
+	}
1582
+	if endtime > 0 {
1583
+		db = db.Where("x.inspect_date <=?", endtime)
1584
+	}
1585
+	err = db.Group("x.id").Select("x.id,x.patient_id,x.item_id,x.item_name,x.inspect_value,x.inspect_date,s.name,s.dialysis_no,r.range_max,r.range_min,d.sort").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").Joins("left join xt_quality_control_standard as d on d.inspection_minor = x.item_id").Order("x.inspect_date desc").Scan(&inspection).Error
1586
+
1587
+	return inspection, err
1588
+}
1589
+
1590
+func GetPatientContor(lapstor, orgid int64, keywords string, startime int64, endtime int64) (inspection []*models.PatientInspectionCount, err error) {
1591
+
1592
+	db := readDb.Table("xt_inspection as x").Where("x.status =1")
1593
+	table := readDb.Table("xt_patients as s")
1594
+	fmt.Println(table)
1595
+	d := readDb.Table(" xt_inspection_reference as r")
1596
+	fmt.Println(d)
1597
+	d2 := readDb.Table("xt_quality_control_standard as d")
1598
+	fmt.Println("d2", d2)
1599
+
1600
+	if len(keywords) > 0 {
1601
+		db = db.Where("s.name LIKE ? OR s.dialysis_no LIKE ?", keywords, keywords)
1602
+	}
1558 1603
 
1559 1604
 	if orgid > 0 {
1560 1605
 		db = db.Where("x.org_id = ?", orgid)
@@ -1562,13 +1607,57 @@ func GetLastPatientsControl(orgid int64, lapstor int64, startime int64, endtime
1562 1607
 	if lapstor == 0 {
1563 1608
 		table = table.Where("s.lapseto = 1 or s.lapseto = 2")
1564 1609
 	}
1610
+
1611
+	if lapstor == 1 {
1612
+		table = table.Where("s.lapseto = 1")
1613
+	}
1614
+	if lapstor == 2 {
1615
+		table = table.Where("s.lapseto = 2")
1616
+	}
1565 1617
 	if startime > 0 {
1566 1618
 		db = db.Where("x.inspect_date >=?", startime)
1567 1619
 	}
1568 1620
 	if endtime > 0 {
1569 1621
 		db = db.Where("x.inspect_date <=?", endtime)
1570 1622
 	}
1571
-	err = db.Select("x.id,x.patient_id,x.item_id,x.item_name,x.inspect_value,x.inspect_date,s.name,s.dialysis_no,r.range_max,r.range_min").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").Order("x.inspect_date desc").Scan(&inspection).Error
1623
+	err = db.Group("x.id").Select("x.id,x.patient_id,x.item_id,x.item_name,x.inspect_value,x.inspect_date,s.name,s.dialysis_no,r.range_max,r.range_min,d.sort").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").Joins("left join xt_quality_control_standard as d on d.inspection_minor = x.item_id").Order("x.inspect_date desc").Scan(&inspection).Error
1624
+
1625
+	return inspection, err
1626
+}
1627
+
1628
+func GetPatientNames(orgid int64, patientname string) (models.XtPatients, error) {
1629
+	patients := models.XtPatients{}
1630
+	err := readDb.Where("user_org_id = ? and (name=? or dialysis_no=?) and status = 1", orgid, patientname, patientname).Find(&patients).Error
1631
+	return patients, err
1632
+}
1633
+
1634
+func GetQualityControlById(orgid int64, patientid int64, startime int64, endtime int64, itemid int64) (inspection []*models.PatientInspectionCount, err error) {
1635
+
1636
+	db := readDb.Table("xt_inspection as x").Where("x.status =1")
1637
+	table := readDb.Table("xt_patients as s")
1638
+	fmt.Println(table)
1639
+	d := readDb.Table(" xt_inspection_reference as r")
1640
+	fmt.Println(d)
1641
+	d2 := readDb.Table("xt_quality_control_standard as d")
1642
+	fmt.Println("d2", d2)
1643
+
1644
+	if orgid > 0 {
1645
+		db = db.Where("x.org_id = ?", orgid)
1646
+	}
1647
+	if patientid > 0 {
1648
+		db = db.Where("x.patient_id = ?", patientid)
1649
+	}
1650
+
1651
+	if startime > 0 {
1652
+		db = db.Where("x.inspect_date >=?", startime)
1653
+	}
1654
+	if endtime > 0 {
1655
+		db = db.Where("x.inspect_date <=?", endtime)
1656
+	}
1657
+	if itemid > 0 {
1658
+		db = db.Where("x.item_id = ?", itemid)
1659
+	}
1660
+	err = db.Group("x.id").Select("x.id,x.patient_id,x.item_id,x.item_name,x.inspect_value,x.inspect_date,s.name,s.dialysis_no,r.range_max,r.range_min,d.sort,r.unit").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").Joins("left join xt_quality_control_standard as d on d.inspection_minor = x.item_id").Order("x.inspect_date desc").Scan(&inspection).Error
1572 1661
 
1573 1662
 	return inspection, err
1574 1663
 }