|
@@ -572,3 +572,99 @@ func GetDataConfig(orgid int64) (list []*models.XcxDataConfig, err error) {
|
572
|
572
|
err = XTReadDB().Model(&list).Where("(org_id = ? or org_id = 0) and status = 1", orgid).Find(&list).Error
|
573
|
573
|
return list, err
|
574
|
574
|
}
|
|
575
|
+
|
|
576
|
+func GetLastScheduleListOne(patient_id int64, schedule_date int64) (models.XcxSchedule, error) {
|
|
577
|
+
|
|
578
|
+ schedule := models.XcxSchedule{}
|
|
579
|
+ err := XTReadDB().Model(&schedule).Where("patient_id = ? and status = 1 and schedule_date <=?", patient_id, schedule_date).Order("schedule_date desc").Last(&schedule).Error
|
|
580
|
+ return schedule, err
|
|
581
|
+}
|
|
582
|
+
|
|
583
|
+func GetInspectionGroupList(patientid int64, startime int64, endtime int64) (inspection []*models.XcxInspection, err error) {
|
|
584
|
+
|
|
585
|
+ db := XTReadDB().Table("xt_inspection as x").Where("x.status = 1")
|
|
586
|
+ if patientid > 0 {
|
|
587
|
+ db = db.Where("x.patient_id = ?", patientid)
|
|
588
|
+ }
|
|
589
|
+ if startime > 0 {
|
|
590
|
+ db = db.Where("x.inspect_date >= ?", startime)
|
|
591
|
+ }
|
|
592
|
+ if endtime > 0 {
|
|
593
|
+ db = db.Where("x.inspect_date <= ?", endtime)
|
|
594
|
+ }
|
|
595
|
+ err = db.Group("x.inspect_date,x.project_id").Find(&inspection).Error
|
|
596
|
+ return inspection, err
|
|
597
|
+}
|
|
598
|
+
|
|
599
|
+func GetInsepctionList(patientid int64, startime int64, endtime int64) (inspection []*models.XcxInspection, err error) {
|
|
600
|
+ db := XTReadDB().Table("xt_inspection as x").Where("x.status =1")
|
|
601
|
+ table := XTReadDB().Table("xt_inspection_reference as r")
|
|
602
|
+ fmt.Print("table", table)
|
|
603
|
+ if patientid > 0 {
|
|
604
|
+ db = db.Where("x.patient_id = ?", patientid)
|
|
605
|
+ }
|
|
606
|
+ if startime > 0 {
|
|
607
|
+ db = db.Where("x.inspect_date >= ?", startime)
|
|
608
|
+ }
|
|
609
|
+ if endtime > 0 {
|
|
610
|
+ db = db.Where("x.inspect_date <= ?", endtime)
|
|
611
|
+ }
|
|
612
|
+ err = db.Group("x.id").Select("x.id,x.patient_id,x.org_id,x.project_id,x.item_id,x.item_name,x.project_name,x.inspect_type,x.inspect_value,x.inspect_date,x.status,x.created_time,x.updated_time,r.range_type,r.range_min,r.range_max,r.range_value,r.range_options,r.unit").Joins("left join xt_inspection_reference as r on (r.item_id = x.item_id AND r.org_id > 0) OR ( x.item_id = r.id AND r.org_id = 0) ").Scan(&inspection).Error
|
|
613
|
+ return inspection, err
|
|
614
|
+}
|
|
615
|
+
|
|
616
|
+func GetArticList(activityID int64, page int64, limit int64) (story []*models.SybStory, total int64, err error) {
|
|
617
|
+
|
|
618
|
+ offset := (page - 1) * limit
|
|
619
|
+ err = UserReadDB().Model(&story).Where("activity_id = ? and audit_status = 2", activityID).Count(&total).Order("ctime desc").Offset(offset).Limit(limit).Find(&story).Error
|
|
620
|
+ return story, total, err
|
|
621
|
+}
|
|
622
|
+
|
|
623
|
+func GetArticListDetail(id int64) (models.SybStory, error) {
|
|
624
|
+
|
|
625
|
+ story := models.SybStory{}
|
|
626
|
+ err := UserReadDB().Where("id = ?", id).Find(&story).Error
|
|
627
|
+ return story, err
|
|
628
|
+}
|
|
629
|
+
|
|
630
|
+func GetStoryScoreList(activityID int64, page int64, limit int64) (score []*models.SybStoryScore, total int64, err error) {
|
|
631
|
+ offset := (page - 1) * limit
|
|
632
|
+ err = UserReadDB().Model(&score).Where("activity_id = ?", activityID).Count(&total).Offset(offset).Limit(limit).Preload("SybStory").Find(&score).Error
|
|
633
|
+ return score, total, err
|
|
634
|
+}
|
|
635
|
+
|
|
636
|
+func SendWxAuthAPI(appID string, appSecret string, grant_type string, code string) (map[string]string, error) {
|
|
637
|
+
|
|
638
|
+ var code2sessionURL = "https://api.weixin.qq.com/sns/jscode2session?appid=" + appID + "&secret=" + appSecret + "&js_code=" + code + "&grant_type=" + grant_type
|
|
639
|
+ var url = fmt.Sprintf(code2sessionURL, appID, appSecret, code)
|
|
640
|
+ fmt.Println("url233232323322323", url)
|
|
641
|
+ resp, err := http.DefaultClient.Get(code2sessionURL)
|
|
642
|
+ fmt.Println("resp32332232332322", resp)
|
|
643
|
+
|
|
644
|
+ var wxMap map[string]string
|
|
645
|
+ err = json.NewDecoder(resp.Body).Decode(&wxMap)
|
|
646
|
+ if err != nil {
|
|
647
|
+ return wxMap, err
|
|
648
|
+ }
|
|
649
|
+ defer resp.Body.Close()
|
|
650
|
+
|
|
651
|
+ return wxMap, err
|
|
652
|
+}
|
|
653
|
+
|
|
654
|
+func SendWxAuthAPIOne(appID string, appSecret string, grant_type string, code string) (string, error) {
|
|
655
|
+ var code2sessionURL = "https://api.weixin.qq.com/sns/jscode2session?appid=" + appID + "&secret=" + appSecret + "&js_code=" + code + "&grant_type=" + grant_type
|
|
656
|
+ var url = fmt.Sprintf(code2sessionURL, appID, appSecret, code)
|
|
657
|
+ fmt.Println(url)
|
|
658
|
+ resp, err := http.DefaultClient.Get(code2sessionURL)
|
|
659
|
+ if err != nil {
|
|
660
|
+ return "", err
|
|
661
|
+ }
|
|
662
|
+ var wxMap map[string]string
|
|
663
|
+ err = json.NewDecoder(resp.Body).Decode(&wxMap)
|
|
664
|
+ if err != nil {
|
|
665
|
+ return "", err
|
|
666
|
+ }
|
|
667
|
+ defer resp.Body.Close()
|
|
668
|
+ fmt.Println("2333232232", wxMap)
|
|
669
|
+ return wxMap["session_key"], nil
|
|
670
|
+}
|