Browse Source

Merge branch 'master' of http://git.shengws.com/csx/gdyb

XMLWAN 4 years ago
parent
commit
8c8ef20498
3 changed files with 583 additions and 41 deletions
  1. 574 40
      controllers/sz/sz_his_api_controller.go
  2. 4 0
      enums/error_code.go
  3. 5 1
      service/sz_his_service.go

+ 574 - 40
controllers/sz/sz_his_api_controller.go View File

@@ -277,6 +277,11 @@ func SZHisManagerApiRegistRouters() {
277 277
 
278 278
 	//退费
279 279
 	beego.Router("/sz/api/refund/get", &SZHisApiController{}, "get:Refund")
280
+
281
+	beego.Router("/sz/api/readcard", &SZHisApiController{}, "get:ReadCard")
282
+
283
+	beego.Router("sz/api/refundnumber/get", &SZHisApiController{}, "get:RefundNumber")
284
+
280 285
 	beego.Router("/sz/api/monthrefund/get", &SZHisApiController{}, "get:MonthRefund")
281 286
 	//查询交易
282 287
 	beego.Router("/sz/api/settle/query", &SZHisApiController{}, "get:GetSettleAccounts")
@@ -323,6 +328,40 @@ type Custom struct {
323 328
 	ItemId           int64
324 329
 }
325 330
 
331
+func (c *SZHisApiController) ReadCard() {
332
+	id_card_type, _ := c.GetInt64("id_card_type")
333
+	adminInfo := c.GetAdminUserInfo()
334
+	if id_card_type != 1 {
335
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorNoReadCardException)
336
+		return
337
+	}
338
+	month := time.Unix(1557042972, 0).Format("1")
339
+	year := time.Now().Format("2006")
340
+	month = time.Now().Format("01")
341
+	day := time.Now().Format("02")
342
+
343
+	miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
344
+	number := miConfig.Code + year + month + day +
345
+		fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
346
+	id_card_number, health_card_no, _, ret4 := ReadBasCard("MZ002" + "|" + number + "|" + miConfig.Code + "|")
347
+	if ret4 == 0 {
348
+		patient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
349
+		if patient.ID == 0 {
350
+			patient.HealthCareNo = health_card_no
351
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
352
+			return
353
+		} else {
354
+			c.ServeSuccessJSON(map[string]interface{}{
355
+				"patient": patient,
356
+			})
357
+		}
358
+	} else {
359
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
360
+		return
361
+	}
362
+
363
+}
364
+
326 365
 //获取读卡信息 -- 门诊挂号
327 366
 //func (c *SZHisApiController) GetRegisterInfo() {
328 367
 //	adminInfo := c.GetAdminUserInfo()
