csx hace 4 años
padre
commit
54b374c556

BIN
SSCardDriver_SZ.dll Ver fichero


+ 355 - 127
controllers/sz/sz_his_api_controller.go Ver fichero

13
 	"math/rand"
13
 	"math/rand"
14
 	"strconv"
14
 	"strconv"
15
 	"strings"
15
 	"strings"
16
+	//"strings"
16
 	"syscall"
17
 	"syscall"
17
 	"time"
18
 	"time"
18
 	"unsafe"
19
 	"unsafe"
74
 	Operatorpass       string `json:"operatorPass"`
75
 	Operatorpass       string `json:"operatorPass"`
75
 	Transbody          struct {
76
 	Transbody          struct {
76
 		Ckc618     string  `json:"ckc618"`
77
 		Ckc618     string  `json:"ckc618"`
77
-		Akc264     int     `json:"akc264"`
78
+		Akc264     float64 `json:"akc264"`
78
 		Akb068     int     `json:"akb068"`
79
 		Akb068     int     `json:"akb068"`
79
-		Akb066     int     `json:"akb066"`
80
+		Akb066     float64 `json:"akb066"`
80
 		Akb067     int     `json:"akb067"`
81
 		Akb067     int     `json:"akb067"`
81
 		Aae240     float64 `json:"aae240"`
82
 		Aae240     float64 `json:"aae240"`
82
 		Outputlist []struct {
83
 		Outputlist []struct {
83
-			Aaa036 string `json:"aaa036"`
84
-			Aae019 int    `json:"aae019"`
84
+			Aaa036 string  `json:"aaa036"`
85
+			Aae019 float64 `json:"aae019"`
85
 		} `json:"outputlist"`
86
 		} `json:"outputlist"`
86
 		Outputlist2 []interface{} `json:"outputlist2"`
87
 		Outputlist2 []interface{} `json:"outputlist2"`
87
 	} `json:"transBody"`
88
 	} `json:"transBody"`
114
 		Akb067      float64 `json:"akb067"`
115
 		Akb067      float64 `json:"akb067"`
115
 		Aae240      float64 `json:"aae240"`
116
 		Aae240      float64 `json:"aae240"`
116
 		Outputlist1 []struct {
117
 		Outputlist1 []struct {
117
-			Aka111 string `json:"aka111"`
118
-			Bka058 int    `json:"bka058"`
118
+			Aka111 string  `json:"aka111"`
119
+			Bka058 float64 `json:"bka058"`
119
 		} `json:"outputlist1"`
120
 		} `json:"outputlist1"`
120
 		Outputlist2 []struct {
121
 		Outputlist2 []struct {
121
-			Aaa036 string `json:"aaa036"`
122
-			Aae019 int    `json:"aae019"`
122
+			Aaa036 string  `json:"aaa036"`
123
+			Aae019 float64 `json:"aae019"`
123
 		} `json:"outputlist2"`
124
 		} `json:"outputlist2"`
124
 		Outputlist3 []interface{} `json:"outputlist3"`
125
 		Outputlist3 []interface{} `json:"outputlist3"`
125
 	} `json:"transBody"`
126
 	} `json:"transBody"`
171
 	Operatorpass       string `json:"operatorPass"`
172
 	Operatorpass       string `json:"operatorPass"`
172
 	Transbody          struct {
173
 	Transbody          struct {
173
 		Akc190      string  `json:"akc190"`
174
 		Akc190      string  `json:"akc190"`
174
-		Akc194      int     `json:"akc194"`
175
+		Akc194      float64 `json:"akc194"`
175
 		Bae917      int64   `json:"bae917"`
176
 		Bae917      int64   `json:"bae917"`
176
 		Aka018      string  `json:"aka018"`
177
 		Aka018      string  `json:"aka018"`
177
 		Aka030      string  `json:"aka030"`
178
 		Aka030      string  `json:"aka030"`
178
 		Ckc618      string  `json:"ckc618"`
179
 		Ckc618      string  `json:"ckc618"`
179
-		Akc264      int     `json:"akc264"`
180
-		Akb068      int     `json:"akb068"`
181
-		Akb066      int     `json:"akb066"`
182
-		Akb067      int     `json:"akb067"`
180
+		Akc264      float64 `json:"akc264"`
181
+		Akb068      float64 `json:"akb068"`
182
+		Akb066      float64 `json:"akb066"`
183
+		Akb067      float64 `json:"akb067"`
183
 		Cke298      float64 `json:"cke298"`
184
 		Cke298      float64 `json:"cke298"`
184
 		Aae240      float64 `json:"aae240"`
185
 		Aae240      float64 `json:"aae240"`
185
 		Outputlist2 []struct {
186
 		Outputlist2 []struct {
186
-			Aka111 string `json:"aka111"`
187
-			Bka058 int    `json:"bka058"`
187
+			Aka111 string  `json:"aka111"`
188
+			Bka058 float64 `json:"bka058"`
188
 		} `json:"outputlist2"`
189
 		} `json:"outputlist2"`
189
 		Outputlist3 []struct {
190
 		Outputlist3 []struct {
190
-			Aaa036 string `json:"aaa036"`
191
-			Aae019 int    `json:"aae019"`
191
+			Aaa036 string  `json:"aaa036"`
192
+			Aae019 float64 `json:"aae019"`
192
 		} `json:"outputlist3"`
193
 		} `json:"outputlist3"`
193
 	} `json:"transBody"`
194
 	} `json:"transBody"`
194
 	Verifycode         string `json:"verifyCode"`
195
 	Verifycode         string `json:"verifyCode"`
199
 	Caz055             string `json:"caz055"`
200
 	Caz055             string `json:"caz055"`
200
 	Aae501             string `json:"aae501"`
201
 	Aae501             string `json:"aae501"`
201
 }
202
 }
202
-
203
+type ResultFive struct {
204
+	Transtime          string `json:"transTime"`
205
+	Transtype          string `json:"transType"`
206
+	Transreturncode    string `json:"transReturnCode"`
207
+	Transreturnmessage string `json:"transReturnMessage"`
208
+	Transversion       string `json:"transVersion"`
209
+	Serialnumber       string `json:"serialNumber"`
210
+	Cardarea           string `json:"cardArea"`
211
+	Hospitalcode       string `json:"hospitalCode"`
212
+	Operatorcode       string `json:"operatorCode"`
213
+	Operatorname       string `json:"operatorName"`
214
+	Operatorpass       string `json:"operatorPass"`
215
+	Transbody          struct {
216
+		Akc190     string `json:"akc190"`
217
+		Listsize   int    `json:"listsize"`
218
+		Outputlist []struct {
219
+			Aae072 string `json:"aae072"`
220
+			Bkf500 string `json:"bkf500"`
221
+			Baz700 string `json:"baz700"`
222
+			Bce574 string `json:"bce574"`
223
+		} `json:"outputlist"`
224
+	} `json:"transBody"`
225
+	Verifycode         string `json:"verifyCode"`
226
+	Extenddeviceid     string `json:"extendDeviceId"`
227
+	Transchannel       string `json:"transChannel"`
228
+	Extenduserid       string `json:"extendUserId"`
229
+	Extendserialnumber string `json:"extendSerialNumber"`
230
+	Caz055             string `json:"caz055"`
231
+	Aae501             string `json:"aae501"`
232
+}
203
 type SZHisApiController struct {
233
 type SZHisApiController struct {
204
 	controllers.BaseAuthAPIController
234
 	controllers.BaseAuthAPIController
205
 }
235
 }
