Browse Source

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

陈少旭 4 weeks ago
parent
commit
c0010a8c03

BIN
XT_New.exe View File


+ 3 - 3
controllers/dialysis_api_controller.go View File

@@ -2573,13 +2573,13 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
2573 2573
 			service.CreateDialysisFinish(finish)
2574 2574
 		}
2575 2575
 
2576
-		if adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 3877 || adminUserInfo.CurrentOrgId == 10469 || adminUserInfo.CurrentOrgId == 10551 || adminUserInfo.CurrentOrgId == 10579 || adminUserInfo.CurrentOrgId == 10580 || adminUserInfo.CurrentOrgId == 10585 || adminUserInfo.CurrentOrgId == 10344 || adminUserInfo.CurrentOrgId == 10622 || adminUserInfo.CurrentOrgId == 10702 || adminUserInfo.CurrentOrgId == 10635 {
2576
+		if adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 3877 || adminUserInfo.CurrentOrgId == 10469 || adminUserInfo.CurrentOrgId == 10551 || adminUserInfo.CurrentOrgId == 10579 || adminUserInfo.CurrentOrgId == 10580 || adminUserInfo.CurrentOrgId == 10585 || adminUserInfo.CurrentOrgId == 10344 || adminUserInfo.CurrentOrgId == 10622 || adminUserInfo.CurrentOrgId == 10702 || adminUserInfo.CurrentOrgId == 10635 || adminUserInfo.CurrentOrgId == 10723 || adminUserInfo.CurrentOrgId == 10164 {
2577 2577
 			var dewater_amount float64
2578 2578
 			dewater_amount = 0
2579 2579
 			if dry_weight > 0 {
2580 2580
 				dewater_amount = weight_before - dry_weight - additional_weight
2581 2581
 
2582
-				if adminUserInfo.CurrentOrgId != 10551 && adminUserInfo.CurrentOrgId != 10579 && adminUserInfo.CurrentOrgId != 10580 && adminUserInfo.CurrentOrgId != 10585 && adminUserInfo.CurrentOrgId != 10344 && adminUserInfo.CurrentOrgId != 10622 && adminUserInfo.CurrentOrgId != 10702 && adminUserInfo.CurrentOrgId != 10635 {
2582
+				if adminUserInfo.CurrentOrgId != 10551 && adminUserInfo.CurrentOrgId != 10579 && adminUserInfo.CurrentOrgId != 10580 && adminUserInfo.CurrentOrgId != 10585 && adminUserInfo.CurrentOrgId != 10344 && adminUserInfo.CurrentOrgId != 10622 && adminUserInfo.CurrentOrgId != 10702 && adminUserInfo.CurrentOrgId != 10635 && adminUserInfo.CurrentOrgId != 10723 {
2583 2583
 					dewater_amount = dewater_amount * 1000
2584 2584
 				}
2585 2585
 
@@ -3178,7 +3178,7 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
3178 3178
 		}
3179 3179
 
3180 3180
 		//针对孝昌康桥超滤率计算问题
3181
-		if adminUserInfo.CurrentOrgId == 10702 || adminUserInfo.CurrentOrgId == 10635 {
3181
+		if adminUserInfo.CurrentOrgId == 10702 || adminUserInfo.CurrentOrgId == 10635 || adminUserInfo.CurrentOrgId == 10723 {
3182 3182
 			if assessmentBeforeDislysis.ID == 0 {
3183 3183
 				dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
3184 3184
 				if dialysisPrescribeOne.ID > 0 && assessmentBeforeDislysis.ID > 0 {

+ 199 - 0
controllers/his_api_controller.go View File

@@ -108,6 +108,18 @@ func HisManagerApiRegistRouters() {
108 108
 
109 109
 	beego.Router("/api/getallgoodinforlist", &HisApiController{}, "Get:GetAllGoodInforList")
110 110
 
111
+	beego.Router("/api/savegoodlist", &HisApiController{}, "Post:SaveGoodList")
112
+
113
+	beego.Router("/api/getgoodlist", &HisApiController{}, "Get:GetGoodList")
114
+
115
+	beego.Router("/api/getgoodnamedetail", &HisApiController{}, "Get:GetGoodNameDetail")
116
+
117
+	beego.Router("/api/updategoodlist", &HisApiController{}, "Post:UpdateGoodList")
118
+
119
+	beego.Router("/api/deletegoodteam", &HisApiController{}, "Get:DeleteGoodTeam")
120
+
121
+	beego.Router("/api/deletegood", &HisApiController{}, "Get:DeleteGood")
122
+
111 123
 }
112 124
 
113 125
 func (c *HisApiController) CheckHisPatient() {
@@ -14187,3 +14199,190 @@ func (c *HisApiController) GetAllGoodInforList() {
14187 14199
 	})
14188 14200
 	return
14189 14201
 }
14202
+
14203
+func (this *HisApiController) SaveGoodList() {
14204
+
14205
+	project_name := this.GetString("project_name")
14206
+	sort, _ := this.GetInt64("sort")
14207
+	orgId := this.GetAdminUserInfo().CurrentOrgId
14208
+
14209
+	dataBody := make(map[string]interface{}, 0)
14210
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
14211
+	if err != nil {
14212
+		utils.ErrorLog(err.Error())
14213
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
14214
+		return
14215
+	}
14216
+
14217
+	goodTeam := models.XtGoodTeam{
14218
+		ProjectName: project_name,
14219
+		Sort:        sort,
14220
+		UserOrgId:   orgId,
14221
+		Status:      1,
14222
+		Ctime:       time.Now().Unix(),
14223
+		Mtime:       time.Now().Unix(),
14224
+	}
14225
+
14226
+	service.CreateGoodTeam(goodTeam)
14227
+
14228
+	lastGoodTeam, _ := service.GetLastGoodTeam(orgId)
14229
+
14230
+	if dataBody["info"] != nil && reflect.TypeOf(dataBody["info"]).String() == "[]interface {}" {
14231
+		infos, _ := dataBody["info"].([]interface{})
14232
+		if len(infos) > 0 {
14233
+			for _, item := range infos {
14234
+				items := item.(map[string]interface{})
14235
+				if items["good_id"] == nil || reflect.TypeOf(items["good_id"]).String() != "float64" {
14236
+					utils.ErrorLog("good_id")
14237
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
14238
+					return
14239
+				}
14240
+				good_id := int64(items["good_id"].(float64))
14241
+
14242
+				if items["number"] == nil || reflect.TypeOf(items["number"]).String() != "float64" {
14243
+					utils.ErrorLog("number")
14244
+				}
14245
+
14246
+				number := int64(items["number"].(float64))
14247
+
14248
+				xtGoodTeamList := models.XtGoodTeamList{
14249
+					GoodId:    good_id,
14250
+					Count:     number,
14251
+					TeamId:    lastGoodTeam.ID,
14252
+					UserOrgId: orgId,
14253
+					Status:    1,
14254
+					Ctime:     time.Now().Unix(),
14255
+					Mtime:     time.Now().Unix(),
14256
+				}
14257
+
14258
+				service.CreateGoodList(xtGoodTeamList)
14259
+			}
14260
+			this.ServeSuccessJSON(map[string]interface{}{
14261
+				"lastGoodTeam": lastGoodTeam,
14262
+			})
14263
+		}
14264
+	}
14265
+	return
14266
+}
14267
+
14268
+func (this *HisApiController) GetGoodList() {
14269
+
14270
+	orgId := this.GetAdminUserInfo().CurrentOrgId
14271
+	limit, _ := this.GetInt64("limit")
14272
+	page, _ := this.GetInt64("page")
14273
+	keyword := this.GetString("keyword")
14274
+	list, total, _ := service.GetGoodList(orgId, limit, page, keyword)
14275
+
14276
+	this.ServeSuccessJSON(map[string]interface{}{
14277
+		"list":  list,
14278
+		"total": total,
14279
+	})
14280
+}
14281
+
14282
+func (this *HisApiController) GetGoodNameDetail() {
14283
+
14284
+	id, _ := this.GetInt64("id")
14285
+
14286
+	orgId := this.GetAdminUserInfo().CurrentOrgId
14287
+	goodNameDetail, _ := service.GetGoodNameDetail(id, orgId)
14288
+	goodList, _ := service.GetAllGoodList(orgId)
14289
+	this.ServeSuccessJSON(map[string]interface{}{
14290
+		"goodNameDetail": goodNameDetail,
14291
+		"goodList":       goodList,
14292
+	})
14293
+}
14294
+
14295
+func (this *HisApiController) UpdateGoodList() {
14296
+
14297
+	project_name := this.GetString("project_name")
14298
+	sort, _ := this.GetInt64("sort")
14299
+	id, _ := this.GetInt64("id")
14300
+	orgId := this.GetAdminUserInfo().CurrentOrgId
14301
+
14302
+	dataBody := make(map[string]interface{}, 0)
14303
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
14304
+	if err != nil {
14305
+		utils.ErrorLog(err.Error())
14306
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
14307
+		return
14308
+	}
14309
+
14310
+	goodTeam := models.XtGoodTeam{
14311
+		ProjectName: project_name,
14312
+		Sort:        sort,
14313
+		UserOrgId:   orgId,
14314
+		Status:      1,
14315
+		Ctime:       time.Now().Unix(),
14316
+		Mtime:       time.Now().Unix(),
14317
+		ID:          id,
14318
+	}
14319
+
14320
+	service.SaveGoodTeam(goodTeam)
14321
+
14322
+	lastGoodTeam, _ := service.GetLastGoodTeam(orgId)
14323
+
14324
+	if dataBody["info"] != nil && reflect.TypeOf(dataBody["info"]).String() == "[]interface {}" {
14325
+		infos, _ := dataBody["info"].([]interface{})
14326
+		if len(infos) > 0 {
14327
+			for _, item := range infos {
14328
+				items := item.(map[string]interface{})
14329
+				if items["good_id"] == nil || reflect.TypeOf(items["good_id"]).String() != "float64" {
14330
+					utils.ErrorLog("good_id")
14331
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
14332
+					return
14333
+				}
14334
+				good_id := int64(items["good_id"].(float64))
14335
+
14336
+				if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
14337
+					utils.ErrorLog("id")
14338
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
14339
+					return
14340
+				}
14341
+				id := int64(items["id"].(float64))
14342
+
14343
+				if items["number"] == nil || reflect.TypeOf(items["number"]).String() != "float64" {
14344
+					utils.ErrorLog("number")
14345
+				}
14346
+
14347
+				number := int64(items["number"].(float64))
14348
+
14349
+				xtGoodTeamList := models.XtGoodTeamList{
14350
+					ID:        id,
14351
+					GoodId:    good_id,
14352
+					Count:     number,
14353
+					TeamId:    lastGoodTeam.ID,
14354
+					UserOrgId: orgId,
14355
+					Status:    1,
14356
+					Ctime:     time.Now().Unix(),
14357
+					Mtime:     time.Now().Unix(),
14358
+				}
14359
+
14360
+				service.SaveGoodList(xtGoodTeamList)
14361
+			}
14362
+			this.ServeSuccessJSON(map[string]interface{}{
14363
+				"lastGoodTeam": lastGoodTeam,
14364
+			})
14365
+		}
14366
+	}
14367
+	return
14368
+}
14369
+
14370
+func (this *HisApiController) DeleteGoodTeam() {
14371
+
14372
+	id, _ := this.GetInt64("id")
14373
+	team, _ := service.DeleteGoodTeam(id)
14374
+	this.ServeSuccessJSON(map[string]interface{}{
14375
+		"team": team,
14376
+	})
14377
+}
14378
+
14379
+func (this *HisApiController) DeleteGood() {
14380
+
14381
+	id, _ := this.GetInt64("id")
14382
+
14383
+	good, _ := service.DeleteGood(id)
14384
+
14385
+	this.ServeSuccessJSON(map[string]interface{}{
14386
+		"good": good,
14387
+	})
14388
+}

+ 2 - 2
controllers/mobile_api_controllers/check_weight_api_controller.go View File

@@ -319,7 +319,7 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
319 319
 
320 320
 	template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
321 321
 
322
-	if template.TemplateId == 22 || template.TemplateId == 17 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 27 || template.TemplateId == 34 || template.TemplateId == 30 || template.TemplateId == 32 || template.TemplateId == 36 || template.TemplateId == 40 || template.TemplateId == 38 || template.TemplateId == 43 || template.TemplateId == 46 || template.TemplateId == 53 || template.TemplateId == 48 || adminUserInfo.Org.Id == 10345 || adminUserInfo.Org.Id == 10432 || adminUserInfo.Org.Id == 10441 || adminUserInfo.Org.Id == 10445 || adminUserInfo.Org.Id == 10138 || adminUserInfo.Org.Id == 10278 || adminUserInfo.Org.Id == 9829 || adminUserInfo.Org.Id == 10440 || adminUserInfo.Org.Id == 10469 || adminUserInfo.Org.Id == 10471 || adminUserInfo.Org.Id == 10537 || adminUserInfo.Org.Id == 10667 {
322
+	if template.TemplateId == 22 || template.TemplateId == 17 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 27 || template.TemplateId == 34 || template.TemplateId == 30 || template.TemplateId == 32 || template.TemplateId == 36 || template.TemplateId == 40 || template.TemplateId == 38 || template.TemplateId == 43 || template.TemplateId == 46 || template.TemplateId == 53 || template.TemplateId == 48 || adminUserInfo.Org.Id == 10345 || adminUserInfo.Org.Id == 10432 || adminUserInfo.Org.Id == 10441 || adminUserInfo.Org.Id == 10445 || adminUserInfo.Org.Id == 10138 || adminUserInfo.Org.Id == 10278 || adminUserInfo.Org.Id == 9829 || adminUserInfo.Org.Id == 10440 || adminUserInfo.Org.Id == 10469 || adminUserInfo.Org.Id == 10471 || adminUserInfo.Org.Id == 10537 || adminUserInfo.Org.Id == 10667 || adminUserInfo.Org.Id == 10723 {
323 323
 		if adminUserInfo.Org.Id != 10447 {
324 324
 			dewater_amount = dewater_amount * 1000
325 325
 		}
@@ -952,7 +952,7 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
952 952
 		}
953 953
 
954 954
 		//针对患者称重两次没有数据的问题
955
-		if adminUserInfo.Org.Id == 10702 {
955
+		if adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10723 {
956 956
 
957 957
 			dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
958 958
 			lastDialysisPrescription, _ := service.GetLastDialysisPrescription(id, adminUserInfo.Org.Id)

+ 5 - 0
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -3741,6 +3741,11 @@ func (this *DialysisAPIController) StartDialysis() {
3741 3741
 				ultrafiltration_rate = ultrafiltration_rate / 1000
3742 3742
 			}
3743 3743
 
3744
+			if adminUserInfo.Org.Id == 10723 {
3745
+				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater * 1000 / float64(totalMin) * 60 * 1000)
3746
+				ultrafiltration_rate = ultrafiltration_rate / 1000
3747
+			}
3748
+
3744 3749
 		}
3745 3750
 	}
3746 3751
 

+ 2 - 2
controllers/new_stock_api_controller.go View File

@@ -112,14 +112,14 @@ func (c *NewStockApiController) GetDrugChange() {
112 112
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
113 113
 	dealerList, _ := service.GetAllDealerList(orgId)
114 114
 	houseList, _ := service.GetAllStoreHouseList(orgId)
115
-	//patientList, _ := service.GetAllPatientListSix(orgId)
115
+	patientList, _ := service.GetAllPatientListSix(orgId)
116 116
 	c.ServeSuccessJSON(map[string]interface{}{
117 117
 		"info":             list,
118 118
 		"total":            total,
119 119
 		"manufacturerList": manufacturerList,
120 120
 		"dealerList":       dealerList,
121 121
 		"houseList":        houseList,
122
-		//"patientList":      patientList,
122
+		"patientList":      patientList,
123 123
 	})
124 124
 }
125 125
 func (c *NewStockApiController) GetDrugQuery() {

+ 27 - 32
controllers/pharmacy_controller.go View File

@@ -4,6 +4,7 @@ import (
4 4
 	"fmt"
5 5
 	"math"
6 6
 	"strconv"
7
+	"strings"
7 8
 	"time"
8 9
 
9 10
 	"XT_New/enums"
@@ -185,8 +186,17 @@ func (this *PharmacyController) IssuedDrug() {
185 186
 		etime = stime + 86399
186 187
 	}
187 188
 
189
+	var patientsId []int64
190
+
191
+	patient, _ := service.GetPatientKeyWord(keyword, orgid)
192
+	if len(patient) > 0 {
193
+		for _, item := range patient {
194
+			patientsId = append(patientsId, item.ID)
195
+		}
196
+	}
197
+
188 198
 	//获取排班班次
189
-	schedule, _ := service.GetSchedulePatientId(stime, etime, orgid, shift, partition)
199
+	schedule, _ := service.GetSchedulePatientId(stime, etime, orgid, shift, partition, patientsId)
190 200
 
191 201
 	var ids []int64
192 202
 	for _, item := range schedule {
@@ -262,34 +272,19 @@ func (this *PharmacyController) WaitingDrug() {
262 272
 		etime = stime + 86399
263 273
 	}
264 274
 
265
-	//if orgid != 9671 && orgid != 10188 && orgid != 10217 && orgid != 3877 && orgid != 10164 && orgid != 10387 && orgid != 10375 && orgid != 10480 && orgid != 10344 {
266
-	//	//查询表里当天的数据
267
-	//	var flist []*models.TmpPatient
268
-	//	flist, err = service.GetTodayDrug(stime, etime, orgid, 0, keyword)
269
-	//
270
-	//	if err != nil {
271
-	//		utils.ErrorLog(err.Error())
272
-	//		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
273
-	//		return
274
-	//	}
275
-	//	listt, err := service.PartitionAndLayout(stime, etime, orgid, shift, partition, flist)
276
-	//
277
-	//	if err != nil {
278
-	//		utils.ErrorLog(err.Error())
279
-	//		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
280
-	//		return
281
-	//	}
282
-	//	baseList, _ := service.GetAllBaseDrugListTwo(orgid)
283
-	//	this.ServeSuccessJSON(map[string]interface{}{
284
-	//		"list":     listt,
285
-	//		"baseList": baseList,
286
-	//	})
287
-	//	return
288
-	//}
289
-	fmt.Println(keyword)
275
+	var patientsId []int64
276
+
277
+	patient, _ := service.GetPatientKeyWord(keyword, orgid)
278
+	fmt.Println("hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", patient)
279
+	if len(patient) > 0 {
280
+		for _, item := range patient {
281
+			patientsId = append(patientsId, item.ID)
282
+		}
283
+	}
284
+
290 285
 	//当未发药的人数
291 286
 	//获取排班班次
292
-	schedule, _ := service.GetSchedulePatientId(stime, etime, orgid, shift, partition)
287
+	schedule, _ := service.GetSchedulePatientId(stime, etime, orgid, shift, partition, patientsId)
293 288
 	var ids []int64
294 289
 	for _, item := range schedule {
295 290
 		ids = append(ids, item.PatientId)
@@ -1383,14 +1378,14 @@ func (this *PharmacyController) ChangeDrugCode() {
1383 1378
 	orgId := this.GetAdminUserInfo().CurrentOrgId
1384 1379
 	data_source, _ := this.GetInt64("data_source")
1385 1380
 	drug_code := this.GetString("drug_code")
1386
-
1387
-	fmt.Println("data_source--------------------", data_source)
1381
+	str := strings.Replace(drug_code, " ", "", -1)
1382
+	// 去除换行符
1383
+	str = strings.Replace(str, "\n", "", -1)
1388 1384
 	if data_source == 1 {
1389
-		fmt.Println("HHAHAHAH")
1390
-		service.ChangeHisDrugCode(id, drug_code, orgId)
1385
+		service.ChangeHisDrugCode(id, str, orgId)
1391 1386
 	}
1392 1387
 	if data_source == 2 {
1393
-		service.ChangeAdivceDrugCode(id, drug_code, orgId)
1388
+		service.ChangeAdivceDrugCode(id, str, orgId)
1394 1389
 	}
1395 1390
 
1396 1391
 	this.ServeSuccessJSON(map[string]interface{}{

+ 30 - 0
models/his_models.go View File

@@ -2903,3 +2903,33 @@ type XtSelfDrugOutConfig struct {
2903 2903
 func (XtSelfDrugOutConfig) TableName() string {
2904 2904
 	return "xt_self_drug_out_config"
2905 2905
 }
2906
+
2907
+type XtGoodTeam struct {
2908
+	ID             int64             `gorm:"column:id" json:"id" form:"id"`
2909
+	ProjectName    string            `gorm:"column:project_name" json:"project_name" form:"project_name"`
2910
+	Sort           int64             `gorm:"column:sort" json:"sort" form:"sort"`
2911
+	UserOrgId      int64             `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2912
+	Status         int64             `gorm:"column:status" json:"status" form:"status"`
2913
+	Ctime          int64             `gorm:"column:ctime" json:"ctime" form:"ctime"`
2914
+	Mtime          int64             `gorm:"column:mtime" json:"mtime" form:"mtime"`
2915
+	XtGoodTeamList []*XtGoodTeamList `gorm:"ForeignKey:TeamId;AssociationForeignKey:ID" json:"xt_good_team_list"`
2916
+}
2917
+
2918
+func (XtGoodTeam) TableName() string {
2919
+	return "xt_good_team"
2920
+}
2921
+
2922
+type XtGoodTeamList struct {
2923
+	ID        int64 `gorm:"column:id" json:"id" form:"id"`
2924
+	GoodId    int64 `gorm:"column:good_id" json:"good_id" form:"good_id"`
2925
+	Count     int64 `gorm:"column:count" json:"count" form:"count"`
2926
+	TeamId    int64 `gorm:"column:team_id" json:"team_id" form:"team_id"`
2927
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2928
+	Status    int64 `gorm:"column:status" json:"status" form:"status"`
2929
+	Ctime     int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
2930
+	Mtime     int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
2931
+}
2932
+
2933
+func (XtGoodTeamList) TableName() string {
2934
+	return "xt_good_team_list"
2935
+}

+ 5 - 5
models/new_drug_stock.go View File

@@ -65,11 +65,11 @@ type NewDrugFlow struct {
65 65
 	IsChange                  int64                  `gorm:"column:is_change" json:"is_change" form:"is_change"`
66 66
 	Bchno                     string                 `gorm:"column:bchno" json:"bchno" form:"bchno"`
67 67
 	BgBchno                   string                 `gorm:"column:bg_bchno" json:"bg_bchno" form:"bg_bchno"`
68
-
69
-	PCount float64
70
-	SDate  string
71
-	PDate  int64
72
-	Unit   string
68
+	HisDoctorAdviceInfo       HisDoctorAdviceInfo    `gorm:"ForeignKey:PatientId,AdviceDate,DrugId;AssociationForeignKey:PatientId,SystemTime,DrugId"json:"his_advice_info" `
69
+	PCount                    float64
70
+	SDate                     string
71
+	PDate                     int64
72
+	Unit                      string
73 73
 }
74 74
 
75 75
 func (NewDrugFlow) TableName() string {

+ 83 - 0
service/his_service.go View File

@@ -3520,3 +3520,86 @@ func GetDialysisPresriptionById(user_org_id int64, patient_id int64, record_date
3520 3520
 
3521 3521
 	return prescriptionInfo, err
3522 3522
 }
3523
+
3524
+func CreateGoodTeam(team models.XtGoodTeam) error {
3525
+
3526
+	err := XTWriteDB().Create(&team).Error
3527
+
3528
+	return err
3529
+}
3530
+
3531
+func SaveGoodTeam(team models.XtGoodTeam) error {
3532
+
3533
+	err := XTWriteDB().Save(&team).Error
3534
+
3535
+	return err
3536
+}
3537
+
3538
+func GetLastGoodTeam(org_id int64) (models.XtGoodTeam, error) {
3539
+
3540
+	goodTeam := models.XtGoodTeam{}
3541
+
3542
+	err := XTReadDB().Where("user_org_id = ? and status=1", org_id).Last(&goodTeam).Error
3543
+
3544
+	return goodTeam, err
3545
+}
3546
+
3547
+func CreateGoodList(list models.XtGoodTeamList) error {
3548
+
3549
+	err := XTWriteDB().Create(&list).Error
3550
+
3551
+	return err
3552
+}
3553
+
3554
+func SaveGoodList(list models.XtGoodTeamList) error {
3555
+
3556
+	err := XTWriteDB().Save(&list).Error
3557
+
3558
+	return err
3559
+}
3560
+
3561
+func GetGoodList(user_org_id int64, limit int64, page int64, keyword string) (list []*models.XtGoodTeam, total int64, err error) {
3562
+
3563
+	key := "%" + keyword + "%"
3564
+	offset := (page - 1) * limit
3565
+	db := XTReadDB().Model(&list).Where("status=1")
3566
+
3567
+	if user_org_id > 0 {
3568
+		db = db.Where("user_org_id = ?", user_org_id)
3569
+	}
3570
+
3571
+	if len(keyword) > 0 {
3572
+		db = db.Where("project_name like ?", key)
3573
+	}
3574
+
3575
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("id desc").Find(&list).Error
3576
+
3577
+	return list, total, err
3578
+}
3579
+
3580
+func GetGoodNameDetail(id int64, org_id int64) (models.XtGoodTeam, error) {
3581
+
3582
+	goodTeam := models.XtGoodTeam{}
3583
+
3584
+	err := XTReadDB().Where("id = ? and status =1 and user_org_id = ?", id, org_id).Preload("XtGoodTeamList", "status = 1 and user_org_id = ?", org_id).Find(&goodTeam).Error
3585
+
3586
+	return goodTeam, err
3587
+}
3588
+
3589
+func DeleteGoodTeam(id int64) (models.XtGoodTeamList, error) {
3590
+
3591
+	goodTeamList := models.XtGoodTeamList{}
3592
+
3593
+	err := XTWriteDB().Model(&goodTeamList).Where("id = ? and status =1", id).Updates(map[string]interface{}{"status": 0}).Error
3594
+
3595
+	return goodTeamList, err
3596
+}
3597
+
3598
+func DeleteGood(id int64) (models.XtGoodTeam, error) {
3599
+
3600
+	goodTeam := models.XtGoodTeam{}
3601
+
3602
+	err := XTWriteDB().Model(&goodTeam).Where("id = ? and status=1", id).Updates(map[string]interface{}{"status": 0}).Error
3603
+
3604
+	return goodTeam, err
3605
+}

+ 1 - 1
service/new_stock_medical_insurance_service.go View File

@@ -58,7 +58,7 @@ func GetNewDrugFlow(orgid int64, limit int64, page int64, startTime int64, endTi
58 58
 	//}
59 59
 
60 60
 	//}
61
-	err = db.Count(&total).Offset(offset).Limit(limit).Order("id desc").Preload("BaseDrugLib", "status = 1").Preload("DrugWarehouseInfo", "status = 1").Preload("XtDrugWarehouseOutInfo", "status = 1").Find(&drug_flow).Error
61
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("id desc").Preload("BaseDrugLib", "status = 1 and org_id =?", orgid).Preload("DrugWarehouseInfo", "status = 1 and org_id = ?", orgid).Preload("XtDrugWarehouseOutInfo", "status = 1 and org_id = ?", orgid).Preload("HisDoctorAdviceInfo", "status=1 and user_org_id =?", orgid).Find(&drug_flow).Error
62 62
 	for _, item := range drug_flow {
63 63
 		var doc models.HisDoctorAdviceInfo
64 64
 		var p models.HisPrescription

+ 27 - 1
service/pharmacy_service.go View File

@@ -97,7 +97,24 @@ func GetTodayAdviceCount(stime, etime, orgid, is_medicine int64) (num int, err e
97 97
 	return len(tmp), err
98 98
 }
99 99
 
100
-func GetSchedulePatientId(start_time int64, end_time int64, org_id int64, class_type int64, partion_type int64) (schedule []*models.XtSchedules, err error) {
100
+func GetPatientKeyWord(keywword string, org_id int64) (patient []*models.XtPatients, err error) {
101
+
102
+	db := XTReadDB().Model(&patient).Where("status=1")
103
+
104
+	likeKey := "%" + keywword + "%"
105
+	if len(keywword) > 0 {
106
+		db = db.Where("name like ? or first_letter like ?", likeKey, likeKey)
107
+	}
108
+	if org_id > 0 {
109
+		db = db.Where("user_org_id = ?", org_id)
110
+	}
111
+
112
+	err = db.Find(&patient).Error
113
+
114
+	return patient, err
115
+}
116
+
117
+func GetSchedulePatientId(start_time int64, end_time int64, org_id int64, class_type int64, partion_type int64, patientsId []int64) (schedule []*models.XtSchedules, err error) {
101 118
 
102 119
 	db := XTReadDB().Model(&schedule).Where("status = 1")
103 120
 
@@ -118,6 +135,15 @@ func GetSchedulePatientId(start_time int64, end_time int64, org_id int64, class_
118 135
 	if partion_type > 0 {
119 136
 		db = db.Where("partition_id = ?", partion_type)
120 137
 	}
138
+
139
+	if len(patientsId) == 0 {
140
+		db = db.Where("patient_id in(?)", patientsId)
141
+	}
142
+
143
+	if len(patientsId) > 0 {
144
+		db = db.Where("patient_id in(?)", patientsId)
145
+	}
146
+
121 147
 	err = db.Find(&schedule).Error
122 148
 
123 149
 	return schedule, err