@@ -717,6 +756,480 @@ type Custom struct {
717 756
 //		return
718 757
 //	}
719 758
 //}
759
+func (c *SZHisApiController) GetRegisterInfo() {
760
+	adminInfo := c.GetAdminUserInfo()
761
+	admin_user_id, _ := c.GetInt64("admin_user_id")
762
+	patient_id, _ := c.GetInt64("id")
763
+	record_time := c.GetString("record_time")
764
+	settlementValue, _ := c.GetInt64("settlement_value")
765
+	medical_insurance_card := c.GetString("medical_insurance_card")
766
+	name := c.GetString("name")
767
+	id_card_type, _ := c.GetInt64("id_card_type")
768
+	certificates, _ := c.GetInt64("certificates")
769
+	medical_care, _ := c.GetInt64("medical_care")
770
+	birthday := c.GetString("birthday")
771
+	id_card := c.GetString("id_card")
772
+	register_type, _ := c.GetInt64("register")
773
+	doctor, _ := c.GetInt64("doctor")
774
+	department, _ := c.GetInt64("department")
775
+	gender, _ := c.GetInt64("sex")
776
+	registration_fee, _ := c.GetFloat("registration_fee")
777
+	medical_expenses, _ := c.GetFloat("medical_expenses")
778
+	social_type, _ := c.GetInt64("social_type")
779
+
780
+	is_yidi, _ := c.GetInt64("is_yidi")
781
+
782
+	timeLayout := "2006-01-02"
783
+	loc, _ := time.LoadLocation("Local")
784
+	birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
785
+	birthUnix := birthdays.Unix()
786
+
787
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
788
+	if err != nil {
789
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
790
+		return
791
+	}
792
+
793
+	var patient service.Patients
794
+	if patient_id == 0 {
795
+		patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
796
+	} else {
797
+		patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, patient_id)
798
+	}
799
+
800
+	miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
801
+	if patient.ID == 0 {
802
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
803
+		return
804
+	}
805
+	if len(patient.IdCardNo) == 0 {
806
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
807
+		return
808
+	}
809
+
810
+	adminRole, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
811
+	his, _ := service.GetHisPatientInfo(adminInfo.CurrentOrgId, patient_id, theTime.Unix())
812
+
813
+	var custom_code string
814
+	var custom_project_name string
815
+	var allPrice float64
816
+
817
+	switch register_type {
818
+	case 1:
819
+		custom_code = "110100002"
820
+		custom_project_name = "普通门诊"
821
+		allPrice = 10
822
+		break
823
+	case 3:
824
+		custom_code = "110200002-2"
825
+		custom_project_name = "主任医师"
826
+		allPrice = 10
827
+
828
+		break
829
+	case 2:
830
+		custom_code = "110200002-3"
831
+		custom_project_name = "副主任医师"
832
+		allPrice = 10
833
+
834
+		break
835
+	case 4:
836
+		custom_code = "0"
837
+		custom_project_name = "免受诊金"
838
+		allPrice = 0
839
+		break
840
+	case 5:
841
+		custom_code = "110200002-1"
842
+		custom_project_name = "专家"
843
+		allPrice = 10
844
+
845
+		break
846
+	}
847
+
848
+	if his.ID == 0 {
849
+
850
+		var doctor_name string
851
+		var doctor_code string
852
+		if adminRole.ID == 0 {
853
+
854
+			doctor_name = "管理员"
855
+			doctor_code = "01"
856
+
857
+		} else {
858
+			doctor_name = adminRole.UserName
859
+			doctor_code = strconv.FormatInt(admin_user_id, 10)
860
+
861
+		}
862
+		month := time.Unix(1557042972, 0).Format("1")
863
+		year := time.Now().Format("2006")
864
+		month = time.Now().Format("01")
865
+		day := time.Now().Format("02")
866
+
867
+		//流水号
868
+		//
869
+		number := miConfig.Code + year + month + day +
870
+			fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
871
+		mz_number := miConfig.Code + year + month + day +
872
+			fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000))
873
+		//1.判断读卡类型
874
+		//2.读卡 获取交易验证码,医疗证号,发卡地区行政区划代码
875
+		yiliao_number, id_card_number, verifyCode, version_code, _, ret4 := ReadBasCardGetNumber("MZ002" + "|" + number + "|" + miConfig.Code + "|")
876
+		fmt.Println(yiliao_number)
877
+		fmt.Println(id_card_number)
878
+		fmt.Println(verifyCode)
879
+		fmt.Println(version_code)
880
+		fmt.Println(ret4)
881
+
882
+		dept_code := "0306"
883
+		is_yidi = 1
884
+		tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
885
+		//根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
886
+		fmt.Println(tempPatient.ID)
887
+		fmt.Println(patient_id)
888
+
889
+		if tempPatient.ID == patient_id {
890
+			if ret4 == 0 { //本地卡流程
891
+				if is_yidi == 1 {
892
+					//本地就医流程
893
+					//挂号
894
+					resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, dept_code, yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice, medical_care)
895
+					var dat map[string]interface{}
896
+					if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
897
+						fmt.Println(dat)
898
+					} else {
899
+						fmt.Println(err)
900
+					}
901
+					userJSONBytes, _ := json.Marshal(dat)
902
+					var res ResultOne
903
+					if err := json.Unmarshal(userJSONBytes, &res); err != nil {
904
+						utils.ErrorLog("解析失败:%v", err)
905
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
906
+						return
907
+					}
908
+					if res.Transreturncode == "00000000" {
909
+						his := models.VMHisPatient{
910
+							Name:                   name,
911
+							Gender:                 gender,
912
+							Birthday:               birthUnix,
913
+							MedicalTreatmentType:   medical_care,
914
+							IdType:                 certificates,
915
+							IdCardNo:               id_card,
916
+							BalanceAccountsType:    settlementValue,
917
+							SocialType:             social_type,
918
+							MedicalInsuranceNumber: medical_insurance_card,
919
+							RegisterType:           register_type,
920
+							RegisterCost:           registration_fee,
921
+							TreatmentCost:          medical_expenses,
922
+							Status:                 1,
923
+							Ctime:                  time.Now().Unix(),
924
+							Mtime:                  time.Now().Unix(),
925
+							Iinfo:                  resp_result,
926
+							PatientId:              patient.ID,
927
+							RecordDate:             theTime.Unix(),
928
+							UserOrgId:              adminInfo.CurrentOrgId,
929
+							AdminUserId:            admin_user_id,
930
+							IsReturn:               1,
931
+							IdCardType:             id_card_type,
932
+							Doctor:                 doctor,
933
+							Departments:            department,
934
+							YiliaoNumber:           yiliao_number,
935
+							MzNumber:               number,
936
+							Number:                 mz_number,
937
+						}
938
+						service.CreateHisPatientTwo(&his)
939
+						c.ServeSuccessJSON(map[string]interface{}{
940
+							"msg": "挂号成功",
941
+						})
942
+					} else {
943
+						c.ServeSuccessJSON(map[string]interface{}{
944
+							"failed_code": -10,
945
+							"msg":         res.Transreturnmessage,
946
+						})
947
+						return
948
+					}
949
+
950
+				} else {
951
+					//异地就医流程
952
+					//异地走鉴权流程
953
+					//authResult := CardAuth(number)
954
+					//fmt.Println(authResult)
955
+
956
+					//tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
957
+					//if tempPatient.ID == patient_id {
958
+					resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice, medical_care)
959
+					var dat map[string]interface{}
960
+					if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
961
+						fmt.Println(dat)
962
+					} else {
963
+						fmt.Println(err)
964
+					}
965
+
966
+					userJSONBytes, _ := json.Marshal(dat)
967
+
968
+					var res ResultOne
969
+					if err := json.Unmarshal(userJSONBytes, &res); err != nil {
970
+						utils.ErrorLog("解析失败:%v", err)
971
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
972
+						return
973
+					}
974
+					if res.Transreturncode == "00000000" {
975
+						his := models.VMHisPatient{
976
+							Name:                   name,
977
+							Gender:                 gender,
978
+							Birthday:               birthUnix,
979
+							MedicalTreatmentType:   medical_care,
980
+							IdType:                 certificates,
981
+							IdCardNo:               id_card,
982
+							BalanceAccountsType:    settlementValue,
983
+							SocialType:             social_type,
984
+							MedicalInsuranceNumber: medical_insurance_card,
985
+							RegisterType:           register_type,
986
+							RegisterCost:           registration_fee,
987
+							TreatmentCost:          medical_expenses,
988
+							Status:                 1,
989
+							Ctime:                  time.Now().Unix(),
990
+							Mtime:                  time.Now().Unix(),
991
+							Iinfo:                  resp_result,
992
+							PatientId:              patient.ID,
993
+							RecordDate:             theTime.Unix(),
994
+							UserOrgId:              adminInfo.CurrentOrgId,
995
+							AdminUserId:            admin_user_id,
996
+							IsReturn:               1,
997
+							IdCardType:             id_card_type,
998
+							Doctor:                 doctor,
999
+							Departments:            department,
1000
+							YiliaoNumber:           yiliao_number,
1001
+							MzNumber:               number,
1002
+							Number:                 mz_number,
1003
+						}
1004
+						service.CreateHisPatientTwo(&his)
1005
+						c.ServeSuccessJSON(map[string]interface{}{
1006
+							"msg": "挂号成功",
1007
+						})
1008
+					} else {
1009
+						c.ServeSuccessJSON(map[string]interface{}{
1010
+							"failed_code": -10,
1011
+							"msg":         res.Transreturnmessage,
1012
+						})
1013
+						return
1014
+					}
1015
+
1016
+				}
1017
+
1018
+			} else { //异地卡流程
1019
+				//readCardBasResult := ReadCardBasHSM(number)
1020
+				//fmt.Println(readCardBasResult)
1021
+				//是否异地就医,是的话走鉴权流程,不是的话走门诊挂号
1022
+				if is_yidi == 1 { //1本地就医
1023
+					resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice, medical_care)
1024
+					var dat map[string]interface{}
1025
+					if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
1026
+						fmt.Println(dat)
1027
+					} else {
1028
+						fmt.Println(err)
1029
+					}
1030
+
1031
+					userJSONBytes, _ := json.Marshal(dat)
1032
+
1033
+					var res ResultOne
1034
+					if err := json.Unmarshal(userJSONBytes, &res); err != nil {
1035
+						utils.ErrorLog("解析失败:%v", err)
1036
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1037
+						return
1038
+					}
1039
+					if res.Transreturncode == "00000000" {
1040
+						his := models.VMHisPatient{
1041
+							Name:                   name,
1042
+							Gender:                 gender,
1043
+							Birthday:               birthUnix,
1044
+							MedicalTreatmentType:   medical_care,
1045
+							IdType:                 certificates,
1046
+							IdCardNo:               id_card,
1047
+							BalanceAccountsType:    settlementValue,
1048
+							SocialType:             social_type,
1049
+							MedicalInsuranceNumber: medical_insurance_card,
1050
+							RegisterType:           register_type,
1051
+							RegisterCost:           registration_fee,
1052
+							TreatmentCost:          medical_expenses,
1053
+							Status:                 1,
1054
+							Ctime:                  time.Now().Unix(),
1055
+							Mtime:                  time.Now().Unix(),
1056
+							Iinfo:                  resp_result,
1057
+							PatientId:              patient.ID,
1058
+							RecordDate:             theTime.Unix(),
1059
+							UserOrgId:              adminInfo.CurrentOrgId,
1060
+							AdminUserId:            admin_user_id,
1061
+							IsReturn:               1,
1062
+							IdCardType:             id_card_type,
1063
+							Doctor:                 doctor,
1064
+							Departments:            department,
1065
+							YiliaoNumber:           yiliao_number,
1066
+							MzNumber:               number,
1067
+							Number:                 mz_number,
1068
+						}
1069
+						service.CreateHisPatientTwo(&his)
1070
+						c.ServeSuccessJSON(map[string]interface{}{
1071
+							"msg": "挂号成功",
1072
+						})
1073
+					} else {
1074
+						c.ServeSuccessJSON(map[string]interface{}{
1075
+							"failed_code": -10,
1076
+							"msg":         res.Transreturnmessage,
1077
+						})
1078
+						return
1079
+					}
1080
+
1081
+				} else { //异地就医需要走鉴权流程
1082
+					//authResult := CardAuth(number)
1083
+					//fmt.Println(authResult)
1084
+					resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice, medical_care)
1085
+					var dat map[string]interface{}
1086
+					if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
1087
+						fmt.Println(dat)
1088
+					} else {
1089
+						fmt.Println(err)
1090
+					}
1091
+
1092
+					userJSONBytes, _ := json.Marshal(dat)
1093
+
1094
+					var res ResultOne
1095
+					if err := json.Unmarshal(userJSONBytes, &res); err != nil {
1096
+						utils.ErrorLog("解析失败:%v", err)
1097
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1098
+						return
1099
+					}
1100
+					if res.Transreturncode == "00000000" {
1101
+						his := models.VMHisPatient{
1102
+							Name:                   name,
1103
+							Gender:                 gender,
1104
+							Birthday:               birthUnix,
1105
+							MedicalTreatmentType:   medical_care,
1106
+							IdType:                 certificates,
1107
+							IdCardNo:               id_card,
1108
+							BalanceAccountsType:    settlementValue,
1109
+							SocialType:             social_type,
1110
+							MedicalInsuranceNumber: medical_insurance_card,
1111
+							RegisterType:           register_type,
1112
+							RegisterCost:           registration_fee,
1113
+							TreatmentCost:          medical_expenses,
1114
+							Status:                 1,
1115
+							Ctime:                  time.Now().Unix(),
1116
+							Mtime:                  time.Now().Unix(),
1117
+							Iinfo:                  resp_result,
1118
+							PatientId:              patient.ID,
1119
+							RecordDate:             theTime.Unix(),
1120
+							UserOrgId:              adminInfo.CurrentOrgId,
1121
+							AdminUserId:            admin_user_id,
1122
+							IsReturn:               1,
1123
+							IdCardType:             id_card_type,
1124
+							Doctor:                 doctor,
1125
+							Departments:            department,
1126
+							YiliaoNumber:           yiliao_number,
1127
+							MzNumber:               number,
1128
+							Number:                 mz_number,
1129
+						}
1130
+						service.CreateHisPatientTwo(&his)
1131
+						c.ServeSuccessJSON(map[string]interface{}{
1132
+							"msg": "挂号成功",
1133
+						})
1134
+					} else {
1135
+						c.ServeSuccessJSON(map[string]interface{}{
1136
+							"failed_code": -10,
1137
+							"msg":         res.Transreturnmessage,
1138
+						})
1139
+						return
1140
+					}
1141
+
1142
+				}
1143
+			}
1144
+		} else {
1145
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
1146
+			return
1147
+		}
1148
+	} else {
1149
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
1150
+		return
1151
+	}
1152
+}
1153
+
1154
+func (c *SZHisApiController) RefundNumber() {
1155
+	order_id, _ := c.GetInt64("order_id")
1156
+	record_time := c.GetString("record_time")
1157
+	patient_id, _ := c.GetInt64("patient_id")
1158
+	admin_user_id, _ := c.GetInt64("admin_user_id")
1159
+	timeLayout := "2006-01-02"
1160
+	loc, _ := time.LoadLocation("Local")
1161
+	adminUser := c.GetAdminUserInfo()
1162
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
1163
+	fmt.Println(err)
1164
+	if err != nil {
1165
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1166
+		return
1167
+	}
1168
+	recordDateTime := theTime.Unix()
1169
+	fmt.Println(recordDateTime)
1170
+	var order models.HisOrder
1171
+	order, _ = service.GetHisOrderByID(order_id)
1172
+	if order.ID == 0 {
1173
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
1174
+		return
1175
+	}
1176
+	his, _ := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, theTime.Unix())
1177
+	roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
1178
+	miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
1179
+	//结算流程
1180
+	var doctor_name string
1181
+	var doctor_code string
1182
+	if roles.ID == 0 {
1183
+		doctor_name = "管理员"
1184
+		doctor_code = "01"
1185
+	} else {
1186
+		doctor_name = roles.UserName
1187
+		doctor_code = strconv.FormatInt(admin_user_id, 10)
1188
+
1189
+	}
1190
+	month := time.Unix(1557042972, 0).Format("1")
1191
+	year := time.Now().Format("2006")
1192
+	month = time.Now().Format("01")
1193
+	day := time.Now().Format("02")
1194
+	//number := miConfig.Code  + year + month + day + "1367866"
1195
+	number := miConfig.Code + year + month + day +
1196
+		fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
1197
+	//number := miConfig.Code + year + month + day + "1590003"
1198
+
1199
+	//流水号
1200
+	//number_two := miConfig.Code + "-" + year + month + day + "-" + strconv.FormatInt(patient_id, 10)
1201
+	verifyCode, version_code := ReadCardGetCode("JY002" + "|" + number + "|" + miConfig.Code)
1202
+	config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
1203
+	if config.IsOpen == 1 { //对接了医保,走医保流程
1204
+		result := service.SzybJY002(doctor_name, doctor_code, miConfig.Code, his.MzNumber, order.Number, verifyCode, number, version_code)
1205
+		var dat map[string]interface{}
1206
+		if err := json.Unmarshal([]byte(result), &dat); err == nil {
1207
+			fmt.Println(dat)
1208
+		} else {
1209
+			fmt.Println(err)
1210
+		}
1211
+		userJSONBytes, _ := json.Marshal(dat)
1212
+		var res ResultThree
1213
+		if err := json.Unmarshal(userJSONBytes, &res); err != nil {
1214
+			utils.ErrorLog("解析失败:%v", err)
1215
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1216
+			return
1217
+		}
1218
+		if res.Transreturncode == "00000000" {
1219
+			service.UpdataHisStatusSZ(adminUser.CurrentOrgId, his.MzNumber, his.Number, result)
1220
+			c.ServeSuccessJSON(map[string]interface{}{
1221
+				"msg": "退号成功",
1222
+			})
1223
+		} else {
1224
+			c.ServeSuccessJSON(map[string]interface{}{
1225
+				"failed_code": -10,
1226
+				"msg":         res.Transreturnmessage,
1227
+			})
1228
+
1229
+		}
1230
+	}
1231
+
1232
+}
720 1233
 //func (c *SZHisApiController) GetRegisterInfo() {
