|
@@ -2174,178 +2174,269 @@ func (c *PatientApiController) GetPrintDialysisOrder() {
|
2174
|
2174
|
}
|
2175
|
2175
|
|
2176
|
2176
|
func (c *PatientApiController) CreateGroupAdvice() {
|
2177
|
|
- patient, _ := c.GetInt64("id", 0)
|
2178
|
|
- if patient <= 0 {
|
2179
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
2180
|
|
- return
|
2181
|
|
- }
|
2182
|
|
- adminUserInfo := c.GetMobileAdminUserInfo()
|
|
2177
|
+ is_child, _ := c.GetInt64("is_child", 0)
|
2183
|
2178
|
|
2184
|
|
- patientInfo, _ := service.FindPatientById(adminUserInfo.Org.Id, patient)
|
2185
|
|
- if patientInfo.ID == 0 {
|
2186
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
|
2187
|
|
- return
|
2188
|
|
- }
|
|
2179
|
+ if is_child == 1 {
|
|
2180
|
+ patient, _ := c.GetInt64("id", 0)
|
|
2181
|
+ if patient <= 0 {
|
|
2182
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
2183
|
+ return
|
|
2184
|
+ }
|
|
2185
|
+ adminUserInfo := c.GetMobileAdminUserInfo()
|
2189
|
2186
|
|
2190
|
|
- group_no, _ := c.GetInt64("group_no")
|
2191
|
|
- if group_no <= 0 {
|
2192
|
|
- group_no = 0
|
2193
|
|
- }
|
|
2187
|
+ patientInfo, _ := service.FindPatientById(adminUserInfo.Org.Id, patient)
|
|
2188
|
+ if patientInfo.ID == 0 {
|
|
2189
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
|
|
2190
|
+ return
|
|
2191
|
+ }
|
2194
|
2192
|
|
2195
|
|
- dataBody := make(map[string]interface{}, 0)
|
2196
|
|
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
|
2197
|
|
- if err != nil {
|
2198
|
|
- utils.ErrorLog(err.Error())
|
2199
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
2200
|
|
- return
|
2201
|
|
- }
|
|
2193
|
+ group_no, _ := c.GetInt64("group_no")
|
|
2194
|
+ if group_no <= 0 {
|
|
2195
|
+ group_no = 0
|
|
2196
|
+ }
|
2202
|
2197
|
|
2203
|
|
- timeLayout := "2006-01-02"
|
2204
|
|
- loc, _ := time.LoadLocation("Local")
|
|
2198
|
+ dataBody := make(map[string]interface{}, 0)
|
|
2199
|
+ err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
|
|
2200
|
+ if err != nil {
|
|
2201
|
+ utils.ErrorLog(err.Error())
|
|
2202
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
2203
|
+ return
|
|
2204
|
+ }
|
2205
|
2205
|
|
2206
|
|
- if dataBody["advice_type"] == nil || reflect.TypeOf(dataBody["advice_type"]).String() != "float64" {
|
2207
|
|
- utils.ErrorLog("advice_type")
|
2208
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
2209
|
|
- return
|
2210
|
|
- }
|
2211
|
|
- adviceType := int64(dataBody["advice_type"].(float64))
|
2212
|
|
- if adviceType != 1 && adviceType != 2 {
|
2213
|
|
- utils.ErrorLog("advice_type != 1&&2")
|
2214
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
2215
|
|
- return
|
2216
|
|
- }
|
|
2206
|
+ timeLayout := "2006-01-02"
|
|
2207
|
+ loc, _ := time.LoadLocation("Local")
|
2217
|
2208
|
|
2218
|
|
- if dataBody["start_time"] == nil || reflect.TypeOf(dataBody["start_time"]).String() != "string" {
|
2219
|
|
- utils.ErrorLog("start_time")
|
2220
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
2221
|
|
- return
|
2222
|
|
- }
|
|
2209
|
+ if dataBody["advice_type"] == nil || reflect.TypeOf(dataBody["advice_type"]).String() != "float64" {
|
|
2210
|
+ utils.ErrorLog("advice_type")
|
|
2211
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
2212
|
+ return
|
|
2213
|
+ }
|
|
2214
|
+ adviceType := int64(dataBody["advice_type"].(float64))
|
|
2215
|
+ if adviceType != 1 && adviceType != 2 {
|
|
2216
|
+ utils.ErrorLog("advice_type != 1&&2")
|
|
2217
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
2218
|
+ return
|
|
2219
|
+ }
|
2223
|
2220
|
|
2224
|
|
- startTime2, _ := dataBody["start_time"].(string)
|
2225
|
|
- time_arr := strings.Split(startTime2, " ")
|
2226
|
|
- if len(time_arr) > 0 {
|
2227
|
|
- startTime2 = time_arr[0]
|
2228
|
|
- }
|
2229
|
|
- if dataBody["advice_date"] == nil || reflect.TypeOf(dataBody["advice_date"]).String() != "string" {
|
2230
|
|
- utils.ErrorLog("advice_date")
|
2231
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
2232
|
|
- return
|
2233
|
|
- }
|
2234
|
|
- adviceDate := startTime2
|
2235
|
|
- if len(adviceDate) == 0 {
|
2236
|
|
- utils.ErrorLog("len(adviceDate) == 0")
|
2237
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
2238
|
|
- return
|
2239
|
|
- }
|
2240
|
|
- theTime, err := time.ParseInLocation(timeLayout, adviceDate, loc)
|
2241
|
|
- if err != nil {
|
2242
|
|
- utils.ErrorLog(err.Error())
|
2243
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
2244
|
|
- return
|
2245
|
|
- }
|
2246
|
|
- AdviceDate := theTime.Unix()
|
2247
|
|
- RecordDate := theTime.Unix()
|
|
2221
|
+ if dataBody["start_time"] == nil || reflect.TypeOf(dataBody["start_time"]).String() != "string" {
|
|
2222
|
+ utils.ErrorLog("start_time")
|
|
2223
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
2224
|
+ return
|
|
2225
|
+ }
|
2248
|
2226
|
|
2249
|
|
- if dataBody["start_time"] == nil || reflect.TypeOf(dataBody["start_time"]).String() != "string" {
|
2250
|
|
- utils.ErrorLog("start_time")
|
2251
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
2252
|
|
- return
|
2253
|
|
- }
|
2254
|
|
- startTime, _ := dataBody["start_time"].(string)
|
2255
|
|
- if len(startTime) == 0 {
|
2256
|
|
- utils.ErrorLog("len(start_time) == 0")
|
2257
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
2258
|
|
- return
|
2259
|
|
- }
|
2260
|
|
- theTime, err = time.ParseInLocation(timeLayout+" 15:04:05", startTime, loc)
|
2261
|
|
- if err != nil {
|
2262
|
|
- utils.ErrorLog(err.Error())
|
2263
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
2264
|
|
- return
|
2265
|
|
- }
|
2266
|
|
- StartTime := theTime.Unix()
|
|
2227
|
+ startTime2, _ := dataBody["start_time"].(string)
|
|
2228
|
+ time_arr := strings.Split(startTime2, " ")
|
|
2229
|
+ if len(time_arr) > 0 {
|
|
2230
|
+ startTime2 = time_arr[0]
|
|
2231
|
+ }
|
|
2232
|
+ if dataBody["advice_date"] == nil || reflect.TypeOf(dataBody["advice_date"]).String() != "string" {
|
|
2233
|
+ utils.ErrorLog("advice_date")
|
|
2234
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
2235
|
+ return
|
|
2236
|
+ }
|
|
2237
|
+ adviceDate := startTime2
|
|
2238
|
+ if len(adviceDate) == 0 {
|
|
2239
|
+ utils.ErrorLog("len(adviceDate) == 0")
|
|
2240
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
2241
|
+ return
|
|
2242
|
+ }
|
|
2243
|
+ theTime, err := time.ParseInLocation(timeLayout, adviceDate, loc)
|
|
2244
|
+ if err != nil {
|
|
2245
|
+ utils.ErrorLog(err.Error())
|
|
2246
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
2247
|
+ return
|
|
2248
|
+ }
|
|
2249
|
+ AdviceDate := theTime.Unix()
|
|
2250
|
+ RecordDate := theTime.Unix()
|
2267
|
2251
|
|
2268
|
|
- Remark := ""
|
2269
|
|
- if dataBody["remark"] != nil && reflect.TypeOf(dataBody["remark"]).String() == "string" {
|
2270
|
|
- remark, _ := dataBody["remark"].(string)
|
2271
|
|
- Remark = remark
|
2272
|
|
- }
|
|
2252
|
+ if dataBody["start_time"] == nil || reflect.TypeOf(dataBody["start_time"]).String() != "string" {
|
|
2253
|
+ utils.ErrorLog("start_time")
|
|
2254
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
2255
|
+ return
|
|
2256
|
+ }
|
|
2257
|
+ startTime, _ := dataBody["start_time"].(string)
|
|
2258
|
+ if len(startTime) == 0 {
|
|
2259
|
+ utils.ErrorLog("len(start_time) == 0")
|
|
2260
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
2261
|
+ return
|
|
2262
|
+ }
|
|
2263
|
+ theTime, err = time.ParseInLocation(timeLayout+" 15:04:05", startTime, loc)
|
|
2264
|
+ if err != nil {
|
|
2265
|
+ utils.ErrorLog(err.Error())
|
|
2266
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
2267
|
+ return
|
|
2268
|
+ }
|
|
2269
|
+ StartTime := theTime.Unix()
|
2273
|
2270
|
|
2274
|
|
- var advices []*models.GroupAdvice
|
2275
|
|
- // utils.TraceLog("%+v", dataBody["adviceNames"])
|
2276
|
|
- if dataBody["adviceNames"] == nil || reflect.TypeOf(dataBody["adviceNames"]).String() != "[]interface {}" {
|
2277
|
|
- utils.ErrorLog("adviceNames")
|
2278
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
2271
|
+ Remark := ""
|
|
2272
|
+ if dataBody["remark"] != nil && reflect.TypeOf(dataBody["remark"]).String() == "string" {
|
|
2273
|
+ remark, _ := dataBody["remark"].(string)
|
|
2274
|
+ Remark = remark
|
|
2275
|
+ }
|
|
2276
|
+
|
|
2277
|
+ var advices []*models.GroupAdvice
|
|
2278
|
+ // utils.TraceLog("%+v", dataBody["adviceNames"])
|
|
2279
|
+ if dataBody["adviceNames"] == nil || reflect.TypeOf(dataBody["adviceNames"]).String() != "[]interface {}" {
|
|
2280
|
+ utils.ErrorLog("adviceNames")
|
|
2281
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
2282
|
+ return
|
|
2283
|
+ }
|
|
2284
|
+ adviceNames := dataBody["adviceNames"].([]interface{})
|
|
2285
|
+ for _, adviceNameMap := range adviceNames {
|
|
2286
|
+ adviceNameM := adviceNameMap.(map[string]interface{})
|
|
2287
|
+ var advice models.GroupAdvice
|
|
2288
|
+ advice.Remark = Remark
|
|
2289
|
+ advice.AdviceType = adviceType
|
|
2290
|
+ advice.StartTime = StartTime
|
|
2291
|
+ advice.AdviceDate = AdviceDate
|
|
2292
|
+ advice.RecordDate = RecordDate
|
|
2293
|
+ advice.Status = 1
|
|
2294
|
+ advice.CreatedTime = time.Now().Unix()
|
|
2295
|
+ advice.UpdatedTime = time.Now().Unix()
|
|
2296
|
+ advice.StopState = 2
|
|
2297
|
+ advice.ExecutionState = 2
|
|
2298
|
+ advice.UserOrgId = adminUserInfo.Org.Id
|
|
2299
|
+ advice.PatientId = patientInfo.ID
|
|
2300
|
+ advice.AdviceDoctor = adminUserInfo.AdminUser.Id
|
|
2301
|
+
|
|
2302
|
+ errcode := c.setAdviceWithJSON(&advice, adviceNameM)
|
|
2303
|
+ if errcode > 0 {
|
|
2304
|
+ c.ServeFailJSONWithSGJErrorCode(errcode)
|
|
2305
|
+ return
|
|
2306
|
+ }
|
|
2307
|
+
|
|
2308
|
+ if adviceNameM["subdrugs"] != nil && reflect.TypeOf(adviceNameM["subdrugs"]).String() == "[]interface {}" {
|
|
2309
|
+ subdrugs := adviceNameM["subdrugs"].([]interface{})
|
|
2310
|
+ if len(subdrugs) > 0 {
|
|
2311
|
+ for _, subdrug := range subdrugs {
|
|
2312
|
+ var s models.GroupAdvice
|
|
2313
|
+ s.Remark = Remark
|
|
2314
|
+ s.AdviceType = adviceType
|
|
2315
|
+ s.StartTime = StartTime
|
|
2316
|
+ s.AdviceDate = AdviceDate
|
|
2317
|
+ s.RecordDate = RecordDate
|
|
2318
|
+ s.Status = 1
|
|
2319
|
+ s.CreatedTime = time.Now().Unix()
|
|
2320
|
+ s.UpdatedTime = time.Now().Unix()
|
|
2321
|
+ s.StopState = 2
|
|
2322
|
+ s.ExecutionState = 2
|
|
2323
|
+ s.UserOrgId = adminUserInfo.Org.Id
|
|
2324
|
+ s.PatientId = patientInfo.ID
|
|
2325
|
+ s.AdviceDoctor = adminUserInfo.AdminUser.Id
|
|
2326
|
+
|
|
2327
|
+ errcode := c.setAdviceWithJSON(&s, subdrug.(map[string]interface{}))
|
|
2328
|
+ if errcode > 0 {
|
|
2329
|
+ c.ServeFailJSONWithSGJErrorCode(errcode)
|
|
2330
|
+ return
|
|
2331
|
+ }
|
|
2332
|
+
|
|
2333
|
+ advice.Children = append(advice.Children, &s)
|
|
2334
|
+ }
|
|
2335
|
+ }
|
|
2336
|
+ }
|
|
2337
|
+
|
|
2338
|
+ advices = append(advices, &advice)
|
|
2339
|
+ }
|
|
2340
|
+
|
|
2341
|
+ newAdvices, createErr := service.CreateMGroupAdvice(adminUserInfo.Org.Id, advices, group_no)
|
|
2342
|
+ if createErr != nil {
|
|
2343
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
|
|
2344
|
+ return
|
|
2345
|
+ }
|
|
2346
|
+
|
|
2347
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
2348
|
+ "msg": "ok",
|
|
2349
|
+ "advices": newAdvices,
|
|
2350
|
+ })
|
2279
|
2351
|
return
|
2280
|
|
- }
|
2281
|
|
- adviceNames := dataBody["adviceNames"].([]interface{})
|
2282
|
|
- for _, adviceNameMap := range adviceNames {
|
2283
|
|
- adviceNameM := adviceNameMap.(map[string]interface{})
|
2284
|
|
- var advice models.GroupAdvice
|
2285
|
|
- advice.Remark = Remark
|
2286
|
|
- advice.AdviceType = adviceType
|
2287
|
|
- advice.StartTime = StartTime
|
2288
|
|
- advice.AdviceDate = AdviceDate
|
2289
|
|
- advice.RecordDate = RecordDate
|
|
2352
|
+
|
|
2353
|
+ } else if is_child == 2 {
|
|
2354
|
+
|
|
2355
|
+ patient, _ := c.GetInt64("id", 0)
|
|
2356
|
+ if patient <= 0 {
|
|
2357
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
2358
|
+ return
|
|
2359
|
+ }
|
|
2360
|
+
|
|
2361
|
+ adminUserInfo := c.GetMobileAdminUserInfo()
|
|
2362
|
+ patientInfo, _ := service.FindPatientById(adminUserInfo.Org.Id, patient)
|
|
2363
|
+ if patientInfo.ID == 0 {
|
|
2364
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
|
|
2365
|
+ return
|
|
2366
|
+ }
|
|
2367
|
+ //appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
|
|
2368
|
+
|
|
2369
|
+ //if appRole.UserType == 3{
|
|
2370
|
+ // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdvicePermissionDeniedModify)
|
|
2371
|
+ // return
|
|
2372
|
+ //}
|
|
2373
|
+
|
|
2374
|
+ //appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
|
|
2375
|
+ //
|
|
2376
|
+ //if appRole.UserType == 3 {
|
|
2377
|
+ // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
|
|
2378
|
+ // if getPermissionErr != nil {
|
|
2379
|
+ // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
2380
|
+ // return
|
|
2381
|
+ // } else if headNursePermission == nil {
|
|
2382
|
+ // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
|
|
2383
|
+ // return
|
|
2384
|
+ // }
|
|
2385
|
+ //}
|
|
2386
|
+
|
|
2387
|
+ var advice models.DoctorAdvice
|
|
2388
|
+ code := adviceFormData(&advice, c.Ctx.Input.RequestBody, "create")
|
|
2389
|
+ if code > 0 {
|
|
2390
|
+ c.ServeFailJSONWithSGJErrorCode(code)
|
|
2391
|
+ return
|
|
2392
|
+ }
|
|
2393
|
+
|
|
2394
|
+ if advice.ParentId > 0 {
|
|
2395
|
+ old, _ := service.FindDoctorAdvice(adminUserInfo.Org.Id, advice.ParentId)
|
|
2396
|
+ if old.ID == 0 || old.PatientId != patient {
|
|
2397
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParentAdviceNotExist)
|
|
2398
|
+ return
|
|
2399
|
+ }
|
|
2400
|
+
|
|
2401
|
+ if old.StopState == 1 || old.ExecutionState == 1 {
|
|
2402
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceStoped)
|
|
2403
|
+ return
|
|
2404
|
+ }
|
|
2405
|
+
|
|
2406
|
+ if old.ParentId > 0 {
|
|
2407
|
+ advice.ParentId = old.ParentId
|
|
2408
|
+ }
|
|
2409
|
+ advice.StartTime = old.StartTime
|
|
2410
|
+ advice.AdviceDoctor = old.AdviceDoctor
|
|
2411
|
+ advice.DeliveryWay = old.DeliveryWay
|
|
2412
|
+ advice.ExecutionFrequency = old.ExecutionFrequency
|
|
2413
|
+ advice.GroupNo = old.GroupNo
|
|
2414
|
+
|
|
2415
|
+ }
|
|
2416
|
+
|
2290
|
2417
|
advice.Status = 1
|
2291
|
2418
|
advice.CreatedTime = time.Now().Unix()
|
2292
|
2419
|
advice.UpdatedTime = time.Now().Unix()
|
2293
|
2420
|
advice.StopState = 2
|
2294
|
2421
|
advice.ExecutionState = 2
|
2295
|
2422
|
advice.UserOrgId = adminUserInfo.Org.Id
|
2296
|
|
- advice.PatientId = patientInfo.ID
|
|
2423
|
+ advice.PatientId = patient
|
2297
|
2424
|
advice.AdviceDoctor = adminUserInfo.AdminUser.Id
|
2298
|
2425
|
|
2299
|
|
- errcode := c.setAdviceWithJSON(&advice, adviceNameM)
|
2300
|
|
- if errcode > 0 {
|
2301
|
|
- c.ServeFailJSONWithSGJErrorCode(errcode)
|
|
2426
|
+ err := service.CreateDoctorAdvice(&advice)
|
|
2427
|
+ if err != nil {
|
|
2428
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
|
2302
|
2429
|
return
|
2303
|
2430
|
}
|
2304
|
2431
|
|
2305
|
|
- if adviceNameM["subdrugs"] != nil && reflect.TypeOf(adviceNameM["subdrugs"]).String() == "[]interface {}" {
|
2306
|
|
- subdrugs := adviceNameM["subdrugs"].([]interface{})
|
2307
|
|
- if len(subdrugs) > 0 {
|
2308
|
|
- for _, subdrug := range subdrugs {
|
2309
|
|
- var s models.GroupAdvice
|
2310
|
|
- s.Remark = Remark
|
2311
|
|
- s.AdviceType = adviceType
|
2312
|
|
- s.StartTime = StartTime
|
2313
|
|
- s.AdviceDate = AdviceDate
|
2314
|
|
- s.RecordDate = RecordDate
|
2315
|
|
- s.Status = 1
|
2316
|
|
- s.CreatedTime = time.Now().Unix()
|
2317
|
|
- s.UpdatedTime = time.Now().Unix()
|
2318
|
|
- s.StopState = 2
|
2319
|
|
- s.ExecutionState = 2
|
2320
|
|
- s.UserOrgId = adminUserInfo.Org.Id
|
2321
|
|
- s.PatientId = patientInfo.ID
|
2322
|
|
- s.AdviceDoctor = adminUserInfo.AdminUser.Id
|
2323
|
|
-
|
2324
|
|
- errcode := c.setAdviceWithJSON(&s, subdrug.(map[string]interface{}))
|
2325
|
|
- if errcode > 0 {
|
2326
|
|
- c.ServeFailJSONWithSGJErrorCode(errcode)
|
2327
|
|
- return
|
2328
|
|
- }
|
2329
|
|
-
|
2330
|
|
- advice.Children = append(advice.Children, &s)
|
2331
|
|
- }
|
2332
|
|
- }
|
2333
|
|
- }
|
2334
|
|
-
|
2335
|
|
- advices = append(advices, &advice)
|
2336
|
|
- }
|
2337
|
|
-
|
2338
|
|
- newAdvices, createErr := service.CreateMGroupAdvice(adminUserInfo.Org.Id, advices, group_no)
|
2339
|
|
- if createErr != nil {
|
2340
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
|
|
2432
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
2433
|
+ "msg": "ok",
|
|
2434
|
+ "advice": advice,
|
|
2435
|
+ })
|
2341
|
2436
|
return
|
|
2437
|
+
|
2342
|
2438
|
}
|
2343
|
2439
|
|
2344
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
2345
|
|
- "msg": "ok",
|
2346
|
|
- "advices": newAdvices,
|
2347
|
|
- })
|
2348
|
|
- return
|
2349
|
2440
|
}
|
2350
|
2441
|
|
2351
|
2442
|
func (c *PatientApiController) setAdviceWithJSON(advice *models.GroupAdvice, json map[string]interface{}) int {
|