浏览代码

Merge branch '20201014_xt_api_new_branch' of http://git.shengws.com/csx/XT_New into 20201014_xt_api_new_branch

XMLWAN 4 年前
父节点
当前提交
10c0de484d
共有 2 个文件被更改,包括 74 次插入209 次删除
  1. 56 208
      controllers/his_api_controller.go
  2. 18 1
      service/his_service.go

+ 56 - 208
controllers/his_api_controller.go 查看文件

142
 	patients, _ := service.GetScheduleHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
142
 	patients, _ := service.GetScheduleHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
143
 	patients_two, _ := service.GetHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
143
 	patients_two, _ := service.GetHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
144
 	patients = append(patients, patients_two...)
144
 	patients = append(patients, patients_two...)
145
+	patients = RemoveRepeatedPatient(patients)
145
 
146
 
146
 	var total_one int64
147
 	var total_one int64
147
 	var total_two int64
148
 	var total_two int64
244
 	case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.CurrentOrgId, patient_id, recordDateTime)
245
 	case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.CurrentOrgId, patient_id, recordDateTime)
245
 	patientPrescriptionInfo, _ := service.FindPatientPrescriptionInfo(admin.CurrentOrgId, patient_id, recordDateTime)
246
 	patientPrescriptionInfo, _ := service.FindPatientPrescriptionInfo(admin.CurrentOrgId, patient_id, recordDateTime)
246
 	order, _ := service.GetHisOrder(admin.CurrentOrgId, number, patient_id)
247
 	order, _ := service.GetHisOrder(admin.CurrentOrgId, number, patient_id)
248
+
249
+	doctors, _ := service.GetHisAdminUserDoctors(admin.CurrentOrgId)
250
+	//获取所有科室信息
251
+	department, _ := service.GetAllDepartMent(admin.CurrentOrgId)
252
+
247
 	c.ServeSuccessJSON(map[string]interface{}{
253
 	c.ServeSuccessJSON(map[string]interface{}{
248
 		"his_info":            his_patient_info,
254
 		"his_info":            his_patient_info,
249
 		"xt_info":             xt_patient_info,
255
 		"xt_info":             xt_patient_info,
252
 		"info":                patientPrescriptionInfo,
258
 		"info":                patientPrescriptionInfo,
253
 		"month_prescriptions": monthPrescriptions,
259
 		"month_prescriptions": monthPrescriptions,
254
 		"order":               order,
260
 		"order":               order,
261
+		"doctors":             doctors,
262
+		"department":          department,
255
 	})
263
 	})
256
 	return
264
 	return
257
 
265
 
