Explorar el Código

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

XMLWAN hace 4 años
padre
commit
8d6d4e9937

+ 7 - 8
controllers/base_api_controller.go Ver fichero

70
 	this.BaseAPIController.Prepare()
70
 	this.BaseAPIController.Prepare()
71
 	if this.GetAdminUserInfo() == nil {
71
 	if this.GetAdminUserInfo() == nil {
72
 		var userAdmin models.AdminUser
72
 		var userAdmin models.AdminUser
73
-		userAdmin.Id = 558
74
-		userAdmin.Mobile = "13535547901"
73
+		userAdmin.Id = 1448
74
+		userAdmin.Mobile = "13318599895"
75
 
75
 
76
 		//userAdmin.Id = 597
76
 		//userAdmin.Id = 597
77
 		//userAdmin.Mobile = "19874122664"
77
 		//userAdmin.Mobile = "19874122664"
92
 		subscibes[4] = &subscibe
92
 		subscibes[4] = &subscibe
93
 		var adminUserInfo service.AdminUserInfo
93
 		var adminUserInfo service.AdminUserInfo
94
 		adminUserInfo.CurrentOrgId = 4
94
 		adminUserInfo.CurrentOrgId = 4
95
-		adminUserInfo.CurrentAppId = 18
95
+		adminUserInfo.CurrentAppId = 8642
96
 		adminUserInfo.AdminUser = &userAdmin
96
 		adminUserInfo.AdminUser = &userAdmin
97
 		adminUserInfo.Subscibes = subscibes
97
 		adminUserInfo.Subscibes = subscibes
98
 		this.SetSession("admin_user_info", &adminUserInfo)
98
 		this.SetSession("admin_user_info", &adminUserInfo)
316
 	this.BaseAPIController.Prepare()
316
 	this.BaseAPIController.Prepare()
317
 	if this.GetAdminUserInfo() == nil {
317
 	if this.GetAdminUserInfo() == nil {
318
 		var userAdmin models.AdminUser
318
 		var userAdmin models.AdminUser
319
-		userAdmin.Id = 558
320
-		userAdmin.Mobile = "13535547901"
319
+		userAdmin.Id = 1448
320
+		userAdmin.Mobile = "13318599895"
321
+
321
 		//userAdmin.Id = 597
322
 		//userAdmin.Id = 597
322
 		//userAdmin.Mobile = "19874122664"
323
 		//userAdmin.Mobile = "19874122664"
323
 		userAdmin.IsSuperAdmin = false
324
 		userAdmin.IsSuperAdmin = false
333
 		subscibe.Status = 1
334
 		subscibe.Status = 1
334
 		subscibe.CreatedTime = 1538035409
335
 		subscibe.CreatedTime = 1538035409
335
 		subscibe.UpdatedTime = 1538035409
336
 		subscibe.UpdatedTime = 1538035409
336
-
337
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
337
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
338
 		subscibes[4] = &subscibe
338
 		subscibes[4] = &subscibe
339
 		var adminUserInfo service.AdminUserInfo
339
 		var adminUserInfo service.AdminUserInfo
340
 		adminUserInfo.CurrentOrgId = 4
340
 		adminUserInfo.CurrentOrgId = 4
341
-		adminUserInfo.CurrentAppId = 18
341
+		adminUserInfo.CurrentAppId = 8642
342
 		adminUserInfo.AdminUser = &userAdmin
342
 		adminUserInfo.AdminUser = &userAdmin
343
 		adminUserInfo.Subscibes = subscibes
343
 		adminUserInfo.Subscibes = subscibes
344
 		this.SetSession("admin_user_info", &adminUserInfo)
344
 		this.SetSession("admin_user_info", &adminUserInfo)
345
-
346
 		//this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
345
 		//this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
347
 		//this.StopRun()
346
 		//this.StopRun()
348
 	}
347
 	}

+ 7 - 1
controllers/dialysis_record_api_controller.go Ver fichero

265
 
265
 
266
 	_, record := service.FindAutomaticReduceRecordByOrgId(adminInfo.CurrentOrgId)
266
 	_, record := service.FindAutomaticReduceRecordByOrgId(adminInfo.CurrentOrgId)
267
 
267
 
268
-	his_advices, _ := service.GetAllHisDoctorAdvice(adminInfo.CurrentOrgId, patientID, date.Unix())
268
+	_, is_open_config := service.FindXTHisRecordByOrgId(adminInfo.CurrentOrgId)
269
+
270
+	var his_advices []*models.HisDoctorAdviceInfo
271
+	if is_open_config.IsOpen == 1 {
272
+		his_advices, _ = service.GetAllHisDoctorAdvice(adminInfo.CurrentOrgId, patientID, date.Unix())
273
+	}
269
 
274
 
270
 	returnData := map[string]interface{}{
275
 	returnData := map[string]interface{}{
271
 		"patient":                     patient,
276
 		"patient":                     patient,
292
 		"headNurses":                  headNurses,
297
 		"headNurses":                  headNurses,
293
 		"system_prescribe":            systemDialysisPrescribe,
298
 		"system_prescribe":            systemDialysisPrescribe,
294
 		"his_advices":                 his_advices,
299
 		"his_advices":                 his_advices,
300
+		"is_open_config":              is_open_config,
295
 	}
301
 	}
296
 	this.ServeSuccessJSON(returnData)
302
 	this.ServeSuccessJSON(returnData)
297
 
303
 

+ 18 - 4
controllers/gdyb_controller.go Ver fichero

226
 	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
226
 	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
227
 
227
 
228
 	secret_key := c.GetString("secret_key")
228
 	secret_key := c.GetString("secret_key")
229
+	fixmedins_code := c.GetString("fixmedins_code")
229
 
230
 
230
-	result := service.Gdyb2205(psnNo, mdtrtId, chrgBchno, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key)
231
-
231
+	result := service.Gdyb2205(psnNo, mdtrtId, chrgBchno, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code)
232
+	var dat map[string]interface{}
233
+	if err := json.Unmarshal([]byte(result), &dat); err == nil {
234
+		fmt.Println(dat)
235
+	} else {
236
+		fmt.Println(err)
237
+	}
232
 	c.ServeSuccessJSON(map[string]interface{}{
238
 	c.ServeSuccessJSON(map[string]interface{}{
233
 		"pre": result,
239
 		"pre": result,
234
 	})
240
 	})
291
 	org_name := c.GetString("org_name")
297
 	org_name := c.GetString("org_name")
292
 	doctor := c.GetString("doctor")
298
 	doctor := c.GetString("doctor")
293
 	secret_key := c.GetString("secret_key")
299
 	secret_key := c.GetString("secret_key")
294
-
295
-	result := service.Gdyb2208(psnNo, mdtrtId, setlId, org_name, doctor, secret_key)
300
+	fixmedins_code := c.GetString("fixmedins_code")
301
+	insuplc_admdvs := c.GetString("insuplc_admdvs")
302
+	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
303
+	result := service.Gdyb2208(psnNo, mdtrtId, setlId, org_name, doctor, secret_key, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
304
+	var dat map[string]interface{}
305
+	if err := json.Unmarshal([]byte(result), &dat); err == nil {
306
+		fmt.Println(dat)
307
+	} else {
308
+		fmt.Println(err)
309
+	}
296
 	c.ServeSuccessJSON(map[string]interface{}{
310
 	c.ServeSuccessJSON(map[string]interface{}{
297
 		"pre": result,
311
 		"pre": result,
298
 	})
312
 	})

+ 126 - 12
controllers/his_api_controller.go Ver fichero

57
 
57
 
58
 	beego.Router("/api/doctor/list", &HisApiController{}, "get:GetAdminUsers")
58
 	beego.Router("/api/doctor/list", &HisApiController{}, "get:GetAdminUsers")
59
 
59
 
60
-	//beego.Router("/api/medicalinsurance/config", &HisApiController{}, "get:GetMedicalInsuranceConfig")
60
+	beego.Router("/api/hisprescription/get", &DialysisApiController{}, "Get:GetLastOrNextHisPrescription")
61
 
61
 
62
-	//新增附加费用
63
-	//beego.Router("/api/his/additionalcharge", &HisApiController{}, "Post:AdditionalCharge")
64
-
65
-	//beego.Router("/api/additionalcharge/get", &HisApiController{}, "Get:GetAdditionalcharge")
62
+	beego.Router("/api/callhisprescription/get", &DialysisApiController{}, "Get:GetCallHisPrescription")
66
 
63
 
67
 }
64
 }
68
 
65
 
357
 							s.Status = 1
354
 							s.Status = 1
358
 							s.UserOrgId = adminInfo.CurrentOrgId
355
 							s.UserOrgId = adminInfo.CurrentOrgId
359
 							s.RecordDate = recordDateTime
356
 							s.RecordDate = recordDateTime
360
-							s.StartTime = recordDateTime
357
+							s.StartTime = time.Now().Unix()
361
 							s.Groupno = groupNo
358
 							s.Groupno = groupNo
362
 							s.CreatedTime = ctime
359
 							s.CreatedTime = ctime
363
 							s.UpdatedTime = mtime
360
 							s.UpdatedTime = mtime
1304
 
1301
 
1305
 	if config.IsOpen == 1 {
1302
 	if config.IsOpen == 1 {
1306
 
1303
 
1307
-		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
1304
+		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
1308
 		resp, requestErr := http.Get(api)
1305
 		resp, requestErr := http.Get(api)
1309
 
1306
 
1310
 		if requestErr != nil {
1307
 		if requestErr != nil {
1387
 		doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
1384
 		doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
1388
 
1385
 
1389
 		if count <= 0 {
1386
 		if count <= 0 {
1390
-			api := "http://127.0.0.1:9531/" + "gdyb/two?cert_no=" + patient.IdCardNo + "&insutype=" +
1387
+			api := "http://127.0.0.1:9532/" + "gdyb/two?cert_no=" + patient.IdCardNo + "&insutype=" +
1391
 				res.Output.Iinfo[0].Insutype + "&psn_no=" + res.Output.Baseinfo.PsnNo +
1388
 				res.Output.Iinfo[0].Insutype + "&psn_no=" + res.Output.Baseinfo.PsnNo +
1392
 				"&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&ipt_otp_no=" + ipt_otp_no +
1389
 				"&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&ipt_otp_no=" + ipt_otp_no +
1393
 				"&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
1390
 				"&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
1442
 			diagnosisConfig, _ := service.FindDiagnoseById(patientPrescription.Diagnosis)
1439
 			diagnosisConfig, _ := service.FindDiagnoseById(patientPrescription.Diagnosis)
1443
 
1440
 
1444
 			if err == nil {
1441
 			if err == nil {
1445
-				api := "http://127.0.0.1:9531/" + "gdyb/four?psn_no=" + his.PsnNo +
1442
+				api := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
1446
 					"&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
1443
 					"&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
1447
 					"&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 +
1444
 					"&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 +
1448
 					"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
1445
 					"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
1602
 
1599
 
1603
 	if config.IsOpen == 1 { //对接了医保,走医保流程
1600
 	if config.IsOpen == 1 { //对接了医保,走医保流程
1604
 		bytesData, _ := json.Marshal(data)
1601
 		bytesData, _ := json.Marshal(data)
1605
-		req, _ := http.NewRequest("POST", "http://127.0.0.1:9531/"+"gdyb/five", bytes.NewReader(bytesData))
1602
+		req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
1606
 		resp, _ := client.Do(req)
1603
 		resp, _ := client.Do(req)
1607
 		defer resp.Body.Close()
1604
 		defer resp.Body.Close()
1608
 		body, ioErr := ioutil.ReadAll(resp.Body)
1605
 		body, ioErr := ioutil.ReadAll(resp.Body)
2009
 func (c *HisApiController) Refund() {
2006
 func (c *HisApiController) Refund() {
2010
 	order_id, _ := c.GetInt64("order_id")
2007
 	order_id, _ := c.GetInt64("order_id")
2011
 	number := c.GetString("number")
2008
 	number := c.GetString("number")
2009
+	record_time := c.GetString("record_time")
2010
+	patient_id, _ := c.GetInt64("patient_id")
2011
+
2012
+	timeLayout := "2006-01-02"
2013
+	loc, _ := time.LoadLocation("Local")
2012
 
2014
 
2013
 	adminUser := c.GetAdminUserInfo()
2015
 	adminUser := c.GetAdminUserInfo()
2016
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
2017
+	if err != nil {
2018
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2019
+		return
2020
+	}
2021
+	recordDateTime := theTime.Unix()
2022
+
2023
+	his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
2024
+	miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
2025
+	patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
2026
+	order, _ := service.GetHisOrderByID(order_id)
2027
+
2014
 	config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
2028
 	config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
2015
 	if config.IsOpen == 1 { //对接了医保,走医保流程
2029
 	if config.IsOpen == 1 { //对接了医保,走医保流程
2030
+		api := "http://127.0.0.1:9531/" + "gdyb/nine?psn_no=" + his.PsnNo +
2031
+			"&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&setl_id=" + order.SetlId + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
2032
+			"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
2033
+		resp, requestErr := http.Get(api)
2034
+		if requestErr != nil {
2035
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2036
+			return
2037
+		}
2038
+		body, ioErr := ioutil.ReadAll(resp.Body)
2039
+		if ioErr != nil {
2040
+			utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
2041
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2042
+			return
2043
+		}
2044
+		var respJSON map[string]interface{}
2045
+		if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
2046
+			utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
2047
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2048
+			return
2049
+		}
2050
+		respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
2051
+		userJSONBytes, _ := json.Marshal(respJSON)
2052
+		fmt.Println(respJSON)
2053
+		fmt.Println(userJSONBytes)
2054
+
2055
+		api2 := "http://127.0.0.1:9531/" + "gdyb/six?psn_no=" + his.PsnNo +
2056
+			"&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
2057
+			"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
2058
+		resp2, requestErr2 := http.Get(api2)
2059
+		if requestErr2 != nil {
2060
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2061
+			return
2062
+		}
2016
 
2063
 
2064
+		body2, ioErr2 := ioutil.ReadAll(resp2.Body)
2065
+		if ioErr2 != nil {
2066
+			utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
2067
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2068
+			return
2069
+		}
2070
+		var respJSON2 map[string]interface{}
2071
+		if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
2072
+			utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
2073
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2074
+			return
2075
+		}
2076
+		err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
2077
+		if err == nil {
2078
+			c.ServeSuccessJSON(map[string]interface{}{
2079
+				"msg": "退费成功",
2080
+			})
2081
+		} else {
2082
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2083
+			return
2084
+		}
2017
 	} else {
2085
 	} else {
2018
 		err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
2086
 		err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
2019
 		if err == nil {
2087
 		if err == nil {
2024
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2092
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2025
 			return
2093
 			return
2026
 		}
2094
 		}
2027
-
2028
 	}
2095
 	}
2029
-
2030
 }
2096
 }
2031
 
2097
 
2032
 func (this *HisApiController) AdditionalCharge() {
2098
 func (this *HisApiController) AdditionalCharge() {
2115
 		"doctors": doctors,
2181
 		"doctors": doctors,
2116
 	})
2182
 	})
2117
 }
2183
 }
2184
+
2185
+func (this *DialysisApiController) GetLastOrNextHisPrescription() {
2186
+	change_type, _ := this.GetInt64("type", 0)
2187
+	record_date := this.GetString("record_time")
2188
+	patient_id, _ := this.GetInt64("patient_id", 0)
2189
+
2190
+	timeLayout := "2006-01-02"
2191
+	loc, _ := time.LoadLocation("Local")
2192
+	theAdviceRecordTime, _ := time.ParseInLocation(timeLayout, record_date, loc)
2193
+	record_time := theAdviceRecordTime.Unix()
2194
+	adminUserInfo := this.GetAdminUserInfo()
2195
+	prescriptions, err := service.GetHisPrescriptionByType(change_type, record_time, adminUserInfo.CurrentOrgId, patient_id)
2196
+	if err == nil {
2197
+		if len(prescriptions) == 0 {
2198
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDoctorAdviceEmpty)
2199
+			return
2200
+		} else {
2201
+			this.ServeSuccessJSON(map[string]interface{}{
2202
+				"prescriptions": prescriptions,
2203
+			})
2204
+			return
2205
+		}
2206
+	} else {
2207
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
2208
+		return
2209
+	}
2210
+}
2211
+
2212
+func (this *DialysisApiController) GetCallHisPrescription() {
2213
+	patient_id, _ := this.GetInt64("patient_id", 0)
2214
+	timeLayout := "2006-01-02"
2215
+	loc, _ := time.LoadLocation("Local")
2216
+	start_time := this.GetString("start_time")
2217
+	startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
2218
+	end_time := this.GetString("end_time")
2219
+	endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
2220
+	adminUserInfo := this.GetAdminUserInfo()
2221
+	prescriptions, err := service.GetCallHisPrescriptions(startime.Unix(), endtime.Unix(), adminUserInfo.CurrentOrgId, patient_id)
2222
+	if err == nil {
2223
+		this.ServeSuccessJSON(map[string]interface{}{
2224
+			"prescriptions": prescriptions,
2225
+		})
2226
+		return
2227
+	} else {
2228
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
2229
+		return
2230
+	}
2231
+}

+ 11 - 11
controllers/mobile_api_controllers/check_weight_api_controller.go Ver fichero

562
 			}
562
 			}
563
 		}
563
 		}
