Browse Source

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

XMLWAN 4 years ago
parent
commit
8d6d4e9937

+ 7 - 8
controllers/base_api_controller.go View File

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

+ 7 - 1
controllers/dialysis_record_api_controller.go View File

@@ -265,7 +265,12 @@ func (this *DialysisRecordAPIController) DialysisSchedule() {
265 265
 
266 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 275
 	returnData := map[string]interface{}{
271 276
 		"patient":                     patient,
@@ -292,6 +297,7 @@ func (this *DialysisRecordAPIController) DialysisSchedule() {
292 297
 		"headNurses":                  headNurses,
293 298
 		"system_prescribe":            systemDialysisPrescribe,
294 299
 		"his_advices":                 his_advices,
300
+		"is_open_config":              is_open_config,
295 301
 	}
296 302
 	this.ServeSuccessJSON(returnData)
297 303
 

+ 18 - 4
controllers/gdyb_controller.go View File

@@ -226,9 +226,15 @@ func (c *GdybController) PostSix() {
226 226
 	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
227 227
 
228 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 238
 	c.ServeSuccessJSON(map[string]interface{}{
233 239
 		"pre": result,
234 240
 	})
@@ -291,8 +297,16 @@ func (c *GdybController) PostNine() {
291 297
 	org_name := c.GetString("org_name")
292 298
 	doctor := c.GetString("doctor")
293 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 310
 	c.ServeSuccessJSON(map[string]interface{}{
297 311
 		"pre": result,
298 312
 	})

+ 126 - 12
controllers/his_api_controller.go View File

@@ -57,12 +57,9 @@ func HisManagerApiRegistRouters() {
57 57
 
58 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,7 +354,7 @@ func (c *HisApiController) CreateHisPrescription() {
357 354
 							s.Status = 1
358 355
 							s.UserOrgId = adminInfo.CurrentOrgId
359 356
 							s.RecordDate = recordDateTime
360
-							s.StartTime = recordDateTime
357
+							s.StartTime = time.Now().Unix()
361 358
 							s.Groupno = groupNo
362 359
 							s.CreatedTime = ctime
363 360
 							s.UpdatedTime = mtime
@@ -1304,7 +1301,7 @@ func (c *HisApiController) GetRegisterInfo() {
1304 1301
 
1305 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 1305
 		resp, requestErr := http.Get(api)
1309 1306
 
1310 1307
 		if requestErr != nil {
@@ -1387,7 +1384,7 @@ func (c *HisApiController) GetRegisterInfo() {
1387 1384
 		doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
1388 1385
 
1389 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 1388
 				res.Output.Iinfo[0].Insutype + "&psn_no=" + res.Output.Baseinfo.PsnNo +
1392 1389
 				"&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&ipt_otp_no=" + ipt_otp_no +
1393 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,7 +1439,7 @@ func (c *HisApiController) GetRegisterInfo() {
1442 1439
 			diagnosisConfig, _ := service.FindDiagnoseById(patientPrescription.Diagnosis)
1443 1440
 
1444 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 1443
 					"&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
1447 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 1445
 					"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
@@ -1602,7 +1599,7 @@ func (c *HisApiController) GetUploadInfo() {
1602 1599
 
1603 1600
 	if config.IsOpen == 1 { //对接了医保,走医保流程
1604 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 1603
 		resp, _ := client.Do(req)
1607 1604
 		defer resp.Body.Close()
1608 1605
 		body, ioErr := ioutil.ReadAll(resp.Body)
@@ -2009,11 +2006,82 @@ func (c *HisApiController) GetUploadInfo() {
2009 2006
 func (c *HisApiController) Refund() {
2010 2007
 	order_id, _ := c.GetInt64("order_id")
2011 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 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 2028
 	config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
2015 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 2085
 	} else {
2018 2086
 		err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
2019 2087
 		if err == nil {
@@ -2024,9 +2092,7 @@ func (c *HisApiController) Refund() {
2024 2092
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2025 2093
 			return
2026 2094
 		}
2027
-
2028 2095
 	}
2029
-
2030 2096
 }
2031 2097
 
2032 2098
 func (this *HisApiController) AdditionalCharge() {
@@ -2115,3 +2181,51 @@ func (this *HisApiController) GetAdminUsers() {
2115 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 View File

@@ -562,17 +562,17 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
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 577
 		theEvaluation, getPEErr := service.MobileGetPredialysisEvaluation(adminUserInfo.Org.Id, id, theAssessmentDateTime)
578 578
 		if getPEErr != nil {

+ 26 - 16
controllers/new_mobile_api_controllers/good_types.json View File

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

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

File diff suppressed because it is too large
+ 624 - 288
controllers/patient_api_controller.go


+ 4 - 1
controllers/verify_login_controller.go View File

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

+ 3 - 3
main.go View File

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

+ 16 - 0
models/his_models.go View File

@@ -422,6 +422,21 @@ func (HisDoctorAdviceParentTemplate) TableName() string {
422 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 440
 type HisDoctorAdviceTemplate struct {
426 441
 	ID                    int64   `gorm:"column:id" json:"id" form:"id"`
427 442
 	OrgId                 int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
@@ -448,6 +463,7 @@ type HisDoctorAdviceTemplate struct {
448 463
 	DrugId                int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
449 464
 	Way                   int64   `gorm:"column:way" json:"way" form:"way"`
450 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 469
 func (HisDoctorAdviceTemplate) TableName() string {

+ 1 - 0
models/vm_models.go View File

@@ -348,6 +348,7 @@ type VMGoodsType struct {
348 348
 	Status   int64  `gorm:"column:status" json:"status"`
349 349
 	Type     int64  `gorm:"column:type" json:"type"`
350 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 354
 func (VMGoodsType) TableName() string {

+ 17 - 0
service/dialysis_service.go View File

@@ -320,11 +320,22 @@ func ExceDoctorAdviceById(m *models.DoctorAdvice, id int64, patientId int64) err
320 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 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 329
 func CheckDoctorAdviceById(m *models.DoctorAdvice, id int64, patientId int64) error {
324 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 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 339
 func CreateMonitor(m *models.MonitoringRecord) (err error) {
329 340
 	return writeDb.Create(m).Error
330 341
 }
@@ -1122,6 +1133,12 @@ func GetExecutionDoctors(orgid int64, patientid int64, id int64) (doctorAdvice [
1122 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 1142
 func FindHisDoctorAdviceById(orgID int64, id int64) (advice models.HisDoctorAdviceInfo, err error) {
1126 1143
 	err = readDb.Model(&models.HisDoctorAdviceInfo{}).Where("user_org_id=? and status=1 and id = ?", orgID, id).First(&advice).Error
1127 1144
 	return

+ 63 - 6
service/gdyb_service.go View File

@@ -32,11 +32,11 @@ func Gdyb1101(certNo string, org_name string, doctor string, fixmedins_code stri
32 32
 	inputData := make(map[string]interface{})
33 33
 	inputMessage["infno"] = "1101"      // 交易编码
34 34
 	inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
35
-	inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
35
+	inputData["mdtrt_cert_no"] = ""     // 就诊凭证编号
36 36
 	inputData["card_sn"] = ""           // 卡识别码
37 37
 	inputData["begntime"] = ""          // 开始时间
38 38
 	inputData["psn_cert_type"] = ""     // 人员证件类型
39
-	inputData["certno"] = ""            // 证件号码
39
+	inputData["certno"] = certNo        // 证件号码
40 40
 	inputData["psn_name"] = ""          // 人员姓名
41 41
 	input["data"] = inputData
42 42
 	inputMessage["input"] = input //交易输入
@@ -484,14 +484,14 @@ func Gdyb2204(psnNo string, mdtrtId string, hisPrescription []*models.HisPrescri
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 489
 	nonce := GetRandomString(32)
490 490
 	timestamp := time.Now().Unix()
491 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 495
 	input := make(map[string]interface{})
496 496
 	inputData := make(map[string]interface{})
497 497
 	inputMessage["infno"] = "2205" // 交易编码
@@ -673,14 +673,71 @@ func Gdyb2207(psnNo string, mdtrtId string, chrgBchno string, certNo string, ins
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 678
 	nonce := GetRandomString(32)
679 679
 	timestamp := time.Now().Unix()
680 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 741
 	input := make(map[string]interface{})
685 742
 	inputData := make(map[string]interface{})
686 743
 	inputMessage["infno"] = "2208" // 交易编码

+ 78 - 0
service/his_service.go View File

@@ -720,3 +720,81 @@ func UpdateHisPatientIsReturn(patientid int64, recorddate int64, orgid int64) (m
720 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 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 View File

@@ -710,6 +710,12 @@ func FindDoctorAdvice(orgID, id int64) (advice models.DoctorAdvice, err error) {
710 710
 	err = readDb.Model(&models.DoctorAdvice{}).Where("id = ? and user_org_id=? and status = 1", id, orgID).First(&advice).Error
711 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 719
 func FindDoctorAdviceByGroupNo(orgID, groupNo int64) (advice models.DoctorAdvice, err error) {
714 720
 	err = readDb.Model(&models.DoctorAdvice{}).Where("groupno = ? and user_org_id=? and status = 1", groupNo, orgID).First(&advice).Error
715 721
 	return