|
@@ -442,11 +442,14 @@ func MobileGetSchedualDetail(orgID int64, patientID int64, schedualDate int64) (
|
442
|
442
|
redis.Set(key, schedual_detail_str, time.Second*60*60*18)
|
443
|
443
|
}
|
444
|
444
|
} else {
|
445
|
|
- redis.Set(key, " ", time.Second*60*60*18)
|
|
445
|
+ redis.Set(key, "null", time.Second*60*60*18)
|
446
|
446
|
}
|
447
|
447
|
return &vm, nil
|
448
|
448
|
}
|
449
|
449
|
} else { //缓存数据了数据,将redis缓存的json字符串转为map
|
|
450
|
+ if schedual_detail_str == "null" {
|
|
451
|
+ return &vm, nil
|
|
452
|
+ }
|
450
|
453
|
json.Unmarshal([]byte(schedual_detail_str), &vm)
|
451
|
454
|
|
452
|
455
|
return &vm, nil
|
|
@@ -556,11 +559,17 @@ func MobileGetReceiverTreatmentAccessRecord(orgID int64, patientID int64, record
|
556
|
559
|
|
557
|
560
|
key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":receive_treatment_asses"
|
558
|
561
|
receive_treatment_asses_str, _ := redis.Get(key).Result()
|
559
|
|
-
|
|
562
|
+ fmt.Println("长度233232323322332322323", receive_treatment_asses_str)
|
560
|
563
|
if len(receive_treatment_asses_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
|
561
|
564
|
err = readDb.Model(&models.ReceiveTreatmentAsses{}).Where("patient_id = ? and user_org_id = ? and status = 1 and record_date = ?", patientID, orgID, recordDate).First(&record).Error
|
562
|
565
|
if err != nil {
|
|
566
|
+ fmt.Println("h2323232woweewweweweweeweeewweewweweweewweewwewe", record.ID)
|
563
|
567
|
if err == gorm.ErrRecordNotFound {
|
|
568
|
+ if record.ID <= 0 {
|
|
569
|
+
|
|
570
|
+ redis.Set(key, "null", time.Second*60*60*18)
|
|
571
|
+ fmt.Println("j你来了呃呃呃呃呃呃呃呃呃呃")
|
|
572
|
+ }
|
564
|
573
|
return nil, nil
|
565
|
574
|
} else {
|
566
|
575
|
return nil, err
|
|
@@ -573,11 +582,15 @@ func MobileGetReceiverTreatmentAccessRecord(orgID int64, patientID int64, record
|
573
|
582
|
redis.Set(key, receive_treatment_asses_str, time.Second*60*60*18)
|
574
|
583
|
}
|
575
|
584
|
} else {
|
576
|
|
- redis.Set(key, " ", time.Second*60*60*18)
|
|
585
|
+ redis.Set(key, "null", time.Second*60*60*18)
|
577
|
586
|
}
|
578
|
587
|
return &record, nil
|
579
|
588
|
}
|
580
|
589
|
} else { //缓存数据了数据,将redis缓存的json字符串转为map
|
|
590
|
+ if receive_treatment_asses_str == "null" {
|
|
591
|
+
|
|
592
|
+ return &record, nil
|
|
593
|
+ }
|
581
|
594
|
json.Unmarshal([]byte(receive_treatment_asses_str), &record)
|
582
|
595
|
return &record, nil
|
583
|
596
|
}
|
|
@@ -598,6 +611,9 @@ func MobileGetPredialysisEvaluation(orgID int64, patientID int64, recordDate int
|
598
|
611
|
err := readDb.Model(&models.PredialysisEvaluation{}).Where("patient_id = ? and user_org_id = ? and status = 1 and assessment_date = ?", patientID, orgID, recordDate).First(&record).Error
|
599
|
612
|
if err != nil {
|
600
|
613
|
if err == gorm.ErrRecordNotFound {
|
|
614
|
+ if record.ID <= 0 {
|
|
615
|
+ redis.Set(key, "null", time.Second*60*60*18)
|
|
616
|
+ }
|
601
|
617
|
return nil, nil
|
602
|
618
|
} else {
|
603
|
619
|
return nil, err
|
|
@@ -610,13 +626,18 @@ func MobileGetPredialysisEvaluation(orgID int64, patientID int64, recordDate int
|
610
|
626
|
redis.Set(key, assessment_before_dislysis_str, time.Second*60*60*18)
|
611
|
627
|
}
|
612
|
628
|
} else {
|
613
|
|
- redis.Set(key, " ", time.Second*60*60*18)
|
|
629
|
+ redis.Set(key, "null", time.Second*60*60*18)
|
614
|
630
|
}
|
615
|
631
|
return &record, nil
|
616
|
632
|
}
|
617
|
633
|
} else { //缓存数据了数据,将redis缓存的json字符串转为map
|
618
|
|
- json.Unmarshal([]byte(assessment_before_dislysis_str), &record)
|
619
|
|
- return &record, nil
|
|
634
|
+ if assessment_before_dislysis_str == "null" {
|
|
635
|
+ return &record, nil
|
|
636
|
+ } else {
|
|
637
|
+ json.Unmarshal([]byte(assessment_before_dislysis_str), &record)
|
|
638
|
+ return &record, nil
|
|
639
|
+ }
|
|
640
|
+
|
620
|
641
|
}
|
621
|
642
|
}
|
622
|
643
|
|
|
@@ -634,6 +655,9 @@ func MobileGetLastTimePredialysisEvaluation(orgID int64, patientID int64, maxDat
|
634
|
655
|
err := readDb.Model(&models.PredialysisEvaluation{}).Where("patient_id = ? and user_org_id = ? and status = 1 and assessment_date < ?", patientID, orgID, maxDate).Order("assessment_date desc").First(&record).Error
|
635
|
656
|
if err != nil {
|
636
|
657
|
if err == gorm.ErrRecordNotFound {
|
|
658
|
+ if record.ID <= 0 {
|
|
659
|
+ redis.Set(key, "null", time.Second*60*60*18)
|
|
660
|
+ }
|
637
|
661
|
return nil, nil
|
638
|
662
|
} else {
|
639
|
663
|
return nil, err
|
|
@@ -646,13 +670,18 @@ func MobileGetLastTimePredialysisEvaluation(orgID int64, patientID int64, maxDat
|
646
|
670
|
redis.Set(key, assessment_before_dislysis_last_str, time.Second*60*60*4)
|
647
|
671
|
}
|
648
|
672
|
} else {
|
649
|
|
- redis.Set(key, " ", time.Second*60*60*18)
|
|
673
|
+ redis.Set(key, "null", time.Second*60*60*18)
|
650
|
674
|
}
|
651
|
675
|
return &record, nil
|
652
|
676
|
}
|
653
|
677
|
} else { //缓存数据了数据,将redis缓存的json字符串转为map
|
654
|
|
- json.Unmarshal([]byte(assessment_before_dislysis_last_str), &record)
|
655
|
|
- return &record, nil
|
|
678
|
+ if assessment_before_dislysis_last_str == "null" {
|
|
679
|
+ return &record, nil
|
|
680
|
+ } else {
|
|
681
|
+ json.Unmarshal([]byte(assessment_before_dislysis_last_str), &record)
|
|
682
|
+ return &record, nil
|
|
683
|
+ }
|
|
684
|
+
|
656
|
685
|
}
|
657
|
686
|
}
|
658
|
687
|
|
|
@@ -690,6 +719,9 @@ func MobileGetDoctorAdvicesByGroups(orgID int64, patientID int64, recordDate int
|
690
|
719
|
Scan(&records).Error
|
691
|
720
|
if err != nil {
|
692
|
721
|
if err == gorm.ErrRecordNotFound {
|
|
722
|
+ if len(records) <= 0 {
|
|
723
|
+ redis.Set(key, "null", time.Second*60*60*18)
|
|
724
|
+ }
|
693
|
725
|
return nil, nil
|
694
|
726
|
} else {
|
695
|
727
|
return nil, err
|
|
@@ -703,14 +735,18 @@ func MobileGetDoctorAdvicesByGroups(orgID int64, patientID int64, recordDate int
|
703
|
735
|
return records, nil
|
704
|
736
|
}
|
705
|
737
|
} else {
|
706
|
|
- redis.Set(key, " ", time.Second*60*60*18)
|
|
738
|
+ redis.Set(key, "null", time.Second*60*60*18)
|
707
|
739
|
return records, nil
|
708
|
740
|
}
|
709
|
741
|
return records, nil
|
710
|
742
|
}
|
711
|
743
|
} else { //缓存数据了数据,将redis缓存的json字符串转为map
|
712
|
|
- json.Unmarshal([]byte(doctor_advices_str), &records)
|
713
|
|
- return records, nil
|
|
744
|
+ if doctor_advices_str == "null" {
|
|
745
|
+ return records, nil
|
|
746
|
+ } else {
|
|
747
|
+ json.Unmarshal([]byte(doctor_advices_str), &records)
|
|
748
|
+ return records, nil
|
|
749
|
+ }
|
714
|
750
|
}
|
715
|
751
|
}
|
716
|
752
|
|
|
@@ -728,6 +764,9 @@ func MobileGetSchedualDialysisRecord(orgID int64, patientID int64, recordDate in
|
728
|
764
|
err := readDb.Model(&models.DialysisOrder{}).Preload("DeviceNumber", "org_id = ? AND status = 1", orgID).Where("user_org_id = ? AND patient_id = ? AND dialysis_date = ?", orgID, patientID, recordDate).First(&record).Error
|
729
|
765
|
if err != nil {
|
730
|
766
|
if err == gorm.ErrRecordNotFound {
|
|
767
|
+ if record.ID <= 0 {
|
|
768
|
+ redis.Set(key, "null", time.Second*60*60*18)
|
|
769
|
+ }
|
731
|
770
|
return nil, nil
|
732
|
771
|
} else {
|
733
|
772
|
return nil, err
|
|
@@ -740,13 +779,18 @@ func MobileGetSchedualDialysisRecord(orgID int64, patientID int64, recordDate in
|
740
|
779
|
redis.Set(key, dialysis_order_str, time.Second*60*60*18)
|
741
|
780
|
}
|
742
|
781
|
} else {
|
743
|
|
- redis.Set(key, " ", time.Second*60*60*18)
|
|
782
|
+ redis.Set(key, "null", time.Second*60*60*18)
|
744
|
783
|
}
|
745
|
784
|
return &record, nil
|
746
|
785
|
}
|
747
|
786
|
} else { //缓存数据了数据,将redis缓存的json字符串转为map
|
748
|
|
- json.Unmarshal([]byte(dialysis_order_str), &record)
|
749
|
|
- return &record, nil
|
|
787
|
+ if dialysis_order_str == "null" {
|
|
788
|
+ return &record, nil
|
|
789
|
+ } else {
|
|
790
|
+ json.Unmarshal([]byte(dialysis_order_str), &record)
|
|
791
|
+ return &record, nil
|
|
792
|
+ }
|
|
793
|
+
|
750
|
794
|
}
|
751
|
795
|
}
|
752
|
796
|
|
|
@@ -764,6 +808,9 @@ func MobileGetDoubleCheck(orgID int64, patientID int64, recordDate int64) (*mode
|
764
|
808
|
err := readDb.Model(&models.DoubleCheck{}).Where("patient_id = ? and user_org_id = ? and status = 1 and check_date = ?", patientID, orgID, recordDate).First(&record).Error
|
765
|
809
|
if err != nil {
|
766
|
810
|
if err == gorm.ErrRecordNotFound {
|
|
811
|
+ if record.ID <= 0 {
|
|
812
|
+ redis.Set(key, "null", time.Second*60*60*18)
|
|
813
|
+ }
|
767
|
814
|
return nil, nil
|
768
|
815
|
} else {
|
769
|
816
|
return nil, err
|
|
@@ -776,13 +823,18 @@ func MobileGetDoubleCheck(orgID int64, patientID int64, recordDate int64) (*mode
|
776
|
823
|
redis.Set(key, double_check_str, time.Second*60*60*18)
|
777
|
824
|
}
|
778
|
825
|
} else {
|
779
|
|
- redis.Set(key, " ", time.Second*60*60*18)
|
|
826
|
+ redis.Set(key, "null", time.Second*60*60*18)
|
780
|
827
|
}
|
781
|
828
|
return &record, nil
|
782
|
829
|
}
|
783
|
830
|
} else { //缓存数据了数据,将redis缓存的json字符串转为map
|
784
|
|
- json.Unmarshal([]byte(double_check_str), &record)
|
785
|
|
- return &record, nil
|
|
831
|
+ if double_check_str == "null" {
|
|
832
|
+ return &record, nil
|
|
833
|
+ } else {
|
|
834
|
+ json.Unmarshal([]byte(double_check_str), &record)
|
|
835
|
+ return &record, nil
|
|
836
|
+ }
|
|
837
|
+
|
786
|
838
|
}
|
787
|
839
|
}
|
788
|
840
|
|
|
@@ -800,6 +852,9 @@ func MobileGetMonitorRecords(orgID int64, patientID int64, recordDate int64) ([]
|
800
|
852
|
err := readDb.Model(&models.MonitoringRecord{}).Where("patient_id = ? and user_org_id = ? and status = 1 and monitoring_date = ?", patientID, orgID, recordDate).Order("operate_time asc").Find(&records).Error
|
801
|
853
|
if err != nil {
|
802
|
854
|
if err == gorm.ErrRecordNotFound {
|
|
855
|
+ if len(records) <= 0 {
|
|
856
|
+ redis.Set(key, "null", time.Second*60*60*18)
|
|
857
|
+ }
|
803
|
858
|
return nil, nil
|
804
|
859
|
} else {
|
805
|
860
|
return nil, err
|
|
@@ -812,13 +867,18 @@ func MobileGetMonitorRecords(orgID int64, patientID int64, recordDate int64) ([]
|
812
|
867
|
redis.Set(key, monitor_records_str, time.Second*60*60*18)
|
813
|
868
|
}
|
814
|
869
|
} else {
|
815
|
|
- redis.Set(key, " ", time.Second*60*60*18)
|
|
870
|
+ redis.Set(key, "null", time.Second*60*60*18)
|
816
|
871
|
}
|
817
|
872
|
return records, nil
|
818
|
873
|
}
|
819
|
874
|
} else { //缓存数据了数据,将redis缓存的json字符串转为map
|
820
|
|
- json.Unmarshal([]byte(monitor_records_str), &records)
|
821
|
|
- return records, nil
|
|
875
|
+ if monitor_records_str == "null" {
|
|
876
|
+ return records, nil
|
|
877
|
+ } else {
|
|
878
|
+ json.Unmarshal([]byte(monitor_records_str), &records)
|
|
879
|
+ return records, nil
|
|
880
|
+ }
|
|
881
|
+
|
822
|
882
|
}
|
823
|
883
|
}
|
824
|
884
|
|
|
@@ -844,6 +904,9 @@ func MobileGetLastMonitorRecord(orgID int64, patientID int64, beforeDate int64)
|
844
|
904
|
err := readDb.Model(&models.MonitoringRecord{}).Where("patient_id = ? and user_org_id = ? and status = 1 and monitoring_date = ?", patientID, orgID, beforeDate).Order("operate_time desc").First(&record).Error
|
845
|
905
|
if err != nil {
|
846
|
906
|
if err == gorm.ErrRecordNotFound {
|
|
907
|
+ if record.ID <= 0 {
|
|
908
|
+ redis.Set(key, "null", time.Second*60*60*18)
|
|
909
|
+ }
|
847
|
910
|
return nil, nil
|
848
|
911
|
} else {
|
849
|
912
|
return nil, err
|
|
@@ -856,13 +919,17 @@ func MobileGetLastMonitorRecord(orgID int64, patientID int64, beforeDate int64)
|
856
|
919
|
redis.Set(key, monitor_record_last_str, time.Second*60*60*18)
|
857
|
920
|
}
|
858
|
921
|
} else {
|
859
|
|
- redis.Set(key, " ", time.Second*60*60*18)
|
|
922
|
+ redis.Set(key, "null", time.Second*60*60*18)
|
860
|
923
|
}
|
861
|
924
|
return &record, nil
|
862
|
925
|
}
|
863
|
926
|
} else { //缓存数据了数据,将redis缓存的json字符串转为map
|
864
|
|
- json.Unmarshal([]byte(monitor_record_last_str), &record)
|
865
|
|
- return &record, nil
|
|
927
|
+ if monitor_record_last_str == "null" {
|
|
928
|
+ return &record, nil
|
|
929
|
+ } else {
|
|
930
|
+ json.Unmarshal([]byte(monitor_record_last_str), &record)
|
|
931
|
+ return &record, nil
|
|
932
|
+ }
|
866
|
933
|
}
|
867
|
934
|
}
|
868
|
935
|
|
|
@@ -880,6 +947,9 @@ func MobileGetAssessmentAfterDislysis(orgID int64, patientID int64, recordDate i
|
880
|
947
|
err := readDb.Model(&models.AssessmentAfterDislysis{}).Where("patient_id = ? and user_org_id = ? and status = 1 and assessment_date = ?", patientID, orgID, recordDate).First(&record).Error
|
881
|
948
|
if err != nil {
|
882
|
949
|
if err == gorm.ErrRecordNotFound {
|
|
950
|
+ if record.ID <= 0 {
|
|
951
|
+ redis.Set(key, "null", time.Second*60*60*18)
|
|
952
|
+ }
|
883
|
953
|
return nil, nil
|
884
|
954
|
} else {
|
885
|
955
|
return nil, err
|
|
@@ -892,13 +962,17 @@ func MobileGetAssessmentAfterDislysis(orgID int64, patientID int64, recordDate i
|
892
|
962
|
redis.Set(key, assessment_after_dislysis_str, time.Second*60*60*18)
|
893
|
963
|
}
|
894
|
964
|
} else {
|
895
|
|
- redis.Set(key, " ", time.Second*60*60*18)
|
|
965
|
+ redis.Set(key, "null", time.Second*60*60*18)
|
896
|
966
|
}
|
897
|
967
|
return &record, nil
|
898
|
968
|
}
|
899
|
969
|
} else { //缓存数据了数据,将redis缓存的json字符串转为map
|
900
|
|
- json.Unmarshal([]byte(assessment_after_dislysis_str), &record)
|
901
|
|
- return &record, nil
|
|
970
|
+ if assessment_after_dislysis_str == "null" {
|
|
971
|
+ return &record, nil
|
|
972
|
+ } else {
|
|
973
|
+ json.Unmarshal([]byte(assessment_after_dislysis_str), &record)
|
|
974
|
+ return &record, nil
|
|
975
|
+ }
|
902
|
976
|
}
|
903
|
977
|
}
|
904
|
978
|
|
|
@@ -916,6 +990,9 @@ func MobileGetLastTimeAssessmentAfterDislysis(orgID int64, patientID int64, maxD
|
916
|
990
|
err := readDb.Model(&models.AssessmentAfterDislysis{}).Where("patient_id = ? and user_org_id = ? and status = 1 and assessment_date < ?", patientID, orgID, maxDate).Order("assessment_date desc").First(&record).Error
|
917
|
991
|
if err != nil {
|
918
|
992
|
if err == gorm.ErrRecordNotFound {
|
|
993
|
+ if record.ID <= 0 {
|
|
994
|
+ redis.Set(key, "null", time.Second*60*60*18)
|
|
995
|
+ }
|
919
|
996
|
return nil, nil
|
920
|
997
|
} else {
|
921
|
998
|
return nil, err
|
|
@@ -928,13 +1005,18 @@ func MobileGetLastTimeAssessmentAfterDislysis(orgID int64, patientID int64, maxD
|
928
|
1005
|
redis.Set(key, assessment_after_dislysis_last_str, time.Second*60*60*18)
|
929
|
1006
|
}
|
930
|
1007
|
} else {
|
931
|
|
- redis.Set(key, " ", time.Second*60*60*18)
|
|
1008
|
+ redis.Set(key, "null", time.Second*60*60*18)
|
932
|
1009
|
}
|
933
|
1010
|
return &record, nil
|
934
|
1011
|
}
|
935
|
1012
|
} else { //缓存数据了数据,将redis缓存的json字符串转为map
|
936
|
|
- json.Unmarshal([]byte(assessment_after_dislysis_last_str), &record)
|
937
|
|
- return &record, nil
|
|
1013
|
+ if assessment_after_dislysis_last_str == "null" {
|
|
1014
|
+ return &record, nil
|
|
1015
|
+ } else {
|
|
1016
|
+ json.Unmarshal([]byte(assessment_after_dislysis_last_str), &record)
|
|
1017
|
+ return &record, nil
|
|
1018
|
+ }
|
|
1019
|
+
|
938
|
1020
|
}
|
939
|
1021
|
}
|
940
|
1022
|
func MobileGetLast(orgID int64, patientID int64, maxDate int64) (models.AssessmentAfterDislysis, error) {
|
|
@@ -952,11 +1034,15 @@ func MobileGetTreatmentSummary(orgID int64, patientID int64, recordDate int64) (
|
952
|
1034
|
// cur_date := time.Now().Format("2006-01-02")
|
953
|
1035
|
key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":treatment_summary"
|
954
|
1036
|
treatment_summary_str, _ := redis.Get(key).Result()
|
955
|
|
- fmt.Println("质量洗哦啊稼23323232323232323233232322332", treatment_summary_str)
|
956
|
1037
|
if len(treatment_summary_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
|
957
|
1038
|
err := readDb.Model(&models.TreatmentSummary{}).Where("patient_id = ? and user_org_id = ? and status = 1 and assessment_date = ?", patientID, orgID, recordDate).First(&record).Error
|
|
1039
|
+
|
958
|
1040
|
if err != nil {
|
959
|
1041
|
if err == gorm.ErrRecordNotFound {
|
|
1042
|
+ if record.ID <= 0 {
|
|
1043
|
+ fmt.Println("创建成功没有", treatment_summary_str)
|
|
1044
|
+ redis.Set(key, "null", time.Second*60*60*18)
|
|
1045
|
+ }
|
960
|
1046
|
return nil, nil
|
961
|
1047
|
} else {
|
962
|
1048
|
return nil, err
|
|
@@ -969,13 +1055,18 @@ func MobileGetTreatmentSummary(orgID int64, patientID int64, recordDate int64) (
|
969
|
1055
|
redis.Set(key, treatment_summary_str, time.Second*60*60*18)
|
970
|
1056
|
}
|
971
|
1057
|
} else {
|
972
|
|
- redis.Set(key, " ", time.Second*60*60*18)
|
|
1058
|
+ redis.Set(key, "null", time.Second*60*60*18)
|
973
|
1059
|
}
|
974
|
1060
|
return &record, nil
|
975
|
1061
|
}
|
976
|
1062
|
} else { //缓存数据了数据,将redis缓存的json字符串转为map
|
977
|
|
- json.Unmarshal([]byte(treatment_summary_str), &record)
|
978
|
|
- return &record, nil
|
|
1063
|
+
|
|
1064
|
+ if treatment_summary_str == "null" {
|
|
1065
|
+ return &record, nil
|
|
1066
|
+ } else {
|
|
1067
|
+ json.Unmarshal([]byte(treatment_summary_str), &record)
|
|
1068
|
+ return &record, nil
|
|
1069
|
+ }
|
979
|
1070
|
}
|
980
|
1071
|
}
|
981
|
1072
|
|
|
@@ -1809,6 +1900,9 @@ func MobileGetLastDryWeight(orgID int64, patientID int64) (*models.SgjPatientDry
|
1809
|
1900
|
err := readDb.Model(&models.SgjPatientDryweight{}).Where("patient_id = ? and user_org_id = ? and status = 1", patientID, orgID).Last(&record).Error
|
1810
|
1901
|
if err != nil {
|
1811
|
1902
|
if err == gorm.ErrRecordNotFound {
|
|
1903
|
+ if record.ID <= 0 {
|
|
1904
|
+ redis.Set(key, "null", time.Second*60*60*18)
|
|
1905
|
+ }
|
1812
|
1906
|
return nil, nil
|
1813
|
1907
|
} else {
|
1814
|
1908
|
return nil, err
|
|
@@ -1822,14 +1916,19 @@ func MobileGetLastDryWeight(orgID int64, patientID int64) (*models.SgjPatientDry
|
1822
|
1916
|
return nil, err
|
1823
|
1917
|
}
|
1824
|
1918
|
} else {
|
1825
|
|
- redis.Set(key, " ", time.Second*60*60*18)
|
|
1919
|
+ redis.Set(key, "null", time.Second*60*60*18)
|
1826
|
1920
|
return nil, err
|
1827
|
1921
|
}
|
1828
|
1922
|
return &record, nil
|
1829
|
1923
|
}
|
1830
|
1924
|
} else { //缓存数据了数据,将redis缓存的json字符串转为map
|
1831
|
|
- json.Unmarshal([]byte(last_dry_weight_str), &record)
|
1832
|
|
- return &record, nil
|
|
1925
|
+ if last_dry_weight_str == "null" {
|
|
1926
|
+ return &record, nil
|
|
1927
|
+ } else {
|
|
1928
|
+ json.Unmarshal([]byte(last_dry_weight_str), &record)
|
|
1929
|
+ return &record, nil
|
|
1930
|
+ }
|
|
1931
|
+
|
1833
|
1932
|
}
|
1834
|
1933
|
}
|
1835
|
1934
|
|
|
@@ -1847,6 +1946,9 @@ func MobileGetDialysisSolutionByModeId(orgID int64, patientID int64, mode_id int
|
1847
|
1946
|
err := readDb.Model(&models.DialysisSolution{}).Where("patient_id = ? and user_org_id = ? and status = 1 AND mode_id = ?", patientID, orgID, mode_id).Last(&record).Error
|
1848
|
1947
|
if err != nil {
|
1849
|
1948
|
if err == gorm.ErrRecordNotFound {
|
|
1949
|
+ if record.ID <= 0 {
|
|
1950
|
+ redis.Set(key, "null", time.Second*60*60*18)
|
|
1951
|
+ }
|
1850
|
1952
|
return nil, nil
|
1851
|
1953
|
} else {
|
1852
|
1954
|
return nil, err
|
|
@@ -1859,13 +1961,18 @@ func MobileGetDialysisSolutionByModeId(orgID int64, patientID int64, mode_id int
|
1859
|
1961
|
redis.Set(key, dialysis_solution_str, time.Second*60*60*18)
|
1860
|
1962
|
}
|
1861
|
1963
|
} else {
|
1862
|
|
- redis.Set(key, " ", time.Second*60*60*18)
|
|
1964
|
+ redis.Set(key, "null", time.Second*60*60*18)
|
1863
|
1965
|
}
|
1864
|
1966
|
return &record, nil
|
1865
|
1967
|
}
|
1866
|
1968
|
} else { //缓存数据了数据,将redis缓存的json字符串转为map
|
1867
|
|
- json.Unmarshal([]byte(dialysis_solution_str), &record)
|
1868
|
|
- return &record, nil
|
|
1969
|
+ if dialysis_solution_str == "null" {
|
|
1970
|
+ return &record, nil
|
|
1971
|
+ } else {
|
|
1972
|
+ json.Unmarshal([]byte(dialysis_solution_str), &record)
|
|
1973
|
+ return &record, nil
|
|
1974
|
+ }
|
|
1975
|
+
|
1869
|
1976
|
}
|
1870
|
1977
|
}
|
1871
|
1978
|
|
|
@@ -1884,6 +1991,9 @@ func MobileGetDialysisPrescribeByModeId(orgID int64, patientID int64, recordDate
|
1884
|
1991
|
err := readDb.Model(&models.DialysisPrescription{}).Where("patient_id = ? and user_org_id = ? and status = 1 and record_date = ? AND mode_id = ?", patientID, orgID, recordDate, mode_id).First(&record).Error
|
1885
|
1992
|
if err != nil {
|
1886
|
1993
|
if err == gorm.ErrRecordNotFound {
|
|
1994
|
+ if record.ID <= 0 {
|
|
1995
|
+ redis.Set(key, "null", time.Second*60*60*18)
|
|
1996
|
+ }
|
1887
|
1997
|
return nil, nil
|
1888
|
1998
|
} else {
|
1889
|
1999
|
return nil, err
|
|
@@ -1896,13 +2006,18 @@ func MobileGetDialysisPrescribeByModeId(orgID int64, patientID int64, recordDate
|
1896
|
2006
|
redis.Set(key, dialysis_prescribe_str, time.Second*60*60*18)
|
1897
|
2007
|
}
|
1898
|
2008
|
} else {
|
1899
|
|
- redis.Set(key, " ", time.Second*60*60*18)
|
|
2009
|
+ redis.Set(key, "null", time.Second*60*60*18)
|
1900
|
2010
|
}
|
1901
|
2011
|
return &record, nil
|
1902
|
2012
|
}
|
1903
|
2013
|
} else { //缓存数据了数据,将redis缓存的json字符串转为map
|
1904
|
|
- json.Unmarshal([]byte(dialysis_prescribe_str), &record)
|
1905
|
|
- return &record, nil
|
|
2014
|
+ if dialysis_prescribe_str == "null" {
|
|
2015
|
+ return &record, nil
|
|
2016
|
+ } else {
|
|
2017
|
+ json.Unmarshal([]byte(dialysis_prescribe_str), &record)
|
|
2018
|
+ return &record, nil
|
|
2019
|
+ }
|
|
2020
|
+
|
1906
|
2021
|
}
|
1907
|
2022
|
}
|
1908
|
2023
|
|
|
@@ -1919,6 +2034,9 @@ func MobileGetDialysisPrescribeByModeIdOne(orgID int64, patientID int64, recordD
|
1919
|
2034
|
err := readDb.Model(&models.DialysisPrescription{}).Where("patient_id = ? and user_org_id = ? and status = 1 and record_date = ?", patientID, orgID, recordDate).First(&record).Error
|
1920
|
2035
|
if err != nil {
|
1921
|
2036
|
if err == gorm.ErrRecordNotFound {
|
|
2037
|
+ if record.ID <= 0 {
|
|
2038
|
+ redis.Set(key, "null", time.Second*60*60*18)
|
|
2039
|
+ }
|
1922
|
2040
|
return nil, nil
|
1923
|
2041
|
} else {
|
1924
|
2042
|
return nil, err
|
|
@@ -1934,14 +2052,20 @@ func MobileGetDialysisPrescribeByModeIdOne(orgID int64, patientID int64, recordD
|
1934
|
2052
|
return nil, err
|
1935
|
2053
|
}
|
1936
|
2054
|
} else {
|
1937
|
|
- redis.Set(key, " ", time.Second*60*60*18)
|
|
2055
|
+ redis.Set(key, "null", time.Second*60*60*18)
|
1938
|
2056
|
return nil, err
|
1939
|
2057
|
}
|
1940
|
2058
|
return &record, nil
|
1941
|
2059
|
}
|
1942
|
2060
|
} else { //缓存数据了数据,将redis缓存的json字符串转为map
|
1943
|
|
- json.Unmarshal([]byte(dialysis_prescribe_by_mode_str), &record)
|
1944
|
|
- return &record, nil
|
|
2061
|
+ if dialysis_prescribe_by_mode_str == "null" {
|
|
2062
|
+ json.Unmarshal([]byte(dialysis_prescribe_by_mode_str), &record)
|
|
2063
|
+ return &record, nil
|
|
2064
|
+ } else {
|
|
2065
|
+ json.Unmarshal([]byte(dialysis_prescribe_by_mode_str), &record)
|
|
2066
|
+ return &record, nil
|
|
2067
|
+ }
|
|
2068
|
+
|
1945
|
2069
|
}
|
1946
|
2070
|
}
|
1947
|
2071
|
|
|
@@ -1981,6 +2105,9 @@ func MobileGetLastDialysisPrescribeByModeId(orgID int64, patientID int64, mode_i
|
1981
|
2105
|
err := readDb.Model(&models.DialysisPrescription{}).Where("patient_id = ? and user_org_id = ? and status = 1 and mode_id = ?", patientID, orgID, mode_id).First(&record).Error
|
1982
|
2106
|
if err != nil {
|
1983
|
2107
|
if err == gorm.ErrRecordNotFound {
|
|
2108
|
+ if record.ID <= 0 {
|
|
2109
|
+ redis.Set(key, "null", time.Second*60*60*18)
|
|
2110
|
+ }
|
1984
|
2111
|
return nil, nil
|
1985
|
2112
|
} else {
|
1986
|
2113
|
return nil, err
|
|
@@ -1992,18 +2119,24 @@ func MobileGetLastDialysisPrescribeByModeId(orgID int64, patientID int64, mode_i
|
1992
|
2119
|
dialysis_prescribe_by_mode_str, err := json.Marshal(record)
|
1993
|
2120
|
|
1994
|
2121
|
if err == nil {
|
|
2122
|
+
|
1995
|
2123
|
redis.Set(key, dialysis_prescribe_by_mode_str, time.Second*60*60*18)
|
1996
|
2124
|
return nil, err
|
1997
|
2125
|
}
|
1998
|
2126
|
} else {
|
1999
|
|
- redis.Set(key, " ", time.Second*60*60*18)
|
|
2127
|
+ redis.Set(key, "null", time.Second*60*60*18)
|
2000
|
2128
|
return nil, err
|
2001
|
2129
|
}
|
2002
|
2130
|
return &record, nil
|
2003
|
2131
|
}
|
2004
|
2132
|
} else { //缓存数据了数据,将redis缓存的json字符串转为map
|
2005
|
|
- json.Unmarshal([]byte(dialysis_prescribe_by_mode_id), &record)
|
2006
|
|
- return &record, nil
|
|
2133
|
+ if dialysis_prescribe_by_mode_id == "null" {
|
|
2134
|
+ return &record, nil
|
|
2135
|
+ } else {
|
|
2136
|
+ json.Unmarshal([]byte(dialysis_prescribe_by_mode_id), &record)
|
|
2137
|
+ return &record, nil
|
|
2138
|
+ }
|
|
2139
|
+
|
2007
|
2140
|
}
|
2008
|
2141
|
}
|
2009
|
2142
|
|
|
@@ -2191,6 +2324,9 @@ func MobileGetSystemDialysisPrescribeByModeId(orgID int64, mode_id int64) (*mode
|
2191
|
2324
|
err := readDb.Model(&models.SystemPrescription{}).Where("user_org_id = ? and status = 1 AND mode_id = ?", orgID, mode_id).First(&record).Error
|
2192
|
2325
|
if err != nil {
|
2193
|
2326
|
if err == gorm.ErrRecordNotFound {
|
|
2327
|
+ if record.ID <= 0 {
|
|
2328
|
+ redis.Set(key, "null", time.Second*60*60*18)
|
|
2329
|
+ }
|
2194
|
2330
|
return nil, nil
|
2195
|
2331
|
} else {
|
2196
|
2332
|
return nil, err
|
|
@@ -2203,13 +2339,17 @@ func MobileGetSystemDialysisPrescribeByModeId(orgID int64, mode_id int64) (*mode
|
2203
|
2339
|
redis.Set(key, system_dialysis_prescribe_str, time.Second*60*60*18)
|
2204
|
2340
|
}
|
2205
|
2341
|
} else {
|
2206
|
|
- redis.Set(key, " ", time.Second*60*60*18)
|
|
2342
|
+ redis.Set(key, "null", time.Second*60*60*18)
|
2207
|
2343
|
}
|
2208
|
2344
|
return &record, nil
|
2209
|
2345
|
}
|
2210
|
2346
|
} else { //缓存数据了数据,将redis缓存的json字符串转为map
|
2211
|
|
- json.Unmarshal([]byte(system_dialysis_prescribe_str), &record)
|
2212
|
|
- return &record, nil
|
|
2347
|
+ if system_dialysis_prescribe_str == "null" {
|
|
2348
|
+ return &record, nil
|
|
2349
|
+ } else {
|
|
2350
|
+ json.Unmarshal([]byte(system_dialysis_prescribe_str), &record)
|
|
2351
|
+ return &record, nil
|
|
2352
|
+ }
|
2213
|
2353
|
}
|
2214
|
2354
|
}
|
2215
|
2355
|
|
|
@@ -2552,6 +2692,9 @@ func GetAllHisDoctorAdvice(orgid int64, patientid int64, recorddate int64) (his
|
2552
|
2692
|
err = readDb.Model(&models.DialysisBeforePrepare{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date = ?", patientid, orgid, recorddate).Find(&his).Error
|
2553
|
2693
|
if err != nil {
|
2554
|
2694
|
if err == gorm.ErrRecordNotFound {
|
|
2695
|
+ if len(his) <= 0 {
|
|
2696
|
+ redis.Set(key, "null", time.Second*60*60*18)
|
|
2697
|
+ }
|
2555
|
2698
|
return his, nil
|
2556
|
2699
|
} else {
|
2557
|
2700
|
return his, err
|
|
@@ -2564,7 +2707,7 @@ func GetAllHisDoctorAdvice(orgid int64, patientid int64, recorddate int64) (his
|
2564
|
2707
|
redis.Set(key, his_doctor_advice_str, time.Second*60*60*18)
|
2565
|
2708
|
}
|
2566
|
2709
|
} else {
|
2567
|
|
- redis.Set(key, " ", time.Second*60*60*18)
|
|
2710
|
+ redis.Set(key, "null", time.Second*60*60*18)
|
2568
|
2711
|
}
|
2569
|
2712
|
return his, nil
|
2570
|
2713
|
}
|
|
@@ -3054,3 +3197,57 @@ func UPdateAutoStockGoods(good_id int64, record_time int64, patient_id int64, co
|
3054
|
3197
|
err := XTWriteDB().Model(&detail).Where("good_id = ? and record_time = ? and patient_id = ? and count <> 0 and status = 1", good_id, record_time, patient_id).Updates(map[string]interface{}{"count": count}).Error
|
3055
|
3198
|
return err
|
3056
|
3199
|
}
|
|
3200
|
+
|
|
3201
|
+func MobileGetDialysisSolutionByModeIdSeven(orgID int64, patientID int64, mode_id int64) (*models.DialysisSolution, error) {
|
|
3202
|
+ var record models.DialysisSolution
|
|
3203
|
+ err := readDb.Model(&models.DialysisSolution{}).Where("patient_id = ? and user_org_id = ? and status = 1 AND mode_id = ?", patientID, orgID, mode_id).Last(&record).Error
|
|
3204
|
+ if err != nil {
|
|
3205
|
+ if err == gorm.ErrRecordNotFound {
|
|
3206
|
+ return nil, nil
|
|
3207
|
+ } else {
|
|
3208
|
+ return nil, err
|
|
3209
|
+ }
|
|
3210
|
+ }
|
|
3211
|
+ return &record, nil
|
|
3212
|
+}
|
|
3213
|
+
|
|
3214
|
+func MobileGetLastDialysisPrescribeByModeIdSeven(orgID int64, patientID int64, mode_id int64) (*models.DialysisPrescription, error) {
|
|
3215
|
+ var record models.DialysisPrescription
|
|
3216
|
+ err := readDb.Model(&models.DialysisPrescription{}).Where("patient_id = ? and user_org_id = ? and status = 1 AND mode_id = ?", patientID, orgID, mode_id).Last(&record).Error
|
|
3217
|
+ if err != nil {
|
|
3218
|
+ if err == gorm.ErrRecordNotFound {
|
|
3219
|
+ return nil, nil
|
|
3220
|
+ } else {
|
|
3221
|
+ return nil, err
|
|
3222
|
+ }
|
|
3223
|
+ }
|
|
3224
|
+ return &record, nil
|
|
3225
|
+}
|
|
3226
|
+
|
|
3227
|
+func MobileGetSystemDialysisPrescribeByModeIdSeven(orgID int64, mode_id int64) (*models.SystemPrescription, error) {
|
|
3228
|
+ var record models.SystemPrescription
|
|
3229
|
+ err := readDb.Model(&models.SystemPrescription{}).Where("user_org_id = ? and status = 1 AND mode_id = ?", orgID, mode_id).First(&record).Error
|
|
3230
|
+ if err != nil {
|
|
3231
|
+ if err == gorm.ErrRecordNotFound {
|
|
3232
|
+ return nil, nil
|
|
3233
|
+ } else {
|
|
3234
|
+ return nil, err
|
|
3235
|
+ }
|
|
3236
|
+ }
|
|
3237
|
+ return &record, nil
|
|
3238
|
+}
|
|
3239
|
+
|
|
3240
|
+// 透前评估
|
|
3241
|
+func MobileGetPredialysisEvaluationSeven(orgID int64, patientID int64, recordDate int64) (*models.PredialysisEvaluation, error) {
|
|
3242
|
+ fmt.Println("recordDate", recordDate)
|
|
3243
|
+ var record models.PredialysisEvaluation
|
|
3244
|
+ err := readDb.Model(&models.PredialysisEvaluation{}).Where("patient_id = ? and user_org_id = ? and status = 1 and assessment_date = ?", patientID, orgID, recordDate).First(&record).Error
|
|
3245
|
+ if err != nil {
|
|
3246
|
+ if err == gorm.ErrRecordNotFound {
|
|
3247
|
+ return nil, nil
|
|
3248
|
+ } else {
|
|
3249
|
+ return nil, err
|
|
3250
|
+ }
|
|
3251
|
+ }
|
|
3252
|
+ return &record, nil
|
|
3253
|
+}
|