564
 
564
 
565
-		// if dialysisPrescribe != nil {
566
-		// 	dialysisPrescribe.UpdatedTime = time.Now().Unix()
567
-		// 	dialysisPrescribe.RecordDate = theAssessmentDateTime
568
-		// 	dialysisPrescribe.DewaterAmount = dewater_amount
569
-		// 	dialysisPrescribe.TargetUltrafiltration = dewater_amount
570
-		// 	dialysisPrescribe.Status = 1
571
-		// 	updateErr := service.UpDateDialysisPrescription(dialysisPrescribe)
572
-		// 	if updateErr != nil {
573
-		// 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
574
-		// 	}
575
-		// }
565
+		if dialysisPrescribe != nil && dialysisPrescribe.TargetUltrafiltration == 0 {
566
+			dialysisPrescribe.UpdatedTime = time.Now().Unix()
567
+			dialysisPrescribe.RecordDate = theAssessmentDateTime
568
+			dialysisPrescribe.DewaterAmount = dewater_amount
569
+			dialysisPrescribe.TargetUltrafiltration = dewater_amount
570
+			dialysisPrescribe.Status = 1
571
+			updateErr := service.UpDateDialysisPrescription(dialysisPrescribe)
572
+			if updateErr != nil {
573
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
574
+			}
575
+		}
576
 
