Browse Source

2024/6/17

28169 8 months ago
parent
commit
525892e454

+ 1 - 1
controllers/his_api_controller.go View File

@@ -10295,7 +10295,7 @@ func (this *HisApiController) GetCallHisPrescription() {
10295 10295
 						info, _ := service.GetWarehoseInfoByDrugId(subItem.DrugId, adminUserInfo.CurrentOrgId)
10296 10296
 						if info.RetailPrice > 0 {
10297 10297
 							if subItem.PrescribingNumberUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
10298
-								subItem.Drug.RetailPrice = info.RetailPrice * float64(drug.MinNumber)
10298
+								subItem.Drug.RetailPrice = drug.RetailPrice
10299 10299
 							}
10300 10300
 							if subItem.PrescribingNumberUnit == drug.MinUnit {
10301 10301
 								subItem.Drug.MinPrice = info.RetailPrice

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

@@ -10796,9 +10796,16 @@ func (c *DialysisAPIController) SaveLongMobileAdvice() {
10796 10796
 	patient_id := int64(dataBody["patient_id"].(float64))
10797 10797
 
10798 10798
 	day_count := int64(dataBody["day_count"].(float64))
10799
+
10800
+	groupNo := int64(dataBody["group_no"].(float64))
10799 10801
 	advice_doctor := c.GetMobileAdminUserInfo().AdminUser.Id
10800 10802
 
10801 10803
 	adviceLast, _ := service.GetLastLongAdviceList(org_id)
10804
+
10805
+	if groupNo <= 0 {
10806
+		group := service.GetMaxAdviceGroupID(org_id)
10807
+		groupNo = group + 1
10808
+	}
10802 10809
 	var template_id = ""
10803 10810
 	adviceLastId := strconv.FormatInt(adviceLast.ID, 10)
10804 10811
 	template_id = "M" + adviceLastId
@@ -10854,6 +10861,7 @@ func (c *DialysisAPIController) SaveLongMobileAdvice() {
10854 10861
 		PushStartTime:         0,
10855 10862
 		IsSettle:              0,
10856 10863
 		IsPrescription:        0,
10864
+		GroupNo:               groupNo,
10857 10865
 	}
10858 10866
 
10859 10867
 	service.CreateMobileAdivce(advice)
@@ -10877,3 +10885,435 @@ func (c *DialysisAPIController) GetLongDoctorAdviceByPatient() {
10877 10885
 		"adminRoles": adminRoles,
10878 10886
 	})
10879 10887
 }
10888
+
10889
+func (c *DialysisAPIController) SaveSelfChildDrugLongAdivce() {
10890
+
10891
+	org_id := c.GetMobileAdminUserInfo().Org.Id
10892
+	dataBody := make(map[string]interface{}, 0)
10893
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
10894
+	if err != nil {
10895
+		utils.ErrorLog(err.Error())
10896
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
10897
+		return
10898
+	}
10899
+
10900
+	timeLayout := "2006-01-02"
10901
+	loc, _ := time.LoadLocation("Local")
10902
+
10903
+	if dataBody["start_time"] == nil || reflect.TypeOf(dataBody["start_time"]).String() != "string" {
10904
+		utils.ErrorLog("start_time")
10905
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
10906
+		return
10907
+	}
10908
+
10909
+	startTime2, _ := dataBody["start_time"].(string)
10910
+	time_arr := strings.Split(startTime2, " ")
10911
+	if len(time_arr) > 0 {
10912
+		startTime2 = time_arr[0]
10913
+	}
10914
+	if dataBody["advice_date"] == nil || reflect.TypeOf(dataBody["advice_date"]).String() != "string" {
10915
+		utils.ErrorLog("advice_date")
10916
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
10917
+		return
10918
+	}
10919
+	advice_date, _ := dataBody["advice_date"].(string)
10920
+
10921
+	var advicedateunix int64
10922
+	if len(advice_date) > 0 {
10923
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", advice_date+" 00:00:00", loc)
10924
+		if err != nil {
10925
+			fmt.Println(err)
10926
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
10927
+			return
10928
+		}
10929
+		advicedateunix = theTime.Unix()
10930
+	}
10931
+
10932
+	adviceDate := startTime2
10933
+	if len(adviceDate) == 0 {
10934
+		utils.ErrorLog("len(adviceDate) == 0")
10935
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
10936
+		return
10937
+	}
10938
+	theTime, err := time.ParseInLocation(timeLayout, adviceDate, loc)
10939
+	if err != nil {
10940
+		utils.ErrorLog(err.Error())
10941
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
10942
+		return
10943
+	}
10944
+	AdviceDate := advicedateunix
10945
+	RecordDate := advicedateunix
10946
+
10947
+	if dataBody["start_time"] == nil || reflect.TypeOf(dataBody["start_time"]).String() != "string" {
10948
+		utils.ErrorLog("start_time")
10949
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
10950
+		return
10951
+	}
10952
+	startTime, _ := dataBody["start_time"].(string)
10953
+
10954
+	if len(startTime) == 0 {
10955
+		utils.ErrorLog("len(start_time) == 0")
10956
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
10957
+		return
10958
+	}
10959
+	theTime, err = time.ParseInLocation(timeLayout+" 15:04:05", startTime, loc)
10960
+
10961
+	if err != nil {
10962
+		utils.ErrorLog(err.Error())
10963
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
10964
+		return
10965
+	}
10966
+	StartTime := theTime.Unix()
10967
+
10968
+	advice_name, _ := dataBody["advice_name"].(string)
10969
+
10970
+	advice_desc, _ := dataBody["advice_desc"].(string)
10971
+
10972
+	delivery_way, _ := dataBody["delivery_way"].(string)
10973
+
10974
+	execution_frequency, _ := dataBody["execution_frequency"].(string)
10975
+
10976
+	prescribing_number := dataBody["prescribing_number"].(float64)
10977
+
10978
+	prescribing_number_unit := dataBody["prescribing_number_unit"].(string)
10979
+
10980
+	remark := dataBody["remark"].(string)
10981
+
10982
+	single_dose := dataBody["single_dose"].(float64)
10983
+
10984
+	single_dose_unit := dataBody["single_dose_unit"].(string)
10985
+
10986
+	patient_id := int64(dataBody["patient_id"].(float64))
10987
+
10988
+	groupNo := int64(dataBody["group_no"].(float64))
10989
+
10990
+	parent_id := int64(dataBody["parent_id"].(float64))
10991
+
10992
+	advice_doctor := c.GetMobileAdminUserInfo().AdminUser.Id
10993
+	advice := models.XtDoctorAdviceOne{
10994
+		UserOrgId:             org_id,
10995
+		PatientId:             patient_id,
10996
+		AdviceType:            1,
10997
+		AdviceDate:            AdviceDate,
10998
+		StartTime:             StartTime,
10999
+		AdviceName:            advice_name,
11000
+		AdviceDesc:            advice_desc,
11001
+		ReminderDate:          0,
11002
+		SingleDose:            single_dose,
11003
+		SingleDoseUnit:        single_dose_unit,
11004
+		PrescribingNumber:     prescribing_number,
11005
+		PrescribingNumberUnit: prescribing_number_unit,
11006
+		DeliveryWay:           delivery_way,
11007
+		ExecutionFrequency:    execution_frequency,
11008
+		AdviceDoctor:          advice_doctor,
11009
+		Status:                1,
11010
+		CreatedTime:           time.Now().Unix(),
11011
+		UpdatedTime:           time.Now().Unix(),
11012
+		AdviceAffirm:          "",
11013
+		Remark:                remark,
11014
+		StopTime:              0,
11015
+		StopReason:            "",
11016
+		StopDoctor:            0,
11017
+		StopState:             0,
11018
+		ParentId:              parent_id,
11019
+		ExecutionTime:         0,
11020
+		ExecutionStaff:        0,
11021
+		ExecutionState:        0,
11022
+		Checker:               0,
11023
+		RecordDate:            RecordDate,
11024
+		DialysisOrderId:       0,
11025
+		CheckTime:             0,
11026
+		CheckState:            0,
11027
+		DrugSpec:              0,
11028
+		DrugSpecUnit:          "",
11029
+		Groupno:               groupNo,
11030
+		RemindType:            0,
11031
+		FrequencyType:         0,
11032
+		DayCount:              0,
11033
+		WeekDay:               "",
11034
+		TemplateId:            "",
11035
+		Modifier:              0,
11036
+	}
11037
+
11038
+	service.CreateMobileAdivceOne(advice)
11039
+
11040
+	c.ServeSuccessJSON(map[string]interface{}{
11041
+		"msg": "保存成功!",
11042
+	})
11043
+}
11044
+
11045
+func (c *DialysisAPIController) DeleteSelfAdviceSubAdvice() {
11046
+
11047
+	id, _ := c.GetInt64("id")
11048
+
11049
+	service.DeleteSelfAdviceSubAdvice(id)
11050
+
11051
+	c.ServeSuccessJSON(map[string]interface{}{
11052
+		"msg": "保存成功!",
11053
+	})
11054
+}
11055
+
11056
+func (c *DialysisAPIController) GetEditAdviceAction() {
11057
+
11058
+	id, _ := c.GetInt64("id")
11059
+	org_id := c.GetMobileAdminUserInfo().Org.Id
11060
+	advice, _ := service.GetEditAdviceActionList(id, org_id)
11061
+	drugList, _ := service.GetAllDrugList(org_id)
11062
+	c.ServeSuccessJSON(map[string]interface{}{
11063
+		"advice":   advice,
11064
+		"drugList": drugList,
11065
+	})
11066
+}
11067
+
11068
+func (c *DialysisAPIController) UpdateLongMobileAdvice() {
11069
+
11070
+	dataBody := make(map[string]interface{}, 0)
11071
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
11072
+	if err != nil {
11073
+		utils.ErrorLog(err.Error())
11074
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
11075
+		return
11076
+	}
11077
+
11078
+	timeLayout := "2006-01-02"
11079
+	loc, _ := time.LoadLocation("Local")
11080
+
11081
+	if dataBody["start_time"] == nil || reflect.TypeOf(dataBody["start_time"]).String() != "string" {
11082
+		utils.ErrorLog("start_time")
11083
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
11084
+		return
11085
+	}
11086
+
11087
+	startTime2, _ := dataBody["start_time"].(string)
11088
+	time_arr := strings.Split(startTime2, " ")
11089
+	if len(time_arr) > 0 {
11090
+		startTime2 = time_arr[0]
11091
+	}
11092
+	if dataBody["advice_date"] == nil || reflect.TypeOf(dataBody["advice_date"]).String() != "string" {
11093
+		utils.ErrorLog("advice_date")
11094
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
11095
+		return
11096
+	}
11097
+	advice_date, _ := dataBody["advice_date"].(string)
11098
+
11099
+	var advicedateunix int64
11100
+	if len(advice_date) > 0 {
11101
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", advice_date+" 00:00:00", loc)
11102
+		if err != nil {
11103
+			fmt.Println(err)
11104
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
11105
+			return
11106
+		}
11107
+		advicedateunix = theTime.Unix()
11108
+	}
11109
+
11110
+	adviceDate := startTime2
11111
+	if len(adviceDate) == 0 {
11112
+		utils.ErrorLog("len(adviceDate) == 0")
11113
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
11114
+		return
11115
+	}
11116
+	theTime, err := time.ParseInLocation(timeLayout, adviceDate, loc)
11117
+	if err != nil {
11118
+		utils.ErrorLog(err.Error())
11119
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
11120
+		return
11121
+	}
11122
+	AdviceDate := advicedateunix
11123
+	RecordDate := advicedateunix
11124
+
11125
+	if dataBody["start_time"] == nil || reflect.TypeOf(dataBody["start_time"]).String() != "string" {
11126
+		utils.ErrorLog("start_time")
11127
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
11128
+		return
11129
+	}
11130
+	startTime, _ := dataBody["start_time"].(string)
11131
+
11132
+	if len(startTime) == 0 {
11133
+		utils.ErrorLog("len(start_time) == 0")
11134
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
11135
+		return
11136
+	}
11137
+	theTime, err = time.ParseInLocation(timeLayout+" 15:04:05", startTime, loc)
11138
+
11139
+	if err != nil {
11140
+		utils.ErrorLog(err.Error())
11141
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
11142
+		return
11143
+	}
11144
+	StartTime := theTime.Unix()
11145
+
11146
+	advice_name, _ := dataBody["advice_name"].(string)
11147
+
11148
+	advice_desc, _ := dataBody["advice_desc"].(string)
11149
+
11150
+	delivery_way, _ := dataBody["delivery_way"].(string)
11151
+
11152
+	execution_frequency, _ := dataBody["execution_frequency"].(string)
11153
+
11154
+	prescribing_number := dataBody["prescribing_number"].(float64)
11155
+
11156
+	prescribing_number_unit := dataBody["prescribing_number_unit"].(string)
11157
+
11158
+	remark := dataBody["remark"].(string)
11159
+
11160
+	single_dose := dataBody["single_dose"].(float64)
11161
+
11162
+	single_dose_unit := dataBody["single_dose_unit"].(string)
11163
+
11164
+	id := int64(dataBody["id"].(float64))
11165
+
11166
+	frequency_type := int64(dataBody["frequency_type"].(float64))
11167
+
11168
+	frequency_week, _ := dataBody["frequency_week"].(string)
11169
+
11170
+	day_count := int64(dataBody["day_count"].(float64))
11171
+
11172
+	advice_doctor := c.GetMobileAdminUserInfo().AdminUser.Id
11173
+	advice := models.XtDoctorAdviceOne{
11174
+		AdviceDate:            AdviceDate,
11175
+		StartTime:             StartTime,
11176
+		AdviceName:            advice_name,
11177
+		AdviceDesc:            advice_desc,
11178
+		SingleDose:            single_dose,
11179
+		SingleDoseUnit:        single_dose_unit,
11180
+		PrescribingNumber:     prescribing_number,
11181
+		PrescribingNumberUnit: prescribing_number_unit,
11182
+		DeliveryWay:           delivery_way,
11183
+		ExecutionFrequency:    execution_frequency,
11184
+		AdviceDoctor:          advice_doctor,
11185
+		Remark:                remark,
11186
+		RecordDate:            RecordDate,
11187
+		FrequencyType:         frequency_type,
11188
+		DayCount:              day_count,
11189
+		WeekDay:               frequency_week,
11190
+	}
11191
+
11192
+	service.UpdateMobileDoctorAdviceByIdOne(id, advice)
11193
+
11194
+	c.ServeSuccessJSON(map[string]interface{}{
11195
+		"advice": advice,
11196
+	})
11197
+}
11198
+
11199
+func (c *DialysisAPIController) UpdateEditDrugOrder() {
11200
+
11201
+	dataBody := make(map[string]interface{}, 0)
11202
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
11203
+	if err != nil {
11204
+		utils.ErrorLog(err.Error())
11205
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
11206
+		return
11207
+	}
11208
+
11209
+	timeLayout := "2006-01-02"
11210
+	loc, _ := time.LoadLocation("Local")
11211
+
11212
+	if dataBody["start_time"] == nil || reflect.TypeOf(dataBody["start_time"]).String() != "string" {
11213
+		utils.ErrorLog("start_time")
11214
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
11215
+		return
11216
+	}
11217
+
11218
+	startTime2, _ := dataBody["start_time"].(string)
11219
+	time_arr := strings.Split(startTime2, " ")
11220
+	if len(time_arr) > 0 {
11221
+		startTime2 = time_arr[0]
11222
+	}
11223
+	if dataBody["advice_date"] == nil || reflect.TypeOf(dataBody["advice_date"]).String() != "string" {
11224
+		utils.ErrorLog("advice_date")
11225
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
11226
+		return
11227
+	}
11228
+	advice_date, _ := dataBody["advice_date"].(string)
11229
+
11230
+	var advicedateunix int64
11231
+	if len(advice_date) > 0 {
11232
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", advice_date+" 00:00:00", loc)
11233
+		if err != nil {
11234
+			fmt.Println(err)
11235
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
11236
+			return
11237
+		}
11238
+		advicedateunix = theTime.Unix()
11239
+	}
11240
+
11241
+	adviceDate := startTime2
11242
+	if len(adviceDate) == 0 {
11243
+		utils.ErrorLog("len(adviceDate) == 0")
11244
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
11245
+		return
11246
+	}
11247
+	theTime, err := time.ParseInLocation(timeLayout, adviceDate, loc)
11248
+	if err != nil {
11249
+		utils.ErrorLog(err.Error())
11250
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
11251
+		return
11252
+	}
11253
+	AdviceDate := advicedateunix
11254
+	RecordDate := advicedateunix
11255
+
11256
+	if dataBody["start_time"] == nil || reflect.TypeOf(dataBody["start_time"]).String() != "string" {
11257
+		utils.ErrorLog("start_time")
11258
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
11259
+		return
11260
+	}
11261
+	startTime, _ := dataBody["start_time"].(string)
11262
+
11263
+	if len(startTime) == 0 {
11264
+		utils.ErrorLog("len(start_time) == 0")
11265
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
11266
+		return
11267
+	}
11268
+	theTime, err = time.ParseInLocation(timeLayout+" 15:04:05", startTime, loc)
11269
+
11270
+	if err != nil {
11271
+		utils.ErrorLog(err.Error())
11272
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
11273
+		return
11274
+	}
11275
+	StartTime := theTime.Unix()
11276
+
11277
+	advice_name, _ := dataBody["advice_name"].(string)
11278
+
11279
+	advice_desc, _ := dataBody["advice_desc"].(string)
11280
+
11281
+	delivery_way, _ := dataBody["delivery_way"].(string)
11282
+
11283
+	execution_frequency, _ := dataBody["execution_frequency"].(string)
11284
+
11285
+	prescribing_number := dataBody["prescribing_number"].(float64)
11286
+
11287
+	prescribing_number_unit := dataBody["prescribing_number_unit"].(string)
11288
+
11289
+	remark := dataBody["remark"].(string)
11290
+
11291
+	single_dose := dataBody["single_dose"].(float64)
11292
+
11293
+	single_dose_unit := dataBody["single_dose_unit"].(string)
11294
+
11295
+	id := int64(dataBody["id"].(float64))
11296
+
11297
+	advice_doctor := c.GetMobileAdminUserInfo().AdminUser.Id
11298
+	advice := models.XtDoctorAdviceOne{
11299
+		AdviceDate:            AdviceDate,
11300
+		StartTime:             StartTime,
11301
+		AdviceName:            advice_name,
11302
+		AdviceDesc:            advice_desc,
11303
+		SingleDose:            single_dose,
11304
+		SingleDoseUnit:        single_dose_unit,
11305
+		PrescribingNumber:     prescribing_number,
11306
+		PrescribingNumberUnit: prescribing_number_unit,
11307
+		DeliveryWay:           delivery_way,
11308
+		ExecutionFrequency:    execution_frequency,
11309
+		AdviceDoctor:          advice_doctor,
11310
+		Remark:                remark,
11311
+		RecordDate:            RecordDate,
11312
+	}
11313
+
11314
+	service.UpdateMobileDoctorAdviceById(id, advice)
11315
+
11316
+	c.ServeSuccessJSON(map[string]interface{}{
11317
+		"advice": advice,
11318
+	})
11319
+}

+ 10 - 0
controllers/mobile_api_controllers/mobile_api_router_register.go View File

@@ -219,4 +219,14 @@ func MobileAPIControllersRegisterRouters() {
219 219
 	beego.Router("/m/api/savelongmobileadvice", &DialysisAPIController{}, "Post:SaveLongMobileAdvice")
220 220
 
221 221
 	beego.Router("/m/api/getlongdoctoradvicebypatient", &DialysisAPIController{}, "Get:GetLongDoctorAdviceByPatient")
222
+
223
+	beego.Router("/m/api/saveselfchilddruglongadvice", &DialysisAPIController{}, "Post:SaveSelfChildDrugLongAdivce")
224
+
225
+	beego.Router("/m/api/deleteselfadvicesubadvice", &DialysisAPIController{}, "Get:DeleteSelfAdviceSubAdvice")
226
+
227
+	beego.Router("/m/api/geteditadviceaction", &DialysisAPIController{}, "Get:GetEditAdviceAction")
228
+
229
+	beego.Router("/m/api/updatelongmobileadvice", &DialysisAPIController{}, "Post:UpdateLongMobileAdvice")
230
+
231
+	beego.Router("/m/api/updateeditdrugorder", &DialysisAPIController{}, "Post:UpdateEditDrugOrder")
222 232
 }

+ 7 - 2
controllers/mobile_api_controllers/patient_api_controller.go View File

@@ -1467,9 +1467,12 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1467 1467
 					if lastWarehouseOut.ID == 0 {
1468 1468
 						service.AddSelfSigleDrugWarehouseOut(&drugWarehouseOut, tx)
1469 1469
 					}
1470
+
1471
+					//查询今日是否有出库数据
1472
+					lastWarehouseOutOne, _ := service.GetSelfDrugLastWarehouseOutTwety(adminUserInfo.Org.Id, advice.AdviceDate, tx, 1)
1470 1473
 					//出库
1471 1474
 					warehouseOutInfo := &models.XtSelfDrugWarehouseOutInfo{
1472
-						WarehouseOutId:          lastWarehouseOut.ID,
1475
+						WarehouseOutId:          lastWarehouseOutOne.ID,
1473 1476
 						WarehouseOutOrderNumber: warehousing_out_order,
1474 1477
 						DrugId:                  advice.DrugId,
1475 1478
 						Count:                   prescribing_number_total,
@@ -2163,9 +2166,11 @@ func (c *PatientApiController) ExecDoctorAdvice() {
2163 2166
 								if lastWarehouseOut.ID == 0 {
2164 2167
 									service.AddSelfSigleDrugWarehouseOut(&drugWarehouseOut, tx)
2165 2168
 								}
2169
+								//查询今日是否有出库数据
2170
+								lastWarehouseOutOne, _ := service.GetSelfDrugLastWarehouseOutTwety(adminInfo.Org.Id, advice.AdviceDate, tx, 1)
2166 2171
 								//出库
2167 2172
 								warehouseOutInfo := &models.XtSelfDrugWarehouseOutInfo{
2168
-									WarehouseOutId:          lastWarehouseOut.ID,
2173
+									WarehouseOutId:          lastWarehouseOutOne.ID,
2169 2174
 									WarehouseOutOrderNumber: warehousing_out_order,
2170 2175
 									DrugId:                  advice.DrugId,
2171 2176
 									Count:                   prescribing_number_total,

+ 8 - 4
controllers/patient_api_controller.go View File

@@ -2326,8 +2326,6 @@ func (c *PatientApiController) ExecDoctorAdvice() {
2326 2326
 					prescribing_number_total_one = count
2327 2327
 				}
2328 2328
 
2329
-				fmt.Println("prescribing_number_total_one------------------", prescribing_number_total_one)
2330
-				fmt.Println("selfDrugStockCount.FlushCount", selfDrugStockCount.FlushCount)
2331 2329
 				//库存不足
2332 2330
 				if prescribing_number_total_one > selfDrugStockCount.FlushCount {
2333 2331
 					c.ServeSuccessJSON(map[string]interface{}{
@@ -2771,9 +2769,12 @@ func (c *PatientApiController) ExecDoctorAdvice() {
2771 2769
 						if lastWarehouseOut.ID == 0 {
2772 2770
 							service.AddSelfSigleDrugWarehouseOut(&drugWarehouseOut, tx)
2773 2771
 						}
2772
+
2773
+						//查询今日是否有出库数据
2774
+						lastWarehouseOutOne, _ := service.GetSelfDrugLastWarehouseOutTwety(c.GetAdminUserInfo().CurrentOrgId, advice.AdviceDate, tx, 1)
2774 2775
 						//出库
2775 2776
 						warehouseOutInfo := &models.XtSelfDrugWarehouseOutInfo{
2776
-							WarehouseOutId:          lastWarehouseOut.ID,
2777
+							WarehouseOutId:          lastWarehouseOutOne.ID,
2777 2778
 							WarehouseOutOrderNumber: warehousing_out_order,
2778 2779
 							DrugId:                  advice.DrugId,
2779 2780
 							Count:                   prescribing_number_total,
@@ -3584,9 +3585,12 @@ func (c *PatientApiController) ExecDoctorAdvice() {
3584 3585
 						if lastWarehouseOut.ID == 0 {
3585 3586
 							service.AddSelfSigleDrugWarehouseOut(&drugWarehouseOut, tx)
3586 3587
 						}
3588
+						//查询今日是否有出库数据
3589
+						lastWarehouseOutOne, _ := service.GetSelfDrugLastWarehouseOutTwety(c.GetAdminUserInfo().CurrentOrgId, advice.AdviceDate, tx, 1)
3590
+
3587 3591
 						//出库
3588 3592
 						warehouseOutInfo := &models.XtSelfDrugWarehouseOutInfo{
3589
-							WarehouseOutId:          lastWarehouseOut.ID,
3593
+							WarehouseOutId:          lastWarehouseOutOne.ID,
3590 3594
 							WarehouseOutOrderNumber: warehousing_out_order,
3591 3595
 							DrugId:                  advice.DrugId,
3592 3596
 							Count:                   prescribing_number_total,

+ 64 - 1
models/dialysis.go View File

@@ -514,7 +514,7 @@ type XtDoctorAdvice struct {
514 514
 	WeekDay               string  `gorm:"column:week_day" json:"week_day" form:"week_day"`
515 515
 	TemplateId            string  `gorm:"column:template_id" json:"template_id" form:"template_id"`
516 516
 	UserName              string  `gorm:"column:user_name" json:"user_name" form:"user_name"`
517
-	CheckerName           string  `gorm:"column:user_name" json:"name" form:"name"`
517
+	CheckerName           string  `gorm:"column:name" json:"name" form:"name"`
518 518
 	Modifier              int64   `gorm:"column:modifier" json:"modifier" form:"modifier"`
519 519
 }
520 520
 
@@ -1747,3 +1747,66 @@ type MewTreatmentMode struct {
1747 1747
 func (MewTreatmentMode) TableName() string {
1748 1748
 	return "xt_treatment_mode"
1749 1749
 }
1750
+
1751
+type XtDoctorAdviceOne struct {
1752
+	ID                    int64   `gorm:"column:id" json:"id" form:"id"`
1753
+	UserOrgId             int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1754
+	PatientId             int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1755
+	AdviceType            int64   `gorm:"column:advice_type" json:"advice_type" form:"advice_type"`
1756
+	AdviceDate            int64   `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
1757
+	StartTime             int64   `gorm:"column:start_time" json:"start_time" form:"start_time"`
1758
+	AdviceName            string  `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
1759
+	AdviceDesc            string  `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
1760
+	ReminderDate          int64   `gorm:"column:reminder_date" json:"reminder_date" form:"reminder_date"`
1761
+	SingleDose            float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
1762
+	SingleDoseUnit        string  `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
1763
+	PrescribingNumber     float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
1764
+	PrescribingNumberUnit string  `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
1765
+	DeliveryWay           string  `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
1766
+	ExecutionFrequency    string  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
1767
+	AdviceDoctor          int64   `gorm:"column:advice_doctor" json:"advice_doctor" form:"advice_doctor"`
1768
+	Status                int64   `gorm:"column:status" json:"status" form:"status"`
1769
+	CreatedTime           int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
1770
+	UpdatedTime           int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
1771
+	AdviceAffirm          string  `gorm:"column:advice_affirm" json:"advice_affirm" form:"advice_affirm"`
1772
+	Remark                string  `gorm:"column:remark" json:"remark" form:"remark"`
1773
+	StopTime              int64   `gorm:"column:stop_time" json:"stop_time" form:"stop_time"`
1774
+	StopReason            string  `gorm:"column:stop_reason" json:"stop_reason" form:"stop_reason"`
1775
+	StopDoctor            int64   `gorm:"column:stop_doctor" json:"stop_doctor" form:"stop_doctor"`
1776
+	StopState             int64   `gorm:"column:stop_state" json:"stop_state" form:"stop_state"`
1777
+	ParentId              int64   `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
1778
+	ExecutionTime         int64   `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
1779
+	ExecutionStaff        int64   `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
1780
+	ExecutionState        int64   `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
1781
+	Checker               int64   `gorm:"column:checker" json:"checker" form:"checker"`
1782
+	RecordDate            int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
1783
+	DialysisOrderId       int64   `gorm:"column:dialysis_order_id" json:"dialysis_order_id" form:"dialysis_order_id"`
1784
+	CheckTime             int64   `gorm:"column:check_time" json:"check_time" form:"check_time"`
1785
+	CheckState            int64   `gorm:"column:check_state" json:"check_state" form:"check_state"`
1786
+	DrugSpec              float64 `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
1787
+	DrugSpecUnit          string  `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
1788
+	Groupno               int64   `gorm:"column:groupno" json:"groupno" form:"groupno"`
1789
+	FrequencyType         int64   `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
1790
+	DayCount              int64   `gorm:"column:day_count" json:"day_count" form:"day_count"`
1791
+	WeekDay               string  `gorm:"column:week_day" json:"week_day" form:"week_day"`
1792
+	RemindType            int64   `gorm:"column:remind_type" json:"remind_type" form:"remind_type"`
1793
+	TemplateId            string  `gorm:"column:template_id" json:"template_id" form:"template_id"`
1794
+	Modifier              int64   `gorm:"column:modifier" json:"modifier" form:"modifier"`
1795
+	Way                   int64   `gorm:"column:way" json:"way" form:"way"`
1796
+	DrugId                int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
1797
+	DrugNameId            int64   `gorm:"column:drug_name_id" json:"drug_name_id" form:"drug_name_id"`
1798
+	SyncAdviceId          int64   `gorm:"column:sync_advice_id" json:"sync_advice_id" form:"sync_advice_id"`
1799
+	IsSync                int64   `gorm:"column:is_sync" json:"is_sync" form:"is_sync"`
1800
+	SyncId                string  `gorm:"column:sync_id" json:"sync_id" form:"sync_id"`
1801
+	SyncIdStr             string  `gorm:"column:sync_id_str" json:"sync_id_str" form:"sync_id_str"`
1802
+	IsMedicine            int64   `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
1803
+	People                int64   `gorm:"column:people" json:"people" form:"people"`
1804
+	DispensingTime        int64   `gorm:"column:dispensing_time" json:"dispensing_time" form:"dispensing_time"`
1805
+	PushStartTime         int64   `gorm:"column:push_start_time" json:"push_start_time" form:"push_start_time"`
1806
+	IsSettle              int64   `gorm:"column:is_settle" json:"is_settle" form:"is_settle"`
1807
+	IsPrescription        int64   `gorm:"column:is_prescription" json:"is_prescription" form:"is_prescription"`
1808
+}
1809
+
1810
+func (XtDoctorAdviceOne) TableName() string {
1811
+	return "xt_doctor_advice"
1812
+}

+ 30 - 2
service/dialysis_service.go View File

@@ -2584,9 +2584,16 @@ func CreateMobileAdivce(advice models.DoctorAdvice) error {
2584 2584
 	return err
2585 2585
 }
2586 2586
 
2587
+func CreateMobileAdivceOne(advice models.XtDoctorAdviceOne) error {
2588
+
2589
+	err := XTWriteDB().Create(&advice).Error
2590
+
2591
+	return err
2592
+}
2593
+
2587 2594
 func GetLongDoctorAdviceByPatient(patient_id int64, org_id int64) (advice []*models.XtDoctorAdvice, err error) {
2588 2595
 
2589
-	err = XTReadDB().Where("patient_id = ? and user_org_id = ? and status=1 and advice_type =1", patient_id, org_id).Order("start_time desc").Find(&advice).Error
2596
+	err = XTReadDB().Where("patient_id = ? and user_org_id = ? and status=1 and advice_type =1", patient_id, org_id).Order("start_time asc").Find(&advice).Error
2590 2597
 
2591 2598
 	return advice, err
2592 2599
 }
@@ -2595,8 +2602,29 @@ func GetLastLongAdviceList(user_org_id int64) (models.XtDoctorAdvice, error) {
2595 2602
 
2596 2603
 	advice := models.XtDoctorAdvice{}
2597 2604
 
2598
-	err := XTReadDB().Where("user_org_id =? and stauts=1 and advice_type =1", user_org_id).Last(&advice).Error
2605
+	err := XTReadDB().Where("user_org_id =? and status=1 and advice_type =1", user_org_id).Last(&advice).Error
2599 2606
 
2600 2607
 	return advice, err
2601 2608
 
2602 2609
 }
2610
+
2611
+func DeleteSelfAdviceSubAdvice(id int64) (models.XtDoctorAdviceOne, error) {
2612
+
2613
+	adviceOne := models.XtDoctorAdviceOne{}
2614
+
2615
+	err2 := XTWriteDB().Model(&adviceOne).Where("id = ? and status=1", id).Updates(map[string]interface{}{"status": 0}).Error
2616
+
2617
+	return adviceOne, err2
2618
+}
2619
+
2620
+func UpdateMobileDoctorAdviceById(id int64, advice models.XtDoctorAdviceOne) error {
2621
+
2622
+	err := XTWriteDB().Where("id = ? and status=1", id).Updates(map[string]interface{}{"advice_name": advice.AdviceName, "advice_date": advice.AdviceDate, "start_time": advice.StartTime, "advice_desc": advice.AdviceDesc, "single_dose": advice.SingleDose, "single_dose_unit": advice.SingleDoseUnit, "prescribing_number": advice.PrescribingNumber, "prescribing_number_unit": advice.PrescribingNumberUnit, "delivery_way": advice.DeliveryWay, "execution_frequency": advice.ExecutionFrequency, "remark": advice.Remark}).Error
2623
+	return err
2624
+}
2625
+
2626
+func UpdateMobileDoctorAdviceByIdOne(id int64, advice models.XtDoctorAdviceOne) error {
2627
+
2628
+	err := XTWriteDB().Where("id = ? and status=1", id).Updates(map[string]interface{}{"advice_name": advice.AdviceName, "advice_date": advice.AdviceDate, "start_time": advice.StartTime, "advice_desc": advice.AdviceDesc, "single_dose": advice.SingleDose, "single_dose_unit": advice.SingleDoseUnit, "prescribing_number": advice.PrescribingNumber, "prescribing_number_unit": advice.PrescribingNumberUnit, "delivery_way": advice.DeliveryWay, "execution_frequency": advice.ExecutionFrequency, "remark": advice.Remark, "frequency_type": advice.FrequencyType, "week_day": advice.WeekDay, "day_count": advice.DayCount}).Error
2629
+	return err
2630
+}

+ 8 - 0
service/patient_service.go View File

@@ -4098,3 +4098,11 @@ func UpdateTheatmentPland(id int64, content string) error {
4098 4098
 
4099 4099
 	return err
4100 4100
 }
4101
+
4102
+func GetEditAdviceActionList(id int64, org_id int64) (models.XtDoctorAdviceOne, error) {
4103
+
4104
+	doctorAdviceOne := models.XtDoctorAdviceOne{}
4105
+	err := XTReadDB().Where("id = ? and status=1 and user_org_id = ?", id, org_id).Find(&doctorAdviceOne).Error
4106
+
4107
+	return doctorAdviceOne, err
4108
+}