|
@@ -3745,10 +3745,165 @@ func (c *HisApiController) CreateHisPrescription() {
|
3745
|
3745
|
//fmt.Println("药品名称----------------------", drug.IsUse)
|
3746
|
3746
|
//fmt.Println("is_user_total-------------------------", is_user_total)
|
3747
|
3747
|
//fmt.Println("no_user_total-------------------------", no_user_total)
|
|
3748
|
+ //fmt.Println("drug.IsUse---------------", drug.IsUse)
|
|
3749
|
+ //fmt.Println("00000000000000000000", s.UserOrgId)
|
3748
|
3750
|
|
3749
|
3751
|
if is_user_total != no_user_total {
|
3750
|
3752
|
//出库
|
|
3753
|
+ //针对御享天源
|
|
3754
|
+ if drug.IsUse == 1 && s.UserOrgId == 10635 {
|
|
3755
|
+
|
|
3756
|
+ creater := adminInfo.AdminUser.Id
|
|
3757
|
+ newadviceInfo := &models.HisDoctorAdviceInfo{
|
|
3758
|
+ ID: s.ID,
|
|
3759
|
+ UserOrgId: s.UserOrgId,
|
|
3760
|
+ PatientId: s.PatientId,
|
|
3761
|
+ HisPatientId: s.HisPatientId,
|
|
3762
|
+ AdviceType: s.AdviceType,
|
|
3763
|
+ AdviceDate: s.AdviceDate,
|
|
3764
|
+ StartTime: s.StartTime,
|
|
3765
|
+ AdviceName: s.AdviceName,
|
|
3766
|
+ AdviceDesc: s.AdviceDesc,
|
|
3767
|
+ ReminderDate: s.ReminderDate,
|
|
3768
|
+ SingleDose: s.SingleDose,
|
|
3769
|
+ SingleDoseUnit: s.SingleDoseUnit,
|
|
3770
|
+ PrescribingNumber: s.PrescribingNumber,
|
|
3771
|
+ PrescribingNumberUnit: s.PrescribingNumberUnit,
|
|
3772
|
+ DeliveryWay: s.DeliveryWay,
|
|
3773
|
+ ExecutionFrequency: s.ExecutionFrequency,
|
|
3774
|
+ AdviceDoctor: s.AdviceDoctor,
|
|
3775
|
+ Status: s.Status,
|
|
3776
|
+ CreatedTime: s.CreatedTime,
|
|
3777
|
+ UpdatedTime: s.UpdatedTime,
|
|
3778
|
+ AdviceAffirm: s.AdviceAffirm,
|
|
3779
|
+ Remark: s.Remark,
|
|
3780
|
+ StopTime: s.StopTime,
|
|
3781
|
+ StopReason: s.StopReason,
|
|
3782
|
+ StopDoctor: s.StopDoctor,
|
|
3783
|
+ StopState: s.StopState,
|
|
3784
|
+ ParentId: s.ParentId,
|
|
3785
|
+ ExecutionTime: s.ExecutionTime,
|
|
3786
|
+ ExecutionStaff: s.ExecutionStaff,
|
|
3787
|
+ ExecutionState: s.ExecutionState,
|
|
3788
|
+ Checker: s.Checker,
|
|
3789
|
+ RecordDate: s.RecordDate,
|
|
3790
|
+ DialysisOrderId: s.DialysisOrderId,
|
|
3791
|
+ CheckTime: s.CheckTime,
|
|
3792
|
+ CheckState: s.CheckState,
|
|
3793
|
+ DrugSpec: s.DrugSpec,
|
|
3794
|
+ DrugSpecUnit: s.DrugSpecUnit,
|
|
3795
|
+ Groupno: s.Groupno,
|
|
3796
|
+ RemindType: s.RemindType,
|
|
3797
|
+ FrequencyType: s.FrequencyType,
|
|
3798
|
+ DayCount: s.DayCount,
|
|
3799
|
+ WeekDay: s.WeekDay,
|
|
3800
|
+ TemplateId: s.TemplateId,
|
|
3801
|
+ Modifier: s.Modifier,
|
|
3802
|
+ DrugId: s.DrugId,
|
|
3803
|
+ Price: s.Price,
|
|
3804
|
+ PrescriptionId: s.PrescriptionId,
|
|
3805
|
+ MedListCodg: s.MedListCodg,
|
|
3806
|
+ FeedetlSn: s.FeedetlSn,
|
|
3807
|
+ Day: s.DayCount,
|
|
3808
|
+ ChildDoctorAdvice: nil,
|
|
3809
|
+ Drug: models.Drug{},
|
|
3810
|
+ Diagnosis: s.Diagnosis,
|
|
3811
|
+ Way: s.Way,
|
|
3812
|
+ HospApprFlag: s.HospApprFlag,
|
|
3813
|
+ LmtUsedFlag: s.LmtUsedFlag,
|
|
3814
|
+ HisOrderInfo: models.HisOrderInfo{},
|
|
3815
|
+ IsMedicine: s.IsMedicine,
|
|
3816
|
+ ExecutionFrequencyId: s.ExecutionFrequencyId,
|
|
3817
|
+ Child: nil,
|
|
3818
|
+ IsSettle: s.IsSettle,
|
|
3819
|
+ IsMobile: s.IsMobile,
|
|
3820
|
+ IsSelfDrug: s.IsSelfDrug,
|
|
3821
|
+ DrugWayCount: s.DrugWayCount,
|
|
3822
|
+ }
|
|
3823
|
+
|
|
3824
|
+ var history_count int64
|
|
3825
|
+ var local_count int64
|
|
3826
|
+ //查找已经开过的医嘱信息
|
|
3827
|
+ adviceHistory, _ := service.GetHistory(s.ID, s.UserOrgId, tx)
|
|
3828
|
+
|
|
3829
|
+ if s.PrescribingNumberUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
|
|
3830
|
+
|
|
3831
|
+ prescribingNumberTenty := strconv.FormatFloat(s.PrescribingNumber, 'f', -1, 64)
|
|
3832
|
+ prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
|
|
3833
|
+
|
|
3834
|
+ local_count += prescribingNumberSevenTy * drug.MinNumber
|
|
3835
|
+ }
|
|
3836
|
+
|
|
3837
|
+ if s.PrescribingNumberUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
|
|
3838
|
+
|
|
3839
|
+ prescribingNumberTenty := strconv.FormatFloat(s.PrescribingNumber, 'f', -1, 64)
|
|
3840
|
+ prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
|
|
3841
|
+ local_count += prescribingNumberSevenTy
|
|
3842
|
+ }
|
|
3843
|
+
|
|
3844
|
+ if s.PrescribingNumberUnit == drug.MaxUnit && drug.MaxUnit == drug.MinUnit {
|
|
3845
|
+
|
|
3846
|
+ prescribingNumberTenty := strconv.FormatFloat(s.PrescribingNumber, 'f', -1, 64)
|
|
3847
|
+ prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
|
|
3848
|
+ local_count += prescribingNumberSevenTy
|
|
3849
|
+ }
|
|
3850
|
+
|
|
3851
|
+ if adviceHistory.PrescribingNumberUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
|
|
3852
|
+
|
|
3853
|
+ prescribingNumberTenty := strconv.FormatFloat(adviceHistory.PrescribingNumber, 'f', -1, 64)
|
|
3854
|
+ prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
|
|
3855
|
+
|
|
3856
|
+ history_count += prescribingNumberSevenTy * drug.MinNumber
|
|
3857
|
+ }
|
|
3858
|
+
|
|
3859
|
+ if adviceHistory.PrescribingNumberUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
|
|
3860
|
+
|
|
3861
|
+ prescribingNumberTenty := strconv.FormatFloat(adviceHistory.PrescribingNumber, 'f', -1, 64)
|
|
3862
|
+ prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
|
|
3863
|
+ history_count += prescribingNumberSevenTy
|
|
3864
|
+ }
|
|
3865
|
+
|
|
3866
|
+ if adviceHistory.PrescribingNumberUnit == drug.MaxUnit && drug.MaxUnit == drug.MinUnit {
|
|
3867
|
+
|
|
3868
|
+ prescribingNumberTenty := strconv.FormatFloat(adviceHistory.PrescribingNumber, 'f', -1, 64)
|
|
3869
|
+ prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
|
|
3870
|
+ history_count += prescribingNumberSevenTy
|
|
3871
|
+ }
|
|
3872
|
+
|
|
3873
|
+ fmt.Println("local_count---------------", local_count)
|
|
3874
|
+ fmt.Println("history_count---------------", history_count)
|
|
3875
|
+
|
|
3876
|
+ //如果当前出库数量大于历史出库数量则需要出库
|
|
3877
|
+ if local_count > history_count {
|
|
3878
|
+ //按最小单位出库
|
|
3879
|
+ var cha_count = local_count - history_count
|
|
3880
|
+
|
|
3881
|
+ newadviceInfo.PrescribingNumber = float64(cha_count)
|
|
3882
|
+ newadviceInfo.PrescribingNumberUnit = drug.MinUnit
|
|
3883
|
+
|
|
3884
|
+ service.NewHisDrugsDelivery(s.UserOrgId, creater, newadviceInfo, tx)
|
|
3885
|
+ }
|
|
3886
|
+
|
|
3887
|
+ //如果当前出库数量小于历史出库数量则需要退库
|
|
3888
|
+ if local_count < history_count {
|
|
3889
|
+
|
|
3890
|
+ var cha_count = history_count - local_count
|
|
3891
|
+
|
|
3892
|
+ service.NewHisDrugCancelInfo(s.UserOrgId, creater, newadviceInfo, cha_count, drug, tx)
|
|
3893
|
+
|
|
3894
|
+ service.NewHisDrugAutoCancelInfo(s.UserOrgId, creater, newadviceInfo, cha_count, drug, tx)
|
|
3895
|
+ }
|
|
3896
|
+
|
|
3897
|
+ if local_count == history_count {
|
|
3898
|
+ if is_user_total == 0 {
|
|
3899
|
+ service.NewHisDrugsDelivery(s.UserOrgId, creater, newadviceInfo, tx)
|
|
3900
|
+ }
|
|
3901
|
+
|
|
3902
|
+ }
|
|
3903
|
+ }
|
|
3904
|
+
|
3751
|
3905
|
if drug.IsUse == 2 {
|
|
3906
|
+
|
3752
|
3907
|
creater := adminInfo.AdminUser.Id
|
3753
|
3908
|
newadviceInfo := &models.HisDoctorAdviceInfo{
|
3754
|
3909
|
ID: s.ID,
|
|
@@ -3866,6 +4021,9 @@ func (c *HisApiController) CreateHisPrescription() {
|
3866
|
4021
|
history_count += prescribingNumberSevenTy
|
3867
|
4022
|
}
|
3868
|
4023
|
|
|
4024
|
+ fmt.Println("local_count---------------", local_count)
|
|
4025
|
+ fmt.Println("history_count---------------", history_count)
|
|
4026
|
+
|
3869
|
4027
|
//如果当前出库数量大于历史出库数量则需要出库
|
3870
|
4028
|
if local_count > history_count {
|
3871
|
4029
|
//按最小单位出库
|