576
 
577
 		theEvaluation, getPEErr := service.MobileGetPredialysisEvaluation(adminUserInfo.Org.Id, id, theAssessmentDateTime)
577
 		theEvaluation, getPEErr := service.MobileGetPredialysisEvaluation(adminUserInfo.Org.Id, id, theAssessmentDateTime)
578
 		if getPEErr != nil {
578
 		if getPEErr != nil {

+ 26 - 16
controllers/new_mobile_api_controllers/good_types.json Ver fichero

12
       "org_id": 0,
12
       "org_id": 0,
13
       "status": 1,
13
       "status": 1,
14
       "type": 1,
14
       "type": 1,
15
-      "number": 1
15
+      "number": 1,
16
+      "out_stock": 1
16
     },
17
     },
17
     {
18
     {
18
       "id": 10001,
19
       "id": 10001,
26
       "org_id": 0,
27
       "org_id": 0,
27
       "status": 1,
28
       "status": 1,
28
       "type": 1,
29
       "type": 1,
29
-      "number": 2
30
+      "number": 2,
31
+      "out_stock": 1
30
     },
32
     },
31
     {
33
     {
32
       "id": 10002,
34
       "id": 10002,
40
       "org_id": 0,
42
       "org_id": 0,
41
       "status": 1,
43
       "status": 1,
42
       "type": 1,
44
       "type": 1,
43
-      "number": 3
44
-
45
+      "number": 3,
46
+      "out_stock": 1
45
     },
47
     },
