Procházet zdrojové kódy

Merge branch '20201014_xt_api_new_branch' of http://git.shengws.com/csx/XT_New into 20201014_xt_api_new_branch

csx před 4 roky
rodič
revize
db7a892ac8

+ 128 - 13
controllers/gdyb_controller.go Zobrazit soubor

1
 package controllers
1
 package controllers
2
 
2
 
3
 import (
3
 import (
4
+	"XT_New/models"
4
 	"XT_New/service"
5
 	"XT_New/service"
6
+	"XT_New/utils"
7
+	"encoding/json"
8
+	"fmt"
5
 	"github.com/astaxie/beego"
9
 	"github.com/astaxie/beego"
10
+	"io/ioutil"
6
 )
11
 )
7
 
12
 
8
 type GdybController struct {
13
 type GdybController struct {
14
 	beego.Router("/gdyb/two", &GdybController{}, "get:PostTwo")
19
 	beego.Router("/gdyb/two", &GdybController{}, "get:PostTwo")
15
 	beego.Router("/gdyb/three", &GdybController{}, "get:PostThree")
20
 	beego.Router("/gdyb/three", &GdybController{}, "get:PostThree")
16
 	beego.Router("/gdyb/four", &GdybController{}, "get:PostFour")
21
 	beego.Router("/gdyb/four", &GdybController{}, "get:PostFour")
17
-	beego.Router("/gdyb/five", &GdybController{}, "get:PostFive")
22
+	beego.Router("/gdyb/five", &GdybController{}, "post:PostFive")
18
 	beego.Router("/gdyb/six", &GdybController{}, "get:PostSix")
23
 	beego.Router("/gdyb/six", &GdybController{}, "get:PostSix")
19
 	beego.Router("/gdyb/seven", &GdybController{}, "get:PostSeven")
24
 	beego.Router("/gdyb/seven", &GdybController{}, "get:PostSeven")
20
 	beego.Router("/gdyb/eight", &GdybController{}, "get:PostEight")
25
 	beego.Router("/gdyb/eight", &GdybController{}, "get:PostEight")
23
 
28
 
24
 //provinces, _ := service.GetDistrictsByUpid(0)21
29
 //provinces, _ := service.GetDistrictsByUpid(0)21
25
 
30
 
31
+type Result struct {
32
+	ErrMsg      interface{} `json:"err_msg"`
33
+	InfRefmsgid string      `json:"inf_refmsgid"`
34
+	Infcode     int64       `json:"infcode"`
35
+	Output      struct {
36
+		Baseinfo struct {
37
+			Age         float64 `json:"age"`
38
+			Brdy        string  `json:"brdy"`
39
+			Certno      string  `json:"certno"`
40
+			Gend        string  `json:"gend"`
41
+			Naty        string  `json:"naty"`
42
+			PsnCertType string  `json:"psn_cert_type"`
43
+			PsnName     string  `json:"psn_name"`
44
+			PsnNo       string  `json:"psn_no"`
45
+		} `json:"baseinfo"`
46
+		Idetinfo []interface{} `json:"idetinfo"`
47
+		Iinfo    []struct {
48
+			Balc                   int64       `json:"balc"`
49
+			CvlservFlag            string      `json:"cvlserv_flag"`
50
+			EmpName                string      `json:"emp_name"`
51
+			InsuplcAdmdvs          string      `json:"insuplc_admdvs"`
52
+			Insutype               string      `json:"insutype"`
53
+			PausInsuDansuplcAdmdvs string      `json:"paus_insu_dansuplc_admdvs"`
54
+			PausInsuDate           interface{} `json:"paus_insu_date"`
55
+			PsnInsuDate            string      `json:"psn_insu_date"`
56
+			PsnInsuStas            string      `json:"psn_insu_stas"`
57
+			PsnType                string      `json:"psn_type"`
58
+		} `json:"iinfo"`
59
+	} `json:"output"`
60
+	RefmsgTime  string      `json:"refmsg_time"`
61
+	RespondTime string      `json:"respond_time"`
62
+	Signtype    interface{} `json:"signtype"`
63
+	WarnInfo    interface{} `json:"warn_info"`
64
+}
65
+
26
 func (c *GdybController) PostOne() {
66
 func (c *GdybController) PostOne() {
27
 	certNo := c.GetString("cert_no")
67
 	certNo := c.GetString("cert_no")
28
 	result := service.Gdyb1101(certNo)
68
 	result := service.Gdyb1101(certNo)
69
+
70
+	var dat map[string]interface{}
71
+	if err := json.Unmarshal([]byte(result), &dat); err == nil {
72
+		fmt.Println("11111")
73
+		fmt.Println(dat)
74
+		//fmt.Println(dat["status"])
75
+	} else {
76
+		fmt.Println(err)
77
+	}
78
+
29
 	c.ServeSuccessJSON(map[string]interface{}{
79
 	c.ServeSuccessJSON(map[string]interface{}{
30
-		"pre": result,
80
+		"pre": dat,
31
 	})
81
 	})
32
 }
82
 }
33
 
83
 
36
 	insutype := c.GetString("insutype")
86
 	insutype := c.GetString("insutype")
37
 	certNo := c.GetString("cert_no")
87
 	certNo := c.GetString("cert_no")
38
 	result := service.Gdyb2201(psnNo, insutype, certNo)
88
 	result := service.Gdyb2201(psnNo, insutype, certNo)
89
+
90
+	var dat map[string]interface{}
91
+	if err := json.Unmarshal([]byte(result), &dat); err == nil {
92
+		fmt.Println("22222222")
93
+		fmt.Println(dat)
94
+		//fmt.Println(dat["status"])
95
+	} else {
96
+		fmt.Println(err)
97
+	}
98
+
39
 	c.ServeSuccessJSON(map[string]interface{}{
99
 	c.ServeSuccessJSON(map[string]interface{}{
40
-		"pre": result,
100
+		"pre": dat,
41
 	})
101
 	})
42
 }
102
 }
43
 
103
 
59
 	})
119
 	})
60
 }
120
 }
61
 
121
 