2007
 func (c *HisApiController) GetRegisterInfo() {
2015
 func (c *HisApiController) GetRegisterInfo() {
2008
 	id, _ := c.GetInt64("id")
2016
 	id, _ := c.GetInt64("id")
2009
 	record_time := c.GetString("record_time")
2017
 	record_time := c.GetString("record_time")
2010
-
2018
+	settlementValue, _ := c.GetInt64("settlement_value")
2019
+	medical_insurance_card := c.GetString("medical_insurance_card")
2011
 	name := c.GetString("name")
2020
 	name := c.GetString("name")
2012
-	gender, _ := c.GetInt64("gender")
2013
-	age, _ := c.GetInt64("age")
2021
+	id_card_type, _ := c.GetInt64("id_card_type")
2022
+	certificates, _ := c.GetInt64("certificates")
2023
+	medical_care, _ := c.GetInt64("medical_care")
2014
 	birthday := c.GetString("birthday")
2024
 	birthday := c.GetString("birthday")
2025
+	age, _ := c.GetInt64("age")
2026
+	id_card := c.GetString("idCard")
2027
+	register_type, _ := c.GetInt64("register")
2028
+	doctor, _ := c.GetInt64("doctor")
2029
+	department, _ := c.GetInt64("department")
2030
+	gender, _ := c.GetInt64("sex")
2015
 	phone := c.GetString("phone")
2031
 	phone := c.GetString("phone")
2016
-	medical_care, _ := c.GetInt64("medical_care")
2017
-	id_card := c.GetString("id_card")
2018
-	register_type, _ := c.GetInt64("register_type")
2019
 	registration_fee, _ := c.GetFloat("registration_fee")
2032
 	registration_fee, _ := c.GetFloat("registration_fee")
2020
 	medical_expenses, _ := c.GetFloat("medical_expenses")
2033
 	medical_expenses, _ := c.GetFloat("medical_expenses")
2021
-	certificates, _ := c.GetInt64("certificates")
2022
-	settlementValue, _ := c.GetInt64("settlement_value")
2023
 	social_type, _ := c.GetInt64("social_type")
2034
 	social_type, _ := c.GetInt64("social_type")
2024
-	medical_insurance_card := c.GetString("medical_insurance_card")
2025
-	id_card_type, _ := c.GetInt64("id_card_type")
2026
 
2035
 
2027
 	timeLayout := "2006-01-02"
2036
 	timeLayout := "2006-01-02"
2028
 	loc, _ := time.LoadLocation("Local")
2037
 	loc, _ := time.LoadLocation("Local")
2037
 	recordDateTime := theTime.Unix()
2046
 	recordDateTime := theTime.Unix()
2038
 
2047
 
2039
 	adminInfo := c.GetAdminUserInfo()
2048
 	adminInfo := c.GetAdminUserInfo()
2040
-	patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
2041
-	patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
2042
 
2049
 
2043
-	miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
2050
+	var patient service.Patients
2044
 
2051
 
2045
-	if patient == nil {
2052
+	if id == 0 {
2053
+		patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
2054
+
2055
+	} else {
2056
+		patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
2057
+
2058
+	}
2059
+
2060
+	if patient.ID == 0 {
2046
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
2061
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
2047
 		return
2062
 		return
2048
 	}
2063
 	}
2051
 		return
2066
 		return
2052
 	}
2067
 	}
2053
 
2068
 
2054
-	//org, _ := service.GetOrgById(adminInfo.CurrentOrgId)
2055
 	config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
2069
 	config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
2056
 
2070
 