46
     {
48
     {
47
       "id": 10003,
49
       "id": 10003,
55
       "org_id": 0,
57
       "org_id": 0,
56
       "status": 1,
58
       "status": 1,
57
       "type": 1,
59
       "type": 1,
58
-      "number": 4
60
+      "number": 4,
61
+      "out_stock": 1
59
     },
62
     },
60
     {
63
     {
61
       "id": 10004,
64
       "id": 10004,
69
       "org_id": 0,
72
       "org_id": 0,
70
       "status": 1,
73
       "status": 1,
71
       "type": 1,
74
       "type": 1,
72
-      "number": 5
73
-
75
+      "number": 5,
76
+      "out_stock": 1
74
     },
77
     },
75
     {
78
     {
76
       "id": 10005,
79
       "id": 10005,
84
       "org_id": 13,
87
       "org_id": 13,
85
       "status": 1,
88
       "status": 1,
86
       "type": 1,
89
       "type": 1,
87
-      "number": 6
88
-
90
+      "number": 6,
91
+      "out_stock": 1
89
     },
92
     },
90
     {
93
     {
91
       "id": 79,
94
       "id": 79,
99
       "org_id": 0,
102
       "org_id": 0,
100
       "status": 1,
103
       "status": 1,
101
       "type": 1,
104
       "type": 1,
102
-      "number": 7
105
+      "number": 7,
106
+      "out_stock": 1
103
     },
107
     },
104
     {
108
     {
105
       "id": 80,
109
       "id": 80,
113
       "org_id": 0,
117
       "org_id": 0,
114
       "status": 1,
118
       "status": 1,
115
       "type": 1,
119
       "type": 1,
116
-      "number": 8
120
+      "number": 8,
121
+      "out_stock": 1
117
     },
122
     },
118
     {
123
     {
119
       "id": 81,
124
       "id": 81,
127
       "org_id": 0,
132
       "org_id": 0,
128
       "status": 1,
133
       "status": 1,
129
       "type": 1,
134
       "type": 1,
130
-      "number": 9
135
+      "number": 9,
136
+      "out_stock": 1
131
     }, {
137
     }, {
132
       "id": 81,
138
       "id": 81,
133
       "type_code": "14000009",
139
       "type_code": "14000009",
140
       "org_id": 0,
146
       "org_id": 0,
141
       "status": 1,
147
       "status": 1,
142
       "type": 1,
148
       "type": 1,
143
-      "number": 10
149
+      "number": 10,
150
+      "out_stock": 1
144
     },{
151
     },{
145
       "id": 81,
152
       "id": 81,
146
       "type_code": "14000010",
153
       "type_code": "14000010",
153
       "org_id": 0,
160
       "org_id": 0,
154
       "status": 1,
161
       "status": 1,
155
       "type": 1,
162
       "type": 1,
156
-      "number": 11
163
+      "number": 11,
164
+      "out_stock": 1
157
     },{
165
     },{
158
       "id": 81,
166
       "id": 81,
159
       "type_code": "14000011",
167
       "type_code": "14000011",
166
       "org_id": 0,
174
       "org_id": 0,
167
       "status": 1,
175
       "status": 1,
168
       "type": 1,
176
       "type": 1,
169
-      "number": 12
177
+      "number": 12,
178
+      "out_stock": 1
170
     },{
179
     },{
171
       "id": 81,
180
       "id": 81,
172
       "type_code": "14000012",
181
       "type_code": "14000012",
179
       "org_id": 0,
188
       "org_id": 0,
180
       "status": 1,
189
       "status": 1,
181
       "type": 1,
190
       "type": 1,
182
-      "number": 13
191
+      "number": 13,
192
+      "out_stock": 1
183
     }
193
     }
