|
@@ -633,115 +633,114 @@ func (c *HisApiController) CreateHisPrescription() {
|
633
|
633
|
|
634
|
634
|
patient, _ := service.GetPatientByIDTwo(adminInfo.CurrentOrgId, patient_id)
|
635
|
635
|
|
636
|
|
- _, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
|
637
|
|
-
|
638
|
|
- _, stockConfig := service.FindAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
|
639
|
|
-
|
640
|
|
- if drugStockConfig.IsOpen == 1 {
|
641
|
|
- //校验库存总量
|
642
|
|
- if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
|
643
|
|
- prescriptions, _ := dataBody["prescriptions"].([]interface{})
|
644
|
|
- if len(prescriptions) > 0 {
|
645
|
|
- for _, item := range prescriptions {
|
646
|
|
- items := item.(map[string]interface{})
|
647
|
|
- if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
|
648
|
|
- advices := items["advices"].([]interface{})
|
649
|
|
- if len(advices) > 0 {
|
650
|
|
- for _, advice := range advices {
|
651
|
|
- var drug_id int64
|
652
|
|
- var prescribing_number float64
|
653
|
|
- var prescribingNumberUnit string
|
654
|
|
-
|
655
|
|
- if advice.(map[string]interface{})["id"] != nil || reflect.TypeOf(advice.(map[string]interface{})["id"]).String() == "float64" {
|
656
|
|
- drug_id = int64(advice.(map[string]interface{})["id"].(float64))
|
657
|
|
- }
|
658
|
|
- if advice.(map[string]interface{})["prescribing_number"] != nil || reflect.TypeOf(advice.(map[string]interface{})["prescribing_number"]).String() == "string" {
|
659
|
|
- //prescribing_number = advice.(map[string]interface{})["prescribing_number"].(string)
|
660
|
|
- prescribing_number_str := advice.(map[string]interface{})["prescribing_number"].(string)
|
661
|
|
- prescribing_number, _ = strconv.ParseFloat(prescribing_number_str, 64)
|
662
|
|
-
|
663
|
|
- }
|
664
|
|
-
|
665
|
|
- if advice.(map[string]interface{})["prescribing_number_unit"] != nil && reflect.TypeOf(advice.(map[string]interface{})["prescribing_number_unit"]).String() == "string" {
|
666
|
|
- prescribingNumberUnit, _ = advice.(map[string]interface{})["prescribing_number_unit"].(string)
|
667
|
|
- }
|
668
|
|
-
|
669
|
|
- drug, _ := service.FindBaseDrugLibRecord(adminInfo.CurrentOrgId, drug_id)
|
670
|
|
- if drug.ID == 0 {
|
671
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
672
|
|
- return
|
673
|
|
- }
|
674
|
|
-
|
675
|
|
- if prescribingNumberUnit == drug.MinUnit {
|
676
|
|
- if prescribing_number > drug.Total {
|
677
|
|
- c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
|
678
|
|
- //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOutOfStockParamWrong)
|
679
|
|
- return
|
680
|
|
- }
|
681
|
|
- } else {
|
682
|
|
- if prescribingNumberUnit == drug.MaxUnit {
|
683
|
|
- num := prescribing_number * float64(drug.MinNumber)
|
684
|
|
- if num > drug.Total {
|
685
|
|
- c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
|
686
|
|
- //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOutOfStockParamWrong)
|
687
|
|
- return
|
688
|
|
- }
|
689
|
|
- }
|
690
|
|
- }
|
691
|
|
- }
|
692
|
|
- }
|
693
|
|
- }
|
694
|
|
- }
|
695
|
|
- }
|
696
|
|
- }
|
697
|
|
- }
|
698
|
|
-
|
699
|
|
- if stockConfig.IsOpen == 1 {
|
700
|
|
- if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
|
701
|
|
- prescriptions, _ := dataBody["prescriptions"].([]interface{})
|
702
|
|
- if len(prescriptions) > 0 {
|
703
|
|
- for _, item := range prescriptions {
|
704
|
|
- items := item.(map[string]interface{})
|
705
|
|
- if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
|
706
|
|
- projects := items["project"].([]interface{})
|
707
|
|
- if len(projects) > 0 {
|
708
|
|
- for _, project := range projects {
|
709
|
|
- var project_id int64
|
710
|
|
- var project_type int64
|
711
|
|
- var totals float64
|
712
|
|
- if project.(map[string]interface{})["project_id"] != nil || reflect.TypeOf(project.(map[string]interface{})["project_id"]).String() == "float64" {
|
713
|
|
- project_id = int64(project.(map[string]interface{})["project_id"].(float64))
|
714
|
|
- }
|
715
|
|
- if project.(map[string]interface{})["type"] != nil || reflect.TypeOf(project.(map[string]interface{})["type"]).String() == "float64" {
|
716
|
|
- project_type = int64(project.(map[string]interface{})["type"].(float64))
|
717
|
|
- }
|
718
|
|
- if project.(map[string]interface{})["total"] != nil || reflect.TypeOf(project.(map[string]interface{})["total"]).String() == "string" {
|
719
|
|
- total, _ := project.(map[string]interface{})["total"].(string)
|
720
|
|
-
|
721
|
|
- totals, _ = strconv.ParseFloat(total, 64)
|
722
|
|
- }
|
723
|
|
- if project_type == 3 {
|
724
|
|
- good, _ := service.FindGoodInfoByIdTwo(project_id)
|
725
|
|
- if good.ID == 0 {
|
726
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
727
|
|
- return
|
728
|
|
- }
|
729
|
|
- if totals > good.Total {
|
730
|
|
- c.ServeDynamicFailJsonSend(good.GoodName + "库存不足")
|
731
|
|
- //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOutOfStockParamWrong)
|
732
|
|
- return
|
733
|
|
- }
|
734
|
|
-
|
735
|
|
- }
|
736
|
|
-
|
737
|
|
- }
|
738
|
|
- }
|
739
|
|
- }
|
740
|
|
- }
|
741
|
|
- }
|
742
|
|
- }
|
743
|
|
-
|
744
|
|
- }
|
|
636
|
+ //_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
|
|
637
|
+ //
|
|
638
|
+ //_, stockConfig := service.FindAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
|
|
639
|
+ //
|
|
640
|
+ //if drugStockConfig.IsOpen == 1 {
|
|
641
|
+ // //校验库存总量
|
|
642
|
+ // if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
|
|
643
|
+ // prescriptions, _ := dataBody["prescriptions"].([]interface{})
|
|
644
|
+ // if len(prescriptions) > 0 {
|
|
645
|
+ // for _, item := range prescriptions {
|
|
646
|
+ // items := item.(map[string]interface{})
|
|
647
|
+ // if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
|
|
648
|
+ // advices := items["advices"].([]interface{})
|
|
649
|
+ // if len(advices) > 0 {
|
|
650
|
+ // for _, advice := range advices {
|
|
651
|
+ // var drug_id int64
|
|
652
|
+ // var prescribing_number float64
|
|
653
|
+ // var prescribingNumberUnit string
|
|
654
|
+ //
|
|
655
|
+ // if advice.(map[string]interface{})["id"] != nil || reflect.TypeOf(advice.(map[string]interface{})["id"]).String() == "float64" {
|
|
656
|
+ // drug_id = int64(advice.(map[string]interface{})["id"].(float64))
|
|
657
|
+ // }
|
|
658
|
+ // if advice.(map[string]interface{})["prescribing_number"] != nil || reflect.TypeOf(advice.(map[string]interface{})["prescribing_number"]).String() == "string" {
|
|
659
|
+ // //prescribing_number = advice.(map[string]interface{})["prescribing_number"].(string)
|
|
660
|
+ // prescribing_number_str := advice.(map[string]interface{})["prescribing_number"].(string)
|
|
661
|
+ // prescribing_number, _ = strconv.ParseFloat(prescribing_number_str, 64)
|
|
662
|
+ //
|
|
663
|
+ // }
|
|
664
|
+ //
|
|
665
|
+ // if advice.(map[string]interface{})["prescribing_number_unit"] != nil && reflect.TypeOf(advice.(map[string]interface{})["prescribing_number_unit"]).String() == "string" {
|
|
666
|
+ // prescribingNumberUnit, _ = advice.(map[string]interface{})["prescribing_number_unit"].(string)
|
|
667
|
+ // }
|
|
668
|
+ //
|
|
669
|
+ // drug, _ := service.FindBaseDrugLibRecord(adminInfo.CurrentOrgId, drug_id)
|
|
670
|
+ // if drug.ID == 0 {
|
|
671
|
+ // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
672
|
+ // return
|
|
673
|
+ // }
|
|
674
|
+ //
|
|
675
|
+ // if prescribingNumberUnit == drug.MinUnit {
|
|
676
|
+ // if prescribing_number > drug.Total {
|
|
677
|
+ // c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
|
|
678
|
+ // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOutOfStockParamWrong)
|
|
679
|
+ // return
|
|
680
|
+ // }
|
|
681
|
+ // } else {
|
|
682
|
+ // if prescribingNumberUnit == drug.MaxUnit {
|
|
683
|
+ // num := prescribing_number * float64(drug.MinNumber)
|
|
684
|
+ // if num > drug.Total {
|
|
685
|
+ // c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
|
|
686
|
+ // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOutOfStockParamWrong)
|
|
687
|
+ // return
|
|
688
|
+ // }
|
|
689
|
+ // }
|
|
690
|
+ // }
|
|
691
|
+ // }
|
|
692
|
+ // }
|
|
693
|
+ // }
|
|
694
|
+ // }
|
|
695
|
+ // }
|
|
696
|
+ // }
|
|
697
|
+ //}
|
|
698
|
+ //
|
|
699
|
+ //if stockConfig.IsOpen == 1 {
|
|
700
|
+ // if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
|
|
701
|
+ // prescriptions, _ := dataBody["prescriptions"].([]interface{})
|
|
702
|
+ // if len(prescriptions) > 0 {
|
|
703
|
+ // for _, item := range prescriptions {
|
|
704
|
+ // items := item.(map[string]interface{})
|
|
705
|
+ // if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
|
|
706
|
+ // projects := items["project"].([]interface{})
|
|
707
|
+ // if len(projects) > 0 {
|
|
708
|
+ // for _, project := range projects {
|
|
709
|
+ // var project_id int64
|
|
710
|
+ // var project_type int64
|
|
711
|
+ // var totals float64
|
|
712
|
+ // if project.(map[string]interface{})["project_id"] != nil || reflect.TypeOf(project.(map[string]interface{})["project_id"]).String() == "float64" {
|
|
713
|
+ // project_id = int64(project.(map[string]interface{})["project_id"].(float64))
|
|
714
|
+ // }
|
|
715
|
+ // if project.(map[string]interface{})["type"] != nil || reflect.TypeOf(project.(map[string]interface{})["type"]).String() == "float64" {
|
|
716
|
+ // project_type = int64(project.(map[string]interface{})["type"].(float64))
|
|
717
|
+ // }
|
|
718
|
+ // if project.(map[string]interface{})["total"] != nil || reflect.TypeOf(project.(map[string]interface{})["total"]).String() == "string" {
|
|
719
|
+ // total, _ := project.(map[string]interface{})["total"].(string)
|
|
720
|
+ //
|
|
721
|
+ // totals, _ = strconv.ParseFloat(total, 64)
|
|
722
|
+ // }
|
|
723
|
+ // if project_type == 3 {
|
|
724
|
+ // good, _ := service.FindGoodInfoByIdTwo(project_id)
|
|
725
|
+ // if good.ID == 0 {
|
|
726
|
+ // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
727
|
+ // return
|
|
728
|
+ // }
|
|
729
|
+ // if totals > good.Total {
|
|
730
|
+ // c.ServeDynamicFailJsonSend(good.GoodName + "库存不足")
|
|
731
|
+ // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOutOfStockParamWrong)
|
|
732
|
+ // return
|
|
733
|
+ // }
|
|
734
|
+ //
|
|
735
|
+ // }
|
|
736
|
+ //
|
|
737
|
+ // }
|
|
738
|
+ // }
|
|
739
|
+ // }
|
|
740
|
+ // }
|
|
741
|
+ // }
|
|
742
|
+ // }
|
|
743
|
+ //}
|
745
|
744
|
|
746
|
745
|
info, _ := service.FindHisPatientPrescriptionInfo(adminInfo.CurrentOrgId, patient_id, recordDateTime, p_type, his_patient_id)
|
747
|
746
|
var hpInfo models.HisPrescriptionInfo
|