|
@@ -6516,6 +6516,8 @@ func (c *HisApiController) GetHisOrderList() {
|
6516
|
6516
|
org_id := adminUser.CurrentOrgId
|
6517
|
6517
|
order, err, total := service.GetHisOrderList(org_id, page, limit, startTime, endTime, types, keywords, p_type, sort_type, start_time, end_time, charge_type, sch_type, zone_type, med_type)
|
6518
|
6518
|
|
|
6519
|
+ order2, _ := service.GetNewHisOrderListTwo(org_id, startTime, endTime)
|
|
6520
|
+
|
6519
|
6521
|
for _, item := range order {
|
6520
|
6522
|
info, _ := service.GetHisPrescriptionByPatientID(item.PatientId, item.UserOrgId)
|
6521
|
6523
|
item.DoctorName = info.Doctor
|
|
@@ -6524,8 +6526,9 @@ func (c *HisApiController) GetHisOrderList() {
|
6524
|
6526
|
|
6525
|
6527
|
if err == nil {
|
6526
|
6528
|
c.ServeSuccessJSON(map[string]interface{}{
|
6527
|
|
- "order": order,
|
6528
|
|
- "total": total,
|
|
6529
|
+ "order": order,
|
|
6530
|
+ "order2": order2,
|
|
6531
|
+ "total": total,
|
6529
|
6532
|
})
|
6530
|
6533
|
|
6531
|
6534
|
} else {
|
|
@@ -10253,193 +10256,208 @@ func (c *HisApiController) CreateHisPrescriptionTemplate() {
|
10253
|
10256
|
//如果已经存在记录则删除处方
|
10254
|
10257
|
if template_one.ID > 0 {
|
10255
|
10258
|
ps, _ := service.GetHisPrescriptionInfoTemplates(template_one.ID, template_one.UserOrgId)
|
|
10259
|
+ var ids []int64
|
|
10260
|
+ var org_id int64
|
10256
|
10261
|
for _, item := range ps {
|
10257
|
|
- service.DelelteHisPrescriptionInfoTemplate(item.ID, item.UserOrgId)
|
|
10262
|
+ org_id = c.GetAdminUserInfo().CurrentOrgId
|
|
10263
|
+ ids = append(ids, item.ID)
|
10258
|
10264
|
}
|
10259
|
|
- if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
|
10260
|
|
- prescriptions, _ := dataBody["prescriptions"].([]interface{})
|
10261
|
|
- if len(prescriptions) > 0 {
|
10262
|
|
- for _, item := range prescriptions {
|
10263
|
|
- items := item.(map[string]interface{})
|
10264
|
|
- if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
|
10265
|
|
- utils.ErrorLog("type")
|
10266
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
10267
|
|
- return
|
10268
|
|
- }
|
10269
|
|
- types := int64(items["type"].(float64))
|
|
10265
|
+ err2 := service.BatchDelelteHisPrescriptionInfoTemplate(ids, org_id)
|
10270
|
10266
|
|
10271
|
|
- if items["med_type"] == nil || reflect.TypeOf(items["med_type"]).String() != "float64" {
|
10272
|
|
- utils.ErrorLog("med_type")
|
10273
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
10274
|
|
- return
|
10275
|
|
- }
|
10276
|
|
- med_type := strconv.Itoa(int(items["med_type"].(float64)))
|
|
10267
|
+ if err2 == nil {
|
|
10268
|
+ if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
|
|
10269
|
+ prescriptions, _ := dataBody["prescriptions"].([]interface{})
|
|
10270
|
+ if len(prescriptions) > 0 {
|
|
10271
|
+ for _, item := range prescriptions {
|
|
10272
|
+ items := item.(map[string]interface{})
|
|
10273
|
+ if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
|
|
10274
|
+ utils.ErrorLog("type")
|
|
10275
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
10276
|
+ return
|
|
10277
|
+ }
|
|
10278
|
+ types := int64(items["type"].(float64))
|
10277
|
10279
|
|
10278
|
|
- ctime := time.Now().Unix()
|
10279
|
|
- prescription := &models.HisPrescriptionInfoTemplate{
|
10280
|
|
- PatientId: patient_id,
|
10281
|
|
- UserOrgId: adminInfo.CurrentOrgId,
|
10282
|
|
- Ctime: ctime,
|
10283
|
|
- Mtime: ctime,
|
10284
|
|
- Type: types,
|
10285
|
|
- Modifier: adminInfo.AdminUser.Id,
|
10286
|
|
- Creator: adminInfo.AdminUser.Id,
|
10287
|
|
- Status: 1,
|
10288
|
|
- PTemplateId: template_one.ID,
|
10289
|
|
- MedType: med_type,
|
10290
|
|
- }
|
10291
|
|
- service.CreateHisPrescriptionInfoTemplate(prescription)
|
|
10280
|
+ if items["med_type"] == nil || reflect.TypeOf(items["med_type"]).String() != "float64" {
|
|
10281
|
+ utils.ErrorLog("med_type")
|
|
10282
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
10283
|
+ return
|
|
10284
|
+ }
|
|
10285
|
+ med_type := strconv.Itoa(int(items["med_type"].(float64)))
|
10292
|
10286
|
|
10293
|
|
- if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
|
10294
|
|
- advices := items["advices"].([]interface{})
|
10295
|
|
- //group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
|
10296
|
10287
|
ctime := time.Now().Unix()
|
10297
|
|
- mtime := ctime
|
10298
|
|
- if len(advices) > 0 {
|
10299
|
|
- for _, advice := range advices {
|
10300
|
|
- var s models.HisPrescriptionAdviceTemplate
|
10301
|
|
- s.PrescriptionId = prescription.ID
|
10302
|
|
- s.AdviceType = 2
|
10303
|
|
- s.StopState = 2
|
10304
|
|
- s.ExecutionState = 2
|
10305
|
|
- s.Status = 1
|
10306
|
|
- s.UserOrgId = adminInfo.CurrentOrgId
|
10307
|
|
- s.CreatedTime = ctime
|
10308
|
|
- s.UpdatedTime = mtime
|
10309
|
|
- s.PatientId = patient_id
|
10310
|
|
- errcode := c.setAdviceTemplateWithJSON(&s, advice.(map[string]interface{}))
|
10311
|
|
- if errcode > 0 {
|
10312
|
|
- c.ServeFailJSONWithSGJErrorCode(errcode)
|
10313
|
|
- return
|
10314
|
|
- }
|
|
10288
|
+ prescription := &models.HisPrescriptionInfoTemplate{
|
|
10289
|
+ PatientId: patient_id,
|
|
10290
|
+ UserOrgId: adminInfo.CurrentOrgId,
|
|
10291
|
+ Ctime: ctime,
|
|
10292
|
+ Mtime: ctime,
|
|
10293
|
+ Type: types,
|
|
10294
|
+ Modifier: adminInfo.AdminUser.Id,
|
|
10295
|
+ Creator: adminInfo.AdminUser.Id,
|
|
10296
|
+ Status: 1,
|
|
10297
|
+ PTemplateId: template_one.ID,
|
|
10298
|
+ MedType: med_type,
|
|
10299
|
+ }
|
|
10300
|
+ service.CreateHisPrescriptionInfoTemplate(prescription)
|
|
10301
|
+
|
|
10302
|
+ if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
|
|
10303
|
+ advices := items["advices"].([]interface{})
|
|
10304
|
+ //group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
|
|
10305
|
+ ctime := time.Now().Unix()
|
|
10306
|
+ mtime := ctime
|
|
10307
|
+ if len(advices) > 0 {
|
|
10308
|
+ for _, advice := range advices {
|
|
10309
|
+ var s models.HisPrescriptionAdviceTemplate
|
|
10310
|
+ s.PrescriptionId = prescription.ID
|
|
10311
|
+ s.AdviceType = 2
|
|
10312
|
+ s.StopState = 2
|
|
10313
|
+ s.ExecutionState = 2
|
|
10314
|
+ s.Status = 1
|
|
10315
|
+ s.UserOrgId = adminInfo.CurrentOrgId
|
|
10316
|
+ s.CreatedTime = ctime
|
|
10317
|
+ s.UpdatedTime = mtime
|
|
10318
|
+ s.PatientId = patient_id
|
|
10319
|
+ errcode := c.setAdviceTemplateWithJSON(&s, advice.(map[string]interface{}))
|
|
10320
|
+ if errcode > 0 {
|
|
10321
|
+ c.ServeFailJSONWithSGJErrorCode(errcode)
|
|
10322
|
+ return
|
|
10323
|
+ }
|
10315
|
10324
|
|
10316
|
|
- service.CreateHisPrescriptionAdviceTemplate(&s)
|
|
10325
|
+ service.CreateHisPrescriptionAdviceTemplate(&s)
|
10317
|
10326
|
|
|
10327
|
+ }
|
10318
|
10328
|
}
|
10319
|
10329
|
}
|
10320
|
|
- }
|
10321
|
|
- if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
|
10322
|
|
- projects := items["project"].([]interface{})
|
10323
|
|
- if len(projects) > 0 {
|
10324
|
|
- for _, project := range projects {
|
10325
|
|
- var p models.HisPrescriptionProjectTemplate
|
10326
|
|
- p.PrescriptionId = prescription.ID
|
10327
|
|
- p.Ctime = time.Now().Unix()
|
10328
|
|
- p.Mtime = time.Now().Unix()
|
10329
|
|
- p.PatientId = patient_id
|
10330
|
|
- p.UserOrgId = adminInfo.CurrentOrgId
|
10331
|
|
- p.Status = 1
|
10332
|
|
- errcode := c.setProjectTemplateWithJSON(&p, project.(map[string]interface{}))
|
10333
|
|
- if errcode > 0 {
|
10334
|
|
- c.ServeFailJSONWithSGJErrorCode(errcode)
|
10335
|
|
- return
|
10336
|
|
- }
|
10337
|
|
- service.CreateHisPrescriptionProjectTemplate(&p)
|
|
10330
|
+ if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
|
|
10331
|
+ projects := items["project"].([]interface{})
|
|
10332
|
+ if len(projects) > 0 {
|
|
10333
|
+ for _, project := range projects {
|
|
10334
|
+ var p models.HisPrescriptionProjectTemplate
|
|
10335
|
+ p.PrescriptionId = prescription.ID
|
|
10336
|
+ p.Ctime = time.Now().Unix()
|
|
10337
|
+ p.Mtime = time.Now().Unix()
|
|
10338
|
+ p.PatientId = patient_id
|
|
10339
|
+ p.UserOrgId = adminInfo.CurrentOrgId
|
|
10340
|
+ p.Status = 1
|
|
10341
|
+ errcode := c.setProjectTemplateWithJSON(&p, project.(map[string]interface{}))
|
|
10342
|
+ if errcode > 0 {
|
|
10343
|
+ c.ServeFailJSONWithSGJErrorCode(errcode)
|
|
10344
|
+ return
|
|
10345
|
+ }
|
|
10346
|
+ service.CreateHisPrescriptionProjectTemplate(&p)
|
10338
|
10347
|
|
|
10348
|
+ }
|
10339
|
10349
|
}
|
10340
|
10350
|
}
|
|
10351
|
+
|
10341
|
10352
|
}
|
10342
|
10353
|
|
|
10354
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
10355
|
+ "msg": "创建成功",
|
|
10356
|
+ })
|
10343
|
10357
|
}
|
10344
|
|
-
|
10345
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
10346
|
|
- "msg": "创建成功",
|
10347
|
|
- })
|
10348
|
10358
|
}
|
|
10359
|
+ } else {
|
|
10360
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
10361
|
+ return
|
10349
|
10362
|
}
|
10350
|
10363
|
|
10351
|
10364
|
} else {
|
10352
|
|
- err = service.CreateHisPrescriptionTemplate(template)
|
10353
|
|
- if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
|
10354
|
|
- prescriptions, _ := dataBody["prescriptions"].([]interface{})
|
10355
|
|
- if len(prescriptions) > 0 {
|
10356
|
|
- for _, item := range prescriptions {
|
10357
|
|
- items := item.(map[string]interface{})
|
10358
|
|
- if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
|
10359
|
|
- utils.ErrorLog("type")
|
10360
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
10361
|
|
- return
|
10362
|
|
- }
|
10363
|
|
- types := int64(items["type"].(float64))
|
10364
|
|
-
|
10365
|
|
- if items["med_type"] == nil || reflect.TypeOf(items["med_type"]).String() != "float64" {
|
10366
|
|
- utils.ErrorLog("med_type")
|
10367
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
10368
|
|
- return
|
10369
|
|
- }
|
10370
|
|
- med_type := strconv.Itoa(int(items["med_type"].(float64)))
|
|
10365
|
+ err3 := service.CreateHisPrescriptionTemplate(template)
|
|
10366
|
+ if err3 == nil {
|
|
10367
|
+ if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
|
|
10368
|
+ prescriptions, _ := dataBody["prescriptions"].([]interface{})
|
|
10369
|
+ if len(prescriptions) > 0 {
|
|
10370
|
+ for _, item := range prescriptions {
|
|
10371
|
+ items := item.(map[string]interface{})
|
|
10372
|
+ if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
|
|
10373
|
+ utils.ErrorLog("type")
|
|
10374
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
10375
|
+ return
|
|
10376
|
+ }
|
|
10377
|
+ types := int64(items["type"].(float64))
|
10371
|
10378
|
|
10372
|
|
- ctime := time.Now().Unix()
|
10373
|
|
- prescription := &models.HisPrescriptionInfoTemplate{
|
10374
|
|
- PatientId: patient_id,
|
10375
|
|
- UserOrgId: adminInfo.CurrentOrgId,
|
10376
|
|
- Ctime: ctime,
|
10377
|
|
- Mtime: ctime,
|
10378
|
|
- Type: types,
|
10379
|
|
- Modifier: adminInfo.AdminUser.Id,
|
10380
|
|
- Creator: adminInfo.AdminUser.Id,
|
10381
|
|
- Status: 1,
|
10382
|
|
- PTemplateId: template.ID,
|
10383
|
|
- MedType: med_type,
|
10384
|
|
- }
|
10385
|
|
- service.CreateHisPrescriptionInfoTemplate(prescription)
|
|
10379
|
+ if items["med_type"] == nil || reflect.TypeOf(items["med_type"]).String() != "float64" {
|
|
10380
|
+ utils.ErrorLog("med_type")
|
|
10381
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
10382
|
+ return
|
|
10383
|
+ }
|
|
10384
|
+ med_type := strconv.Itoa(int(items["med_type"].(float64)))
|
10386
|
10385
|
|
10387
|
|
- if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
|
10388
|
|
- advices := items["advices"].([]interface{})
|
10389
|
|
- //group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
|
10390
|
10386
|
ctime := time.Now().Unix()
|
10391
|
|
- mtime := ctime
|
10392
|
|
- if len(advices) > 0 {
|
10393
|
|
- for _, advice := range advices {
|
10394
|
|
- var s models.HisPrescriptionAdviceTemplate
|
10395
|
|
- s.PrescriptionId = prescription.ID
|
10396
|
|
- s.AdviceType = 2
|
10397
|
|
- s.StopState = 2
|
10398
|
|
- s.ExecutionState = 2
|
10399
|
|
- s.Status = 1
|
10400
|
|
- s.UserOrgId = adminInfo.CurrentOrgId
|
10401
|
|
- s.CreatedTime = ctime
|
10402
|
|
- s.UpdatedTime = mtime
|
10403
|
|
- s.PatientId = patient_id
|
10404
|
|
- errcode := c.setAdviceTemplateWithJSON(&s, advice.(map[string]interface{}))
|
10405
|
|
- if errcode > 0 {
|
10406
|
|
- c.ServeFailJSONWithSGJErrorCode(errcode)
|
10407
|
|
- return
|
10408
|
|
- }
|
|
10387
|
+ prescription := &models.HisPrescriptionInfoTemplate{
|
|
10388
|
+ PatientId: patient_id,
|
|
10389
|
+ UserOrgId: adminInfo.CurrentOrgId,
|
|
10390
|
+ Ctime: ctime,
|
|
10391
|
+ Mtime: ctime,
|
|
10392
|
+ Type: types,
|
|
10393
|
+ Modifier: adminInfo.AdminUser.Id,
|
|
10394
|
+ Creator: adminInfo.AdminUser.Id,
|
|
10395
|
+ Status: 1,
|
|
10396
|
+ PTemplateId: template.ID,
|
|
10397
|
+ MedType: med_type,
|
|
10398
|
+ }
|
|
10399
|
+ service.CreateHisPrescriptionInfoTemplate(prescription)
|
|
10400
|
+
|
|
10401
|
+ if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
|
|
10402
|
+ advices := items["advices"].([]interface{})
|
|
10403
|
+ //group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
|
|
10404
|
+ ctime := time.Now().Unix()
|
|
10405
|
+ mtime := ctime
|
|
10406
|
+ if len(advices) > 0 {
|
|
10407
|
+ for _, advice := range advices {
|
|
10408
|
+ var s models.HisPrescriptionAdviceTemplate
|
|
10409
|
+ s.PrescriptionId = prescription.ID
|
|
10410
|
+ s.AdviceType = 2
|
|
10411
|
+ s.StopState = 2
|
|
10412
|
+ s.ExecutionState = 2
|
|
10413
|
+ s.Status = 1
|
|
10414
|
+ s.UserOrgId = adminInfo.CurrentOrgId
|
|
10415
|
+ s.CreatedTime = ctime
|
|
10416
|
+ s.UpdatedTime = mtime
|
|
10417
|
+ s.PatientId = patient_id
|
|
10418
|
+ errcode := c.setAdviceTemplateWithJSON(&s, advice.(map[string]interface{}))
|
|
10419
|
+ if errcode > 0 {
|
|
10420
|
+ c.ServeFailJSONWithSGJErrorCode(errcode)
|
|
10421
|
+ return
|
|
10422
|
+ }
|
10409
|
10423
|
|
10410
|
|
- service.CreateHisPrescriptionAdviceTemplate(&s)
|
|
10424
|
+ service.CreateHisPrescriptionAdviceTemplate(&s)
|
10411
|
10425
|
|
|
10426
|
+ }
|
10412
|
10427
|
}
|
10413
|
10428
|
}
|
10414
|
|
- }
|
10415
|
|
- if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
|
10416
|
|
- projects := items["project"].([]interface{})
|
10417
|
|
- if len(projects) > 0 {
|
10418
|
|
- for _, project := range projects {
|
10419
|
|
- var p models.HisPrescriptionProjectTemplate
|
10420
|
|
- p.PrescriptionId = prescription.ID
|
10421
|
|
- p.Ctime = time.Now().Unix()
|
10422
|
|
- p.Mtime = time.Now().Unix()
|
10423
|
|
- p.PatientId = patient_id
|
10424
|
|
- p.UserOrgId = adminInfo.CurrentOrgId
|
10425
|
|
- p.Status = 1
|
10426
|
|
- errcode := c.setProjectTemplateWithJSON(&p, project.(map[string]interface{}))
|
10427
|
|
- if errcode > 0 {
|
10428
|
|
- c.ServeFailJSONWithSGJErrorCode(errcode)
|
10429
|
|
- return
|
10430
|
|
- }
|
10431
|
|
- service.CreateHisPrescriptionProjectTemplate(&p)
|
|
10429
|
+ if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
|
|
10430
|
+ projects := items["project"].([]interface{})
|
|
10431
|
+ if len(projects) > 0 {
|
|
10432
|
+ for _, project := range projects {
|
|
10433
|
+ var p models.HisPrescriptionProjectTemplate
|
|
10434
|
+ p.PrescriptionId = prescription.ID
|
|
10435
|
+ p.Ctime = time.Now().Unix()
|
|
10436
|
+ p.Mtime = time.Now().Unix()
|
|
10437
|
+ p.PatientId = patient_id
|
|
10438
|
+ p.UserOrgId = adminInfo.CurrentOrgId
|
|
10439
|
+ p.Status = 1
|
|
10440
|
+ errcode := c.setProjectTemplateWithJSON(&p, project.(map[string]interface{}))
|
|
10441
|
+ if errcode > 0 {
|
|
10442
|
+ c.ServeFailJSONWithSGJErrorCode(errcode)
|
|
10443
|
+ return
|
|
10444
|
+ }
|
|
10445
|
+ service.CreateHisPrescriptionProjectTemplate(&p)
|
10432
|
10446
|
|
|
10447
|
+ }
|
10433
|
10448
|
}
|
10434
|
10449
|
}
|
|
10450
|
+
|
10435
|
10451
|
}
|
10436
|
10452
|
|
|
10453
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
10454
|
+ "msg": "创建成功",
|
|
10455
|
+ })
|
10437
|
10456
|
}
|
10438
|
|
-
|
10439
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
10440
|
|
- "msg": "创建成功",
|
10441
|
|
- })
|
10442
|
10457
|
}
|
|
10458
|
+ } else {
|
|
10459
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
10460
|
+ return
|
10443
|
10461
|
}
|
10444
|
10462
|
}
|
10445
|
10463
|
|