184
   ]
194
   ]
185
 }
195
 }

+ 1 - 1
controllers/new_mobile_api_controllers/mobile_regist_controller.go Ver fichero

241
 		InitEquitMentInformation(org)
241
 		InitEquitMentInformation(org)
242
 		//初始化显示配置和打印模版
242
 		//初始化显示配置和打印模版
243
 		InitShowConfig(org)
243
 		InitShowConfig(org)
244
-
245
 		//初始化商品类型
244
 		//初始化商品类型
246
 		InitGoodTypesConfig(org)
245
 		InitGoodTypesConfig(org)
247
 
246
 
1267
 			OrgId:    org.Id,
1266
 			OrgId:    org.Id,
1268
 			Status:   1,
1267
 			Status:   1,
1269
 			Type:     1,
1268
 			Type:     1,
1269
+			OutStock: item.OutStock,
1270
 		}
1270
 		}
1271
 		service.AddSigleGoodType(good_type)
1271
 		service.AddSigleGoodType(good_type)
1272
 	}
1272
 	}

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 624 - 288
controllers/patient_api_controller.go


+ 4 - 1
controllers/verify_login_controller.go Ver fichero

252
 							if len(ids) == 0 {
252
 							if len(ids) == 0 {
253
 								ids = purview_ids
253
 								ids = purview_ids
254
 							} else {
254
 							} else {
255
-								ids = ids + "," + purview_ids
255
+								if len(purview_ids) > 0 {
256
+									ids = ids + "," + purview_ids
257
+								}
256
 							}
258
 							}
257
 
259
 
258
 							if len(system_ids) > 0 {
260
 							if len(system_ids) > 0 {
259
 								ids = ids + "," + system_ids
261
 								ids = ids + "," + system_ids
260
 							}
262
 							}
261
 						}
263
 						}
264
+
262
 						if len(ids) != 0 {
265
 						if len(ids) != 0 {
263
 							pruviews, _ = service.GetPurviewById(CompressStr(ids))
266
 							pruviews, _ = service.GetPurviewById(CompressStr(ids))
264
 							for _, item := range pruviews {
267
 							for _, item := range pruviews {

+ 3 - 3
main.go Ver fichero

12
 }
12
 }
13
 
13
 
14
 func main() {
14
 func main() {
15
-	service.BeginAutoCreateWeekSchedulesJob()
16
-	service.BeginAutoCreateWeekDisinfectionJob()
15
+	//service.BeginAutoCreateWeekSchedulesJob()
16
+	//service.BeginAutoCreateWeekDisinfectionJob()
17
 	//service.BeginAutoCreatePlanJob()
17
 	//service.BeginAutoCreatePlanJob()
18
 	//service.AutoClearSchedules()
18
 	//service.AutoClearSchedules()
19
-	service.BeginAutoCreateStaffScheduleJob()
19
+	//service.BeginAutoCreateStaffScheduleJob()
20
 	beego.Run()
20
 	beego.Run()
21
 }
21
 }

+ 16 - 0
models/his_models.go Ver fichero

422
 	return "his_doctor_advice_parent_template"
422
 	return "his_doctor_advice_parent_template"
423
 }
423
 }
424
 
424
 
