|
@@ -2,11 +2,11 @@ package service
|
2
|
2
|
|
3
|
3
|
import (
|
4
|
4
|
"XT_New/models"
|
|
5
|
+ "encoding/json"
|
5
|
6
|
"fmt"
|
6
|
7
|
"github.com/jinzhu/gorm"
|
7
|
|
- "time"
|
8
|
|
- "encoding/json"
|
9
|
8
|
"strconv"
|
|
9
|
+ "time"
|
10
|
10
|
)
|
11
|
11
|
|
12
|
12
|
// func GetSchedualPatients(orgID int64) ([]*MDialysisScheduleVM, error) {
|
|
@@ -146,8 +146,8 @@ type MDialysisScheduleVMForList struct {
|
146
|
146
|
Prescription *models.DialysisPrescriptionList `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"prescription"`
|
147
|
147
|
AssessmentBeforeDislysis *models.PredialysisEvaluationList `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"assessment_before_dislysis"`
|
148
|
148
|
AssessmentAfterDislysis *models.VMAssessmentAfterDislysis `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"assessment_after_dislysis"`
|
149
|
|
- HisAdvices []VMHisDoctorAdviceInfo `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"his_doctor_advice"`
|
150
|
|
- Advices []models.VMDoctorAdviceForList `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"doctor_advice"`
|
|
149
|
+ HisAdvices []VMHisDoctorAdviceInfo `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"his_doctor_advice"`
|
|
150
|
+ Advices []models.VMDoctorAdviceForList `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"doctor_advice"`
|
151
|
151
|
TreatmentSummary *models.VMTreatmentSummaryForList `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"treatment_summary"`
|
152
|
152
|
}
|
153
|
153
|
|
|
@@ -388,18 +388,18 @@ func MobileGetSchedualDetail(orgID int64, patientID int64, schedualDate int64) (
|
388
|
388
|
var vm MDialysisScheduleVM
|
389
|
389
|
|
390
|
390
|
// cur_date := time.Now().Format("2006-01-02")
|
391
|
|
- key := strconv.FormatInt(orgID, 10) + ":"+ strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(schedualDate, 10) + ":schedual_detail"
|
|
391
|
+ key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(schedualDate, 10) + ":schedual_detail"
|
392
|
392
|
schedual_detail_str, _ := redis.Get(key).Result()
|
393
|
393
|
|
394
|
394
|
if len(schedual_detail_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
|
395
|
395
|
err := readDb.
|
396
|
|
- Table("xt_schedule").
|
397
|
|
- // Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
|
398
|
|
- Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
|
399
|
|
- Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
400
|
|
- Where("status = 1 AND user_org_id = ? AND schedule_date = ? AND patient_id = ?", orgID, schedualDate, patientID).
|
401
|
|
- First(&vm).Error
|
402
|
|
-
|
|
396
|
+ Table("xt_schedule").
|
|
397
|
+ // Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
|
|
398
|
+ Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
|
|
399
|
+ Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
|
400
|
+ Where("status = 1 AND user_org_id = ? AND schedule_date = ? AND patient_id = ?", orgID, schedualDate, patientID).
|
|
401
|
+ First(&vm).Error
|
|
402
|
+
|
403
|
403
|
if err != nil {
|
404
|
404
|
if err == gorm.ErrRecordNotFound {
|
405
|
405
|
return nil, nil
|
|
@@ -526,7 +526,7 @@ func MobileGetReceiverTreatmentAccessRecord(orgID int64, patientID int64, record
|
526
|
526
|
defer redis.Close()
|
527
|
527
|
|
528
|
528
|
// cur_date := time.Now().Format("2006-01-02")
|
529
|
|
- key := strconv.FormatInt(orgID, 10) + ":"+ strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":receive_treatment_asses"
|
|
529
|
+ key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":receive_treatment_asses"
|
530
|
530
|
receive_treatment_asses_str, _ := redis.Get(key).Result()
|
531
|
531
|
|
532
|
532
|
if len(receive_treatment_asses_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
|
|
@@ -563,7 +563,7 @@ func MobileGetPredialysisEvaluation(orgID int64, patientID int64, recordDate int
|
563
|
563
|
defer redis.Close()
|
564
|
564
|
|
565
|
565
|
// cur_date := time.Now().Format("2006-01-02")
|
566
|
|
- key := strconv.FormatInt(orgID, 10) + ":"+ strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":assessment_before_dislysis"
|
|
566
|
+ key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":assessment_before_dislysis"
|
567
|
567
|
assessment_before_dislysis_str, _ := redis.Get(key).Result()
|
568
|
568
|
|
569
|
569
|
if len(assessment_before_dislysis_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
|
|
@@ -599,7 +599,7 @@ func MobileGetLastTimePredialysisEvaluation(orgID int64, patientID int64, maxDat
|
599
|
599
|
defer redis.Close()
|
600
|
600
|
|
601
|
601
|
// cur_date := time.Now().Format("2006-01-02")
|
602
|
|
- key := strconv.FormatInt(orgID, 10) + ":"+ strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(maxDate, 10) + ":assessment_before_dislysis_last"
|
|
602
|
+ key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(maxDate, 10) + ":assessment_before_dislysis_last"
|
603
|
603
|
assessment_before_dislysis_last_str, _ := redis.Get(key).Result()
|
604
|
604
|
|
605
|
605
|
if len(assessment_before_dislysis_last_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
|
|
@@ -652,16 +652,16 @@ func MobileGetDoctorAdvicesByGroups(orgID int64, patientID int64, recordDate int
|
652
|
652
|
defer redis.Close()
|
653
|
653
|
|
654
|
654
|
// cur_date := time.Now().Format("2006-01-02")
|
655
|
|
- key := strconv.FormatInt(orgID, 10) + ":"+ strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":doctor_advices"
|
|
655
|
+ key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":doctor_advices"
|
656
|
656
|
doctor_advices_str, _ := redis.Get(key).Result()
|
657
|
657
|
|
658
|
658
|
if len(doctor_advices_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
|
659
|
659
|
err := readDb.
|
660
|
|
- Model(&models.DoctorAdvice{}).
|
661
|
|
- Where("patient_id = ? and user_org_id = ? and status = 1 and record_date = ? and (advice_type = 2 || advice_type = 3)", patientID, orgID, recordDate).
|
662
|
|
- Select("id, user_org_id, patient_id, advice_type, advice_date, record_date, start_time, advice_name,advice_desc, reminder_date, drug_spec, drug_spec_unit, single_dose, single_dose_unit, prescribing_number, prescribing_number_unit, delivery_way, execution_frequency, advice_doctor, status, created_time,updated_time, advice_affirm, remark, stop_time, stop_reason, stop_doctor, stop_state, parent_id, execution_time, execution_staff, execution_state, checker, check_state, check_time, groupno,way,drug_id,drug_name_id, IF(parent_id > 0, parent_id, id) as advice_order").
|
663
|
|
- Order("start_time asc, groupno desc, advice_order desc, id asc").
|
664
|
|
- Scan(&records).Error
|
|
660
|
+ Model(&models.DoctorAdvice{}).
|
|
661
|
+ Where("patient_id = ? and user_org_id = ? and status = 1 and record_date = ? and (advice_type = 2 || advice_type = 3)", patientID, orgID, recordDate).
|
|
662
|
+ Select("id, user_org_id, patient_id, advice_type, advice_date, record_date, start_time, advice_name,advice_desc, reminder_date, drug_spec, drug_spec_unit, single_dose, single_dose_unit, prescribing_number, prescribing_number_unit, delivery_way, execution_frequency, advice_doctor, status, created_time,updated_time, advice_affirm, remark, stop_time, stop_reason, stop_doctor, stop_state, parent_id, execution_time, execution_staff, execution_state, checker, check_state, check_time, groupno,way,drug_id,drug_name_id, IF(parent_id > 0, parent_id, id) as advice_order").
|
|
663
|
+ Order("start_time asc, groupno desc, advice_order desc, id asc").
|
|
664
|
+ Scan(&records).Error
|
665
|
665
|
if err != nil {
|
666
|
666
|
if err == gorm.ErrRecordNotFound {
|
667
|
667
|
return nil, nil
|
|
@@ -693,7 +693,7 @@ func MobileGetSchedualDialysisRecord(orgID int64, patientID int64, recordDate in
|
693
|
693
|
defer redis.Close()
|
694
|
694
|
|
695
|
695
|
// cur_date := time.Now().Format("2006-01-02")
|
696
|
|
- key := strconv.FormatInt(orgID, 10) + ":"+ strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":dialysis_order"
|
|
696
|
+ key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":dialysis_order"
|
697
|
697
|
dialysis_order_str, _ := redis.Get(key).Result()
|
698
|
698
|
|
699
|
699
|
if len(dialysis_order_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
|
|
@@ -729,7 +729,7 @@ func MobileGetDoubleCheck(orgID int64, patientID int64, recordDate int64) (*mode
|
729
|
729
|
defer redis.Close()
|
730
|
730
|
|
731
|
731
|
// cur_date := time.Now().Format("2006-01-02")
|
732
|
|
- key := strconv.FormatInt(orgID, 10) + ":"+ strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":double_check"
|
|
732
|
+ key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":double_check"
|
733
|
733
|
double_check_str, _ := redis.Get(key).Result()
|
734
|
734
|
|
735
|
735
|
if len(double_check_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
|
|
@@ -765,7 +765,7 @@ func MobileGetMonitorRecords(orgID int64, patientID int64, recordDate int64) ([]
|
765
|
765
|
defer redis.Close()
|
766
|
766
|
|
767
|
767
|
// cur_date := time.Now().Format("2006-01-02")
|
768
|
|
- key := strconv.FormatInt(orgID, 10) + ":"+ strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":monitor_records"
|
|
768
|
+ key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":monitor_records"
|
769
|
769
|
monitor_records_str, _ := redis.Get(key).Result()
|
770
|
770
|
|
771
|
771
|
if len(monitor_records_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
|
|
@@ -809,7 +809,7 @@ func MobileGetLastMonitorRecord(orgID int64, patientID int64, beforeDate int64)
|
809
|
809
|
defer redis.Close()
|
810
|
810
|
|
811
|
811
|
// cur_date := time.Now().Format("2006-01-02")
|
812
|
|
- key := strconv.FormatInt(orgID, 10) + ":"+ strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(beforeDate, 10) + ":monitor_record_last"
|
|
812
|
+ key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(beforeDate, 10) + ":monitor_record_last"
|
813
|
813
|
monitor_record_last_str, _ := redis.Get(key).Result()
|
814
|
814
|
|
815
|
815
|
if len(monitor_record_last_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
|
|
@@ -845,7 +845,7 @@ func MobileGetAssessmentAfterDislysis(orgID int64, patientID int64, recordDate i
|
845
|
845
|
defer redis.Close()
|
846
|
846
|
|
847
|
847
|
// cur_date := time.Now().Format("2006-01-02")
|
848
|
|
- key := strconv.FormatInt(orgID, 10) + ":"+ strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":assessment_after_dislysis"
|
|
848
|
+ key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":assessment_after_dislysis"
|
849
|
849
|
assessment_after_dislysis_str, _ := redis.Get(key).Result()
|
850
|
850
|
|
851
|
851
|
if len(assessment_after_dislysis_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
|
|
@@ -881,7 +881,7 @@ func MobileGetLastTimeAssessmentAfterDislysis(orgID int64, patientID int64, maxD
|
881
|
881
|
defer redis.Close()
|
882
|
882
|
|
883
|
883
|
// cur_date := time.Now().Format("2006-01-02")
|
884
|
|
- key := strconv.FormatInt(orgID, 10) + ":"+ strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(maxDate, 10) + ":assessment_after_dislysis_last"
|
|
884
|
+ key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(maxDate, 10) + ":assessment_after_dislysis_last"
|
885
|
885
|
assessment_after_dislysis_last_str, _ := redis.Get(key).Result()
|
886
|
886
|
|
887
|
887
|
if len(assessment_after_dislysis_last_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
|
|
@@ -922,7 +922,7 @@ func MobileGetTreatmentSummary(orgID int64, patientID int64, recordDate int64) (
|
922
|
922
|
defer redis.Close()
|
923
|
923
|
|
924
|
924
|
// cur_date := time.Now().Format("2006-01-02")
|
925
|
|
- key := strconv.FormatInt(orgID, 10) + ":"+ strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":treatment_summary"
|
|
925
|
+ key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":treatment_summary"
|
926
|
926
|
treatment_summary_str, _ := redis.Get(key).Result()
|
927
|
927
|
|
928
|
928
|
if len(treatment_summary_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
|
|
@@ -1766,7 +1766,7 @@ func MobileGetLastDryWeight(orgID int64, patientID int64) (*models.SgjPatientDry
|
1766
|
1766
|
defer redis.Close()
|
1767
|
1767
|
|
1768
|
1768
|
// cur_date := time.Now().Format("2006-01-02")
|
1769
|
|
- key := strconv.FormatInt(orgID, 10) + ":"+ strconv.FormatInt(patientID, 10) + ":last_dry_weight"
|
|
1769
|
+ key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":last_dry_weight"
|
1770
|
1770
|
last_dry_weight_str, _ := redis.Get(key).Result()
|
1771
|
1771
|
|
1772
|
1772
|
if len(last_dry_weight_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
|
|
@@ -1802,7 +1802,7 @@ func MobileGetDialysisSolutionByModeId(orgID int64, patientID int64, mode_id int
|
1802
|
1802
|
defer redis.Close()
|
1803
|
1803
|
|
1804
|
1804
|
// cur_date := time.Now().Format("2006-01-02")
|
1805
|
|
- key := strconv.FormatInt(orgID, 10) + ":"+ strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_solution"
|
|
1805
|
+ key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_solution"
|
1806
|
1806
|
dialysis_solution_str, _ := redis.Get(key).Result()
|
1807
|
1807
|
|
1808
|
1808
|
if len(dialysis_solution_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
|
|
@@ -1838,7 +1838,8 @@ func MobileGetDialysisPrescribeByModeId(orgID int64, patientID int64, recordDate
|
1838
|
1838
|
defer redis.Close()
|
1839
|
1839
|
|
1840
|
1840
|
// cur_date := time.Now().Format("2006-01-02")
|
1841
|
|
- key := strconv.FormatInt(orgID, 10) + ":"+ strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
|
|
1841
|
+ key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
|
|
1842
|
+ fmt.Println("透析处方中的keyzhi", key)
|
1842
|
1843
|
dialysis_prescribe_str, _ := redis.Get(key).Result()
|
1843
|
1844
|
|
1844
|
1845
|
if len(dialysis_prescribe_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
|
|
@@ -1873,7 +1874,7 @@ func MobileGetDialysisPrescribeByModeIdOne(orgID int64, patientID int64, recordD
|
1873
|
1874
|
defer redis.Close()
|
1874
|
1875
|
|
1875
|
1876
|
// cur_date := time.Now().Format("2006-01-02")
|
1876
|
|
- key := strconv.FormatInt(orgID, 10) + ":"+ strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":dialysis_prescribe_by_mode"
|
|
1877
|
+ key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":dialysis_prescribe_by_mode"
|
1877
|
1878
|
dialysis_prescribe_by_mode_str, _ := redis.Get(key).Result()
|
1878
|
1879
|
|
1879
|
1880
|
if len(dialysis_prescribe_by_mode_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
|
|
@@ -1915,41 +1916,54 @@ func MobileGetLastDialysisPrescribe(orgID int64, patientID int64) (*models.Dialy
|
1915
|
1916
|
return &record, nil
|
1916
|
1917
|
}
|
1917
|
1918
|
|
1918
|
|
-func MobileGetLastDialysisPrescribeByModeId(orgID int64, patientID int64, recordDate int64,mode_id int64) (*models.DialysisPrescription, error) {
|
|
1919
|
+func MobileGetLastDialysisPrescribeByModeId(orgID int64, patientID int64, mode_id int64) (*models.DialysisPrescription, error) {
|
1919
|
1920
|
var record models.DialysisPrescription
|
1920
|
|
- redis := RedisClient()
|
1921
|
|
- defer redis.Close()
|
1922
|
|
-
|
1923
|
|
- // cur_date := time.Now().Format("2006-01-02")
|
1924
|
|
- key := strconv.FormatInt(orgID, 10) + ":"+ strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe_last"
|
1925
|
|
- dialysis_prescribe_last_str, _ := redis.Get(key).Result()
|
1926
|
|
-
|
1927
|
|
- if len(dialysis_prescribe_last_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
|
1928
|
|
- err := readDb.Model(&models.DialysisPrescription{}).Where("patient_id = ? and user_org_id = ? and status = 1 AND mode_id = ? AND record_date < ?", patientID, orgID, mode_id,recordDate).Last(&record).Error
|
1929
|
|
- if err != nil {
|
1930
|
|
- if err == gorm.ErrRecordNotFound {
|
1931
|
|
- return nil, nil
|
1932
|
|
- } else {
|
1933
|
|
- return nil, err
|
1934
|
|
- }
|
|
1921
|
+ 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
|
|
1922
|
+ if err != nil {
|
|
1923
|
+ if err == gorm.ErrRecordNotFound {
|
|
1924
|
+ return nil, nil
|
1935
|
1925
|
} else {
|
1936
|
|
- if record.ID > 0 {
|
1937
|
|
- //缓存数据
|
1938
|
|
- dialysis_prescribe_last_str, err := json.Marshal(record)
|
1939
|
|
- if err == nil {
|
1940
|
|
- redis.Set(key, dialysis_prescribe_last_str, time.Second*60*60*18)
|
1941
|
|
- }
|
1942
|
|
- } else {
|
1943
|
|
- redis.Set(key, " ", time.Second*60*60*18)
|
1944
|
|
- }
|
1945
|
|
- return &record, nil
|
|
1926
|
+ return nil, err
|
1946
|
1927
|
}
|
1947
|
|
- } else { //缓存数据了数据,将redis缓存的json字符串转为map
|
1948
|
|
- json.Unmarshal([]byte(dialysis_prescribe_last_str), &record)
|
1949
|
|
- return &record, nil
|
1950
|
1928
|
}
|
|
1929
|
+ return &record, nil
|
1951
|
1930
|
}
|
1952
|
1931
|
|
|
1932
|
+//func MobileGetLastDialysisPrescribeByModeId(orgID int64, patientID int64, recordDate int64,mode_id int64) (*models.DialysisPrescription, error) {
|
|
1933
|
+// var record models.DialysisPrescription
|
|
1934
|
+// redis := RedisClient()
|
|
1935
|
+// defer redis.Close()
|
|
1936
|
+//
|
|
1937
|
+// // cur_date := time.Now().Format("2006-01-02")
|
|
1938
|
+// key := strconv.FormatInt(orgID, 10) + ":"+ strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe_last"
|
|
1939
|
+// dialysis_prescribe_last_str, _ := redis.Get(key).Result()
|
|
1940
|
+//
|
|
1941
|
+// if len(dialysis_prescribe_last_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
|
|
1942
|
+// err := readDb.Model(&models.DialysisPrescription{}).Where("patient_id = ? and user_org_id = ? and status = 1 AND mode_id = ? AND record_date < ?", patientID, orgID, mode_id,recordDate).Last(&record).Error
|
|
1943
|
+// if err != nil {
|
|
1944
|
+// if err == gorm.ErrRecordNotFound {
|
|
1945
|
+// return nil, nil
|
|
1946
|
+// } else {
|
|
1947
|
+// return nil, err
|
|
1948
|
+// }
|
|
1949
|
+// } else {
|
|
1950
|
+// if record.ID > 0 {
|
|
1951
|
+// //缓存数据
|
|
1952
|
+// dialysis_prescribe_last_str, err := json.Marshal(record)
|
|
1953
|
+// if err == nil {
|
|
1954
|
+// redis.Set(key, dialysis_prescribe_last_str, time.Second*60*60*18)
|
|
1955
|
+// }
|
|
1956
|
+// } else {
|
|
1957
|
+// redis.Set(key, " ", time.Second*60*60*18)
|
|
1958
|
+// }
|
|
1959
|
+// return &record, nil
|
|
1960
|
+// }
|
|
1961
|
+// } else { //缓存数据了数据,将redis缓存的json字符串转为map
|
|
1962
|
+// json.Unmarshal([]byte(dialysis_prescribe_last_str), &record)
|
|
1963
|
+// return &record, nil
|
|
1964
|
+// }
|
|
1965
|
+//}
|
|
1966
|
+
|
1953
|
1967
|
func GetAllAvaildDeviceNumbers(orgID int64, record_date int64, schedule_type int) ([]*DeviceNumberViewModel, error) {
|
1954
|
1968
|
var vms []*DeviceNumberViewModel = make([]*DeviceNumberViewModel, 0)
|
1955
|
1969
|
rows, err := readDb.Raw("SELECT n.*, z.name as zone_name, g.name as group_name FROM xt_device_number as n join xt_device_zone as z on z.id = n.zone_id join xt_device_group as g on g.id = n.group_id WHERE (n.org_id = ? AND n.status = 1) AND NOT EXISTS (Select * FROM xt_schedule as s Where s.`schedule_date` = ? AND s.user_org_id = n.org_id AND s.`bed_id` = n.id AND s.`schedule_type` = ? AND s.status = 1 )", orgID, record_date, schedule_type).Rows()
|
|
@@ -2453,7 +2467,7 @@ func GetAssessmentBefor(orgid int64, patientid int64, recorddate int64) (*models
|
2453
|
2467
|
func GetAllHisDoctorAdvice(orgid int64, patientid int64, recorddate int64) (his []*models.HisDoctorAdviceInfo, err error) {
|
2454
|
2468
|
redis := RedisClient()
|
2455
|
2469
|
defer redis.Close()
|
2456
|
|
- key := strconv.FormatInt(orgid, 10) + ":"+ strconv.FormatInt(patientid, 10) + ":"+ strconv.FormatInt(recorddate, 10) + ":his_doctor_advice"
|
|
2470
|
+ key := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientid, 10) + ":" + strconv.FormatInt(recorddate, 10) + ":his_doctor_advice"
|
2457
|
2471
|
his_doctor_advice_str, _ := redis.Get(key).Result()
|
2458
|
2472
|
|
2459
|
2473
|
if len(his_doctor_advice_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
|