216
 	beego.Router("/sz/api/monthrefund/get", &SZHisApiController{}, "get:MonthRefund")
246
 	beego.Router("/sz/api/monthrefund/get", &SZHisApiController{}, "get:MonthRefund")
217
 	//查询交易
247
 	//查询交易
218
 	beego.Router("/sz/api/settle/query", &SZHisApiController{}, "get:GetSettleAccounts")
248
 	beego.Router("/sz/api/settle/query", &SZHisApiController{}, "get:GetSettleAccounts")
249
+	//撤销明细
250
+	beego.Router("/sz/api/detail/cancel", &SZHisApiController{}, "get:CancelOrderDetail")
219
 
251
 
220
 	//机构药品目录备案
252
 	//机构药品目录备案
221
 	beego.Router("/sz/api/drug/get", &SZHisApiController{}, "get:GetDrugList")
253
 	beego.Router("/sz/api/drug/get", &SZHisApiController{}, "get:GetDrugList")
319
 		custom_project_name = "普通门诊"
351
 		custom_project_name = "普通门诊"
320
 		allPrice = registration_fee + medical_expenses
352
 		allPrice = registration_fee + medical_expenses
321
 		break
353
 		break
322
-	case 2:
354
+	case 3:
323
 		custom_code = "110200002-2"
355
 		custom_code = "110200002-2"
324
 		custom_project_name = "主任医师"
356
 		custom_project_name = "主任医师"
325
 		allPrice = registration_fee + medical_expenses
357
 		allPrice = registration_fee + medical_expenses
326
 
358
 
327
 		break
359
 		break
328
-	case 3:
360
+	case 2:
329
 		custom_code = "110200002-3"
361
 		custom_code = "110200002-3"
330
 		custom_project_name = "副主任医师"
362
 		custom_project_name = "副主任医师"
331
 		allPrice = registration_fee + medical_expenses
363
 		allPrice = registration_fee + medical_expenses
332
 
364
 
333
 		break
365
 		break
334
 	case 4:
366
 	case 4:
335
-		custom_code = "110200003"
336
-		custom_project_name = "急诊诊查费"
337
-		allPrice = registration_fee + medical_expenses
338
-
367
+		custom_code = "0"
368
+		custom_project_name = "免受诊金"
369
+		allPrice = 0
339
 		break
370
 		break
340
 	case 5:
371
 	case 5:
341
 		custom_code = "110200002-1"
372
 		custom_code = "110200002-1"
342
 		custom_project_name = "专家"
373
 		custom_project_name = "专家"
343
 		allPrice = registration_fee + medical_expenses
374
 		allPrice = registration_fee + medical_expenses
344
 
375
 
345
-		break
346
-	case 6:
347
-		custom_code = "0"
348
-		custom_project_name = "免受诊金"
349
-		allPrice = 0
350
 		break
376
 		break
351
 	}
377
 	}
352
 
378
 
371
 
397
 
372
 		//流水号
398
 		//流水号
373
 		//
399
 		//
374
-		//number := miConfig.Code + year + month + day +
375
-		//	fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
376
-		mz_number := year + month + day + strconv.FormatInt(patient_id, 10)
377
-		number := miConfig.Code + year + month + day + "2233445"
378
-		//verifyCode, version_code := ReadCardGetCode("MZ002" + "|" + number + "|" + miConfig.Code)
379
-		verifyCode := "000000|4d221ed0d796a493ada20244272962d4"
380
-		version_code := "0.03"
400
+		number := miConfig.Code + year + month + day +
401
+			fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
402
+		mz_number := year + month + day + strconv.FormatInt(patient_id, 10) +
403
+			fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000))
404
+		//number := miConfig.Code + year + month + day + "1590000"
405
+		verifyCode, version_code := ReadCardGetCode("MZ002" + "|" + number + "|" + miConfig.Code)
406
+		//verifyCode := "000000|4c871a545d1006754246a50a85c3a353"
407
+		//version_code := "V0.3"
381
 		//1.判断读卡类型
408
 		//1.判断读卡类型
382
 		//2.读卡 获取交易验证码,医疗证号,发卡地区行政区划代码
409
 		//2.读卡 获取交易验证码,医疗证号,发卡地区行政区划代码
383
 		//yiliao_number, id_card_number,verifyCode, err, ret4 := ReadBasCardGetNumber(number)
410
 		//yiliao_number, id_card_number,verifyCode, err, ret4 := ReadBasCardGetNumber(number)
445
 						"msg": "挂号成功",
472
 						"msg": "挂号成功",
446
 					})
473
 					})
447
 				} else {
474
 				} else {
448
-
475
+					c.ServeSuccessJSON(map[string]interface{}{
476
+						"failed_code": -10,
477
+						"msg":         res.Transreturnmessage,
478
+					})
479
+					return
449
 				}
480
 				}
450
-				//
451
-				//} else {
452
-				//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
453
-				//	return
454
-				//}
455
 
481
 
456
 			} else { //异地就医流程
482
 			} else { //异地就医流程
457
 				//异地走鉴权流程
483
 				//异地走鉴权流程
511
 						"msg": "挂号成功",
537
 						"msg": "挂号成功",
512
 					})
538
 					})
513
 				} else {
539
 				} else {
514
-
540
+					c.ServeSuccessJSON(map[string]interface{}{
541
+						"failed_code": -10,
542
+						"msg":         res.Transreturnmessage,
543
+					})
544
+					return
515
 				}
545
 				}
516
 
546
 
517
 				//}
547
 				//}
573
 						"msg": "挂号成功",
603
 						"msg": "挂号成功",
574
 					})
604
 					})
575
 				} else {
605
 				} else {
576
-
606
+					c.ServeSuccessJSON(map[string]interface{}{
607
+						"failed_code": -10,
608
+						"msg":         res.Transreturnmessage,
609
+					})
610
+					return
577
 				}
611
 				}
578
 
612
 
579
 			} else { //异地就医需要走鉴权流程
613
 			} else { //异地就医需要走鉴权流程
630
 						"msg": "挂号成功",
664
 						"msg": "挂号成功",
631
 					})
665
 					})
632
 				} else {
666
 				} else {
633
-
667
+					c.ServeSuccessJSON(map[string]interface{}{
668
+						"failed_code": -10,
669
+						"msg":         res.Transreturnmessage,
670
+					})
671
+					return
634
 				}
672
 				}
635
 
673
 
636
 			}
674
 			}
643
 
681
 
644
 //上传明细----预结算----确认订单
682
 //上传明细----预结算----确认订单
645
 func (c *SZHisApiController) GetUploadInfo() {
683
 func (c *SZHisApiController) GetUploadInfo() {
646
-	patient_id, _ := c.GetInt64("id")
684
+	patient_id, _ := c.GetInt64("patient_id")
647
 	record_time := c.GetString("record_time")
685
 	record_time := c.GetString("record_time")
648
 	settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
686
 	settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
649
 	admin_user_id, _ := c.GetInt64("admin_user_id")
687
 	admin_user_id, _ := c.GetInt64("admin_user_id")
706
 		ids = append(ids, item.ID)
744
 		ids = append(ids, item.ID)
707
 	}
745
 	}