425
+type VMDrug struct {
426
+	ID                     int64   `gorm:"column:id" json:"id" form:"id"`
427
+	MaxUnit                string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
428
+	MinUnit                string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
429
+	RetailPrice            float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
430
+	Status                 int64   `gorm:"column:status" json:"status" form:"status"`
431
+	OrgId                  int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
432
+	DrugCode               string  `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
433
+	MedicalInsuranceNumber string  `gorm:"column:medical_insurance_number" json:"medical_insurance_number"`
434
+}
435
+
436
+func (VMDrug) TableName() string {
437
+	return "xt_base_drug"
438
+}
439
+
425
 type HisDoctorAdviceTemplate struct {
440
 type HisDoctorAdviceTemplate struct {
426
 	ID                    int64   `gorm:"column:id" json:"id" form:"id"`
441
 	ID                    int64   `gorm:"column:id" json:"id" form:"id"`
427
 	OrgId                 int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
442
 	OrgId                 int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
448
 	DrugId                int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
463
 	DrugId                int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
449
 	Way                   int64   `gorm:"column:way" json:"way" form:"way"`
464
 	Way                   int64   `gorm:"column:way" json:"way" form:"way"`
450
 	DrugNameId            int64   `gorm:"column:drug_name_id" json:"drug_name_id" form:"drug_name_id"`
465
 	DrugNameId            int64   `gorm:"column:drug_name_id" json:"drug_name_id" form:"drug_name_id"`
466
+	VMDrug                VMDrug  `gorm:"ForeignKey:TemplateId;AssociationForeignKey:ID" json:"advices"`
451
 }
467
 }
452
 
468
 
453
 func (HisDoctorAdviceTemplate) TableName() string {
469
 func (HisDoctorAdviceTemplate) TableName() string {

+ 1 - 0
models/vm_models.go Ver fichero

348
 	Status   int64  `gorm:"column:status" json:"status"`
348
 	Status   int64  `gorm:"column:status" json:"status"`
349
 	Type     int64  `gorm:"column:type" json:"type"`
349
 	Type     int64  `gorm:"column:type" json:"type"`
350
 	Number   int64  `gorm:"column:number" json:"number"`
350
 	Number   int64  `gorm:"column:number" json:"number"`
351
+	OutStock int64  `gorm:"column:out_stock" json:"out_stock" form:"out_stock"`
351
 }
352
 }
352
 
353
 
353
 func (VMGoodsType) TableName() string {
354
 func (VMGoodsType) TableName() string {

+ 17 - 0
service/dialysis_service.go Ver fichero

320
 	err := writeDb.Model(&models.DoctorAdvice{}).Where("patient_id = ? AND (id = ? Or parent_id=?)  AND status = 1 ", patientId, id, id).Updates(map[string]interface{}{"execution_time": m.ExecutionTime, "execution_staff": m.ExecutionStaff, "execution_state": 1}).Error
320
 	err := writeDb.Model(&models.DoctorAdvice{}).Where("patient_id = ? AND (id = ? Or parent_id=?)  AND status = 1 ", patientId, id, id).Updates(map[string]interface{}{"execution_time": m.ExecutionTime, "execution_staff": m.ExecutionStaff, "execution_state": 1}).Error
321
 	return err
321
 	return err
322
 }
322
 }
323
+
324
+func ExceHidDoctorAdviceById(m *models.HisDoctorAdviceInfo, id int64, patientId int64) error {
325
+	err := writeDb.Model(&models.HisDoctorAdviceInfo{}).Where("patient_id = ? AND (id = ? Or parent_id=?)  AND status = 1 ", patientId, id, id).Updates(map[string]interface{}{"execution_time": m.ExecutionTime, "execution_staff": m.ExecutionStaff, "execution_state": 1}).Error
326
+	return err
327
+}
328
+
323
 func CheckDoctorAdviceById(m *models.DoctorAdvice, id int64, patientId int64) error {
329
 func CheckDoctorAdviceById(m *models.DoctorAdvice, id int64, patientId int64) error {
324
 	err := writeDb.Model(&models.DoctorAdvice{}).Where("patient_id = ? AND (id = ? Or parent_id=?) AND status = 1 ", patientId, id, id).Updates(map[string]interface{}{"check_time": m.CheckTime, "checker": m.Checker, "check_state": 1}).Error
330
 	err := writeDb.Model(&models.DoctorAdvice{}).Where("patient_id = ? AND (id = ? Or parent_id=?) AND status = 1 ", patientId, id, id).Updates(map[string]interface{}{"check_time": m.CheckTime, "checker": m.Checker, "check_state": 1}).Error
325
 	return err
331
 	return err
326
 }
332
 }
327
 
333
 
334
+func CheckHisDoctorAdviceById(m *models.HisDoctorAdviceInfo, id int64, patientId int64) error {
335
+	err := writeDb.Model(&models.HisDoctorAdviceInfo{}).Where("patient_id = ? AND (id = ? Or parent_id=?) AND status = 1 ", patientId, id, id).Updates(map[string]interface{}{"check_time": m.CheckTime, "checker": m.Checker, "check_state": 1}).Error
336
+	return err
337
+}
338
+
328
 func CreateMonitor(m *models.MonitoringRecord) (err error) {
339
 func CreateMonitor(m *models.MonitoringRecord) (err error) {
329
 	return writeDb.Create(m).Error
340
 	return writeDb.Create(m).Error
330
 }
341
 }
1122
 	return doctorAdvice, err
1133
 	return doctorAdvice, err
1123
 }
1134
 }
1124
 
1135
 
1136
+func GetHisExecutionDoctors(orgid int64, patientid int64, id int64) (doctorAdvice []*models.HisDoctorAdviceInfo, err error) {
1137
+
1138
+	err = readDb.Model(&models.HisDoctorAdviceInfo{}).Where("user_org_id = ? and patient_id = ? AND (id = ? Or parent_id=?) and status = 1", orgid, patientid, id, id).Find(&doctorAdvice).Error
1139
+	return doctorAdvice, err
1140
+}
1141
+
1125
 func FindHisDoctorAdviceById(orgID int64, id int64) (advice models.HisDoctorAdviceInfo, err error) {
1142
 func FindHisDoctorAdviceById(orgID int64, id int64) (advice models.HisDoctorAdviceInfo, err error) {
1126
 	err = readDb.Model(&models.HisDoctorAdviceInfo{}).Where("user_org_id=? and status=1 and id = ?", orgID, id).First(&advice).Error
1143
 	err = readDb.Model(&models.HisDoctorAdviceInfo{}).Where("user_org_id=? and status=1 and id = ?", orgID, id).First(&advice).Error
1127
 	return
1144
 	return

+ 63 - 6
service/gdyb_service.go Ver fichero

32
 	inputData := make(map[string]interface{})
32
 	inputData := make(map[string]interface{})
33
 	inputMessage["infno"] = "1101"      // 交易编码
33
 	inputMessage["infno"] = "1101"      // 交易编码
34
 	inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
34
 	inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
35
-	inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
35
+	inputData["mdtrt_cert_no"] = ""     // 就诊凭证编号
36
 	inputData["card_sn"] = ""           // 卡识别码
36
 	inputData["card_sn"] = ""           // 卡识别码
37
 	inputData["begntime"] = ""          // 开始时间
37
 	inputData["begntime"] = ""          // 开始时间
38
 	inputData["psn_cert_type"] = ""     // 人员证件类型
38
 	inputData["psn_cert_type"] = ""     // 人员证件类型
39
-	inputData["certno"] = ""            // 证件号码
39
+	inputData["certno"] = certNo        // 证件号码
40
 	inputData["psn_name"] = ""          // 人员姓名
40
 	inputData["psn_name"] = ""          // 人员姓名
41
 	input["data"] = inputData
41
 	input["data"] = inputData
42
 	inputMessage["input"] = input //交易输入
42
 	inputMessage["input"] = input //交易输入
484
 }
484
 }
485
 
485
 
486
 //  门诊费用明细信息撤销
486
 //  门诊费用明细信息撤销
487
-func Gdyb2205(psnNo string, mdtrtId string, chrgBchno string, org_name string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
487
+func Gdyb2205(psnNo string, mdtrtId string, chrgBchno string, org_name string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, fixmedins_code string) string {
488
 	// 生成签名
488
 	// 生成签名
489
 	nonce := GetRandomString(32)
489
 	nonce := GetRandomString(32)
490
 	timestamp := time.Now().Unix()
490
 	timestamp := time.Now().Unix()
491
 	signature := setSignature(timestamp, nonce, secret_key)
491
 	signature := setSignature(timestamp, nonce, secret_key)
492
 
492
 
493
 	// 生成输入报文
493
 	// 生成输入报文
494
-	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, "", insuplc_admdvs, mdtrtarea_admvs)
494
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
495
 	input := make(map[string]interface{})
495
 	input := make(map[string]interface{})
496
 	inputData := make(map[string]interface{})
496
 	inputData := make(map[string]interface{})
497
 	inputMessage["infno"] = "2205" // 交易编码
497
 	inputMessage["infno"] = "2205" // 交易编码
673
 }
673
 }
674
 
674
 
675
 //  门诊结算撤销
675
 //  门诊结算撤销
676
-func Gdyb2208(psnNo string, mdtrtId string, setlId string, org_name string, doctor string, secret_key string) string {
676
+func Gdyb2208(psnNo string, mdtrtId string, setlId string, org_name string, doctor string, secret_key string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) string {
677
 	// 生成签名
677
 	// 生成签名
678
 	nonce := GetRandomString(32)
678
 	nonce := GetRandomString(32)
679
 	timestamp := time.Now().Unix()
679
 	timestamp := time.Now().Unix()
680
 	signature := setSignature(timestamp, nonce, secret_key)
680
 	signature := setSignature(timestamp, nonce, secret_key)
681
 
681
 
682
 	// 生成输入报文
682
 	// 生成输入报文
683
-	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, "", "", "")
683
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
684
+	input := make(map[string]interface{})
685
+	inputData := make(map[string]interface{})
686
+	inputMessage["infno"] = "2208" // 交易编码
687
+
688
+	inputData["psn_no"] = psnNo     // 人员编号 (来自1101接口返回)
689
+	inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
690
+	inputData["setl_id"] = setlId   // 结算 ID
691
+
692
+	input["data"] = inputData
693
+	inputMessage["input"] = input //交易输入
694
+
695
+	bytesData, err := json.Marshal(inputMessage)
696
+	fmt.Println(string(bytesData))
697
+	if err != nil {
698
+		fmt.Println(err.Error())
699
+		return err.Error()
700
+	}
701
+	reader := bytes.NewReader(bytesData)
702
+
703
+	url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2208"
704
+	request, err := http.NewRequest("POST", url, reader)
705
+	if err != nil {
706
+		fmt.Println(err.Error())
707
+		return err.Error()
708
+	}
709
+
710
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
711
+	request.Header.Set("x-tif-paasid", "test_hosp")
712
+	request.Header.Set("x-tif-signature", signature)
713
+	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
714
+	request.Header.Set("x-tif-nonce", nonce)
715
+
716
+	client := http.Client{}
717
+	resp, err := client.Do(request)
718
+	if err != nil {
719
+		fmt.Println(err.Error())
720
+		return err.Error()
721
+	}
722
+	respBytes, err := ioutil.ReadAll(resp.Body)
723
+	if err != nil {
724
+		fmt.Println(err.Error())
725
+		return err.Error()
726
+	}
727
+	str := string(respBytes)
728
+	fmt.Println(str)
729
+	return str
730
+}
731
+
732
+//  门诊结算撤销
733
+func Gdyb3201(psnNo string, mdtrtId string, setlId string, org_name string, doctor string, secret_key string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) string {
734
+	// 生成签名
735
+	nonce := GetRandomString(32)
736
+	timestamp := time.Now().Unix()
737
+	signature := setSignature(timestamp, nonce, secret_key)
738
+
739
+	// 生成输入报文
740
+	inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
684
 	input := make(map[string]interface{})
741
 	input := make(map[string]interface{})
685
 	inputData := make(map[string]interface{})
742
 	inputData := make(map[string]interface{})
686
 	inputMessage["infno"] = "2208" // 交易编码
743
 	inputMessage["infno"] = "2208" // 交易编码

+ 78 - 0
service/his_service.go Ver fichero

720
 	err := XTWriteDB().Model(&patient).Where("patient_id = ? and record_date = ? and user_org_id = ? and status = 1", patientid, recorddate, orgid).Updates(map[string]interface{}{"is_return": 3}).Error
720
 	err := XTWriteDB().Model(&patient).Where("patient_id = ? and record_date = ? and user_org_id = ? and status = 1", patientid, recorddate, orgid).Updates(map[string]interface{}{"is_return": 3}).Error
721
 	return patient, err
721
 	return patient, err
722
 }
722
 }
723
+
724
+type VMOtherHisPrescriptionInfo struct {
725
+	ID                int64                `gorm:"column:id" json:"id" form:"id"`
726
+	UserOrgId         int64                `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
727
+	RecordDate        int64                `gorm:"column:record_date" json:"record_date" form:"record_date"`
728
+	PatientId         int64                `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
729
+	Status            int64                `gorm:"column:status" json:"status" form:"status"`
730
+	CheckGroup        []int64              `gorm:"-" json:"check_group" form:"check_group"`
731
+	VMHisPrescription []*VMHisPrescription `gorm:"ForeignKey:RecordDate,PatientId;AssociationForeignKey:RecordDate,PatientId" json:"prescriptions"`
732
+}
733
+
734
+func (VMOtherHisPrescriptionInfo) TableName() string {
735
+	return "his_prescription_info"
736
+}
737
+
738
+type VMHisPrescription struct {
739
+	ID                     int64                            `gorm:"column:id" json:"id" form:"id"`
740
+	UserOrgId              int64                            `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
741
+	RecordDate             int64                            `gorm:"column:record_date" json:"record_date" form:"record_date"`
742
+	PatientId              int64                            `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
743
+	Status                 int64                            `gorm:"column:status" json:"status" form:"status"`
744
+	OrderStatus            int64                            `gorm:"column:order_status" json:"order_status" form:"order_status"`
745
+	BatchNumber            string                           `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
746
+	PrescriptionNumber     string                           `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
747
+	Type                   int64                            `gorm:"column:type" json:"type" form:"type"`
748
+	HisDoctorAdviceInfo    []*models.HisDoctorAdviceInfo    `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"doctor_advice"`
749
+	HisPrescriptionProject []*models.HisPrescriptionProject `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
750
+}
751
+
752
+func (VMHisPrescription) TableName() string {
753
+	return "his_prescription"
754
+}
755
+
756
+func GetHisPrescriptionByType(change_type int64, record_time int64, org_id int64, patient_id int64) (advice []*VMOtherHisPrescriptionInfo, err error) {
757
+	if change_type == 1 { //根据日期取出上一方数据
758
+		var Id AdviceDate
759
+		err = readDb.Model(&VMOtherHisPrescriptionInfo{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date < ?", patient_id, org_id, record_time).Select("record_date").Group("record_date").Order("record_date asc").Scan(&Id).Error
760
+		err = readDb.Model(&VMOtherHisPrescriptionInfo{}).Where("patient_id = ? AND user_org_id = ? AND  status=1 AND record_date  = ?", patient_id, org_id, Id.RecordDate).
761
+			Preload("VMHisPrescription", func(db *gorm.DB) *gorm.DB {
762
+				return db.Where("status = 1 AND user_org_id = ?", org_id).
763
+					Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ?", org_id).
764
+					Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
765
+						return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
766
+					})
767
+			}).Find(&advice).Error
768
+
769
+	} else if change_type == 2 {
770
+		var Id AdviceDate
771
+		err = readDb.Model(&VMOtherHisPrescriptionInfo{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date > ?", patient_id, org_id, record_time).Select("record_date").Group("record_date").Order("record_date desc").Scan(&Id).Error
772
+		err = readDb.Model(&VMOtherHisPrescriptionInfo{}).Where("patient_id = ? AND user_org_id = ? AND  status=1 AND record_date  = ?", patient_id, org_id, Id.RecordDate).
773
+			Preload("VMHisPrescription", func(db *gorm.DB) *gorm.DB {
774
+				return db.Where("status = 1 AND user_org_id = ?", org_id).
775
+					Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ?", org_id).
776
+					Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
777
+						return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
778
+					})
779
+			}).Find(&advice).Error
780
+	}
781
+	return
782
+}
783
+
784
+func GetCallHisPrescriptions(start_time int64, end_time int64, org_id int64, patient_id int64) (advice []*VMOtherHisPrescriptionInfo, err error) {
785
+	err = readDb.Model(&VMOtherHisPrescriptionInfo{}).Where("patient_id = ? AND user_org_id = ? AND  status=1 AND record_date >= ? AND record_date <= ?", patient_id, org_id, start_time, end_time).
786
+		Preload("VMHisPrescription", func(db *gorm.DB) *gorm.DB {
787
+			return db.Where("status = 1 AND user_org_id = ?", org_id).
788
+				Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ?", org_id).
789
+				Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
790
+					return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
791
+				})
792
+		}).Find(&advice).Error
793
+
794
+	return
795
+}
796
+
797
+func GetHisOrderByID(order_id int64) (order models.HisOrder, err error) {
798
+	err = readDb.Model(&models.HisOrder{}).Where("id = ?", order_id).First(&order).Error
799
+	return
800
+}