2057
 	if config.IsOpen == 1 {
2071
 	if config.IsOpen == 1 {
2058
 
2072
 
2059
-		api := "http://127.0.0.1:9531/" + "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
2060
-		resp, requestErr := http.Get(api)
2061
-
2062
-		if requestErr != nil {
2063
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2064
-			return
2065
-		}
2066
-		defer resp.Body.Close()
2067
-		body, ioErr := ioutil.ReadAll(resp.Body)
2068
-		if ioErr != nil {
2069
-			utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
2070
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2071
-			return
2072
-		}
2073
-		var respJSON map[string]interface{}
2074
-
2075
-		if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
2076
-			utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
2077
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2078
-			return
2079
-		}
2080
-
2081
-		userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
2082
-		userJSONBytes, _ := json.Marshal(userJSON)
2083
-		var res ResultTwo
2084
-		if err := json.Unmarshal(userJSONBytes, &res); err != nil {
2085
-			utils.ErrorLog("解析失败:%v", err)
2086
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2087
-			return
2088
-		}
2089
-		Iinfos, _ := json.Marshal(res.Output.Iinfo)
2090
-		Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
2091
-		infoStr := string(Iinfos)
2092
-		idetinfoStr := string(Idetinfos)
2093
-
2094
-		his := models.VMHisPatient{
2095
-			PsnNo:       res.Output.Baseinfo.PsnNo,
2096
-			PsnCertType: res.Output.Baseinfo.PsnCertType,
2097
-			Certno:      res.Output.Baseinfo.Certno,
2098
-			PsnName:     res.Output.Baseinfo.PsnName,
2099
-			Gend:        res.Output.Baseinfo.Gend,
2100
-			Naty:        res.Output.Baseinfo.Naty,
2101
-			Brdy:        res.Output.Baseinfo.Brdy,
2102
-			Age:         res.Output.Baseinfo.Age,
2103
-			Iinfo:       infoStr,
2104
-			Idetinfo:    idetinfoStr,
2105
-			PatientId:   patient.ID,
2106
-			RecordDate:  theTime.Unix(),
2107
-			UserOrgId:   adminInfo.CurrentOrgId,
2108
-			AdminUserId: adminInfo.AdminUser.Id,
2109
-			IsReturn:    1,
2110
-		}
2111
-		fmt.Println(his)
2112
-
2113
-		lastPatient, _ := service.GetLastPatient(adminInfo.CurrentOrgId)
2114
-		timeStr := time.Now().Format("2006-01-02")
2115
-		timeArr := strings.Split(timeStr, "-")
2116
-		var str = timeArr[0] + timeArr[1] + timeArr[2] + strconv.FormatInt(lastPatient.ID, 10)
2117
-
2118
-		hisPatient := models.HisPatient{
2119
-			Number: str,
2120
-		}
2121
-		err = service.UpdateHisPatient(lastPatient.ID, hisPatient)
2122
-
2123
-		if res.Output.Iinfo == nil || len(res.Output.Iinfo) == 0 {
2124
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterOneException)
2125
-			return
2126
-		}
2127
-
2128
-		timestamp := time.Now().Unix()
2129
-		tempTime := time.Unix(timestamp, 0)
2130
-		timeFormat := tempTime.Format("20060102150405")
2131
-		chrgBchno := rand.Intn(100000) + 10000
2132
-		ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
2133
-
2134
-		count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
2135
-
2136
-		department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
2137
-
2138
-		//department_id := strconv.FormatInt(department.ID, 10)
2139
-		doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
2140
-
2141
-		if count <= 0 {
2142
-			api := "http://127.0.0.1:9531/" + "gdyb/two?cert_no=" + patient.IdCardNo + "&insutype=" +
2143
-				res.Output.Iinfo[0].Insutype + "&psn_no=" + res.Output.Baseinfo.PsnNo +
2144
-				"&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&ipt_otp_no=" + ipt_otp_no +
2145
-				"&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
2146
-			resp, requestErr := http.Get(api)
2147
-			if requestErr != nil {
2148
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2149
-				return
2150
-			}
2151
-			defer resp.Body.Close()
2152
-			body, ioErr := ioutil.ReadAll(resp.Body)
2153
-			if ioErr != nil {
2154
-				utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
2155
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2156
-				return
2157
-			}
2158
-			var respJSON map[string]interface{}
2159
-			if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
2160
-				utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
2161
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2162
-				return
2163
-			}
2164
-
2165
-			respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
2166
-			userJSONBytes, _ := json.Marshal(respJSON)
2167
-			var res ResultThree
2168
-			if err := json.Unmarshal(userJSONBytes, &res); err != nil {
2169
-				utils.ErrorLog("解析失败:%v", err)
2170
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2171
-				return
2172
-			}
2173
-			if res.Infcode == -1 {
2174
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterTwoException)
2175
-				return
2176
-			}
2177
-			fmt.Println("000!!!!!!")
2178
-			fmt.Println(res)
2179
-			fmt.Println(res.Output.Data.MdtrtID)
2180
-			fmt.Println(res.Output.Data.PsnNo)
2181
-			fmt.Println(res.Output.Data.IptOtpNo)
2182
-
2183
-			his.Number = res.Output.Data.MdtrtID
2184
-			his.PsnNo = res.Output.Data.PsnNo
2185
-			his.IptOtpNo = res.Output.Data.IptOtpNo
2186
-			his.IdCardNo = patient.IdCardNo
2187
-			his.PhoneNumber = patient.Phone
2188
-			his.UserOrgId = adminInfo.CurrentOrgId
2189
-			his.Status = 1
2190
-			his.Ctime = time.Now().Unix()
2191
-			his.Mtime = time.Now().Unix()
2192
-			err := service.CreateHisPatientTwo(&his)
2193
-
2194
-			diagnosisConfig, _ := service.FindDiagnoseById(patientPrescription.Diagnosis)
2195
-
2196
-			if err == nil {
2197
-				api := "http://127.0.0.1:9531/" + "gdyb/four?psn_no=" + his.PsnNo +
2198
-					"&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
2199
-					"&diag=" + diagnosisConfig.ClassName + "&org_name=" + miConfig.OrgName + "&med_type=" + "11" + "&doctor_id=" + strconv.FormatInt(patientPrescription.DoctorId, 10) + "&fixmedins_code=" + miConfig.Code + "&diag_code=" + diagnosisConfig.CountryCode +
2200
-					"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
2201
-				resp, requestErr := http.Get(api)
2202
-				if requestErr != nil {
2203
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2204
-					return
2205
-				}
2206
-
2207
-				body, ioErr := ioutil.ReadAll(resp.Body)
2208
-				if ioErr != nil {
2209
-					utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
2210
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2211
-					return
2212
-				}
2213
-				var respJSON map[string]interface{}
2214
-				if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
2215
-					utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
2216
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2217
-					return
2218
-				}
2219
-
2220
-				respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
2221
-				userJSONBytes, _ := json.Marshal(respJSON)
2222
-				fmt.Println(respJSON)
2223
-				fmt.Println(userJSONBytes)
2224
-
2225
-				var res ResultSix
2226
-				if err := json.Unmarshal(userJSONBytes, &res); err != nil {
2227
-					utils.ErrorLog("解析失败:%v", err)
2228
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2229
-					return
2230
-				}
2231
-				if res.Infcode == -1 {
2232
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterTwoException)
2233
-					return
2234
-				}
2235
-
2236
-				c.ServeSuccessJSON(map[string]interface{}{
2237
-					"his_info": his,
2238
-				})
2239
-			} else {
2240
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2241
-				return
2242
-			}
2243
-		}
2244
-
2245
 	} else {
2073
 	} else {
2246
 		timeStr := time.Now().Format("2006-01-02")
2074
 		timeStr := time.Now().Format("2006-01-02")
2247
 		timeArr := strings.Split(timeStr, "-")
2075
 		timeArr := strings.Split(timeStr, "-")
2275
 				Mtime:                  time.Now().Unix(),
2103
 				Mtime:                  time.Now().Unix(),
2276
 				Number:                 str,
2104
 				Number:                 str,
2277
 				IdCardType:             id_card_type,
2105
 				IdCardType:             id_card_type,
2106
+				Departments:            department,
2107
+				Doctor:                 doctor,
2278
 			}