708
 
746
 
747
+	patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
748
+
749
+	adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
750
+
709
 	adminRole, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
751
 	adminRole, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
710
 	his, err := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
752
 	his, err := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
711
-	number := his.MzNumber
753
+	//number := his.MzNumber
754
+
712
 	mz_number := his.Number
755
 	mz_number := his.Number
713
 
756
 
757
+	number := miConfig.Code + year + month + day +
758
+		fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
759
+	//number := miConfig.Code + year + month + day + "1590003"
760
+
714
 	var doctor_name string
761
 	var doctor_name string
715
 	var doctor_code string
762
 	var doctor_code string
716
 
763
 
717
 	var drug_doctor_code string
764
 	var drug_doctor_code string
718
-	drug_doctor_code = "H24962918"
765
+	drug_doctor_code = adminRole_two.DoctorCode
766
+	drug_doctor_name := adminRole_two.UserName
719
 
767
 
720
 	if adminRole.ID == 0 {
768
 	if adminRole.ID == 0 {
721
 		doctor_name = "黄亦轩"
769
 		doctor_name = "黄亦轩"
725
 		doctor_code = strconv.FormatInt(admin_user_id, 10)
773
 		doctor_code = strconv.FormatInt(admin_user_id, 10)
726
 	}
774
 	}
727
 
775
 
728
-	//verifyCode, version_code := ReadCardGetCode("FY001" + "|" + number + "|" + miConfig.Code)
729
-	verifyCode := ""
730
-	version_code := ""
776
+	verifyCode, version_code := ReadCardGetCode("FY001" + "|" + number + "|" + miConfig.Code)
777
+	//verifyCode := "000000|bf885fa312a7f92861d6b61542a637fa"
778
+	//version_code := "V0.3"
731
 	var customs []*models.CustomDetail
779
 	var customs []*models.CustomDetail
732
 	for _, item := range prescriptions {
780
 	for _, item := range prescriptions {
781
+		fmt.Println("111111")
733
 		if item.Type == 1 { //药品
782
 		if item.Type == 1 { //药品
783
+			fmt.Println("222222")
734
 			for _, subItem := range item.HisDoctorAdviceInfo {
784
 			for _, subItem := range item.HisDoctorAdviceInfo {
785
+				fmt.Println(subItem.BaseDrugLib.MedicalInsuranceNumber)
786
+
735
 				if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
787
 				if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
788
+					fmt.Println("3333333")
789
+
736
 					_, dose_code := service.GetDoseCode(subItem.BaseDrugLib.DrugDosageForm, adminUser.CurrentOrgId)
790
 					_, dose_code := service.GetDoseCode(subItem.BaseDrugLib.DrugDosageForm, adminUser.CurrentOrgId)
737
 					detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber), 64)
791
 					detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber), 64)
738
 					price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
792
 					price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
749
 						DoctorCode:         doctor_code,
803
 						DoctorCode:         doctor_code,
750
 						Total:              detItemFeeSumamt,
804
 						Total:              detItemFeeSumamt,
751
 						DoseCode:           dose_code,
805
 						DoseCode:           dose_code,
752
-						Spec:               strconv.FormatFloat(subItem.DrugSpec, 'E', -1, 64) + subItem.DrugSpecUnit,
806
+						Spec:               subItem.BaseDrugLib.DrugSpec,
753
 					}
807
 					}
754
 					customs = append(customs, cus)
808
 					customs = append(customs, cus)
755
 				}
809
 				}
808
 		//}
862
 		//}
809
 	}
863
 	}
810
 
864
 
811
-	//c1 := &models.CustomDetail{
812
-	//	PrescriptionNumber: chrg_bchno,
813
-	//	OrderType:          "1",
814
-	//	ChargeSerialNumber: "202101130843076996-1-488",
815
-	//	Code:               "86901187000367",
816
-	//	CodeName:           "普瑞巴林胶囊",
817
-	//	Flag:               "1",
818
-	//	Price:              10.00,
819
-	//	Count:              10.00,
820
-	//	ChargeOrderDate:    year + month + day,
821
-	//	DoctorCode:         doctor_code,
822
-	//	Total:              100.00,
823
-	//	DoseCode:           "",
824
-	//	Spec:               strconv.FormatFloat(75.00, 'E', -1, 64) + "mg",
825
-	//}
826
-
827
 	var pagesize int = 50
865
 	var pagesize int = 50
828
 	var start int = 1
866
 	var start int = 1
829
 	var stop int
867
 	var stop int
879
 				Stage:      10,
917
 				Stage:      10,
880
 			}
918
 			}
881
 			service.CreateErrMsgLog(errlog)
919
 			service.CreateErrMsgLog(errlog)
882
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreSettleFaildParamWrong)
920
+
921
+			c.ServeSuccessJSON(map[string]interface{}{
922
+				"failed_code": -10,
923
+				"msg":         res.Transreturnmessage,
924
+			})
925
+
926
+			//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreSettleFaildParamWrong)
883
 			return
927
 			return
884
 		}
928
 		}
885
 		//设置变量,根据变量的值来判断上传是否成功
929
 		//设置变量,根据变量的值来判断上传是否成功
886
 	}
930
 	}
887
 
931
 
888
 	if isSuccess == true {
932
 	if isSuccess == true {
933
+
889
 		order := &models.HisOrder{
934
 		order := &models.HisOrder{
890
 			UserOrgId:           adminUser.CurrentOrgId,
935
 			UserOrgId:           adminUser.CurrentOrgId,
891
 			HisPatientId:        0,
936
 			HisPatientId:        0,
908
 			SettleEndTime:       end_time,
953
 			SettleEndTime:       end_time,
909
 			Creator:             admin_user_id,
954
 			Creator:             admin_user_id,
910
 			Modify:              admin_user_id,
955
 			Modify:              admin_user_id,
956
+			OrgSetlNumber:       number,
911
 		}
957
 		}
958
+		data, _ := json.Marshal(ress)
959
+		order.DetailLog = string(data)
960
+
912
 		err = service.CreateOrder(order)
961
 		err = service.CreateOrder(order)
913
 		if err != nil {
962
 		if err != nil {
914
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
963
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
979
 				total = total + (subItem.Price * float64(subItem.Count))
1028
 				total = total + (subItem.Price * float64(subItem.Count))
980
 			}
1029
 			}
981
 		}
1030
 		}
982
-		//verifyCode, version_code := ReadCardGetCode("FY004" + "|" + number + "|" + miConfig.Code)
983
-		verifyCode := ""
984
-		version_code := ""
985
-		result_two := service.SzybFY004(doctor_name, doctor_code, miConfig.Code, total, verifyCode, number, mz_number, version_code)
1031
+		verifyCode, version_code := ReadCardGetCode("FY004" + "|" + number + "|" + miConfig.Code)
1032
+		//verifyCode := "000000|08728e77da60a4857803af17aba9caae"
1033
+		//version_code := "V0.3"
1034
+		result_two := service.SzybFY004(doctor_name, doctor_code, miConfig.Code, total, verifyCode, number, mz_number, version_code, drug_doctor_code, drug_doctor_name)
986
 		var dat map[string]interface{}