+ 6 - 0
service/patient_service.go Ver fichero

710
 	err = readDb.Model(&models.DoctorAdvice{}).Where("id = ? and user_org_id=? and status = 1", id, orgID).First(&advice).Error
710
 	err = readDb.Model(&models.DoctorAdvice{}).Where("id = ? and user_org_id=? and status = 1", id, orgID).First(&advice).Error
711
 	return
711
 	return
712
 }
712
 }
713
+
714
+func FindHisDoctorAdvice(orgID, id int64) (advice models.HisDoctorAdviceInfo, err error) {
715
+	err = readDb.Model(&models.HisDoctorAdviceInfo{}).Where("id = ? and user_org_id=? and status = 1", id, orgID).First(&advice).Error
716
+	return
717
+}
718
+
713
 func FindDoctorAdviceByGroupNo(orgID, groupNo int64) (advice models.DoctorAdvice, err error) {
719
 func FindDoctorAdviceByGroupNo(orgID, groupNo int64) (advice models.DoctorAdvice, err error) {
714
 	err = readDb.Model(&models.DoctorAdvice{}).Where("groupno = ? and user_org_id=? and status = 1", groupNo, orgID).First(&advice).Error
720
 	err = readDb.Model(&models.DoctorAdvice{}).Where("groupno = ? and user_org_id=? and status = 1", groupNo, orgID).First(&advice).Error
715
 	return
721
 	return