62
-func (c *GdybController) PostFive() {
63
-	psnNo := c.GetString("psn_no")
64
-	mdtrtId := c.GetString("mdtrt_id")
65
-	prescriptions, _ := service.GetHisPrescription(4, 1, 1605715200)
122
+type All struct {
123
+	HisPrescription HisPrescription
124
+	mdtrt_id        string
125
+	psn_no          string
126
+}
66
 
127
 
67
-	result := service.Gdyb2204(psnNo, mdtrtId, prescriptions)
128
+type HisPrescription struct {
129
+	ID                     int64                            `gorm:"column:id" json:"id" form:"id"`
130
+	UserOrgId              int64                            `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
131
+	RecordDate             int64                            `gorm:"column:record_date" json:"record_date" form:"record_date"`
132
+	PatientId              int64                            `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
133
+	HisPatientId           int64                            `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
134
+	Status                 int64                            `gorm:"column:status" json:"status" form:"status"`
135
+	Ctime                  int64                            `gorm:"column:ctime" json:"ctime" form:"ctime"`
136
+	Mtime                  int64                            `gorm:"column:mtime" json:"mtime" form:"mtime"`
137
+	Number                 string                           `gorm:"column:number" json:"number" form:"number"`
138
+	Type                   int64                            `gorm:"column:type" json:"type" form:"type"`
139
+	Doctor                 int64                            `gorm:"column:doctor" json:"doctor" form:"doctor"`
140
+	Creator                int64                            `gorm:"column:creator" json:"creator" form:"creator"`
141
+	Modifier               int64                            `gorm:"column:modifier" json:"modifier" form:"modifier"`
142
+	HisDoctorAdviceInfo    []*models.HisDoctorAdviceInfo    `gorm:"ForeignKey:PatientId,RecordDate,PrescriptionId;AssociationForeignKey:PatientId,RecordDate,ID" json:"advices"`
143
+	HisPrescriptionProject []*models.HisPrescriptionProject `gorm:"ForeignKey:PatientId,RecordDate,PrescriptionId;AssociationForeignKey:PatientId,RecordDate,ID" json:"project"`
144
+}
68
 
145
 
146
+func (c *GdybController) PostFive() {
147
+	body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
148
+	var respJSON map[string]interface{}
149
+	if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
150
+		utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
151
+		return
152
+	}
153
+	userJSONBytes, _ := json.Marshal(respJSON["pre"])
154
+	var hp []*models.HisPrescription
155
+	if err := json.Unmarshal(userJSONBytes, &hp); err != nil {
156
+		utils.ErrorLog("解析失败:%v", err)
157
+		return
158
+	}
159
+	result := service.Gdyb2204(respJSON["psn_no"].(string), respJSON["mdtrt_id"].(string), hp, respJSON["chrg_bchno"].(string))
160
+
161
+	var dat map[string]interface{}
162
+	if err := json.Unmarshal([]byte(result), &dat); err == nil {
163
+		fmt.Println(dat)
164
+	} else {
165
+		fmt.Println(err)
166
+	}
69
 	c.ServeSuccessJSON(map[string]interface{}{
167
 	c.ServeSuccessJSON(map[string]interface{}{
70
-		"pre": result,
168
+		"pre": dat,
71
 	})
169
 	})
72
 }
170
 }
73
 
171
 
76
 	mdtrtId := c.GetString("mdtrt_id")
174
 	mdtrtId := c.GetString("mdtrt_id")
77
 	chrgBchno := c.GetString("chrg_bchno")
175
 	chrgBchno := c.GetString("chrg_bchno")
78
 	result := service.Gdyb2205(psnNo, mdtrtId, chrgBchno)
176
 	result := service.Gdyb2205(psnNo, mdtrtId, chrgBchno)
177
+
79
 	c.ServeSuccessJSON(map[string]interface{}{
178
 	c.ServeSuccessJSON(map[string]interface{}{
80
 		"pre": result,
179
 		"pre": result,
81
 	})
180
 	})
87
 	chrgBchno := c.GetString("chrg_bchno")
186
 	chrgBchno := c.GetString("chrg_bchno")
88
 	certNo := c.GetString("cert_no")
187
 	certNo := c.GetString("cert_no")
89
 	insutype := c.GetString("insutype")
188
 	insutype := c.GetString("insutype")
90
-	result := service.Gdyb2206(psnNo, mdtrtId, chrgBchno, certNo, insutype)
189
+	total := c.GetString("total")
190
+
191
+	result := service.Gdyb2206(psnNo, mdtrtId, chrgBchno, certNo, insutype, total)
192
+	var dat map[string]interface{}
193
+	if err := json.Unmarshal([]byte(result), &dat); err == nil {
194
+		fmt.Println(dat)
195
+	} else {
196
+		fmt.Println(err)
197
+	}
91
 	c.ServeSuccessJSON(map[string]interface{}{
198
 	c.ServeSuccessJSON(map[string]interface{}{
92
-		"pre": result,
199
+		"pre": dat,
93
 	})
200
 	})
94
 }
201
 }
95
 
202
 
99
 	chrgBchno := c.GetString("chrg_bchno")
206
 	chrgBchno := c.GetString("chrg_bchno")
100
 	certNo := c.GetString("cert_no")
207
 	certNo := c.GetString("cert_no")
101
 	insutype := c.GetString("insutype")
208
 	insutype := c.GetString("insutype")
102
-	result := service.Gdyb2207(psnNo, mdtrtId, chrgBchno, certNo, insutype)
209
+	total := c.GetString("total")
210
+	result := service.Gdyb2207(psnNo, mdtrtId, chrgBchno, certNo, insutype, total)
211
+	var dat map[string]interface{}
212
+	if err := json.Unmarshal([]byte(result), &dat); err == nil {
213
+		fmt.Println(dat)
214
+	} else {
215
+		fmt.Println(err)
216
+	}
217
+
103
 	c.ServeSuccessJSON(map[string]interface{}{
218
 	c.ServeSuccessJSON(map[string]interface{}{
104
-		"pre": result,
219
+		"pre": dat,
105
 	})
220
 	})
106
 }
221
 }
107
 
222
 

+ 383 - 5
controllers/his_api_controller.go Zobrazit soubor

5
 	"XT_New/models"
5
 	"XT_New/models"
6
 	"XT_New/service"
6
 	"XT_New/service"
7
 	"XT_New/utils"
7
 	"XT_New/utils"
8
+	"bytes"
8
 	"encoding/json"
9
 	"encoding/json"
9
 	"fmt"
10
 	"fmt"
10
 	"github.com/astaxie/beego"
11
 	"github.com/astaxie/beego"
12
+	"io/ioutil"
13
+	"math/rand"
14
+	"net/http"
11
 	"reflect"
15
 	"reflect"
12
 	"strconv"
16
 	"strconv"
13
 	"time"
17
 	"time"
32
 	beego.Router("/api/doctorworkstation/casehistorytemplate/get", &HisApiController{}, "get:GetCaseHistoryTemplate")
36
 	beego.Router("/api/doctorworkstation/casehistorytemplate/get", &HisApiController{}, "get:GetCaseHistoryTemplate")
33
 	beego.Router("/api/doctorworkstation/printcasehistory/get", &HisApiController{}, "get:GetPrintHisPatientCaseHistory")
37
 	beego.Router("/api/doctorworkstation/printcasehistory/get", &HisApiController{}, "get:GetPrintHisPatientCaseHistory")
34
 
38
 
39
+	beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
40
+	beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
41
+
35
 }
42
 }
36
 
43
 
37
 func (c *HisApiController) GetHisPatientList() {
44
 func (c *HisApiController) GetHisPatientList() {
91
 	admin := c.GetAdminUserInfo()
98
 	admin := c.GetAdminUserInfo()
92
 	his_patient_info, _ := service.GetHisPatientInfo(admin.CurrentOrgId, patient_id, recordDateTime)
99
 	his_patient_info, _ := service.GetHisPatientInfo(admin.CurrentOrgId, patient_id, recordDateTime)
93
 	xt_patient_info, _ := service.GetXTPatientInfo(admin.CurrentOrgId, patient_id)
100
 	xt_patient_info, _ := service.GetXTPatientInfo(admin.CurrentOrgId, patient_id)
94
-
95
 	prescriptions, _ := service.GetHisPrescription(admin.CurrentOrgId, patient_id, recordDateTime)
101
 	prescriptions, _ := service.GetHisPrescription(admin.CurrentOrgId, patient_id, recordDateTime)
96
-
97
-	//prescriptions, _ := service.GetHisPrescription(admin.CurrentOrgId, patient_id, recordDateTime)
98
 	case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.CurrentOrgId, patient_id, recordDateTime)
102
 	case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.CurrentOrgId, patient_id, recordDateTime)
99
-
100
 	c.ServeSuccessJSON(map[string]interface{}{
103
 	c.ServeSuccessJSON(map[string]interface{}{
101
 		"his_info":     his_patient_info,
104
 		"his_info":     his_patient_info,
102
 		"xt_info":      xt_patient_info,
105
 		"xt_info":      xt_patient_info,
137
 	//diagnose := c.GetString("diagnose")
140
 	//diagnose := c.GetString("diagnose")
138
 	//sick_history := c.GetString("sick_history")
141
 	//sick_history := c.GetString("sick_history")
139
 	doctor, _ := c.GetInt64("doctor")
142
 	doctor, _ := c.GetInt64("doctor")
140
-	//departm/**/ent, _ := c.GetInt64("department")
143
+	//department, _ := c.GetInt64("department")
141
 	his_patient_id, _ := c.GetInt64("his_patient_id")
144
 	his_patient_id, _ := c.GetInt64("his_patient_id")
142
 	dataBody := make(map[string]interface{}, 0)
145
 	dataBody := make(map[string]interface{}, 0)
143
 	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
146
 	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
157
 	adminInfo := c.GetAdminUserInfo()
160
 	adminInfo := c.GetAdminUserInfo()
158
 	recordDateTime := theTime.Unix()
161
 	recordDateTime := theTime.Unix()
159
 
162
 
163
+	//hpInfo := models.HisPrescriptionInfo{
164
+	//	UserOrgId: adminInfo.CurrentOrgId,
165
+	//	RecordDate: theTime.Unix(),
166
+	//	PatientId:   patient_id,
167
+	//	Status: 1,
168
+	//	Ctime: time.Now().Unix(),
169
+	//	Mtime: time.Now().Unix(),
170
+	//	Creator: adminInfo.AdminUser.Id,
171
+	//	Modifier: adminInfo.AdminUser.Id,
172
+	//	Diagnosis: diagnose,
173
+	//	SickHistory: sick_history,
174
+	//	Departments:department,
175
+	//
176
+	//}
177
+	//
178
+
160
 	if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
179
 	if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
161
 		prescriptions, _ := dataBody["prescriptions"].([]interface{})
180
 		prescriptions, _ := dataBody["prescriptions"].([]interface{})
162
 
181
 
493
 	})
512
 	})
494
 
513
 
495
 }
514
 }
515
+
516
+type ResultTwo struct {
517
+	ErrMsg      interface{} `json:"err_msg"`
518
+	InfRefmsgid string      `json:"inf_refmsgid"`
519
+	Infcode     int64       `json:"infcode"`
520
+	Output      struct {
521
+		Baseinfo struct {
522
+			Age         float64 `json:"age"`
523
+			Brdy        string  `json:"brdy"`
524
+			Certno      string  `json:"certno"`
525
+			Gend        string  `json:"gend"`
526
+			Naty        string  `json:"naty"`
527
+			PsnCertType string  `json:"psn_cert_type"`
528
+			PsnName     string  `json:"psn_name"`
529
+			PsnNo       string  `json:"psn_no"`
530
+		} `json:"baseinfo"`
531
+		Idetinfo []interface{} `json:"idetinfo"`
532
+		Iinfo    []struct {
533
+			Balc                   int64       `json:"balc"`
534
+			CvlservFlag            string      `json:"cvlserv_flag"`
535
+			EmpName                string      `json:"emp_name"`
536
+			InsuplcAdmdvs          string      `json:"insuplc_admdvs"`
537
+			Insutype               string      `json:"insutype"`
538
+			PausInsuDansuplcAdmdvs string      `json:"paus_insu_dansuplc_admdvs"`
539
+			PausInsuDate           interface{} `json:"paus_insu_date"`
540
+			PsnInsuDate            string      `json:"psn_insu_date"`
541
+			PsnInsuStas            string      `json:"psn_insu_stas"`
542
+			PsnType                string      `json:"psn_type"`
543
+		} `json:"insuinfo"`
544
+	} `json:"output"`
545
+	RefmsgTime  string      `json:"refmsg_time"`
546
+	RespondTime string      `json:"respond_time"`
547
+	Signtype    interface{} `json:"signtype"`
548
+	WarnInfo    interface{} `json:"warn_info"`
549
+}
550
+
551
+type ResultThree struct {
552
+	Cainfo      interface{} `json:"cainfo"`
553
+	ErrMsg      interface{} `json:"err_msg"`
554
+	InfRefmsgid string      `json:"inf_refmsgid"`
555
+	Infcode     int64       `json:"infcode"`
556
+	Output      struct {
557
+		Data struct {
558
+			IptOtpNo string `json:"ipt_otp_no"`
559
+			MdtrtID  string `json:"mdtrt_id"`
560
+			PsnNo    string `json:"psn_no"`
561
+		} `json:"data"`
562
+	} `json:"output"`
563
+	RefmsgTime  string      `json:"refmsg_time"`
564
+	RespondTime string      `json:"respond_time"`
565
+	Signtype    interface{} `json:"signtype"`
566
+	WarnMsg     interface{} `json:"warn_msg"`
567
+}
568
+
569
+func (c *HisApiController) GetRegisterInfo() {
570
+	id, _ := c.GetInt64("id")
571
+	record_time := c.GetString("record_time")
572
+
573
+	adminInfo := c.GetAdminUserInfo()
574
+	patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
575
+
576
+	if patient == nil {
577
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
578
+		return
579
+	}
580
+	if len(patient.IdCardNo) == 0 {
581
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
582
+		return
583
+	}
584
+
585
+	timeLayout := "2006-01-02"
586
+	loc, _ := time.LoadLocation("Local")
587
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
588
+	if err != nil {
589
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
590
+		return
591
+	}
592
+
593
+	api := "http://127.0.0.1:9531/" + "gdyb/one?cert_no=" + "44020219710324062X"
594
+	resp, requestErr := http.Get(api)
595
+
596
+	if requestErr != nil {
597
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
598
+		return
599
+	}
600
+	defer resp.Body.Close()
601
+	body, ioErr := ioutil.ReadAll(resp.Body)
602
+	if ioErr != nil {
603
+		utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
604
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
605
+		return
606
+	}
607
+	var respJSON map[string]interface{}
608
+
609
+	if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
610
+		utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
611
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
612
+		return
613
+	}
614
+
615
+	userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
616
+	userJSONBytes, _ := json.Marshal(userJSON)
617
+	var res ResultTwo
618
+	if err := json.Unmarshal(userJSONBytes, &res); err != nil {
619
+		utils.ErrorLog("解析失败:%v", err)
620
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
621
+		return
622
+	}
623
+	Iinfos, _ := json.Marshal(res.Output.Iinfo)
624
+	Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
625
+	infoStr := string(Iinfos)
626
+	idetinfoStr := string(Idetinfos)
627
+
628
+	his := models.VMHisPatient{
629
+		PsnNo:       res.Output.Baseinfo.PsnNo,
630
+		PsnCertType: res.Output.Baseinfo.PsnCertType,
631
+		Certno:      res.Output.Baseinfo.Certno,
632
+		PsnName:     res.Output.Baseinfo.PsnName,
633
+		Gend:        res.Output.Baseinfo.Gend,
634
+		Naty:        res.Output.Baseinfo.Naty,
635
+		Brdy:        res.Output.Baseinfo.Brdy,
636
+		Age:         res.Output.Baseinfo.Age,
637
+		Iinfo:       infoStr,
638
+		Idetinfo:    idetinfoStr,
639
+		PatientId:   patient.ID,
640
+		RecordDate:  theTime.Unix(),
641
+	}
642
+	fmt.Println(his)
643
+
644
+	if res.Output.Iinfo == nil || len(res.Output.Iinfo) == 0 {
645
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterOneException)
646
+		return
647
+	}
648
+
649
+	count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
650
+	if count <= 0 {
651
+		api := "http://127.0.0.1:9531/" + "gdyb/two?cert_no=" + patient.IdCardNo + "&insutype=" + res.Output.Iinfo[0].Insutype + "&psn_no=" + res.Output.Baseinfo.PsnNo
652
+		resp, requestErr := http.Get(api)
653
+		if requestErr != nil {
654
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
655
+			return
656
+		}
657
+		defer resp.Body.Close()
658
+		body, ioErr := ioutil.ReadAll(resp.Body)
659
+		if ioErr != nil {
660
+			utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
661
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
662
+			return
663
+		}
664
+		var respJSON map[string]interface{}
665
+		if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
666
+			utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
667
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
668
+			return
669
+		}
670
+
671
+		respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
672
+		userJSONBytes, _ := json.Marshal(respJSON)
673
+		var res ResultThree
674
+		if err := json.Unmarshal(userJSONBytes, &res); err != nil {
675
+			utils.ErrorLog("解析失败:%v", err)
676
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
677
+			return
678
+		}
679
+		if res.Infcode == -1 {
680
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterTwoException)
681
+			return
682
+		}
683
+		fmt.Println("000!!!!!!")
684
+		fmt.Println(res)
685
+		fmt.Println(res.Output.Data.MdtrtID)
686
+		fmt.Println(res.Output.Data.PsnNo)
687
+		fmt.Println(res.Output.Data.IptOtpNo)
688
+
689
+		his.Number = res.Output.Data.MdtrtID
690
+		his.PsnNo = res.Output.Data.PsnNo
691
+		his.IptOtpNo = res.Output.Data.IptOtpNo
692
+		his.IdCardNo = patient.IdCardNo
693
+		his.PhoneNumber = patient.Phone
694
+		his.UserOrgId = adminInfo.CurrentOrgId
695
+		his.Status = 1
696
+		his.Ctime = time.Now().Unix()
697
+		his.Mtime = time.Now().Unix()
698
+		err := service.CreateHisPatientTwo(&his)
699
+		if err == nil {
700
+			c.ServeSuccessJSON(map[string]interface{}{
701
+				"his_info": his,
702
+			})
703
+		} else {
704
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
705
+			return
706
+		}
707
+
708
+	}
709
+
710
+}
711
+
496
 func (c *HisApiController) GetPrintHisPatientCaseHistory() {
712
 func (c *HisApiController) GetPrintHisPatientCaseHistory() {
497
 
713
 
498
 }
714
 }
567
 		price, _ := strconv.ParseFloat(json["retail_price"].(string), 64)
783
 		price, _ := strconv.ParseFloat(json["retail_price"].(string), 64)
568
 		advice.Price = price
784
 		advice.Price = price
569
 	}
785
 	}
786
+	if json["medical_insurance_number"] != nil || reflect.TypeOf(json["medical_insurance_number"]).String() == "string" {
787
+		med_list_codg, _ := json["medical_insurance_number"].(string)
788
+		advice.MedListCodg = med_list_codg
789
+	}
790
+
570
 	return 0
791
 	return 0
571
 }
792
 }
572
 
793
 
587
 	return 0
808
 	return 0
588
 
809
 
589
 }
810
 }
811
+
812
+type ResultFour struct {
813
+	Cainfo      string `json:"cainfo"`
814
+	ErrMsg      string `json:"err_msg"`
815
+	InfRefmsgid string `json:"inf_refmsgid"`
816
+	Infcode     int64  `json:"infcode"`
817
+	Output      struct {
818
+		Result []struct {
819
+			BasMednFlag      string `json:"bas_medn_flag"`
820
+			ChldMedcFlag     string `json:"chld_medc_flag"`
821
+			ChrgitmLv        string `json:"chrgitm_lv"`
822
+			Cnt              int64  `json:"cnt"`
823
+			DetItemFeeSumamt int64  `json:"det_item_fee_sumamt"`
824
+			DrtReimFlag      string `json:"drt_reim_flag"`
825
+			FeedetlSn        string `json:"feedetl_sn"`
826
+			FulamtOwnpayAmt  int64  `json:"fulamt_ownpay_amt"`
827
+			HiNegoDrugFlag   string `json:"hi_nego_drug_flag"`
828
+			InscpScpAmt      int64  `json:"inscp_scp_amt"`
829
+			ListSpItemFlag   string `json:"list_sp_item_flag"`
830
+			LmtUsedFlag      string `json:"lmt_used_flag"`
831
+			MedChrgitmType   string `json:"med_chrgitm_type"`
832
+			Memo             string `json:"memo"`
833
+			OverlmtAmt       int64  `json:"overlmt_amt"`
834
+			PreselfpayAmt    int64  `json:"preselfpay_amt"`
835
+			Pric             int64  `json:"pric"`
836
+			PricUplmtAmt     int64  `json:"pric_uplmt_amt"`
837
+			SelfpayProp      int64  `json:"selfpay_prop"`
838
+		} `json:"result"`
839
+	} `json:"output"`
840
+	RefmsgTime  string `json:"refmsg_time"`
841
+	RespondTime string `json:"respond_time"`
842
+	Signtype    string `json:"signtype"`
843
+	WarnMsg     string `json:"warn_msg"`
844
+}
845
+
846
+type ResultFive struct {
847
+	Insutype string `json:"insutype"`
848
+}
849
+
850
+func (c *HisApiController) GetUploadInfo() {
851
+	id, _ := c.GetInt64("id")
852
+	record_time := c.GetString("record_time")
853
+
854
+	//record_date := c.GetString("record_date")
855
+
856
+	timeLayout := "2006-01-02"
857
+	loc, _ := time.LoadLocation("Local")
858
+
859
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
860
+	if err != nil {
861
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
862
+		return
863
+	}
864
+	recordDateTime := theTime.Unix()
865
+	adminUser := c.GetAdminUserInfo()
866
+	prescriptions, _ := service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
867
+
868
+	his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
869
+
870
+	timestamp := time.Now().Unix()
871
+	tempTime := time.Unix(timestamp, 0)
872
+	timeFormat := tempTime.Format("20060102150405")
873
+	chrgBchno := rand.Intn(100000) + 10000
874
+	chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
875
+
876
+	client := &http.Client{}
877
+	data := make(map[string]interface{})
878
+	data["psn_no"] = his.PsnNo
879
+	data["mdtrt_id"] = his.Number
880
+	data["pre"] = prescriptions
881
+	data["chrg_bchno"] = chrg_bchno
882
+	bytesData, _ := json.Marshal(data)
883
+	req, _ := http.NewRequest("POST", "http://127.0.0.1:9531/"+"gdyb/five", bytes.NewReader(bytesData))
884
+	resp, _ := client.Do(req)
885
+
886
+	defer resp.Body.Close()
887
+	body, ioErr := ioutil.ReadAll(resp.Body)
888
+	if ioErr != nil {
889
+		utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
890
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
891
+		return
892
+	}
893
+	var respJSON map[string]interface{}
894
+	if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
895
+		utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
896
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
897
+		return
898
+	}
899
+
900
+	respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
901
+	userJSONBytes, _ := json.Marshal(respJSON)
902
+	var res ResultFour
903
+	if err := json.Unmarshal(userJSONBytes, &res); err != nil {
904
+		utils.ErrorLog("解析失败:%v", err)
905
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
906
+		return
907
+	}
908
+
909
+	var total float64
910
+	for _, item := range prescriptions {
911
+		if item.Type == 1 { //药品
912
+			for _, subItem := range item.HisDoctorAdviceInfo {
913
+				total = total + (subItem.Price * subItem.PrescribingNumber)
914
+			}
915
+		}
916
+		if item.Type == 2 { //项目
917
+			for _, subItem := range item.HisPrescriptionProject {
918
+				total = total + (subItem.Price * float64(subItem.Count))
919
+			}
920
+		}
921
+	}
922
+	allTotal := fmt.Sprintf("%.2f", total)
923
+	fmt.Println(allTotal)
924
+	if res.Infcode == 0 {
925
+		var rf []*ResultFive
926
+		json.Unmarshal([]byte(his.Iinfo), &rf)
927
+		psn_no := his.PsnNo
928
+		mdtrt_id := his.Number
929
+		chrg_bchno := chrg_bchno
930
+		cert_no := his.Certno
931
+		insutype := rf[0].Insutype
932
+		api := "http://127.0.0.1:9531/" + "gdyb/eight?cert_no=" + cert_no + "&insutype=" +
933
+			insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
934
+			"&total=" + allTotal
935
+		resp, requestErr := http.Get(api)
936
+
937
+		if requestErr != nil {
938
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
939
+			return
940
+		}
941
+		defer resp.Body.Close()
942
+		body, ioErr := ioutil.ReadAll(resp.Body)
943
+		if ioErr != nil {
944
+			utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
945
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
946
+			return
947
+		}
948
+		var respJSON map[string]interface{}
949
+		if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
950
+			utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
951
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
952
+			return
953
+		}
954
+		fmt.Println(respJSON)
955
+		respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
956
+		userJSONBytes, _ := json.Marshal(respJSON)
957
+		var res ResultFour
958
+		if err := json.Unmarshal(userJSONBytes, &res); err != nil {
959
+			utils.ErrorLog("解析失败:%v", err)
960
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
961
+			return
962
+		}
963
+
964
+	} else {
965
+
966
+	}
967
+}

+ 1 - 1
controllers/mobile_api_controllers/check_weight_api_controller.go Zobrazit soubor

643
 		evaluation.WeightBefore = weighing_before
643
 		evaluation.WeightBefore = weighing_before
644
 		evaluation.AssessmentTime = time.Now().Unix()
644
 		evaluation.AssessmentTime = time.Now().Unix()
645
 
645
 
646
-		err = service.UpadatePredialysisEvaluation(&evaluation)
646
+		err := service.UpadatePredialysisEvaluation(&evaluation)
647
 		if err != nil {
647
 		if err != nil {
648
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
648
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
649
 			return
649
 			return

+ 12 - 0
enums/error_code.go Zobrazit soubor

212
 	ErrorCodeOpenStocktWrong = 20053
212
 	ErrorCodeOpenStocktWrong = 20053
213
 
213
 
214
 	ErrorCodeDrugRepeatDataException = 20054
214
 	ErrorCodeDrugRepeatDataException = 20054
215
+
216
+	ErrorCodeIDCartNo = 20055
217
+
218
+	ErrorCodeRegisterOneException = 20066
219
+
220
+	ErrorCodeRegisterTwoException = 20067
215
 )
221
 )
216
 
222
 
217
 var ErrCodeMsgs = map[int]string{
223
 var ErrCodeMsgs = map[int]string{
414
 	ErrorCodeOpenStocktWrong:   "未开启自动扣减功能,无法出库",
420
 	ErrorCodeOpenStocktWrong:   "未开启自动扣减功能,无法出库",
415
 
421
 
416
 	ErrorCodeDrugRepeatDataException: "该药已经存在,无法添加",
422
 	ErrorCodeDrugRepeatDataException: "该药已经存在,无法添加",
423
+
424
+	ErrorCodeIDCartNo: "身份证不能为空",
425
+
426
+	ErrorCodeRegisterOneException: "无参保信息",
427
+
428
+	ErrorCodeRegisterTwoException: "挂号失败",
417
 }
429
 }
418
 
430
 
419
 type SGJError struct {
431
 type SGJError struct {

+ 123 - 15
models/his_models.go Zobrazit soubor

237
 	return "his_patient_case_history"
237
 	return "his_patient_case_history"
238
 }
238
 }
239
 
239
 
240
-type HisPatientInfo struct {
240
+type HisPrescriptionInfo struct {
241
 	ID           int64  `gorm:"column:id" json:"id" form:"id"`
241
 	ID           int64  `gorm:"column:id" json:"id" form:"id"`
242
 	UserOrgId    int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
242
 	UserOrgId    int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
243
 	RecordDate   int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
243
 	RecordDate   int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
251
 	Diagnosis    string `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
251
 	Diagnosis    string `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
252
 	SickType     string `gorm:"column:sick_type" json:"sick_type" form:"sick_type"`
252
 	SickType     string `gorm:"column:sick_type" json:"sick_type" form:"sick_type"`
253
 	PType        string `gorm:"column:p_type" json:"p_type" form:"p_type"`
253
 	PType        string `gorm:"column:p_type" json:"p_type" form:"p_type"`
254
+	SickHistory  string `gorm:"column:sick_history" json:"sick_history" form:"sick_history"`
255
+	Departments  int64  `gorm:"column:departments" json:"departments" form:"departments"`
254
 }
256
 }
255
 
257
 
256
-func (HisPatientInfo) TableName() string {
257
-	return "his_patient_info"
258
+func (HisPrescriptionInfo) TableName() string {
259
+	return "his_prescription_info"
258
 }
260
 }
259
 
261
 
260
 type HisPrescription struct {
262
 type HisPrescription struct {
403
 }
405
 }
404
 
406
 
405
 type HisPrescriptionProject struct {
407
 type HisPrescriptionProject struct {
406
-	ID             int64   `gorm:"column:id" json:"id" form:"id"`
407
-	ProjectId      int64   `gorm:"column:project_id" json:"project_id" form:"project_id"`
408
-	Price          float64 `gorm:"column:price" json:"price" form:"price"`
409
-	UserOrgId      int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
410
-	Status         int64   `gorm:"column:status" json:"status" form:"status"`
411
-	Ctime          int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
412
-	Mtime          int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
413
-	PatientId      int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
414
-	HisPatientId   int64   `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
415
-	RecordDate     int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
416
-	PrescriptionId int64   `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
417
-	Count          int64   `gorm:"column:count" json:"count" form:"count"`
408
+	ID             int64       `gorm:"column:id" json:"id" form:"id"`
409
+	ProjectId      int64       `gorm:"column:project_id" json:"project_id" form:"project_id"`
410
+	Price          float64     `gorm:"column:price" json:"price" form:"price"`
411
+	UserOrgId      int64       `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
412
+	Status         int64       `gorm:"column:status" json:"status" form:"status"`
413
+	Ctime          int64       `gorm:"column:ctime" json:"ctime" form:"ctime"`
414
+	Mtime          int64       `gorm:"column:mtime" json:"mtime" form:"mtime"`
415
+	PatientId      int64       `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
416
+	HisPatientId   int64       `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
417
+	RecordDate     int64       `gorm:"column:record_date" json:"record_date" form:"record_date"`
418
+	PrescriptionId int64       `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
419
+	Count          int64       `gorm:"column:count" json:"count" form:"count"`
420
+	HisProject     *HisProject `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
418
 }
421
 }
