csx 4 years ago
parent
commit
852ed7f1aa

+ 5 - 2
controllers/gdyb_controller.go View File

@@ -106,7 +106,9 @@ func (c *GdybController) PostTwo() {
106 106
 
107 107
 	secret_key := c.GetString("secret_key")
108 108
 
109
-	result := service.Gdyb2201(psnNo, insutype, certNo, org_name, doctor, ipt_otp_no, dept, fixmedins_code, dept_code, doctor_id, insuplc_admdvs, mdtrtarea_admvs, secret_key)
109
+	id_card_type, _ := c.GetInt64("id_card_type")
110
+
111
+	result := service.Gdyb2201(psnNo, insutype, certNo, org_name, doctor, ipt_otp_no, dept, fixmedins_code, dept_code, doctor_id, insuplc_admdvs, mdtrtarea_admvs, secret_key, id_card_type)
110 112
 
111 113
 	var dat map[string]interface{}
112 114
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
@@ -299,8 +301,9 @@ func (c *GdybController) PostEight() {
299 301
 	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
300 302
 	secret_key := c.GetString("secret_key")
301 303
 	med_type := c.GetString("med_type")
304
+	id_card_type, _ := c.GetInt64("id_card_type")
302 305
 
303
-	result := service.Gdyb2207(psnNo, mdtrtId, chrgBchno, certNo, insutype, total, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, med_type)
306
+	result := service.Gdyb2207(psnNo, mdtrtId, chrgBchno, certNo, insutype, total, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, med_type, id_card_type)
304 307
 	var dat map[string]interface{}
305 308
 	if err := json.Unmarshal([]byte(result), &dat); err == nil {
306 309
 		fmt.Println(dat)

+ 264 - 146
controllers/his_api_controller.go View File

@@ -32,6 +32,7 @@ type HisApiController struct {
32 32
 func HisManagerApiRegistRouters() {
33 33
 
34 34
 	beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
35
+	beego.Router("/api/diag/upload", &HisApiController{}, "get:GetUploadDiag")
35 36
 	beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
36 37
 	beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
37 38
 	beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
@@ -52,17 +53,88 @@ func HisManagerApiRegistRouters() {
52 53
 }
53 54
 
54 55
 func (c *HisApiController) Sscard() {
56
+	id_card_type, _ := c.GetInt64("id_card_type")
57
+	adminUser := c.GetAdminUserInfo()
55 58
 	r := CardInit()
56 59
 	if r == 0 {
57
-		GetBaseInfo()
60
+		switch id_card_type {
61
+		case 1:
62
+			basStr, err := GetBasBaseInfo()
63
+
64
+			if err != nil {
65
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
66
+				return
67
+
68
+			} else {
69
+				bas := strings.Split(basStr, "|")
70
+				basNumber := bas[1]
71
+				patient, err := service.GetPatientByNumber(basNumber, adminUser.CurrentOrgId)
72
+				if err == gorm.ErrRecordNotFound {
73
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
74
+					return
75
+
76
+				} else if err != nil {
77
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
78
+					return
79
+
80
+				} else {
81
+					c.ServeSuccessJSON(map[string]interface{}{
82
+						"patient": patient,
83
+						"number":  basNumber,
84
+					})
85
+				}
86
+
87
+			}
88
+
89
+			break
90
+		case 2:
91
+			SFZStr, err := GetSFZBaseInfo()
92
+			if err != nil {
93
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
94
+				return
95
+
96
+			} else {
97
+
98
+				id_card_str := strings.Split(SFZStr, "^")
99
+				id_card_number := id_card_str[0]
100
+				patient, err := service.GetPatientByIDCard(id_card_number, adminUser.CurrentOrgId)
101
+				if err == gorm.ErrRecordNotFound {
102
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
103
+					return
104
+
105
+				} else if err != nil {
106
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
107
+					return
108
+
109
+				} else {
110
+					c.ServeSuccessJSON(map[string]interface{}{
111
+						"patient": patient,
112
+					})
113
+				}
114
+
115
+			}
116
+			break
117
+		case 3:
118
+			//QRStr, err :=GetQRBaseInfo()
119
+			//if err != nil{
120
+			//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
121
+			//	return
122
+			//
123
+			//}else{
124
+			//
125
+			//
126
+			//
127
+			//}
128
+			break
129
+
130
+		}
58 131
 	}
59 132
 	c.ServeSuccessJSON(map[string]interface{}{
60 133
 		"list": "11",
61 134
 	})
62 135
 
63 136
 }
64
-
65
-func GetBaseInfo() error {
137
+func GetBasBaseInfo() (jsonStr string, err error) {
66 138
 	handle := syscall.MustLoadDLL("SSCard.dll")
67 139
 	ReadCardBas := handle.MustFindProc("ReadCardBas")
68 140
 
@@ -72,7 +144,33 @@ func GetBaseInfo() error {
72 144
 
73 145
 	fmt.Println(string(str))
74 146
 	fmt.Println(r)
75
-	return nil
147
+	return string(str), nil
148
+}
149
+
150
+func GetSFZBaseInfo() (jsonStr string, err error) {
151
+	handle := syscall.MustLoadDLL("SSCard.dll")
152
+	ReadCardBas := handle.MustFindProc("ReadSFZ")
153
+
154
+	str := make([]byte, 256)
155
+	str1 := make([]byte, 256)
156
+	r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
157
+
158
+	fmt.Println(string(str))
159
+	fmt.Println(r)
160
+	return string(str), nil
161
+}
162
+
163
+func GetQRBaseInfo() (jsonStr string, err error) {
164
+	handle := syscall.MustLoadDLL("SSCard.dll")
165
+	ReadCardBas := handle.MustFindProc("GetQRBase")
166
+
167
+	str := make([]byte, 256)
168
+	str1 := make([]byte, 256)
169
+	r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
170
+
171
+	fmt.Println(string(str))
172
+	fmt.Println(r)
173
+	return string(str), nil
76 174
 }
77 175
 
78 176
 func CardInit() int {
@@ -366,20 +464,23 @@ type Custom struct {
366 464
 func (c *HisApiController) GetRegisterInfo() {
367 465
 	id, _ := c.GetInt64("id")
368 466
 	record_time := c.GetString("record_time")
467
+	settlementValue, _ := c.GetInt64("settlement_value")
468
+	medical_insurance_card := c.GetString("medical_insurance_card")
369 469
 	name := c.GetString("name")
370
-	gender, _ := c.GetInt64("gender")
371
-	age, _ := c.GetInt64("age")
470
+	id_card_type, _ := c.GetInt64("id_card_type")
471
+	certificates, _ := c.GetInt64("certificates")
472
+	medical_care, _ := c.GetInt64("medical_care")
372 473
 	birthday := c.GetString("birthday")
474
+	age, _ := c.GetInt64("age")
475
+	id_card := c.GetString("idCard")
476
+	register_type, _ := c.GetInt64("register")
477
+	doctor, _ := c.GetInt64("doctor")
478
+	department, _ := c.GetInt64("department")
479
+	gender, _ := c.GetInt64("sex")
373 480
 	phone := c.GetString("phone")
374
-	medical_care, _ := c.GetInt64("medical_care")
375
-	id_card := c.GetString("id_card")
376
-	register_type, _ := c.GetInt64("register_type")
377 481
 	registration_fee, _ := c.GetFloat("registration_fee")
378 482
 	medical_expenses, _ := c.GetFloat("medical_expenses")
379
-	certificates, _ := c.GetInt64("certificates")
380
-	settlementValue, _ := c.GetInt64("settlement_value")
381 483
 	social_type, _ := c.GetInt64("social_type")
382
-	medical_insurance_card := c.GetString("medical_insurance_card")
383 484
 	admin_user_id, _ := c.GetInt64("admin_user_id")
384 485
 
385 486
 	timeLayout := "2006-01-02"
@@ -411,6 +512,7 @@ func (c *HisApiController) GetRegisterInfo() {
411 512
 		return
412 513
 	}
413 514
 	config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
515
+
414 516
 	if config.IsOpen == 1 {
415 517
 		api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + patient.IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
416 518
 		resp, requestErr := http.Get(api)
@@ -478,6 +580,9 @@ func (c *HisApiController) GetRegisterInfo() {
478 580
 				UserOrgId:              adminInfo.CurrentOrgId,
479 581
 				AdminUserId:            admin_user_id,
480 582
 				IsReturn:               1,
583
+				IdCardType:             id_card_type,
584
+				Doctor:                 doctor,
585
+				Departments:            department,
481 586
 			}
482 587
 
483 588
 			timestamp := time.Now().Unix()
@@ -488,14 +593,21 @@ func (c *HisApiController) GetRegisterInfo() {
488 593
 			count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
489 594
 			department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
490 595
 			doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
491
-
492
-			fmt.Println(miConfig.SecretKey)
596
+			diagnosisConfig, _ := service.FindDiagnoseById(patientPrescription.Diagnosis)
597
+			sickConfig, _ := service.FindSickById(patientPrescription.SickType)
598
+
599
+			IdCardNo := ""
600
+			if id_card_type == 1 {
601
+				IdCardNo = medical_insurance_card
602
+			} else if id_card_type == 2 {
603
+				IdCardNo = patient.IdCardNo
604
+			}
493 605
 
494 606
 			if count <= 0 {
495
-				api := "http://127.0.0.1:9532/" + "gdyb/two?cert_no=" + patient.IdCardNo + "&insutype=" +
607
+				api := "http://127.0.0.1:9532/" + "gdyb/two?cert_no=" + IdCardNo + "&insutype=" +
496 608
 					res.Output.Iinfo[0].Insutype + "&psn_no=" + res.Output.Baseinfo.PsnNo +
497 609
 					"&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&ipt_otp_no=" + ipt_otp_no +
498
-					"&dept=" + department.Name + "&fixmedins_code=" + miConfig.Code + "&dept_code=" + department.Number + "&doctor_id=" + doctor_id + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
610
+					"&dept=" + department.Name + "&fixmedins_code=" + miConfig.Code + "&dept_code=" + department.Number + "&doctor_id=" + doctor_id + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(int64(id_card_type), 10)
499 611
 				resp, requestErr := http.Get(api)
500 612
 				if requestErr != nil {
501 613
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -536,7 +648,6 @@ func (c *HisApiController) GetRegisterInfo() {
536 648
 						Stage:      2,
537 649
 					}
538 650
 					service.CreateErrMsgLog(errlog)
539
-
540 651
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterTwoException)
541 652
 					return
542 653
 				}
@@ -549,68 +660,65 @@ func (c *HisApiController) GetRegisterInfo() {
549 660
 				his.UserOrgId = adminInfo.CurrentOrgId
550 661
 				his.Ctime = time.Now().Unix()
551 662
 				his.Mtime = time.Now().Unix()
552
-				diagnosisConfig, _ := service.FindDiagnoseById(patientPrescription.Diagnosis)
553
-
554
-				sickConfig, _ := service.FindSickById(patientPrescription.SickType)
555
-
556
-				fmt.Println("1112222222")
557
-				fmt.Println(sickConfig.ClassName)
558
-				fmt.Println(sickConfig.CountryCode)
559
-				fmt.Println("223333333")
560
-
561
-				api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
562
-					"&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
563
-					"&diag=" + diagnosisConfig.ClassName + "&org_name=" + miConfig.OrgName + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&doctor_id=" + strconv.FormatInt(patientPrescription.DoctorId, 10) + "&fixmedins_code=" + miConfig.Code + "&diag_code=" + diagnosisConfig.CountryCode +
564
-					"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.CountryCode + "&sick_name=" + sickConfig.ClassName
565
-				resp2, requestErr2 := http.Get(api2)
566
-				if requestErr2 != nil {
567
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
568
-					return
569
-				}
570
-				body2, ioErr2 := ioutil.ReadAll(resp2.Body)
571
-				if ioErr2 != nil {
572
-					utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
573
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
574
-					return
575
-				}
576
-				var respJSON2 map[string]interface{}
577
-				if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
578
-					utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
579
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
580
-					return
581
-				}
582
-				respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
583
-				userJSONBytes2, _ := json.Marshal(respJSON2)
663
+				his.Status = 1
664
+				err := service.CreateHisPatientTwo(&his)
665
+				if err == nil {
666
+					api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
667
+						"&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
668
+						"&diag=" + diagnosisConfig.ClassName + "&org_name=" + miConfig.OrgName + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&doctor_id=" + strconv.FormatInt(patientPrescription.DoctorId, 10) + "&fixmedins_code=" + miConfig.Code + "&diag_code=" + diagnosisConfig.CountryCode +
669
+						"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.CountryCode + "&sick_name=" + sickConfig.ClassName
670
+					resp2, requestErr2 := http.Get(api2)
671
+					if requestErr2 != nil {
672
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
673
+						return
674
+					}
675
+					body2, ioErr2 := ioutil.ReadAll(resp2.Body)
676
+					if ioErr2 != nil {
677
+						utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
678
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
679
+						return
680
+					}
681
+					var respJSON2 map[string]interface{}
682
+					if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
683
+						utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
684
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
685
+						return
686
+					}
687
+					respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
688
+					userJSONBytes2, _ := json.Marshal(respJSON2)
584 689
 
585
-				var res2 ResultSix
586
-				if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
587
-					utils.ErrorLog("解析失败:%v", err)
588
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
589
-					return
590
-				}
591
-				if res2.Infcode == -1 {
592
-					adminUser := c.GetAdminUserInfo()
593
-					errlog := &models.HisOrderError{
594
-						UserOrgId:  adminUser.CurrentOrgId,
595
-						Ctime:      time.Now().Unix(),
596
-						Mtime:      time.Now().Unix(),
597
-						ErrMsg:     res2.ErrMsg,
598
-						Status:     1,
599
-						PatientId:  id,
600
-						RecordTime: recordDateTime,
601
-						Stage:      3,
690
+					var res2 ResultSix
691
+					if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
692
+						utils.ErrorLog("解析失败:%v", err)
693
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
694
+						return
602 695
 					}
603
-					service.CreateErrMsgLog(errlog)
696
+					if res2.Infcode == -1 {
697
+						adminUser := c.GetAdminUserInfo()
698
+						errlog := &models.HisOrderError{
699
+							UserOrgId:  adminUser.CurrentOrgId,
700
+							Ctime:      time.Now().Unix(),
701
+							Mtime:      time.Now().Unix(),
702
+							ErrMsg:     res2.ErrMsg,
703
+							Status:     1,
704
+							PatientId:  id,
705
+							RecordTime: recordDateTime,
706
+							Stage:      3,
707
+						}
708
+						service.CreateErrMsgLog(errlog)
709
+
710
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
711
+						return
712
+					}
713
+
714
+					c.ServeSuccessJSON(map[string]interface{}{
715
+						"his_info": his,
716
+					})
604 717
 
605
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
718
+				} else {
719
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
606 720
 					return
607 721
 				}
608
-				his.Status = 1
609
-				service.CreateHisPatientTwo(&his)
610
-
611
-				c.ServeSuccessJSON(map[string]interface{}{
612
-					"his_info": his,
613
-				})
614 722
 
615 723
 			} else {
616 724
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
@@ -728,76 +836,6 @@ func (c *HisApiController) GetUploadInfo() {
728 836
 		prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
729 837
 		data["pre"] = prescriptions
730 838
 
731
-		//var advices []*models.HisDoctorAdviceInfo
732
-		//var projects []*models.HisPrescriptionProject
733
-		//var additions []*models.HisAdditionalCharge
734
-		//var customs []*models.Custom
735
-		//for _, item := range monthPrescriptions {
736
-		//	advices = append(advices, item.HisDoctorAdviceInfo...)
737
-		//	projects = append(projects, item.HisPrescriptionProject...)
738
-		//	additions = append(additions, item.HisAdditionalCharge...)
739
-		//}
740
-		//
741
-		//var adviceCodes []string
742
-		//var projectCodes []string
743
-		//var additionCodes []string
744
-		//
745
-		//
746
-		//
747
-		//
748
-		//for _, item := range advices {
749
-		//	adviceCodes = append(adviceCodes, item.MedListCodg)
750
-		//}
751
-		//for _, item := range projects {
752
-		//	projectCodes = append(projectCodes, item.MedListCodg)
753
-		//}
754
-		//for _, item := range additions {
755
-		//	additionCodes = append(additionCodes, item.XtHisAddtionConfig.Code)
756
-		//}
757
-		//adviceCodes = RemoveRepeatedCode(adviceCodes)
758
-		//projectCodes = RemoveRepeatedCode(projectCodes)
759
-		//additionCodes = RemoveRepeatedCode(additionCodes)
760
-		//
761
-		//for  _, item := range adviceCodes{
762
-		//	var custom models.Custom
763
-		//	for _,subItem := range advices{
764
-		//		if item == subItem.MedListCodg{
765
-		//			custom.Price =fmt.Sprintf("%.2f", subItem.Price)
766
-		//			custom.MedListCodg = subItem.MedListCodg
767
-		//			custom.Cut = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
768
-		//			custom.DetItemFeeSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
769
-		//			custom.FeedetlSn = subItem.FeedetlSn
770
-		//			customs = append(customs,&custom)
771
-		//		}
772
-		//	}
773
-		//}
774
-		//for  _, item := range additionCodes{
775
-		//	var custom models.Custom
776
-		//	for _,subItem := range additions{
777
-		//		if item == subItem.XtHisAddtionConfig.Code{
778
-		//			custom.Price =fmt.Sprintf("%.2f", subItem.Price)
779
-		//			custom.MedListCodg = subItem.XtHisAddtionConfig.Code
780
-		//			custom.Cut = fmt.Sprintf("%.2f", subItem.Count)
781
-		//			custom.DetItemFeeSumamt = fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count))
782
-		//			custom.FeedetlSn = subItem.FeedetlSn
783
-		//			customs = append(customs,&custom)
784
-		//		}
785
-		//	}
786
-		//}
787
-		//for  _, item := range projectCodes{
788
-		//	var custom models.Custom
789
-		//	for _,subItem := range projects{
790
-		//		if item == subItem.MedListCodg{
791
-		//			custom.Price =fmt.Sprintf("%.2f", subItem.Price)
792
-		//			custom.MedListCodg = subItem.MedListCodg
793
-		//			custom.Cut = fmt.Sprintf("%.2f", subItem.Count)
794
-		//			custom.DetItemFeeSumamt = fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count))
795
-		//			custom.FeedetlSn = subItem.FeedetlSn
796
-		//			customs = append(customs,&custom)
797
-		//		}
798
-		//	}
799
-		//}
800
-
801 839
 	}
802 840
 	his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
803 841
 	timestamp := time.Now().Unix()
@@ -974,11 +1012,21 @@ func (c *HisApiController) GetUploadInfo() {
974 1012
 				chrg_bchno := chrg_bchno
975 1013
 				cert_no := his.Certno
976 1014
 				insutype := rf[0].Insutype
1015
+
1016
+				if his.IdCardType == 1 {
1017
+					cert_no = his.MedicalInsuranceNumber
1018
+
1019
+				} else if his.IdCardType == 2 {
1020
+
1021
+					cert_no = his.Certno
1022
+
1023
+				}
1024
+
977 1025
 				api := "http://127.0.0.1:9532/" + "gdyb/eight?cert_no=" + cert_no + "&insutype=" +
978 1026
 					insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
979
-					"&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10)
1027
+					"&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
1028
+					miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
980 1029
 				resp, requestErr := http.Get(api)
981
-
982 1030
 				if requestErr != nil {
983 1031
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
984 1032
 					return
@@ -2196,6 +2244,76 @@ func (c *HisApiController) PutRecord() {
2196 2244
 
2197 2245
 }
2198 2246
 
2247
+func (c *HisApiController) GetUploadDiag() {
2248
+	id, _ := c.GetInt64("id")
2249
+	record_time := c.GetString("record_time")
2250
+	timeLayout := "2006-01-02"
2251
+	loc, _ := time.LoadLocation("Local")
2252
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
2253
+	if err != nil {
2254
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2255
+		return
2256
+	}
2257
+	recordDateTime := theTime.Unix()
2258
+	adminInfo := c.GetAdminUserInfo()
2259
+	patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
2260
+
2261
+	miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
2262
+	diagnosisConfig, _ := service.FindDiagnoseById(patientPrescription.Diagnosis)
2263
+	his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
2264
+	sickConfig, _ := service.FindSickById(patientPrescription.SickType)
2265
+	department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
2266
+
2267
+	api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
2268
+		"&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
2269
+		"&diag=" + diagnosisConfig.ClassName + "&org_name=" + miConfig.OrgName + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&doctor_id=" + strconv.FormatInt(patientPrescription.DoctorId, 10) + "&fixmedins_code=" + miConfig.Code + "&diag_code=" + diagnosisConfig.CountryCode +
2270
+		"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.CountryCode + "&sick_name=" + sickConfig.ClassName
2271
+	resp2, requestErr2 := http.Get(api2)
2272
+	if requestErr2 != nil {
2273
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2274
+		return
2275
+	}
2276
+	body2, ioErr2 := ioutil.ReadAll(resp2.Body)
2277
+	if ioErr2 != nil {
2278
+		utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
2279
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2280
+		return
2281
+	}
2282
+	var respJSON2 map[string]interface{}
2283
+	if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
2284
+		utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
2285
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2286
+		return
2287
+	}
2288
+	respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
2289
+	userJSONBytes2, _ := json.Marshal(respJSON2)
2290
+
2291
+	var res2 ResultSix
2292
+	if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
2293
+		utils.ErrorLog("解析失败:%v", err)
2294
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2295
+		return
2296
+	}
2297
+	if res2.Infcode == -1 {
2298
+		adminUser := c.GetAdminUserInfo()
2299
+		errlog := &models.HisOrderError{
2300
+			UserOrgId:  adminUser.CurrentOrgId,
2301
+			Ctime:      time.Now().Unix(),
2302
+			Mtime:      time.Now().Unix(),
2303
+			ErrMsg:     res2.ErrMsg,
2304
+			Status:     1,
2305
+			PatientId:  id,
2306
+			RecordTime: recordDateTime,
2307
+			Stage:      3,
2308
+		}
2309
+		service.CreateErrMsgLog(errlog)
2310
+
2311
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
2312
+		return
2313
+	}
2314
+
2315
+}
2316
+
2199 2317
 func PathExists(path string) (bool, error) {
2200 2318
 	_, err := os.Stat(path)
2201 2319
 	if err == nil {

+ 7 - 0
enums/error_code.go View File

@@ -230,6 +230,10 @@ const ( // ErrorCode
230 230
 	ErrorCodeRegisterRepeatException = 20072
231 231
 
232 232
 	ErrorCodeAmountAccountException = 20073
233
+
234
+	ErrorCodeReadCardException = 20074
235
+
236
+	ErrorCodeNoPateintException = 20075
233 237
 )
234 238
 
235 239
 var ErrCodeMsgs = map[int]string{
@@ -444,6 +448,9 @@ var ErrCodeMsgs = map[int]string{
444 448
 	ErrorCodeRegisterThreeException:  "就诊信息上传失败",
445 449
 	ErrorCodeRegisterRepeatException: "一天只能挂号一次",
446 450
 	ErrorCodeAmountAccountException:  "结算失败",
451
+
452
+	ErrorCodeReadCardException:  "读卡失败",
453
+	ErrorCodeNoPateintException: "该患者不存在血透系统中,请在血透系统中添加该患者",
447 454
 }
448 455
 
449 456
 type SGJError struct {

+ 1 - 0
models/his_models.go View File

@@ -740,6 +740,7 @@ type VMHisPatient struct {
740 740
 	IptOtpNo               string  `gorm:"column:ipt_otp_no" json:"ipt_otp_no" form:"ipt_otp_no"`
741 741
 	Phone                  string  `gorm:"column:phone" json:"phone" form:"phone"`
742 742
 	SocialType             int64   `gorm:"column:social_type" json:"social_type" form:"social_type"`
743
+	IdCardType             int64   `gorm:"column:id_card_type" json:"id_card_type" form:"id_card_type"`
743 744
 }
744 745
 
745 746
 func (VMHisPatient) TableName() string {

+ 28 - 13
service/gdyb_service.go View File

@@ -85,7 +85,7 @@ func Gdyb1101(certNo string, org_name string, doctor string, fixmedins_code stri
85 85
 }
86 86
 
87 87
 // 门诊挂号
88
-func Gdyb2201(psnNo string, insutype string, certNo string, org_name string, doctor string, ipt_otp_no string, dept string, fixmedins_code string, dept_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
88
+func Gdyb2201(psnNo string, insutype string, certNo string, org_name string, doctor string, ipt_otp_no string, dept string, fixmedins_code string, dept_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64) string {
89 89
 	// 生成签名
90 90
 	nonce := GetRandomString(32)
91 91
 	timestamp := time.Now().Unix()
@@ -101,14 +101,22 @@ func Gdyb2201(psnNo string, insutype string, certNo string, org_name string, doc
101 101
 	inputData["psn_no"] = psnNo           // 人员编号 (来自1101接口返回)
102 102
 	inputData["insutype"] = insutype      // 险种类型(来自1101接口返回)
103 103
 	inputData["begntime"] = timeFormatOne // 开始时间
104
-	inputData["mdtrt_cert_type"] = "02"   // 就诊凭证类型
105
-	inputData["mdtrt_cert_no"] = certNo   // 就诊凭证编号
106
-	inputData["ipt_otp_no"] = ipt_otp_no  // 住院/门诊号
107
-	inputData["atddr_no"] = doctor_id     // 医师编码
108
-	inputData["dr_name"] = doctor         // 医师姓名
109
-	inputData["dept_code"] = dept_code    // 科室编码
110
-	inputData["dept_name"] = dept         // 科室名称
111
-	inputData["caty"] = "A03.06"          // 科别
104
+
105
+	if id_card_type == 1 {
106
+		inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
107
+		inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
108
+
109
+	} else if id_card_type == 2 {
110
+		inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
111
+		inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
112
+	}
113
+
114
+	inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
115
+	inputData["atddr_no"] = doctor_id    // 医师编码
116
+	inputData["dr_name"] = doctor        // 医师姓名
117
+	inputData["dept_code"] = dept_code   // 科室编码
118
+	inputData["dept_name"] = dept        // 科室名称
119
+	inputData["caty"] = "A03.06"         // 科别
112 120
 
113 121
 	input["data"] = inputData
114 122
 	inputMessage["input"] = input //交易输入
@@ -625,7 +633,7 @@ func Gdyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, ins
625 633
 }
626 634
 
627 635
 //  门诊结算
628
-func Gdyb2207(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, med_type string) string {
636
+func Gdyb2207(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, med_type string, id_card_type int64) string {
629 637
 	// 生成签名
630 638
 	nonce := GetRandomString(32)
631 639
 	timestamp := time.Now().Unix()
@@ -637,9 +645,16 @@ func Gdyb2207(psnNo string, mdtrtId string, chrgBchno string, certNo string, ins
637 645
 	inputData := make(map[string]interface{})
638 646
 	inputMessage["infno"] = "2207" // 交易编码
639 647
 
640
-	inputData["psn_no"] = psnNo         // 人员编号 (来自1101接口返回)
641
-	inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
642
-	inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
648
+	inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
649
+
650
+	if id_card_type == 1 {
651
+		inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
652
+		inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
653
+	} else if id_card_type == 2 {
654
+		inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
655
+		inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
656
+	}
657
+
643 658
 	inputData["med_type"] = med_type    // 医疗类别 11 普通门诊  12 门诊挂号
644 659
 	inputData["medfee_sumamt"] = total  // 医疗费总额
645 660
 	inputData["psn_setlway"] = "01"     // 个人结算方式 01 按项目结 02 按定额结算

+ 93 - 9
service/his_service.go View File

@@ -68,10 +68,89 @@ func (VMHisPrescriptionInfo) TableName() string {
68 68
 }
69 69
 
70 70
 type Patients struct {
71
-	ID        int64  `gorm:"column:id" json:"id" form:"id"`
72
-	UserOrgId int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
73
-	Name      string `gorm:"column:name" json:"name" form:"name"`
74
-	Status    int64  `gorm:"column:status" json:"status" form:"status"`
71
+	ID                           int64   `gorm:"column:id" json:"id" form:"id"`
72
+	UserOrgId                    int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
73
+	UserId                       int64   `gorm:"column:user_id" json:"user_id" form:"user_id"`
74
+	Avatar                       string  `gorm:"column:avatar" json:"avatar" form:"avatar"`
75
+	PatientType                  int64   `gorm:"column:patient_type" json:"patient_type" form:"patient_type"`
76
+	DialysisNo                   string  `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
77
+	AdmissionNumber              string  `gorm:"column:admission_number" json:"admission_number" form:"admission_number"`
78
+	Source                       int64   `gorm:"column:source" json:"source" form:"source"`
79
+	Lapseto                      int64   `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
80
+	PartitionId                  int64   `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
81
+	BedId                        int64   `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
82
+	Name                         string  `gorm:"column:name" json:"name" form:"name"`
83
+	Alias                        string  `gorm:"column:alias" json:"alias" form:"alias"`
84
+	Gender                       int64   `gorm:"column:gender" json:"gender" form:"gender"`
85
+	MaritalStatus                int64   `gorm:"column:marital_status" json:"marital_status" form:"marital_status"`
86
+	IdCardNo                     string  `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
87
+	Birthday                     int64   `gorm:"column:birthday" json:"birthday" form:"birthday"`
88
+	ReimbursementWayId           int64   `gorm:"column:reimbursement_way_id" json:"reimbursement_way_id" form:"reimbursement_way_id"`
89
+	HealthCareType               int64   `gorm:"column:health_care_type" json:"health_care_type" form:"health_care_type"`
90
+	HealthCareNo                 string  `gorm:"column:health_care_no" json:"health_care_no" form:"health_care_no"`
91
+	HealthCareDueDate            int64   `gorm:"column:health_care_due_date" json:"health_care_due_date" form:"health_care_due_date"`
92
+	Height                       int64   `gorm:"column:height" json:"height" form:"height"`
93
+	BloodType                    int64   `gorm:"column:blood_type" json:"blood_type" form:"blood_type"`
94
+	Rh                           int64   `gorm:"column:rh" json:"rh" form:"rh"`
95
+	HealthCareDueAlertDate       int64   `gorm:"column:health_care_due_alert_date" json:"health_care_due_alert_date" form:"health_care_due_alert_date"`
96
+	EducationLevel               int64   `gorm:"column:education_level" json:"education_level" form:"education_level"`
97
+	Profession                   int64   `gorm:"column:profession" json:"profession" form:"profession"`
98
+	Phone                        string  `gorm:"column:phone" json:"phone" form:"phone"`
99
+	HomeTelephone                string  `gorm:"column:home_telephone" json:"home_telephone" form:"home_telephone"`
100
+	RelativePhone                string  `gorm:"column:relative_phone" json:"relative_phone" form:"relative_phone"`
101
+	RelativeRelations            string  `gorm:"column:relative_relations" json:"relative_relations" form:"relative_relations"`
102
+	HomeAddress                  string  `gorm:"column:home_address" json:"home_address" form:"home_address"`
103
+	WorkUnit                     string  `gorm:"column:work_unit" json:"work_unit" form:"work_unit"`
104
+	UnitAddress                  string  `gorm:"column:unit_address" json:"unit_address" form:"unit_address"`
105
+	Children                     int64   `gorm:"column:children" json:"children" form:"children"`
106
+	ReceivingDate                int64   `gorm:"column:receiving_date" json:"receiving_date" form:"receiving_date"`
107
+	IsHospitalFirstDialysis      int64   `gorm:"column:is_hospital_first_dialysis" json:"is_hospital_first_dialysis" form:"is_hospital_first_dialysis"`
108
+	FirstDialysisDate            int64   `gorm:"column:first_dialysis_date" json:"first_dialysis_date" form:"first_dialysis_date"`
109
+	FirstDialysisHospital        string  `gorm:"column:first_dialysis_hospital" json:"first_dialysis_hospital" form:"first_dialysis_hospital"`
110
+	PredialysisCondition         string  `gorm:"column:predialysis_condition" json:"predialysis_condition" form:"predialysis_condition"`
111
+	PreHospitalDialysisFrequency string  `gorm:"column:pre_hospital_dialysis_frequency" json:"pre_hospital_dialysis_frequency" form:"pre_hospital_dialysis_frequency"`
112
+	PreHospitalDialysisTimes     int64   `gorm:"column:pre_hospital_dialysis_times" json:"pre_hospital_dialysis_times" form:"pre_hospital_dialysis_times"`
113
+	HospitalFirstDialysisDate    int64   `gorm:"column:hospital_first_dialysis_date" json:"hospital_first_dialysis_date" form:"hospital_first_dialysis_date"`
114
+	InductionPeriod              int64   `gorm:"column:induction_period" json:"induction_period" form:"induction_period"`
115
+	InitialDialysis              int64   `gorm:"column:initial_dialysis" json:"initial_dialysis" form:"initial_dialysis"`
116
+	TotalDialysis                int64   `gorm:"column:total_dialysis" json:"total_dialysis" form:"total_dialysis"`
117
+	AttendingDoctorId            int64   `gorm:"column:attending_doctor_id" json:"attending_doctor_id" form:"attending_doctor_id"`
118
+	HeadNurseId                  int64   `gorm:"column:head_nurse_id" json:"head_nurse_id" form:"head_nurse_id"`
119
+	Evaluate                     string  `gorm:"column:evaluate" json:"evaluate" form:"evaluate"`
120
+	Diagnose                     string  `gorm:"column:diagnose" json:"diagnose" form:"diagnose"`
121
+	Remark                       string  `gorm:"column:remark" json:"remark" form:"remark"`
122
+	RegistrarsId                 int64   `gorm:"column:registrars_id" json:"registrars_id" form:"registrars_id"`
123
+	Registrars                   string  `gorm:"column:registrars" json:"registrars" form:"registrars"`
124
+	QrCode                       string  `gorm:"column:qr_code" json:"qr_code" form:"qr_code"`
125
+	BindingState                 int64   `gorm:"column:binding_state" json:"binding_state" form:"binding_state"`
126
+	PatientComplains             string  `gorm:"column:patient_complains" json:"patient_complains" form:"patient_complains"`
127
+	PresentHistory               string  `gorm:"column:present_history" json:"present_history" form:"present_history"`
128
+	PastHistory                  string  `gorm:"column:past_history" json:"past_history" form:"past_history"`
129
+	Temperature                  float64 `gorm:"column:temperature" json:"temperature" form:"temperature"`
130
+	Pulse                        int64   `gorm:"column:pulse" json:"pulse" form:"pulse"`
131
+	Respiratory                  int64   `gorm:"column:respiratory" json:"respiratory" form:"respiratory"`
132
+	Sbp                          int64   `gorm:"column:sbp" json:"sbp" form:"sbp"`
133
+	Dbp                          int64   `gorm:"column:dbp" json:"dbp" form:"dbp"`
134
+	Status                       int64   `gorm:"column:status" json:"status" form:"status"`
135
+	CreatedTime                  int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
136
+	UpdatedTime                  int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
137
+	Nation                       string  `gorm:"column:nation" json:"nation" form:"nation"`
138
+	NativePlace                  string  `gorm:"column:native_place" json:"native_place" form:"native_place"`
139
+	Age                          int64   `gorm:"column:age" json:"age" form:"age"`
140
+	InfectiousNextRecordTime     int64   `gorm:"column:infectious_next_record_time" json:"infectious_next_record_time" form:"infectious_next_record_time"`
141
+	IsInfectious                 int64   `gorm:"column:is_infectious" json:"is_infectious" form:"is_infectious"`
142
+	IsOpenRemind                 int64   `gorm:"column:is_open_remind" json:"is_open_remind" form:"is_open_remind"`
143
+	RemindCycle                  int64   `gorm:"column:remind_cycle" json:"remind_cycle" form:"remind_cycle"`
144
+	ResponseResult               string  `gorm:"column:response_result" json:"response_result" form:"response_result"`
145
+	FirstTreatmentDate           int64   `gorm:"column:first_treatment_date" json:"first_treatment_date" form:"first_treatment_date"`
146
+	DialysisAge                  int64   `gorm:"column:dialysis_age" json:"dialysis_age" form:"dialysis_age"`
147
+	ExpenseKind                  int64   `gorm:"column:expense_kind" json:"expense_kind" form:"expense_kind"`
148
+	TellPhone                    string  `gorm:"column:tell_phone" json:"tell_phone" form:"tell_phone"`
149
+	ContactName                  string  `gorm:"column:contact_name" json:"contact_name" form:"contact_name"`
150
+	UserSysBeforeCount           int64   `gorm:"column:user_sys_before_count" json:"user_sys_before_count" form:"user_sys_before_count"`
151
+	IsExcelExport                int64   `gorm:"column:is_excel_export" json:"is_excel_export" form:"is_excel_export"`
152
+	SchRemark                    string  `gorm:"column:sch_remark" json:"sch_remark" form:"sch_remark"`
153
+	OutReason                    string  `gorm:"column:out_reason" json:"out_reason" form:"out_reason"`
75 154
 }
76 155
 
77 156
 func (Patients) TableName() string {
@@ -439,11 +518,6 @@ func UpDatePrescriptionNumber(user_org_id int64, ids []int64, number string) (er
439 518
 	return
440 519
 }
441 520
 
442
-func UpDateAddtionNumber(user_org_id int64, ids []int64, number string) (err error) {
443
-	err = writeDb.Model(&models.HisAdditionalCharge{}).Where("user_org_id = ? AND status = 1 AND id in (?)", user_org_id, ids).Updates(map[string]interface{}{"batch_number": number, "mtime": time.Now().Unix()}).Error
444
-	return
445
-}
446
-
447 521
 func UpDatePrescriptionInfoNumber(user_org_id int64, id int64, number string, record_time int64) (err error) {
448 522
 	err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND patient_id = ? AND record_date = ?", user_org_id, id, record_time).Updates(map[string]interface{}{"batch_number": number, "prescription_status": 3, "mtime": time.Now().Unix()}).Error
449 523
 
@@ -847,3 +921,13 @@ func GetMonthHisPrescription(org_id int64, patient_id int64, start_time int64, e
847 921
 		Find(&prescription).Error
848 922
 	return
849 923
 }
924
+
925
+func GetPatientByNumber(number string, user_org_id int64) (patient Patients, err error) {
926
+	err = readDb.Model(&Patients{}).Where("health_care_no = ? AND user_org_id = ?", number, user_org_id).First(&patient).Error
927
+	return
928
+}
929
+
930
+func GetPatientByIDCard(id_card_no string, user_org_id int64) (patient Patients, err error) {
931
+	err = readDb.Model(&Patients{}).Where("id_card_no = ? AND user_org_id = ?", id_card_no, user_org_id).First(&patient).Error
932
+	return
933
+}