瀏覽代碼

耗材参数

XMLWAN 4 年之前
父節點
當前提交
da884e47b9
共有 5 個文件被更改,包括 1350 次插入1 次删除
  1. 833 0
      controllers/his_project_api_controller.go
  2. 235 0
      models/his_models.go
  3. 1 0
      routers/router.go
  4. 280 0
      service/his_project_service.go
  5. 1 1
      service/self_drug_service.go

+ 833 - 0
controllers/his_project_api_controller.go 查看文件

@@ -0,0 +1,833 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/models"
6
+	"XT_New/service"
7
+	"XT_New/utils"
8
+	"encoding/json"
9
+	"fmt"
10
+	"github.com/astaxie/beego"
11
+	"github.com/jinzhu/gorm"
12
+	"strconv"
13
+	"strings"
14
+	"time"
15
+)
16
+
17
+type HisProjectApiController struct {
18
+	BaseAuthAPIController
19
+}
20
+
21
+func HisProjectRouters() {
22
+
23
+	beego.Router("/api/his/saveproject", &HisProjectApiController{}, "Get:SaveProject")
24
+	beego.Router("/api/his/getprojectlist", &HisProjectApiController{}, "Get:GetProjectList")
25
+	beego.Router("/api/his/getprojectdetail", &HisProjectApiController{}, "Get:GetProjectDetail")
26
+	beego.Router("/api/his/updatedproject", &HisProjectApiController{}, "Get:UpdatedProject")
27
+	beego.Router("/api/his/deletehisproject", &HisProjectApiController{}, "Get:DeleteHisProject")
28
+	beego.Router("/api/his/saveprojectteam", &HisProjectApiController{}, "Get:SaveProjectTeam")
29
+	beego.Router("/api/his/getprojectteamlist", &HisProjectApiController{}, "Get:GetProjectTeamList")
30
+	beego.Router("/api/his/getprojectteamdetail", &HisProjectApiController{}, "Get:GetProjectTeamDetail")
31
+	beego.Router("/api/his/updateprojectteam", &HisProjectApiController{}, "Get:UpdatedProjectTeam")
32
+	beego.Router("/api/his/deleteprojectteam", &HisProjectApiController{}, "Get:DeleteProjectTeam")
33
+	beego.Router("/api/his/savedepartment", &HisProjectApiController{}, "Get:SaveDePartment")
34
+	beego.Router("/api/his/getdepartmentlist", &HisProjectApiController{}, "Get:GetDepartMentList")
35
+	beego.Router("/api/his/getdepartmentdetail", &HisProjectApiController{}, "Get:GetDepartMentDetail")
36
+	beego.Router("/api/his/updagtedepartment", &HisProjectApiController{}, "Get:UpdatedDeparment")
37
+	beego.Router("/api/his/deletedeparment", &HisProjectApiController{}, "Get:DeleteDepartment")
38
+	beego.Router("/api/his/getallprojectlist", &HisProjectApiController{}, "Get:GetAllProjectList")
39
+	beego.Router("/api/his/addprojectlist", &HisProjectApiController{}, "Get:AddProjectList")
40
+	beego.Router("/api/his/deleteproject", &HisProjectApiController{}, "Get:DeleteProject")
41
+	beego.Router("/api/his/gethisproject", &HisProjectApiController{}, "Get:GetHisProject")
42
+	beego.Router("/api/his/getprojectteam", &HisProjectApiController{}, "Get:GetProjectTeam")
43
+	beego.Router("/api/his/getalldoctorlist", &HisProjectApiController{}, "Get:GetAllDoctorList")
44
+	beego.Router("/api/his/savehispatient", &HisProjectApiController{}, "Get:SaveHisPatient")
45
+	//获取今日血透排班的患者
46
+	beego.Router("/api/his/getbloodpatient", &HisProjectApiController{}, "Get:GetBloodPatientList")
47
+	//获取患者的今日透析处方
48
+	beego.Router("/api/his/gethisprescription", &HisProjectApiController{}, "Get:GetHisPrescription")
49
+	//新增附加费用
50
+	beego.Router("/api/his/additionalcharge", &HisProjectApiController{}, "Post:AdditionalCharge")
51
+	//获取治疗单
52
+	beego.Router("/api/his/gettreatlist", &HisProjectApiController{}, "Get:GetTreatmentList")
53
+	beego.Router("/api/his/getpatientinformation", &HisProjectApiController{}, "Get:GetPatientInformation")
54
+	beego.Router("/api/hist/getallprojecteam", &HisProjectApiController{}, "Get:GetAllProjectTeam")
55
+}
56
+
57
+func (this *HisProjectApiController) SaveProject() {
58
+
59
+	project_name := this.GetString("project_name")
60
+	pinyin := this.GetString("pinyin")
61
+	wubi := this.GetString("wubi")
62
+	price := this.GetString("price")
63
+	price_float, err := strconv.ParseFloat(price, 64)
64
+	unit := this.GetString("unit")
65
+	cost_classify, _ := this.GetInt64("cost_classify")
66
+	executive_section, _ := this.GetInt64("executive_section")
67
+	medical_coverage, _ := this.GetInt64("medical_coverage")
68
+	statistical_classification, _ := this.GetInt64("statistical_classification")
69
+	disease_directory, _ := this.GetInt64("disease_directory")
70
+	is_record, _ := this.GetInt64("is_record")
71
+	medical_code := this.GetString("medical_code")
72
+	tube_color, _ := this.GetInt64("tube_color")
73
+	medical_status, _ := this.GetInt64("medical_status")
74
+	remark := this.GetString("remark")
75
+	sign, _ := this.GetInt64("sign")
76
+	default_number := this.GetString("default_number")
77
+	is_charge, _ := this.GetInt64("is_charge")
78
+	is_estimate, _ := this.GetInt64("is_estimate")
79
+	is_workload, _ := this.GetInt64("is_workload")
80
+	sort := this.GetString("sort")
81
+	is_advice, _ := this.GetInt64("is_advice")
82
+	is_default, _ := this.GetInt64("is_default")
83
+	single_dose := this.GetString("single_dose")
84
+	delivery_way := this.GetString("delivery_way")
85
+	execution_frequency := this.GetString("execution_frequency")
86
+	number_days := this.GetString("number_days")
87
+	total := this.GetString("total")
88
+	adminUserInfo := this.GetAdminUserInfo()
89
+	orgId := adminUserInfo.CurrentOrgId
90
+	hisProject := models.XtHisProject{
91
+		ProjectName:               project_name,
92
+		Pinyin:                    pinyin,
93
+		Wubi:                      wubi,
94
+		Price:                     price_float,
95
+		Unit:                      unit,
96
+		CostClassify:              cost_classify,
97
+		ExecutiveSection:          executive_section,
98
+		MedicalCoverage:           medical_coverage,
99
+		StatisticalClassification: statistical_classification,
100
+		DiseaseDirectory:          disease_directory,
101
+		IsRecord:                  is_record,
102
+		MedicalCode:               medical_code,
103
+		TubeColor:                 tube_color,
104
+		MedicalStatus:             medical_status,
105
+		Remark:                    remark,
106
+		Sign:                      sign,
107
+		DefaultNumber:             default_number,
108
+		IsCharge:                  is_charge,
109
+		IsEstimate:                is_estimate,
110
+		IsWorkload:                is_workload,
111
+		Sort:                      sort,
112
+		DoctorAdvice:              is_advice,
113
+		IsDefault:                 is_default,
114
+		UserOrgId:                 orgId,
115
+		Status:                    1,
116
+		CreatedTime:               time.Now().Unix(),
117
+		SingleDose:                single_dose,
118
+		DeliveryWay:               delivery_way,
119
+		ExecutionFrequency:        execution_frequency,
120
+		NumberDays:                number_days,
121
+		Total:                     total,
122
+	}
123
+	//查询项目名称是否存在
124
+	_, errcode := service.GetHisProjectIsExist(project_name, orgId)
125
+	fmt.Println("9999999999999", errcode)
126
+	if errcode == gorm.ErrRecordNotFound {
127
+		fmt.Println("222")
128
+		err = service.CreateHisProject(&hisProject)
129
+		if err != nil {
130
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
131
+			return
132
+		}
133
+		this.ServeSuccessJSON(map[string]interface{}{
134
+			"hisProject": hisProject,
135
+		})
136
+		return
137
+	} else if errcode == nil {
138
+		fmt.Println("3333")
139
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
140
+		return
141
+	}
142
+}
143
+
144
+func (this *HisProjectApiController) GetProjectList() {
145
+
146
+	adminUserInfo := this.GetAdminUserInfo()
147
+	orgId := adminUserInfo.CurrentOrgId
148
+	limit, _ := this.GetInt64("limit")
149
+	page, _ := this.GetInt64("page")
150
+	is_charge, _ := this.GetInt64("is_charge")
151
+	is_start, _ := this.GetInt64("is_start")
152
+	keyword := this.GetString("keyword")
153
+	projecList, total, err := service.GetHisProjectList(orgId, limit, page, is_charge, is_start, keyword)
154
+	fmt.Println("err", err)
155
+	if err != nil {
156
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
157
+		return
158
+	}
159
+	this.ServeSuccessJSON(map[string]interface{}{
160
+		"projecList": projecList,
161
+		"total":      total,
162
+	})
163
+	return
164
+}
165
+
166
+func (this *HisProjectApiController) GetProjectDetail() {
167
+	id, _ := this.GetInt64("id")
168
+	projectDetail, err := service.GetProjectDetail(id)
169
+	if err != nil {
170
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
171
+		return
172
+	}
173
+	this.ServeSuccessJSON(map[string]interface{}{
174
+		"projecDetail": projectDetail,
175
+	})
176
+	return
177
+}
178
+
179
+func (this *HisProjectApiController) UpdatedProject() {
180
+
181
+	id, _ := this.GetInt64("id")
182
+	project_name := this.GetString("project_name")
183
+	pinyin := this.GetString("pinyin")
184
+	wubi := this.GetString("wubi")
185
+	price := this.GetString("price")
186
+	price_float, _ := strconv.ParseFloat(price, 64)
187
+	unit := this.GetString("unit")
188
+	cost_classify, _ := this.GetInt64("cost_classify")
189
+	executive_section, _ := this.GetInt64("executive_section")
190
+	medical_coverage, _ := this.GetInt64("medical_coverage")
191
+	statistical_classification, _ := this.GetInt64("statistical_classification")
192
+	disease_directory, _ := this.GetInt64("disease_directory")
193
+	is_record, _ := this.GetInt64("is_record")
194
+	medical_code := this.GetString("medical_code")
195
+	tube_color, _ := this.GetInt64("tube_color")
196
+	medical_status, _ := this.GetInt64("medical_status")
197
+	remark := this.GetString("remark")
198
+	sign, _ := this.GetInt64("sign")
199
+	default_number := this.GetString("default_number")
200
+	is_charge, _ := this.GetInt64("is_charge")
201
+	is_estimate, _ := this.GetInt64("is_estimate")
202
+	is_workload, _ := this.GetInt64("is_workload")
203
+	sort := this.GetString("sort")
204
+	is_advice, _ := this.GetInt64("is_advice")
205
+	is_default, _ := this.GetInt64("is_default")
206
+	single_dose := this.GetString("single_dose")
207
+	delivery_way := this.GetString("delivery_way")
208
+	execution_frequency := this.GetString("execution_frequency")
209
+	number_days := this.GetString("number_days")
210
+	total := this.GetString("total")
211
+	hisProject := models.XtHisProject{
212
+		ProjectName:               project_name,
213
+		Pinyin:                    pinyin,
214
+		Wubi:                      wubi,
215
+		Price:                     price_float,
216
+		Unit:                      unit,
217
+		CostClassify:              cost_classify,
218
+		ExecutiveSection:          executive_section,
219
+		MedicalCoverage:           medical_coverage,
220
+		StatisticalClassification: statistical_classification,
221
+		DiseaseDirectory:          disease_directory,
222
+		IsRecord:                  is_record,
223
+		MedicalCode:               medical_code,
224
+		TubeColor:                 tube_color,
225
+		MedicalStatus:             medical_status,
226
+		Remark:                    remark,
227
+		Sign:                      sign,
228
+		DefaultNumber:             default_number,
229
+		IsCharge:                  is_charge,
230
+		IsEstimate:                is_estimate,
231
+		IsWorkload:                is_workload,
232
+		Sort:                      sort,
233
+		DoctorAdvice:              is_advice,
234
+		IsDefault:                 is_default,
235
+		UpdatedTime:               time.Now().Unix(),
236
+		SingleDose:                single_dose,
237
+		DeliveryWay:               delivery_way,
238
+		ExecutionFrequency:        execution_frequency,
239
+		NumberDays:                number_days,
240
+		Total:                     total,
241
+	}
242
+
243
+	err := service.UpdatedProject(id, &hisProject)
244
+	if err != nil {
245
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
246
+		return
247
+	}
248
+	this.ServeSuccessJSON(map[string]interface{}{
249
+		"hisProject": hisProject,
250
+	})
251
+	return
252
+}
253
+
254
+func (this *HisProjectApiController) DeleteHisProject() {
255
+
256
+	id, _ := this.GetInt64("id")
257
+	err := service.DeleteHisProject(id)
258
+	if err != nil {
259
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
260
+		return
261
+	}
262
+	returnData := make(map[string]interface{}, 0)
263
+	returnData["msg"] = "ok"
264
+	this.ServeSuccessJSON(returnData)
265
+	return
266
+}
267
+
268
+func (this *HisProjectApiController) SaveProjectTeam() {
269
+
270
+	project_team := this.GetString("project_team")
271
+
272
+	price := this.GetString("price")
273
+	price_float, _ := strconv.ParseFloat(price, 64)
274
+	pinyin := this.GetString("pinyin")
275
+	wubi := this.GetString("wubi")
276
+	tube_color, _ := this.GetInt64("tube_color")
277
+	team_type, _ := this.GetInt64("team_type")
278
+	remark := this.GetString("remark")
279
+	ids := this.GetString("ids")
280
+
281
+	adminUserInfo := this.GetAdminUserInfo()
282
+	orgId := adminUserInfo.CurrentOrgId
283
+	projectTeam := models.XtHisProjectTeam{
284
+		ProjectTeam: project_team,
285
+		Price:       price_float,
286
+		Pinyin:      pinyin,
287
+		Wubi:        wubi,
288
+		TubeColor:   tube_color,
289
+		TeamType:    team_type,
290
+		Remark:      remark,
291
+		UserOrgId:   orgId,
292
+		Status:      1,
293
+		CreatedTime: time.Now().Unix(),
294
+		ProjectId:   ids,
295
+	}
296
+	fmt.Println(projectTeam)
297
+
298
+	_, errcodes := service.GetHisProjectByNameOne(project_team, orgId)
299
+
300
+	if errcodes == gorm.ErrRecordNotFound {
301
+
302
+		err := service.CreatedProjectTeam(&projectTeam)
303
+		if err != nil {
304
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
305
+			return
306
+		}
307
+		this.ServeSuccessJSON(map[string]interface{}{
308
+			"projectTeam": projectTeam,
309
+		})
310
+		return
311
+	} else if errcodes == nil {
312
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
313
+		return
314
+	}
315
+}
316
+
317
+func (this *HisProjectApiController) GetProjectTeamList() {
318
+
319
+	limit, _ := this.GetInt64("limit")
320
+	page, _ := this.GetInt64("page")
321
+	keyword := this.GetString("keyword")
322
+	adminUserInfo := this.GetAdminUserInfo()
323
+	orgId := adminUserInfo.CurrentOrgId
324
+	projectTeamList, total, err := service.GetProjectTeamList(limit, page, orgId, keyword)
325
+	if err != nil {
326
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
327
+		return
328
+	}
329
+	this.ServeSuccessJSON(map[string]interface{}{
330
+		"projectTeamList": projectTeamList,
331
+		"total":           total,
332
+	})
333
+	return
334
+}
335
+
336
+func (this *HisProjectApiController) GetProjectTeamDetail() {
337
+
338
+	id, _ := this.GetInt64("id")
339
+	projectTeamDetail, err := service.GetProjectTeamDetail(id)
340
+	if err != nil {
341
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
342
+		return
343
+	}
344
+	this.ServeSuccessJSON(map[string]interface{}{
345
+		"projectTeamDetail": projectTeamDetail,
346
+	})
347
+	return
348
+}
349
+
350
+func (this *HisProjectApiController) UpdatedProjectTeam() {
351
+
352
+	id, _ := this.GetInt64("id")
353
+	project_team := this.GetString("project_team")
354
+	price := this.GetString("price")
355
+	price_float, _ := strconv.ParseFloat(price, 64)
356
+	pinyin := this.GetString("pinyin")
357
+	wubi := this.GetString("wubi")
358
+	tube_color, _ := this.GetInt64("tube_color")
359
+	team_type, _ := this.GetInt64("team_type")
360
+	remark := this.GetString("remark")
361
+	ids := this.GetString("ids")
362
+	projectTeam := models.XtHisProjectTeam{
363
+		ProjectTeam: project_team,
364
+		Price:       price_float,
365
+		Pinyin:      pinyin,
366
+		Wubi:        wubi,
367
+		TubeColor:   tube_color,
368
+		TeamType:    team_type,
369
+		Remark:      remark,
370
+		ProjectId:   ids,
371
+	}
372
+
373
+	err := service.UpdatedProjectTeam(id, &projectTeam)
374
+	if err != nil {
375
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
376
+		return
377
+	}
378
+	this.ServeSuccessJSON(map[string]interface{}{
379
+		"projectTeam": projectTeam,
380
+	})
381
+	return
382
+}
383
+
384
+func (this *HisProjectApiController) DeleteProjectTeam() {
385
+
386
+	id, _ := this.GetInt64("id")
387
+	err := service.DeleteProjectTeam(id)
388
+	if err != nil {
389
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
390
+		return
391
+	}
392
+	returnData := make(map[string]interface{}, 0)
393
+	returnData["msg"] = "ok"
394
+	this.ServeSuccessJSON(returnData)
395
+	return
396
+}
397
+
398
+func (this *HisProjectApiController) SaveDePartment() {
399
+
400
+	name := this.GetString("name")
401
+	number := this.GetString("number")
402
+	adminUserInfo := this.GetAdminUserInfo()
403
+	orgId := adminUserInfo.CurrentOrgId
404
+	department := models.XtHisDepartment{
405
+		Name:        name,
406
+		Number:      number,
407
+		UserOrgId:   orgId,
408
+		CreatedTime: time.Now().Unix(),
409
+		Status:      1,
410
+	}
411
+	err := service.CreateDePartment(&department)
412
+	if err != nil {
413
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
414
+		return
415
+	}
416
+	this.ServeSuccessJSON(map[string]interface{}{
417
+		"department": department,
418
+	})
419
+	return
420
+}
421
+
422
+func (this *HisProjectApiController) GetDepartMentList() {
423
+
424
+	limit, _ := this.GetInt64("limit")
425
+	page, _ := this.GetInt64("page")
426
+	adminUserInfo := this.GetAdminUserInfo()
427
+	orgId := adminUserInfo.CurrentOrgId
428
+	departMentList, total, err := service.GetDepartMentList(limit, page, orgId)
429
+	if err != nil {
430
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
431
+		return
432
+	}
433
+	this.ServeSuccessJSON(map[string]interface{}{
434
+		"departMentList": departMentList,
435
+		"total":          total,
436
+	})
437
+	return
438
+}
439
+
440
+func (this *HisProjectApiController) GetDepartMentDetail() {
441
+
442
+	id, _ := this.GetInt64("id")
443
+	departDetail, err := service.GetDepartMentDetail(id)
444
+	if err != nil {
445
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
446
+		return
447
+	}
448
+	this.ServeSuccessJSON(map[string]interface{}{
449
+		"departDetail": departDetail,
450
+	})
451
+	return
452
+}
453
+
454
+func (this *HisProjectApiController) UpdatedDeparment() {
455
+
456
+	id, _ := this.GetInt64("id")
457
+	name := this.GetString("name")
458
+	number := this.GetString("number")
459
+	department := models.XtHisDepartment{
460
+		Name:   name,
461
+		Number: number,
462
+	}
463
+	err := service.UpdatedDepartment(id, &department)
464
+	if err != nil {
465
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
466
+		return
467
+	}
468
+	this.ServeSuccessJSON(map[string]interface{}{
469
+		"department": department,
470
+	})
471
+	return
472
+}
473
+
474
+func (this *HisProjectApiController) DeleteDepartment() {
475
+
476
+	id, _ := this.GetInt64("id")
477
+	err := service.DeleteDepartment(id)
478
+	if err != nil {
479
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
480
+		return
481
+	}
482
+	returnData := make(map[string]interface{}, 0)
483
+	returnData["msg"] = "ok"
484
+	this.ServeSuccessJSON(returnData)
485
+	return
486
+}
487
+
488
+func (this *HisProjectApiController) GetBloodPatientList() {
489
+
490
+	adminUserInfo := this.GetAdminUserInfo()
491
+	orgId := adminUserInfo.CurrentOrgId
492
+	fmt.Println("org", orgId)
493
+	timeStr := time.Now().Format("2006-01-02")
494
+	timeLayout := "2006-01-02 15:04:05"
495
+	fmt.Println("timeStr:", timeStr)
496
+	timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
497
+	timenow := timeStringToTime.Unix()
498
+
499
+	//统计血透排班的患者
500
+	scheduleList, err := service.GetBloodPatientList(orgId, timenow)
501
+	//统计当日挂号的患者
502
+	hisPatient, _ := service.GetHisPatient(orgId, timenow)
503
+	//统计今天开处方的患者
504
+	prescription, _ := service.HisPrescription(orgId, timenow)
505
+	if err != nil {
506
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
507
+		return
508
+	}
509
+	this.ServeSuccessJSON(map[string]interface{}{
510
+		"scheduleList": scheduleList,
511
+		"hisPatient":   hisPatient,
512
+		"prescription": prescription,
513
+	})
514
+	return
515
+}
516
+
517
+func (this *HisProjectApiController) GetHisPrescription() {
518
+
519
+	id, _ := this.GetInt64("id")
520
+	timeStr := time.Now().Format("2006-01-02")
521
+	timeLayout := "2006-01-02 15:04:05"
522
+	fmt.Println("timeStr:", timeStr)
523
+	timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
524
+	timenow := timeStringToTime.Unix()
525
+	prescriptionList, err := service.GetHisPrescriptionByPatientId(id, timenow)
526
+	if err != nil {
527
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
528
+		return
529
+	}
530
+	this.ServeSuccessJSON(map[string]interface{}{
531
+		"prescriptionList": prescriptionList,
532
+	})
533
+	return
534
+}
535
+
536
+func (this *HisProjectApiController) AdditionalCharge() {
537
+
538
+	dataBody := make(map[string]interface{}, 0)
539
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
540
+	fmt.Println(err)
541
+	patient_id := int64(dataBody["patient_id"].(float64))
542
+	fmt.Println("patient_id2222222222", patient_id)
543
+	medicineData, _ := dataBody["medicineData"].([]interface{})
544
+	adminUserInfo := this.GetAdminUserInfo()
545
+	orgId := adminUserInfo.CurrentOrgId
546
+	admin_user_id := adminUserInfo.AdminUser.Id
547
+	timeStr := time.Now().Format("2006-01-02")
548
+	timeLayout := "2006-01-02 15:04:05"
549
+	fmt.Println("timeStr:", timeStr)
550
+	timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
551
+	timenow := timeStringToTime.Unix()
552
+	for _, item := range medicineData {
553
+		items := item.(map[string]interface{})
554
+		drug_id := int64(items["id"].(float64))
555
+		money := int64(items["money"].(float64))
556
+		monStr := strconv.FormatInt(money, 10)
557
+		monneyStr, _ := strconv.ParseFloat(monStr, 64)
558
+		additionalCharge := models.HisAdditionalCharge{
559
+			DrugId:      drug_id,
560
+			UserOrgId:   orgId,
561
+			PatientId:   patient_id,
562
+			RecordDate:  timenow,
563
+			Money:       monneyStr,
564
+			Status:      1,
565
+			AdminUserId: admin_user_id,
566
+			CreatedTime: time.Now().Unix(),
567
+		}
568
+
569
+		err := service.CreateAdditionalCharge(&additionalCharge)
570
+		if err != nil {
571
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
572
+			return
573
+		}
574
+		this.ServeSuccessJSON(map[string]interface{}{
575
+			"additionalCharge": additionalCharge,
576
+		})
577
+		return
578
+	}
579
+}
580
+
581
+func (this *HisProjectApiController) GetTreatmentList() {
582
+
583
+	patient_id, _ := this.GetInt64("patient_id")
584
+	timeStr := time.Now().Format("2006-01-02")
585
+	timeLayout := "2006-01-02 15:04:05"
586
+	fmt.Println("timeStr:", timeStr)
587
+	timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
588
+	timenow := timeStringToTime.Unix()
589
+	treatmentList, err := service.GetTreatmentList(patient_id, timenow)
590
+	if err != nil {
591
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
592
+		return
593
+	}
594
+	this.ServeSuccessJSON(map[string]interface{}{
595
+		"treatmentList": treatmentList,
596
+	})
597
+	return
598
+}
599
+
600
+func (this *HisProjectApiController) GetAllProjectList() {
601
+
602
+	adminUserInfo := this.GetAdminUserInfo()
603
+	orgId := adminUserInfo.CurrentOrgId
604
+	projectList, err := service.GetAllProjectList(orgId)
605
+	//获取列表数据
606
+	hisprojectlist, err := service.GetHisProjectListByOrgId(orgId)
607
+
608
+	if err != nil {
609
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
610
+		return
611
+	}
612
+	this.ServeSuccessJSON(map[string]interface{}{
613
+		"projectList":    projectList,
614
+		"hisprojectlist": hisprojectlist,
615
+	})
616
+	return
617
+}
618
+
619
+func (this *HisProjectApiController) AddProjectList() {
620
+
621
+	id, _ := this.GetInt64("id")
622
+	number, _ := this.GetInt64("number")
623
+	fmt.Println(id, number)
624
+	adminUserInfo := this.GetAdminUserInfo()
625
+	orgId := adminUserInfo.CurrentOrgId
626
+	projectList := models.XtHisProjectList{
627
+		ProjectId:   id,
628
+		Number:      number,
629
+		UserOrgId:   orgId,
630
+		Status:      1,
631
+		CreatedTime: time.Now().Unix(),
632
+	}
633
+	err := service.CreateProjectList(&projectList)
634
+
635
+	if err != nil {
636
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
637
+		return
638
+	}
639
+	this.ServeSuccessJSON(map[string]interface{}{
640
+		"projectList": projectList,
641
+	})
642
+	return
643
+}
644
+
645
+func (this *HisProjectApiController) GetPatientInformation() {
646
+
647
+	id, _ := this.GetInt64("id")
648
+	information, err := service.GetHisPatientInformation(id)
649
+	if err != nil {
650
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
651
+		return
652
+	}
653
+	this.ServeSuccessJSON(map[string]interface{}{
654
+		"information": information,
655
+	})
656
+	return
657
+}
658
+
659
+func (this *HisProjectApiController) DeleteProject() {
660
+
661
+	id, _ := this.GetInt64("id")
662
+	err := service.DeleteProjectList(id)
663
+	if err != nil {
664
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
665
+		return
666
+	}
667
+	returnData := make(map[string]interface{}, 0)
668
+	returnData["msg"] = "ok"
669
+	this.ServeSuccessJSON(returnData)
670
+	return
671
+}
672
+
673
+func (this *HisProjectApiController) GetHisProject() {
674
+
675
+	adminUserInfo := this.GetAdminUserInfo()
676
+	orgId := adminUserInfo.CurrentOrgId
677
+	project, err := service.GetHisProject(orgId)
678
+	if err != nil {
679
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
680
+		return
681
+	}
682
+	this.ServeSuccessJSON(map[string]interface{}{
683
+		"project": project,
684
+	})
685
+}
686
+
687
+func (this *HisProjectApiController) GetProjectTeam() {
688
+
689
+	strids := this.GetString("strids")
690
+
691
+	idStrs := strings.Split(strids, ",")
692
+	adminUserInfo := this.GetAdminUserInfo()
693
+	orgId := adminUserInfo.CurrentOrgId
694
+	team, err := service.GetProjectTeam(idStrs, orgId)
695
+	if err != nil {
696
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
697
+		return
698
+	}
699
+	this.ServeSuccessJSON(map[string]interface{}{
700
+		"team": team,
701
+	})
702
+}
703
+
704
+func (this *HisProjectApiController) GetAllDoctorList() {
705
+
706
+	adminUserInfo := this.GetAdminUserInfo()
707
+	orgId := adminUserInfo.CurrentOrgId
708
+	appId := adminUserInfo.CurrentAppId
709
+	//获取所有的医生
710
+	doctor, err := service.GetAllDoctor(orgId, appId)
711
+	//获取所有的科室
712
+	department, err := service.GetAllDepartMent(orgId)
713
+	if err != nil {
714
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
715
+		return
716
+	}
717
+	this.ServeSuccessJSON(map[string]interface{}{
718
+		"doctor":     doctor,
719
+		"department": department,
720
+	})
721
+}
722
+
723
+func (this *HisProjectApiController) SaveHisPatient() {
724
+	timeLayout := "2006-01-02"
725
+	loc, _ := time.LoadLocation("Local")
726
+	age, _ := this.GetInt64("age")
727
+
728
+	birthday := this.GetString("birthDay")
729
+	birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
730
+	birthUnix := birthdays.Unix()
731
+	certificates, _ := this.GetInt64("certificates")
732
+	cost_checked, _ := this.GetInt64("costChecked")
733
+	cost, _ := this.GetInt64("cost")
734
+	costs := strconv.FormatInt(cost, 10)
735
+	cost_float, _ := strconv.ParseFloat(costs, 64)
736
+	department, _ := this.GetInt64("department")
737
+	doctor, _ := this.GetInt64("doctor")
738
+	medicalcare, _ := this.GetInt64("medicalCare")
739
+	idcard := this.GetString("idCard")
740
+	medicalExpenses, _ := this.GetInt64("medicalExpenses")
741
+	medicalExpense := strconv.FormatInt(medicalExpenses, 10)
742
+	medicalExpense_float, _ := strconv.ParseFloat(medicalExpense, 64)
743
+	medicalinsurancecard := this.GetString("medicalInsuranceCard")
744
+
745
+	name := this.GetString("name")
746
+	register, _ := this.GetInt64("register")
747
+	registrationfee, _ := this.GetInt64("registrationFee")
748
+	registrationfees := strconv.FormatInt(registrationfee, 10)
749
+	registrationfees_float, _ := strconv.ParseFloat(registrationfees, 64)
750
+	settlementValue, _ := this.GetInt64("settlementValue")
751
+	sex, _ := this.GetInt64("sex")
752
+	total, _ := this.GetInt64("total")
753
+	totals := strconv.FormatInt(total, 10)
754
+	totals_float, _ := strconv.ParseFloat(totals, 64)
755
+	adminUserInfo := this.GetAdminUserInfo()
756
+	orgId := adminUserInfo.CurrentOrgId
757
+
758
+	bloodPatient, errcode := service.GetBloodPatientByIdCard(idcard, orgId)
759
+	if errcode == gorm.ErrRecordNotFound {
760
+		patient := models.XtHisPatient{
761
+			Age:                    age,
762
+			Birthday:               birthUnix,
763
+			IdType:                 certificates,
764
+			CostOfProduction:       cost_float,
765
+			Departments:            department,
766
+			AdminUserId:            doctor,
767
+			MedicalTreatmentType:   medicalcare,
768
+			IdCardNo:               idcard,
769
+			IsNeedCostOfProduction: cost_checked,
770
+			TreatmentCost:          medicalExpense_float,
771
+			MedicalInsuranceNumber: medicalinsurancecard,
772
+			Name:                   name,
773
+			RegisterType:           register,
774
+			RegisterCost:           registrationfees_float,
775
+			BalanceAccountsType:    settlementValue,
776
+			Gender:                 sex,
777
+			Total:                  totals_float,
778
+			UserOrgId:              orgId,
779
+		}
780
+		err := service.CreateHisPatient(&patient)
781
+		if err != nil {
782
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
783
+			return
784
+		}
785
+		this.ServeSuccessJSON(map[string]interface{}{
786
+			"patient": patient,
787
+		})
788
+	} else if errcode == nil {
789
+		patient := models.XtHisPatient{
790
+			Age:                    age,
791
+			Birthday:               birthUnix,
792
+			IdType:                 certificates,
793
+			CostOfProduction:       cost_float,
794
+			Departments:            department,
795
+			AdminUserId:            doctor,
796
+			MedicalTreatmentType:   medicalcare,
797
+			IdCardNo:               idcard,
798
+			IsNeedCostOfProduction: cost_checked,
799
+			TreatmentCost:          medicalExpense_float,
800
+			MedicalInsuranceNumber: medicalinsurancecard,
801
+			Name:                   name,
802
+			RegisterType:           register,
803
+			RegisterCost:           registrationfees_float,
804
+			BalanceAccountsType:    settlementValue,
805
+			Gender:                 sex,
806
+			Total:                  totals_float,
807
+			UserOrgId:              orgId,
808
+			PatientId:              bloodPatient.ID,
809
+		}
810
+		err := service.CreateHisPatient(&patient)
811
+		if err != nil {
812
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
813
+			return
814
+		}
815
+		this.ServeSuccessJSON(map[string]interface{}{
816
+			"patient": patient,
817
+		})
818
+	}
819
+}
820
+
821
+func (this *HisProjectApiController) GetAllProjectTeam() {
822
+
823
+	adminUserInfo := this.GetAdminUserInfo()
824
+	orgId := adminUserInfo.CurrentOrgId
825
+	team, err := service.GetAllProjectTeam(orgId)
826
+	if err != nil {
827
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
828
+		return
829
+	}
830
+	this.ServeSuccessJSON(map[string]interface{}{
831
+		"team": team,
832
+	})
833
+}