1035
 		var dat map[string]interface{}
987
 		if err := json.Unmarshal([]byte(result_two), &dat); err == nil {
1036
 		if err := json.Unmarshal([]byte(result_two), &dat); err == nil {
988
 			fmt.Println(dat)
1037
 			fmt.Println(dat)
1001
 				"msg": "预结算成功",
1050
 				"msg": "预结算成功",
1002
 			})
1051
 			})
1003
 		} else {
1052
 		} else {
1004
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreSettleFaildParamWrong)
1053
+
1054
+			c.ServeSuccessJSON(map[string]interface{}{
1055
+				"failed_code": -10,
1056
+				"msg":         res.Transreturnmessage,
1057
+			})
1058
+			//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreSettleFaildParamWrong)
1005
 			return
1059
 			return
1006
 		}
1060
 		}
1007
 	} else {
1061
 	} else {
1096
 				}
1150
 				}
1097
 			}
1151
 			}
1098
 
1152
 
1153
+			patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
1154
+
1155
+			adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
1156
+
1157
+			var drug_doctor string
1158
+			drug_doctor = adminRole_two.DoctorCode
1159
+			drug_doctor_name := adminRole_two.UserName
1099
 			//结算流程
1160
 			//结算流程
1100
 			var doctor_name string
1161
 			var doctor_name string
1101
 			var doctor_code string
1162
 			var doctor_code string
1102
 			if roles.ID == 0 {
1163
 			if roles.ID == 0 {
1103
 				doctor_name = "黄亦轩"
1164
 				doctor_name = "黄亦轩"
1104
-				doctor_code = "H24962918"
1165
+				doctor_code = "1010"
1105
 			} else {
1166
 			} else {
1106
 				doctor_name = roles.UserName
1167
 				doctor_name = roles.UserName
1107
 				doctor_code = strconv.FormatInt(admin_user_id, 10)
1168
 				doctor_code = strconv.FormatInt(admin_user_id, 10)
1108
 			}
1169
 			}
1109
-			number := his.MzNumber
1170
+			number := order_src.OrgSetlNumber
1110
 			mz_number := his.Number
1171
 			mz_number := his.Number
1111
-			//verifyCode, version_code := ReadCardGetCode("FY005" + "|" + number + "|" + miConfig.Code)
1172
+			verifyCode, version_code := ReadCardGetCode("FY005" + "|" + number + "|" + miConfig.Code)
1112
 
1173
 
1113
-			verifyCode := ""
1114
-			version_code := ""
1115
-			//verifyCode := "000000|eb7acc3ec61eb5e3fd12a3586ad3a9c5"
1116
-			//version_code := "0.03"
1174
+			//verifyCode := "000000|707c35a62c2f0609d7b0a811649f3913"
1175
+			//version_code := "V0.3"
1117
 			//yiliao_number, id_card_number,verifyCode,versionCode, err, ret4 := ReadBasCardGetNumber("FY005" + "|" + number + "|" + miConfig.Code)
1176
 			//yiliao_number, id_card_number,verifyCode,versionCode, err, ret4 := ReadBasCardGetNumber("FY005" + "|" + number + "|" + miConfig.Code)
1118
 			yiliao_number := his.YiliaoNumber
1177
 			yiliao_number := his.YiliaoNumber
1119
-			result_three := service.SzybFY005(doctor_name, doctor_code, miConfig.Code, total, yiliao_number, verifyCode, number, mz_number, version_code)
1178
+			result_three := service.SzybFY005(doctor_name, doctor_code, miConfig.Code, total, yiliao_number, verifyCode, number, mz_number, version_code, drug_doctor, drug_doctor_name)
1120
 			var dat map[string]interface{}
1179
 			var dat map[string]interface{}
1121
 			if err := json.Unmarshal([]byte(result_three), &dat); err == nil {
1180
 			if err := json.Unmarshal([]byte(result_three), &dat); err == nil {
1122
 				fmt.Println(dat)
1181
 				fmt.Println(dat)
1151
 				order_src.PsnCashPay = res.Transbody.Akb067
1210
 				order_src.PsnCashPay = res.Transbody.Akb067
1152
 				order_src.PsnPartAmt = res.Transbody.Akb067
1211
 				order_src.PsnPartAmt = res.Transbody.Akb067
1153
 				order_src.AccountPrice = res.Transbody.Aae240
1212
 				order_src.AccountPrice = res.Transbody.Aae240
1154
-				order_src.OrgSetlNumber = number
1155
 				order_src.MzNumber = mz_number
1213
 				order_src.MzNumber = mz_number
1156
 				order_src.YiliaoNumber = yiliao_number
1214
 				order_src.YiliaoNumber = yiliao_number
1157
 				setlDetailOne, _ := json.Marshal(res.Transbody.Outputlist1)
1215
 				setlDetailOne, _ := json.Marshal(res.Transbody.Outputlist1)
1163
 				setlDetailThree, _ := json.Marshal(res.Transbody.Outputlist3)
1221
 				setlDetailThree, _ := json.Marshal(res.Transbody.Outputlist3)
1164
 				detailStrThree := string(setlDetailThree)
1222
 				detailStrThree := string(setlDetailThree)
1165
 				order_src.SzMedicineInsuranceInfo = detailStrThree
1223
 				order_src.SzMedicineInsuranceInfo = detailStrThree
1224
+				order_src.Cainfo = result_three
1225
+
1166
 				err = service.UpdataOrderStatusTwo(order_src.Number, adminUser.CurrentOrgId)
1226
 				err = service.UpdataOrderStatusTwo(order_src.Number, adminUser.CurrentOrgId)
1167
 				err = service.UpDateOrder(order_src)
1227
 				err = service.UpDateOrder(order_src)
1228
+
1168
 				c.ServeSuccessJSON(map[string]interface{}{
1229
 				c.ServeSuccessJSON(map[string]interface{}{
1169
 					"msg": "结算成功",
1230
 					"msg": "结算成功",
1170
 				})
1231
 				})
1171
 			} else {
1232
 			} else {
1233
+				//version_code := "0.03"
1234
+				c.ServeSuccessJSON(map[string]interface{}{
1235
+					"failed_code": -10,
1236
+					"msg":         res.Transreturnmessage,
1237
+				})
1172
 
1238
 
1173
 			}
1239
 			}
