|
@@ -3,6 +3,8 @@ import { MainService } from "src/app/services/main.service";
|
3
|
3
|
import { ToolService } from "src/app/services/tool.service";
|
4
|
4
|
import { Subject } from 'rxjs';
|
5
|
5
|
import { debounceTime } from 'rxjs/operators';
|
|
6
|
+import { ActivatedRoute } from '@angular/router';
|
|
7
|
+import { FormGroup, FormBuilder, Validators } from '@angular/forms';
|
6
|
8
|
|
7
|
9
|
@Component({
|
8
|
10
|
selector: "app-patient-search",
|
|
@@ -10,96 +12,142 @@ import { debounceTime } from 'rxjs/operators';
|
10
|
12
|
styleUrls: ["./patient-search.component.less"],
|
11
|
13
|
})
|
12
|
14
|
export class PatientSearchComponent implements OnInit {
|
13
|
|
- constructor(private mainService: MainService, private tool: ToolService) {}
|
14
|
|
-
|
15
|
|
- searchCriteria = {
|
16
|
|
- //搜索条件
|
17
|
|
- patientName: "",
|
18
|
|
- bedNum: "",
|
19
|
|
- hospital: null,
|
20
|
|
- department: null,
|
21
|
|
- };
|
22
|
|
- allHospital: any = []; //院区下拉框
|
|
15
|
+ constructor(
|
|
16
|
+ private mainService: MainService,
|
|
17
|
+ private tool: ToolService,
|
|
18
|
+ private route: ActivatedRoute,
|
|
19
|
+ private fb: FormBuilder,
|
|
20
|
+ ) {}
|
|
21
|
+
|
|
22
|
+ hosId = this.tool.getCurrentHospital().id; //当前院区
|
|
23
|
+
|
|
24
|
+ searchCriteria:any = {};
|
23
|
25
|
listOfData: any[] = []; //表格数据
|
24
|
26
|
pageIndex: number = 1; //表格当前页码
|
25
|
27
|
pageSize: number = 10; //表格每页展示条数
|
26
|
28
|
listLength: number = 10; //表格总数据量
|
27
|
29
|
changeInpSubject = new Subject();
|
|
30
|
+
|
|
31
|
+ // 初始化增删改按钮
|
|
32
|
+ coopBtns: any = {};
|
|
33
|
+
|
28
|
34
|
ngOnInit() {
|
29
|
35
|
this.changeInpSubject.pipe(debounceTime(500)).subscribe((v) => {
|
30
|
|
- this.searchDepartment(v[0], v[1]);
|
|
36
|
+ if(v[1] === 'department'){
|
|
37
|
+ this.getDepartmentList(v[0]);
|
|
38
|
+ }else if(v[1] === 'departmentSearch'){
|
|
39
|
+ this.getDepartmentSearchList(v[0]);
|
|
40
|
+ }
|
31
|
41
|
});
|
32
|
|
- this.getAllHospital();
|
|
42
|
+ this.coopBtns = this.tool.initCoopBtns(this.route);
|
|
43
|
+ this.searchCriteria.hosId = this.tool.getCurrentHospital().id;
|
|
44
|
+ this.getList(1);
|
|
45
|
+ this.getGenderList();
|
|
46
|
+ this.getCareLevelList();
|
|
47
|
+ this.getIllnessStateList();
|
|
48
|
+ this.getPatientTypeList();
|
|
49
|
+ this.getHospitalList();
|
|
50
|
+ this.getHospitalSearchList();
|
33
|
51
|
}
|
34
|
|
- // 选择院区
|
35
|
|
- changeHospital(id, type) {
|
36
|
|
- if (type === "search") {
|
37
|
|
- this.searchCriteria.department = null;
|
38
|
|
- }
|
|
52
|
+
|
|
53
|
+ // 获取院区列表
|
|
54
|
+ hospitalList = [];
|
|
55
|
+ getHospitalList() {
|
|
56
|
+ this.hospitalList = this.tool.getHospitalList();
|
|
57
|
+ }
|
|
58
|
+
|
|
59
|
+ changeHospital(e){
|
|
60
|
+ this.deptList = [];
|
|
61
|
+ this.validateForm.controls.department.setValue(null);
|
39
|
62
|
}
|
|
63
|
+
|
|
64
|
+ // 获取院区列表
|
|
65
|
+ hospitalSearchList = [];
|
|
66
|
+ getHospitalSearchList() {
|
|
67
|
+ this.hospitalSearchList = this.tool.getHospitalList();
|
|
68
|
+ }
|
|
69
|
+
|
|
70
|
+ changeHospitalSearch(e){
|
|
71
|
+ this.deptSearchList = [];
|
|
72
|
+ this.searchCriteria.department = undefined;
|
|
73
|
+ }
|
|
74
|
+
|
40
|
75
|
// 搜索科室
|
41
|
|
- departmentSearch = []; // 院区下的科室列表(搜索框)
|
42
|
|
- deptKey = "";
|
|
76
|
+ deptList = []; // 院区下的科室列表(搜索框)
|
43
|
77
|
isLoading = false;
|
44
|
|
- searchDepartment(dept, type) {
|
|
78
|
+ getDepartmentList(dept) {
|
45
|
79
|
let data = {
|
46
|
80
|
department: {
|
|
81
|
+ searchType: 1,// 简单查询
|
47
|
82
|
dept,
|
48
|
83
|
hospital: {
|
49
|
|
- id: this.searchCriteria.hospital,
|
|
84
|
+ id: this.validateForm.value.hosId,
|
50
|
85
|
},
|
51
|
86
|
},
|
52
|
87
|
idx: 0,
|
53
|
88
|
sum: 10,
|
54
|
89
|
};
|
55
|
90
|
this.mainService
|
56
|
|
- .getFetchDataList("data", "department", data)
|
|
91
|
+ .getFetchDataList("simple/data", "department", data)
|
57
|
92
|
.subscribe((data) => {
|
|
93
|
+ this.isLoading = false;
|
58
|
94
|
if (data.status == 200) {
|
59
|
|
- if (type === "search") {
|
60
|
|
- if (this.deptKey === dept) {
|
61
|
|
- this.isLoading = false;
|
62
|
|
- this.departmentSearch = data.list;
|
63
|
|
- }
|
64
|
|
- }
|
|
95
|
+ this.deptList = data.list;
|
|
96
|
+ }else{
|
|
97
|
+ this.deptList = [];
|
|
98
|
+ }
|
|
99
|
+ });
|
|
100
|
+ }
|
|
101
|
+
|
|
102
|
+ // 搜索科室
|
|
103
|
+ deptSearchList = []; // 院区下的科室列表(搜索框)
|
|
104
|
+ getDepartmentSearchList(dept) {
|
|
105
|
+ let data = {
|
|
106
|
+ department: {
|
|
107
|
+ searchType: 1,// 简单查询
|
|
108
|
+ dept,
|
|
109
|
+ hospital: {
|
|
110
|
+ id: this.searchCriteria.hosId,
|
|
111
|
+ },
|
|
112
|
+ },
|
|
113
|
+ idx: 0,
|
|
114
|
+ sum: 10,
|
|
115
|
+ };
|
|
116
|
+ this.mainService
|
|
117
|
+ .getFetchDataList("simple/data", "department", data)
|
|
118
|
+ .subscribe((data) => {
|
|
119
|
+ this.isLoading = false;
|
|
120
|
+ if (data.status == 200) {
|
|
121
|
+ this.deptSearchList = data.list;
|
|
122
|
+ }else{
|
|
123
|
+ this.deptSearchList = [];
|
65
|
124
|
}
|
66
|
125
|
});
|
67
|
126
|
}
|
68
|
127
|
changeInp(dept, type) {
|
69
|
|
- if (!dept) {
|
70
|
|
- return;
|
71
|
|
- }
|
72
|
|
- if (dept === "no") {
|
73
|
|
- dept = "";
|
74
|
|
- }
|
75
|
|
- this.deptKey = dept;
|
76
|
128
|
this.isLoading = true;
|
77
|
129
|
this.changeInpSubject.next([dept, type]);
|
78
|
130
|
}
|
79
|
131
|
// 打开搜索框
|
80
|
|
- changeSearch(flag) {
|
|
132
|
+ openDepartment(flag) {
|
81
|
133
|
if (flag) {
|
82
|
|
- this.changeInp("no", "search");
|
|
134
|
+ this.changeInp("", "department");
|
|
135
|
+ }
|
|
136
|
+ }
|
|
137
|
+ // 打开搜索框
|
|
138
|
+ openDepartmentSearch(flag) {
|
|
139
|
+ if (flag) {
|
|
140
|
+ this.changeInp("", "departmentSearch");
|
83
|
141
|
}
|
84
|
142
|
}
|
85
|
143
|
// 重置
|
86
|
144
|
reset() {
|
87
|
145
|
this.searchCriteria = {
|
88
|
|
- //搜索条件
|
89
|
|
- patientName: "",
|
90
|
|
- bedNum: "",
|
91
|
|
- hospital: this.allHospital[0] ? this.allHospital[0]["id"] + "" : null,
|
92
|
|
- department: null,
|
|
146
|
+ hosId: this.tool.getCurrentHospital().id,
|
93
|
147
|
};
|
94
|
148
|
this.getList(1);
|
95
|
149
|
}
|
96
|
150
|
|
97
|
|
- // 获取所有院区
|
98
|
|
- getAllHospital() {
|
99
|
|
- this.allHospital = [this.tool.getCurrentHospital()];
|
100
|
|
- this.searchCriteria.hospital = this.tool.getCurrentHospital().id + "";
|
101
|
|
- this.getList(1);
|
102
|
|
- }
|
103
|
151
|
// 查看标本历史记录
|
104
|
152
|
historyPromptModalShow = false; //标本历史记录弹窗开关
|
105
|
153
|
scode = ""; //查看历史记录携带
|
|
@@ -121,10 +169,12 @@ export class PatientSearchComponent implements OnInit {
|
121
|
169
|
let postData = {
|
122
|
170
|
idx: this.pageIndex - 1,
|
123
|
171
|
sum: this.pageSize,
|
124
|
|
- hosId: this.searchCriteria.hospital,
|
|
172
|
+ hosId: this.searchCriteria.hosId,
|
125
|
173
|
patientName: this.searchCriteria.patientName,
|
126
|
|
- bedNum: this.searchCriteria.bedNum,
|
127
|
174
|
department: this.searchCriteria.department || undefined,
|
|
175
|
+ careLevel: this.searchCriteria.careLevel || undefined,
|
|
176
|
+ illnessState: this.searchCriteria.illnessState || undefined,
|
|
177
|
+ patientType: this.searchCriteria.patientType || undefined,
|
128
|
178
|
};
|
129
|
179
|
this.loading1 = true;
|
130
|
180
|
this.mainService.listMsgByMain('listPatient',postData).subscribe((data) => {
|
|
@@ -135,4 +185,206 @@ export class PatientSearchComponent implements OnInit {
|
135
|
185
|
}
|
136
|
186
|
});
|
137
|
187
|
}
|
|
188
|
+
|
|
189
|
+ // 新增弹框
|
|
190
|
+ modal: boolean = false; //新增/编辑模态框
|
|
191
|
+ add: boolean; //true:新增;false:编辑
|
|
192
|
+ validateForm: FormGroup; //新增/编辑表单
|
|
193
|
+ showModal() {
|
|
194
|
+ this.add = true;
|
|
195
|
+ this.modal = true;
|
|
196
|
+ this.initForm();
|
|
197
|
+ this.validateForm.controls.hosId.setValue(this.searchCriteria.hosId);
|
|
198
|
+ }
|
|
199
|
+ hideModal() {
|
|
200
|
+ this.modal = false;
|
|
201
|
+ }
|
|
202
|
+
|
|
203
|
+ // 初始化新增form表单
|
|
204
|
+ initForm() {
|
|
205
|
+ if (this.add) {
|
|
206
|
+ this.deptList = [];
|
|
207
|
+ }
|
|
208
|
+ this.validateForm = this.fb.group({
|
|
209
|
+ patientName: ['', [Validators.required]],
|
|
210
|
+ gender: [null],
|
|
211
|
+ age: [undefined],
|
|
212
|
+ residenceNo: ['', [Validators.required]],
|
|
213
|
+ barCode: ['', [Validators.required]],
|
|
214
|
+ bedNum: [''],
|
|
215
|
+ hosId: [null, [Validators.required]],
|
|
216
|
+ department: [null, [Validators.required]],
|
|
217
|
+ careLevel: [null, [Validators.required]],
|
|
218
|
+ illnessState: [null],
|
|
219
|
+ patientType: [null, [Validators.required]],
|
|
220
|
+ });
|
|
221
|
+ }
|
|
222
|
+ // 表单提交
|
|
223
|
+ btnLoading: boolean = false; //提交按钮loading状态
|
|
224
|
+ submitForm(): void {
|
|
225
|
+ for (const i in this.validateForm.controls) {
|
|
226
|
+ this.validateForm.controls[i].markAsDirty({ onlySelf: true });
|
|
227
|
+ this.validateForm.controls[i].updateValueAndValidity();
|
|
228
|
+ }
|
|
229
|
+ if (this.validateForm.invalid) return;
|
|
230
|
+ this.btnLoading = true;
|
|
231
|
+ let postData = {};
|
|
232
|
+ if(this.add){
|
|
233
|
+ postData = {
|
|
234
|
+ patient: {
|
|
235
|
+ hosId: this.validateForm.value.hosId,
|
|
236
|
+ patientName: this.validateForm.value.patientName,
|
|
237
|
+ gender: {
|
|
238
|
+ id: this.validateForm.value.gender
|
|
239
|
+ },
|
|
240
|
+ age: this.validateForm.value.age,
|
|
241
|
+ residenceNo: this.validateForm.value.residenceNo,
|
|
242
|
+ barCode: this.validateForm.value.barCode,
|
|
243
|
+ bedNum: this.validateForm.value.bedNum,
|
|
244
|
+ department: {
|
|
245
|
+ id: this.validateForm.value.department,
|
|
246
|
+ },
|
|
247
|
+ careLevel: {
|
|
248
|
+ id: this.validateForm.value.careLevel,
|
|
249
|
+ },
|
|
250
|
+ illnessState: this.validateForm.value.illnessState ? {
|
|
251
|
+ id: this.validateForm.value.illnessState,
|
|
252
|
+ } : undefined,
|
|
253
|
+ patientType: {
|
|
254
|
+ id: this.validateForm.value.patientType,
|
|
255
|
+ },
|
|
256
|
+ }
|
|
257
|
+ }
|
|
258
|
+ }else{
|
|
259
|
+ postData = {
|
|
260
|
+ patient: {
|
|
261
|
+ ...this.coopData,
|
|
262
|
+ hosId: this.validateForm.value.hosId,
|
|
263
|
+ patientName: this.validateForm.value.patientName,
|
|
264
|
+ gender: {
|
|
265
|
+ id: this.validateForm.value.gender
|
|
266
|
+ },
|
|
267
|
+ age: this.validateForm.value.age,
|
|
268
|
+ residenceNo: this.validateForm.value.residenceNo,
|
|
269
|
+ barCode: this.validateForm.value.barCode,
|
|
270
|
+ bedNum: this.validateForm.value.bedNum,
|
|
271
|
+ department: {
|
|
272
|
+ id: this.validateForm.value.department,
|
|
273
|
+ },
|
|
274
|
+ careLevel: {
|
|
275
|
+ id: this.validateForm.value.careLevel,
|
|
276
|
+ },
|
|
277
|
+ illnessState: this.validateForm.value.illnessState ? {
|
|
278
|
+ id: this.validateForm.value.illnessState,
|
|
279
|
+ } : undefined,
|
|
280
|
+ patientType: {
|
|
281
|
+ id: this.validateForm.value.patientType,
|
|
282
|
+ },
|
|
283
|
+ }
|
|
284
|
+ }
|
|
285
|
+ }
|
|
286
|
+
|
|
287
|
+ this.mainService
|
|
288
|
+ .coopData("addData", "patient", postData)
|
|
289
|
+ .subscribe((data) => {
|
|
290
|
+ this.btnLoading = false;
|
|
291
|
+ this.hideModal();
|
|
292
|
+ if (data.status == 200) {
|
|
293
|
+ this.showPromptModal(this.add ? "新增" : "编辑", true, "");
|
|
294
|
+ } else{
|
|
295
|
+ this.showPromptModal(this.add ? "新增" : "编辑", false, data.msg);
|
|
296
|
+ }
|
|
297
|
+ });
|
|
298
|
+ }
|
|
299
|
+
|
|
300
|
+ // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
|
|
301
|
+ promptContent: string; //操作提示框提示信息
|
|
302
|
+ ifSuccess: boolean; //操作成功/失败
|
|
303
|
+ promptInfo: string; //操作结果提示信息
|
|
304
|
+ promptModalShow: boolean; //操作提示框是否展示
|
|
305
|
+ showPromptModal(con, success, promptInfo?) {
|
|
306
|
+ this.promptModalShow = false;
|
|
307
|
+ this.promptContent = con;
|
|
308
|
+ this.ifSuccess = success;
|
|
309
|
+ this.promptInfo = promptInfo;
|
|
310
|
+ setTimeout(() => {
|
|
311
|
+ this.promptModalShow = true;
|
|
312
|
+ }, 100);
|
|
313
|
+ this.getList(1);
|
|
314
|
+ }
|
|
315
|
+
|
|
316
|
+ // 编辑
|
|
317
|
+ maskFlag: any = false;
|
|
318
|
+ coopData = {};
|
|
319
|
+ edit(data) {
|
|
320
|
+ this.initForm();
|
|
321
|
+ this.validateForm.controls.hosId.setValue(data.hosId);
|
|
322
|
+ this.validateForm.controls.patientName.setValue(data.patientName);
|
|
323
|
+ if(data.gender){
|
|
324
|
+ this.validateForm.controls.gender.setValue(data.gender.id);
|
|
325
|
+ }else{
|
|
326
|
+ this.validateForm.controls.gender.setValue(null);
|
|
327
|
+ }
|
|
328
|
+ this.validateForm.controls.age.setValue(data.age);
|
|
329
|
+ this.validateForm.controls.residenceNo.setValue(data.residenceNo);
|
|
330
|
+ this.validateForm.controls.barCode.setValue(data.barCode);
|
|
331
|
+ this.validateForm.controls.bedNum.setValue(data.bedNum);
|
|
332
|
+ if(data.department){
|
|
333
|
+ this.deptList = [data.department];
|
|
334
|
+ this.validateForm.controls.department.setValue(data.department.id);
|
|
335
|
+ }else{
|
|
336
|
+ this.validateForm.controls.department.setValue(null);
|
|
337
|
+ }
|
|
338
|
+ if(data.careLevel){
|
|
339
|
+ this.validateForm.controls.careLevel.setValue(data.careLevel.id);
|
|
340
|
+ }else{
|
|
341
|
+ this.validateForm.controls.careLevel.setValue(null);
|
|
342
|
+ }
|
|
343
|
+ if(data.illnessState){
|
|
344
|
+ this.validateForm.controls.illnessState.setValue(data.illnessState.id);
|
|
345
|
+ }else{
|
|
346
|
+ this.validateForm.controls.illnessState.setValue(null);
|
|
347
|
+ }
|
|
348
|
+ if(data.patientType){
|
|
349
|
+ this.validateForm.controls.patientType.setValue(data.patientType.id);
|
|
350
|
+ }else{
|
|
351
|
+ this.validateForm.controls.patientType.setValue(null);
|
|
352
|
+ }
|
|
353
|
+
|
|
354
|
+ this.modal = true;
|
|
355
|
+ this.add = false;
|
|
356
|
+ this.coopData = data;
|
|
357
|
+ }
|
|
358
|
+
|
|
359
|
+ // 获取性别
|
|
360
|
+ genderList: any = [];
|
|
361
|
+ getGenderList() {
|
|
362
|
+ this.mainService.getDictionary("list", "user_gender").subscribe((data) => {
|
|
363
|
+ this.genderList = data || [];
|
|
364
|
+ });
|
|
365
|
+ }
|
|
366
|
+
|
|
367
|
+ // 获取护理等级
|
|
368
|
+ careLevelList: any = [];
|
|
369
|
+ getCareLevelList() {
|
|
370
|
+ this.mainService.getDictionary("list", "levelOfCare").subscribe((data) => {
|
|
371
|
+ this.careLevelList = data || [];
|
|
372
|
+ });
|
|
373
|
+ }
|
|
374
|
+
|
|
375
|
+ // 获取病情级别
|
|
376
|
+ illnessStateList: any = [];
|
|
377
|
+ getIllnessStateList() {
|
|
378
|
+ this.mainService.getDictionary("list", "stateOfAnIllness").subscribe((data) => {
|
|
379
|
+ this.illnessStateList = data || [];
|
|
380
|
+ });
|
|
381
|
+ }
|
|
382
|
+
|
|
383
|
+ // 获取患者类别
|
|
384
|
+ patientTypeList: any = [];
|
|
385
|
+ getPatientTypeList() {
|
|
386
|
+ this.mainService.getDictionary("list", "patient_type").subscribe((data) => {
|
|
387
|
+ this.patientTypeList = data || [];
|
|
388
|
+ });
|
|
389
|
+ }
|
138
|
390
|
}
|