Browse Source

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

csx 4 years ago
parent
commit
8cfade900b

+ 76 - 2
controllers/gobal_config_api_controller.go View File

@@ -64,6 +64,11 @@ func GobalConfigRegistRouters() {
64 64
 
65 65
 	beego.Router("/api/patients/search", &GobalConfigApiController{}, "Post:GetPatientsByKeyWord")
66 66
 
67
+	beego.Router("/api/xtconfig/get", &GobalConfigApiController{}, "get:GetXTHisConfig")
68
+	beego.Router("/api/xtconfig/isopen", &GobalConfigApiController{}, "post:PostXTHisConfig")
69
+
70
+	beego.Router("/api/isopen/init", &GobalConfigApiController{}, "get:GetAllIsOpenConfig")
71
+
67 72
 }
68 73
 
69 74
 //provinces, _ := service.GetDistrictsByUpid(0)21
@@ -343,7 +348,6 @@ func (c *GobalConfigApiController) PostConfig() {
343 348
 		ConfigType:     config_type,
344 349
 	}
345 350
 	err := service.CreateConfigData(config)
346
-
347 351
 	if err == nil {
348 352
 		c.ServeSuccessJSON(map[string]interface{}{
349 353
 			"config": config,
@@ -352,7 +356,6 @@ func (c *GobalConfigApiController) PostConfig() {
352 356
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
353 357
 		return
354 358
 	}
355
-
356 359
 }
357 360
 
358 361
 func (c *GobalConfigApiController) GetDataUploadConfig() {
@@ -1292,3 +1295,74 @@ func (this *GobalConfigApiController) GetPatientsByKeyWord() {
1292 1295
 		"patient": patient,
1293 1296
 	})
1294 1297
 }
1298
+
1299
+func (c *GobalConfigApiController) PostXTHisConfig() {
1300
+	is_open, _ := c.GetBool("is_open", false)
1301
+	adminUserInfo := c.GetAdminUserInfo()
1302
+	org_id := adminUserInfo.CurrentOrgId
1303
+	isOpen := 0
1304
+
1305
+	if is_open {
1306
+		isOpen = 1
1307
+	} else {
1308
+		isOpen = 2
1309
+	}
1310
+
1311
+	config := models.XtHisConfig{
1312
+		UserOrgId: org_id,
1313
+		IsOpen:    int64(isOpen),
1314
+		Status:    1,
1315
+		Ctime:     time.Now().Unix(),
1316
+		Mtime:     time.Now().Unix(),
1317
+	}
1318
+
1319
+	errs, configs := service.FindXTHisRecordByOrgId(org_id)
1320
+
1321
+	if errs == gorm.ErrRecordNotFound {
1322
+		err := service.CreateXTHisRecord(&config)
1323
+		if err != nil {
1324
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1325
+			return
1326
+		}
1327
+
1328
+	} else if errs == nil {
1329
+		modifyConfig := models.XtHisConfig{
1330
+			ID:        configs.ID,
1331
+			UserOrgId: org_id,
1332
+			Status:    1,
1333
+			Ctime:     time.Now().Unix(),
1334
+			Mtime:     time.Now().Unix(),
1335
+			IsOpen:    int64(isOpen),
1336
+		}
1337
+
1338
+		err := service.UpdateXTHisRecord(&modifyConfig)
1339
+		if err != nil {
1340
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1341
+			return
1342
+		}
1343
+
1344
+	}
1345
+
1346
+	c.ServeSuccessJSON(map[string]interface{}{
1347
+		"is_open": is_open,
1348
+	})
1349
+
1350
+	return
1351
+}
1352
+func (c *GobalConfigApiController) GetXTHisConfig() {
1353
+	adminUserInfo := c.GetAdminUserInfo()
1354
+	_, config := service.FindXTHisRecordByOrgId(adminUserInfo.CurrentOrgId)
1355
+	c.ServeSuccessJSON(map[string]interface{}{
1356
+		"config": config,
1357
+	})
1358
+}
1359
+
1360
+func (c *GobalConfigApiController) GetAllIsOpenConfig() {
1361
+	adminUserInfo := c.GetAdminUserInfo()
1362
+	_, config := service.FindXTHisRecordByOrgId(adminUserInfo.CurrentOrgId)
1363
+
1364
+	c.ServeSuccessJSON(map[string]interface{}{
1365
+		"is_open_xt_his": config.IsOpen,
1366
+	})
1367
+
1368
+}

+ 14 - 7
controllers/his_api_controller.go View File

@@ -115,6 +115,7 @@ func (c *HisApiController) GetHisPatientInfo() {
115 115
 	prescriptions, _ := service.GetHisPrescription(admin.CurrentOrgId, patient_id, recordDateTime)
116 116
 	case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.CurrentOrgId, patient_id, recordDateTime)
117 117
 	patientPrescriptionInfo, _ := service.FindPatientPrescriptionInfo(admin.CurrentOrgId, patient_id, recordDateTime)
118
+	lastPatientPrescriptionInfo, _ := service.FindLastPatientPrescriptionInfo(admin.CurrentOrgId, patient_id, recordDateTime)
118 119
 
119 120
 	c.ServeSuccessJSON(map[string]interface{}{
120 121
 		"his_info":     his_patient_info,
@@ -122,6 +123,7 @@ func (c *HisApiController) GetHisPatientInfo() {
122 123
 		"prescription": prescriptions,
123 124
 		"case_history": case_history,
124 125
 		"info":         patientPrescriptionInfo,
126
+		"last_info":    lastPatientPrescriptionInfo,
125 127
 	})
126 128
 	return
127 129
 
@@ -132,13 +134,15 @@ func (c *HisApiController) GetHisPrescriptionConfig() {
132 134
 	advices, _ := service.FindAllHisAdviceTemplate(adminInfo.CurrentOrgId)
133 135
 	//获取所有基础药
134 136
 	drugs, _ := service.GetAllDrugLibList(adminInfo.CurrentOrgId)
135
-
136 137
 	drugways, _, _ := service.GetDrugWayDics(adminInfo.CurrentOrgId)
137 138
 	efs, _, _ := service.GetExecutionFrequencyDics(adminInfo.CurrentOrgId)
138
-
139 139
 	doctors, _ := service.GetHisAdminUserDoctors(adminInfo.CurrentOrgId)
140 140
 	//获取所有科室信息
141 141
 	department, _ := service.GetAllDepartMent(adminInfo.CurrentOrgId)
142
+
143
+	//获取诊断信息
144
+	sick, _ := service.FindAllSick(adminInfo.CurrentOrgId)
145
+
142 146
 	c.ServeSuccessJSON(map[string]interface{}{
143 147
 		"drugs":            drugs,
144 148
 		"advices_template": advices,
@@ -146,6 +150,7 @@ func (c *HisApiController) GetHisPrescriptionConfig() {
146 150
 		"efs":              efs,
147 151
 		"doctors":          doctors,
148 152
 		"department":       department,
153
+		"sick":             sick,
149 154
 	})
150 155
 }
151 156
 func (c *HisApiController) CreateHisPrescription() {
@@ -272,8 +277,8 @@ func (c *HisApiController) CreateHisPrescription() {
272 277
 
273 278
 				if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
274 279
 					advices := items["advices"].([]interface{})
275
-					group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
276
-					groupNo := group + 1
280
+					//group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
281
+					groupNo := int64(0)
277 282
 					ctime := time.Now().Unix()
278 283
 					mtime := ctime
279 284
 					if len(advices) > 0 {
@@ -1537,12 +1542,13 @@ func (c *HisApiController) GetUploadInfo() {
1537 1542
 		order := &models.HisOrder{
1538 1543
 			UserOrgId:          adminUser.CurrentOrgId,
1539 1544
 			HisPatientId:       his.ID,
1540
-			PatientId:          his.PatientId,
1545
+			PatientId:          id,
1541 1546
 			SettleAccountsDate: recordDateTime,
1542 1547
 			Ctime:              time.Now().Unix(),
1543 1548
 			Mtime:              time.Now().Unix(),
1544 1549
 			Status:             1,
1545
-			OrderStatus:        3,
1550
+			OrderStatus:        2,
1551
+			Number:             chrg_bchno,
1546 1552
 		}
1547 1553
 		err = service.CreateOrder(order)
1548 1554
 		if err != nil {
@@ -1609,7 +1615,7 @@ func (c *HisApiController) GetUploadInfo() {
1609 1615
 				DetItemFeeSumamt: detItemFeeSumamt,
1610 1616
 				Cnt:              cut,
1611 1617
 				Pric:             pric,
1612
-				PatientId:        his.PatientId,
1618
+				PatientId:        id,
1613 1619
 				Status:           1,
1614 1620
 				Mtime:            time.Now().Unix(),
1615 1621
 				Ctime:            time.Now().Unix(),
@@ -1622,6 +1628,7 @@ func (c *HisApiController) GetUploadInfo() {
1622 1628
 			service.CreateOrderInfo(info)
1623 1629
 		}
1624 1630
 		err := service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
1631
+		err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
1625 1632
 		err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
1626 1633
 		if err == nil {
1627 1634
 			c.ServeSuccessJSON(map[string]interface{}{

+ 154 - 0
controllers/manager_center_api_controller.go View File

@@ -59,6 +59,13 @@ func ManagerCenterRegistRouters() {
59 59
 	beego.Router("/api/stock/good/info/get", &ManagerCenterApiController{}, "get:GetGoodInfoByGoodId")
60 60
 	beego.Router("/api/stock/good/info", &ManagerCenterApiController{}, "get:GetGoodInfoById")
61 61
 
62
+	//门诊大病
63
+	beego.Router("/api/mz/sick/create", &ManagerCenterApiController{}, "post:CreateMZSick")
64
+	beego.Router("/api/mz/sick/modify", &ManagerCenterApiController{}, "post:ModifyMZSick")
65
+	beego.Router("/api/mz/sick/list", &ManagerCenterApiController{}, "get:GetMZSickList")
66
+	beego.Router("/api/mz/sick/delete", &ManagerCenterApiController{}, "post:DeleteMZSick")
67
+	beego.Router("/api/mz/sick/get", &ManagerCenterApiController{}, "get:GetMZSick")
68
+
62 69
 }
63 70
 
64 71
 func (c *ManagerCenterApiController) CreateBaseDrugLib() {
@@ -1625,3 +1632,150 @@ func (c *ManagerCenterApiController) GetMedicineInsurancePercent() {
1625 1632
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1626 1633
 	}
1627 1634
 }
1635
+
1636
+func (c *ManagerCenterApiController) CreateMZSick() {
1637
+	class_name := c.GetString("class_name")
1638
+	content_code := c.GetString("content_code")
1639
+	country_code := c.GetString("country_code")
1640
+	country_content_name := c.GetString("country_content_name")
1641
+	remark := c.GetString("remark")
1642
+	pinyin := c.GetString("pinyin")
1643
+	wubi := c.GetString("wubi")
1644
+
1645
+	if len(class_name) <= 0 {
1646
+		utils.ErrorLog("len(class_name) == 0")
1647
+
1648
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1649
+		return
1650
+	}
1651
+
1652
+	if len(content_code) <= 0 {
1653
+		utils.ErrorLog("len(content_code) == 0")
1654
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1655
+		return
1656
+	}
1657
+
1658
+	adminUserInfo := c.GetAdminUserInfo()
1659
+
1660
+	dealer := models.OutpatientServiceSick{
1661
+		ClassName:          class_name,
1662
+		ContentCode:        content_code,
1663
+		CountryCode:        country_code,
1664
+		CountryContentName: country_content_name,
1665
+		Ctime:              time.Now().Unix(),
1666
+		Mtime:              time.Now().Unix(),
1667
+		Remark:             remark,
1668
+		UserOrgId:          adminUserInfo.CurrentOrgId,
1669
+		Status:             1,
1670
+		Pinyin:             pinyin,
1671
+		Wubi:               wubi,
1672
+	}
1673
+
1674
+	err, dealers := service.AddSigleMZSick(&dealer)
1675
+	if err == nil {
1676
+		c.ServeSuccessJSON(map[string]interface{}{
1677
+			"sick": dealers,
1678
+		})
1679
+
1680
+	} else {
1681
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1682
+
1683
+	}
1684
+
1685
+}
1686
+func (c *ManagerCenterApiController) ModifyMZSick() {
1687
+	id, _ := c.GetInt64("id", 0)
1688
+
1689
+	class_name := c.GetString("class_name")
1690
+	content_code := c.GetString("content_code")
1691
+	country_code := c.GetString("country_code")
1692
+	country_content_name := c.GetString("country_content_name")
1693
+	remark := c.GetString("remark")
1694
+	pinyin := c.GetString("pinyin")
1695
+	wubi := c.GetString("wubi")
1696
+
1697
+	if id <= 0 {
1698
+		utils.ErrorLog("id == 0")
1699
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1700
+		return
1701
+	}
1702
+
1703
+	if len(class_name) <= 0 {
1704
+		utils.ErrorLog("len(class_name) == 0")
1705
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1706
+		return
1707
+	}
1708
+
1709
+	if len(content_code) <= 0 {
1710
+		utils.ErrorLog("len(content_code) == 0")
1711
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1712
+		return
1713
+	}
1714
+
1715
+	adminUserInfo := c.GetAdminUserInfo()
1716
+	dealer := models.OutpatientServiceSick{
1717
+		ID:                 id,
1718
+		ClassName:          class_name,
1719
+		ContentCode:        content_code,
1720
+		CountryCode:        country_code,
1721
+		CountryContentName: country_content_name,
1722
+		Ctime:              time.Now().Unix(),
1723
+		Mtime:              time.Now().Unix(),
1724
+		Remark:             remark,
1725
+		UserOrgId:          adminUserInfo.CurrentOrgId,
1726
+		Pinyin:             pinyin,
1727
+		Wubi:               wubi,
1728
+		Status:             1,
1729
+	}
1730
+
1731
+	err := service.ModifyMZSick(&dealer)
1732
+
1733
+	if err == nil {
1734
+		c.ServeSuccessJSON(map[string]interface{}{
1735
+			"sick": dealer,
1736
+		})
1737
+	} else {
1738
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1739
+	}
1740
+}
1741
+func (c *ManagerCenterApiController) GetMZSickList() {
1742
+	page, _ := c.GetInt64("page", 1)
1743
+	limit, _ := c.GetInt64("limit", 7)
1744
+	adminUserInfo := c.GetAdminUserInfo()
1745
+	mzSick, total, err := service.FindAllMZSickList(adminUserInfo.CurrentOrgId, page, limit)
1746
+	if err == nil {
1747
+		c.ServeSuccessJSON(map[string]interface{}{
1748
+			"sick":  mzSick,
1749
+			"total": total,
1750
+		})
1751
+	} else {
1752
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1753
+	}
1754
+}
1755
+func (c *ManagerCenterApiController) DeleteMZSick() {
1756
+	id, _ := c.GetInt64("id", 0)
1757
+	total, _ := service.FindStockInByDealerId(id)
1758
+	if total > 0 {
1759
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteDealerWrong)
1760
+		return
1761
+	}
1762
+	err := service.DeleteMZSickById(id)
1763
+	if err == nil {
1764
+		c.ServeSuccessJSON(map[string]interface{}{
1765
+			"msg": "删除成功",
1766
+		})
1767
+	} else {
1768
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1769
+	}
1770
+}
1771
+func (c *ManagerCenterApiController) GetMZSick() {
1772
+	id, _ := c.GetInt64("id", 0)
1773
+	mzSick, err := service.FindMZSickById(id)
1774
+	if err == nil {
1775
+		c.ServeSuccessJSON(map[string]interface{}{
1776
+			"sick": mzSick,
1777
+		})
1778
+	} else {
1779
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1780
+	}
1781
+}

+ 24 - 3
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -367,7 +367,12 @@ func (this *DialysisAPIController) DialysisRecord() {
367 367
 
368 368
 	//operators, _ := service.GetAllAdminUserES(adminInfo.Org.Id, adminInfo.App.Id)
369 369
 
370
-	his_advices, _ := service.GetAllHisDoctorAdvice(adminInfo.Org.Id, patientID, date.Unix())
370
+	_, is_open_config := service.FindXTHisRecordByOrgId(adminInfo.Org.Id)
371
+
372
+	var his_advices []*models.HisDoctorAdviceInfo
373
+	if is_open_config.IsOpen == 1 {
374
+		his_advices, _ = service.GetAllHisDoctorAdvice(adminInfo.Org.Id, patientID, date.Unix())
375
+	}
371 376
 
372 377
 	if getLPEErr != nil {
373 378
 		this.ErrorLog("获取上一次透前评估失败:%v", getLPEErr)
@@ -1130,7 +1135,7 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1130 1135
 		PreImpulse:                 pre_impulse,
1131 1136
 		AnticoagulantStopTimeHour:  anticoagulant_stop_time_hour,
1132 1137
 		AnticoagulantStopTimeMin:   anticoagulant_stop_time_min,
1133
-		Blood:                      blood,
1138
+		Blood: blood,
1134 1139
 	}
1135 1140
 
1136 1141
 	_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
@@ -1893,7 +1898,7 @@ func (c *DialysisAPIController) PostSolution() {
1893 1898
 		ALiquid:                   a_liquid,
1894 1899
 		AnticoagulantStopTimeMin:  anticoagulant_stop_time_min,
1895 1900
 		AnticoagulantStopTimeHour: anticoagulant_stop_time_hour,
1896
-		Blood:                     blood,
1901
+		Blood: blood,
1897 1902
 	}
1898 1903
 
1899 1904
 	_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
@@ -4300,3 +4305,19 @@ func RemoveRepeatedGoodTwo(arr []*models.DialysisBeforePrepare) (newArr []*model
4300 4305
 	}
4301 4306
 	return
4302 4307
 }
4308
+
4309
+func (c *DialysisAPIController) GetDepartment() {
4310
+	adminInfo := c.GetMobileAdminUserInfo()
4311
+	departments, err := service.GetAllDepartMent(adminInfo.Org.Id)
4312
+	if err == nil {
4313
+		c.ServeSuccessJSON(map[string]interface{}{
4314
+			"departments": departments,
4315
+		})
4316
+	} else {
4317
+
4318
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
4319
+		return
4320
+
4321
+	}
4322
+
4323
+}

+ 2 - 0
controllers/mobile_api_controllers/mobile_api_router_register.go View File

@@ -134,4 +134,6 @@ func MobileAPIControllersRegisterRouters() {
134 134
 
135 135
 	beego.Router("/m/api/drug/get", &DialysisAPIController{}, "Get:GetAllDrug")
136 136
 
137
+	beego.Router("/m/api/department/get", &DialysisAPIController{}, "Get:GetDepartment")
138
+
137 139
 }

File diff suppressed because it is too large
+ 556 - 573
controllers/mobile_api_controllers/patient_api_controller.go


+ 11 - 1
controllers/new_mobile_api_controllers/new_role_api_controller.go View File

@@ -53,6 +53,9 @@ func (this *NewRoleApiController) EditAdmin() {
53 53
 	user_type, _ := this.GetInt64("user_type", 0)
54 54
 	user_title, _ := this.GetInt64("user_title", 0)
55 55
 
56
+	department_name := this.GetString("department_name")
57
+	department_id, _ := this.GetInt64("department_id", 0)
58
+
56 59
 	//roleIds := this.GetString("role_ids")
57 60
 
58 61
 	if adminUserId <= 0 || len(name) == 0 || len(roleIds) <= 0 {
@@ -75,7 +78,10 @@ func (this *NewRoleApiController) EditAdmin() {
75 78
 	appRole.ModifyTime = time.Now().Unix()
76 79
 	appRole.UserType = int8(user_type)
77 80
 	appRole.UserTitle = int8(user_title)
81
+	appRole.Department = department_name
82
+	appRole.DepartmentId = department_id
78 83
 	saveErr := service.SaveAppRole(appRole)
84
+
79 85
 	if saveErr != nil {
80 86
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
81 87
 	} else {
@@ -170,6 +176,9 @@ func (this *NewRoleApiController) CreateAdminUser() {
170 176
 	name := this.GetString("name")
171 177
 	role_ids := this.GetString("role_ids")
172 178
 	userTitle := this.GetString("title")
179
+	department_name := this.GetString("department_name")
180
+	department_id, _ := this.GetInt64("department_id")
181
+
173 182
 	user_type, _ := this.GetInt("user_type", 0)
174 183
 	user_title, _ := this.GetInt("user_title", 0)
175 184
 	if len(mobile) == 0 || len(name) == 0 || len(role_ids) <= 0 {
@@ -184,7 +193,8 @@ func (this *NewRoleApiController) CreateAdminUser() {
184 193
 		return
185 194
 	} else {
186 195
 		if adminUser == nil { //新增账号和用户
187
-			_, password, createErr := service.CreateGeneralAdminUser(adminUserInfo.Org.Id, adminUserInfo.App.Id, mobile, name, userTitle, role_ids, user_type, user_title)
196
+
197
+			_, password, createErr := service.CreateGeneralAdminUser(adminUserInfo.Org.Id, adminUserInfo.App.Id, mobile, name, userTitle, role_ids, user_type, user_title, department_id, department_name)
188 198
 			if createErr != nil {
189 199
 				//beego.Error("创建管理员失败:", createErr)
190 200
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)

+ 4 - 1
controllers/role_controller.go View File

@@ -874,6 +874,9 @@ func (this *RoleAPIController) AddAdmin() {
874 874
 	userTitle, _ := this.GetInt("title")
875 875
 	roleIds := this.GetString("role")
876 876
 	user_title_name := this.GetString("user_title_name")
877
+	department_name := this.GetString("department_name")
878
+	department_id, _ := this.GetInt64("department_id")
879
+
877 880
 	if len(mobile) == 0 || len(name) == 0 || (userType != 2 && userType != 3 && userType != 4) || len(roleIds) <= 0 {
878 881
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
879 882
 		return
@@ -886,7 +889,7 @@ func (this *RoleAPIController) AddAdmin() {
886 889
 		return
887 890
 	} else {
888 891
 		if adminUser == nil { //新增账号和用户
889
-			_, password, createErr := service.CreateGeneralAdminUser(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, mobile, name, user_title_name, roleIds, userType, userTitle)
892
+			_, password, createErr := service.CreateGeneralAdminUser(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, mobile, name, user_title_name, roleIds, userType, userTitle, department_id, department_name)
890 893
 			if createErr != nil {
891 894
 				//beego.Error("创建管理员失败:", createErr)
892 895
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)

+ 19 - 0
models/data_models.go View File

@@ -107,3 +107,22 @@ type FiledConfig struct {
107 107
 func (FiledConfig) TableName() string {
108 108
 	return "xt_filed_config"
109 109
 }
110
+
111
+type OutpatientServiceSick struct {
112
+	ID                 int64  `gorm:"column:id" json:"id" form:"id"`
113
+	ClassName          string `gorm:"column:class_name" json:"class_name" form:"class_name"`
114
+	Pinyin             string `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
115
+	Wubi               string `gorm:"column:wubi" json:"wubi" form:"wubi"`
116
+	ContentCode        string `gorm:"column:content_code" json:"content_code" form:"content_code"`
117
+	CountryCode        string `gorm:"column:country_code" json:"country_code" form:"country_code"`
118
+	CountryContentName string `gorm:"column:country_content_name" json:"country_content_name" form:"country_content_name"`
119
+	Remark             string `gorm:"column:remark" json:"remark" form:"remark"`
120
+	UserOrgId          int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
121
+	Status             int64  `gorm:"column:status" json:"status" form:"status"`
122
+	Ctime              int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
123
+	Mtime              int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
124
+}
125
+
126
+func (OutpatientServiceSick) TableName() string {
127
+	return "outpatient_service_sick"
128
+}

+ 1 - 0
models/drug.go View File

@@ -52,6 +52,7 @@ type BaseDrugLib struct {
52 52
 	OrgId                       int64                          `gorm:"column:org_id" json:"org_id" form:"org_id"`
53 53
 	DrugCode                    string                         `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
54 54
 	MedicineInsurancePercentage []*MedicineInsurancePercentage `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"monitoring_record"`
55
+	DrugWarehouseInfo           []*DrugWarehouseInfo           `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" json:"stock_in"`
55 56
 }
56 57
 
57 58
 func (BaseDrugLib) TableName() string {

+ 13 - 0
models/his_models.go View File

@@ -725,3 +725,16 @@ type MedicalInsuranceOrgConfig struct {
725 725
 func (MedicalInsuranceOrgConfig) TableName() string {
726 726
 	return "medical_insurance_org_config"
727 727
 }
728
+
729
+type XtHisConfig struct {
730
+	ID        int64 `gorm:"column:id" json:"id" form:"id"`
731
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
732
+	Ctime     int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
733
+	Mtime     int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
734
+	Status    int64 `gorm:"column:status" json:"status" form:"status"`
735
+	IsOpen    int64 `gorm:"column:is_open" json:"is_open" form:"is_open"`
736
+}
737
+
738
+func (XtHisConfig) TableName() string {
739
+	return "xt_his_config"
740
+}

+ 16 - 13
models/patient_models.go View File

@@ -313,19 +313,22 @@ func (DialysisSolution) TableName() string {
313 313
 }
314 314
 
315 315
 type UserAdminRole struct {
316
-	ID          int64  `gorm:"column:id" json:"id"`
317
-	AdminUserId int64  `gorm:"column:admin_user_id" json:"admin_user_id"`
318
-	OrgId       int64  `gorm:"column:org_id" json:"org_id"`
319
-	AppId       int64  `gorm:"column:app_id" json:"app_id"`
320
-	RoleId      int64  `gorm:"column:role_id" json:"role_id"`
321
-	UserName    string `gorm:"column:user_name" json:"user_name"`
322
-	Avatar      string `gorm:"column:avatar" json:"avatar"`
323
-	UserType    int64  `gorm:"column:user_type" json:"user_type"`
324
-	UserTitle   int64  `gorm:"column:user_title" json:"user_title"`
325
-	Intro       string `gorm:"column:intro" json:"intro"`
326
-	Status      int64  `gorm:"column:status" json:"status"`
327
-	Ctime       int64  `gorm:"column:ctime" json:"ctime"`
328
-	Mtime       int64  `gorm:"column:mtime" json:"mtime"`
316
+	ID              int64           `gorm:"column:id" json:"id"`
317
+	AdminUserId     int64           `gorm:"column:admin_user_id" json:"admin_user_id"`
318
+	OrgId           int64           `gorm:"column:org_id" json:"org_id"`
319
+	AppId           int64           `gorm:"column:app_id" json:"app_id"`
320
+	RoleId          int64           `gorm:"column:role_id" json:"role_id"`
321
+	UserName        string          `gorm:"column:user_name" json:"user_name"`
322
+	Avatar          string          `gorm:"column:avatar" json:"avatar"`
323
+	UserType        int64           `gorm:"column:user_type" json:"user_type"`
324
+	UserTitle       int64           `gorm:"column:user_title" json:"user_title"`
325
+	Intro           string          `gorm:"column:intro" json:"intro"`
326
+	Status          int64           `gorm:"column:status" json:"status"`
327
+	Ctime           int64           `gorm:"column:ctime" json:"ctime"`
328
+	Mtime           int64           `gorm:"column:mtime" json:"mtime"`
329
+	Department      string          `gorm:"column:department" json:"department"`
330
+	DepartmentId    int64           `gorm:"column:department_id" json:"department_id"`
331
+	XtHisDepartment XtHisDepartment `json:"department" gorm:"foreignkey:DepartmentId;AssociationForeignKey:ID;"`
329 332
 }
330 333
 
331 334
 func (UserAdminRole) TableName() string {

+ 2 - 0
models/role_models.go View File

@@ -61,6 +61,8 @@ type App_Role struct {
61 61
 	Birthday        int64  `gorm:"column:birthday" json:"birthday" form:"birthday"`
62 62
 	Sort            int64  `gorm:"column:sort" json:"sort" form:"sort"`
63 63
 	IsSort          int64  `gorm:"column:is_sort" json:"is_sort" form:"is_sort"`
64
+	DepartmentId    int64  `gorm:"column:department_id" json:"department_id" form:"department_id"`
65
+	Department      string `gorm:"column:department" json:"department" form:"department"`
64 66
 }
65 67
 
66 68
 func (App_Role) TableName() string {

+ 10 - 0
service/dialysis_service.go View File

@@ -1121,3 +1121,13 @@ func GetExecutionDoctors(orgid int64, patientid int64, id int64) (doctorAdvice [
1121 1121
 	err = readDb.Model(&doctorAdvice).Where("user_org_id = ? and patient_id = ? AND (id = ? Or parent_id=?) and status = 1", orgid, patientid, id, id).Find(&doctorAdvice).Error
1122 1122
 	return doctorAdvice, err
1123 1123
 }
1124
+
1125
+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
1127
+	return
1128
+}
1129
+
1130
+func SaveHisDoctorAdvice(advice *models.HisDoctorAdviceInfo) (err error) {
1131
+	err = writeDb.Save(&advice).Error
1132
+	return
1133
+}

+ 15 - 0
service/gobal_config_service.go View File

@@ -177,3 +177,18 @@ func GetExportLogByType(org_id int64, log_type int64) (log []*models.ExportLog,
177 177
 		Preload("ExportErrLog", "status = 1").Order("export_time desc").Find(&log).Error
178 178
 	return
179 179
 }
180
+
181
+func FindXTHisRecordByOrgId(org_id int64) (err error, config models.XtHisConfig) {
182
+	err = readDb.Model(&models.XtHisConfig{}).Where("status = 1 AND user_org_id = ?", org_id).Find(&config).Error
183
+	return
184
+}
185
+
186
+func UpdateXTHisRecord(config *models.XtHisConfig) (err error) {
187
+	err = writeDb.Save(config).Error
188
+	return
189
+}
190
+
191
+func CreateXTHisRecord(config *models.XtHisConfig) (err error) {
192
+	err = writeDb.Model(&models.XtHisConfig{}).Create(config).Error
193
+	return
194
+}

+ 45 - 26
service/his_service.go View File

@@ -177,7 +177,7 @@ func GetHisPrescription(org_id int64, patient_id int64, record_date int64) (pres
177 177
 }
178 178
 
179 179
 func GetAllDrugLibList(org_id int64) (list []*models.BaseDrugLib, err error) {
180
-	err = readDb.Model(&models.BaseDrugLib{}).Where("org_id = ?  AND status = 1", org_id).Find(&list).Error
180
+	err = readDb.Model(&models.BaseDrugLib{}).Preload("DrugWarehouseInfo", "status = 1 AND user_org_id = ?", org_id).Where("org_id = ?  AND status = 1", org_id).Find(&list).Error
181 181
 	return
182 182
 }
183 183
 
@@ -199,7 +199,9 @@ func FindAllHisAdviceTemplate(org_id int64) (temps []*models.HisDoctorAdvicePare
199 199
 }
200 200
 
201 201
 func GetHisAdminUserDoctors(org_id int64) (doctors []*models.UserAdminRole, err error) {
202
-	err = readUserDb.Model(&models.UserAdminRole{}).Where("org_id = ? AND status = 1 AND (user_type = 1 OR user_type = 2)", org_id).Find(&doctors).Error
202
+	err = readUserDb.Model(&models.UserAdminRole{}).Preload("XtHisDepartment", func(db *gorm.DB) *gorm.DB {
203
+		return readDb.Model(&models.XtHisDepartment{}).Where("status = 1 AND user_org_id = ?", org_id)
204
+	}).Where("org_id = ? AND status = 1 AND (user_type = 1 OR user_type = 2)", org_id).Find(&doctors).Error
203 205
 	return
204 206
 }
205 207
 
@@ -243,6 +245,12 @@ func FindPatientPrescriptionInfo(org_id int64, patient_id int64, record_date int
243 245
 	return
244 246
 
245 247
 }
248
+
249
+func FindLastPatientPrescriptionInfo(org_id int64, patient_id int64, record_date int64) (info models.HisPrescriptionInfo, err error) {
250
+	err = readDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND record_date < ? AND patient_id = ?", org_id, record_date, patient_id).Order("record_date desc").First(&info).Error
251
+	return
252
+}
253
+
246 254
 func SavePatientPrescriptionInfo(info models.HisPrescriptionInfo) (err error) {
247 255
 	err = writeDb.Save(&info).Error
248 256
 	return
@@ -315,27 +323,28 @@ func GetHisPrescriptionThree(org_id int64, patient_id int64, record_date int64,
315 323
 }
316 324
 
317 325
 type HisPrescriptionInfo struct {
318
-	ID                 int64             `gorm:"column:id" json:"id" form:"id"`
319
-	UserOrgId          int64             `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
320
-	RecordDate         int64             `gorm:"column:record_date" json:"record_date" form:"record_date"`
321
-	PatientId          int64             `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
322
-	HisPatientId       int64             `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
323
-	Status             int64             `gorm:"column:status" json:"status" form:"status"`
324
-	Ctime              int64             `gorm:"column:ctime" json:"ctime" form:"ctime"`
325
-	Mtime              int64             `gorm:"column:mtime" json:"mtime" form:"mtime"`
326
-	Creator            int64             `gorm:"column:creator" json:"creator" form:"creator"`
327
-	Modifier           int64             `gorm:"column:modifier" json:"modifier" form:"modifier"`
328
-	Diagnosis          string            `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
329
-	RegisterType       string            `gorm:"column:register_type" json:"register_type" form:"register_type"`
330
-	Doctor             string            `gorm:"column:doctor" json:"doctor" form:"doctor"`
331
-	Departments        string            `gorm:"column:departments" json:"departments" form:"departments"`
332
-	SickHistory        string            `gorm:"column:sick_history" json:"sick_history" form:"sick_history"`
333
-	Patients           models.Patients   `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
334
-	HisPatient         models.HisPatient `gorm:"ForeignKey:HisPatientId,RecordDate;AssociationForeignKey:ID,RecordDate" json:"his_patient"`
335
-	PrescriptionNumber string            `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
336
-	BatchNumber        string            `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
337
-	PrescriptionStatus int64             `gorm:"column:prescription_status" json:"prescription_status" form:"prescription_status"`
338
-	DoctorId           int64             `gorm:"column:doctor_id" json:"doctor_id" form:"doctor_id"`
326
+	ID                    int64                        `gorm:"column:id" json:"id" form:"id"`
327
+	UserOrgId             int64                        `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
328
+	RecordDate            int64                        `gorm:"column:record_date" json:"record_date" form:"record_date"`
329
+	PatientId             int64                        `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
330
+	HisPatientId          int64                        `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
331
+	Status                int64                        `gorm:"column:status" json:"status" form:"status"`
332
+	Ctime                 int64                        `gorm:"column:ctime" json:"ctime" form:"ctime"`
333
+	Mtime                 int64                        `gorm:"column:mtime" json:"mtime" form:"mtime"`
334
+	Creator               int64                        `gorm:"column:creator" json:"creator" form:"creator"`
335
+	Modifier              int64                        `gorm:"column:modifier" json:"modifier" form:"modifier"`
336
+	Diagnosis             string                       `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
337
+	RegisterType          string                       `gorm:"column:register_type" json:"register_type" form:"register_type"`
338
+	Doctor                string                       `gorm:"column:doctor" json:"doctor" form:"doctor"`
339
+	Departments           string                       `gorm:"column:departments" json:"departments" form:"departments"`
340
+	SickHistory           string                       `gorm:"column:sick_history" json:"sick_history" form:"sick_history"`
341
+	Patients              models.Patients              `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
342
+	HisPatient            models.HisPatient            `gorm:"ForeignKey:HisPatientId,RecordDate;AssociationForeignKey:ID,RecordDate" json:"his_patient"`
343
+	HisPatientCaseHistory models.HisPatientCaseHistory `gorm:"ForeignKey:PatientId,RecordDate;AssociationForeignKey:PatientId,RecordDate" json:"case_history"`
344
+	PrescriptionNumber    string                       `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
345
+	BatchNumber           string                       `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
346
+	PrescriptionStatus    int64                        `gorm:"column:prescription_status" json:"prescription_status" form:"prescription_status"`
347
+	DoctorId              int64                        `gorm:"column:doctor_id" json:"doctor_id" form:"doctor_id"`
339 348
 }
340 349
 
341 350
 func (HisPrescriptionInfo) TableName() string {
@@ -345,7 +354,9 @@ func (HisPrescriptionInfo) TableName() string {
345 354
 func GetHisPrescriptionOrderList(org_id int64) (prescriptionOrder []*HisPrescriptionInfo, err error) {
346 355
 	err = readDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND user_org_id = ?", org_id).
347 356
 		Preload("Patients", "status = 1 AND user_org_id = ?", org_id).
348
-		Preload("HisPatient", "status = 1 AND user_org_id = ?", org_id).Order("ctime desc").Find(&prescriptionOrder).Error
357
+		Preload("HisPatient", "status = 1 AND user_org_id = ?", org_id).
358
+		Preload("HisPatientCaseHistory", "status = 1 AND user_org_id = ?", org_id).
359
+		Order("ctime desc").Find(&prescriptionOrder).Error
349 360
 	return
350 361
 
351 362
 }
@@ -353,7 +364,8 @@ func GetHisPrescriptionOrderList(org_id int64) (prescriptionOrder []*HisPrescrip
353 364
 func GetHisPrescriptionOrderInfo(id int64, org_id int64) (prescriptionOrder HisPrescriptionInfo, err error) {
354 365
 	err = readDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND id = ? AND user_org_id = ? ", id, org_id).
355 366
 		Preload("Patients", "status = 1 AND user_org_id = ?", org_id).
356
-		Preload("HisPatient", "status = 1 AND user_org_id = ?", org_id).First(&prescriptionOrder).Error
367
+		Preload("HisPatient", "status = 1 AND user_org_id = ?", org_id).
368
+		Preload("HisPatientCaseHistory", "status = 1 AND user_org_id = ?", org_id).First(&prescriptionOrder).Error
357 369
 	return
358 370
 
359 371
 }
@@ -401,7 +413,7 @@ func UpDateOrder(order models.HisOrder) (err error) {
401 413
 }
402 414
 
403 415
 func UpdataOrderStatusTwo(number string, user_org_id int64) (err error) {
404
-	err = writeDb.Model(&models.HisPrescription{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"order_status": 3, "mtime": time.Now().Unix()}).Error
416
+	err = writeDb.Model(&models.HisPrescription{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"order_status": 2, "mtime": time.Now().Unix()}).Error
405 417
 	err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"prescription_status": 3, "mtime": time.Now().Unix()}).Error
406 418
 	return
407 419
 }
@@ -422,3 +434,10 @@ func FindMedicalInsuranceInfo(org_id int64) (config models.MedicalInsuranceOrgCo
422 434
 	err = readDb.Model(&models.MedicalInsuranceOrgConfig{}).Where("status = 1 AND user_org_id = ?", org_id).First(&config).Error
423 435
 	return
424 436
 }
437
+
438
+func FindAllSick(orgId int64) (list []*models.OutpatientServiceSick, err error) {
439
+	db := readDb.Model(&models.OutpatientServiceSick{})
440
+	db = db.Where("user_org_id = ? AND status = 1", orgId)
441
+	err = db.Order("ctime desc").Find(&list).Error
442
+	return
443
+}

+ 34 - 1
service/manage_center_service.go View File

@@ -1,6 +1,9 @@
1 1
 package service
2 2
 
3
-import "XT_New/models"
3
+import (
4
+	"XT_New/models"
5
+	"time"
6
+)
4 7
 
5 8
 func GetDictionaryConfigList(orgID int64) (dataconfig interface{}, err error) {
6 9
 	var configList []*models.DictionaryDataconfig
@@ -218,3 +221,33 @@ func CreateUnitSafeguard(dus *models.DrugUnitSafeguard) (err error) {
218 221
 	err = writeDb.Create(dus).Error
219 222
 	return
220 223
 }
224
+
225
+func AddSigleMZSick(dealer *models.OutpatientServiceSick) (error, *models.OutpatientServiceSick) {
226
+	err := writeDb.Create(&dealer).Error
227
+	return err, dealer
228
+}
229
+
230
+func ModifyMZSick(mesick *models.OutpatientServiceSick) error {
231
+	err := writeDb.Save(&mesick).Error
232
+
233
+	return err
234
+}
235
+
236
+func FindAllMZSickList(orgId int64, page int64, limit int64) (list []*models.OutpatientServiceSick, total int64, err error) {
237
+	offset := (page - 1) * limit
238
+	db := readDb.Model(&models.OutpatientServiceSick{})
239
+	db = db.Where("user_org_id = ? AND status = 1", orgId)
240
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("ctime desc").Find(&list).Error
241
+	return
242
+}
243
+
244
+func DeleteMZSickById(id int64) error {
245
+	err := writeDb.Model(&models.OutpatientServiceSick{}).Where("id = ? AND status = 1", id).Updates(map[string]interface{}{"mtime": time.Now().Unix(), "status": 0}).Error
246
+	return err
247
+}
248
+
249
+func FindMZSickById(id int64) (*models.OutpatientServiceSick, error) {
250
+	dealer := &models.OutpatientServiceSick{}
251
+	err := readDb.Model(&models.OutpatientServiceSick{}).Where("id = ? AND status = 1", id).First(&dealer).Error
252
+	return dealer, err
253
+}

+ 3 - 1
service/role_service.go View File

@@ -310,7 +310,7 @@ func IsUserSuperAdminWithMobile(mobile string) (bool, error) {
310 310
 	return user.IsSuperAdmin, nil
311 311
 }
312 312
 
313
-func CreateGeneralAdminUser(orgID int64, appID int64, mobile string, name string, userTitle string, roleIds string, user_type int, user_title int) (*models.AdminUser, string, error) {
313
+func CreateGeneralAdminUser(orgID int64, appID int64, mobile string, name string, userTitle string, roleIds string, user_type int, user_title int, department_id int64, deapartment_name string) (*models.AdminUser, string, error) {
314 314
 	now := time.Now().Unix()
315 315
 	tx := writeUserDb.Begin()
316 316
 	var adminUser models.AdminUser
@@ -347,6 +347,8 @@ func CreateGeneralAdminUser(orgID int64, appID int64, mobile string, name string
347 347
 		ModifyTime:    now,
348 348
 		RoleIds:       roleIds,
349 349
 		IsSort:        1,
350
+		Department:    deapartment_name,
351
+		DepartmentId:  department_id,
350 352
 	}
351 353
 	if createApp_RoleErr := tx.Create(&app_role).Error; createApp_RoleErr != nil {
352 354
 		tx.Rollback()