test_user 4 months ago
parent
commit
aad0ab6639

+ 153 - 45
controllers/sg/his_api_controller.go View File

14
 	"fmt"
14
 	"fmt"
15
 	//"github.com/tjfoc/gmsm/sm2"
15
 	//"github.com/tjfoc/gmsm/sm2"
16
 	//"github.com/tjfoc/gmsm/sm3"
16
 	//"github.com/tjfoc/gmsm/sm3"
17
-
17
+	"github.com/go-ole/go-ole"
18
 	"gdyb/controllers"
18
 	"gdyb/controllers"
19
 	"gdyb/enums"
19
 	"gdyb/enums"
20
 	"gdyb/models"
20
 	"gdyb/models"
2525
 			flow.OriginalRxFile = ""
2525
 			flow.OriginalRxFile = ""
2526
 			flow.OriginalValue = ""
2526
 			flow.OriginalValue = ""
2527
 			flow.SignCertDn = ""
2527
 			flow.SignCertDn = ""
2528
+			flow.UserOrgId = 10454
2528
 			flow.SignCertSn = ""
2529
 			flow.SignCertSn = ""
2529
 			flow.Mtime = time.Now().Unix()
2530
 			flow.Mtime = time.Now().Unix()
2530
-			flow.ID = 0
2531
-			service.Createflow(flow)
2531
+
2532
+			service.Createflow(&flow)
2532
 			c.ServeSuccessJSON(map[string]interface{}{
2533
 			c.ServeSuccessJSON(map[string]interface{}{
2533
 				"msg": "上传成功",
2534
 				"msg": "上传成功",
2534
 			})
2535
 			})
2537
 }
2538
 }
2538
 func (c *HisApiController) GetCFYLJG002() {
2539
 func (c *HisApiController) GetCFYLJG002() {
2539
 	admin_user_id, _ := c.GetInt64("admin_user_id")
2540
 	admin_user_id, _ := c.GetInt64("admin_user_id")
2540
-
2541
-	id, _ := c.GetInt64("id")
2541
+	his_patient_id, _ := c.GetInt64("his_patient_id")
2542
+	record_time := c.GetString("record_time")
2543
+	admin_user_id = 3626
2544
+	his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
2545
+	//id, _ := c.GetInt64("id")
2542
 	admin_user_id = 3626
2546
 	admin_user_id = 3626
2543
 	curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
2547
 	curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
2544
 	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
2548
 	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
2545
-	flow, _ := service.Getflow(id)
2546
-	his, _ := service.GetHisPatientByNumber(flow.MID)
2547
-	record_time := c.GetString("record_time")
2549
+
2550
+	flow, _ := service.Getflowtwo(his.Number)
2551
+	//his, _ := service.GetHisPatientByNumber(flow.MID)
2552
+	//record_time := c.GetString("record_time")
2548
 	patient_id, _ := c.GetInt64("patient_id")
2553
 	patient_id, _ := c.GetInt64("patient_id")
2549
 	//patient_id = 23834
2554
 	//patient_id = 23834
2550
 	//record_time = "2023-09-18"
2555
 	//record_time = "2023-09-18"
2640
 }
2645
 }
2641
 func (c *HisApiController) GetCFYLJG003() {
2646
 func (c *HisApiController) GetCFYLJG003() {
2642
 	admin_user_id, _ := c.GetInt64("admin_user_id")
2647
 	admin_user_id, _ := c.GetInt64("admin_user_id")
2643
-
2644
-	id, _ := c.GetInt64("id")
2648
+	his_patient_id, _ := c.GetInt64("his_patient_id")
2649
+	record_time := c.GetString("record_time")
2650
+	admin_user_id = 3626
2651
+	his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
2652
+	//id, _ := c.GetInt64("id")
2645
 	admin_user_id = 3626
2653
 	admin_user_id = 3626
2646
-	//id  = 3
2647
 	curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
2654
 	curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
2648
 	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
2655
 	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
2649
-	flow, _ := service.Getflow(id)
2650
-	his, _ := service.GetHisPatientByNumber(flow.MID)
2651
-	record_time := c.GetString("record_time")
2656
+
2657
+	flow, _ := service.Getflowtwo(his.Number)
2658
+	//id  = 3
2652
 	patient_id, _ := c.GetInt64("patient_id")
2659
 	patient_id, _ := c.GetInt64("patient_id")
2653
 	//patient_id = 23834
2660
 	//patient_id = 23834
2654
 	//record_time = "2023-09-18"
2661
 	//record_time = "2023-09-18"
2728
 }
2735
 }
