|
@@ -1,16 +1,17 @@
|
1
|
1
|
package controllers
|
2
|
2
|
|
3
|
3
|
import (
|
4
|
|
- "XT_New/enums"
|
5
|
|
- "XT_New/models"
|
6
|
|
- "XT_New/service"
|
7
|
4
|
"encoding/json"
|
8
|
5
|
"fmt"
|
9
|
|
- "github.com/astaxie/beego"
|
10
|
|
- "github.com/jinzhu/gorm"
|
11
|
6
|
"reflect"
|
12
|
7
|
"strconv"
|
13
|
8
|
"time"
|
|
9
|
+
|
|
10
|
+ "XT_New/enums"
|
|
11
|
+ "XT_New/models"
|
|
12
|
+ "XT_New/service"
|
|
13
|
+ "github.com/astaxie/beego"
|
|
14
|
+ "github.com/jinzhu/gorm"
|
14
|
15
|
)
|
15
|
16
|
|
16
|
17
|
func SignWeighAPIControllerRegistRouters() {
|
|
@@ -490,7 +491,6 @@ func (c *SignWeighAPIController) Sighdata() {
|
490
|
491
|
func (c *SignWeighAPIController) UpdateSignweight() {
|
491
|
492
|
patientID, _ := c.GetInt64("patient_id", 0)
|
492
|
493
|
dateTime := c.GetString("date_time")
|
493
|
|
- fmt.Println("病人ID", patientID, dateTime)
|
494
|
494
|
timeLayout := "2006-01-02"
|
495
|
495
|
loc, _ := time.LoadLocation("Local")
|
496
|
496
|
theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", dateTime+" 00:00:00", loc)
|
|
@@ -506,11 +506,9 @@ func (c *SignWeighAPIController) UpdateSignweight() {
|
506
|
506
|
weight_before, _ := c.GetFloat("weight_before", 0)
|
507
|
507
|
dry_weight, _ := c.GetFloat("dry_weight", 0)
|
508
|
508
|
temperature, _ := c.GetFloat("temperature", 0)
|
509
|
|
- fmt.Println("温度", temperature)
|
510
|
509
|
pulse_frequency, _ := c.GetFloat("pulse_frequency", 0)
|
511
|
510
|
systolic_blood_pressure, _ := c.GetFloat("systolic_blood_pressure", 0)
|
512
|
511
|
diastolic_blood_pressure, _ := c.GetFloat("diastolic_blood_pressure", 0)
|
513
|
|
- fmt.Println("dry_weight", dry_weight)
|
514
|
512
|
var predialysisevaluation models.PredialysisEvaluation
|
515
|
513
|
predialysisevaluation.PatientId = patientID
|
516
|
514
|
predialysisevaluation.UserOrgId = adminUserInfo.CurrentOrgId
|
|
@@ -527,7 +525,30 @@ func (c *SignWeighAPIController) UpdateSignweight() {
|
527
|
525
|
predialysis, errcode := service.GetDislysisBerfore(adminUserInfo.CurrentOrgId, dateTimeStam, patientID)
|
528
|
526
|
fmt.Println("sigh", predialysis)
|
529
|
527
|
fmt.Println("错误:", errcode)
|
|
528
|
+
|
|
529
|
+ lastPredialysisEvaluation, _ := service.MobileGetLastTimePredialysisEvaluationOne(adminUserInfo.CurrentOrgId, patientID, dateTimeStam)
|
|
530
|
+
|
|
531
|
+ if lastPredialysisEvaluation != nil {
|
|
532
|
+ predialysisevaluation.DryWeight = lastPredialysisEvaluation.DryWeight
|
|
533
|
+ predialysisevaluation.InternalFistula = lastPredialysisEvaluation.InternalFistula
|
|
534
|
+ predialysisevaluation.InternalFistulaSkin = lastPredialysisEvaluation.InternalFistulaSkin
|
|
535
|
+ predialysisevaluation.VenousCatheterization = lastPredialysisEvaluation.VenousCatheterization
|
|
536
|
+ predialysisevaluation.Catheter = lastPredialysisEvaluation.Catheter
|
|
537
|
+ predialysisevaluation.CatheterBend = lastPredialysisEvaluation.CatheterBend
|
|
538
|
+ predialysisevaluation.PunctureNeedle = lastPredialysisEvaluation.PunctureNeedle
|
|
539
|
+ predialysisevaluation.PunctureNeedleDirection = lastPredialysisEvaluation.PunctureNeedleDirection
|
|
540
|
+ predialysisevaluation.PunctureWay = lastPredialysisEvaluation.PunctureWay
|
|
541
|
+ predialysisevaluation.PointPuncture = lastPredialysisEvaluation.PointPuncture
|
|
542
|
+ predialysisevaluation.IsHemorrhage = lastPredialysisEvaluation.IsHemorrhage
|
|
543
|
+ predialysisevaluation.ThromubusType = lastPredialysisEvaluation.ThromubusType
|
|
544
|
+ predialysisevaluation.Skin = lastPredialysisEvaluation.Skin
|
|
545
|
+ predialysisevaluation.Complication = lastPredialysisEvaluation.Complication
|
|
546
|
+ predialysisevaluation.SymptomBeforeDialysis = lastPredialysisEvaluation.SymptomBeforeDialysis
|
|
547
|
+ predialysisevaluation.LastPostDialysisOther = lastPredialysisEvaluation.LastPostDialysisOther
|
|
548
|
+ }
|
|
549
|
+
|
530
|
550
|
if errcode == gorm.ErrRecordNotFound {
|
|
551
|
+
|
531
|
552
|
service.SaveDislysisiBefore(&predialysisevaluation)
|
532
|
553
|
} else if errcode == nil {
|
533
|
554
|
|
|
@@ -537,6 +558,493 @@ func (c *SignWeighAPIController) UpdateSignweight() {
|
537
|
558
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
538
|
559
|
}
|
539
|
560
|
|
|
561
|
+ // 计算透析处方的相关超滤量
|
|
562
|
+ schedual, _ := service.MobileGetSchedualDetailSix(adminUserInfo.CurrentOrgId, patientID, dateTimeStam)
|
|
563
|
+
|
|
564
|
+ var lastDialysisPrescribe *models.DialysisPrescription
|
|
565
|
+ var dialysisSolution *models.DialysisSolution
|
|
566
|
+ var dialysisPrescribe *models.DialysisPrescription
|
|
567
|
+ var system_dialysisPrescribe *models.SystemPrescription
|
|
568
|
+
|
|
569
|
+ dialysisPrescribe, _ = service.MobileGetDialysisPrescribe(adminUserInfo.CurrentOrgId, patientID, dateTimeStam)
|
|
570
|
+
|
|
571
|
+ var dewater_amount float64
|
|
572
|
+
|
|
573
|
+ dewater_amount = predialysisevaluation.WeightBefore - predialysisevaluation.DryWeight - predialysisevaluation.AdditionalWeight
|
|
574
|
+
|
|
575
|
+ dialysisSolution, _ = service.MobileGetDialysisSolutionByModeIdSix(adminUserInfo.CurrentOrgId, patientID, schedual.ModeId)
|
|
576
|
+
|
|
577
|
+ // 插入透析处方
|
|
578
|
+ if dialysisPrescribe == nil && dialysisSolution != nil {
|
|
579
|
+ var newprescribe models.DialysisPrescription
|
|
580
|
+ newprescribe.UserOrgId = dialysisSolution.UserOrgId
|
|
581
|
+ newprescribe.PatientId = dialysisSolution.PatientId
|
|
582
|
+ newprescribe.Anticoagulant = dialysisSolution.Anticoagulant
|
|
583
|
+ newprescribe.AnticoagulantShouji = dialysisSolution.AnticoagulantShouji
|
|
584
|
+ newprescribe.AnticoagulantWeichi = dialysisSolution.AnticoagulantWeichi
|
|
585
|
+ newprescribe.AnticoagulantZongliang = dialysisSolution.AnticoagulantZongliang
|
|
586
|
+ newprescribe.AnticoagulantGaimingcheng = dialysisSolution.AnticoagulantGaimingcheng
|
|
587
|
+ newprescribe.AnticoagulantGaijiliang = dialysisSolution.AnticoagulantGaijiliang
|
|
588
|
+ newprescribe.ModeId = dialysisSolution.ModeId
|
|
589
|
+ newprescribe.DialysisDuration = dialysisSolution.DialysisDuration
|
|
590
|
+ newprescribe.ReplacementWay = dialysisSolution.ReplacementWay
|
|
591
|
+ newprescribe.HemodialysisMachine = dialysisSolution.HemodialysisMachine
|
|
592
|
+ newprescribe.BloodFilter = dialysisSolution.BloodFilter
|
|
593
|
+ newprescribe.PerfusionApparatus = dialysisSolution.PerfusionApparatus
|
|
594
|
+ newprescribe.BloodFlowVolume = dialysisSolution.BloodFlowVolume
|
|
595
|
+ newprescribe.DisplaceLiqui = dialysisSolution.DisplaceLiqui
|
|
596
|
+ newprescribe.Glucose = dialysisSolution.Glucose
|
|
597
|
+ newprescribe.DialysateFlow = dialysisSolution.DialysateFlow
|
|
598
|
+ newprescribe.Kalium = dialysisSolution.Kalium
|
|
599
|
+ newprescribe.Sodium = dialysisSolution.Sodium
|
|
600
|
+ newprescribe.Calcium = dialysisSolution.Calcium
|
|
601
|
+ newprescribe.Bicarbonate = dialysisSolution.Bicarbonate
|
|
602
|
+ newprescribe.DialysateTemperature = dialysisSolution.DialysateTemperature
|
|
603
|
+ newprescribe.Conductivity = dialysisSolution.Conductivity
|
|
604
|
+ newprescribe.BodyFluid = dialysisSolution.BodyFluid
|
|
605
|
+ newprescribe.SpecialMedicine = dialysisSolution.SpecialMedicine
|
|
606
|
+ newprescribe.SpecialMedicineOther = dialysisSolution.SpecialMedicineOther
|
|
607
|
+ newprescribe.DisplaceLiquiPart = dialysisSolution.DisplaceLiquiPart
|
|
608
|
+ newprescribe.DisplaceLiquiValue = dialysisSolution.DisplaceLiquiValue
|
|
609
|
+ newprescribe.BloodAccess = dialysisSolution.BloodAccess
|
|
610
|
+ newprescribe.Ultrafiltration = dialysisSolution.Ultrafiltration
|
|
611
|
+ newprescribe.DialysisDurationHour = dialysisSolution.DialysisDurationHour
|
|
612
|
+ newprescribe.DialysisDurationMinute = dialysisSolution.DialysisDurationMinute
|
|
613
|
+ newprescribe.TargetUltrafiltration = dialysisSolution.TargetUltrafiltration
|
|
614
|
+ newprescribe.DialysateFormulation = dialysisSolution.DialysateFormulation
|
|
615
|
+ newprescribe.Dialyzer = dialysisSolution.Dialyzer
|
|
616
|
+ newprescribe.ReplacementTotal = dialysisSolution.ReplacementTotal
|
|
617
|
+ newprescribe.DialyzerPerfusionApparatus = dialysisSolution.DialyzerPerfusionApparatus
|
|
618
|
+ newprescribe.DialysisIrrigation = dialysisSolution.DialysisIrrigation
|
|
619
|
+ newprescribe.DialysisDialyszers = dialysisSolution.DialysisDialyszers
|
|
620
|
+ newprescribe.DialysisStrainer = dialysisSolution.DialysisStrainer
|
|
621
|
+ newprescribe.BodyFluidOther = dialysisSolution.BodyFluidOther
|
|
622
|
+ newprescribe.TargetKtv = dialysisSolution.TargetKtv
|
|
623
|
+
|
|
624
|
+ newprescribe.CreatedTime = time.Now().Unix()
|
|
625
|
+ newprescribe.UpdatedTime = time.Now().Unix()
|
|
626
|
+ newprescribe.RecordDate = dateTimeStam
|
|
627
|
+ newprescribe.DewaterAmount = dewater_amount
|
|
628
|
+ newprescribe.TargetUltrafiltration = dewater_amount
|
|
629
|
+ newprescribe.PrescriptionWater = dewater_amount
|
|
630
|
+ newprescribe.Chaptalization = dialysisSolution.Chaptalization
|
|
631
|
+ newprescribe.PrescribingNumber = 1
|
|
632
|
+ newprescribe.BloodAccessPartId = dialysisSolution.BloodAccessPartId
|
|
633
|
+ newprescribe.Status = 1
|
|
634
|
+ if adminUserInfo.CurrentOrgId != 10013 && adminUserInfo.CurrentOrgId != 10014 && adminUserInfo.CurrentOrgId != 10016 {
|
|
635
|
+ newprescribe.Remark = dialysisSolution.Remark
|
|
636
|
+ }
|
|
637
|
+
|
|
638
|
+ if adminUserInfo.CurrentOrgId == 10340 {
|
|
639
|
+ newprescribe.TargetUltrafiltration = 0
|
|
640
|
+ newprescribe.Sodium = 138
|
|
641
|
+ newprescribe.Bicarbonate = 31.1
|
|
642
|
+ newprescribe.DialysateFlow = 500
|
|
643
|
+ newprescribe.TargetUltrafiltration = 0
|
|
644
|
+ }
|
|
645
|
+ // 针对新化博翔
|
|
646
|
+ if adminUserInfo.CurrentOrgId == 10447 {
|
|
647
|
+ newprescribe.DisplaceLiquiPart = 1
|
|
648
|
+ newprescribe.DisplaceLiquiValue = 32
|
|
649
|
+ newprescribe.DialysateFlow = 500
|
|
650
|
+ }
|
|
651
|
+
|
|
652
|
+ if adminUserInfo.CurrentOrgId == 10121 {
|
|
653
|
+ newprescribe.DialysisDurationHour = 4
|
|
654
|
+ newprescribe.DialysisDurationMinute = 0
|
|
655
|
+ newprescribe.BloodAccess = dialysisSolution.BloodAccess
|
|
656
|
+ }
|
|
657
|
+
|
|
658
|
+ if adminUserInfo.CurrentOrgId == 10445 {
|
|
659
|
+ lastDialysisPrescription, _ := service.GetLastDialysisPrescription(patientID, adminUserInfo.CurrentOrgId)
|
|
660
|
+ newprescribe.Remark = lastDialysisPrescription.Remark
|
|
661
|
+ }
|
|
662
|
+
|
|
663
|
+ //恒泰
|
|
664
|
+ if adminUserInfo.CurrentOrgId == 10490 || adminUserInfo.CurrentOrgId == 10016 {
|
|
665
|
+ newprescribe.Remark = ""
|
|
666
|
+ }
|
|
667
|
+
|
|
668
|
+ if adminUserInfo.CurrentOrgId == 10599 {
|
|
669
|
+ // 获取透析模版
|
|
670
|
+ solutionone, _ := service.MobileGetDialysisSolutionByModeIdSevenTwety(adminUserInfo.CurrentOrgId, patientID, schedual.ModeId)
|
|
671
|
+ if solutionone.Anticoagulant > 0 {
|
|
672
|
+ newprescribe.Anticoagulant = solutionone.Anticoagulant
|
|
673
|
+ newprescribe.AnticoagulantShouji = solutionone.AnticoagulantShouji
|
|
674
|
+ newprescribe.AnticoagulantWeichi = solutionone.AnticoagulantWeichi
|
|
675
|
+ newprescribe.AnticoagulantZongliang = solutionone.AnticoagulantZongliang
|
|
676
|
+ newprescribe.BloodAccess = solutionone.BloodAccess
|
|
677
|
+ newprescribe.DialysisDurationHour = solutionone.DialysisDurationHour
|
|
678
|
+ newprescribe.DialysisDurationMinute = solutionone.DialysisDurationMinute
|
|
679
|
+ newprescribe.DialysisIrrigation = solutionone.DialysisIrrigation
|
|
680
|
+ newprescribe.DialysisDialyszers = solutionone.DialysisDialyszers
|
|
681
|
+ newprescribe.DialysisStrainer = solutionone.DialysisStrainer
|
|
682
|
+
|
|
683
|
+ }
|
|
684
|
+
|
|
685
|
+ }
|
|
686
|
+
|
|
687
|
+ //针对普宁和揭阳
|
|
688
|
+ if adminUserInfo.CurrentOrgId == 10597 || adminUserInfo.CurrentOrgId == 10599 {
|
|
689
|
+ prescriptionTwenty, _ := service.GetLastDialysisPrescriptionTwenty(newprescribe.PatientId, newprescribe.RecordDate, newprescribe.UserOrgId)
|
|
690
|
+ if prescriptionTwenty.ID == 0 {
|
|
691
|
+ //插入透析处方
|
|
692
|
+ service.AddSigleRecord(&newprescribe)
|
|
693
|
+ } else {
|
|
694
|
+ //插入透析处方
|
|
695
|
+ service.UpdateAddSigleRecord(prescriptionTwenty.ID, newprescribe.TargetUltrafiltration)
|
|
696
|
+ }
|
|
697
|
+ } else {
|
|
698
|
+ //插入透析处方
|
|
699
|
+ service.AddSigleRecord(&newprescribe)
|
|
700
|
+ }
|
|
701
|
+
|
|
702
|
+ //记录日志
|
|
703
|
+ byterequest, _ := json.Marshal(newprescribe)
|
|
704
|
+ prescriptionLog := models.XtDialysisPrescriptionLog{
|
|
705
|
+ UserOrgId: newprescribe.UserOrgId,
|
|
706
|
+ Ctime: time.Now().Unix(),
|
|
707
|
+ Mtime: 0,
|
|
708
|
+ ErrLog: string(byterequest),
|
|
709
|
+ AdminUserId: adminUserInfo.AdminUser.Id,
|
|
710
|
+ RecordDate: newprescribe.RecordDate,
|
|
711
|
+ PatientId: newprescribe.PatientId,
|
|
712
|
+ Source: "物联网上传",
|
|
713
|
+ Status: 1,
|
|
714
|
+ }
|
|
715
|
+
|
|
716
|
+ service.CreatePrescriptionLog(prescriptionLog)
|
|
717
|
+
|
|
718
|
+ key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(dateTimeStam, 10) + ":" + strconv.FormatInt(schedual.ModeId, 10) + ":dialysis_prescribe"
|
|
719
|
+ redis := service.RedisClient()
|
|
720
|
+ //清空key 值
|
|
721
|
+ redis.Set(key, "", time.Second)
|
|
722
|
+ keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(dateTimeStam, 10) + ":prescriptions_list_all"
|
|
723
|
+ redis.Set(keyTwo, "", time.Second)
|
|
724
|
+ thisTime := time.Now()
|
|
725
|
+ scheduleDateStartOne := thisTime.Format("2006-01-02")
|
|
726
|
+ keyThree := "scheduals_" + scheduleDateStartOne + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
|
|
727
|
+ redis.Set(keyThree, "", time.Second)
|
|
728
|
+ defer redis.Close()
|
|
729
|
+ }
|
|
730
|
+
|
|
731
|
+ if dialysisPrescribe == nil && dialysisSolution == nil {
|
|
732
|
+ if lastDialysisPrescribe != nil {
|
|
733
|
+ var newprescribe models.DialysisPrescription
|
|
734
|
+ newprescribe.UserOrgId = lastDialysisPrescribe.UserOrgId
|
|
735
|
+ newprescribe.PatientId = lastDialysisPrescribe.PatientId
|
|
736
|
+ newprescribe.Anticoagulant = lastDialysisPrescribe.Anticoagulant
|
|
737
|
+ newprescribe.AnticoagulantShouji = lastDialysisPrescribe.AnticoagulantShouji
|
|
738
|
+ newprescribe.AnticoagulantWeichi = lastDialysisPrescribe.AnticoagulantWeichi
|
|
739
|
+ newprescribe.AnticoagulantZongliang = lastDialysisPrescribe.AnticoagulantZongliang
|
|
740
|
+ newprescribe.AnticoagulantGaimingcheng = lastDialysisPrescribe.AnticoagulantGaimingcheng
|
|
741
|
+ newprescribe.AnticoagulantGaijiliang = lastDialysisPrescribe.AnticoagulantGaijiliang
|
|
742
|
+ newprescribe.ModeId = lastDialysisPrescribe.ModeId
|
|
743
|
+ newprescribe.DialysisDuration = lastDialysisPrescribe.DialysisDuration
|
|
744
|
+ newprescribe.ReplacementWay = lastDialysisPrescribe.ReplacementWay
|
|
745
|
+ newprescribe.HemodialysisMachine = lastDialysisPrescribe.HemodialysisMachine
|
|
746
|
+ newprescribe.BloodFilter = lastDialysisPrescribe.BloodFilter
|
|
747
|
+ newprescribe.PerfusionApparatus = lastDialysisPrescribe.PerfusionApparatus
|
|
748
|
+ newprescribe.BloodFlowVolume = lastDialysisPrescribe.BloodFlowVolume
|
|
749
|
+ newprescribe.DisplaceLiqui = lastDialysisPrescribe.DisplaceLiqui
|
|
750
|
+ newprescribe.Glucose = lastDialysisPrescribe.Glucose
|
|
751
|
+ newprescribe.DialysateFlow = lastDialysisPrescribe.DialysateFlow
|
|
752
|
+ newprescribe.Kalium = lastDialysisPrescribe.Kalium
|
|
753
|
+ newprescribe.Sodium = lastDialysisPrescribe.Sodium
|
|
754
|
+ newprescribe.Calcium = lastDialysisPrescribe.Calcium
|
|
755
|
+ newprescribe.Bicarbonate = lastDialysisPrescribe.Bicarbonate
|
|
756
|
+ newprescribe.DialysateTemperature = lastDialysisPrescribe.DialysateTemperature
|
|
757
|
+ newprescribe.Conductivity = lastDialysisPrescribe.Conductivity
|
|
758
|
+ newprescribe.BodyFluid = lastDialysisPrescribe.BodyFluid
|
|
759
|
+ newprescribe.SpecialMedicine = lastDialysisPrescribe.SpecialMedicine
|
|
760
|
+ newprescribe.SpecialMedicineOther = lastDialysisPrescribe.SpecialMedicineOther
|
|
761
|
+ newprescribe.DisplaceLiquiPart = lastDialysisPrescribe.DisplaceLiquiPart
|
|
762
|
+ newprescribe.DisplaceLiquiValue = lastDialysisPrescribe.DisplaceLiquiValue
|
|
763
|
+ newprescribe.BloodAccess = lastDialysisPrescribe.BloodAccess
|
|
764
|
+ newprescribe.Ultrafiltration = lastDialysisPrescribe.Ultrafiltration
|
|
765
|
+ newprescribe.DialysisDurationHour = lastDialysisPrescribe.DialysisDurationHour
|
|
766
|
+ newprescribe.DialysisDurationMinute = lastDialysisPrescribe.DialysisDurationMinute
|
|
767
|
+ newprescribe.DialysateFormulation = lastDialysisPrescribe.DialysateFormulation
|
|
768
|
+ newprescribe.Dialyzer = lastDialysisPrescribe.Dialyzer
|
|
769
|
+ newprescribe.ReplacementTotal = lastDialysisPrescribe.ReplacementTotal
|
|
770
|
+ newprescribe.DialyzerPerfusionApparatus = lastDialysisPrescribe.DialyzerPerfusionApparatus
|
|
771
|
+ newprescribe.DialysisDialyszers = lastDialysisPrescribe.DialysisDialyszers
|
|
772
|
+ newprescribe.DialysisIrrigation = lastDialysisPrescribe.DialysisIrrigation
|
|
773
|
+ newprescribe.DialysisStrainer = lastDialysisPrescribe.DialysisStrainer
|
|
774
|
+ newprescribe.BodyFluidOther = lastDialysisPrescribe.BodyFluidOther
|
|
775
|
+ newprescribe.TargetKtv = lastDialysisPrescribe.TargetKtv
|
|
776
|
+ newprescribe.BloodAccessPartId = lastDialysisPrescribe.BloodAccessPartId
|
|
777
|
+ newprescribe.CreatedTime = time.Now().Unix()
|
|
778
|
+ newprescribe.UpdatedTime = time.Now().Unix()
|
|
779
|
+ newprescribe.RecordDate = dateTimeStam
|
|
780
|
+ newprescribe.DewaterAmount = dewater_amount
|
|
781
|
+ newprescribe.TargetUltrafiltration = dewater_amount
|
|
782
|
+ newprescribe.PrescriptionWater = dewater_amount
|
|
783
|
+ newprescribe.Status = 1
|
|
784
|
+
|
|
785
|
+ if adminUserInfo.CurrentOrgId == 10490 || adminUserInfo.CurrentOrgId == 10016 {
|
|
786
|
+ newprescribe.Remark = ""
|
|
787
|
+ }
|
|
788
|
+
|
|
789
|
+ newprescribe.Chaptalization = lastDialysisPrescribe.Chaptalization
|
|
790
|
+ newprescribe.PrescribingNumber = 1
|
|
791
|
+ if adminUserInfo.CurrentOrgId == 10340 {
|
|
792
|
+ newprescribe.TargetUltrafiltration = 0
|
|
793
|
+ }
|
|
794
|
+ if adminUserInfo.CurrentOrgId == 10121 {
|
|
795
|
+ newprescribe.DialysisDurationHour = 4
|
|
796
|
+ newprescribe.DialysisDurationMinute = 0
|
|
797
|
+ newprescribe.BloodAccess = dialysisSolution.BloodAccess
|
|
798
|
+ }
|
|
799
|
+
|
|
800
|
+ if adminUserInfo.CurrentOrgId == 10445 {
|
|
801
|
+ lastDialysisPrescription, _ := service.GetLastDialysisPrescription(patientID, adminUserInfo.CurrentOrgId)
|
|
802
|
+ newprescribe.Remark = lastDialysisPrescription.Remark
|
|
803
|
+ }
|
|
804
|
+ //err := service.AddSigleRecord(&newprescribe)
|
|
805
|
+ var err error
|
|
806
|
+ if adminUserInfo.CurrentOrgId == 10597 || adminUserInfo.CurrentOrgId == 10599 || adminUserInfo.CurrentOrgId == 3877 {
|
|
807
|
+ prescriptionTwenty, _ := service.GetLastDialysisPrescriptionTwenty(newprescribe.PatientId, newprescribe.RecordDate, newprescribe.UserOrgId)
|
|
808
|
+ if prescriptionTwenty.ID == 0 {
|
|
809
|
+ //插入透析处方
|
|
810
|
+ service.AddSigleRecord(&newprescribe)
|
|
811
|
+ } else {
|
|
812
|
+ //插入透析处方
|
|
813
|
+ service.UpdateAddSigleRecord(prescriptionTwenty.ID, newprescribe.TargetUltrafiltration)
|
|
814
|
+ }
|
|
815
|
+ } else {
|
|
816
|
+ //插入透析处方
|
|
817
|
+ err = service.AddSigleRecord(&newprescribe)
|
|
818
|
+ }
|
|
819
|
+ //记录日志
|
|
820
|
+ byterequest, _ := json.Marshal(newprescribe)
|
|
821
|
+ prescriptionLog := models.XtDialysisPrescriptionLog{
|
|
822
|
+ UserOrgId: adminUserInfo.CurrentOrgId,
|
|
823
|
+ Ctime: time.Now().Unix(),
|
|
824
|
+ Mtime: 0,
|
|
825
|
+ ErrLog: string(byterequest),
|
|
826
|
+ AdminUserId: adminUserInfo.AdminUser.Id,
|
|
827
|
+ RecordDate: newprescribe.RecordDate,
|
|
828
|
+ PatientId: patientID,
|
|
829
|
+ Source: "物联网上传",
|
|
830
|
+ Status: 1,
|
|
831
|
+ }
|
|
832
|
+
|
|
833
|
+ service.CreatePrescriptionLog(prescriptionLog)
|
|
834
|
+
|
|
835
|
+ key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(dateTimeStam, 10) + ":" + strconv.FormatInt(schedual.ModeId, 10) + ":dialysis_prescribe"
|
|
836
|
+ redis := service.RedisClient()
|
|
837
|
+ //清空key 值
|
|
838
|
+ redis.Set(key, "", time.Second)
|
|
839
|
+ keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(dateTimeStam, 10) + ":prescriptions_list_all"
|
|
840
|
+ redis.Set(keyTwo, "", time.Second)
|
|
841
|
+ thisTime := time.Now()
|
|
842
|
+ scheduleDateStartOne := thisTime.Format("2006-01-02")
|
|
843
|
+ keyThree := "scheduals_" + scheduleDateStartOne + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
|
|
844
|
+ redis.Set(keyThree, "", time.Second)
|
|
845
|
+ defer redis.Close()
|
|
846
|
+ if err != nil {
|
|
847
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
|
|
848
|
+ }
|
|
849
|
+ } else if system_dialysisPrescribe != nil {
|
|
850
|
+ var newprescribe models.DialysisPrescription
|
|
851
|
+ newprescribe.UserOrgId = system_dialysisPrescribe.UserOrgId
|
|
852
|
+ newprescribe.PatientId = patientID
|
|
853
|
+ newprescribe.Anticoagulant = system_dialysisPrescribe.Anticoagulant
|
|
854
|
+ newprescribe.AnticoagulantShouji = system_dialysisPrescribe.AnticoagulantShouji
|
|
855
|
+ newprescribe.AnticoagulantWeichi = system_dialysisPrescribe.AnticoagulantWeichi
|
|
856
|
+ newprescribe.AnticoagulantZongliang = system_dialysisPrescribe.AnticoagulantZongliang
|
|
857
|
+ newprescribe.AnticoagulantGaimingcheng = system_dialysisPrescribe.AnticoagulantGaimingcheng
|
|
858
|
+ newprescribe.AnticoagulantGaijiliang = system_dialysisPrescribe.AnticoagulantGaijiliang
|
|
859
|
+ newprescribe.ModeId = system_dialysisPrescribe.ModeId
|
|
860
|
+ newprescribe.DialysisDuration = system_dialysisPrescribe.DialysisDuration
|
|
861
|
+ newprescribe.ReplacementWay = system_dialysisPrescribe.ReplacementWay
|
|
862
|
+ newprescribe.HemodialysisMachine = system_dialysisPrescribe.HemodialysisMachine
|
|
863
|
+ newprescribe.BloodFilter = system_dialysisPrescribe.BloodFilter
|
|
864
|
+ newprescribe.PerfusionApparatus = system_dialysisPrescribe.PerfusionApparatus
|
|
865
|
+ newprescribe.BloodFlowVolume = system_dialysisPrescribe.BloodFlowVolume
|
|
866
|
+ newprescribe.DisplaceLiqui = system_dialysisPrescribe.DisplaceLiqui
|
|
867
|
+ newprescribe.Glucose = system_dialysisPrescribe.Glucose
|
|
868
|
+ newprescribe.DialysateFlow = system_dialysisPrescribe.DialysateFlow
|
|
869
|
+ newprescribe.Kalium = system_dialysisPrescribe.Kalium
|
|
870
|
+ newprescribe.Sodium = system_dialysisPrescribe.Sodium
|
|
871
|
+ newprescribe.Calcium = system_dialysisPrescribe.Calcium
|
|
872
|
+ newprescribe.Bicarbonate = system_dialysisPrescribe.Bicarbonate
|
|
873
|
+ newprescribe.DialysateTemperature = system_dialysisPrescribe.DialysateTemperature
|
|
874
|
+ newprescribe.Conductivity = system_dialysisPrescribe.Conductivity
|
|
875
|
+ newprescribe.BodyFluid = system_dialysisPrescribe.BodyFluid
|
|
876
|
+ newprescribe.SpecialMedicine = system_dialysisPrescribe.SpecialMedicine
|
|
877
|
+ newprescribe.SpecialMedicineOther = system_dialysisPrescribe.SpecialMedicineOther
|
|
878
|
+ newprescribe.DisplaceLiquiPart = system_dialysisPrescribe.DisplaceLiquiPart
|
|
879
|
+ newprescribe.DisplaceLiquiValue = system_dialysisPrescribe.DisplaceLiquiValue
|
|
880
|
+ newprescribe.BloodAccess = system_dialysisPrescribe.BloodAccess
|
|
881
|
+ newprescribe.Ultrafiltration = system_dialysisPrescribe.Ultrafiltration
|
|
882
|
+ newprescribe.DialysisDurationHour = system_dialysisPrescribe.DialysisDurationHour
|
|
883
|
+ newprescribe.DialysisDurationMinute = system_dialysisPrescribe.DialysisDurationMinute
|
|
884
|
+ newprescribe.DialysateFormulation = system_dialysisPrescribe.DialysateFormulation
|
|
885
|
+ newprescribe.Dialyzer = system_dialysisPrescribe.Dialyzer
|
|
886
|
+ newprescribe.ReplacementTotal = system_dialysisPrescribe.ReplacementTotal
|
|
887
|
+ newprescribe.DialyzerPerfusionApparatus = system_dialysisPrescribe.DialyzerPerfusionApparatus
|
|
888
|
+ newprescribe.DialysisIrrigation = system_dialysisPrescribe.DialysisIrrigation
|
|
889
|
+ newprescribe.DialysisDialyszers = system_dialysisPrescribe.DialysisDialyszers
|
|
890
|
+ newprescribe.BodyFluidOther = system_dialysisPrescribe.BodyFluidOther
|
|
891
|
+ newprescribe.TargetKtv = system_dialysisPrescribe.TargetKtv
|
|
892
|
+ newprescribe.CreatedTime = time.Now().Unix()
|
|
893
|
+ newprescribe.UpdatedTime = time.Now().Unix()
|
|
894
|
+ newprescribe.RecordDate = dateTimeStam
|
|
895
|
+ newprescribe.DewaterAmount = dewater_amount
|
|
896
|
+ newprescribe.TargetUltrafiltration = dewater_amount
|
|
897
|
+ newprescribe.Chaptalization = lastDialysisPrescribe.Chaptalization
|
|
898
|
+ newprescribe.BloodAccessPartId = lastDialysisPrescribe.BloodAccessPartId
|
|
899
|
+ newprescribe.Status = 1
|
|
900
|
+ newprescribe.PrescribingNumber = 1
|
|
901
|
+
|
|
902
|
+ if adminUserInfo.CurrentOrgId == 10340 {
|
|
903
|
+ newprescribe.TargetUltrafiltration = 0
|
|
904
|
+ }
|
|
905
|
+ if adminUserInfo.CurrentOrgId == 10121 {
|
|
906
|
+ newprescribe.DialysisDurationHour = 4
|
|
907
|
+ newprescribe.DialysisDurationMinute = 0
|
|
908
|
+ newprescribe.BloodAccess = dialysisSolution.BloodAccess
|
|
909
|
+ }
|
|
910
|
+ if adminUserInfo.CurrentOrgId == 10445 {
|
|
911
|
+ lastDialysisPrescription, _ := service.GetLastDialysisPrescription(patientID, adminUserInfo.CurrentOrgId)
|
|
912
|
+ newprescribe.Remark = lastDialysisPrescription.Remark
|
|
913
|
+ }
|
|
914
|
+
|
|
915
|
+ if adminUserInfo.CurrentOrgId == 10597 || adminUserInfo.CurrentOrgId == 10599 || adminUserInfo.CurrentOrgId == 3877 {
|
|
916
|
+ prescriptionTwenty, _ := service.GetLastDialysisPrescriptionTwenty(newprescribe.PatientId, newprescribe.RecordDate, newprescribe.UserOrgId)
|
|
917
|
+ if prescriptionTwenty.ID == 0 {
|
|
918
|
+ //插入透析处方
|
|
919
|
+ service.AddSigleRecord(&newprescribe)
|
|
920
|
+ } else {
|
|
921
|
+ //插入透析处方
|
|
922
|
+ service.UpdateAddSigleRecord(prescriptionTwenty.ID, newprescribe.TargetUltrafiltration)
|
|
923
|
+ }
|
|
924
|
+ } else {
|
|
925
|
+ service.AddSigleRecord(&newprescribe)
|
|
926
|
+ }
|
|
927
|
+
|
|
928
|
+ //记录日志
|
|
929
|
+ byterequest, _ := json.Marshal(newprescribe)
|
|
930
|
+ prescriptionLog := models.XtDialysisPrescriptionLog{
|
|
931
|
+ UserOrgId: adminUserInfo.CurrentOrgId,
|
|
932
|
+ Ctime: time.Now().Unix(),
|
|
933
|
+ Mtime: 0,
|
|
934
|
+ ErrLog: string(byterequest),
|
|
935
|
+ AdminUserId: adminUserInfo.AdminUser.Id,
|
|
936
|
+ RecordDate: newprescribe.RecordDate,
|
|
937
|
+ PatientId: patientID,
|
|
938
|
+ Source: "物联网上传",
|
|
939
|
+ Status: 1,
|
|
940
|
+ }
|
|
941
|
+
|
|
942
|
+ service.CreatePrescriptionLog(prescriptionLog)
|
|
943
|
+ key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(dateTimeStam, 10) + ":" + strconv.FormatInt(schedual.ModeId, 10) + ":dialysis_prescribe"
|
|
944
|
+ redis := service.RedisClient()
|
|
945
|
+ //清空key 值
|
|
946
|
+ redis.Set(key, "", time.Second)
|
|
947
|
+ keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(dateTimeStam, 10) + ":prescriptions_list_all"
|
|
948
|
+ redis.Set(keyTwo, "", time.Second)
|
|
949
|
+ thisTime := time.Now()
|
|
950
|
+ scheduleDateStartOne := thisTime.Format("2006-01-02")
|
|
951
|
+ keyThree := "scheduals_" + scheduleDateStartOne + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
|
|
952
|
+ redis.Set(keyThree, "", time.Second)
|
|
953
|
+ defer redis.Close()
|
|
954
|
+
|
|
955
|
+ } else {
|
|
956
|
+ var newprescribe models.DialysisPrescription
|
|
957
|
+ newprescribe.UserOrgId = adminUserInfo.CurrentOrgId
|
|
958
|
+ newprescribe.PatientId = patientID
|
|
959
|
+ newprescribe.ModeId = schedual.ModeId
|
|
960
|
+ newprescribe.CreatedTime = time.Now().Unix()
|
|
961
|
+ newprescribe.UpdatedTime = time.Now().Unix()
|
|
962
|
+ newprescribe.RecordDate = dateTimeStam
|
|
963
|
+ newprescribe.DewaterAmount = dewater_amount
|
|
964
|
+ newprescribe.TargetUltrafiltration = dewater_amount
|
|
965
|
+ newprescribe.Status = 1
|
|
966
|
+ if adminUserInfo.CurrentOrgId == 10445 {
|
|
967
|
+ lastDialysisPrescription, _ := service.GetLastDialysisPrescription(patientID, adminUserInfo.CurrentOrgId)
|
|
968
|
+ newprescribe.Remark = lastDialysisPrescription.Remark
|
|
969
|
+ }
|
|
970
|
+ err := service.AddSigleRecord(&newprescribe)
|
|
971
|
+ //记录日志
|
|
972
|
+ byterequest, _ := json.Marshal(newprescribe)
|
|
973
|
+ prescriptionLog := models.XtDialysisPrescriptionLog{
|
|
974
|
+ UserOrgId: adminUserInfo.CurrentOrgId,
|
|
975
|
+ Ctime: time.Now().Unix(),
|
|
976
|
+ Mtime: 0,
|
|
977
|
+ ErrLog: string(byterequest),
|
|
978
|
+ AdminUserId: adminUserInfo.AdminUser.Id,
|
|
979
|
+ RecordDate: newprescribe.RecordDate,
|
|
980
|
+ PatientId: patientID,
|
|
981
|
+ Source: "物联网上传",
|
|
982
|
+ Status: 1,
|
|
983
|
+ }
|
|
984
|
+
|
|
985
|
+ service.CreatePrescriptionLog(prescriptionLog)
|
|
986
|
+ key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(dateTimeStam, 10) + ":" + strconv.FormatInt(schedual.ModeId, 10) + ":dialysis_prescribe"
|
|
987
|
+ redis := service.RedisClient()
|
|
988
|
+ //清空key 值
|
|
989
|
+ redis.Set(key, "", time.Second)
|
|
990
|
+ keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(dateTimeStam, 10) + ":prescriptions_list_all"
|
|
991
|
+ redis.Set(keyTwo, "", time.Second)
|
|
992
|
+ thisTime := time.Now()
|
|
993
|
+ scheduleDateStartOne := thisTime.Format("2006-01-02")
|
|
994
|
+ keyThree := "scheduals_" + scheduleDateStartOne + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
|
|
995
|
+ redis.Set(keyThree, "", time.Second)
|
|
996
|
+ defer redis.Close()
|
|
997
|
+ if err != nil {
|
|
998
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
|
|
999
|
+ }
|
|
1000
|
+ }
|
|
1001
|
+ }
|
|
1002
|
+
|
|
1003
|
+ if dialysisPrescribe != nil && dialysisPrescribe.TargetUltrafiltration == 0 {
|
|
1004
|
+ dialysisPrescribe.UpdatedTime = time.Now().Unix()
|
|
1005
|
+ dialysisPrescribe.RecordDate = dateTimeStam
|
|
1006
|
+ dialysisPrescribe.DewaterAmount = dewater_amount
|
|
1007
|
+ dialysisPrescribe.TargetUltrafiltration = dewater_amount
|
|
1008
|
+ dialysisPrescribe.Status = 1
|
|
1009
|
+ if adminUserInfo.CurrentOrgId == 10340 {
|
|
1010
|
+ dialysisPrescribe.TargetUltrafiltration = 0
|
|
1011
|
+ }
|
|
1012
|
+ if adminUserInfo.CurrentOrgId == 10445 {
|
|
1013
|
+ lastDialysisPrescription, _ := service.GetLastDialysisPrescription(patientID, adminUserInfo.CurrentOrgId)
|
|
1014
|
+ dialysisPrescribe.Remark = lastDialysisPrescription.Remark
|
|
1015
|
+ }
|
|
1016
|
+ updateErr := service.UpDateDialysisPrescription(dialysisPrescribe)
|
|
1017
|
+ //记录日志
|
|
1018
|
+ byterequest, _ := json.Marshal(dialysisPrescribe)
|
|
1019
|
+ prescriptionLog := models.XtDialysisPrescriptionLog{
|
|
1020
|
+ UserOrgId: adminUserInfo.CurrentOrgId,
|
|
1021
|
+ Ctime: time.Now().Unix(),
|
|
1022
|
+ Mtime: 0,
|
|
1023
|
+ ErrLog: string(byterequest),
|
|
1024
|
+ AdminUserId: adminUserInfo.AdminUser.Id,
|
|
1025
|
+ RecordDate: dialysisPrescribe.RecordDate,
|
|
1026
|
+ PatientId: patientID,
|
|
1027
|
+ Source: "物联网上传",
|
|
1028
|
+ Status: 1,
|
|
1029
|
+ }
|
|
1030
|
+
|
|
1031
|
+ service.CreatePrescriptionLog(prescriptionLog)
|
|
1032
|
+ key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(dateTimeStam, 10) + ":" + strconv.FormatInt(schedual.ModeId, 10) + ":dialysis_prescribe"
|
|
1033
|
+ redis := service.RedisClient()
|
|
1034
|
+ //清空key 值
|
|
1035
|
+ redis.Set(key, "", time.Second)
|
|
1036
|
+ keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(dateTimeStam, 10) + ":prescriptions_list_all"
|
|
1037
|
+ redis.Set(keyTwo, "", time.Second)
|
|
1038
|
+ thisTime := time.Now()
|
|
1039
|
+ scheduleDateStartOne := thisTime.Format("2006-01-02")
|
|
1040
|
+ keyThree := "scheduals_" + scheduleDateStartOne + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
|
|
1041
|
+ redis.Set(keyThree, "", time.Second)
|
|
1042
|
+ defer redis.Close()
|
|
1043
|
+ if updateErr != nil {
|
|
1044
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
|
|
1045
|
+ }
|
|
1046
|
+ }
|
|
1047
|
+
|
540
|
1048
|
//透后
|
541
|
1049
|
weight_after, _ := c.GetFloat("weight_after", 0)
|
542
|
1050
|
temperatureafter, _ := c.GetFloat("temperatureafter", 0)
|