1174
 		} else {
1240
 		} else {
1185
 //当月退费
1251
 //当月退费
1186
 func (c *SZHisApiController) Refund() {
1252
 func (c *SZHisApiController) Refund() {
1187
 	order_id, _ := c.GetInt64("order_id")
1253
 	order_id, _ := c.GetInt64("order_id")
1188
-	//record_time := c.GetString("record_time")
1189
-	//patient_id, _ := c.GetInt64("patient_id")
1254
+	record_time := c.GetString("record_time")
1255
+	patient_id, _ := c.GetInt64("patient_id")
1190
 	admin_user_id, _ := c.GetInt64("admin_user_id")
1256
 	admin_user_id, _ := c.GetInt64("admin_user_id")
1191
-	//timeLayout := "2006-01-02"
1192
-	//loc, _ := time.LoadLocation("Local")
1257
+	timeLayout := "2006-01-02"
1258
+	loc, _ := time.LoadLocation("Local")
1193
 	adminUser := c.GetAdminUserInfo()
1259
 	adminUser := c.GetAdminUserInfo()
1194
-	//theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
1195
-	//fmt.Println(err)
1196
-	//if err != nil {
1197
-	//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1198
-	//	return
1199
-	//}
1200
-	//recordDateTime := theTime.Unix()
1260
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
1261
+	fmt.Println(err)
1262
+	if err != nil {
1263
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1264
+		return
1265
+	}
1266
+	recordDateTime := theTime.Unix()
1267
+	fmt.Println(recordDateTime)
1201
 	var order models.HisOrder
1268
 	var order models.HisOrder
1202
 	order, _ = service.GetHisOrderByID(order_id)
1269
 	order, _ = service.GetHisOrderByID(order_id)
1203
 	if order.ID == 0 {
1270
 	if order.ID == 0 {
1204
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
1271
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
1205
 		return
1272
 		return
1206
 	}
1273
 	}
1207
-
1274
+	his, _ := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, theTime.Unix())
1208
 	roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
1275
 	roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
1209
 	miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
1276
 	miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
1210
 	//结算流程
1277
 	//结算流程
1218
 		doctor_code = strconv.FormatInt(admin_user_id, 10)
1285
 		doctor_code = strconv.FormatInt(admin_user_id, 10)
1219
 
1286
 
1220
 	}
1287
 	}
1221
-	//month := time.Unix(1557042972, 0).Format("1")
1222
-	//year := time.Now().Format("2006")
1223
-	//month = time.Now().Format("01")
1224
-	//day := time.Now().Format("02")
1288
+	month := time.Unix(1557042972, 0).Format("1")
1289
+	year := time.Now().Format("2006")
1290
+	month = time.Now().Format("01")
1291
+	day := time.Now().Format("02")
1292
+	//number := miConfig.Code  + year + month + day + "1367866"
1293
+	number := miConfig.Code + year + month + day +
1294
+		fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
1295
+	//number := miConfig.Code + year + month + day + "1590003"
1296
+
1225
 	//流水号
1297
 	//流水号
1226
 	//number_two := miConfig.Code + "-" + year + month + day + "-" + strconv.FormatInt(patient_id, 10)
1298
 	//number_two := miConfig.Code + "-" + year + month + day + "-" + strconv.FormatInt(patient_id, 10)
1227
-	//verifyCode,version_code := ReadCardGetCode("JY002" + "|" + number_two + "|" + miConfig.Code)
1228
-	version_code := "0.03"
1229
-
1230
-	verifyCode := "000000|9703b55d0862204b631e43fa922394b5"
1299
+	verifyCode, version_code := ReadCardGetCode("JY002" + "|" + number + "|" + miConfig.Code)
1300
+	//version_code := "V0.3"
1301
+	//
1302
+	//verifyCode := "000000|9972fca7ba9471c7dbe08324b2e31f70"
1231
 	config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
1303
 	config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
1232
 	if config.IsOpen == 1 { //对接了医保,走医保流程
1304
 	if config.IsOpen == 1 { //对接了医保,走医保流程
1233
 
1305
 
1234
-		result := service.SzybJY002(doctor_name, doctor_code, miConfig.Code, order.OrgSetlNumber, order.MzNumber, verifyCode, "", version_code)
1306
+		result := service.SzybJY002(doctor_name, doctor_code, miConfig.Code, order.OrgSetlNumber, order.MzNumber, verifyCode, number, version_code)
1235
 		fmt.Println(result)
1307
 		fmt.Println(result)
1236
 
1308
 
1237
 		var dat map[string]interface{}
1309
 		var dat map[string]interface{}
1248
 			return
1320
 			return
1249
 		}
1321
 		}
1250
 		if res.Transreturncode == "00000000" {
1322
 		if res.Transreturncode == "00000000" {
1323
+			service.UpdataOrderlog(order_id, adminUser.CurrentOrgId, result)
1324
+			service.UpdataOrderStatusSZ(order_id, order.Number, adminUser.CurrentOrgId, his.MzNumber, his.Number)
1251
 			c.ServeSuccessJSON(map[string]interface{}{
1325
 			c.ServeSuccessJSON(map[string]interface{}{
1252
 				"msg": "退费成功",
1326
 				"msg": "退费成功",
1253
 			})
1327
 			})
1254
 		} else {
1328
 		} else {
1329
+			c.ServeSuccessJSON(map[string]interface{}{
1330
+				"failed_code": -10,
1331
+				"msg":         res.Transreturnmessage,
1332
+			})
1333
+
1255
 		}
1334
 		}
1256
 	}
1335
 	}
1257
 }
1336
 }
1375
 	//流水号
1454
 	//流水号
1376
 	//number_two := miConfig.Code + "-" + year + month + day + "-" + strconv.FormatInt(patient_id, 10)
1455
 	//number_two := miConfig.Code + "-" + year + month + day + "-" + strconv.FormatInt(patient_id, 10)
1377
 	//fmt.Println(number_two)
1456
 	//fmt.Println(number_two)
1378
-	//verifyCode,version_code := ReadCardGetCode("JY001" + "|" + number_two + "|" + miConfig.Code)
1379
-	version_code := "0.03"
1380
-	verifyCode := "000000|31b7646eda5bcbf5f5ef5e82d368a0e1"
1457
+	verifyCode, version_code := ReadCardGetCode("JY001" + "|" + order.OrgSetlNumber + "|" + miConfig.Code)
1458
+	//version_code := "V0.3"
1459
+	//verifyCode := "000000|2c9854287e7c3cbc34439ab8e5157816"
1381
 	config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
1460
 	config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
1382
 	if config.IsOpen == 1 { //对接了医保,走医保流程
1461
 	if config.IsOpen == 1 { //对接了医保,走医保流程
1383
 
1462
 
1400
 		if res.Transreturncode == "00000000" {
1479
 		if res.Transreturncode == "00000000" {
1401
 			c.ServeSuccessJSON(map[string]interface{}{})
1480
 			c.ServeSuccessJSON(map[string]interface{}{})
1402
 		} else {
1481
 		} else {
1482
+			c.ServeSuccessJSON(map[string]interface{}{
1483
+				"failed_code": -10,
1484
+				"msg":         res.Transreturnmessage,
1485
+			})
1403
 		}
1486
 		}
1404
 	}
1487
 	}
1405
 }
1488
 }
1406
 
1489
 
