|
@@ -99,6 +99,12 @@ func DialysisApiRegistRouters() {
|
99
|
99
|
beego.Router("/api/patient/getscheduleprintlist", &DialysisApiController{}, "Get:GetSchedulePrintList")
|
100
|
100
|
|
101
|
101
|
beego.Router("/api/patient/getsolutionlistbyorgid", &DialysisApiController{}, "Get:GetSolutionListByOrgId")
|
|
102
|
+
|
|
103
|
+ beego.Router("/api/schedule/excutiondoctoradvice", &DialysisApiController{}, "Get:ExcutionDoctorAdvice")
|
|
104
|
+
|
|
105
|
+ beego.Router("/api/schedule/checknewdoctoradvice", &DialysisApiController{}, "Get:CheckNewDoctorAdvice")
|
|
106
|
+
|
|
107
|
+ beego.Router("/api/schedule/settlenewdoctoradvice", &DialysisApiController{}, "Get:SettleNewDoctorAdvice")
|
102
|
108
|
}
|
103
|
109
|
|
104
|
110
|
func (c *DialysisApiController) GetQueueCall() {
|
|
@@ -311,6 +317,8 @@ func (c *DialysisApiController) PostPrescription() {
|
311
|
317
|
drhy_water := c.GetString("drhy_water")
|
312
|
318
|
dry_water_hour := c.GetString("dry_water_hour")
|
313
|
319
|
water_machine := c.GetString("water_machine")
|
|
320
|
+ add_amount, _ := c.GetFloat("add_amount")
|
|
321
|
+ reduce_amount, _ := c.GetFloat("reduce_amount")
|
314
|
322
|
appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
|
315
|
323
|
//template, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
|
316
|
324
|
|
|
@@ -416,6 +424,8 @@ func (c *DialysisApiController) PostPrescription() {
|
416
|
424
|
DrhyWater: drhy_water,
|
417
|
425
|
DryWaterHour: dry_water_hour,
|
418
|
426
|
WaterMachine: water_machine,
|
|
427
|
+ AddAmount: add_amount,
|
|
428
|
+ ReduceAmount: reduce_amount,
|
419
|
429
|
}
|
420
|
430
|
|
421
|
431
|
if appRole.UserType == 2 || appRole.UserType == 1 {
|
|
@@ -645,6 +655,8 @@ func (c *DialysisApiController) PostSoulution() {
|
645
|
655
|
dry_water_hour := c.GetString("dry_water_hour")
|
646
|
656
|
drhy_water := c.GetString("drhy_water")
|
647
|
657
|
water_machine := c.GetString("water_machine")
|
|
658
|
+ add_amount, _ := c.GetFloat("add_amount")
|
|
659
|
+ reduce_amount, _ := c.GetFloat("reduce_amount")
|
648
|
660
|
var prescription_doctor int64
|
649
|
661
|
appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
|
650
|
662
|
|
|
@@ -762,6 +774,8 @@ func (c *DialysisApiController) PostSoulution() {
|
762
|
774
|
DryWaterHour: dry_water_hour,
|
763
|
775
|
DrhyWater: drhy_water,
|
764
|
776
|
WaterMachine: water_machine,
|
|
777
|
+ AddAmount: add_amount,
|
|
778
|
+ ReduceAmount: reduce_amount,
|
765
|
779
|
}
|
766
|
780
|
|
767
|
781
|
//查询最近透析准备表里是否存在 透析器 灌流器
|
|
@@ -3692,15 +3706,16 @@ func (c *DialysisApiController) GetSolution() {
|
3692
|
3706
|
solution, err := service.MobileGetDialysisSolutionByModeIdSix(adminUserInfo.CurrentOrgId, patient_id, mode_id)
|
3693
|
3707
|
prescription, err := service.MobileGetLastDialysisPrescribeByModeIdSix(adminUserInfo.CurrentOrgId, patient_id, mode_id)
|
3694
|
3708
|
system_prescription, err := service.MobileGetSystemDialysisPrescribeByModeIdSix(adminUserInfo.CurrentOrgId, mode_id)
|
3695
|
|
-
|
|
3709
|
+ dialysisPrescription, _ := service.MobileGetLastDialysisPrescription(patient_id, adminUserInfo.CurrentOrgId)
|
3696
|
3710
|
if err != nil {
|
3697
|
3711
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
3698
|
3712
|
return
|
3699
|
3713
|
}
|
3700
|
3714
|
c.ServeSuccessJSON(map[string]interface{}{
|
3701
|
|
- "solution": solution,
|
3702
|
|
- "prescription": prescription,
|
3703
|
|
- "system_prescription": system_prescription,
|
|
3715
|
+ "solution": solution,
|
|
3716
|
+ "prescription": prescription,
|
|
3717
|
+ "system_prescription": system_prescription,
|
|
3718
|
+ "dialysisPrescription": dialysisPrescription,
|
3704
|
3719
|
})
|
3705
|
3720
|
|
3706
|
3721
|
}
|
|
@@ -4722,3 +4737,396 @@ func (this *DialysisApiController) GetSolutionListByOrgId() {
|
4722
|
4737
|
})
|
4723
|
4738
|
|
4724
|
4739
|
}
|
|
4740
|
+
|
|
4741
|
+func (this *DialysisApiController) ExcutionDoctorAdvice() {
|
|
4742
|
+
|
|
4743
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
4744
|
+ is_open, _ := this.GetInt64("is_open")
|
|
4745
|
+ idsStr := this.GetString("str")
|
|
4746
|
+ recordIDStrs := strings.Split(idsStr, ",")
|
|
4747
|
+ start_time := this.GetString("advice_date")
|
|
4748
|
+ exec_time, _ := this.GetInt64("exec_time")
|
|
4749
|
+ timeLayout := "2006-01-02"
|
|
4750
|
+ loc, _ := time.LoadLocation("Local")
|
|
4751
|
+ var startTime int64
|
|
4752
|
+ if len(start_time) > 0 {
|
|
4753
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
|
|
4754
|
+ if err != nil {
|
|
4755
|
+ //fmt.Println(err)
|
|
4756
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
4757
|
+ return
|
|
4758
|
+ }
|
|
4759
|
+ startTime = theTime.Unix()
|
|
4760
|
+ }
|
|
4761
|
+ config, _ := service.GetDrugOpenConfigOne(orgId)
|
|
4762
|
+ pharmacyConfig, _ := service.FindPharmacyConfig(orgId)
|
|
4763
|
+ storeHouseConfig, _ := service.GetAllStoreHouseConfig(orgId)
|
|
4764
|
+ //his医嘱
|
|
4765
|
+ if is_open == 1 {
|
|
4766
|
+
|
|
4767
|
+ groupList, _ := service.GetHisExcutionDoctorAdviceListGroupList(recordIDStrs, startTime, orgId)
|
|
4768
|
+ //查找未执行医嘱
|
|
4769
|
+ list, _ := service.GetHisExcutionDoctorAdviceList(recordIDStrs, startTime, orgId)
|
|
4770
|
+ for _, item := range groupList {
|
|
4771
|
+ for _, it := range list {
|
|
4772
|
+ if item.DrugId == it.DrugId {
|
|
4773
|
+ item.ChildDoctorAdvice = append(item.ChildDoctorAdvice, it)
|
|
4774
|
+ }
|
|
4775
|
+ }
|
|
4776
|
+ }
|
|
4777
|
+
|
|
4778
|
+ for _, item := range groupList {
|
|
4779
|
+ medical, _ := service.GetBaseDrugMedical(item.DrugId)
|
|
4780
|
+ var sum_out_count int64
|
|
4781
|
+ for _, it := range item.ChildDoctorAdvice {
|
|
4782
|
+ var prescribing_number int64
|
|
4783
|
+ stringPrescribingNumber := strconv.FormatFloat(it.PrescribingNumber, 'f', -1, 64)
|
|
4784
|
+ parseIntPrescribingNumber, _ := strconv.ParseInt(stringPrescribingNumber, 10, 64)
|
|
4785
|
+ if it.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
|
|
4786
|
+ prescribing_number = parseIntPrescribingNumber * medical.MinNumber
|
|
4787
|
+ }
|
|
4788
|
+ if it.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
|
|
4789
|
+ prescribing_number = parseIntPrescribingNumber
|
|
4790
|
+ }
|
|
4791
|
+ if it.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
|
|
4792
|
+ prescribing_number = parseIntPrescribingNumber
|
|
4793
|
+ }
|
|
4794
|
+ sum_out_count += prescribing_number
|
|
4795
|
+ drugStockOut, _ := service.GetDrugSumOutCountByDrugId(it.DrugId, orgId)
|
|
4796
|
+ //库存不足
|
|
4797
|
+ if sum_out_count > drugStockOut.FlushCount {
|
|
4798
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
4799
|
+ "msg": "2",
|
|
4800
|
+ "drug": medical,
|
|
4801
|
+ })
|
|
4802
|
+ return
|
|
4803
|
+ }
|
|
4804
|
+ }
|
|
4805
|
+ }
|
|
4806
|
+
|
|
4807
|
+ //执行出库逻辑
|
|
4808
|
+ for _, item := range list {
|
|
4809
|
+ hisadvice := &models.HisDoctorAdviceInfo{
|
|
4810
|
+ ID: item.ID,
|
|
4811
|
+ UserOrgId: item.UserOrgId,
|
|
4812
|
+ PatientId: item.PatientId,
|
|
4813
|
+ AdviceType: item.AdviceType,
|
|
4814
|
+ AdviceDate: item.AdviceDate,
|
|
4815
|
+ StartTime: item.StartTime,
|
|
4816
|
+ AdviceName: item.AdviceName,
|
|
4817
|
+ AdviceDesc: item.AdviceDesc,
|
|
4818
|
+ ReminderDate: item.ReminderDate,
|
|
4819
|
+ SingleDose: item.SingleDose,
|
|
4820
|
+ SingleDoseUnit: item.SingleDoseUnit,
|
|
4821
|
+ DrugSpec: item.DrugSpec,
|
|
4822
|
+ DrugSpecUnit: item.DrugSpecUnit,
|
|
4823
|
+ PrescribingNumber: item.PrescribingNumber,
|
|
4824
|
+ PrescribingNumberUnit: item.PrescribingNumberUnit,
|
|
4825
|
+ DeliveryWay: item.DeliveryWay,
|
|
4826
|
+ ExecutionFrequency: item.ExecutionFrequency,
|
|
4827
|
+ AdviceDoctor: item.AdviceDoctor,
|
|
4828
|
+ Status: 1,
|
|
4829
|
+ CreatedTime: item.CreatedTime,
|
|
4830
|
+ UpdatedTime: item.UpdatedTime,
|
|
4831
|
+ AdviceAffirm: item.AdviceAffirm,
|
|
4832
|
+ Remark: item.Remark,
|
|
4833
|
+ StopTime: item.StopTime,
|
|
4834
|
+ StopReason: item.StopReason,
|
|
4835
|
+ StopDoctor: item.StopDoctor,
|
|
4836
|
+ StopState: item.StopState,
|
|
4837
|
+ ParentId: item.ParentId,
|
|
4838
|
+ ExecutionTime: item.ExecutionTime,
|
|
4839
|
+ ExecutionStaff: item.ExecutionStaff,
|
|
4840
|
+ ExecutionState: item.ExecutionState,
|
|
4841
|
+ Checker: item.Checker,
|
|
4842
|
+ RecordDate: item.ReminderDate,
|
|
4843
|
+ DialysisOrderId: item.DialysisOrderId,
|
|
4844
|
+ CheckTime: item.CheckTime,
|
|
4845
|
+ CheckState: item.CheckState,
|
|
4846
|
+ RemindType: item.RemindType,
|
|
4847
|
+ FrequencyType: item.FrequencyType,
|
|
4848
|
+ DayCount: item.DayCount,
|
|
4849
|
+ WeekDay: item.WeekDay,
|
|
4850
|
+ TemplateId: item.TemplateId,
|
|
4851
|
+ Modifier: item.Modifier,
|
|
4852
|
+ Way: item.Way,
|
|
4853
|
+ DrugId: item.DrugId,
|
|
4854
|
+ ExecutionFrequencyId: item.ExecutionFrequencyId,
|
|
4855
|
+ }
|
|
4856
|
+ medical, _ := service.GetBaseDrugMedical(item.DrugId)
|
|
4857
|
+ if medical.IsUse == 2 {
|
|
4858
|
+ if config.IsOpen != 1 {
|
|
4859
|
+ if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
|
|
4860
|
+ service.HisDrugsDelivery(item.UserOrgId, item.ExecutionStaff, hisadvice)
|
|
4861
|
+
|
|
4862
|
+ }
|
|
4863
|
+ //不通过药房发药
|
|
4864
|
+ if pharmacyConfig.IsOpen != 1 {
|
|
4865
|
+ service.HisDrugsDelivery(item.UserOrgId, item.ExecutionStaff, hisadvice)
|
|
4866
|
+ }
|
|
4867
|
+ //查询默认仓库
|
|
4868
|
+ storeHouseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
|
|
4869
|
+ //查询默认仓库剩余多少库存
|
|
4870
|
+ var sum_count int64
|
|
4871
|
+ stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
|
|
4872
|
+ for _, its := range stockInfo {
|
|
4873
|
+ if its.MaxUnit == medical.MaxUnit {
|
|
4874
|
+ its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
|
|
4875
|
+ }
|
|
4876
|
+ sum_count += its.StockMaxNumber + its.StockMinNumber
|
|
4877
|
+ }
|
|
4878
|
+ service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
|
|
4879
|
+ service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
|
|
4880
|
+ }
|
|
4881
|
+ }
|
|
4882
|
+
|
|
4883
|
+ info := models.HisDoctorAdviceInfo{
|
|
4884
|
+ ExecutionStaff: this.GetAdminUserInfo().AdminUser.Id,
|
|
4885
|
+ ExecutionTime: exec_time,
|
|
4886
|
+ ExecutionState: 1,
|
|
4887
|
+ UpdatedTime: time.Now().Unix(),
|
|
4888
|
+ }
|
|
4889
|
+ //执行医嘱
|
|
4890
|
+ service.UpdateHisDoctorAdviceExecution(info, item.ID)
|
|
4891
|
+
|
|
4892
|
+ key := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
|
|
4893
|
+ redis := service.RedisClient()
|
|
4894
|
+ //清空key 值
|
|
4895
|
+ redis.Set(key, "", time.Second)
|
|
4896
|
+ keyTwo := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":advice_list_all"
|
|
4897
|
+
|
|
4898
|
+ redis.Set(keyTwo, "", time.Second)
|
|
4899
|
+ keyThree := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_doctor_advice"
|
|
4900
|
+ redis.Set(keyThree, "", time.Second)
|
|
4901
|
+ toTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", start_time)
|
|
4902
|
+ theTime := toTime.Format("2006-01-02")
|
|
4903
|
+
|
|
4904
|
+ fmt.Println("theTIME", theTime)
|
|
4905
|
+ keyFour := "scheduals_" + theTime + "_" + strconv.FormatInt(orgId, 10)
|
|
4906
|
+
|
|
4907
|
+ redis.Set(keyFour, "", time.Second)
|
|
4908
|
+ keyFive := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_advices_list_all"
|
|
4909
|
+ redis.Set(keyFive, "", time.Second)
|
|
4910
|
+ }
|
|
4911
|
+
|
|
4912
|
+ } else {
|
|
4913
|
+
|
|
4914
|
+ groupList, _ := service.GetExcutionDoctorAdviceGroupList(recordIDStrs, startTime, orgId)
|
|
4915
|
+ //查找未执行医嘱
|
|
4916
|
+ list, _ := service.GetExcutionDoctorAdviceList(recordIDStrs, startTime, orgId)
|
|
4917
|
+ for _, item := range groupList {
|
|
4918
|
+ for _, it := range list {
|
|
4919
|
+ if item.DrugId == it.DrugId {
|
|
4920
|
+ item.ChildDoctorAdvice = append(item.ChildDoctorAdvice, it)
|
|
4921
|
+ }
|
|
4922
|
+ }
|
|
4923
|
+ }
|
|
4924
|
+
|
|
4925
|
+ for _, item := range groupList {
|
|
4926
|
+ medical, _ := service.GetBaseDrugMedical(item.DrugId)
|
|
4927
|
+ var sum_out_count int64
|
|
4928
|
+ for _, it := range item.ChildDoctorAdvice {
|
|
4929
|
+ var prescribing_number int64
|
|
4930
|
+ stringPrescribingNumber := strconv.FormatFloat(it.PrescribingNumber, 'f', -1, 64)
|
|
4931
|
+ parseIntPrescribingNumber, _ := strconv.ParseInt(stringPrescribingNumber, 10, 64)
|
|
4932
|
+ if it.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
|
|
4933
|
+ prescribing_number = parseIntPrescribingNumber * medical.MinNumber
|
|
4934
|
+ }
|
|
4935
|
+ if it.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
|
|
4936
|
+ prescribing_number = parseIntPrescribingNumber
|
|
4937
|
+ }
|
|
4938
|
+ if it.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
|
|
4939
|
+ prescribing_number = parseIntPrescribingNumber
|
|
4940
|
+ }
|
|
4941
|
+ sum_out_count += prescribing_number
|
|
4942
|
+ drugStockOut, _ := service.GetDrugSumOutCountByDrugId(it.DrugId, orgId)
|
|
4943
|
+ //库存不足
|
|
4944
|
+ if sum_out_count > drugStockOut.FlushCount {
|
|
4945
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
4946
|
+ "msg": "2",
|
|
4947
|
+ "drug": medical,
|
|
4948
|
+ })
|
|
4949
|
+ return
|
|
4950
|
+ }
|
|
4951
|
+ }
|
|
4952
|
+ }
|
|
4953
|
+
|
|
4954
|
+ for _, item := range list {
|
|
4955
|
+ medical, _ := service.GetBaseDrugMedical(item.DrugId)
|
|
4956
|
+ dadvice := &models.DoctorAdvice{
|
|
4957
|
+ ID: item.ID,
|
|
4958
|
+ UserOrgId: item.UserOrgId,
|
|
4959
|
+ PatientId: item.PatientId,
|
|
4960
|
+ AdviceType: item.AdviceType,
|
|
4961
|
+ AdviceDate: item.AdviceDate,
|
|
4962
|
+ StartTime: item.StartTime,
|
|
4963
|
+ AdviceName: item.AdviceName,
|
|
4964
|
+ AdviceDesc: item.AdviceDesc,
|
|
4965
|
+ ReminderDate: item.ReminderDate,
|
|
4966
|
+ SingleDose: item.SingleDose,
|
|
4967
|
+ SingleDoseUnit: item.SingleDoseUnit,
|
|
4968
|
+ DrugSpec: item.DrugSpec,
|
|
4969
|
+ DrugSpecUnit: item.DrugSpecUnit,
|
|
4970
|
+ PrescribingNumber: item.PrescribingNumber,
|
|
4971
|
+ PrescribingNumberUnit: item.PrescribingNumberUnit,
|
|
4972
|
+ DeliveryWay: item.DeliveryWay,
|
|
4973
|
+ ExecutionFrequency: item.ExecutionFrequency,
|
|
4974
|
+ AdviceDoctor: item.AdviceDoctor,
|
|
4975
|
+ Status: 1,
|
|
4976
|
+ CreatedTime: item.CreatedTime,
|
|
4977
|
+ UpdatedTime: item.UpdatedTime,
|
|
4978
|
+ AdviceAffirm: item.AdviceAffirm,
|
|
4979
|
+ Remark: item.Remark,
|
|
4980
|
+ StopTime: item.StopTime,
|
|
4981
|
+ StopReason: item.StopReason,
|
|
4982
|
+ StopDoctor: item.StopDoctor,
|
|
4983
|
+ StopState: item.StopState,
|
|
4984
|
+ ParentId: item.ParentId,
|
|
4985
|
+ ExecutionTime: item.ExecutionTime,
|
|
4986
|
+ ExecutionStaff: item.ExecutionStaff,
|
|
4987
|
+ ExecutionState: item.ExecutionState,
|
|
4988
|
+ Checker: item.Checker,
|
|
4989
|
+ RecordDate: item.ReminderDate,
|
|
4990
|
+ DialysisOrderId: item.DialysisOrderId,
|
|
4991
|
+ CheckTime: item.CheckTime,
|
|
4992
|
+ CheckState: item.CheckState,
|
|
4993
|
+ RemindType: item.RemindType,
|
|
4994
|
+ FrequencyType: item.FrequencyType,
|
|
4995
|
+ DayCount: item.DayCount,
|
|
4996
|
+ WeekDay: item.WeekDay,
|
|
4997
|
+ TemplateId: item.TemplateId,
|
|
4998
|
+ Modifier: item.Modifier,
|
|
4999
|
+ Way: item.Way,
|
|
5000
|
+ DrugId: item.DrugId,
|
|
5001
|
+ }
|
|
5002
|
+ if medical.IsUse == 2 {
|
|
5003
|
+ if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
|
|
5004
|
+ service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, dadvice)
|
|
5005
|
+ }
|
|
5006
|
+ if pharmacyConfig.IsOpen != 1 {
|
|
5007
|
+ service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, dadvice)
|
|
5008
|
+ }
|
|
5009
|
+
|
|
5010
|
+ //更新字典里面的库存
|
|
5011
|
+ stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
|
|
5012
|
+ var sum_count int64
|
|
5013
|
+ for _, its := range stockInfo {
|
|
5014
|
+ baseDrug, _ := service.GetBaseDrugMedical(its.DrugId)
|
|
5015
|
+ if its.MaxUnit == baseDrug.MaxUnit {
|
|
5016
|
+ its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
|
|
5017
|
+ }
|
|
5018
|
+ sum_count += its.StockMaxNumber + its.StockMinNumber
|
|
5019
|
+ }
|
|
5020
|
+ service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
|
|
5021
|
+ //剩余库存
|
|
5022
|
+ service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
|
|
5023
|
+ }
|
|
5024
|
+
|
|
5025
|
+ info := models.DoctorAdvice{
|
|
5026
|
+ ExecutionStaff: this.GetAdminUserInfo().AdminUser.Id,
|
|
5027
|
+ ExecutionTime: exec_time,
|
|
5028
|
+ ExecutionState: 1,
|
|
5029
|
+ UpdatedTime: time.Now().Unix(),
|
|
5030
|
+ }
|
|
5031
|
+ //执行医嘱
|
|
5032
|
+ service.UpdateDoctorAdviceExecution(info, item.ID)
|
|
5033
|
+ }
|
|
5034
|
+
|
|
5035
|
+ }
|
|
5036
|
+
|
|
5037
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
5038
|
+ "msg": "1",
|
|
5039
|
+ })
|
|
5040
|
+ return
|
|
5041
|
+}
|
|
5042
|
+
|
|
5043
|
+func (this *DialysisApiController) CheckNewDoctorAdvice() {
|
|
5044
|
+
|
|
5045
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
5046
|
+ is_open, _ := this.GetInt64("is_open")
|
|
5047
|
+ idsStr := this.GetString("str")
|
|
5048
|
+ recordIDStrs := strings.Split(idsStr, ",")
|
|
5049
|
+ start_time := this.GetString("advice_date")
|
|
5050
|
+ timeLayout := "2006-01-02"
|
|
5051
|
+ loc, _ := time.LoadLocation("Local")
|
|
5052
|
+ var startTime int64
|
|
5053
|
+ if len(start_time) > 0 {
|
|
5054
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
|
|
5055
|
+ if err != nil {
|
|
5056
|
+ //fmt.Println(err)
|
|
5057
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
5058
|
+ return
|
|
5059
|
+ }
|
|
5060
|
+ startTime = theTime.Unix()
|
|
5061
|
+ }
|
|
5062
|
+
|
|
5063
|
+ if is_open == 1 {
|
|
5064
|
+
|
|
5065
|
+ creater := this.GetAdminUserInfo().AdminUser.Id
|
|
5066
|
+ //查询未核对的医嘱
|
|
5067
|
+ advicelist, _ := service.GetHisCheckDoctorAdvice(orgId, recordIDStrs, startTime)
|
|
5068
|
+ for _, item := range advicelist {
|
|
5069
|
+ if item.ExecutionStaff == creater {
|
|
5070
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
5071
|
+ "msg": "2",
|
|
5072
|
+ "advice": item,
|
|
5073
|
+ })
|
|
5074
|
+ return
|
|
5075
|
+ }
|
|
5076
|
+
|
|
5077
|
+ service.CheckHisDoctorAdvice(item.ID, creater)
|
|
5078
|
+ }
|
|
5079
|
+ } else {
|
|
5080
|
+
|
|
5081
|
+ //查询未核对的医嘱
|
|
5082
|
+ advicelist, _ := service.GetCheckDoctorAdvice(orgId, recordIDStrs, startTime)
|
|
5083
|
+ creater := this.GetAdminUserInfo().AdminUser.Id
|
|
5084
|
+ for _, item := range advicelist {
|
|
5085
|
+ if item.ExecutionStaff == creater {
|
|
5086
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
5087
|
+ "msg": "2",
|
|
5088
|
+ "advice": item,
|
|
5089
|
+ })
|
|
5090
|
+ return
|
|
5091
|
+ }
|
|
5092
|
+
|
|
5093
|
+ service.CheckHisDoctorAdvice(item.ID, creater)
|
|
5094
|
+ }
|
|
5095
|
+ }
|
|
5096
|
+
|
|
5097
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
5098
|
+ "msg": "1",
|
|
5099
|
+ })
|
|
5100
|
+ return
|
|
5101
|
+
|
|
5102
|
+}
|
|
5103
|
+
|
|
5104
|
+func (this *DialysisApiController) SettleNewDoctorAdvice() {
|
|
5105
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
5106
|
+ is_open, _ := this.GetInt64("is_open")
|
|
5107
|
+ idsStr := this.GetString("str")
|
|
5108
|
+ recordIDStrs := strings.Split(idsStr, ",")
|
|
5109
|
+ start_time := this.GetString("advice_date")
|
|
5110
|
+ timeLayout := "2006-01-02"
|
|
5111
|
+ loc, _ := time.LoadLocation("Local")
|
|
5112
|
+ var startTime int64
|
|
5113
|
+ if len(start_time) > 0 {
|
|
5114
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
|
|
5115
|
+ if err != nil {
|
|
5116
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
5117
|
+ return
|
|
5118
|
+ }
|
|
5119
|
+ startTime = theTime.Unix()
|
|
5120
|
+ }
|
|
5121
|
+
|
|
5122
|
+ if is_open == 1 {
|
|
5123
|
+ service.SettleHisNewDoctorAdvice(recordIDStrs, startTime, orgId)
|
|
5124
|
+ } else {
|
|
5125
|
+ service.SettleNewDoctorAdvice(recordIDStrs, startTime, orgId)
|
|
5126
|
+ }
|
|
5127
|
+
|
|
5128
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
5129
|
+ "msg": "1",
|
|
5130
|
+ })
|
|
5131
|
+ return
|
|
5132
|
+}
|