2729
 func (c *HisApiController) GetCFYLJG004() {
2736
 func (c *HisApiController) GetCFYLJG004() {
2730
 	admin_user_id, _ := c.GetInt64("admin_user_id")
2737
 	admin_user_id, _ := c.GetInt64("admin_user_id")
2731
-
2732
-	id, _ := c.GetInt64("id")
2738
+	his_patient_id, _ := c.GetInt64("his_patient_id")
2739
+	record_time := c.GetString("record_time")
2740
+	admin_user_id = 3626
2741
+	his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
2742
+	//id, _ := c.GetInt64("id")
2733
 	admin_user_id = 3626
2743
 	admin_user_id = 3626
2734
-	//id  = 3
2735
 	curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
2744
 	curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
2736
 	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
2745
 	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
2737
-	flow, _ := service.Getflow(id)
2738
-	//his, _ := service.GetHisPatientByNumber(flow.MID)
2739
-	record_time := c.GetString("record_time")
2746
+
2747
+	flow, _ := service.Getflowtwo(his.Number)
2748
+	//id  = 3
2740
 	patient_id, _ := c.GetInt64("patient_id")
2749
 	patient_id, _ := c.GetInt64("patient_id")
2741
 	//patient_id = 23834
2750
 	//patient_id = 23834
2742
 	//record_time = "2023-09-18"
2751
 	//record_time = "2023-09-18"
2793
 }
2802
 }
2794
 func (c *HisApiController) GetCFYLJG005() {
2803
 func (c *HisApiController) GetCFYLJG005() {
2795
 	admin_user_id, _ := c.GetInt64("admin_user_id")
2804
 	admin_user_id, _ := c.GetInt64("admin_user_id")
2805
+	his_patient_id, _ := c.GetInt64("his_patient_id")
2806
+	//record_time := c.GetString("record_time")
2807
+	admin_user_id = 3626
2808
+	his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
2809
+	//id, _ := c.GetInt64("id")
2810
+	admin_user_id = 3626
2796
 	curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
2811
 	curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
2797
 	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
2812
 	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
2813
+
2814
+	flow, _ := service.Getflowtwo(his.Number)
2815
+	//id  = 3
2798
 	var cFYLJG005 models.CFYLJG005
2816
 	var cFYLJG005 models.CFYLJG005
2799
-	id, _ := c.GetInt64("id")
2800
-	patient_id, _ := c.GetInt64("patient_id")
2801
-	patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
2802
-	flow, _ := service.Getflow(id)
2817
+
2818
+	//patient_id, _ := c.GetInt64("patient_id")
2803
 	cFYLJG005.HiRxno = flow.HiRxno
2819
 	cFYLJG005.HiRxno = flow.HiRxno
2804
 	cFYLJG005.MdtrtID = flow.MID
2820
 	cFYLJG005.MdtrtID = flow.MID
2805
 	cFYLJG005.EcToken = ""
2821
 	cFYLJG005.EcToken = ""
2806
-	cFYLJG005.PsnName = patient.Name
2822
+	cFYLJG005.PsnName = his.Name
2807
 	cFYLJG005.PsnCertType = "01"
2823
 	cFYLJG005.PsnCertType = "01"
2808
-	cFYLJG005.Certno = patient.IdCardNo
2824
+	cFYLJG005.Certno = his.IdCardNo
2809
 	result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
2825
 	result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
2810
 	saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
2826
 	saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
2811
 
2827
 
2837
 }
2853
 }