1490
+//费用录入取消
1491
+func (c *SZHisApiController) CancelOrderDetail() {
1492
+	order_id, _ := c.GetInt64("order_id")
1493
+	record_time := c.GetString("record_time")
1494
+	patient_id, _ := c.GetInt64("patient_id")
1495
+	admin_user_id, _ := c.GetInt64("admin_user_id")
1496
+	timeLayout := "2006-01-02"
1497
+	loc, _ := time.LoadLocation("Local")
1498
+	adminUser := c.GetAdminUserInfo()
1499
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
1500
+	fmt.Println(err)
1501
+	if err != nil {
1502
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1503
+		return
1504
+	}
1505
+	recordDateTime := theTime.Unix()
1506
+	var order models.HisOrder
1507
+	order, _ = service.GetHisOrderByID(order_id)
1508
+
1509
+	if order.ID == 0 {
1510
+		order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
1511
+
1512
+	}
1513
+
1514
+	order_infos, _ := service.GetHisOrderInfoByNumber(order.Number)
1515
+
1516
+	roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
1517
+	miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
1518
+	//结算流程
1519
+	var doctor_name string
1520
+	var doctor_code string
1521
+	if roles.ID == 0 {
1522
+		doctor_name = "黄亦轩"
1523
+		doctor_code = "1001"
1524
+	} else {
1525
+		doctor_name = roles.UserName
1526
+		doctor_code = strconv.FormatInt(admin_user_id, 10)
1527
+
1528
+	}
1529
+	var customs []*models.CustomDetail
1530
+
1531
+	for _, item := range order_infos {
1532
+		cus := &models.CustomDetail{
1533
+			PrescriptionNumber: item.OrderNumber,
1534
+			ChargeSerialNumber: item.FeedetlSn,
1535
+		}
1536
+		customs = append(customs, cus)
1537
+	}
1538
+
1539
+	verifyCode, version_code := ReadCardGetCode("FY002" + "|" + order.OrgSetlNumber + "|" + miConfig.Code)
1540
+
1541
+	var pagesize int = 50
1542
+	var start int = 1
1543
+	var stop int
1544
+	var pagecount int
1545
+	var curpage int
1546
+	var isSuccess bool = true
1547
+	var ress []*ResultFive
1548
+
1549
+	//总页数,向上取整,注意除之前要先转换类型为float64
1550
+	pagecount = int(math.Ceil(float64(len(customs)) / float64(pagesize)))
1551
+
1552
+	for curpage = 1; curpage <= pagecount; curpage++ {
1553
+		if curpage == 1 {
1554
+			start = 1
1555
+		} else {
1556
+			start = (curpage-1)*pagesize + 1
1557
+		}
1558
+		stop = curpage * pagesize
1559
+		if stop > len(customs) {
1560
+			stop = len(customs)
1561
+		}
1562
+
1563
+		result := service.SzybFY002(doctor_name, doctor_code, miConfig.Code, customs[start-1:stop], verifyCode, order.OrgSetlNumber, order.MzNumber, version_code)
1564
+		fmt.Println(result)
1565
+
1566
+		var dat map[string]interface{}
1567
+		if err := json.Unmarshal([]byte(result), &dat); err == nil {
1568
+			fmt.Println(dat)
1569
+		} else {
1570
+			fmt.Println(err)
1571
+		}
1572
+		userJSONBytes, _ := json.Marshal(dat)
1573
+		var res ResultFive
1574
+		if err := json.Unmarshal(userJSONBytes, &res); err != nil {
1575
+			utils.ErrorLog("解析失败:%v", err)
1576
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1577
+			return
1578
+		}
1579
+		if res.Transreturncode == "00000000" {
1580
+			ress = append(ress, &res)
1581
+		} else {
1582
+			isSuccess = false
1583
+			//预结算报错
1584
+			errlog := &models.HisOrderError{
1585
+				UserOrgId:  adminUser.CurrentOrgId,
1586
+				Ctime:      time.Now().Unix(),
1587
+				Mtime:      time.Now().Unix(),
1588
+				ErrMsg:     res.Transreturnmessage,
1589
+				Status:     1,
1590
+				PatientId:  patient_id,
1591
+				RecordTime: recordDateTime,
1592
+				Stage:      11,
1593
+			}
1594
+			service.CreateErrMsgLog(errlog)
1595
+
1596
+			c.ServeSuccessJSON(map[string]interface{}{
1597
+				"faild_code": -10,
1598
+				"msg":        res.Transreturnmessage,
1599
+			})
1600
+			return
1601
+		}
1602
+	}
1603
+	if isSuccess == true {
1604
+		c.ServeSuccessJSON(map[string]interface{}{
1605
+			"msg": "撤销成功",
1606
+		})
1607
+	}
1608
+}
1609
+
1407
 //获取verifyCode
1610
 //获取verifyCode
1408
-//func ReadCardGetCode(request string) (string, string) {
1409
-//	DllDef2 := syscall.MustLoadDLL("SSSE32.dll")
1410
-//	readCards := DllDef2.MustFindProc("iVerifyCode")
1411
-//	str := request
1412
-//	str3 := make([]byte, 256)
1413
-//	ret4, _, _ := readCards.Call(StrPtr(str), (uintptr)(unsafe.Pointer(&str3[0])))
1414
-//	fmt.Println(":", string(str3))
1415
-//
1416
-//	if ret4 == 0 {
1417
-//		result := string(str3)
1418
-//		fmt.Println(result)
1419
-//		result_arr := strings.Split(result, "|")
1420
-//		verifyCode := result_arr[0] + "|" + result_arr[1]
1421
-//		versionCode := result_arr[2]
1422
-//
1423
-//		return verifyCode, versionCode
1424
-//
1425
-//	}
1426
-//	return "", ""
1427
-//}
1611
+func ReadCardGetCode(request string) (string, string) {
1612
+	request = request + "|"
1613
+	DllDef2 := syscall.MustLoadDLL("SSCardDriver_SZ.dll")
1614
+	readCards := DllDef2.MustFindProc("iVerifyCode")
1615
+	str := request
1616
+	str3 := make([]byte, 256)
1617
+	ret4, _, _ := readCards.Call(StrPtr(str), (uintptr)(unsafe.Pointer(&str3[0])))
1618
+	fmt.Println(":", string(str3))
1619
+
1620
+	//fmt.Println(":",ConvertByte2String(str3,GB18030) )
1621
+
1622
+	if ret4 == 0 {
1623
+		result := string(str3)
1624
+		fmt.Println(result)
1625
+		result_arr := strings.Split(result, "|")
1626
+		verifyCode := result_arr[0] + "|" + result_arr[1]
1627
+		versionCode := result_arr[2]
1628
+
1629
+		return verifyCode, versionCode
1630
+
1631
+	}
1632
+	return "", ""
1633
+}
1428
 
1634
 
1429
 //
1635
 //
1430
 ////读卡
1636
 ////读卡
2165
 
2371
 
2166
 	}
2372
 	}
2167
 }
2373
 }
2374
+
2375
+//type Charset string
2376
+
2377
+//const (
2378
+//	UTF8    = Charset("UTF-8")
2379
+//	GB18030 = Charset("GB18030")
2380
+//)
2381
+//func ConvertByte2String(byte []byte, charset Charset) string {
2382
+//
2383
+//	var str string
2384
+//	switch charset {
2385
+//	case GB18030:
2386
+//		decodeBytes, _ := simplifiedchinese.GB18030.NewDecoder().Bytes(byte)
2387
+//		str = string(decodeBytes)
2388
+//	case UTF8:
2389
+//		fallthrough
2390
+//	default:
2391
+//		str = string(byte)
2392
+//	}
2393
+//
2394
+//	return str
2395
+//}

+ 3 - 0
models/his_models.go Ver fichero

668
 	SettleStartTime int64 `gorm:"column:settle_start_time" json:"settle_start_time" form:"settle_start_time"`
668
 	SettleStartTime int64 `gorm:"column:settle_start_time" json:"settle_start_time" form:"settle_start_time"`