419
 
422
 
420
 func (HisPrescriptionProject) TableName() string {
423
 func (HisPrescriptionProject) TableName() string {
498
 func (XtHisPatient) TableName() string {
501
 func (XtHisPatient) TableName() string {
499
 	return "his_patient"
502
 	return "his_patient"
500
 }
503
 }
504
+
505
+type HisOrder struct {
506
+	ID                 int64  `gorm:"column:id" json:"id" form:"id"`
507
+	UserOrgId          int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
508
+	HisPatientId       int64  `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
509
+	SettleAccountsDate int64  `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
510
+	Ctime              int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
511
+	Mtime              int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
512
+	Status             int64  `gorm:"column:status" json:"status" form:"status"`
513
+	Number             int64  `gorm:"column:number" json:"number" form:"number"`
514
+	PatientId          int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
515
+	Infcode            int64  `gorm:"column:infcode" json:"infcode" form:"infcode"`
516
+	WarnMsg            string `gorm:"column:warn_msg" json:"warn_msg" form:"warn_msg"`
517
+	Cainfo             string `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
518
+	ErrMsg             string `gorm:"column:err_msg" json:"err_msg" form:"err_msg"`
519
+	RespondTime        string `gorm:"column:respond_time" json:"respond_time" form:"respond_time"`
520
+	InfRefmsgid        string `gorm:"column:inf_refmsgid" json:"inf_refmsgid" form:"inf_refmsgid"`
521
+}
522
+
523
+func (HisOrder) TableName() string {
524
+	return "his_order"
525
+}
526
+
527
+type HisOrderInfo struct {
528
+	ID               int64   `gorm:"column:id" json:"id" form:"id"`
529
+	OrderNumber      int64   `gorm:"column:order_number" json:"order_number" form:"order_number"`
530
+	FeedtlSn         int64   `gorm:"column:feedtl_sn" json:"feedtl_sn" form:"feedtl_sn"`
531
+	UploadDate       int64   `gorm:"column:upload_date" json:"upload_date" form:"upload_date"`
532
+	AdviceId         int64   `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
533
+	DetItemFeeSumamt int64   `gorm:"column:det_item_fee_sumamt" json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
534
+	Cnt              int64   `gorm:"column:cnt" json:"cnt" form:"cnt"`
535
+	Pric             float64 `gorm:"column:pric" json:"pric" form:"pric"`
536
+	PatientId        int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
537
+	PricUplmtAmt     float64 `gorm:"column:pric_uplmt_amt" json:"pric_uplmt_amt" form:"pric_uplmt_amt"`
538
+	SelfpayProp      float64 `gorm:"column:selfpay_prop" json:"selfpay_prop" form:"selfpay_prop"`
539
+	FulamtOwnpayAmt  float64 `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
540
+	OverlmtAmt       float64 `gorm:"column:overlmt_amt" json:"overlmt_amt" form:"overlmt_amt"`
541
+	PreselfpayAmt    float64 `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
542
+	BasMednFlag      string  `gorm:"column:bas_medn_flag" json:"bas_medn_flag" form:"bas_medn_flag"`
543
+	MedChrgitmType   string  `gorm:"column:med_chrgitm_type" json:"med_chrgitm_type" form:"med_chrgitm_type"`
544
+	HiNegoDrugFlag   string  `gorm:"column:hi_nego_drug_flag" json:"hi_nego_drug_flag" form:"hi_nego_drug_flag"`
545
+	Status           int64   `gorm:"column:status" json:"status" form:"status"`
546
+	Memo             string  `gorm:"column:memo" json:"memo" form:"memo"`
547
+	FeedetlSn        string  `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
548
+	Mtime            int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
549
+	InscpScpAmt      float64 `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
550
+	DrtReimFlag      string  `gorm:"column:drt_reim_flag" json:"drt_reim_flag" form:"drt_reim_flag"`
551
+	Ctime            int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
552
+	ListSpItemFlag   string  `gorm:"column:list_sp_item_flag" json:"list_sp_item_flag" form:"list_sp_item_flag"`
553
+	ChldMedcFlag     string  `gorm:"column:chld_medc_flag" json:"chld_medc_flag" form:"chld_medc_flag"`
554
+	LmtUsedFlag      string  `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
555
+	ChrgitmLv        string  `gorm:"column:chrgitm_lv" json:"chrgitm_lv" form:"chrgitm_lv"`
556
+	UserOrgId        int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
557
+	HisPatientId     int64   `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
558
+	OrderId          int64   `gorm:"column:order_id" json:"order_id" form:"order_id"`
559
+}
560
+
561
+func (HisOrderInfo) TableName() string {
562
+	return "his_order_info"
563
+}
564
+
565
+type VMHisPatient struct {
566
+	ID                     int64   `gorm:"column:id" json:"id" form:"id"`
567
+	BalanceAccountsType    int64   `gorm:"column:balance_accounts_type" json:"balance_accounts_type" form:"balance_accounts_type"`
568
+	MedicalInsuranceNumber string  `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
569
+	Name                   string  `gorm:"column:name" json:"name" form:"name"`
570
+	Gender                 int64   `gorm:"column:gender" json:"gender" form:"gender"`
571
+	IdType                 int64   `gorm:"column:id_type" json:"id_type" form:"id_type"`
572
+	MedicalTreatmentType   int64   `gorm:"column:medical_treatment_type" json:"medical_treatment_type" form:"medical_treatment_type"`
573
+	Birthday               int64   `gorm:"column:birthday" json:"birthday" form:"birthday"`
574
+	RecordDate             int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
575
+	Age                    float64 `gorm:"column:age" json:"age" form:"age"`
576
+	PhoneNumber            string  `gorm:"column:phone_number" json:"phone_number" form:"phone_number"`
577
+	IdCardNo               string  `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
578
+	RegisterType           int64   `gorm:"column:register_type" json:"register_type" form:"register_type"`
579
+	AdminUserId            int64   `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
580
+	Departments            int64   `gorm:"column:departments" json:"departments" form:"departments"`
581
+	IsNeedCostOfProduction int64   `gorm:"column:is_need_cost_of_production" json:"is_need_cost_of_production" form:"is_need_cost_of_production"`
582
+	RegisterCost           float64 `gorm:"column:register_cost" json:"register_cost" form:"register_cost"`
583
+	TreatmentCost          float64 `gorm:"column:treatment_cost" json:"treatment_cost" form:"treatment_cost"`
584
+	CostOfProduction       float64 `gorm:"column:cost_of_production" json:"cost_of_production" form:"cost_of_production"`
585
+	Total                  float64 `gorm:"column:total" json:"total" form:"total"`
586
+	UserOrgId              int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
587
+	Status                 int64   `gorm:"column:status" json:"status" form:"status"`
588
+	Ctime                  int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
589
+	Mtime                  int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
590
+	PatientId              int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
591
+	Number                 string  `gorm:"column:number" json:"number" form:"number"`
592
+	Doctor                 int64   `gorm:"column:doctor" json:"doctor" form:"doctor"`
593
+	IsReturn               int64   `gorm:"column:is_return" json:"is_return" form:"is_return"`
594
+	PsnNo                  string  `gorm:"column:psn_no" json:"psn_no" form:"psn_no"`
595
+	PsnCertType            string  `gorm:"column:psn_cert_type" json:"psn_cert_type" form:"psn_cert_type"`
596
+	Certno                 string  `gorm:"column:certno" json:"certno" form:"certno"`
597
+	PsnName                string  `gorm:"column:psn_name" json:"psn_name" form:"psn_name"`
598
+	Gend                   string  `gorm:"column:gend" json:"gend" form:"gend"`
599
+	Naty                   string  `gorm:"column:naty" json:"naty" form:"naty"`
600
+	Brdy                   string  `gorm:"column:brdy" json:"brdy" form:"brdy"`
601
+	Iinfo                  string  `gorm:"column:iinfo" json:"iinfo" form:"iinfo"`
602
+	Idetinfo               string  `gorm:"column:idetinfo" json:"idetinfo" form:"idetinfo"`
603
+	IptOtpNo               string  `gorm:"column:ipt_otp_no" json:"ipt_otp_no" form:"ipt_otp_no"`
604
+}
605
+
606
+func (VMHisPatient) TableName() string {
607
+	return "his_patient"
608
+}

+ 93 - 37
service/gdyb_service.go Zobrazit soubor

17
 
17
 
18
 const (
18
 const (
19
 	SceretKey     = "RhaDw4H0RUbWYyTxmRKM1eSeN0qyGLds" //     secretKey 私钥
19
 	SceretKey     = "RhaDw4H0RUbWYyTxmRKM1eSeN0qyGLds" //     secretKey 私钥
20
-	FixmedinsCOde = "H44022900214"                     // 定点医药机构编号
20
+	FixmedinsCOde = "H44022900158"                     // 定点医药机构编号
21
 )
21
 )
22
 
22
 
23
 // 人员基本信息
23
 // 人员基本信息
74
 		fmt.Println(err.Error())
74
 		fmt.Println(err.Error())
75
 		return err.Error()
75
 		return err.Error()
76
 	}
76
 	}
