陈少旭 пре 1 година
родитељ
комит
31d0ebb7ed
4 измењених фајлова са 1134 додато и 4 уклоњено
  1. 239 0
      controllers/sg/his_api_controller.go
  2. 227 0
      models/cfyljg.go
  3. 648 0
      service/dianzichufang.go
  4. 20 4
      service/his_service.go

+ 239 - 0
controllers/sg/his_api_controller.go Прегледај датотеку

@@ -110,9 +110,248 @@ func HisManagerApiRegistRouters() {
110 110
 
111 111
 	beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
112 112
 
113
+	beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
114
+
115
+	beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
116
+	beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
117
+	beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
118
+	beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
119
+	beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
120
+	beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
121
+	beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
122
+	//beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
123
+	//beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
113 124
 	//beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
114 125
 
115 126
 }
127
+func (c *HisApiController) GetCFYLJG001() {
128
+	admin_user_id, _ := c.GetInt64("admin_user_id")
129
+	patient_id, _ := c.GetInt64("patient_id")
130
+	his_patient_id, _ := c.GetInt64("his_patient_id")
131
+	record_time := c.GetString("record_time")
132
+
133
+	his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
134
+	psn, _ := service.GetPsnByPatientId(patient_id)
135
+
136
+	curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
137
+	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
138
+	var cFYLJG001 models.CFYLJG001
139
+
140
+	timeLayout := "2006-01-02"
141
+	loc, _ := time.LoadLocation("Local")
142
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
143
+	if err != nil {
144
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
145
+		return
146
+	}
147
+	recordDateTime := theTime.Unix()
148
+	prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
149
+	for _, item := range prescriptions {
150
+		doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
151
+		if his.IdCardType == 1 {
152
+			bas := strings.Split(psn.CardInfo, "|")
153
+			basNumber := bas[1]
154
+			fmt.Println(basNumber)
155
+			card_sn := bas[3]
156
+			card_no := bas[2]
157
+			cFYLJG001.MdtrtCertType = "03"
158
+			cFYLJG001.CardSn = card_sn
159
+			cFYLJG001.MdtrtCertNo = card_no
160
+			cFYLJG001.EcToken = ""
161
+			cFYLJG001.AuthNo = ""
162
+		} else if his.IdCardType == 2 {
163
+			cFYLJG001.MdtrtCertType = "02"
164
+			cFYLJG001.CardSn = ""
165
+			cFYLJG001.MdtrtCertNo = his.IdCardNo
166
+			cFYLJG001.EcToken = ""
167
+			cFYLJG001.AuthNo = ""
168
+		} else if his.IdCardType == 4 {
169
+			cFYLJG001.MdtrtCertType = "01"
170
+			cFYLJG001.CardSn = ""
171
+			cFYLJG001.MdtrtCertNo = psn.VerifyNumber
172
+			cFYLJG001.EcToken = psn.VerifyNumber
173
+			cFYLJG001.AuthNo = ""
174
+		}
175
+		cFYLJG001.BizTypeCode = "01"
176
+		cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
177
+		cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
178
+		cFYLJG001.RxTypeCode = "1"
179
+		tempTime := time.Unix(item.PreTime, 0)
180
+		timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
181
+		cFYLJG001.PrscTime = timeFormatOne
182
+		var count float64
183
+		if item.Type == 1 {
184
+			for _, sumItem := range item.HisDoctorAdviceInfo {
185
+				count = count + sumItem.PrescribingNumber
186
+			}
187
+		}
188
+		cFYLJG001.RxDrugCnt = count
189
+		cFYLJG001.ValiDays = "5"
190
+		cFYLJG001.RxCotnFlag = "0"
191
+		for _, subItem := range item.HisDoctorAdviceInfo {
192
+			var drug models.RxDrug
193
+			drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
194
+			drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
195
+			drug.RxItemTypeCode = "11"
196
+			drug.DrugDosform = "" //TODO
197
+			if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
198
+				drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
199
+			}
200
+
201
+			drug.MedcWayDscr = subItem.DeliveryWay
202
+
203
+			tempTime2 := time.Unix(subItem.StartTime, 0)
204
+			timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
205
+			drug.MedcBegntime = timeFormatTwo
206
+			if subItem.Day > 0 {
207
+				ts := time.Unix(subItem.StartTime, 0)
208
+				record_time = ts.AddDate(0, 0, int(subItem.Day)).Unix()
209
+				tempTime3 := time.Unix(record_time, 0)
210
+				timeFormat3 := tempTime3.Format("2006-01-02") + " 23:59:00"
211
+				drug.MedcEndtime = timeFormat3
212
+			} else {
213
+				tempTime2 := time.Unix(subItem.StartTime, 0)
214
+				timeFormatTwo := tempTime2.Format("2006-01-02") + " 23:59:00"
215
+				drug.MedcEndtime = timeFormatTwo
216
+			}
217
+
218
+			drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
219
+			drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
220
+			drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
221
+			drug.DrugCnt = subItem.PrescribingNumber
222
+			drug.DrugDosunt = subItem.PrescribingNumberUnit
223
+			drug.SinDoscnt = subItem.SingleDose
224
+			drug.SinDosunt = subItem.SingleDoseUnit
225
+			drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
226
+			drug.UsedFrquName = subItem.ExecutionFrequency
227
+			drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
228
+			drug.DrugTotlcntEmp = fmt.Sprintf("%.2f", subItem.PrescribingNumberUnit)
229
+			drug.HospApprFlag = "1"
230
+			cFYLJG001.List = append(cFYLJG001.List, drug)
231
+		}
232
+		cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
233
+		cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
234
+		cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
235
+		cFYLJG001.Mdtrtinfo.MedType = item.MedType
236
+		cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
237
+		cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
238
+		cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
239
+		cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
240
+		cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
241
+		cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.2f", his.Age)
242
+		cFYLJG001.Mdtrtinfo.PatnHgt = ""
243
+		cFYLJG001.Mdtrtinfo.PatnWt = ""
244
+		cFYLJG001.Mdtrtinfo.Gend = his.Gend
245
+		cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.2f", his.Age)
246
+		cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
247
+		cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
248
+		cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
249
+		cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
250
+		cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
251
+		cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
252
+		cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
253
+		cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
254
+		cFYLJG001.Mdtrtinfo.Caty = "A03.06"
255
+		tempTime2 := time.Now().Unix()
256
+		tempTime3 := time.Unix(tempTime2, 0)
257
+		timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
258
+		cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
259
+		cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
260
+		cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
261
+		cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
262
+		cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
263
+		diagnosis_ids := strings.Split(his.Diagnosis, ",")
264
+		var config []*models.HisXtDiagnoseConfig
265
+		for _, item := range diagnosis_ids {
266
+			id, _ := strconv.ParseInt(item, 10, 64)
267
+			diagnosisConfig, _ := service.FindDiagnoseById(id)
268
+			config = append(config, &diagnosisConfig)
269
+		}
270
+		for index, item := range config {
271
+			if index == 0 {
272
+				var dia models.DiseInfo
273
+				dia.DiagType = "1"
274
+				dia.MaindiagFlag = "1"
275
+				dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
276
+				dia.DiagCode = item.CountryCode
277
+				dia.DiagName = item.ClassName
278
+				dia.DiagDept = "肾内科"
279
+				dia.DiagDrNo = doctor.DoctorNumber
280
+				dia.DiagDrName = doctor.UserName
281
+				tempTime3 := time.Unix(item.Ctime, 0)
282
+				timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
283
+				dia.DiagTime = timeFormatTwo
284
+				cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
285
+			} else {
286
+				var dia models.DiseInfo
287
+				dia.DiagType = "1"
288
+				dia.MaindiagFlag = "0"
289
+				dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
290
+				dia.DiagCode = item.CountryCode
291
+				dia.DiagName = item.ClassName
292
+				dia.DiagDept = "肾内科"
293
+				dia.DiagDrNo = doctor.DoctorNumber
294
+				dia.DiagDrName = doctor.UserName
295
+				tempTime3 := time.Unix(item.Ctime, 0)
296
+				timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
297
+				dia.DiagTime = timeFormatTwo
298
+				cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
299
+			}
300
+		}
301
+		fmt.Println(cFYLJG001)
302
+		service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001)
303
+	}
304
+
305
+}
306
+func (c *HisApiController) GetCFYLJG002() {
307
+	admin_user_id, _ := c.GetInt64("admin_user_id")
308
+	curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
309
+	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
310
+
311
+	service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "", "", "")
312
+
313
+}
314
+func (c *HisApiController) GetCFYLJG003() {
315
+	admin_user_id, _ := c.GetInt64("admin_user_id")
316
+	curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
317
+	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
318
+	var cFYLJG003 models.CFYLJG003
319
+	service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
320
+
321
+}
322
+func (c *HisApiController) GetCFYLJG004() {
323
+	admin_user_id, _ := c.GetInt64("admin_user_id")
324
+	curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
325
+	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
326
+	var cFYLJG004 models.CFYLJG004
327
+	service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
328
+
329
+}
330
+func (c *HisApiController) GetCFYLJG005() {
331
+	admin_user_id, _ := c.GetInt64("admin_user_id")
332
+	curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
333
+	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
334
+	var cFYLJG005 models.CFYLJG005
335
+	service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
336
+
337
+}
338
+func (c *HisApiController) GetCFYLJG006() {
339
+	admin_user_id, _ := c.GetInt64("admin_user_id")
340
+	curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
341
+	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
342
+	var cFYLJG006 models.CFYLJG006
343
+	service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
344
+
345
+}
346
+func (c *HisApiController) GetCFYLJG007() {
347
+	admin_user_id, _ := c.GetInt64("admin_user_id")
348
+	curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
349
+	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
350
+	var cFYLJG007 models.CFYLJG007
351
+	service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
352
+
353
+}
354
+
116 355
 func (c *HisApiController) GetBL4201A() {
117 356
 	order_id, _ := c.GetInt64("order_id")
118 357
 	admin_user_id, _ := c.GetInt64("admin_user_id")

+ 227 - 0
models/cfyljg.go Прегледај датотеку

@@ -0,0 +1,227 @@
1
+package models
2
+
3
+type RxDrug struct {
4
+	MedListCodg     string  `json:"med_list_codg"`
5
+	MedinsListCodg  string  `json:"medins_list_codg"`
6
+	HospPrepFlag    string  `json:"hosp_prep_flag"`
7
+	RxItemTypeCode  string  `json:"rx_item_type_code"`
8
+	RxItemTypeName  string  `json:"rx_item_type_name"`
9
+	TcmdrugTypeName string  `json:"tcmdrug_type_name"`
10
+	TcmdrugTypeCode string  `json:"tcmdrug_type_code"`
11
+	TcmherbFoote    string  `json:"tcmherb_foote"`
12
+	MednTypeCode    string  `json:"medn_type_code"`
13
+	MednTypeName    string  `json:"medn_type_name"`
14
+	MainMedcFlag    string  `json:"main_medc_flag"`
15
+	UrgtFlag        string  `json:"urgt_flag"`
16
+	BasMednFlag     string  `json:"bas_medn_flag"`
17
+	ImpDrugFlag     string  `json:"imp_drug_flag"`
18
+	DrugProdname    string  `json:"drug_prodname"`
19
+	GennameCodg     string  `json:"genname_codg"`
20
+	DrugGenname     string  `json:"drug_genname"`
21
+	DrugDosform     string  `json:"drug_dosform"`
22
+	DrugSpec        string  `json:"drug_spec"`
23
+	PrdrName        string  `json:"prdr_name"`
24
+	MedcWayCodg     string  `json:"medc_way_codg"`
25
+	MedcWayDscr     string  `json:"medc_way_dscr"`
26
+	MedcBegntime    string  `json:"medc_begntime"`
27
+	MedcEndtime     string  `json:"medc_endtime"`
28
+	MedcDays        string  `json:"medc_days"`
29
+	DrugPric        string  `json:"drug_pric"`
30
+	DrugSumamt      string  `json:"drug_sumamt"`
31
+	DrugCnt         float64 `json:"drug_cnt"`
32
+	DrugDosunt      string  `json:"drug_dosunt"`
33
+	SinDoscnt       float64 `json:"sin_doscnt"`
34
+	SinDosunt       string  `json:"sin_dosunt"`
35
+	UsedFrquCodg    string  `json:"used_frqu_codg"`
36
+	UsedFrquName    string  `json:"used_frqu_name"`
37
+	DrugTotlcnt     string  `json:"drug_totlcnt"`
38
+	DrugTotlcntEmp  string  `json:"drug_totlcnt_emp"`
39
+	HospApprFlag    string  `json:"hosp_appr_flag"`
40
+	Extras          string  `json:"extras"`
41
+}
42
+
43
+type MdtrtInfo struct {
44
+	FixmedinsCode   string `json:"fixmedins_code"`
45
+	FixmedinsName   string `json:"fixmedins_name"`
46
+	MdtrtID         string `json:"mdtrt_id"`
47
+	MedType         string `json:"med_type"`
48
+	IptOtpNo        string `json:"ipt_otp_no"`
49
+	OtpIptFlag      string `json:"otp_ipt_flag"`
50
+	PsnNo           string `json:"psn_no"`
51
+	PatnName        string `json:"patn_name"`
52
+	PsnCertType     string `json:"psn_cert_type"`
53
+	Certno          string `json:"certno"`
54
+	PatnAge         string `json:"patn_age"`
55
+	PatnHgt         string `json:"patn_hgt"`
56
+	PatnWt          string `json:"patn_wt"`
57
+	Gend            string `json:"gend"`
58
+	BirctrlType     string `json:"birctrlType"`
59
+	BirctrlMatnDate string `json:"birctrlMatnDate"`
60
+	MatnType        string `json:"matnType"`
61
+	GesoVal         string `json:"geso_val"`
62
+	NwbFlag         string `json:"nwb_flag"`
63
+	NwbAge          string `json:"nwb_age"`
64
+	SuckPrdFlag     string `json:"suck_prd_flag"`
65
+	AlgsHis         string `json:"algs_his"`
66
+	PrscDeptName    string `json:"prsc_dept_name"`
67
+	PrscDeptCode    string `json:"prsc_dept_code"`
68
+	DrCode          string `json:"dr_code"`
69
+	PrscDrName      string `json:"prsc_dr_name"`
70
+	PrscDrCertType  string `json:"prsc_dr_cert_type"`
71
+	PrscDrCertno    string `json:"prsc_dr_certno"`
72
+	DrProfttlCodg   string `json:"dr_profttl_codg"`
73
+	DrProfttlName   string `json:"dr_profttl_name"`
74
+	DrDeptCode      string `json:"dr_dept_code"`
75
+	DrDeptName      string `json:"dr_dept_name"`
76
+	Caty            string `json:"caty"`
77
+	MdtrtTime       string `json:"mdtrt_time"`
78
+	DiseCodg        string `json:"dise_codg"`
79
+	DiseName        string `json:"dise_name"`
80
+	SpDiseFlag      string `json:"sp_dise_flag"`
81
+	MaindiagCode    string `json:"maindiag_code"`
82
+	MaindiagName    string `json:"maindiag_name"`
83
+	DiseCondDscr    string `json:"dise_cond_dscr"`
84
+	HiFeesetlFlag   string `json:"hi_feesetl_flag"`
85
+	HiFeesetlName   string `json:"hi_feesetl_name"`
86
+	RgstFee         string `json:"rgst_fee"`
87
+	MedfeeSumamt    string `json:"medfee_sumamt"`
88
+	FstdiagFlag     string `json:"fstdiag_flag"`
89
+	Extras          string `json:"extras"`
90
+}
91
+
92
+type DiseInfo struct {
93
+	DiagType     string `json:"diag_type"`
94
+	MaindiagFlag string `json:"maindiag_flag"`
95
+	DiagSrtNo    string `json:"diag_srt_no"`
96
+	DiagCode     string `json:"diag_code"`
97
+	DiagName     string `json:"diag_name"`
98
+	DiagDept     string `json:"diag_dept"`
99
+	DiagDrNo     string `json:"diag_dr_no"`
100
+	DiagDrName   string `json:"diag_dr_name"`
101
+	DiagTime     string `json:"diag_time"`
102
+	TcmDiseCode  string `json:"tcm_dise_code"`
103
+	TcmDiseName  string `json:"tcm_dise_name"`
104
+	TcmsympCode  string `json:"tcmsymp_code"`
105
+	Tcmsymp      string `json:"tcmsymp"`
106
+}
107
+
108
+type CFYLJG001 struct {
109
+	MdtrtCertType string     `json:"mdtrt_cert_type"`
110
+	MdtrtCertNo   string     `json:"mdtrt_cert_no"`
111
+	CardSn        string     `json:"card_sn"`
112
+	EcToken       string     `json:"ec_token"`
113
+	AuthNo        string     `json:"auth_no"`
114
+	BizTypeCode   string     `json:"biz_type_code"`
115
+	InsuAdmdvs    string     `json:"insu_admdvs"`
116
+	HospRxno      string     `json:"hosp_rxno"`
117
+	InitRxno      string     `json:"init_rxno"`
118
+	RxTypeCode    string     `json:"rx_type_code"`
119
+	PrscTime      string     `json:"prsc_time"`
120
+	RxDrugCnt     float64    `json:"rx_drug_cnt"`
121
+	RxUsedWayCodg string     `json:"rx_used_way_codg"`
122
+	RxUsedWayName string     `json:"rx_used_way_name"`
123
+	RxFrquCodg    string     `json:"rx_frqu_codg"`
124
+	RxFrquName    string     `json:"rx_frqu_name"`
125
+	RxDosunt      string     `json:"rx_dosunt"`
126
+	RxDoscnt      string     `json:"rx_doscnt"`
127
+	RxDrordDscr   string     `json:"rx_drord_dscr"`
128
+	ValiDays      string     `json:"vali_days"`
129
+	ValiEndTime   string     `json:"vali_end_time"`
130
+	ReptFlag      string     `json:"rept_flag"`
131
+	MaxReptCnt    string     `json:"max_rept_cnt"`
132
+	ReptdCnt      string     `json:"reptd_cnt"`
133
+	MinInrvDays   string     `json:"min_inrv_days"`
134
+	RxCotnFlag    string     `json:"rx_cotn_flag"`
135
+	LongRxFlag    string     `json:"long_rx_flag"`
136
+	MdtrtareaNo   string     `json:"mdtrtareaNo"`
137
+	List          []RxDrug   `json:"list"`
138
+	Mdtrtinfo     MdtrtInfo  `json:"mdtrtinfo"`
139
+	Diseinfo      []DiseInfo `json:"diseinfo"`
140
+}
141
+
142
+type CFYLJG003 struct {
143
+	RxTraceCode     string `json:"rx_trace_code"`
144
+	HiRxno          string `json:"hi_rxno"`
145
+	MdtrtID         string `json:"mdtrt_id"`
146
+	PatnName        string `json:"patn_name"`
147
+	PsnCertType     string `json:"psn_cert_type"`
148
+	Certno          string `json:"certno"`
149
+	FixmedinsName   string `json:"fixmedins_name"`
150
+	FixmedinsCode   string `json:"fixmedins_code"`
151
+	DrCode          string `json:"dr_code"`
152
+	PrscDrName      string `json:"prsc_dr_name"`
153
+	PharDeptName    string `json:"phar_dept_name"`
154
+	PharDeptCode    string `json:"phar_dept_code"`
155
+	PharProfttlCodg string `json:"phar_profttl_codg"`
156
+	PharProfttlName string `json:"phar_profttl_name"`
157
+	PharCode        string `json:"phar_code"`
158
+	RxFrquName      string `json:"rx_frqu_name"`
159
+	PharCertType    string `json:"phar_cert_type"`
160
+	PharCertno      string `json:"phar_certno"`
161
+	PharName        string `json:"phar_name"`
162
+	PharPracCertNo  string `json:"phar_prac_cert_no"`
163
+	PharChkTime     string `json:"phar_chk_time"`
164
+	RxFile          string `json:"rx_file"`
165
+	SignDigest      string `json:"sign_digest"`
166
+}
167
+
168
+type CFYLJG004 struct {
169
+	HiRxno         string `json:"hi_rxno"`
170
+	UndoDrCode     string `json:"undo_dr_code"`
171
+	UndoDrName     string `json:"undo_dr_name"`
172
+	UndoDrCertType string `json:"undo_dr_cert_type"`
173
+	UndoDrCertno   string `json:"undo_dr_certno"`
174
+	UndoRea        string `json:"undo_rea"`
175
+	UndoTime       string `json:"undo_time"`
176
+	FixmedinsCode  string `json:"fixmedins_code"`
177
+}
178
+
179
+type CFYLJG005 struct {
180
+	FixmedinsCode string `json:"fixmedins_code"`
181
+	HiRxno        string `json:"hi_rxno"`
182
+	MdtrtID       string `json:"mdtrt_id"`
183
+	EcToken       string `json:"ec_token"`
184
+	PsnName       string `json:"psn_name"`
185
+	PsnCertType   string `json:"psn_cert_type"`
186
+	Certno        string `json:"certno"`
187
+}
188
+
189
+type CFYLJG006 struct {
190
+	FixmedinsCode string `json:"fixmedins_code"`
191
+	HiRxno        string `json:"hi_rxno"`
192
+	MdtrtID       string `json:"mdtrt_id"`
193
+	PsnCertType   string `json:"psn_cert_type"`
194
+	Certno        string `json:"certno"`
195
+	PsnName       string `json:"psn_name"`
196
+}
197
+
198
+type CFYLJG007 struct {
199
+	FixmedinsCode string `json:"fixmedins_code"`
200
+	HiRxno        string `json:"hi_rxno"`
201
+	MdtrtID       string `json:"mdtrt_id"`
202
+	PsnNo         string `json:"psn_no"`
203
+	PsnCertType   string `json:"psn_cert_type"`
204
+	Certno        string `json:"certno"`
205
+}
206
+
207
+type HisPrescriptionFlow struct {
208
+	ID             int64  `gorm:"column:id" json:"id" form:"id"`
209
+	RxTraceCode    string `gorm:"column:rx_trace_code" json:"rx_trace_code" form:"rx_trace_code"`
210
+	HiRxno         string `gorm:"column:hi_rxno" json:"hi_rxno" form:"hi_rxno"`
211
+	RequestLog     string `gorm:"column:request_log" json:"request_log" form:"request_log"`
212
+	ResultLog      string `gorm:"column:result_log" json:"result_log" form:"result_log"`
213
+	UserOrgId      int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
214
+	Status         int64  `gorm:"column:status" json:"status" form:"status"`
215
+	Ctime          int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
216
+	Mtime          int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
217
+	OriginalValue  string `gorm:"column:original_value" json:"original_value" form:"original_value"`
218
+	OriginalRxFile string `gorm:"column:original_rx_file" json:"original_rx_file" form:"original_rx_file"`
219
+	RxFile         string `gorm:"column:rx_file" json:"rx_file" form:"rx_file"`
220
+	SignDigest     string `gorm:"column:sign_digest" json:"sign_digest" form:"sign_digest"`
221
+	SignCertSn     string `gorm:"column:sign_cert_sn" json:"sign_cert_sn" form:"sign_cert_sn"`
222
+	SignCertDn     string `gorm:"column:sign_cert_dn" json:"sign_cert_dn" form:"sign_cert_dn"`
223
+}
224
+
225
+func (HisPrescriptionFlow) TableName() string {
226
+	return "his_prescription_flow"
227
+}

+ 648 - 0
service/dianzichufang.go Прегледај датотеку

@@ -0,0 +1,648 @@
1
+package service
2
+
3
+import (
4
+	"bytes"
5
+	"encoding/json"
6
+	"fmt"
7
+	"gdyb/models"
8
+	"io/ioutil"
9
+	"net/http"
10
+	"strconv"
11
+	"time"
12
+)
13
+
14
+func GetCFYLJG001(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, cFYLJG001 models.CFYLJG001) (string, string) {
15
+	//生成签名
16
+	nonce := GetRandomString(32)
17
+	timestamp := time.Now().Unix()
18
+	signature := setSignature(timestamp, nonce, secret_key)
19
+	//生成输入报文
20
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
21
+	//input := make(map[string]interface{})
22
+	inputData := make(map[string]interface{}, 0)
23
+
24
+	inputMessage["infno"] = "CFYLJG001"
25
+
26
+	inputData["mdtrt_cert_type"] = cFYLJG001.MdtrtCertType
27
+	inputData["mdtrt_cert_no"] = cFYLJG001.MdtrtCertNo
28
+	inputData["card_sn"] = cFYLJG001.CardSn
29
+	inputData["ec_token"] = cFYLJG001.EcToken
30
+	inputData["auth_no"] = cFYLJG001.AuthNo
31
+	inputData["biz_type_code"] = cFYLJG001.BizTypeCode
32
+	inputData["insu_admdvs"] = cFYLJG001.InsuAdmdvs
33
+	inputData["hosp_rxno"] = cFYLJG001.HospRxno
34
+	inputData["init_rxno"] = cFYLJG001.InitRxno
35
+	inputData["rx_type_code"] = cFYLJG001.RxTypeCode
36
+	inputData["prsc_time"] = cFYLJG001.PrscTime
37
+	inputData["rx_drug_cnt"] = cFYLJG001.RxDrugCnt
38
+	inputData["rx_used_way_codg"] = cFYLJG001.RxUsedWayCodg
39
+	inputData["rx_used_way_name"] = cFYLJG001.RxUsedWayName
40
+	inputData["rx_frqu_codg"] = cFYLJG001.RxFrquCodg
41
+	inputData["rx_frqu_name"] = cFYLJG001.RxFrquName
42
+	inputData["rx_dosunt"] = cFYLJG001.RxDosunt
43
+	inputData["rx_doscnt"] = cFYLJG001.RxDoscnt
44
+	inputData["rx_drord_dscr"] = cFYLJG001.RxDrordDscr
45
+	inputData["vali_days"] = cFYLJG001.ValiDays
46
+	inputData["vali_end_time"] = cFYLJG001.ValiEndTime
47
+	inputData["rept_flag"] = cFYLJG001.ReptFlag
48
+	inputData["max_rept_cnt"] = cFYLJG001.MaxReptCnt
49
+	inputData["reptd_cnt"] = cFYLJG001.ReptdCnt
50
+	inputData["min_inrv_days"] = cFYLJG001.MinInrvDays
51
+	inputData["rx_cotn_flag"] = cFYLJG001.RxCotnFlag
52
+	inputData["long_rx_flag"] = cFYLJG001.LongRxFlag
53
+	inputData["mdtrtareaNo"] = cFYLJG001.MdtrtareaNo
54
+
55
+	rxdrugdetail := make([]map[string]interface{}, 0)
56
+
57
+	rxdrug := make(map[string]interface{})
58
+	for _, item := range cFYLJG001.List {
59
+		rxdrug["med_list_codg"] = item.MedListCodg
60
+		rxdrug["medins_list_codg"] = item.MedinsListCodg
61
+		rxdrug["hosp_prep_flag"] = item.HospPrepFlag
62
+		rxdrug["rx_item_type_code"] = item.RxItemTypeCode
63
+		rxdrug["rx_item_type_name"] = item.RxItemTypeName
64
+		rxdrug["tcmdrug_type_name"] = item.TcmdrugTypeName
65
+		rxdrug["tcmdrug_type_code"] = item.TcmdrugTypeCode
66
+		rxdrug["tcmherb_foote"] = item.TcmherbFoote
67
+		rxdrug["medn_type_code"] = item.MednTypeCode
68
+		rxdrug["medn_type_name"] = item.MednTypeName
69
+		rxdrug["main_medc_flag"] = item.MainMedcFlag
70
+		rxdrug["urgt_flag"] = item.UrgtFlag
71
+		rxdrug["bas_medn_flag"] = item.BasMednFlag
72
+		rxdrug["imp_drug_flag"] = item.ImpDrugFlag
73
+		rxdrug["drug_prodname"] = item.DrugProdname
74
+		rxdrug["genname_codg"] = item.GennameCodg
75
+		rxdrug["drug_genname"] = item.DrugGenname
76
+		rxdrug["drug_dosform"] = item.DrugDosform
77
+		rxdrug["drug_spec"] = item.DrugSpec
78
+		rxdrug["prdr_name"] = item.PrdrName
79
+		rxdrug["medc_way_codg"] = item.MedcWayCodg
80
+		rxdrug["medc_way_dscr"] = item.MedcWayDscr
81
+		rxdrug["medc_begntime"] = item.MedcBegntime
82
+		rxdrug["medc_endtime"] = item.MedcEndtime
83
+		rxdrug["medc_days"] = item.MedcDays
84
+		rxdrug["drug_pric"] = item.DrugPric
85
+		rxdrug["drug_sumamt"] = item.DrugSumamt
86
+		rxdrug["drug_cnt"] = item.DrugCnt
87
+		rxdrug["drug_dosunt"] = item.DrugDosunt
88
+		rxdrug["sin_doscnt"] = item.SinDoscnt
89
+		rxdrug["sin_dosunt"] = item.SinDosunt
90
+		rxdrug["used_frqu_codg"] = item.UsedFrquCodg
91
+		rxdrug["used_frqu_name"] = item.UsedFrquName
92
+		rxdrug["drug_totlcnt_emp"] = item.DrugTotlcntEmp
93
+		rxdrug["hosp_appr_flag"] = item.HospApprFlag
94
+		rxdrug["extras"] = item.Extras
95
+		rxdrugdetail = append(rxdrugdetail, rxdrug)
96
+	}
97
+	inputData["list"] = rxdrugdetail
98
+
99
+	mdtrtinfo := make(map[string]interface{})
100
+	mdtrtinfo["fixmedins_code"] = cFYLJG001.Mdtrtinfo.FixmedinsCode
101
+	mdtrtinfo["fixmedins_name"] = cFYLJG001.Mdtrtinfo.FixmedinsName
102
+	mdtrtinfo["mdtrt_id"] = cFYLJG001.Mdtrtinfo.MdtrtID
103
+	mdtrtinfo["med_type"] = cFYLJG001.Mdtrtinfo.MedType
104
+	mdtrtinfo["ipt_otp_no"] = cFYLJG001.Mdtrtinfo.IptOtpNo
105
+	mdtrtinfo["otp_ipt_flag"] = cFYLJG001.Mdtrtinfo.OtpIptFlag
106
+	mdtrtinfo["psn_no"] = cFYLJG001.Mdtrtinfo.PsnNo
107
+	mdtrtinfo["patn_name"] = cFYLJG001.Mdtrtinfo.PatnName
108
+	mdtrtinfo["psn_cert_type"] = cFYLJG001.Mdtrtinfo.PsnCertType
109
+	mdtrtinfo["certno"] = cFYLJG001.Mdtrtinfo.Certno
110
+	mdtrtinfo["patn_age"] = cFYLJG001.Mdtrtinfo.PatnAge
111
+	mdtrtinfo["patn_hgt"] = cFYLJG001.Mdtrtinfo.PatnHgt
112
+	mdtrtinfo["patn_wt"] = cFYLJG001.Mdtrtinfo.PatnWt
113
+	mdtrtinfo["gend"] = cFYLJG001.Mdtrtinfo.Gend
114
+	mdtrtinfo["birctrlType"] = cFYLJG001.Mdtrtinfo.BirctrlType
115
+	mdtrtinfo["birctrlMatnDate"] = cFYLJG001.Mdtrtinfo.BirctrlMatnDate
116
+	mdtrtinfo["matnType"] = cFYLJG001.Mdtrtinfo.MatnType
117
+	mdtrtinfo["geso_val"] = cFYLJG001.Mdtrtinfo.GesoVal
118
+	mdtrtinfo["nwb_flag"] = cFYLJG001.Mdtrtinfo.NwbFlag
119
+	mdtrtinfo["nwb_age"] = cFYLJG001.Mdtrtinfo.NwbAge
120
+	mdtrtinfo["suck_prd_flag"] = cFYLJG001.Mdtrtinfo.SuckPrdFlag
121
+	mdtrtinfo["algs_his"] = cFYLJG001.Mdtrtinfo.AlgsHis
122
+	mdtrtinfo["prsc_dept_name"] = cFYLJG001.Mdtrtinfo.PrscDeptName
123
+	mdtrtinfo["prsc_dept_code"] = cFYLJG001.Mdtrtinfo.PrscDeptCode
124
+	mdtrtinfo["dr_code"] = cFYLJG001.Mdtrtinfo.DrCode
125
+	mdtrtinfo["prsc_dr_name"] = cFYLJG001.Mdtrtinfo.PrscDrName
126
+	mdtrtinfo["prsc_dr_cert_type"] = cFYLJG001.Mdtrtinfo.PrscDrCertType
127
+	mdtrtinfo["prsc_dr_certno"] = cFYLJG001.Mdtrtinfo.PrscDrCertno
128
+	mdtrtinfo["dr_profttl_codg"] = cFYLJG001.Mdtrtinfo.DrProfttlCodg
129
+	mdtrtinfo["dr_profttl_name"] = cFYLJG001.Mdtrtinfo.DrProfttlName
130
+	mdtrtinfo["dr_dept_code"] = cFYLJG001.Mdtrtinfo.DrDeptCode
131
+	mdtrtinfo["dr_dept_name"] = cFYLJG001.Mdtrtinfo.DrDeptName
132
+	mdtrtinfo["caty"] = cFYLJG001.Mdtrtinfo.Caty
133
+	mdtrtinfo["mdtrt_time"] = cFYLJG001.Mdtrtinfo.MdtrtTime
134
+	mdtrtinfo["dise_codg"] = cFYLJG001.Mdtrtinfo.DiseCodg
135
+	mdtrtinfo["dise_name"] = cFYLJG001.Mdtrtinfo.DiseName
136
+	mdtrtinfo["sp_dise_flag"] = cFYLJG001.Mdtrtinfo.SpDiseFlag
137
+	mdtrtinfo["maindiag_code"] = cFYLJG001.Mdtrtinfo.MaindiagCode
138
+	mdtrtinfo["maindiag_name"] = cFYLJG001.Mdtrtinfo.MaindiagName
139
+	mdtrtinfo["dise_cond_dscr"] = cFYLJG001.Mdtrtinfo.DiseCondDscr
140
+	mdtrtinfo["hi_feesetl_flag"] = cFYLJG001.Mdtrtinfo.HiFeesetlFlag
141
+	mdtrtinfo["hi_feesetl_name"] = cFYLJG001.Mdtrtinfo.HiFeesetlName
142
+	mdtrtinfo["rgst_fee"] = cFYLJG001.Mdtrtinfo.RgstFee
143
+	mdtrtinfo["medfee_sumamt"] = cFYLJG001.Mdtrtinfo.MedfeeSumamt
144
+	mdtrtinfo["fstdiag_flag"] = cFYLJG001.Mdtrtinfo.FstdiagFlag
145
+	mdtrtinfo["extras"] = cFYLJG001.Mdtrtinfo.Extras
146
+	inputData["mdtrtinfo"] = mdtrtinfo
147
+
148
+	diseinfos := make([]map[string]interface{}, 0)
149
+
150
+	for _, item := range cFYLJG001.Diseinfo {
151
+		diseinfo := make(map[string]interface{})
152
+		diseinfo["diag_type"] = item.DiagType
153
+		diseinfo["maindiag_flag"] = item.MaindiagFlag
154
+		diseinfo["diag_srt_no"] = item.DiagSrtNo
155
+		diseinfo["diag_code"] = item.DiagCode
156
+		diseinfo["diag_name"] = item.DiagName
157
+		diseinfo["diag_dept"] = item.DiagDept
158
+		diseinfo["diag_dr_no"] = item.DiagDrNo
159
+		diseinfo["diag_dr_name"] = item.DiagDrName
160
+		diseinfo["diag_time"] = item.DiagTime
161
+		diseinfo["tcm_dise_code"] = item.TcmDiseCode
162
+		diseinfo["tcm_dise_name"] = item.TcmDiseName
163
+		diseinfo["tcmsymp_code"] = item.TcmsympCode
164
+		diseinfo["tcmsymp"] = item.Tcmsymp
165
+		diseinfos = append(diseinfos, diseinfo)
166
+	}
167
+	inputData["diseinfo"] = diseinfos
168
+
169
+	inputMessage["input"] = inputData
170
+
171
+	var inputLog string
172
+	bytesData, err := json.Marshal(inputMessage)
173
+	inputLog = string(bytesData)
174
+	fmt.Println(string(bytesData))
175
+	if err != nil {
176
+		fmt.Println(err.Error())
177
+		return err.Error(), ""
178
+	}
179
+	reader := bytes.NewReader(bytesData)
180
+	gdyb_url := beego.AppConfig.String("gdyb_url")
181
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
182
+
183
+	var url string
184
+	if fixmedins_code == "H15049901371" {
185
+		url = gdyb_url
186
+	} else {
187
+		url = gdyb_url + "CFYLJG001"
188
+	}
189
+
190
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
191
+	request, err := http.NewRequest("POST", url, reader)
192
+	if err != nil {
193
+		fmt.Println(err.Error())
194
+		return err.Error(), ""
195
+	}
196
+
197
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
198
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
199
+	request.Header.Set("x-tif-signature", signature)
200
+	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
201
+	request.Header.Set("x-tif-nonce", nonce)
202
+
203
+	client := http.Client{}
204
+	resp, err := client.Do(request)
205
+	if err != nil {
206
+		fmt.Println(err.Error())
207
+		return err.Error(), ""
208
+	}
209
+	respBytes, err := ioutil.ReadAll(resp.Body)
210
+	if err != nil {
211
+		fmt.Println(err.Error())
212
+		return err.Error(), ""
213
+	}
214
+	fmt.Println(string(respBytes))
215
+	str := string(respBytes)
216
+	return str, inputLog
217
+
218
+}
219
+
220
+func GetCFYLJG002(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, original_value string, original_rx_file string, extras string) (string, string) {
221
+	//生成签名
222
+	nonce := GetRandomString(32)
223
+	timestamp := time.Now().Unix()
224
+	signature := setSignature(timestamp, nonce, secret_key)
225
+	//生成输入报文
226
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
227
+	inputData := make(map[string]interface{})
228
+	//inputData := makemap[string]interface{})
229
+
230
+	inputMessage["infno"] = "CFYLJG002"
231
+	inputData["fixmedins_code"] = fixmedins_code
232
+	inputData["original_value"] = original_value
233
+	inputData["original_rx_file"] = original_rx_file
234
+	inputData["extras"] = extras
235
+	inputMessage["rx_sign_info"] = inputData
236
+
237
+	var inputLog string
238
+	bytesData, err := json.Marshal(inputMessage)
239
+	inputLog = string(bytesData)
240
+	fmt.Println(string(bytesData))
241
+	if err != nil {
242
+		fmt.Println(err.Error())
243
+		return err.Error(), ""
244
+	}
245
+	reader := bytes.NewReader(bytesData)
246
+	gdyb_url := beego.AppConfig.String("gdyb_url")
247
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
248
+
249
+	var url string
250
+	if fixmedins_code == "H15049901371" {
251
+		url = gdyb_url
252
+	} else {
253
+		url = gdyb_url + "CFYLJG002"
254
+	}
255
+
256
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
257
+	request, err := http.NewRequest("POST", url, reader)
258
+	if err != nil {
259
+		fmt.Println(err.Error())
260
+		return err.Error(), ""
261
+	}
262
+
263
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
264
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
265
+	request.Header.Set("x-tif-signature", signature)
266
+	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
267
+	request.Header.Set("x-tif-nonce", nonce)
268
+
269
+	client := http.Client{}
270
+	resp, err := client.Do(request)
271
+	if err != nil {
272
+		fmt.Println(err.Error())
273
+		return err.Error(), ""
274
+	}
275
+	respBytes, err := ioutil.ReadAll(resp.Body)
276
+	if err != nil {
277
+		fmt.Println(err.Error())
278
+		return err.Error(), ""
279
+	}
280
+	fmt.Println(string(respBytes))
281
+	str := string(respBytes)
282
+	return str, inputLog
283
+
284
+}
285
+
286
+func GetCFYLJG003(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, cFYLJG003 models.CFYLJG003) (string, string) {
287
+	//生成签名
288
+	nonce := GetRandomString(32)
289
+	timestamp := time.Now().Unix()
290
+	signature := setSignature(timestamp, nonce, secret_key)
291
+	//生成输入报文
292
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
293
+	input := make(map[string]interface{})
294
+	inputDatas := make([]map[string]interface{}, 0)
295
+
296
+	inputMessage["infno"] = "CFYLJG003"
297
+
298
+	inputData["rx_trace_code"] = cFYLJG003.RxTraceCode
299
+	inputData["hi_rxno"] = cFYLJG003.HiRxno
300
+	inputData["mdtrt_id"] = cFYLJG003.MdtrtID
301
+	inputData["patn_name"] = cFYLJG003.PatnName
302
+	inputData["psn_cert_type"] = cFYLJG003.PsnCertType
303
+	inputData["certno"] = cFYLJG003.Certno
304
+	inputData["fixmedins_name"] = cFYLJG003.FixmedinsName
305
+	inputData["fixmedins_code"] = cFYLJG003.FixmedinsCode
306
+	inputData["dr_code"] = cFYLJG003.DrCode
307
+	inputData["prsc_dr_name"] = cFYLJG003.PrscDrName
308
+	inputData["phar_dept_name"] = cFYLJG003.PharDeptName
309
+	inputData["phar_dept_code"] = cFYLJG003.PharDeptCode
310
+	inputData["phar_profttl_codg"] = cFYLJG003.PharProfttlCodg
311
+	inputData["phar_profttl_name"] = cFYLJG003.PharProfttlName
312
+	inputData["phar_code"] = cFYLJG003.PharCode
313
+	inputData["rx_frqu_name"] = cFYLJG003.RxFrquName
314
+	inputData["phar_cert_type"] = cFYLJG003.PsnCertType
315
+	inputData["phar_certno"] = cFYLJG003.PharCertno
316
+	inputData["phar_name"] = cFYLJG003.PharName
317
+	inputData["phar_prac_cert_no"] = cFYLJG003.PharPracCertNo
318
+	inputData["phar_chk_time"] = cFYLJG003.PharChkTime
319
+	inputData["rx_file"] = cFYLJG003.RxFile
320
+	inputData["sign_digest"] = cFYLJG003.SignDigest
321
+	inputMessage["rx_upload_info"] = inputData
322
+	var inputLog string
323
+	bytesData, err := json.Marshal(inputMessage)
324
+	inputLog = string(bytesData)
325
+	fmt.Println(string(bytesData))
326
+	if err != nil {
327
+		fmt.Println(err.Error())
328
+		return err.Error(), ""
329
+	}
330
+	reader := bytes.NewReader(bytesData)
331
+	gdyb_url := beego.AppConfig.String("gdyb_url")
332
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
333
+
334
+	var url string
335
+	if fixmedins_code == "H15049901371" {
336
+		url = gdyb_url
337
+	} else {
338
+		url = gdyb_url + "CFYLJG003"
339
+	}
340
+
341
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
342
+	request, err := http.NewRequest("POST", url, reader)
343
+	if err != nil {
344
+		fmt.Println(err.Error())
345
+		return err.Error(), ""
346
+	}
347
+
348
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
349
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
350
+	request.Header.Set("x-tif-signature", signature)
351
+	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
352
+	request.Header.Set("x-tif-nonce", nonce)
353
+
354
+	client := http.Client{}
355
+	resp, err := client.Do(request)
356
+	if err != nil {
357
+		fmt.Println(err.Error())
358
+		return err.Error(), ""
359
+	}
360
+	respBytes, err := ioutil.ReadAll(resp.Body)
361
+	if err != nil {
362
+		fmt.Println(err.Error())
363
+		return err.Error(), ""
364
+	}
365
+	fmt.Println(string(respBytes))
366
+	str := string(respBytes)
367
+	return str, inputLog
368
+
369
+}
370
+
371
+func GetCFYLJG004(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, cFYLJG004 models.CFYLJG004) (string, string) {
372
+	//生成签名
373
+	nonce := GetRandomString(32)
374
+	timestamp := time.Now().Unix()
375
+	signature := setSignature(timestamp, nonce, secret_key)
376
+	//生成输入报文
377
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
378
+	input := make(map[string]interface{})
379
+	inputDatas := make([]map[string]interface{}, 0)
380
+
381
+	inputMessage["infno"] = "CFYLJG004"
382
+
383
+	inputData["hi_rxno"] = cFYLJG004.HiRxno
384
+	inputData["undo_dr_code"] = cFYLJG004.UndoDrCode
385
+	inputData["undo_dr_name"] = cFYLJG004.UndoDrName
386
+	inputData["undo_dr_cert_type"] = cFYLJG004.UndoDrCertType
387
+	inputData["undo_dr_certno"] = cFYLJG004.UndoDrCertno
388
+	inputData["undo_rea"] = cFYLJG004.UndoRea
389
+	inputData["undo_time"] = cFYLJG004.UndoTime
390
+	inputData["fixmedins_code"] = cFYLJG004.FixmedinsCode
391
+
392
+	inputMessage["rx_cancel_info"] = inputData
393
+	var inputLog string
394
+	bytesData, err := json.Marshal(inputMessage)
395
+	inputLog = string(bytesData)
396
+	fmt.Println(string(bytesData))
397
+	if err != nil {
398
+		fmt.Println(err.Error())
399
+		return err.Error(), ""
400
+	}
401
+	reader := bytes.NewReader(bytesData)
402
+	gdyb_url := beego.AppConfig.String("gdyb_url")
403
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
404
+
405
+	var url string
406
+	if fixmedins_code == "H15049901371" {
407
+		url = gdyb_url
408
+	} else {
409
+		url = gdyb_url + "CFYLJG004"
410
+	}
411
+
412
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
413
+	request, err := http.NewRequest("POST", url, reader)
414
+	if err != nil {
415
+		fmt.Println(err.Error())
416
+		return err.Error(), ""
417
+	}
418
+
419
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
420
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
421
+	request.Header.Set("x-tif-signature", signature)
422
+	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
423
+	request.Header.Set("x-tif-nonce", nonce)
424
+
425
+	client := http.Client{}
426
+	resp, err := client.Do(request)
427
+	if err != nil {
428
+		fmt.Println(err.Error())
429
+		return err.Error(), ""
430
+	}
431
+	respBytes, err := ioutil.ReadAll(resp.Body)
432
+	if err != nil {
433
+		fmt.Println(err.Error())
434
+		return err.Error(), ""
435
+	}
436
+	fmt.Println(string(respBytes))
437
+	str := string(respBytes)
438
+	return str, inputLog
439
+
440
+}
441
+
442
+func GetCFYLJG005(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, cFYLJG005 models.CFYLJG005) (string, string) {
443
+	//生成签名
444
+	nonce := GetRandomString(32)
445
+	timestamp := time.Now().Unix()
446
+	signature := setSignature(timestamp, nonce, secret_key)
447
+	//生成输入报文
448
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
449
+	input := make(map[string]interface{})
450
+	inputDatas := make([]map[string]interface{}, 0)
451
+
452
+	inputMessage["infno"] = "CFYLJG005"
453
+
454
+	inputData["fixmedins_code"] = cFYLJG005.FixmedinsCode
455
+
456
+	inputData["hi_rxno"] = cFYLJG005.HiRxno
457
+	inputData["mdtrt_id"] = cFYLJG005.MdtrtID
458
+	inputData["ec_token"] = cFYLJG005.EcToken
459
+	inputData["psn_name"] = cFYLJG005.PsnName
460
+	inputData["psn_cert_type"] = cFYLJG005.PsnCertType
461
+	inputData["certno"] = cFYLJG005.Certno
462
+
463
+	inputMessage["rx_detl_query"] = inputData
464
+	var inputLog string
465
+	bytesData, err := json.Marshal(inputMessage)
466
+	inputLog = string(bytesData)
467
+	fmt.Println(string(bytesData))
468
+	if err != nil {
469
+		fmt.Println(err.Error())
470
+		return err.Error(), ""
471
+	}
472
+	reader := bytes.NewReader(bytesData)
473
+	gdyb_url := beego.AppConfig.String("gdyb_url")
474
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
475
+
476
+	var url string
477
+	if fixmedins_code == "H15049901371" {
478
+		url = gdyb_url
479
+	} else {
480
+		url = gdyb_url + "CFYLJG005"
481
+	}
482
+
483
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
484
+	request, err := http.NewRequest("POST", url, reader)
485
+	if err != nil {
486
+		fmt.Println(err.Error())
487
+		return err.Error(), ""
488
+	}
489
+
490
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
491
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
492
+	request.Header.Set("x-tif-signature", signature)
493
+	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
494
+	request.Header.Set("x-tif-nonce", nonce)
495
+
496
+	client := http.Client{}
497
+	resp, err := client.Do(request)
498
+	if err != nil {
499
+		fmt.Println(err.Error())
500
+		return err.Error(), ""
501
+	}
502
+	respBytes, err := ioutil.ReadAll(resp.Body)
503
+	if err != nil {
504
+		fmt.Println(err.Error())
505
+		return err.Error(), ""
506
+	}
507
+	fmt.Println(string(respBytes))
508
+	str := string(respBytes)
509
+	return str, inputLog
510
+
511
+}
512
+
513
+func GetCFYLJG006(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, cFYLJG006 models.CFYLJG006) (string, string) {
514
+	//生成签名
515
+	nonce := GetRandomString(32)
516
+	timestamp := time.Now().Unix()
517
+	signature := setSignature(timestamp, nonce, secret_key)
518
+	//生成输入报文
519
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
520
+	input := make(map[string]interface{})
521
+	inputDatas := make([]map[string]interface{}, 0)
522
+
523
+	inputMessage["infno"] = "CFYLJG006"
524
+
525
+	inputData["fixmedins_code"] = cFYLJG006.FixmedinsCode
526
+	inputData["hi_rxno"] = cFYLJG006.HiRxno
527
+	inputData["mdtrt_id"] = cFYLJG006.MdtrtID
528
+	inputData["psn_cert_type"] = cFYLJG006.PsnCertType
529
+	inputData["certno"] = cFYLJG006.Certno
530
+	inputData["psn_name"] = cFYLJG006.PsnName
531
+
532
+	inputMessage["rx_chk_info"] = inputData
533
+	var inputLog string
534
+	bytesData, err := json.Marshal(inputMessage)
535
+	inputLog = string(bytesData)
536
+	fmt.Println(string(bytesData))
537
+	if err != nil {
538
+		fmt.Println(err.Error())
539
+		return err.Error(), ""
540
+	}
541
+	reader := bytes.NewReader(bytesData)
542
+	gdyb_url := beego.AppConfig.String("gdyb_url")
543
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
544
+
545
+	var url string
546
+	if fixmedins_code == "H15049901371" {
547
+		url = gdyb_url
548
+	} else {
549
+		url = gdyb_url + "CFYLJG006"
550
+	}
551
+
552
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
553
+	request, err := http.NewRequest("POST", url, reader)
554
+	if err != nil {
555
+		fmt.Println(err.Error())
556
+		return err.Error(), ""
557
+	}
558
+
559
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
560
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
561
+	request.Header.Set("x-tif-signature", signature)
562
+	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
563
+	request.Header.Set("x-tif-nonce", nonce)
564
+
565
+	client := http.Client{}
566
+	resp, err := client.Do(request)
567
+	if err != nil {
568
+		fmt.Println(err.Error())
569
+		return err.Error(), ""
570
+	}
571
+	respBytes, err := ioutil.ReadAll(resp.Body)
572
+	if err != nil {
573
+		fmt.Println(err.Error())
574
+		return err.Error(), ""
575
+	}
576
+	fmt.Println(string(respBytes))
577
+	str := string(respBytes)
578
+	return str, inputLog
579
+
580
+}
581
+func GetCFYLJG007(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, cFYLJG007 models.CFYLJG007) (string, string) {
582
+	//生成签名
583
+	nonce := GetRandomString(32)
584
+	timestamp := time.Now().Unix()
585
+	signature := setSignature(timestamp, nonce, secret_key)
586
+	//生成输入报文
587
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
588
+	input := make(map[string]interface{})
589
+	inputDatas := make([]map[string]interface{}, 0)
590
+
591
+	inputMessage["infno"] = "CFYLJG007"
592
+
593
+	inputData["fixmedins_code"] = cFYLJG007.FixmedinsCode
594
+	inputData["hi_rxno"] = cFYLJG007.HiRxno
595
+	inputData["mdtrt_id"] = cFYLJG007.MdtrtID
596
+	inputData["psn_no"] = cFYLJG007.PsnNo
597
+	inputData["psn_cert_type"] = cFYLJG007.PsnCertType
598
+	inputData["certno"] = cFYLJG007.Certno
599
+
600
+	inputMessage["rx_setl_query"] = inputData
601
+	var inputLog string
602
+	bytesData, err := json.Marshal(inputMessage)
603
+	inputLog = string(bytesData)
604
+	fmt.Println(string(bytesData))
605
+	if err != nil {
606
+		fmt.Println(err.Error())
607
+		return err.Error(), ""
608
+	}
609
+	reader := bytes.NewReader(bytesData)
610
+	gdyb_url := beego.AppConfig.String("gdyb_url")
611
+	gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
612
+
613
+	var url string
614
+	if fixmedins_code == "H15049901371" {
615
+		url = gdyb_url
616
+	} else {
617
+		url = gdyb_url + "CFYLJG007"
618
+	}
619
+
620
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
621
+	request, err := http.NewRequest("POST", url, reader)
622
+	if err != nil {
623
+		fmt.Println(err.Error())
624
+		return err.Error(), ""
625
+	}
626
+
627
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
628
+	request.Header.Set("x-tif-paasid", gdyb_paasid)
629
+	request.Header.Set("x-tif-signature", signature)
630
+	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
631
+	request.Header.Set("x-tif-nonce", nonce)
632
+
633
+	client := http.Client{}
634
+	resp, err := client.Do(request)
635
+	if err != nil {
636
+		fmt.Println(err.Error())
637
+		return err.Error(), ""
638
+	}
639
+	respBytes, err := ioutil.ReadAll(resp.Body)
640
+	if err != nil {
641
+		fmt.Println(err.Error())
642
+		return err.Error(), ""
643
+	}
644
+	fmt.Println(string(respBytes))
645
+	str := string(respBytes)
646
+	return str, inputLog
647
+
648
+}

+ 20 - 4
service/his_service.go Прегледај датотеку

@@ -1501,10 +1501,10 @@ func GetAllHisOrder10278() (his []*models.HisOrder, err error) {
1501 1501
 	return
1502 1502
 }
1503 1503
 
1504
-//func GetAllHisOrder2(org_id int64) (his []models.HisOrder, err error) {
1505
-//	err = readDb.Model(&models.HisOrder{}).Where("id = 180753").Order("setl_time asc").First(&his).Error
1506
-//	return
1507
-//}
1504
+//	func GetAllHisOrder2(org_id int64) (his []models.HisOrder, err error) {
1505
+//		err = readDb.Model(&models.HisOrder{}).Where("id = 180753").Order("setl_time asc").First(&his).Error
1506
+//		return
1507
+//	}
1508 1508
 func GetAllHisOrderErr10278() (his []*models.HisOrderError, err error) {
1509 1509
 	err = readDb.Model(&models.HisOrderError{}).Where("user_org_id = 10278 AND status = 1 AND stage = 10276").Find(&his).Error
1510 1510
 	return
@@ -1570,3 +1570,19 @@ func GetHisOrderByIDTwo1111(order_id int64) (order models.NewHisOrder111, err er
1570 1570
 	err = readDb.Model(&models.HisOrder{}).Where("id = ? AND status = 1", order_id).First(&order).Error
1571 1571
 	return
1572 1572
 }
1573
+
1574
+func GetHisPrescriptionForMedType(org_id int64, patient_id int64, record_date int64) (prescription []*models.HisPrescription, err error) {
1575
+	err = readDb.Model(&models.HisPrescription{}).
1576
+		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
1577
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
1578
+		}).
1579
+		Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
1580
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("BaseDrugLib", "status=1")
1581
+		}).
1582
+		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
1583
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
1584
+		}).
1585
+		Where("(user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status <> 2 AND p_type <> 1 and med_type = 148801) or (user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status <> 2 AND p_type <> 1 and med_type = 118801)", org_id, record_date, patient_id, org_id, record_date, patient_id).
1586
+		Find(&prescription).Error
1587
+	return
1588
+}