669
 	SettleEndTime   int64 `gorm:"column:settle_end_time" json:"settle_end_time" form:"settle_end_time"`
669
 	SettleEndTime   int64 `gorm:"column:settle_end_time" json:"settle_end_time" form:"settle_end_time"`
670
 
670
 
671
+	RefundLog string `gorm:"column:refund_log" json:"refund_log" form:"refund_log"`
672
+	DetailLog string `gorm:"column:detail_log" json:"detail_log" form:"detail_log"`
673
+
671
 	HisOrderInfo        HisOrderInfo        `gorm:"ForeignKey:ID;AssociationForeignKey:OrderId" json:"order_info"`
674
 	HisOrderInfo        HisOrderInfo        `gorm:"ForeignKey:ID;AssociationForeignKey:OrderId" json:"order_info"`
672
 	Patients            Patients            `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
675
 	Patients            Patients            `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
673
 	HisPatient          HisPatient          `gorm:"ForeignKey:HisPatientId;AssociationForeignKey:ID" json:"his_patient"`
676
 	HisPatient          HisPatient          `gorm:"ForeignKey:HisPatientId;AssociationForeignKey:ID" json:"his_patient"`

+ 49 - 16
models/patient_models.go Ver fichero

313
 }
313
 }
314
 
314
 