77
+	fmt.Println(string(respBytes))
77
 	str := string(respBytes)
78
 	str := string(respBytes)
78
-	fmt.Println(str)
79
 	return str
79
 	return str
80
 }
80
 }
81
 
81
 
285
 	Cut              string
285
 	Cut              string
286
 	FeedetlSn        string
286
 	FeedetlSn        string
287
 	Price            string
287
 	Price            string
288
+	MedListCodg      string
289
+}
290
+
291
+type RequestResult struct {
292
+	Output      Output `json:"output" form:"output"`
293
+	Infcode     int64  `gorm:"column:infcode" json:"infcode" form:"infcode"`
294
+	WarnMsg     string `gorm:"column:warn_msg" json:"warn_msg" form:"warn_msg"`
295
+	Cainfo      string `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
296
+	ErrMsg      string `gorm:"column:err_msg" json:"err_msg" form:"err_msg"`
297
+	RespondTime string `gorm:"column:respond_time" json:"respond_time" form:"respond_time"`
298
+	InfRefmsgid string `gorm:"column:inf_refmsgid" json:"inf_refmsgid" form:"inf_refmsgid"`
299
+}
300
+type Output struct {
301
+	Result Result `json:"result" form:"result"`
302
+}
303
+
304
+type Result struct {
305
+	BasMednFlag      string  `json:"bas_medn_flag" form:"bas_medn_flag"`
306
+	MedChrgitmType   string  `json:"med_chrgitm_type" form:"med_chrgitm_type"`
307
+	DetItemFeeSumamt int64   `json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
308
+	HiNegoDrugFlag   string  `json:"hi_nego_drug_flag" form:"hi_nego_drug_flag"`
309
+	FulamtOwnpayAmt  float64 `json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
310
+
311
+	FeedtlSn       int64   `json:"feedtl_sn" form:"feedtl_sn"`
312
+	UploadDate     int64   `json:"upload_date" form:"upload_date"`
313
+	AdviceId       int64   `json:"advice_id" form:"advice_id"`
314
+	Cnt            int64   `json:"cnt" form:"cnt"`
315
+	Pric           float64 `json:"pric" form:"pric"`
316
+	PatientId      int64   `json:"patient_id" form:"patient_id"`
317
+	PricUplmtAmt   float64 `json:"pric_uplmt_amt" form:"pric_uplmt_amt"`
318
+	SelfpayProp    float64 `json:"selfpay_prop" form:"selfpay_prop"`
319
+	OverlmtAmt     float64 `json:"overlmt_amt" form:"overlmt_amt"`
320
+	PreselfpayAmt  float64 `json:"preselfpay_amt" form:"preselfpay_amt"`
321
+	Status         int64   `json:"status" form:"status"`
322
+	Memo           string  `json:"memo" form:"memo"`
323
+	FeedetlSn      string  `json:"feedetl_sn" form:"feedetl_sn"`
324
+	Mtime          int64   `json:"mtime" form:"mtime"`
325
+	InscpScpAmt    float64 `json:"inscp_scp_amt" form:"inscp_scp_amt"`
326
+	DrtReimFlag    string  `json:"drt_reim_flag" form:"drt_reim_flag"`
327
+	Ctime          int64   `json:"ctime" form:"ctime"`
328
+	ListSpItemFlag string  `json:"list_sp_item_flag" form:"list_sp_item_flag"`
329
+	ChldMedcFlag   string  `json:"chld_medc_flag" form:"chld_medc_flag"`
330
+	LmtUsedFlag    string  `json:"lmt_used_flag" form:"lmt_used_flag"`
331
+	ChrgitmLv      string  `json:"chrgitm_lv" form:"chrgitm_lv"`
332
+	UserOrgId      int64   `json:"user_org_id" form:"user_org_id"`
333
+	HisPatientId   int64   `json:"his_patient_id" form:"his_patient_id"`
334
+	OrderId        int64   `json:"order_id" form:"order_id"`
288
 }
335
 }
289
 
336
 
290
 //  门诊费用明细信息上传
337
 //  门诊费用明细信息上传
291
-func Gdyb2204(psnNo string, mdtrtId string, hisPrescription []*models.HisPrescription) string {
338
+func Gdyb2204(psnNo string, mdtrtId string, hisPrescription []*models.HisPrescription, chrg_bchno string) string {
292
 	// 生成签名
339
 	// 生成签名
293
 	nonce := GetRandomString(32)
340
 	nonce := GetRandomString(32)
294
 	timestamp := time.Now().Unix()
341
 	timestamp := time.Now().Unix()
296
 	tempTime := time.Unix(timestamp, 0)
343
 	tempTime := time.Unix(timestamp, 0)
297
 	timeFormat := tempTime.Format("20060102150405")
344
 	timeFormat := tempTime.Format("20060102150405")
298
 	timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
345
 	timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
299
-	chrgBchno := rand.Intn(100000) + 10000
346
+	//chrgBchno := rand.Intn(100000) + 10000
300
 
347
 
301
 	var customs []*Custom
348
 	var customs []*Custom
302
 
349
 
311
 					Cut:              fmt.Sprintf("%.2f", subItem.PrescribingNumber),
358
 					Cut:              fmt.Sprintf("%.2f", subItem.PrescribingNumber),
312
 					FeedetlSn:        timeFormat + strconv.FormatInt(int64(randNum), 10) + strconv.FormatInt(subItem.DrugId, 10),
359
 					FeedetlSn:        timeFormat + strconv.FormatInt(int64(randNum), 10) + strconv.FormatInt(subItem.DrugId, 10),
313
 					Price:            fmt.Sprintf("%.2f", subItem.Price),
360
 					Price:            fmt.Sprintf("%.2f", subItem.Price),
361
+					MedListCodg:      subItem.MedListCodg,
314
 				}
362
 				}
315
 
363
 
316
 				customs = append(customs, cus)
364
 				customs = append(customs, cus)
342
 	feedetail := make([]map[string]interface{}, 0)
390
 	feedetail := make([]map[string]interface{}, 0)
343
 	inputMessage["infno"] = "2204" // 交易编码
391
 	inputMessage["infno"] = "2204" // 交易编码
344
 
392
 
345
-	chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
393
+	//chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
346
 	for _, item := range customs {
394
 	for _, item := range customs {
347
 		feedetailInfo := make(map[string]interface{})
395
 		feedetailInfo := make(map[string]interface{})
348
 		feedetailInfo["feedetl_sn"] = item.FeedetlSn
396
 		feedetailInfo["feedetl_sn"] = item.FeedetlSn
353
 		feedetailInfo["rxno"] = ""                                   // 处方号
401
 		feedetailInfo["rxno"] = ""                                   // 处方号
354
 		feedetailInfo["rx_circ_flag"] = "0"                          // 外购处方标志
402
 		feedetailInfo["rx_circ_flag"] = "0"                          // 外购处方标志
355
 		feedetailInfo["fee_ocur_time"] = timeFormatOne               // 费用发生时间
403
 		feedetailInfo["fee_ocur_time"] = timeFormatOne               // 费用发生时间
356
-		feedetailInfo["med_list_codg"] = "XN05AEQ010B001010101435"   // 医疗目录编码
404
+		feedetailInfo["med_list_codg"] = item.MedListCodg            // 医疗目录编码
357
 		feedetailInfo["medins_list_codg"] = FixmedinsCOde            // 医药机构目录编码
405
 		feedetailInfo["medins_list_codg"] = FixmedinsCOde            // 医药机构目录编码
358
 		feedetailInfo["det_item_fee_sumamt"] = item.DetItemFeeSumamt // 明细项目费用总额
406
 		feedetailInfo["det_item_fee_sumamt"] = item.DetItemFeeSumamt // 明细项目费用总额
359
 		feedetailInfo["cnt"] = item.Cut                              // 数量
407
 		feedetailInfo["cnt"] = item.Cut                              // 数量
388
 
436
 
389
 	if err != nil {
437
 	if err != nil {
390
 		fmt.Println(err.Error())
438
 		fmt.Println(err.Error())
391
-		return err.Error()
439
+		return ""
392
 	}
440
 	}
393
 	reader := bytes.NewReader(bytesData)
441
 	reader := bytes.NewReader(bytesData)
394
 
442
 
396
 	request, err := http.NewRequest("POST", url, reader)
444
 	request, err := http.NewRequest("POST", url, reader)
397
 	if err != nil {
445
 	if err != nil {
398
 		fmt.Println(err.Error())
446
 		fmt.Println(err.Error())
399
-		return err.Error()
447
+		return ""
400
 	}
448
 	}
401
 
449
 
402
 	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
450
 	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
409
 	resp, err := client.Do(request)
457
 	resp, err := client.Do(request)
410
 	if err != nil {
458
 	if err != nil {
411
 		fmt.Println(err.Error())
459
 		fmt.Println(err.Error())
412
-		return err.Error()
460
+		return ""
413
 	}
461
 	}
414
 	respBytes, err := ioutil.ReadAll(resp.Body)
462
 	respBytes, err := ioutil.ReadAll(resp.Body)
415
 	if err != nil {
463
 	if err != nil {
416
 		fmt.Println(err.Error())
464
 		fmt.Println(err.Error())
417
-		return err.Error()
465
+		return ""
418
 	}
466
 	}
419
-	str := string(respBytes)
420
-	fmt.Println(str)
421
-	return ""
467
+	return string(respBytes)
468
+	//var result RequestResult
469
+	//json.Unmarshal(respBytes, &result)
470
+	//return &result
422
 }
471
 }
423
 
472
 
424
 //  门诊费用明细信息撤销
473
 //  门诊费用明细信息撤销
482
 }
531
 }
483
 
532
 
484
 //  门诊预结算
533
 //  门诊预结算
485
-func Gdyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string) string {
534
+func Gdyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string) string {
486
 	// 生成签名
535
 	// 生成签名
487
 	nonce := GetRandomString(32)
536
 	nonce := GetRandomString(32)
488
 	timestamp := time.Now().Unix()
537
 	timestamp := time.Now().Unix()
494
 	inputData := make(map[string]interface{})
543
 	inputData := make(map[string]interface{})
495
 	inputMessage["infno"] = "2206" // 交易编码
544
 	inputMessage["infno"] = "2206" // 交易编码
496
 
545
 
497
-	inputData["psn_no"] = psnNo          // 人员编号 (来自1101接口返回)
498
-	inputData["mdtrt_cert_type"] = "02"  // 就诊凭证类型
499
-	inputData["mdtrt_cert_no"] = certNo  // 就诊凭证编号
500
-	inputData["med_type"] = "11"         // 医疗类别 11 普通门诊  12 门诊挂号
501
-	inputData["medfee_sumamt"] = "99.00" // 医疗费总额
502
-	inputData["psn_setlway"] = "01"      // 个人结算方式 01 按项目结 02 按定额结算
503
-	inputData["mdtrt_id"] = mdtrtId      // 就诊 ID(来自2201接口返回)
504
-	inputData["chrg_bchno"] = chrgBchno  // 收费批次号(来自2204生成的)
505
-	inputData["acct_used_flag"] = "1"    // 个人账户使用标志 0否 1是
506
-	inputData["insutype"] = insutype     // 险种类型
546
+	inputData["psn_no"] = psnNo         // 人员编号 (来自1101接口返回)
547
+	inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
548
+	inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
549
+	inputData["med_type"] = "11"        // 医疗类别 11 普通门诊  12 门诊挂号
550
+	inputData["medfee_sumamt"] = total  // 医疗费总额
551
+	inputData["psn_setlway"] = "01"     // 个人结算方式 01 按项目结 02 按定额结算
552
+	inputData["mdtrt_id"] = mdtrtId     // 就诊 ID(来自2201接口返回)
553
+	inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
554
+	inputData["acct_used_flag"] = "1"   // 个人账户使用标志 0否 1是
555
+	inputData["insutype"] = insutype    // 险种类型
507
 
556
 
508
 	input["data"] = inputData
557
 	input["data"] = inputData
509
 	inputMessage["input"] = input //交易输入
558
 	inputMessage["input"] = input //交易输入
546
 }
595
 }
547
 
596
 
548
 //  门诊结算
597
 //  门诊结算
549
-func Gdyb2207(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string) string {
598
+func Gdyb2207(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string) string {
550
 	// 生成签名
599
 	// 生成签名
551
 	nonce := GetRandomString(32)
600
 	nonce := GetRandomString(32)
552
 	timestamp := time.Now().Unix()
601
 	timestamp := time.Now().Unix()
558
 	inputData := make(map[string]interface{})
607
 	inputData := make(map[string]interface{})
559
 	inputMessage["infno"] = "2207" // 交易编码
608
 	inputMessage["infno"] = "2207" // 交易编码
560
 
609
 
561
-	inputData["psn_no"] = psnNo            // 人员编号 (来自1101接口返回)
562
-	inputData["mdtrt_cert_type"] = "02"    // 就诊凭证类型
563
-	inputData["mdtrt_cert_no"] = certNo    // 就诊凭证编号
564
-	inputData["med_type"] = "11"           // 医疗类别 11 普通门诊  12 门诊挂号
565
-	inputData["medfee_sumamt"] = "3226.00" // 医疗费总额
566
-	inputData["psn_setlway"] = "01"        // 个人结算方式 01 按项目结 02 按定额结算
567
-	inputData["mdtrt_id"] = mdtrtId        // 就诊 ID(来自2201接口返回)
568
-	inputData["chrg_bchno"] = chrgBchno    // 收费批次号(来自2204生成的)
569
-	inputData["acct_used_flag"] = "1"      // 个人账户使用标志 0否 1是
570
-	inputData["insutype"] = insutype       // 险种类型
571
-	inputData["invono"] = ""               // 发票号
610
+	inputData["psn_no"] = psnNo         // 人员编号 (来自1101接口返回)
611
+	inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
612
+	inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
613
+	inputData["med_type"] = "11"        // 医疗类别 11 普通门诊  12 门诊挂号
614
+	inputData["medfee_sumamt"] = total  // 医疗费总额
615
+	inputData["psn_setlway"] = "01"     // 个人结算方式 01 按项目结 02 按定额结算
616
+	inputData["mdtrt_id"] = mdtrtId     // 就诊 ID(来自2201接口返回)
617
+	inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
618
+	inputData["acct_used_flag"] = "1"   // 个人账户使用标志 0否 1是
619
+	inputData["insutype"] = insutype    // 险种类型
620
+	inputData["invono"] = ""            // 发票号
572
 
621
 
573
 	input["data"] = inputData
622
 	input["data"] = inputData
574
 	inputMessage["input"] = input //交易输入
623
 	inputMessage["input"] = input //交易输入
719
 	inputMessage["opter_name"] = "测试用户"                                                        // 经办人姓名
768
 	inputMessage["opter_name"] = "测试用户"                                                        // 经办人姓名
720
 	inputMessage["inf_time"] = timeFormatOne                                                   // 交易时间
769
 	inputMessage["inf_time"] = timeFormatOne                                                   // 交易时间
721
 	inputMessage["fixmedins_code"] = FixmedinsCOde                                             // 定点医药机构编号
770
 	inputMessage["fixmedins_code"] = FixmedinsCOde                                             // 定点医药机构编号
722
-	inputMessage["fixmedins_name"] = "翁源百伦血液透析有限公司透析中心"                                        //定点医药机构名称
771
+	inputMessage["fixmedins_name"] = "翁源沅胜血液透析中心"                                              //定点医药机构名称
723
 	inputMessage["sign_no"] = ""                                                               //交易签到流水号
772
 	inputMessage["sign_no"] = ""                                                               //交易签到流水号
724
 	return inputMessage
773
 	return inputMessage
725
 }
774
 }
775
+
776
+func FindHisRegisterRecord(record_time int64, patient_id int64, org_id int64) (total int64, err error) {
777
+
778
+	err = readDb.Model(&models.VMHisPatient{}).Where("status = 1 AND user_org_id = ? AND patient_id = ? AND record_date = ?", org_id, patient_id, record_time).Count(&total).Error
779
+
780
+	return
781
+}

+ 14 - 2
service/his_service.go Zobrazit soubor

75
 }
75
 }
76
 
76
 
77
 func GetHisPatientInfo(org_id int64, patient_id int64, record_date int64) (info HisPatient, err error) {
77
 func GetHisPatientInfo(org_id int64, patient_id int64, record_date int64) (info HisPatient, err error) {
78
-	err = readDb.Model(&models.HisPatient{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND id = ?", org_id, record_date, patient_id).First(&info).Error
78
+	err = readDb.Model(&models.HisPatient{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ?", org_id, record_date, patient_id).First(&info).Error
79
 	return
79
 	return
80
 }
80
 }
81
 
81
 
119
 func GetHisPrescription(org_id int64, patient_id int64, record_date int64) (prescription []*models.HisPrescription, err error) {
119
 func GetHisPrescription(org_id int64, patient_id int64, record_date int64) (prescription []*models.HisPrescription, err error) {
120
 	err = readDb.Model(&models.HisPrescription{}).
120
 	err = readDb.Model(&models.HisPrescription{}).
121
 		Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ?", org_id).
121
 		Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ?", org_id).
122
-		Preload("HisPrescriptionProject", "status = 1 AND user_org_id = ?", org_id).
122
+		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
123
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
124
+		}).
123
 		Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ?", org_id, record_date, patient_id).
125
 		Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ?", org_id, record_date, patient_id).
124
 		Find(&prescription).Error
126
 		Find(&prescription).Error
125
 	return
127
 	return
161
 	err = writeDb.Create(project).Error
163
 	err = writeDb.Create(project).Error
162
 	return
164
 	return
163
 }
165
 }
166
+
167
+func CreateHisPatientTwo(patient *models.VMHisPatient) error {
168
+	err := writeDb.Create(&patient).Error
169
+	return err
170
+}
171
+
172
+func GetVMHisPatientInfo(org_id int64, patient_id int64, record_date int64) (info models.VMHisPatient, err error) {
173
+	err = readDb.Model(&models.VMHisPatient{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ?", org_id, record_date, patient_id).First(&info).Error
174
+	return
175
+}