+ 235 - 0
models/his_models.go 查看文件

@@ -0,0 +1,235 @@
1
+package models
2
+
3
+type XtHisProject struct {
4
+	ID                        int64   `gorm:"column:id" json:"id" form:"id"`
5
+	ProjectName               string  `gorm:"column:project_name" json:"project_name" form:"project_name"`
6
+	Pinyin                    string  `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
7
+	Wubi                      string  `gorm:"column:wubi" json:"wubi" form:"wubi"`
8
+	Price                     float64 `gorm:"column:price" json:"price" form:"price"`
9
+	Unit                      string  `gorm:"column:unit" json:"unit" form:"unit"`
10
+	CostClassify              int64   `gorm:"column:cost_classify" json:"cost_classify" form:"cost_classify"`
11
+	ExecutiveSection          int64   `gorm:"column:executive_section" json:"executive_section" form:"executive_section"`
12
+	MedicalCoverage           int64   `gorm:"column:medical_coverage" json:"medical_coverage" form:"medical_coverage"`
13
+	StatisticalClassification int64   `gorm:"column:statistical_classification" json:"statistical_classification" form:"statistical_classification"`
14
+	DiseaseDirectory          int64   `gorm:"column:disease_directory" json:"disease_directory" form:"disease_directory"`
15
+	IsRecord                  int64   `gorm:"column:is_record" json:"is_record" form:"is_record"`
16
+	MedicalCode               string  `gorm:"column:medical_code" json:"medical_code" form:"medical_code"`
17
+	TubeColor                 int64   `gorm:"column:tube_color" json:"tube_color" form:"tube_color"`
18
+	MedicalStatus             int64   `gorm:"column:medical_status" json:"medical_status" form:"medical_status"`
19
+	Remark                    string  `gorm:"column:remark" json:"remark" form:"remark"`
20
+	Sign                      int64   `gorm:"column:sign" json:"sign" form:"sign"`
21
+	DefaultNumber             string  `gorm:"column:default_number" json:"default_number" form:"default_number"`
22
+	IsDefault                 int64   `gorm:"column:is_default" json:"is_default" form:"is_default"`
23
+	IsCharge                  int64   `gorm:"column:is_charge" json:"is_charge" form:"is_charge"`
24
+	IsEstimate                int64   `gorm:"column:is_estimate" json:"is_estimate" form:"is_estimate"`
25
+	IsWorkload                int64   `gorm:"column:is_workload" json:"is_workload" form:"is_workload"`
26
+	Sort                      string  `gorm:"column:sort" json:"sort" form:"sort"`
27
+	DoctorAdvice              int64   `gorm:"column:doctor_advice" json:"doctor_advice" form:"doctor_advice"`
28
+	UserOrgId                 int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
29
+	Status                    int64   `gorm:"column:status" json:"status" form:"status"`
30
+	CreatedTime               int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
31
+	UpdatedTime               int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
32
+	SingleDose                string  `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
33
+	ExecutionFrequency        string  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
34
+	DeliveryWay               string  `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
35
+	NumberDays                string  `gorm:"column:number_days" json:"number_days" form:"number_days"`
36
+	Total                     string  `gorm:"column:total" json:"total" form:"total"`
37
+}
38
+
39
+func (XtHisProject) TableName() string {
40
+	return "xt_his_project"
41
+}
42
+
43
+type XtHisProjectTeam struct {
44
+	ID          int64   `gorm:"column:id" json:"id" form:"id"`
45
+	ProjectTeam string  `gorm:"column:project_team" json:"project_team" form:"project_team"`
46
+	Price       float64 `gorm:"column:price" json:"price" form:"price"`
47
+	Pinyin      string  `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
48
+	Wubi        string  `gorm:"column:wubi" json:"wubi" form:"wubi"`
49
+	TubeColor   int64   `gorm:"column:tube_color" json:"tube_color" form:"tube_color"`
50
+	TeamType    int64   `gorm:"column:team_type" json:"team_type" form:"team_type"`
51
+	Remark      string  `gorm:"column:remark" json:"remark" form:"remark"`
52
+	UserOrgId   int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
53
+	Status      int64   `gorm:"column:status" json:"status" form:"status"`
54
+	CreatedTime int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
55
+	UpdatedTime int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
56
+	ProjectId   string  `gorm:"column:project_id" json:"project_id" form:"project_id"`
57
+}
58
+
59
+func (XtHisProjectTeam) TableName() string {
60
+	return "xt_his_project_team"
61
+}
62
+
63
+type XtHisDepartment struct {
64
+	ID          int64  `gorm:"column:id" json:"id" form:"id"`
65
+	Name        string `gorm:"column:name" json:"name" form:"name"`
66
+	Number      string `gorm:"column:number" json:"number" form:"number"`
67
+	UserOrgId   int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
68
+	Status      int64  `gorm:"column:status" json:"status" form:"status"`
69
+	CreatedTime int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
70
+	UpdatedTime int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
71
+}
72
+
73
+func (XtHisDepartment) TableName() string {
74
+	return "xt_his_department"
75
+}
76
+
77
+type HisPatient struct {
78
+	ID                     int64   `gorm:"column:id" json:"id" form:"id"`
79
+	BalanceAccountsType    int64   `gorm:"column:balance_accounts_type" json:"balance_accounts_type" form:"balance_accounts_type"`
80
+	MedicalInsuranceNumber string  `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
81
+	Name                   string  `gorm:"column:name" json:"name" form:"name"`
82
+	Gender                 int64   `gorm:"column:gender" json:"gender" form:"gender"`
83
+	IdType                 int64   `gorm:"column:id_type" json:"id_type" form:"id_type"`
84
+	Birthday               int64   `gorm:"column:birthday" json:"birthday" form:"birthday"`
85
+	RecordDate             int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
86
+	Age                    int64   `gorm:"column:age" json:"age" form:"age"`
87
+	PhoneNumber            string  `gorm:"column:phone_number" json:"phone_number" form:"phone_number"`
88
+	IdNumber               string  `gorm:"column:id_number" json:"id_number" form:"id_number"`
89
+	RegisterType           int64   `gorm:"column:register_type" json:"register_type" form:"register_type"`
90
+	Doctor                 int64   `gorm:"column:doctor" json:"doctor" form:"doctor"`
91
+	Departments            int64   `gorm:"column:departments" json:"departments" form:"departments"`
92
+	IsNeedCostOfProduction int64   `gorm:"column:is_need_cost_of_production" json:"is_need_cost_of_production" form:"is_need_cost_of_production"`
93
+	RegisterCost           float64 `gorm:"column:register_cost" json:"register_cost" form:"register_cost"`
94
+	TreatmentCost          float64 `gorm:"column:treatment_cost" json:"treatment_cost" form:"treatment_cost"`
95
+	CostOfProduction       float64 `gorm:"column:cost_of_production" json:"cost_of_production" form:"cost_of_production"`
96
+	Total                  float64 `gorm:"column:total" json:"total" form:"total"`
97
+	UserOrgId              int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
98
+	Status                 int64   `gorm:"column:status" json:"status" form:"status"`
99
+	Ctime                  int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
100
+	Mtime                  int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
101
+}
102
+
103
+func (HisPatient) TableName() string {
104
+	return "his_patient"
105
+}
106
+
107
+type HisPrescriptionVm struct {
108
+	ID           int64  `gorm:"column:id" json:"id" form:"id"`
109
+	UserOrgId    int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
110
+	RecordDate   int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
111
+	PatientId    int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
112
+	HisPatientId int64  `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
113
+	Status       int64  `gorm:"column:status" json:"status" form:"status"`
114
+	Ctime        int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
115
+	Mtime        int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
116
+	Number       string `gorm:"column:number" json:"number" form:"number"`
117
+	Type         int64  `gorm:"column:type" json:"type" form:"type"`
118
+	Doctor       int64  `gorm:"column:doctor" json:"doctor" form:"doctor"`
119
+	Creator      int64  `gorm:"column:creator" json:"creator" form:"creator"`
120
+	Modifier     int64  `gorm:"column:modifier" json:"modifier" form:"modifier"`
121
+	Name         string
122
+}
123
+
124
+type HisPrescription struct {
125
+	ID           int64  `gorm:"column:id" json:"id" form:"id"`
126
+	UserOrgId    int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
127
+	RecordDate   int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
128
+	PatientId    int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
129
+	HisPatientId int64  `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
130
+	Status       int64  `gorm:"column:status" json:"status" form:"status"`
131
+	Ctime        int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
132
+	Mtime        int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
133
+	Number       string `gorm:"column:number" json:"number" form:"number"`
134
+	Type         int64  `gorm:"column:type" json:"type" form:"type"`
135
+	Doctor       int64  `gorm:"column:doctor" json:"doctor" form:"doctor"`
136
+	Creator      int64  `gorm:"column:creator" json:"creator" form:"creator"`
137
+	Modifier     int64  `gorm:"column:modifier" json:"modifier" form:"modifier"`
138
+}
139
+
140
+func (HisPrescription) TableName() string {
141
+	return "his_prescription"
142
+}
143
+
144
+type HisAdditionalCharge struct {
145
+	ID          int64   `gorm:"column:id" json:"id" form:"id"`
146
+	DrugId      int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
147
+	PatientId   int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
148
+	Money       float64 `gorm:"column:money" json:"money" form:"money"`
149
+	AdminUserId int64   `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
150
+	UserOrgId   int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
151
+	RecordDate  int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
152
+	CreatedTime int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
153
+	UpdatedTime int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
154
+	Status      int64   `gorm:"column:status" json:"status" form:"status"`
155
+}
156
+
157
+func (HisAdditionalCharge) TableName() string {
158
+	return "his_additional_charge"
159
+}
160
+
161
+type SchedulesVm struct {
162
+	ID           int64  `gorm:"column:id" json:"id" form:"id"`
163
+	UserOrgId    int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
164
+	PartitionId  int64  `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
165
+	BedId        int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
166
+	PatientId    int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
167
+	ScheduleDate int64  `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
168
+	ScheduleType int64  `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
169
+	ScheduleWeek int64  `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
170
+	ModeId       int64  `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
171
+	Status       int64  `gorm:"column:status" json:"status" form:"status"`
172
+	CreatedTime  int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
173
+	UpdatedTime  int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
174
+	Name         string `gorm:"column:name" json:"name" form:"name"`
175
+	IdCardNo     string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
176
+}
177
+
178
+type HisProjectListVm struct {
179
+	ID           int64   `gorm:"column:id" json:"id" form:"id"`
180
+	Number       int64   `gorm:"column:number" json:"number" form:"number"`
181
+	UserOrgId    int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
182
+	ProjectId    int64   `gorm:"column:project_id" json:"project_id" form:"project_id"`
183
+	Status       int64   `gorm:"column:status" json:"status" form:"status"`
184
+	Price        float64 `gorm:"column:price" json:"price" form:"price"`
185
+	Unit         string  `gorm:"column:unit" json:"unit" form:"unit"`
186
+	ProjectName  string  `gorm:"column:project_name" json:"project_name" form:"project_name"`
187
+	CostClassify int64   `gorm:"column:cost_classify" json:"cost_classify" form:"cost_classify"`
188
+}
189
+
190
+type XtHisProjectList struct {
191
+	ID          int64 `gorm:"column:id" json:"id" form:"id"`
192
+	Number      int64 `gorm:"column:number" json:"number" form:"number"`
193
+	UserOrgId   int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
194
+	ProjectId   int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
195
+	Status      int64 `gorm:"column:status" json:"status" form:"status"`
196
+	CreatedTime int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
197
+	UpdatedTime int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
198
+}
199
+
200
+func (XtHisProjectList) TableName() string {
201
+	return "xt_his_project_list"
202
+}
203
+
204
+type XtHisPatient struct {
205
+	ID                     int64   `gorm:"column:id" json:"id" form:"id"`
206
+	BalanceAccountsType    int64   `gorm:"column:balance_accounts_type" json:"balance_accounts_type" form:"balance_accounts_type"`
207
+	MedicalInsuranceNumber string  `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
208
+	Name                   string  `gorm:"column:name" json:"name" form:"name"`
209
+	Gender                 int64   `gorm:"column:gender" json:"gender" form:"gender"`
210
+	IdType                 int64   `gorm:"column:id_type" json:"id_type" form:"id_type"`
211
+	MedicalTreatmentType   int64   `gorm:"column:medical_treatment_type" json:"medical_treatment_type" form:"medical_treatment_type"`
212
+	Birthday               int64   `gorm:"column:birthday" json:"birthday" form:"birthday"`
213
+	RecordDate             int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
214
+	Age                    int64   `gorm:"column:age" json:"age" form:"age"`
215
+	PhoneNumber            string  `gorm:"column:phone_number" json:"phone_number" form:"phone_number"`
216
+	IdCardNo               string  `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
217
+	RegisterType           int64   `gorm:"column:register_type" json:"register_type" form:"register_type"`
218
+	AdminUserId            int64   `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
219
+	Departments            int64   `gorm:"column:departments" json:"departments" form:"departments"`
220
+	IsNeedCostOfProduction int64   `gorm:"column:is_need_cost_of_production" json:"is_need_cost_of_production" form:"is_need_cost_of_production"`
221
+	RegisterCost           float64 `gorm:"column:register_cost" json:"register_cost" form:"register_cost"`
222
+	TreatmentCost          float64 `gorm:"column:treatment_cost" json:"treatment_cost" form:"treatment_cost"`
223
+	CostOfProduction       float64 `gorm:"column:cost_of_production" json:"cost_of_production" form:"cost_of_production"`
224
+	Total                  float64 `gorm:"column:total" json:"total" form:"total"`
225
+	UserOrgId              int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
226
+	Status                 int64   `gorm:"column:status" json:"status" form:"status"`
227
+	Ctime                  int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
228
+	Mtime                  int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
229
+	PatientId              int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
230
+	Number                 string  `gorm:"column:number" json:"number" form:"number"`
231
+}
232
+
233
+func (XtHisPatient) TableName() string {
234
+	return "his_patient"
235
+}