2838
 func (c *HisApiController) GetCFYLJG006() {
2854
 func (c *HisApiController) GetCFYLJG006() {
2839
 	admin_user_id, _ := c.GetInt64("admin_user_id")
2855
 	admin_user_id, _ := c.GetInt64("admin_user_id")
2856
+	his_patient_id, _ := c.GetInt64("his_patient_id")
2857
+	admin_user_id = 3626
2858
+	his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
2859
+	//id, _ := c.GetInt64("id")
2860
+	admin_user_id = 3626
2840
 	curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
2861
 	curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
2841
 	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
2862
 	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
2842
-	var cFYLJG006 models.CFYLJG006
2843
-	id, _ := c.GetInt64("id")
2863
+
2864
+	flow, _ := service.Getflowtwo(his.Number)
2865
+	//id  = 3
2844
 	patient_id, _ := c.GetInt64("patient_id")
2866
 	patient_id, _ := c.GetInt64("patient_id")
2867
+	var cFYLJG006 models.CFYLJG006
2845
 	patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
2868
 	patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
2846
-	flow, _ := service.Getflow(id)
2847
 	cFYLJG006.HiRxno = flow.HiRxno
2869
 	cFYLJG006.HiRxno = flow.HiRxno
2848
 	cFYLJG006.MdtrtID = flow.MID
2870
 	cFYLJG006.MdtrtID = flow.MID
2849
 	cFYLJG006.PsnName = patient.Name
2871
 	cFYLJG006.PsnName = patient.Name
2851
 	cFYLJG006.Certno = patient.IdCardNo
2873
 	cFYLJG006.Certno = patient.IdCardNo
2852
 	result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
2874
 	result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
2853
 	saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
2875
 	saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
2854
-
2876
+	var res ResultCFYLJG006
2877
+	var respJSON2 map[string]interface{}
2878
+	if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
2879
+		utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
2880
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2881
+		return
2882
+	}
2883
+	userJSONBytes2, _ := json.Marshal(respJSON2)
2884
+	if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
2885
+		utils.ErrorLog("解析失败:%v", err)
2886
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2887
+		return
2888
+	}
2889
+	if res.Infcode == -1 {
2890
+		c.ServeSuccessJSON(map[string]interface{}{
2891
+			"failed_code": -10,
2892
+			"msg":         res.ErrMsg,
2893
+		})
2894
+		return
2895
+	} else {
2896
+		c.ServeSuccessJSON(map[string]interface{}{
2897
+			"info": res.Output,
2898
+		})
2899
+		return
2900
+	}
2855
 }
2901
 }
2856
 func (c *HisApiController) GetCFYLJG007() {
2902
 func (c *HisApiController) GetCFYLJG007() {
2857
 	admin_user_id, _ := c.GetInt64("admin_user_id")
2903
 	admin_user_id, _ := c.GetInt64("admin_user_id")
2904
+	his_patient_id, _ := c.GetInt64("his_patient_id")
2905
+	admin_user_id = 3626
2906
+	his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
2907
+	//id, _ := c.GetInt64("id")
2908
+	admin_user_id = 3626
2858
 	curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
2909
 	curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
2859
 	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
2910
 	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
2860
-	var cFYLJG007 models.CFYLJG007
2861
-	id, _ := c.GetInt64("id")
2911
+
2912
+	flow, _ := service.Getflowtwo(his.Number)
2913
+	//id  = 3
2862
 	patient_id, _ := c.GetInt64("patient_id")
2914
 	patient_id, _ := c.GetInt64("patient_id")
2915
+	var cFYLJG007 models.CFYLJG007
2863
 	patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
2916
 	patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
2864
 	//his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
2917
 	//his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
2865
-	flow, _ := service.Getflow(id)
2866
-	his, _ := service.GetHisPatientByNumber(flow.MID)
2867
 
2918
 
2868
 	cFYLJG007.HiRxno = flow.HiRxno
2919
 	cFYLJG007.HiRxno = flow.HiRxno
2869
 	cFYLJG007.MdtrtID = flow.MID
2920
 	cFYLJG007.MdtrtID = flow.MID
2874
 	result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
2925
 	result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
2875
 	saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
2926
 	saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
2876
 
2927
 
2877
-	var res ResultCFYLJG006
2928
+	var res ResultCFYLJG007
2878
 	var respJSON2 map[string]interface{}
2929
 	var respJSON2 map[string]interface{}
2879
 	if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
2930
 	if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
2880
 		utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
2931
 		utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
2895
 		return
2946
 		return
2896
 	} else {
2947
 	} else {
2897
 		c.ServeSuccessJSON(map[string]interface{}{
2948
 		c.ServeSuccessJSON(map[string]interface{}{
2898
-			"info": res.Output,
2949
+			"info": res,
2899
 		})
2950
 		})
2900
 		return
2951
 		return
2901
 	}
2952
 	}
4429
 					Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
4480
 					Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
4430
 					infoStr := string(Iinfos)
4481
 					infoStr := string(Iinfos)
4431
 					idetinfoStr := string(Idetinfos)
4482
 					idetinfoStr := string(Idetinfos)
