Browse Source

历史排班

28169 1 year ago
parent
commit
f6c245e95c

+ 24 - 2
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -9817,6 +9817,7 @@ func (c *DialysisAPIController) GetControlMonitorList() {
9817 9817
 
9818 9818
 func (c *DialysisAPIController) GetAdviceListNoExecution() {
9819 9819
 
9820
+	admin_user_id, _ := c.GetInt64("admin_user_id")
9820 9821
 	timeStr := time.Now().Format("2006-01-02")
9821 9822
 	timeLayout := "2006-01-02 15:04:05"
9822 9823
 	timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
@@ -9824,10 +9825,31 @@ func (c *DialysisAPIController) GetAdviceListNoExecution() {
9824 9825
 
9825 9826
 	orgId := c.GetMobileAdminUserInfo().Org.Id
9826 9827
 
9827
-	adviceList, _ := service.GetAdviceListNoExecution(timenow, orgId)
9828
+	//查询当前护士的患者
9829
+	orderList, _ := service.GetDialysisOrderNoExecution(admin_user_id, orgId)
9830
+	var patientIds []int64
9831
+
9832
+	for _, item := range orderList {
9833
+		patientIds = append(patientIds, item.PatientId)
9834
+	}
9835
+
9836
+	adviceList, _ := service.GetAdviceListNoExecution(timenow, orgId, patientIds)
9837
+
9838
+	hisAdviceList, _ := service.GetHisAdviceListNoExecution(timenow, orgId, patientIds)
9839
+	fmt.Println("hisAdviceList", hisAdviceList)
9840
+	projectList, _ := service.GetProjectListNoExecution(timenow, orgId, patientIds)
9841
+	fmt.Println("projectList", projectList)
9842
+	//药品管理信息
9843
+	_, drugStockConfig := service.FindHisConfig(orgId)
9844
+
9845
+	patientList, _ := service.GetPatientNoExecutionList(orgId, patientIds)
9828 9846
 
9829 9847
 	c.ServeSuccessJSON(map[string]interface{}{
9830
-		"adviceList": adviceList,
9848
+		"adviceList":      adviceList,
9849
+		"hisAdviceList":   hisAdviceList,
9850
+		"projectList":     projectList,
9851
+		"drugStockConfig": drugStockConfig,
9852
+		"patientList":     patientList,
9831 9853
 	})
9832 9854
 
9833 9855
 }

+ 45 - 0
models/dialysis.go View File

@@ -1552,3 +1552,48 @@ type DialysisFinish struct {
1552 1552
 func (DialysisFinish) TableName() string {
1553 1553
 	return "xt_dialysis_finish"
1554 1554
 }
1555
+
1556
+type NoDoctorAdvice struct {
1557
+	ID             int64 `gorm:"column:id" json:"id" form:"id"`
1558
+	UserOrgId      int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1559
+	PatientId      int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1560
+	Status         int64 `gorm:"column:status" json:"status" form:"status"`
1561
+	ExecutionState int64 `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
1562
+	AdviceDate     int64 `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
1563
+	AdviceType     int64 `gorm:"column:advice_type" json:"advice_type" form:"advice_type"`
1564
+	Count          int64 `json:"count"`
1565
+}
1566
+
1567
+func (NoDoctorAdvice) TableName() string {
1568
+	return "xt_doctor_advice"
1569
+}
1570
+
1571
+type HisNoDoctorAdvice struct {
1572
+	ID             int64 `gorm:"column:id" json:"id" form:"id"`
1573
+	UserOrgId      int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1574
+	PatientId      int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1575
+	Status         int64 `gorm:"column:status" json:"status" form:"status"`
1576
+	ExecutionState int64 `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
1577
+	AdviceDate     int64 `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
1578
+	AdviceType     int64 `gorm:"column:advice_type" json:"advice_type" form:"advice_type"`
1579
+	Count          int64 `json:"count"`
1580
+}
1581
+
1582
+func (HisNoDoctorAdvice) TableName() string {
1583
+	return "his_doctor_advice_info"
1584
+}
1585
+
1586
+type NoHisPrescriptionProject struct {
1587
+	ID             int64 `gorm:"column:id" json:"id" form:"id"`
1588
+	UserOrgId      int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1589
+	Status         int64 `gorm:"column:status" json:"status" form:"status"`
1590
+	PatientId      int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1591
+	RecordDate     int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
1592
+	Count          int64 `json:"count"`
1593
+	ExecutionState int64 `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
1594
+	AdviceDate     int64 `json:"advice_date"`
1595
+}
1596
+
1597
+func (NoHisPrescriptionProject) TableName() string {
1598
+	return "his_prescription_project"
1599
+}

+ 66 - 2
service/patient_service.go View File

@@ -3209,8 +3209,72 @@ func CreateDeviceValusalMapVrr(vrr models.XtDeviceValusalMapVrr) error {
3209 3209
 	return err
3210 3210
 }
3211 3211
 
3212
-func GetAdviceListNoExecution(advice_date int64, user_org_id int64) (advice []*models.XtDoctorAdvice, err error) {
3212
+func GetDialysisOrderNoExecution(start_nurse int64, user_org_id int64) (order []*models.XtDialysisOrder, err error) {
3213
+
3214
+	err = XTReadDB().Where("start_nurse = ? and user_org_id =? and status =1", start_nurse, user_org_id).Find(&order).Error
3215
+	return order, err
3216
+}
3217
+
3218
+func GetAdviceListNoExecution(advice_date int64, user_org_id int64, patientIds []int64) (advice []*models.NoDoctorAdvice, err error) {
3219
+
3220
+	db := XTReadDB().Model(advice).Where("status=1 and  execution_state = 2 and advice_type = 2")
3221
+
3222
+	if advice_date > 0 {
3223
+		db = db.Where("advice_date= ?", advice_date)
3224
+	}
3225
+	if user_org_id > 0 {
3226
+		db = db.Where("user_org_id =?", user_org_id)
3227
+	}
3228
+	if len(patientIds) > 0 {
3229
+		db = db.Where("patient_id in(?)", patientIds)
3230
+	}
3231
+
3232
+	err = db.Select("patient_id,Count(id) as count,advice_date").Group("patient_id").Find(&advice).Error
3233
+	return advice, err
3234
+}
3235
+
3236
+func GetHisAdviceListNoExecution(advice_date int64, user_org_id int64, patientIds []int64) (advice []*models.HisNoDoctorAdvice, err error) {
3237
+
3238
+	db := XTReadDB().Model(advice).Where("status=1 and  execution_state = 2")
3239
+
3240
+	if advice_date > 0 {
3241
+		db = db.Where("advice_date= ?", advice_date)
3242
+	}
3243
+	if user_org_id > 0 {
3244
+		db = db.Where("user_org_id =?", user_org_id)
3245
+	}
3246
+	if len(patientIds) > 0 {
3247
+		db = db.Where("patient_id in(?)", patientIds)
3248
+	}
3249
+
3250
+	err = db.Select("patient_id,Count(id) as count").Group("patient_id").Find(&advice).Error
3213 3251
 
3214
-	err = XTReadDB().Where("advice_date = ? and user_org_id = ? and status =1 and execution_state = 2", advice_date, user_org_id).Find(&advice).Error
3215 3252
 	return advice, err
3216 3253
 }
3254
+
3255
+func GetProjectListNoExecution(record_date int64, user_org_id int64, patientIds []int64) (project []*models.NoHisPrescriptionProject, err error) {
3256
+
3257
+	db := XTReadDB().Model(&project).Where("status=1 and execution_state =0")
3258
+	if record_date > 0 {
3259
+		db = db.Where("record_date= ?", record_date)
3260
+	}
3261
+	if user_org_id > 0 {
3262
+		db = db.Where("user_org_id =?", user_org_id)
3263
+	}
3264
+	if len(patientIds) > 0 {
3265
+		db = db.Where("patient_id in(?)", patientIds)
3266
+	}
3267
+
3268
+	err = db.Select("patient_id,Count(id) as count,record_date as advice_date").Group("patient_id").Find(&project).Error
3269
+	return project, err
3270
+}
3271
+
3272
+func GetPatientNoExecutionList(org_id int64, patientsIds []int64) (patient []*models.XtPatients, err error) {
3273
+
3274
+	err = XTReadDB().Where("user_org_id = ? and id in(?)", org_id, patientsIds).Find(&patient).Error
3275
+	return patient, err
3276
+}
3277
+func FindHisConfig(org_id int64) (err error, config models.XtHisConfig) {
3278
+	err = readDb.Model(&models.XtHisConfig{}).Where("status = 1 AND user_org_id = ?", org_id).First(&config).Error
3279
+	return
3280
+}