+ 1 - 0
routers/router.go 查看文件

@@ -70,4 +70,5 @@ func init() {
70 70
 	new_m_api.DialysisParameterApiControllersRegisterRouters()
71 71
 	controllers.SelfDrugRouters()
72 72
 	new_m_api.NewDrugApiControllersRegisterRouters()
73
+	controllers.HisProjectRouters()
73 74
 }

+ 280 - 0
service/his_project_service.go 查看文件

@@ -0,0 +1,280 @@
1
+package service
2
+
3
+import (
4
+	"XT_New/models"
5
+	"github.com/jinzhu/gorm"
6
+	"time"
7
+)
8
+
9
+func GetHisProjectIsExist(projectName string, orgid int64) (*models.XtHisProject, error) {
10
+
11
+	var project models.XtHisProject
12
+	var err error
13
+	err = XTReadDB().Model(&project).Where("project_name = ? and user_org_id = ? and status = 1", projectName, orgid).Find(&project).Error
14
+	if err == gorm.ErrRecordNotFound {
15
+		return nil, err
16
+	}
17
+
18
+	if err != nil {
19
+		return nil, err
20
+	}
21
+
22
+	return &project, nil
23
+}
24
+
25
+func CreateHisProject(project *models.XtHisProject) error {
26
+
27
+	err := XTWriteDB().Model(&project).Create(&project).Error
28
+	return err
29
+}
30
+
31
+func GetHisProjectList(orgid int64, limit int64, page int64, start int64, charge int64, keyword string) (hisproject []*models.XtHisProject, total int64, err error) {
32
+	offset := (page - 1) * limit
33
+	likeKey := "%" + keyword + "%"
34
+	db := XTReadDB().Table("xt_his_project as x").Where("x.status = 1")
35
+	if orgid > 0 {
36
+		db = db.Where("x.user_org_id = ?", orgid)
37
+	}
38
+	if start > 0 {
39
+		db = db.Where("x.medical_status = ?", start)
40
+	}
41
+	if charge > 0 {
42
+		db = db.Where("x.is_charge = ? ", charge)
43
+	}
44
+	if len(keyword) > 0 {
45
+		db = db.Where("x.project_name like ?", likeKey)
46
+	}
47
+	err = db.Select("x.id,x.project_name,x.pinyin,x.wubi,x.price,x.unit,x.cost_classify,x.executive_section,x.medical_coverage,x.statistical_classification,x.disease_directory,x.is_record,x.medical_code,x.tube_color,x.medical_status,x.remark,x.sign,x.default_number,x.is_default,x.is_charge,x.is_estimate,x.is_workload,x.sort,x.doctor_advice,x.user_org_id,x.status,x.created_time").Count(&total).Offset(offset).Limit(limit).Find(&hisproject).Error
48
+	return hisproject, total, err
49
+}
50
+
51
+func GetProjectDetail(id int64) (models.XtHisProject, error) {
52
+	project := models.XtHisProject{}
53
+	err := XTReadDB().Model(&project).Where("id=? and status = 1", id).Find(&project).Error
54
+	return project, err
55
+}
56
+
57
+func UpdatedProject(id int64, pro *models.XtHisProject) error {
58
+
59
+	err := XTWriteDB().Model(&pro).Where("id=?", id).Updates(map[string]interface{}{"project_name": pro.ProjectName, "pinyin": pro.Pinyin, "wubi": pro.Pinyin, "price": pro.Price, "unit": pro.Unit, "cost_classify": pro.CostClassify, "executive_section": pro.ExecutiveSection, "medical_coverage": pro.MedicalCoverage, "statistical_classification": pro.MedicalCoverage, "disease_directory": pro.DiseaseDirectory, "is_record": pro.DiseaseDirectory, "medical_code": pro.MedicalCode, "tube_color": pro.TubeColor, "medical_status": pro.MedicalStatus, "remark": pro.Remark, "sign": pro.Sign, "default_number": pro.DefaultNumber, "is_default": pro.IsDefault, "is_charge": pro.IsCharge, "is_estimate": pro.IsEstimate, "is_workload": pro.IsWorkload, "sort": pro.Sort, "doctor_advice": pro.DoctorAdvice, "single_dose": pro.SingleDose, "execution_frequency": pro.ExecutionFrequency, "delivery_way": pro.ExecutionFrequency, "number_days": pro.ExecutionFrequency, "total": pro.Total, "updated_time": pro.UpdatedTime}).Error
60
+	return err
61
+}
62
+
63
+func DeleteHisProject(id int64) error {
64
+	project := models.XtHisProject{}
65
+	err := XTWriteDB().Model(&project).Where("id=?", id).Updates(map[string]interface{}{"status": 0}).Error
66
+	return err
67
+}
68
+
69
+func GetHisProjectByNameOne(projectName string, orgid int64) (*models.XtHisProjectTeam, error) {
70
+
71
+	projectTeam := models.XtHisProjectTeam{}
72
+	err := XTReadDB().Model(&projectTeam).Where("project_team = ? and user_org_id = ? and status = 1", projectName, orgid).Find(&projectTeam).Error
73
+	if err != nil {
74
+		if err == gorm.ErrRecordNotFound {
75
+			return nil, err
76
+		} else {
77
+			return nil, err
78
+		}
79
+	}
80
+	return &projectTeam, nil
81
+
82
+}
83
+
84
+func CreatedProjectTeam(team *models.XtHisProjectTeam) error {
85
+
86
+	err := XTWriteDB().Model(&team).Create(&team).Error
87
+	return err
88
+}
89
+
90
+func GetProjectTeamList(limit int64, page int64, orgid int64, keyword string) (projectTeam []*models.XtHisProjectTeam, total int64, err error) {
91
+	offset := (page - 1) * limit
92
+	likeKey := "%" + keyword + "%"
93
+	db := XTReadDB().Model(&projectTeam)
94
+	if len(keyword) > 0 {
95
+		db = db.Where("project_team like ?", likeKey)
96
+	}
97
+	err = db.Where("user_org_id = ? and status = 1", orgid).Count(&total).Offset(offset).Limit(limit).Order("created_time desc").Find(&projectTeam).Error
98
+	return projectTeam, total, err
99
+}
100
+
101
+func GetProjectTeamDetail(id int64) (models.XtHisProjectTeam, error) {
102
+
103
+	projectTeam := models.XtHisProjectTeam{}
104
+	err := XTReadDB().Model(&projectTeam).Where("id= ? and status = 1", id).Find(&projectTeam).Error
105
+	return projectTeam, err
106
+}
107
+
108
+func UpdatedProjectTeam(id int64, team *models.XtHisProjectTeam) error {
109
+
110
+	err := XTWriteDB().Model(&team).Where("id=? and status = 1", id).Updates(map[string]interface{}{"project_team": team.ProjectTeam, "price": team.Price, "pinyin": team.Pinyin, "wubi": team.Wubi, "tube_color": team.TubeColor, "team_type": team.TeamType, "remark": team.Remark, "project_id": team.ProjectId}).Error
111
+	return err
112
+}
113
+
114
+func DeleteProjectTeam(id int64) error {
115
+
116
+	team := models.XtHisProjectTeam{}
117
+	err := XTWriteDB().Model(&team).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"status": 0}).Error
118
+	return err
119
+}
120
+
121
+func CreateDePartment(department *models.XtHisDepartment) error {
122
+
123
+	err := XTWriteDB().Model(&department).Create(&department).Error
124
+	return err
125
+}
126
+
127
+func GetDepartMentList(limit int64, page int64, orgid int64) (departMent []*models.XtHisDepartment, total int64, err error) {
128
+
129
+	offset := (page - 1) * limit
130
+	err = XTReadDB().Model(&departMent).Where("user_org_id = ? and status = 1", orgid).Count(&total).Offset(offset).Limit(limit).Order("created_time desc").Find(&departMent).Error
131
+	return departMent, total, err
132
+}
133
+
134
+func GetDepartMentDetail(id int64) (models.XtHisDepartment, error) {
135
+
136
+	department := models.XtHisDepartment{}
137
+	err := XTReadDB().Model(&department).Where("id=? and status = 1", id).Find(&department).Error
138
+	return department, err
139
+}
140
+
141
+func UpdatedDepartment(id int64, department *models.XtHisDepartment) error {
142
+
143
+	err := XTWriteDB().Model(&department).Where("id=? and status = 1", id).Updates(map[string]interface{}{"name": department.Name, "number": department.Number, "updated_time": time.Now().Unix()}).Error
144
+	return err
145
+}
146
+
147
+func DeleteDepartment(id int64) error {
148
+	department := models.XtHisDepartment{}
149
+	err := XTReadDB().Model(&department).Where("id=? and status = 1", id).Updates(map[string]interface{}{"status": 0}).Error
150
+	return err
151
+}
152
+
153
+func GetBloodPatientList(orgid int64, startime int64) (schedule []*models.SchedulesVm, err error) {
154
+
155
+	db := XTReadDB().Table("xt_schedule as x").Where("x.status = 1")
156
+	if orgid > 0 {
157
+		db = db.Where("x.user_org_id = ?", orgid)
158
+	}
159
+	if startime > 0 {
160
+		db = db.Where("x.schedule_date = ?", startime)
161
+	}
162
+	err = db.Select("x.id,x.user_org_id,x.patient_id,x.schedule_date,x.schedule_type,x.schedule_week,x.mode_id,p.name,p.id_card_no").Joins("left join xt_patients as p on p.id = x.patient_id").Scan(&schedule).Error
163
+	return schedule, err
164
+}
165
+
166
+func GetHisPatient(orgid int64, recorddate int64) (paitent []*models.HisPatient, err error) {
167
+
168
+	err = XTReadDB().Model(&paitent).Where("user_org_id = ?  and record_date = ? and status = 1", orgid, recorddate).Find(&paitent).Error
169
+	return paitent, err
170
+}
171
+
172
+func HisPrescription(orgid int64, recorddate int64) (prescription []*models.HisPrescriptionVm, err error) {
173
+
174
+	db := XTReadDB().Table("his_prescription as x").Where("x.status = 1")
175
+	if orgid > 0 {
176
+		db = db.Where("x.user_org_id = ?", orgid)
177
+	}
178
+	if recorddate > 0 {
179
+		db = db.Where("x.record_date = ? ", recorddate)
180
+	}
181
+	err = db.Select("x.id,x.user_org_id,x.record_date,x.patient_id,x.his_patient_id,x.number,x.type,x.doctor,x.creator,x.modifier,t.name").Joins("left join his_patient as t on t.id = x.his_patient_id").Scan(&prescription).Error
182
+	return prescription, err
183
+}
184
+
185
+func GetHisPrescriptionByPatientId(id int64, recordate int64) (prescription []*models.HisPrescription, err error) {
186
+
187
+	err = XTReadDB().Model(&prescription).Where("his_patient_id = ? and record_date = ? and status= 1", id, recordate).Find(&prescription).Error
188
+	return prescription, err
189
+}
190
+
191
+func CreateAdditionalCharge(charge *models.HisAdditionalCharge) error {
192
+
193
+	err = XTWriteDB().Model(&charge).Create(&charge).Error
194
+	return err
195
+}
196
+
197
+func GetTreatmentList(id int64, startime int64) (prescription []*models.HisPrescription, err error) {
198
+
199
+	err = XTReadDB().Model(&prescription).Where("id = ? and record_date = ? and status = 1", id, startime).Find(&prescription).Error
200
+	return prescription, err
201
+}
202
+
203
+func GetAllProjectList(orgid int64) (project []*models.XtHisProject, err error) {
204
+
205
+	err = XTReadDB().Model(&project).Where("user_org_id = ? and status = 1", orgid).Find(&project).Error
206
+	return project, err
207
+}
208
+
209
+func CreateProjectList(list *models.XtHisProjectList) error {
210
+
211
+	err := XTWriteDB().Model(&list).Create(&list).Error
212
+	return err
213
+}
214
+
215
+func GetHisProjectListByOrgId(orgid int64) (projectlist []*models.HisProjectListVm, err error) {
216
+
217
+	db := XTReadDB().Table("xt_his_project_list as x").Where("x.status = 1")
218
+	if orgid > 0 {
219
+		db = db.Where("x.user_org_id = ? ", orgid)
220
+	}
221
+	err = db.Select("x.id,x.number,x.user_org_id,x.project_id,t.price,t.unit,t.cost_classify,t.project_name").Joins("left join xt_his_project as t on t.id = x.project_id").Scan(&projectlist).Error
222
+	return projectlist, err
223
+}
224
+
225
+func GetHisPatientInformation(id int64) (models.HisPatient, error) {
226
+
227
+	patient := models.HisPatient{}
228
+	err := XTReadDB().Model(&patient).Where("id= ? and status = 1", id).Find(&patient).Error
229
+	return patient, err
230
+}
231
+
232
+func DeleteProjectList(id int64) error {
233
+	list := models.XtHisProjectList{}
234
+	err := XTWriteDB().Model(&list).Where("id=? and status = 1", id).Updates(map[string]interface{}{"status": 0}).Error
235
+	return err
236
+}
237
+
238
+func GetHisProject(orgid int64) (project []*models.XtHisProject, err error) {
239
+
240
+	err = XTReadDB().Model(&project).Where("user_org_id = ? and status =1", orgid).Find(&project).Error
241
+	return project, err
242
+}
243
+
244
+func GetProjectTeam(ids []string, orgid int64) (project []*models.XtHisProject, err error) {
245
+
246
+	err = XTReadDB().Model(&project).Where("user_org_id = ? and id in (?)", orgid, ids).Find(&project).Error
247
+	return project, err
248
+}
249
+
250
+func GetAllDepartMent(orgid int64) (department []*models.XtHisDepartment, err error) {
251
+
252
+	err = XTReadDB().Model(&department).Where("user_org_id = ? and status =1", orgid).Find(&department).Error
253
+	return department, err
254
+}
255
+
256
+func CreateHisPatient(patient *models.XtHisPatient) error {
257
+
258
+	err := XTReadDB().Model(&patient).Create(&patient).Error
259
+	return err
260
+}
261
+
262
+func GetBloodPatientByIdCard(idcard string, orgid int64) (*models.XtPatients, error) {
263
+	var patients models.XtPatients
264
+	var err error
265
+	err = XTReadDB().Model(&patients).Where("id_card_no = ? and user_org_id = ? and status = 1", idcard, orgid).Find(&patients).Error
266
+	if err != nil {
267
+		if err == gorm.ErrRecordNotFound {
268
+			return nil, err
269
+		} else {
270
+			return nil, err
271
+		}
272
+	}
273
+	return &patients, nil
274
+}
275
+
276
+func GetAllProjectTeam(orgid int64) (project []*models.XtHisProjectTeam, err error) {
277
+
278
+	err = XTReadDB().Model(&project).Where("user_org_id = ? and status = 1", orgid).Find(&project).Error
279
+	return project, err
280
+}

+ 1 - 1
service/self_drug_service.go 查看文件

@@ -566,7 +566,7 @@ func (PrivateDrug) TableName() string {
566 566
 }
567 567
 
568 568
 func GetPrivateDrugList(patient_id int64, org_id int64) (pds []*PrivateDrug, err error) {
569
-	err = XTReadDB().Model(&PrivateDrug{}).Preload("PrivateDrug", "status = 1 AND user_org_id = ? AND patient_id = ? ", org_id, patient_id).Where("patient_id = ? and status = 1 AND user_org_id = ?", patient_id, org_id).Group("drug_name").Find(&pds).Error
569
+	err = XTReadDB().Model(&PrivateDrug{}).Preload("PrivateDrug", "status = 1 AND user_org_id = ? AND patient_id = ? ", org_id, patient_id).Where("patient_id = ? and status = 1 AND user_org_id = ?", patient_id, org_id).Group("drug_name_id").Find(&pds).Error
570 570
 	return
571 571
 }
572 572