4483
+				  //date,age,_  :=  GetBirthdateAndAge(res.Output.Baseinfo.Certno),
4484
+						b,age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
4485
+
4432
 					psn := &models.HisPsn{
4486
 					psn := &models.HisPsn{
4433
 						PsnNo: res.Output.Baseinfo.PsnNo,
4487
 						PsnNo: res.Output.Baseinfo.PsnNo,
4434
-
4435
 						PatientId: patient.ID,
4488
 						PatientId: patient.ID,
4436
 						Certno:    res.Output.Baseinfo.Certno,
4489
 						Certno:    res.Output.Baseinfo.Certno,
4437
-
4438
 						Gend:         res.Output.Baseinfo.Gend,
4490
 						Gend:         res.Output.Baseinfo.Gend,
4439
 						Naty:         res.Output.Baseinfo.Naty,
4491
 						Naty:         res.Output.Baseinfo.Naty,
4440
 						PsnCertType:  res.Output.Baseinfo.PsnCertType,
4492
 						PsnCertType:  res.Output.Baseinfo.PsnCertType,
4441
 						PsnName:      res.Output.Baseinfo.PsnName,
4493
 						PsnName:      res.Output.Baseinfo.PsnName,
4494
+						Age:float64(age),
4495
+						Brdy:b,
4442
 						Idetinfo:     idetinfoStr,
4496
 						Idetinfo:     idetinfoStr,
4443
 						Insuinfo:     infoStr,
4497
 						Insuinfo:     infoStr,
4444
 						UserOrgId:    c.GetAdminUserInfo().CurrentOrgId,
4498
 						UserOrgId:    c.GetAdminUserInfo().CurrentOrgId,
7948
 					Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
8002
 					Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
7949
 					infoStr := string(Iinfos)
8003
 					infoStr := string(Iinfos)
7950
 					idetinfoStr := string(Idetinfos)
8004
 					idetinfoStr := string(Idetinfos)
8005
+					b,age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
8006
+
7951
 					psn := &models.HisPsn{
8007
 					psn := &models.HisPsn{
7952
 						PsnNo: res.Output.Baseinfo.PsnNo,
8008
 						PsnNo: res.Output.Baseinfo.PsnNo,
7953
-
7954
 						PatientId: patient.ID,
8009
 						PatientId: patient.ID,
7955
 						Certno:    res.Output.Baseinfo.Certno,
8010
 						Certno:    res.Output.Baseinfo.Certno,
7956
-
8011
+						Brdy:        b,
8012
+						Age:float64(age),
7957
 						Gend:        res.Output.Baseinfo.Gend,
8013
 						Gend:        res.Output.Baseinfo.Gend,
7958
 						Naty:        res.Output.Baseinfo.Naty,
8014
 						Naty:        res.Output.Baseinfo.Naty,
7959
 						PsnCertType: res.Output.Baseinfo.PsnCertType,
8015
 						PsnCertType: res.Output.Baseinfo.PsnCertType,
8122
 							Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
8178
 							Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
8123
 							infoStr := string(Iinfos)
8179
 							infoStr := string(Iinfos)
8124
 							idetinfoStr := string(Idetinfos)
8180
 							idetinfoStr := string(Idetinfos)
8181
+							b,age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
8182
+
8125
 							psn := &models.HisPsn{
8183
 							psn := &models.HisPsn{
8126
 								PsnNo: res.Output.Baseinfo.PsnNo,
8184
 								PsnNo: res.Output.Baseinfo.PsnNo,
8127
-
8128
 								PatientId: patient.ID,
8185
 								PatientId: patient.ID,
8129
 								Certno:    res.Output.Baseinfo.Certno,
8186
 								Certno:    res.Output.Baseinfo.Certno,
8130
-								//Brdy:         res.Output.Baseinfo.Brdy,
8187
+								Brdy:         b,
8188
+								Age:float64(age),
8131
 								Gend:         res.Output.Baseinfo.Gend,
8189
 								Gend:         res.Output.Baseinfo.Gend,
8132
 								Naty:         res.Output.Baseinfo.Naty,
8190
 								Naty:         res.Output.Baseinfo.Naty,
8133
 								PsnCertType:  res.Output.Baseinfo.PsnCertType,
8191
 								PsnCertType:  res.Output.Baseinfo.PsnCertType,
9958
 						Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
10016
 						Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
9959
 						infoStr := string(Iinfos)
10017
 						infoStr := string(Iinfos)
9960
 						idetinfoStr := string(Idetinfos)
10018
 						idetinfoStr := string(Idetinfos)
10019
+						b,age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
10020
+
9961
 						psn := &models.HisPsn{
10021
 						psn := &models.HisPsn{
9962
 							PsnNo:     res.Output.Baseinfo.PsnNo,
10022
 							PsnNo:     res.Output.Baseinfo.PsnNo,
9963
 							PatientId: patient.ID,
10023
 							PatientId: patient.ID,
9964
 							Certno:    res.Output.Baseinfo.Certno,
10024
 							Certno:    res.Output.Baseinfo.Certno,
9965
-
10025
+							Brdy:        b,
10026
+							Age:float64(age),
9966
 							//Brdy: res.Output.Baseinfo.Brdy,
10027
 							//Brdy: res.Output.Baseinfo.Brdy,
9967
 							Gend:         res.Output.Baseinfo.Gend,
10028
 							Gend:         res.Output.Baseinfo.Gend,
9968
 							Naty:         res.Output.Baseinfo.Naty,
10029
 							Naty:         res.Output.Baseinfo.Naty,
11264
 						Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
11325
 						Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
11265
 						infoStr := string(Iinfos)
11326
 						infoStr := string(Iinfos)
11266
 						idetinfoStr := string(Idetinfos)
11327
 						idetinfoStr := string(Idetinfos)
11328
+
11329
+						b,age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
11267
 						psn := &models.HisPsn{
11330
 						psn := &models.HisPsn{
11268
 							PsnNo:     res.Output.Baseinfo.PsnNo,
11331
 							PsnNo:     res.Output.Baseinfo.PsnNo,
11269
 							PatientId: patient.ID,
11332
 							PatientId: patient.ID,
11270
 							Certno:    res.Output.Baseinfo.Certno,
11333
 							Certno:    res.Output.Baseinfo.Certno,
11271
 							Gend:      res.Output.Baseinfo.Gend,
11334
 							Gend:      res.Output.Baseinfo.Gend,
11272
-							//Brdy:         res.Output.Baseinfo.Brdy,
11335
+							Brdy:        b,
11336
+							Age:float64(age),
11273
 							Naty:         res.Output.Baseinfo.Naty,
11337
 							Naty:         res.Output.Baseinfo.Naty,
11274
 							PsnCertType:  res.Output.Baseinfo.PsnCertType,
11338
 							PsnCertType:  res.Output.Baseinfo.PsnCertType,
11275
 							PsnName:      res.Output.Baseinfo.PsnName,
11339
 							PsnName:      res.Output.Baseinfo.PsnName,
17109
 	InfRefmsgid string `json:"inf_refmsgid"`
17173
 	InfRefmsgid string `json:"inf_refmsgid"`
17110
 	Infcode     int64  `json:"infcode"`
17174
 	Infcode     int64  `json:"infcode"`
17111
 	Output      struct {
17175
 	Output      struct {
17176
+		HiRxno           string        `json:"hi_rxno"`
17177
+		RxStasName       string        `json:"rx_stas_name"`
17178
+		RxUsedStasCodg   string        `json:"rx_used_stas_codg"`
17179
+		Seltdelts        []interface{} `json:"seltdelts"`
17180
+		RxUsedStasName   string        `json:"rx_used_stas_name"`
17181
+		RxStasCodg       string        `json:"rx_stas_codg"`
17112
 	} `json:"output"`
17182
 	} `json:"output"`
17113
 	RefmsgTime  string      `json:"refmsg_time"`
17183
 	RefmsgTime  string      `json:"refmsg_time"`
17114
 	RespondTime string      `json:"respond_time"`
17184
 	RespondTime string      `json:"respond_time"`
17241
 			SinDosunt       string  `json:"sin_dosunt"`
17311
 			SinDosunt       string  `json:"sin_dosunt"`
17242
 			UsedFrquCodg    string  `json:"used_frqu_codg"`
17312
 			UsedFrquCodg    string  `json:"used_frqu_codg"`
17243
 			UsedFrquName    string  `json:"used_frqu_name"`
17313
 			UsedFrquName    string  `json:"used_frqu_name"`
17244
-			DrugTotlcnt     float64 `json:"drug_totlcnt"`
17314
+			DrugTotlcnt     string `json:"drug_totlcnt"`
17245
 			DrugTotlcntEmp  string  `json:"drug_totlcnt_emp"`
17315
 			DrugTotlcntEmp  string  `json:"drug_totlcnt_emp"`
17246
 			DiseCodg        string  `json:"dise_codg"`
17316
 			DiseCodg        string  `json:"dise_codg"`
17247
 			HospApprFlag    string  `json:"hosp_appr_flag"`
17317
 			HospApprFlag    string  `json:"hosp_appr_flag"`
21039
 							order.Creator = order.Creator
21109
 							order.Creator = order.Creator
21040
 							order.Modify = roles.AdminUserId
21110
 							order.Modify = roles.AdminUserId
21041
 							order.RequestLog = src_resquest
21111
 							order.RequestLog = src_resquest
21112
+						order.FaPiaoNumber =         fapiao_number
21113
+							order.FaPiaoCode =           fapiao_code
21042
 							//setlDetail, _ := json.Marshal(res.Output.Setldetail)
21114
 							//setlDetail, _ := json.Marshal(res.Output.Setldetail)
21043
 							//detailStr := string(setlDetail)
21115
 							//detailStr := string(setlDetail)
21044
 							//order.SetlDetail = detailStr
21116
 							//order.SetlDetail = detailStr
22117
 				order.Modify = roles.AdminUserId
22189
 				order.Modify = roles.AdminUserId
22118
 				order.RequestLog = src_resquest
22190
 				order.RequestLog = src_resquest
22119
 				order.Diagnosis = diagnosis_id
22191
 				order.Diagnosis = diagnosis_id
22192
+				order.FaPiaoNumber =         fapiao_number
22193
+				order.FaPiaoCode =           fapiao_code
22120
 				setlDetail, _ := json.Marshal(res.Output.Setldetail)
22194
 				setlDetail, _ := json.Marshal(res.Output.Setldetail)
22121
 				detailStr := string(setlDetail)
22195
 				detailStr := string(setlDetail)
22122
 				order.SetlDetail = detailStr
22196
 				order.SetlDetail = detailStr
33027
 	}
33101
 	}
33028
 	return
33102
 	return
33029
 }
33103
 }
33104
+
33105
+
33106
+func getBirthdateAndAge(idNumber string) (string, int, error) {
33107
+	if len(idNumber) != 18 {
33108
+		return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
33109
+	}
33110
+
33111
+	// 提取出生日期
33112
+	year, err := strconv.Atoi(idNumber[6:10])
33113
+	if err != nil {
33114
+		return "", 0, err
33115
+	}
33116
+	month, err := strconv.Atoi(idNumber[10:12])
33117
+	if err != nil {
33118
+		return "", 0, err
33119
+	}
33120
+	day, err := strconv.Atoi(idNumber[12:14])
33121
+	if err != nil {
33122
+		return "", 0, err
33123
+	}
33124
+
33125
+	// 格式化生日字符串
33126
+	birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
33127
+	birthdateFormatted := birthdate.Format("2006-01-02")
33128
+
33129
+	// 计算年龄
33130
+	today := time.Now()
33131
+	age := today.Year() - birthdate.Year()
33132
+	if today.YearDay() < birthdate.YearDay() {
33133
+		age--
33134
+	}
33135
+
33136
+	return birthdateFormatted, age, nil
33137
+}

+ 46 - 0
controllers/zh/zh_his_api_controller.go View File

3792
 
3792
 
3793
 		var customs []*models.NewCustom
3793
 		var customs []*models.NewCustom
3794
 
3794
 
3795
+		var empty_code_errs []string
3796
+
3797
+		for _, item := range prescriptions {
3798
+			if item.Type == 1 { //药品
3799
+				for _, subItem := range item.HisDoctorAdviceInfo {
3800
+					if len(subItem.BaseDrugLib.MedicalInsuranceNumber) == 0 {
3801
+
3802
+						empty_code_errs = append(empty_code_errs,subItem.BaseDrugLib.DrugName)
3803
+					}
3804
+				}
3805
+			}
3806
+
3807
+			if item.Type == 2 { //项目
3808
+				for _, subItem := range item.HisPrescriptionProject {
3809
+					//var randNum int
3810
+					//randNum = rand.Intn(10000) + 1000
3811
+					if subItem.Type == 2 {
3812
+						if len(subItem.HisProject.MedicalCode) == 0 {
3813
+							empty_code_errs = append(empty_code_errs,subItem.HisProject.ProjectName)
3814
+
3815
+						}
3816
+					} else if subItem.Type == 3 {
3817
+						if len(subItem.GoodInfo.MedicalInsuranceNumber) == 0 {
3818
+							empty_code_errs = append(empty_code_errs,subItem.GoodInfo.GoodName)
3819
+
3820
+						}
3821
+					}
3822
+				}
3823
+			}
3824
+
3825
+		}
3826
+		if len(empty_code_errs) > 0{
3827
+			var err string
3828
+			for _, item := range empty_code_errs{
3829
+				if len(err) == 0{
3830
+					err = item
3831
+				}else{
3832
+					err = err +"," + item
3833
+				}
3834
+			}
3835
+			c.ServeSuccessJSON(map[string]interface{}{
3836
+				"failed_code": -10,
3837
+				"msg":     err +" "+ "没有填写国家编码",
3838
+			})
3839
+			return
3840
+		}
3795
 		for _, item := range prescriptions {
3841
 		for _, item := range prescriptions {
3796
 			tm := time.Unix(item.PreTime, 0)
3842
 			tm := time.Unix(item.PreTime, 0)
3797
 			if item.Type == 1 { //药品
3843
 			if item.Type == 1 { //药品

+ 1 - 1
main.go View File

49
 
49
 
50
 	//深圳百霖
50
 	//深圳百霖
51
 	//GetblBatchSettleList()
51
 	//GetblBatchSettleList()
52
-	//GetblbrBatchSettleList()
52
+	//GetblbrBatchSettleList()8
53
 	//深圳百霖贝尔
53
 	//深圳百霖贝尔
54
 	//GetbrBatchSettleList()
54
 	//GetbrBatchSettleList()
55
 
55
 

+ 1 - 1
models/cfyljg.go View File

243
 	SignCertSn     string `gorm:"column:sign_cert_sn" json:"sign_cert_sn" form:"sign_cert_sn"`
243
 	SignCertSn     string `gorm:"column:sign_cert_sn" json:"sign_cert_sn" form:"sign_cert_sn"`
244
 	SignCertDn     string `gorm:"column:sign_cert_dn" json:"sign_cert_dn" form:"sign_cert_dn"`
244
 	SignCertDn     string `gorm:"column:sign_cert_dn" json:"sign_cert_dn" form:"sign_cert_dn"`
245
 	MID            string `gorm:"column:m_id" json:"m_id" form:"m_id"`
245
 	MID            string `gorm:"column:m_id" json:"m_id" form:"m_id"`
246
-	DCode            string `gorm:"column:m_id" json:"m_id" form:"m_id"`
246
+	DCode            string `gorm:"column:d_code" json:"d_code" form:"d_code"`
247
 	DID           int64 `gorm:"column:d_id" json:"d_id" form:"d_id"`
247
 	DID           int64 `gorm:"column:d_id" json:"d_id" form:"d_id"`
248
 
248
 
249
 
249
 

+ 6 - 0
service/dianzichufang.go View File

745
 	err = readDb.Model(&models.HisPrescriptionFlow{}).Where("id = ?", id).First(&flow).Error
745
 	err = readDb.Model(&models.HisPrescriptionFlow{}).Where("id = ?", id).First(&flow).Error
746
 	return
746
 	return
747
 }
747
 }
748
+
749
+
750
+func Getflowtwo(m_id string) (flow models.HisPrescriptionFlow, err error) {
751
+	err = readDb.Model(&models.HisPrescriptionFlow{}).Where("m_id = ?", m_id).First(&flow).Error
752
+	return
753
+}

+ 1 - 0
service/gdyb_service.go View File

626
 
626
 
627
 	for index, item := range config {
627
 	for index, item := range config {
628
 		diseinfo_sun := make(map[string]interface{})
628
 		diseinfo_sun := make(map[string]interface{})
629
+
629
 		diseinfo_sun["diag_type"] = "1"              // 诊断类别
630
 		diseinfo_sun["diag_type"] = "1"              // 诊断类别
630
 		diseinfo_sun["diag_srt_no"] = index + 1          // 诊断排序号
631
 		diseinfo_sun["diag_srt_no"] = index + 1          // 诊断排序号
631
 		diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
632
 		diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码

+ 3 - 3
service/hbyb_service.go View File

2876
 	fmt.Println("----------")
2876
 	fmt.Println("----------")
2877
 	fmt.Println(string(bytesData))
2877
 	fmt.Println(string(bytesData))
2878
 	fmt.Println("----------")
2878
 	fmt.Println("----------")
2879
-	requestLog := string(bytesData)
2879
+	//requestLog := string(bytesData)
2880
 
2880
 
2881
 	if err != nil {
2881
 	if err != nil {
2882
 		fmt.Println(err.Error())
2882
 		fmt.Println(err.Error())
2913
 		fmt.Println(err.Error())
2913
 		fmt.Println(err.Error())
2914
 		return "", ""
2914
 		return "", ""
2915
 	}
2915
 	}
2916
-	return string(respBytes), requestLog
2916
+	return   ConvertToString(string(respBytes), "gbk", "utf-8"), ConvertToString(string(bytesData), "gbk", "utf-8")
2917
 
2917
 
2918
 }
2918
 }
2919
 func Hb2301A(psnNo string, mdtrtId string, hisPrescription []*models.NewCustom, chrg_bchno string, org_name string, doctor string, dept string, fixmedins_code string, dept_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, med_type string, opertor string) (string, string) {
2919
 func Hb2301A(psnNo string, mdtrtId string, hisPrescription []*models.NewCustom, chrg_bchno string, org_name string, doctor string, dept string, fixmedins_code string, dept_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, med_type string, opertor string) (string, string) {
3103
 		fmt.Println("error:", err.Error())
3103
 		fmt.Println("error:", err.Error())
3104
 	}
3104
 	}
3105
 
3105
 
3106
-	return string(out), string(bytesData)
3106
+	return ConvertToString(string(out), "gbk", "utf-8"), ConvertToString(string(bytesData), "gbk", "utf-8")
3107
 }
3107
 }
3108
 //  住院结算
3108
 //  住院结算
3109
 func Hb2304(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, mid_setl_flag string, id_card_type int64, fulamt_ownpay_amt float64, overlmt_selfpay float64, preselfpay_amt float64, inscp_scp_amt float64, certificates int64, fapiao_number string, acct_used_flag string) (string, string) {
3109
 func Hb2304(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, mid_setl_flag string, id_card_type int64, fulamt_ownpay_amt float64, overlmt_selfpay float64, preselfpay_amt float64, inscp_scp_amt float64, certificates int64, fapiao_number string, acct_used_flag string) (string, string) {

+ 1 - 1
service/his_service.go View File

1665
 	writeDb.Save(&flow)
1665
 	writeDb.Save(&flow)
1666
 }
1666
 }
1667
 
1667
 
1668
-func Createflow(flow models.HisPrescriptionFlow) {
1668
+func Createflow(flow *models.HisPrescriptionFlow) {
1669
 	writeDb.Create(&flow)
1669
 	writeDb.Create(&flow)
1670
 }
1670
 }
1671
 
1671
 

+ 1 - 1
service/hn_service.go View File

1633
 	inputData["opsp_mdtrt_date"] = ""                         // 门诊慢特病就诊日期  必填
1633
 	inputData["opsp_mdtrt_date"] = ""                         // 门诊慢特病就诊日期  必填
1634
 	inputData["ipt_med_type"] = struct4101.IptMedType         // 住院医疗类型  必填
1634
 	inputData["ipt_med_type"] = struct4101.IptMedType         // 住院医疗类型  必填
1635
 	inputData["adm_way"] = ""                                 // 入院途径  必填
1635
 	inputData["adm_way"] = ""                                 // 入院途径  必填
1636
-	inputData["trt_type"] = ""                                // 治疗类别  必填
1636
+	inputData["trt_type"] = "10"                                // 治疗类别  必填
1637
 	inputData["adm_time"] = struct4101.AdmTime                // 入院时间  必填
1637
 	inputData["adm_time"] = struct4101.AdmTime                // 入院时间  必填
1638
 	inputData["adm_caty"] = struct4101.AdmCaty                // 入院科别  必填
1638
 	inputData["adm_caty"] = struct4101.AdmCaty                // 入院科别  必填
1639
 	inputData["refldept_dept"] = ""                           // 转科科别  必填
1639
 	inputData["refldept_dept"] = ""                           // 转科科别  必填

+ 4 - 4
service/jsyb_service.go View File

1040
 	inputMessage["infver"] = "1.0.0"                                                            // 接收方系统代码
1040
 	inputMessage["infver"] = "1.0.0"                                                            // 接收方系统代码
1041
 	inputMessage["opter_type"] = "1"                                                            // 经办人类别
1041
 	inputMessage["opter_type"] = "1"                                                            // 经办人类别
1042
 	if fixmedins_code == "H32090403023" {
1042
 	if fixmedins_code == "H32090403023" {
1043
-		inputMessage["opter"] = doctor      // 经办人
1044
-		inputMessage["opter_name"] = doctor // 经办人姓名
1043
+		inputMessage["opter"] = "葛美琴"      // 经办人
1044
+		inputMessage["opter_name"] = "葛美琴" // 经办人姓名
1045
 	} else {
1045
 	} else {
1046
-		inputMessage["opter"] = doctor      // 经办人
1047
-		inputMessage["opter_name"] = doctor // 经办人姓名
1046
+		inputMessage["opter"] = "孙欣欣"      // 经办人
1047
+		inputMessage["opter_name"] = "孙欣欣" // 经办人姓名
1048
 	}
1048
 	}
1049
 	inputMessage["inf_time"] = timeFormatOne        // 交易时间
1049
 	inputMessage["inf_time"] = timeFormatOne        // 交易时间
1050
 	inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
1050
 	inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号