315
 type UserAdminRole struct {
315
 type UserAdminRole struct {
316
-	ID              int64           `gorm:"column:id" json:"id"`
317
-	AdminUserId     int64           `gorm:"column:admin_user_id" json:"admin_user_id"`
318
-	OrgId           int64           `gorm:"column:org_id" json:"org_id"`
319
-	AppId           int64           `gorm:"column:app_id" json:"app_id"`
320
-	RoleId          int64           `gorm:"column:role_id" json:"role_id"`
321
-	UserName        string          `gorm:"column:user_name" json:"user_name"`
322
-	Avatar          string          `gorm:"column:avatar" json:"avatar"`
323
-	UserType        int64           `gorm:"column:user_type" json:"user_type"`
324
-	UserTitle       int64           `gorm:"column:user_title" json:"user_title"`
325
-	Intro           string          `gorm:"column:intro" json:"intro"`
326
-	Status          int64           `gorm:"column:status" json:"status"`
327
-	Ctime           int64           `gorm:"column:ctime" json:"ctime"`
328
-	Mtime           int64           `gorm:"column:mtime" json:"mtime"`
329
-	Department      string          `gorm:"column:department" json:"department"`
330
-	DepartmentId    int64           `gorm:"column:department_id" json:"department_id"`
331
-	XtHisDepartment XtHisDepartment `json:"department" gorm:"foreignkey:DepartmentId;AssociationForeignKey:ID;"`
316
+	ID                                      int64           `gorm:"column:id" json:"id" form:"id"`
317
+	AdminUserId                             int64           `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
318
+	OrgId                                   int64           `gorm:"column:org_id" json:"org_id" form:"org_id"`
319
+	AppId                                   int64           `gorm:"column:app_id" json:"app_id" form:"app_id"`
320
+	RoleId                                  int64           `gorm:"column:role_id" json:"role_id" form:"role_id"`
321
+	UserName                                string          `gorm:"column:user_name" json:"user_name" form:"user_name"`
322
+	Avatar                                  string          `gorm:"column:avatar" json:"avatar" form:"avatar"`
323
+	UserType                                int64           `gorm:"column:user_type" json:"user_type" form:"user_type"`
324
+	UserTitle                               int64           `gorm:"column:user_title" json:"user_title" form:"user_title"`
325
+	Intro                                   string          `gorm:"column:intro" json:"intro" form:"intro"`
326
+	Status                                  int64           `gorm:"column:status" json:"status" form:"status"`
327
+	Ctime                                   int64           `gorm:"column:ctime" json:"ctime" form:"ctime"`
328
+	Mtime                                   int64           `gorm:"column:mtime" json:"mtime" form:"mtime"`
329
+	UserTitleName                           string          `gorm:"column:user_title_name" json:"user_title_name" form:"user_title_name"`
330
+	RoleIds                                 string          `gorm:"column:role_ids" json:"role_ids" form:"role_ids"`
331
+	Message                                 string          `gorm:"column:message" json:"message" form:"message"`
332
+	Sex                                     int64           `gorm:"column:sex" json:"sex" form:"sex"`
333
+	Birthday                                int64           `gorm:"column:birthday" json:"birthday" form:"birthday"`
334
+	Sort                                    int64           `gorm:"column:sort" json:"sort" form:"sort"`
335
+	IsSort                                  int64           `gorm:"column:is_sort" json:"is_sort" form:"is_sort"`
336
+	Department                              string          `gorm:"column:department" json:"department" form:"department"`
337
+	DepartmentId                            int64           `gorm:"column:department_id" json:"department_id" form:"department_id"`
338
+	Age                                     int64           `gorm:"column:age" json:"age" form:"age"`
339
+	Nation                                  string          `gorm:"column:nation" json:"nation" form:"nation"`
340
+	CardType                                int64           `gorm:"column:card_type" json:"card_type" form:"card_type"`
341
+	IdCard                                  string          `gorm:"column:id_card" json:"id_card" form:"id_card"`
342
+	Education                               int64           `gorm:"column:education" json:"education" form:"education"`
343
+	StudyMajorName                          string          `gorm:"column:study_major_name" json:"study_major_name" form:"study_major_name"`
344
+	WorkMajorName                           string          `gorm:"column:work_major_name" json:"work_major_name" form:"work_major_name"`
345
+	RoleType                                int64           `gorm:"column:role_type" json:"role_type" form:"role_type"`
346
+	MedicalCode                             string          `gorm:"column:medical_code" json:"medical_code" form:"medical_code"`
347
+	DoctorCode                              string          `gorm:"column:doctor_code" json:"doctor_code" form:"doctor_code"`
348
+	Licensing                               int64           `gorm:"column:licensing" json:"licensing" form:"licensing"`
349
+	JobNumber                               string          `gorm:"column:job_number" json:"job_number" form:"job_number"`
350
+	PrescriptionQualificationIdentification int64           `gorm:"column:prescription_qualification_identification" json:"prescription_qualification_identification" form:"prescription_qualification_identification"`
351
+	IdentificationOutpatients               int64           `gorm:"column:identification_outpatients" json:"identification_outpatients" form:"identification_outpatients"`
352
+	StartTime                               int64           `gorm:"column:start_time" json:"start_time" form:"start_time"`
353
+	MedicalRangeCode                        int64           `gorm:"column:medical_range_code" json:"medical_range_code" form:"medical_range_code"`
354
+	MedicalLevel                            int64           `gorm:"column:medical_level" json:"medical_level" form:"medical_level"`
355
+	MedicalTypeJob                          int64           `gorm:"column:medical_type_job" json:"medical_type_job" form:"medical_type_job"`
356
+	PharmacistRegistrationNumber            string          `gorm:"column:pharmacist_registration_number" json:"pharmacist_registration_number" form:"pharmacist_registration_number"`
357
+	DoctorRangeCode                         int64           `gorm:"column:doctor_range_code" json:"doctor_range_code" form:"doctor_range_code"`
358
+	DoctorLevel                             int64           `gorm:"column:doctor_level" json:"doctor_level" form:"doctor_level"`
359
+	DoctorTypeJob                           int64           `gorm:"column:doctor_type_job" json:"doctor_type_job" form:"doctor_type_job"`
360
+	DoctorNumber                            string          `gorm:"column:doctor_number" json:"doctor_number" form:"doctor_number"`
361
+	OutpatientIllnessCategory               string          `gorm:"column:outpatient_illness_category" json:"outpatient_illness_category" form:"outpatient_illness_category"`
362
+	IsActive                                int64           `gorm:"column:is_active" json:"is_active" form:"is_active"`
363
+	ActiveStatus                            int64           `gorm:"column:active_status" json:"active_status" form:"active_status"`
364
+	XtHisDepartment                         XtHisDepartment `json:"department" gorm:"foreignkey:DepartmentId;AssociationForeignKey:ID;"`
332
 }
365
 }
333
 
366
 
334
 func (UserAdminRole) TableName() string {
367
 func (UserAdminRole) TableName() string {

+ 25 - 8
service/sz_his_service.go Ver fichero

148
 		feedetailInfo["bkm017"] = item.Code
148
 		feedetailInfo["bkm017"] = item.Code
149
 		feedetailInfo["aka070"] = item.DoseCode
149
 		feedetailInfo["aka070"] = item.DoseCode
150
 		feedetailInfo["aka074"] = item.Spec
150
 		feedetailInfo["aka074"] = item.Spec
151
-		feedetailInfo["aka064"] = 0
151
+		feedetailInfo["aka064"] = 1
152
 		feedetailInfo["ake005"] = item.Code
152
 		feedetailInfo["ake005"] = item.Code
153
 		feedetailInfo["ake006"] = item.CodeName
153
 		feedetailInfo["ake006"] = item.CodeName
154
 		feedetailInfo["akc225"] = item.Price
154
 		feedetailInfo["akc225"] = item.Price
251
 	str := string(respBytes)
251
 	str := string(respBytes)
252
 	return str
252
 	return str
253
 }
253
 }
254
-func SzybFY004(doctor string, doctor_code string, fixmedins_code string, total float64, verify_code string, serial_number string, mz_number string, version_code string) string {
254
+func SzybFY004(doctor string, doctor_code string, fixmedins_code string, total float64, verify_code string, serial_number string, mz_number string, version_code string, drug_doctor_code string, drug_doctor_name string) string {
255
 	// 生成输入报文
255
 	// 生成输入报文
256
 	inputMessage := SetSZInputMessage(doctor, doctor_code, fixmedins_code, verify_code, serial_number)
256
 	inputMessage := SetSZInputMessage(doctor, doctor_code, fixmedins_code, verify_code, serial_number)
257
 	inputData := make(map[string]interface{})
257
 	inputData := make(map[string]interface{})
260
 
260
 
261
 	inputData["akc190"] = mz_number
261
 	inputData["akc190"] = mz_number
262
 	inputData["aka130"] = "11"
262
 	inputData["aka130"] = "11"
263
-	inputData["bkc320"] = doctor_code
264
-	inputData["ckc350"] = doctor
263
+	inputData["bkc320"] = drug_doctor_code
264
+	inputData["ckc350"] = drug_doctor_name
265
 	inputData["aka030"] = "12"
265
 	inputData["aka030"] = "12"
266
 	inputData["akc264"] = total
266
 	inputData["akc264"] = total
267
 	inputData["ckc601"] = "0"
267
 	inputData["ckc601"] = "0"
300
 	str := string(respBytes)
300
 	str := string(respBytes)
301
 	return str
301
 	return str
302
 }
302
 }
303
-func SzybFY005(doctor string, doctor_code string, fixmedins_code string, total float64, account string, verify_code string, serial_number string, mz_number string, version_code string) string {
303
+func SzybFY005(doctor string, doctor_code string, fixmedins_code string, total float64, account string, verify_code string, serial_number string, mz_number string, version_code string, drug_doctor string, drug_doctor_name string) string {
304
 	// 生成输入报文
304
 	// 生成输入报文
305
 	inputMessage := SetSZInputMessage(doctor, doctor_code, fixmedins_code, verify_code, serial_number)
305
 	inputMessage := SetSZInputMessage(doctor, doctor_code, fixmedins_code, verify_code, serial_number)
306
 	inputData := make(map[string]interface{})
306
 	inputData := make(map[string]interface{})
312
 	inputData["bzz269"] = "000000"
312
 	inputData["bzz269"] = "000000"
313
 	inputData["akc190"] = mz_number
313
 	inputData["akc190"] = mz_number
314
 	inputData["aka130"] = "11"
314
 	inputData["aka130"] = "11"
315
-	inputData["bkc320"] = doctor_code
316
-	inputData["ckc350"] = doctor
315
+	inputData["bkc320"] = drug_doctor
316
+	inputData["ckc350"] = drug_doctor_name
317
 	inputData["aka030"] = "12"
317
 	inputData["aka030"] = "12"
318
 	inputData["akc264"] = total
318
 	inputData["akc264"] = total
319
 	inputData["ckc601"] = "0"
319
 	inputData["ckc601"] = "0"
994
 
994
 
995
 func GetDoseCode(dose_id int64, user_org_id int64) (error, string) {
995
 func GetDoseCode(dose_id int64, user_org_id int64) (error, string) {
996
 	var data models.DictDataconfig
996
 	var data models.DictDataconfig
997
-	err := readDb.Model(&models.DictDataconfig{}).Where(" (user_org_id = ? Or user_org_id = 0) AND parent_id = 4 AND module = 'system' AND status = 1 AND value = ?", user_org_id, dose_id).First(&data).Error
997
+	err := readDb.Model(&models.DictDataconfig{}).Where(" (org_id = ? Or org_id = 0) AND parent_id = 4 AND module = 'system' AND status = 1 AND value = ?", user_org_id, dose_id).First(&data).Error
998
 	return err, data.Code
998
 	return err, data.Code
999
 }
999
 }
1000
+
1001
+func UpdataOrderStatusSZ(id int64, number string, user_org_id int64, his_mz_number string, his_number string) (err error) {
1002
+	err = writeDb.Model(&models.HisOrder{}).Where("status = 1 AND id = ? AND user_org_id = ?", id, user_org_id).Updates(map[string]interface{}{"order_status": 3, "mtime": time.Now().Unix(), "status": 0}).Error
1003
+	err = writeDb.Model(&models.HisPrescription{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"order_status": 1, "mtime": time.Now().Unix()}).Error
1004
+	err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"prescription_status": 1, "mtime": time.Now().Unix()}).Error
1005
+	err = writeDb.Model(&models.HisPatient{}).Where("status = 1 AND user_org_id = ? AND mz_number = ? AND number = ?", user_org_id, his_mz_number, his_number).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
1006
+
1007
+	return
1008
+
1009
+}
1010
+
1011
+func UpdataOrderlog(id int64, user_org_id int64, refund_log string) (err error) {
1012
+	err = writeDb.Model(&models.HisOrder{}).Where("status = 1 AND id = ? AND user_org_id = ?", id, user_org_id).Updates(map[string]interface{}{"order_status": 3, "mtime": time.Now().Unix(), "status": 0, "refund_log": refund_log}).Error
1013
+
1014
+	return
1015
+
1016
+}