2108
 			}
2279
 			service.CreateHisPatient(&hisPatient)
2109
 			service.CreateHisPatient(&hisPatient)
2280
 
2110
 
2949
 	}
2779
 	}
2950
 	recordDateTime := theTime.Unix()
2780
 	recordDateTime := theTime.Unix()
2951
 	adminInfo := c.GetAdminUserInfo()
2781
 	adminInfo := c.GetAdminUserInfo()
2952
-	patients, _ := service.GetAllChargeHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
2953
-	//var patients []*service.Patients
2954
-	//for _, item := range tempPatients{
2955
-	//	if len(item.HisPrescription) > 0 {
2956
-	//		patients = append(patients, item)
2957
-	//	}
2958
-	//}
2782
+	tempPatients, _ := service.GetAllChargeHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
2783
+	var patients []*service.Patients
2784
+	for _, item := range tempPatients {
2785
+		//过滤掉没挂号的和没开处方的
2786
+		if item.HisPatient.ID > 0 || len(item.HisPrescription) > 0 {
2787
+			patients = append(patients, item)
2788
+		}
2789
+	}
2959
 	//patients_two, _ := service.GetChargeHisPatientListTwo(adminInfo.CurrentOrgId, "", recordDateTime)
2790
 	//patients_two, _ := service.GetChargeHisPatientListTwo(adminInfo.CurrentOrgId, "", recordDateTime)