721 1234
 //	adminInfo := c.GetAdminUserInfo()
722 1235
 //	admin_user_id, _ := c.GetInt64("admin_user_id")
@@ -2571,7 +3084,7 @@ func ReadCardGetCode(request string) (string, string) {
2571 3084
 	return "", ""
2572 3085
 }
2573 3086
 
2574
-////读卡
3087
+////获取卡信息
2575 3088
 func ReadBasCardGetNumber(request string) (string, string, string, string, error, int64) {
2576 3089
 	DllDef2 := syscall.MustLoadDLL("SSCardDriver_SZ.dll")
2577 3090
 	readCards := DllDef2.MustFindProc("iReadCardBas")
@@ -2598,6 +3111,27 @@ func ReadBasCardGetNumber(request string) (string, string, string, string, error
2598 3111
 	return "", "", "", "", err, -10
2599 3112
 }
2600 3113
 
3114
+//读卡
3115
+func ReadBasCard(request string) (string, string, error, int64) {
3116
+	DllDef2 := syscall.MustLoadDLL("SSCardDriver_SZ.dll")
3117
+	readCards := DllDef2.MustFindProc("iReadCardBas")
3118
+	str := request
3119
+	str3 := make([]byte, 1024)
3120
+	ret4, _, err := readCards.Call(IntPtr(1), StrPtr(str), (uintptr)(unsafe.Pointer(&str3[0])))
3121
+	fmt.Println(":", string(str3))
3122
+	fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
3123
+	if ret4 == 0 {
3124
+		result := string(str3)
3125
+		result_arr := strings.Split(result, "|")
3126
+		//根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
3127
+		id_card_number := result_arr[1]
3128
+		health_card_no := result_arr[2]
3129
+
3130
+		return id_card_number, health_card_no, err, 0
3131
+	}
3132
+	return "", "", err, -10
3133
+}
3134
+
2601 3135
 //
2602 3136
 ////iReadCardBas_HSM_Step1 ---- 1903 iCardInnerAuthentication ---  	iReadCardBas_HSM_Step2
2603 3137
 //func ReadCardBasHSM(number string) string {
@@ -3488,6 +4022,43 @@ func (c *SZHisApiController) GetMedicalList() {
3488 4022
 				StartTime:                               20201010,                                                            //开始日期
3489 4023
 				StaffCode:                               "",                                                                  //医护人员编码
3490 4024
 				EndTime:                                 0,                                                                   // 结束日期
4025
+				UserName:                     item.UserName,
4026
+				RoleId:                       item.Name,
4027
+				Sex:                          sex,
4028
+				CardType:                     card_type,
4029
+				IdCard:                       item.IdCard,
4030
+				Phone:                        item.Mobile,
4031
+				WorkMajorName:                item.WorkMajorName,
4032
+				Nation:                       item.Nation,
4033
+				BirthDay:                     20201022,
4034
+				WorkTime:                     12,
4035
+				Education:                    strconv.FormatInt(item.Education, 10),
4036
+				StudyMajorName:               item.StudyMajorName,
4037
+				CertificateCode:              "",                                           //证书编码
4038
+				MedicalCode:                  item.MedicalCode,                             //医师资格编码
4039
+				MedicalRangeCode:             strconv.FormatInt(item.MedicalRangeCode, 10), //医师执业范围代码
4040
+				MedicalLevel:                 strconv.FormatInt(item.MedicalLevel, 10),     //医生级别
4041
+				TypeJob:                      strconv.FormatInt(item.DoctorTypeJob, 10),    //职业类别
4042
+				DoctorNumber:                 item.DoctorNumber,                            //医师编号
4043
+				Licensing:                    strconv.FormatInt(item.Licensing, 10),        //职业标志
4044
+				DoctorServiceStatus:          "",                                           //医师医保服务资格状态
4045
+				MonitoringLevel:              "",                                           //监控等级
4046
+				DrugPsychotropicSubstances:   "",                                           //毒麻精神药品资格
4047
+				HealthCareCode:               "",                                           // 母婴保健技术考核合格证书编号
4048
+				PlanningTechnicalServiceCode: "",                                           //计划生育技术服务人员合格证编号
4049
+				PharmacistType:               "",                                           //药师类别
4050
+				PharmacistPracticeCategory:   "",                                           //药师执业类别
4051
+				PharmacistsLicensing:         "",                                           //药师执业范围
4052
+				PharmacistRegistrationNumber: item.PharmacistRegistrationNumber,            //执业药师注册证编号
4053
+				OfficeCode:                   "",                                           //科室编码
4054
+				JobNumber:                    item.JobNumber,                               //工号
4055
+				PostName:                     "",                                           //职位名称
4056
+				TechnicalJobLevelCode:        "",                                           //专业技术职务级别编码
4057
+				IsActive:                     is_active,                                    //在职与否
4058
+				PrescriptionQualificationIdentification: item.PharmacistRegistrationNumber, //处方资格标识
4059
+				IdentificationOutpatients:               "",                                //门诊大病医师标识
4060
+				OutpatientIllnessCategory:               item.OutpatientIllnessCategory,    //门诊大病类别
4061
+				StartTime:                               20201012,                          //开始日期
3491 4062
 			}
3492 4063
 			result := service.SzybYS001(doctor_name, doctor_code, miConfig.Code, detail)
3493 4064
 			fmt.Println("reuslt9999999999999999", result)
@@ -3588,45 +4159,8 @@ func (c *SZHisApiController) GetMedicalList() {
3588 4159
 				StartTime:                               20201010,                                                            //开始日期
3589 4160
 				StaffCode:                               "",                                                                  //医护人员编码
3590 4161
 				EndTime:                                 0,                                                                   // 结束日期
3591
-				StaffCode:                               "H27224269",
3592
-				UserName:                                item.UserName,
3593
-				RoleId:                                  item.Name,
3594
-				Sex:                                     "1",
3595
-				CardType:                                "01",
3596
-				IdCard:                                  "430526199408156511",
3597
-				Phone:                                   "13318464642",
3598
-				WorkMajorName:                           "医生",
3599
-				Nation:                                  "01",
3600
-				BirthDay:                                20201022,
3601
-				WorkTime:                                20201022,
3602
-				Education:                               "21",
3603
-				StudyMajorName:                          "医生",
3604
-				CertificateCode:                         "y2222222", //证书编码
3605
-				MedicalCode:                             "y2222222", //医师资格编码
3606
-				MedicalRangeCode:                        "101",      //医师执业范围代码
3607
-				MedicalLevel:                            "1",        //医生级别
3608
-				TypeJob:                                 "1",        //职业类别
3609
-				DoctorNumber:                            "22222",    //医师编号b
3610
-				Licensing:                               "1",        //职业标志
3611
-				DoctorServiceStatus:                     "1",        //医师医保服务资格状态
3612
-				MonitoringLevel:                         "1",        //监控等级
3613
-				DrugPsychotropicSubstances:              "1",        //毒麻精神药品资格
3614
-				HealthCareCode:                          "1001",     // 母婴保健技术考核合格证书编号
3615
-				PlanningTechnicalServiceCode:            "1002",     //计划生育技术服务人员合格证编号
3616
-				PharmacistType:                          "1",        //药师类别
3617
-				PharmacistPracticeCategory:              "1",        //药师执业类别
3618
-				PharmacistsLicensing:                    "1",        //药师执业范围
3619
-				PharmacistRegistrationNumber:            "000200",   //执业药师注册证编号
3620
-				OfficeCode:                              "9933",     //科室编码
3621
-				JobNumber:                               "82021344", //工号
3622
-				PostName:                                "主任",       //职位名称
3623
-				TechnicalJobLevelCode:                   "231",      //专业技术职务级别编码
3624
-				IsActive:                                "1",        //在职与否
3625
-				PrescriptionQualificationIdentification: "1",        //处方资格标识
3626
-				IdentificationOutpatients:               "1",        //门诊大病医师标识
3627
-				OutpatientIllnessCategory:               "血友病",      //门诊大病类别
3628
-				StartTime:                               20210311,   //开始日期
3629
-
4162
+				StaffCode:                    "H27224269",
4163
+			                         20210311,   //开始日期
3630 4164
 			}
3631 4165
 			result := service.SzybYS002(doctor_name, doctor_code, miConfig.Code, detail)
3632 4166
 			fmt.Println("reuslt9999999999999999", result)

+ 4 - 0
enums/error_code.go View File

@@ -243,6 +243,8 @@ const ( // ErrorCode
243 243
 	ErrorDrugPreSettleFaildParamWrong = 30002
244 244
 	ErrorDrugReturnFaildParamWrong    = 30003
245 245
 	ErrorDoctorLoginFaildParamWrong   = 30004
246
+
247
+	ErrorNoReadCardException = 30005
246 248
 )
247 249
 
248 250
 var ErrCodeMsgs = map[int]string{
@@ -468,6 +470,8 @@ var ErrCodeMsgs = map[int]string{
468 470
 	ErrorDrugPreSettleFaildParamWrong:  "备案失败",
469 471
 	ErrorDrugReturnFaildParamWrong:     "撤销失败",
470 472
 	ErrorDoctorLoginFaildParamWrong:    "登记失败",
473
+
474
+	ErrorNoReadCardException: "无法读取除社保卡以外的卡",
471 475
 }
472 476
 
473 477
 type SGJError struct {

+ 5 - 1
service/sz_his_service.go View File

@@ -1373,12 +1373,16 @@ func UpdataOrderStatusSZ(id int64, number string, user_org_id int64, his_mz_numb
1373 1373
 	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
1374 1374
 	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
1375 1375
 	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
1376
-	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
1377 1376
 
1378 1377
 	return
1379 1378
 
1380 1379
 }
1381 1380
 
1381
+func UpdataHisStatusSZ(user_org_id int64, his_mz_number string, his_number string, result string) (err error) {
1382
+	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(), "refund_detail": result}).Error
1383
+	return
1384
+}
1385
+
1382 1386
 func UpdataOrderlog(id int64, user_org_id int64, refund_log string) (err error) {
1383 1387
 	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
1384 1388