2960
 	c.ServeSuccessJSON(map[string]interface{}{
2791
 	c.ServeSuccessJSON(map[string]interface{}{
2961
 		"list": patients,
2792
 		"list": patients,
2990
 	})
2821
 	})
2991
 
2822
 
2992
 }
2823
 }
2824
+
2825
+func RemoveRepeatedPatient(patient []*service.Patients) (newArr []*service.Patients) {
2826
+	newArr = make([]*service.Patients, 0)
2827
+	for i := 0; i < len(patient); i++ {
2828
+		repeat := false
2829
+		for j := i + 1; j < len(patient); j++ {
2830
+			if patient[i].ID == patient[j].ID {
2831
+				repeat = true
2832
+				break
2833
+			}
2834
+		}
2835
+		if !repeat {
2836
+			newArr = append(newArr, patient[i])
2837
+		}
2838
+	}
2839
+	return
2840
+}

+ 18 - 1
service/his_service.go 查看文件

111
 	UserOrgId             int64                 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
111
 	UserOrgId             int64                 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
112
 	Name                  string                `gorm:"column:name" json:"name" form:"name"`
112
 	Name                  string                `gorm:"column:name" json:"name" form:"name"`
113
 	Status                int64                 `gorm:"column:status" json:"status" form:"status"`
113
 	Status                int64                 `gorm:"column:status" json:"status" form:"status"`
114
+	IdCardNo              string                `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
114
 	Schedule              Schedule              `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"schedule"`
115
 	Schedule              Schedule              `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"schedule"`
115
 	HisPatient            HisPatient            `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"his_patient"`
116
 	HisPatient            HisPatient            `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"his_patient"`
116
 	HisPrescription       []*HisPrescription    `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"prescription"`
117
 	HisPrescription       []*HisPrescription    `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"prescription"`
140
 		Joins("join xt_schedule as sch ON sch.patient_id = xt_patients.id AND sch.schedule_date = ? AND sch.status = 1 AND sch.user_org_id = ?", record_date, org_id)
141
 		Joins("join xt_schedule as sch ON sch.patient_id = xt_patients.id AND sch.schedule_date = ? AND sch.status = 1 AND sch.user_org_id = ?", record_date, org_id)
141
 	db = db.Preload("HisPatient", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date)
142
 	db = db.Preload("HisPatient", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date)
142
 	db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date)
143
 	db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date)
143
-	err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date).Find(&patients).Error
144
+	err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date).Group("xt_patients.id").Find(&patients).Error
144
 	return
145
 	return
145
 }
146
 }
146
 
147
 
937
 	err = readDb.Model(&models.HisAdditionalCharge{}).Where("status = 1  AND id = ?", id).First(&addition).Error
938
 	err = readDb.Model(&models.HisAdditionalCharge{}).Where("status = 1  AND id = ?", id).First(&addition).Error
938
 	return
939
 	return
939
 }
940
 }
941
+
942
+func GetPatientByIDCard(id_card_no string, user_org_id int64) (patient Patients, err error) {
943
+	err = readDb.Model(&Patients{}).Where("id_card_no = ? AND user_org_id = ?", id_card_no, user_org_id).First(&patient).Error
944
+	return
945
+}
946
+
947
+func GetHisOrderThree(record_time int64, patient_id int64, user_org_id int64) (order models.HisOrder, err error) {
948
+	err = readDb.Model(&models.HisOrder{}).Where("patient_id = ? AND user_org_id = ? AND settle_accounts_date = ? AND status = 1", patient_id, user_org_id, record_time).First(&order).Error
949
+	return
950
+}
951
+
952
+func GetPatientByIDTwo(orgID int64, patientID int64) (Patients, error) {
953
+	var patient Patients
954
+	err := readDb.Model(&Patients{}).Where("id = ? and user_org_id=? and status=1", patientID, orgID).First(&patient).Error
955
+	return patient, err
956
+}