@csmart/ngc-smart-victim 1.18.9 → 1.18.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. package/esm2022/csmart-ngc-smart-victim.mjs +5 -0
  2. package/esm2022/lib/caseNote/caseNote.component.mjs +194 -0
  3. package/esm2022/lib/common-dialog/common-dialog.component.mjs +23 -0
  4. package/esm2022/lib/common-dialog/common-dialog.module.mjs +34 -0
  5. package/esm2022/lib/common-dialog/common-dialog.service.mjs +33 -0
  6. package/esm2022/lib/contact/contact.component.mjs +140 -0
  7. package/esm2022/lib/email.services.mjs +42 -0
  8. package/esm2022/lib/intake.service.mjs +57 -0
  9. package/esm2022/lib/safetyPlan/serviceProvider.component.mjs +99 -0
  10. package/esm2022/lib/safetyPlan/victimSafetyPlan.component.mjs +116 -0
  11. package/esm2022/lib/safetyPlan/victimSafetyPlanDetail.component.mjs +340 -0
  12. package/esm2022/lib/shared/app.shared.module.mjs +215 -0
  13. package/esm2022/lib/shared/validators/date.validator.mjs +59 -0
  14. package/esm2022/lib/shared/validators/index.mjs +2 -0
  15. package/esm2022/lib/smart-victim-delete-confirm.component.mjs +44 -0
  16. package/esm2022/lib/smart-victim-detail/smart-victim-detail.component.mjs +1155 -0
  17. package/esm2022/lib/smart-victim.component.mjs +317 -0
  18. package/esm2022/lib/smart-victim.model.mjs +142 -0
  19. package/esm2022/lib/smart-victim.module.mjs +128 -0
  20. package/esm2022/lib/smart-victim.service.mjs +370 -0
  21. package/esm2022/lib/victim-routing.module.mjs +41 -0
  22. package/esm2022/lib/victimSearch/VictimSearchFilter.mjs +3 -0
  23. package/esm2022/lib/victimSearch/victimSearchForm.component.mjs +38 -0
  24. package/esm2022/public-api.mjs +11 -0
  25. package/fesm2022/csmart-ngc-smart-victim.mjs +3342 -0
  26. package/fesm2022/csmart-ngc-smart-victim.mjs.map +1 -0
  27. package/index.d.ts +5 -0
  28. package/lib/caseNote/caseNote.component.d.ts +51 -0
  29. package/lib/common-dialog/common-dialog.component.d.ts +14 -0
  30. package/lib/common-dialog/common-dialog.module.d.ts +8 -0
  31. package/lib/common-dialog/common-dialog.service.d.ts +11 -0
  32. package/lib/contact/contact.component.d.ts +40 -0
  33. package/lib/email.services.d.ts +11 -0
  34. package/lib/intake.service.d.ts +57 -0
  35. package/lib/safetyPlan/serviceProvider.component.d.ts +19 -0
  36. package/lib/safetyPlan/victimSafetyPlan.component.d.ts +54 -0
  37. package/lib/safetyPlan/victimSafetyPlanDetail.component.d.ts +62 -0
  38. package/lib/shared/app.shared.module.d.ts +33 -0
  39. package/lib/shared/validators/date.validator.d.ts +9 -0
  40. package/lib/shared/validators/index.d.ts +1 -0
  41. package/lib/smart-victim-delete-confirm.component.d.ts +12 -0
  42. package/lib/smart-victim-detail/smart-victim-detail.component.d.ts +129 -0
  43. package/lib/smart-victim.component.d.ts +69 -0
  44. package/lib/smart-victim.model.d.ts +211 -0
  45. package/lib/smart-victim.module.d.ts +49 -0
  46. package/lib/smart-victim.service.d.ts +71 -0
  47. package/lib/victim-routing.module.d.ts +7 -0
  48. package/{src/lib/victimSearch/VictimSearchFilter.ts → lib/victimSearch/VictimSearchFilter.d.ts} +7 -9
  49. package/lib/victimSearch/victimSearchForm.component.d.ts +14 -0
  50. package/package.json +21 -6
  51. package/{src/public-api.ts → public-api.d.ts} +7 -12
  52. package/karma.conf.js +0 -32
  53. package/ng-package.json +0 -7
  54. package/src/lib/caseNote/caseNote.component.css +0 -22
  55. package/src/lib/caseNote/caseNote.component.html +0 -188
  56. package/src/lib/caseNote/caseNote.component.ts +0 -265
  57. package/src/lib/common-dialog/common-dialog.component.css +0 -10
  58. package/src/lib/common-dialog/common-dialog.component.html +0 -23
  59. package/src/lib/common-dialog/common-dialog.component.spec.ts +0 -25
  60. package/src/lib/common-dialog/common-dialog.component.ts +0 -21
  61. package/src/lib/common-dialog/common-dialog.module.ts +0 -22
  62. package/src/lib/common-dialog/common-dialog.service.ts +0 -35
  63. package/src/lib/contact/contact.component.css +0 -22
  64. package/src/lib/contact/contact.component.html +0 -124
  65. package/src/lib/contact/contact.component.ts +0 -176
  66. package/src/lib/email-notification.service.ts +0 -42
  67. package/src/lib/email.services.ts +0 -51
  68. package/src/lib/http.service.ts +0 -34
  69. package/src/lib/intake.service.ts +0 -82
  70. package/src/lib/loader.service.ts +0 -11
  71. package/src/lib/safetyPlan/serviceProvider.component.ts +0 -94
  72. package/src/lib/safetyPlan/victimSafetyPlan.component.css +0 -27
  73. package/src/lib/safetyPlan/victimSafetyPlan.component.html +0 -85
  74. package/src/lib/safetyPlan/victimSafetyPlan.component.ts +0 -178
  75. package/src/lib/safetyPlan/victimSafetyPlanDetail.component.html +0 -234
  76. package/src/lib/safetyPlan/victimSafetyPlanDetail.component.ts +0 -492
  77. package/src/lib/shared/app.shared.module.ts +0 -111
  78. package/src/lib/shared/validators/date.validator.ts +0 -73
  79. package/src/lib/shared/validators/index.ts +0 -1
  80. package/src/lib/smart-victim-delete-confirm.component.ts +0 -35
  81. package/src/lib/smart-victim-detail/smart-victim-detail.component.css +0 -43
  82. package/src/lib/smart-victim-detail/smart-victim-detail.component.html +0 -869
  83. package/src/lib/smart-victim-detail/smart-victim-detail.component.spec.ts +0 -25
  84. package/src/lib/smart-victim-detail/smart-victim-detail.component.ts +0 -1387
  85. package/src/lib/smart-victim.component.css +0 -245
  86. package/src/lib/smart-victim.component.html +0 -132
  87. package/src/lib/smart-victim.component.spec.ts +0 -25
  88. package/src/lib/smart-victim.component.ts +0 -333
  89. package/src/lib/smart-victim.model.ts +0 -301
  90. package/src/lib/smart-victim.module.ts +0 -110
  91. package/src/lib/smart-victim.service.spec.ts +0 -12
  92. package/src/lib/smart-victim.service.ts +0 -557
  93. package/src/lib/victim-routing.module.ts +0 -35
  94. package/src/lib/victimSearch/victimSearchForm.component.html +0 -35
  95. package/src/lib/victimSearch/victimSearchForm.component.ts +0 -41
  96. package/src/test.ts +0 -16
  97. package/tsconfig.lib.json +0 -36
  98. package/tsconfig.spec.json +0 -17
  99. package/tslint.json +0 -17
@@ -1,1387 +0,0 @@
1
- import { Component, OnInit, OnChanges, Input, Output, EventEmitter, ViewChild } from '@angular/core';
2
- import { UntypedFormBuilder, UntypedFormGroup, UntypedFormControl,Validators,ValidatorFn } from '@angular/forms';
3
- import { MatRadioChange, MatRadioGroup } from '@angular/material/radio';
4
- import { Victim,VictimDrugUse, Contact, VictimAdvocate,VictimGuardian,VictimWeaponUse,VictimSupport } from '../smart-victim.model';
5
- import { NgcSmartVictimService } from '../smart-victim.service';
6
- import { Router, ActivatedRoute } from '@angular/router';
7
- import { CommonDialogService} from '.././common-dialog/common-dialog.service';
8
- import { DatePipe, formatDate, Location} from '@angular/common';
9
- import { coerceBooleanProperty}from'@angular/cdk/coercion';
10
- import { MatTableDataSource} from '@angular/material/table';
11
- import { AddressValidators, SmartAddressComponent } from '@csmart/ngc-smart-address';
12
- import { MatDialog } from '@angular/material/dialog';
13
- import { MatSnackBar } from '@angular/material/snack-bar';
14
- import { MatInput } from '@angular/material/input';
15
- import { MatSelect } from '@angular/material/select';
16
-
17
- import {
18
- AfterViewInit,
19
- ChangeDetectorRef,
20
- Inject,
21
- } from '@angular/core';
22
-
23
- import {
24
- UntypedFormArray,
25
- AbstractControl,
26
- FormGroupDirective,
27
- NgForm,
28
- } from '@angular/forms';
29
-
30
- import { BehaviorSubject, Observable } from 'rxjs';
31
-
32
- import {
33
- XdmService,
34
- SelectedOffender,
35
- SmartAuthService,
36
- LoginStaff,
37
- SmartAccessControlConfig,
38
- AccessType,
39
- } from '@csmart/ngc-smart-core';
40
-
41
- import { map, withLatestFrom } from 'rxjs/operators';
42
- import { SmartDeleteConfirmComponent } from '@csmart/smart-ui';
43
- import { ErrorStateMatcher } from '@angular/material/core';
44
- import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
45
-
46
-
47
-
48
- export interface BooleanFn {
49
- (): boolean;
50
- }
51
- export interface StringFn {
52
- (): string;
53
- }
54
-
55
- export function conditionalValidator(predicate: BooleanFn,
56
- validator: ValidatorFn,
57
- errorNamespace?: string): ValidatorFn {
58
- return (formControl => {
59
- if (!formControl.parent) {
60
- return null;
61
- }
62
- let error = null;
63
- if (predicate()) {
64
- error = validator(formControl);
65
- }
66
- if (errorNamespace && error) {
67
- const customError = {};
68
- customError[errorNamespace] = error;
69
- error = customError
70
- }
71
- return error;
72
- })
73
- }
74
-
75
-
76
- export function stringConditionalValidator(predicate: StringFn,
77
- validator: ValidatorFn,
78
- errorNamespace?: string): ValidatorFn {
79
- return (formControl => {
80
- if (!formControl.parent) {
81
- return null;
82
- }
83
- let error = null;
84
- if (predicate()=='YS') {
85
- error = validator(formControl);
86
- }
87
- if (errorNamespace && error) {
88
- const customError = {};
89
- customError[errorNamespace] = error;
90
- error = customError
91
- }
92
- return error;
93
- })
94
- }
95
-
96
- @Component({
97
- selector: 'csmart-victim-detail',
98
- templateUrl: './smart-victim-detail.component.html',
99
- styleUrls: ['./smart-victim-detail.component.css'],
100
- providers: [CommonDialogService]
101
- })
102
- export class SmartVictimDetailComponent implements OnInit, OnChanges {
103
- @Input() victimDetail = <Victim>{};
104
- @Input() staffId: number;
105
- @Input() offenderId: number;
106
- @Input() isIntake: boolean;
107
-
108
- @Output() onSave = new EventEmitter();
109
- @Output() onCancel = new EventEmitter();
110
- @ViewChild("addressComponent") addressComponent: SmartAddressComponent;
111
-
112
-
113
- victimId: number;
114
- victimForm: UntypedFormGroup;
115
-
116
- drugs: any;
117
- victimSupportTypes: any;
118
- prefixes: any;
119
- //victim: Victim = <Victim>{};
120
- suffixes: any;
121
- relationshipTypes: any;
122
- genders: any;
123
- docketlist: any;
124
- weaponTypes: any;
125
- flagOption: any;
126
- selectedWeaponTypes: any;
127
- selectedVictimSupportTypes: any;
128
- selectedDrugs: any;
129
- id: any;
130
- hidden: boolean=true;
131
- private sub: any;
132
- victimAdvocate: VictimAdvocate = <VictimAdvocate>{};
133
- victimGuardian: VictimGuardian = <VictimGuardian>{};
134
- victimWeaponUse: VictimWeaponUse;
135
- victimSupport: VictimSupport;
136
- victimDrugUse: VictimDrugUse;
137
- result: any;
138
- editMode: any;
139
- guardianTabFlag: boolean = false;
140
- advocateTabFlag: boolean = false;
141
- commonChildrenDivFlag: boolean = false;
142
- cpoExpirationDivFlag : boolean = false;
143
- supportInPlaceDivFlag: boolean = false;
144
- weaponInvolvedDivFlag: boolean = false;
145
- drugUseDivFlag: boolean = false;
146
- showDelete: boolean = false;
147
- addressId: number = 0;
148
- advocateAddressId: number = 0;
149
- guardianAddressId: number = 0;
150
- datePipe = new DatePipe('en-US');
151
- emailPattern = "^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$";
152
- phoneNumber = "\\d{10}";
153
- editVictim: Victim = <Victim>{};
154
- victimAge: number;
155
- otherWeaponFlag: boolean = false;
156
- otherDrugFlag: boolean = false;
157
-
158
- contactDataSource= new MatTableDataSource();
159
- contactList: Contact[];
160
- guardianPhoneExistFlag: boolean = false;
161
- advocatePhoneExistFlag: boolean = false;
162
- phoneValidationFlag: boolean = false;
163
- guaridanNoPhoneChkFlag: boolean = true;
164
- advocateNoPhoneChkFlag: boolean = true;
165
-
166
- addressValidators: AddressValidators = {
167
- street: [],
168
- street2: [],
169
- city: [],
170
- stateCode: [],
171
- zipCode: [],
172
- psaCode: [],
173
- };
174
- homePhoneControl = new UntypedFormControl();
175
- cellPhoneControl = new UntypedFormControl();
176
- workPhoneControl = new UntypedFormControl();
177
- guardianHomePhoneControl = new UntypedFormControl();
178
- guardianCellPhoneControl = new UntypedFormControl();
179
- guardianWorkPhoneControl = new UntypedFormControl();
180
- advocateHomePhoneControl = new UntypedFormControl();
181
- advocateCellPhoneControl = new UntypedFormControl();
182
- advocateWorkPhoneControl = new UntypedFormControl();
183
- emergencyContactPhoneControl = new UntypedFormControl();
184
-
185
- constructor(
186
- private location: Location,
187
- private formBuilder: UntypedFormBuilder,
188
- private dialog: MatDialog,
189
- private route: ActivatedRoute,
190
- private router: Router,
191
- public snackBar: MatSnackBar,
192
- private commonDialogService: CommonDialogService,
193
- private victimService: NgcSmartVictimService,
194
- private changeDetectorRefs: ChangeDetectorRef,
195
-
196
- ) {
197
- this.initForm();
198
- }
199
-
200
- private initForm() {
201
-
202
- this.victimForm = this.formBuilder.group({
203
- underSupervisionFlag: new UntypedFormControl('', Validators.compose([ Validators.required])),
204
- victimOffenderRelationshipTypeId:new UntypedFormControl('', Validators.compose([ Validators.required])),
205
- lastName: new UntypedFormControl('', Validators.compose([ Validators.required])),
206
- firstName: new UntypedFormControl('', Validators.compose([ Validators.required])),
207
- middleName: new UntypedFormControl('', ),
208
- prefixId: new UntypedFormControl('', ),
209
- suffixId: new UntypedFormControl('', ),
210
- genderCode:new UntypedFormControl('', ),
211
- birthDate: new UntypedFormControl('', ),
212
- homePhone: new UntypedFormControl('', ),
213
- cellPhone: new UntypedFormControl('', ),
214
- workPhone: new UntypedFormControl('', ),
215
- email:new UntypedFormControl('', Validators.compose([Validators.pattern(this.emailPattern) ])),
216
- minorFlag:new UntypedFormControl('', Validators.compose([ Validators.required])),
217
- victimAdvocateFlag: new UntypedFormControl('', Validators.compose([ Validators.required])),
218
- guardianLastName:new UntypedFormControl('', stringConditionalValidator(() => this.victimForm.get('minorFlag').value, Validators.required, 'illuminatiError') ),
219
- guardianFirstName: new UntypedFormControl('', stringConditionalValidator(() => this.victimForm.get('minorFlag').value, Validators.required, 'illuminatiError')),
220
- guardianPrefixId:new UntypedFormControl('', ),
221
- guardianSuffixId: new UntypedFormControl('', ),
222
- //guardianGender:new FormControl('', ),
223
- guardianBirthDate: new UntypedFormControl('', ),
224
- guardianNoPhoneFlag:new UntypedFormControl(true),
225
-
226
- guardianHomePhone:new UntypedFormControl('',),
227
- guardianCellPhone:new UntypedFormControl('',),
228
- guardianWorkPhone:new UntypedFormControl('',),
229
-
230
-
231
- guardianEmail:new UntypedFormControl('', Validators.compose([Validators.pattern(this.emailPattern) ])),
232
- advocateNoPhoneFlag: new UntypedFormControl(true),
233
-
234
-
235
- advocateWorkPhone:new UntypedFormControl('',),
236
- advocateHomePhone:new UntypedFormControl('',),
237
- advocateCellPhone: new UntypedFormControl('',),
238
-
239
-
240
- advocateSuffixId:new UntypedFormControl('', ),
241
- advocatePrefixId: new UntypedFormControl('', ),
242
- advocateFirstName: new UntypedFormControl('', stringConditionalValidator(() => this.victimForm.get('victimAdvocateFlag').value, Validators.required, 'illuminatiError')),
243
- advocateLastName: new UntypedFormControl('', stringConditionalValidator(() => this.victimForm.get('victimAdvocateFlag').value, Validators.required,'illuminatiError')),
244
- advocateEmail: new UntypedFormControl('', Validators.compose([Validators.pattern(this.emailPattern) ])),
245
- emergencyContact: new UntypedFormControl('', ),
246
- emergencyContactPhone:new UntypedFormControl('',),
247
- emergencyChildren: new UntypedFormControl('', ),
248
- emergencyCpo: new UntypedFormControl('', ),
249
- emergencyDrug:new UntypedFormControl('', ),
250
- emergencySupport: new UntypedFormControl('', ),
251
- emergencyWeapon: new UntypedFormControl('', ),
252
- drug: new UntypedFormControl('', ),
253
- weapon: new UntypedFormControl('', ),
254
- support: new UntypedFormControl('', ),
255
- commonChildrenFlag: new UntypedFormControl('', ),
256
- commonChildrenNumber:new UntypedFormControl('', ),
257
- cpoExpirationFlag: new UntypedFormControl('', ),
258
- cpoExpirationDate: new UntypedFormControl('', ),
259
- accessRisk:new UntypedFormControl('', ),
260
- drugUseFlag:new UntypedFormControl('', ),
261
- supportInPlaceFlag: new UntypedFormControl('', ),
262
- weaponInvolvedFlag: new UntypedFormControl('', ),
263
- otherWeapon: new UntypedFormControl('', ),
264
- otherDrug: new UntypedFormControl('', ),
265
- alcoholUseFlag:new UntypedFormControl('', ),
266
- victimSupports:new UntypedFormControl('', ),
267
- victimWeaponUses:new UntypedFormControl('', ),
268
- victimDrugUses:new UntypedFormControl('', ),
269
- allowCsosaContactFlag: new UntypedFormControl('', ),
270
- liveWithOffenderFlag: new UntypedFormControl('', ),
271
-
272
- });
273
-
274
- this.victimForm.markAsPristine();
275
- this.victimForm.markAsUntouched();
276
-
277
- }
278
-
279
- private _getVictim() {
280
- if (this.victimId === 0) {
281
-
282
- return;
283
- };
284
- if (this.editMode == true) {
285
- console.log('find victim id inside getVictim');
286
- console.log(this.victimId);
287
-
288
- if (this.victimId === undefined) {
289
- this.sub = this.route.params.subscribe(params => {
290
- this.victimId = params['victimId'];
291
- console.log('my this.victimId');
292
- console.log(this.victimId);
293
- });
294
- }
295
-
296
- this.victimService.getVictim(this.victimId)
297
- .subscribe((victim: Victim) => {
298
- console.log('victim data 1');
299
- console.log(victim);
300
- this.editVictim = <Victim>victim;
301
-
302
- var supportsData =[];
303
- this.editVictim.victimSupports.forEach( t=>{supportsData.push(t.victimSupportTypeId); } )
304
- const victimSupportsControl = this.victimForm.get('victimSupports');
305
- victimSupportsControl.setValue(supportsData);
306
-
307
- var weaponUsesData =[];
308
- var otherWeapon = "";
309
- this.editVictim.victimWeaponUses.forEach( t=>{
310
- weaponUsesData.push(t.weaponTypeId);
311
- if (t.weaponTypeId == "OTHER"){
312
- otherWeapon = t.otherWeapon;
313
- this.otherWeaponFlag = true;
314
- }
315
-
316
- } )
317
-
318
-
319
- const victimWeaponUsesControl = this.victimForm.get('victimWeaponUses');
320
- victimWeaponUsesControl.setValue(weaponUsesData);
321
-
322
- const otherWeaponControl = this.victimForm.get('otherWeapon');
323
- otherWeaponControl.setValue(otherWeapon);
324
-
325
- var drugUseData =[];
326
- var otherDrug = "";
327
-
328
- console.log('load this.editVictim.victimDrugUses');
329
- console.log(this.editVictim.victimDrugUses);
330
- this.editVictim.victimDrugUses.forEach( t=>{
331
-
332
- if (t.drugTypeId === null){
333
- otherDrug = t.otherDrug;
334
- this.otherDrugFlag = true;
335
- t.drugTypeId ='OTHER';
336
- }
337
- drugUseData.push(t.drugTypeId);
338
-
339
- } )
340
-
341
- console.log('this.editVictim.victimDrugUses after push');
342
- console.log(drugUseData);
343
-
344
-
345
- if (drugUseData){
346
- const victimDrugUsesControl = this.victimForm.get('victimDrugUses');
347
- victimDrugUsesControl.setValue(drugUseData);
348
-
349
- }
350
-
351
- if (otherDrug){
352
- const otherDrugControl = this.victimForm.get('otherDrug');
353
- otherDrugControl.setValue(otherDrug);
354
- }
355
-
356
- //contact
357
- this.victimService.getContacts(this.victimId).subscribe(
358
- contactList => {
359
- console.log('contactList');
360
- console.log(contactList);
361
- this.contactList = contactList;
362
- this.contactDataSource.data = this.contactList;
363
- }
364
- );
365
-
366
- //no phone field
367
-
368
- if ( this.editVictim.guardianNoPhoneFlag === false ){
369
- this.victimForm.patchValue({guardianNoPhoneFlag: false});
370
- }
371
- if ( this.editVictim.advocateNoPhoneFlag === false ){
372
- this.victimForm.patchValue({advocateNoPhoneFlag: false});
373
- }
374
-
375
- this.homePhoneControl.setValue(
376
- !this.editVictim.homePhone ? "" : this.editVictim.homePhone
377
- );
378
-
379
- this.cellPhoneControl.setValue(
380
- !this.editVictim.cellPhone ? "" : this.editVictim.cellPhone
381
- );
382
-
383
- this.workPhoneControl.setValue(
384
- !this.editVictim.workPhone ? "" : this.editVictim.workPhone
385
- );
386
-
387
- this.guardianHomePhoneControl.setValue(
388
- !this.editVictim.guardianHomePhone ? "" : this.editVictim.guardianHomePhone
389
- );
390
-
391
- this.guardianCellPhoneControl.setValue(
392
- !this.editVictim.guardianCellPhone ? "" : this.editVictim.guardianCellPhone
393
- );
394
-
395
- this.guardianWorkPhoneControl.setValue(
396
- !this.editVictim.guardianWorkPhone ? "" : this.editVictim.guardianWorkPhone
397
- );
398
-
399
-
400
- this.advocateHomePhoneControl.setValue(
401
- !this.editVictim.advocateHomePhone ? "" : this.editVictim.advocateHomePhone
402
- );
403
-
404
- this.advocateCellPhoneControl.setValue(
405
- !this.editVictim.advocateCellPhone ? "" : this.editVictim.advocateCellPhone
406
- );
407
-
408
- this.advocateWorkPhoneControl.setValue(
409
- !this.editVictim.advocateWorkPhone ? "" : this.editVictim.advocateWorkPhone
410
- );
411
-
412
- this.emergencyContactPhoneControl .setValue(
413
- !this.editVictim.emergencyContactPhone ? "" : this.editVictim.emergencyContactPhone
414
- );
415
-
416
- }, error => {
417
- this.snackBar.open("Error occured while retriving Victim Information. Please try again.");
418
- });
419
- return;
420
- } else {
421
- //new
422
-
423
- }
424
- }
425
-
426
- ngOnChanges() {
427
-
428
- }
429
-
430
- onClear() {
431
- if (this.addressComponent) this.addressComponent.reset();
432
- }
433
-
434
- showAddress(value){
435
-
436
- if (value.checked){
437
-
438
- this.victimService.getCurrentHousing(this.offenderId).subscribe(
439
- (item: any) => {
440
- this.addressId = item.housing.addressId;
441
- this.victimForm.patchValue({addressId: this.addressId})
442
- })
443
- }
444
- else{
445
- this.addressComponent.reset();
446
- this.editVictim.allowCsosaContactFlag = false;
447
- this.addressId = null;
448
- }
449
-
450
- }
451
-
452
- onAddressChange(addressId) {
453
- this.victimForm.patchValue({addressId: addressId})
454
- this.addressId = addressId;
455
- }
456
- onGuardianAddressChange(MyGuardianAddressId) {
457
- this.victimForm.patchValue({guardianAddressId: MyGuardianAddressId})
458
- this.guardianAddressId = MyGuardianAddressId;
459
- }
460
- onAdvocateAddressChange(MyAdvocateAddressId) {
461
- this.victimForm.patchValue({advocateAddressId: MyAdvocateAddressId})
462
- this.advocateAddressId = MyAdvocateAddressId;
463
- }
464
- cancel() {
465
- this.victimForm.reset();
466
- }
467
- ngOnInit() {
468
- this.homePhoneControl.valueChanges.subscribe((hpn: string) => {
469
- const newValue = hpn.replace(/\D/g, '');
470
- this.editVictim.homePhone= newValue;
471
- });
472
-
473
- this.cellPhoneControl.valueChanges.subscribe((hpn: string) => {
474
- const newValue = hpn.replace(/\D/g, '');
475
- this.editVictim.cellPhone= newValue;
476
- });
477
-
478
-
479
- this.workPhoneControl.valueChanges.subscribe((hpn: string) => {
480
- const newValue = hpn.replace(/\D/g, '');
481
- this.editVictim.workPhone= newValue;
482
- });
483
-
484
-
485
- this.guardianHomePhoneControl.valueChanges.subscribe((hpn: string) => {
486
- const newValue = hpn.replace(/\D/g, '');
487
- this.editVictim.guardianHomePhone= newValue;
488
- });
489
-
490
-
491
- this.guardianCellPhoneControl.valueChanges.subscribe((hpn: string) => {
492
- const newValue = hpn.replace(/\D/g, '');
493
- this.editVictim.guardianCellPhone= newValue;
494
- });
495
-
496
- this.guardianWorkPhoneControl.valueChanges.subscribe((hpn: string) => {
497
- const newValue = hpn.replace(/\D/g, '');
498
- this.editVictim.guardianWorkPhone= newValue;
499
- });
500
-
501
- this.advocateHomePhoneControl.valueChanges.subscribe((hpn: string) => {
502
- const newValue = hpn.replace(/\D/g, '');
503
- this.editVictim.advocateHomePhone= newValue;
504
- });
505
-
506
- this.advocateCellPhoneControl.valueChanges.subscribe((hpn: string) => {
507
- const newValue = hpn.replace(/\D/g, '');
508
- this.editVictim.advocateCellPhone= newValue;
509
- });
510
-
511
- this.advocateWorkPhoneControl.valueChanges.subscribe((hpn: string) => {
512
- const newValue = hpn.replace(/\D/g, '');
513
- this.editVictim.advocateWorkPhone= newValue;
514
- });
515
-
516
- this.emergencyContactPhoneControl .valueChanges.subscribe((hpn: string) => {
517
- const newValue = hpn.replace(/\D/g, '');
518
- this.editVictim.emergencyContactPhone= newValue;
519
- });
520
-
521
- console.log('show offenderId');
522
- console.log(this.offenderId);
523
- console.log('show staffId');
524
- console.log(this.staffId);
525
- console.log('show isIntake');
526
- console.log(this.isIntake);
527
-
528
- //required field
529
- const requiredImplementation = {get:function():boolean{if(this._required){return this._required;}
530
- if(this.ngControl&&this.ngControl.control&&this.ngControl.control.validator
531
- ){const emptyValueControl=Object.assign({},
532
- this.ngControl.control);(emptyValueControl as any).value=null;
533
- return('required'in(this.ngControl.control.validator(emptyValueControl)||{}));}
534
- return false;},set:function(value:boolean){this._required=coerceBooleanProperty(value);},};
535
- Object.defineProperty(MatInput.prototype,'required',requiredImplementation,);
536
- Object.defineProperty(MatSelect.prototype,'required',requiredImplementation,);
537
- Object.defineProperty(MatRadioGroup.prototype,'required',requiredImplementation,);
538
- //required field end
539
-
540
- if (this.victimDetail!=null) {
541
- // edit record
542
- this.editMode = true;
543
- this.showDelete= true;
544
- this.victimId = this.victimDetail.victimId;
545
- this.guardianTabFlag = this.victimDetail.minorFlag;
546
-
547
- if (this.victimDetail.victimAdvocateFlag=='YS'){
548
- this.advocateTabFlag = true;
549
- }
550
-
551
- if (this.otherWeaponFlag == true){
552
- const otherWeaponControl = this.victimForm.get('otherWeapon');
553
- otherWeaponControl.setValidators(Validators.required);
554
- }
555
-
556
- if (this.otherDrugFlag == true){
557
- const otherDrugControl = this.victimForm.get('otherDrug');
558
- otherDrugControl.setValidators(Validators.required);
559
- }
560
-
561
- this.cpoExpirationDivFlag =this.victimDetail.cpoExpirationFlag;
562
- this.commonChildrenDivFlag = this.victimDetail.commonChildrenFlag;
563
- this.supportInPlaceDivFlag= this.victimDetail.supportInPlaceFlag;
564
- this.weaponInvolvedDivFlag= this.victimDetail.weaponInvolvedFlag;
565
- this.drugUseDivFlag= this.victimDetail.drugUseFlag;
566
- this.addressId = this.victimDetail.addressId;
567
- this.guardianAddressId = this.victimDetail.guardianAddressId;
568
- this.advocateAddressId = this.victimDetail.advocateAddressId;
569
- this._getVictim();
570
-
571
- } else {
572
- //add new record
573
- this.victimForm.patchValue({guardianNoPhoneFlag: true});
574
- this.victimForm.patchValue({advocateNoPhoneFlag: true});
575
- }
576
-
577
- this.victimService.getFlagOptionYesNoUnknowns().subscribe(
578
- (items: any) => {
579
- this.flagOption = items;
580
- }
581
- );
582
- this.victimService.getGenders().subscribe(
583
- (items: any) => {
584
- this.genders = items;
585
- }
586
- );
587
- this.victimService.getPrefixes().subscribe(
588
- (items: any) => {
589
- this.prefixes = items;
590
- }
591
- );
592
- this.victimService.getSuffixes().subscribe(
593
- (items: any) => {
594
- this.suffixes = items;
595
- }
596
- );
597
- this.victimService.getRelationshipTypes().subscribe(
598
- (items: any) => {
599
- this.relationshipTypes = items.filter( (y) => ((y.relationshipCategoryId === 'ST' || y.relationshipCategoryId === 'FM' )
600
- && y.relationship !== 'AY'
601
- && y.relationship !== 'VT'
602
- && y.relationship !== 'CME'
603
- && y.relationship !== 'HH'
604
- && y.relationship !== 'NC'
605
- && y.relationship !== 'CL'
606
- && y.relationship !== 'OP'
607
-
608
- ));
609
- }
610
- );
611
- this.victimService.getSupportTypes().subscribe(
612
- (items: any) => {
613
- this.victimSupportTypes = items;
614
- }
615
- );
616
- this.victimService.getWeaponTypes().subscribe(
617
- (items: any) => {
618
- this.weaponTypes = items;
619
- }
620
- );
621
- this.victimService.getDrugsTypes().subscribe(
622
- (items: any) => {
623
- console.log('drug lookup items');
624
- console.log(items);
625
- this.drugs = items;
626
- this.drugs.push({drugTypeId: 'OTHER', name: 'Other'});
627
- console.log(this.drugs);
628
- }
629
- );
630
- // this.victimService.getDocketList(this.offenderId).subscribe(
631
- // (items: any) => {
632
- // this.docketlist = items;
633
- // }
634
- // );
635
-
636
- this.victimForm.get('minorFlag').valueChanges
637
- .subscribe(value => {
638
- this.victimForm.get('guardianFirstName').updateValueAndValidity();
639
- this.victimForm.get('guardianLastName').updateValueAndValidity();
640
- this.victimForm.get('guardianWorkPhone').updateValueAndValidity();
641
- this.victimForm.get('guardianHomePhone').updateValueAndValidity();
642
- this.victimForm.get('guardianCellPhone').updateValueAndValidity();
643
- });
644
-
645
- this.victimForm.get('victimAdvocateFlag').valueChanges
646
- .subscribe(value => {
647
- this.victimForm.get('advocateFirstName').updateValueAndValidity();
648
- this.victimForm.get('advocateLastName').updateValueAndValidity();
649
- this.victimForm.get('advocateWorkPhone').updateValueAndValidity();
650
- this.victimForm.get('advocateHomePhone').updateValueAndValidity();
651
- this.victimForm.get('advocateCellPhone').updateValueAndValidity();
652
- });
653
-
654
- }
655
-
656
- back(){
657
- //this.onSave.emit(this.victimDetail);
658
- this.router.navigate(['victimList']);
659
- }
660
-
661
- deleteVictim() {
662
- this.commonDialogService
663
- .confirm('', 'Do you want to delete this Victim?', 'Yes', 'No')
664
- .subscribe(res => {this.result = res;
665
- if (this.result) {
666
- this.victimService.deleteVictims(this.victimDetail.victimId, this.staffId)
667
- .subscribe(result => {
668
- this.snackBar.open('Delete Successfully!', '', {
669
- duration: 3000, });
670
-
671
-
672
- }
673
- );
674
-
675
- // this.onSave.emit(this.victimDetail);
676
- // this.router.navigate(['victim']);
677
- setTimeout(()=>{
678
- window.location.reload();
679
- },1500);
680
-
681
-
682
- }
683
- });
684
- }
685
-
686
- radioMinorChange($event: MatRadioChange){
687
- if ($event.value === true) {
688
- this.guardianTabFlag = true;
689
- }
690
- else{
691
- this.guardianTabFlag = false;
692
- }
693
-
694
- }
695
-
696
- radioAdvocateChange($event: MatRadioChange){
697
-
698
- const advocateLastNameControl = this.victimForm.get('advocateLastName');
699
- const advocateFirstNameControl = this.victimForm.get('advocateFirstName');
700
-
701
- if ($event.value === "YS") {
702
- this.advocateTabFlag = true;
703
- advocateLastNameControl.setValidators(Validators.required);
704
- advocateFirstNameControl.setValidators(Validators.required);
705
- }
706
- else{
707
- this.advocateTabFlag = false;
708
- advocateLastNameControl.clearValidators();
709
- advocateFirstNameControl.clearValidators();
710
- }
711
- advocateLastNameControl.updateValueAndValidity();
712
- advocateFirstNameControl.updateValueAndValidity();
713
-
714
- }
715
-
716
- radioCicChange($event: MatRadioChange){
717
- if ($event.value === true) {
718
- this.commonChildrenDivFlag = true;
719
- // requrie field
720
- this.setValidators('commonChildren');
721
- }
722
- else{
723
- this.commonChildrenDivFlag = false;
724
- }
725
- }
726
-
727
- setValidators(type) {
728
- if(type == 'commonChildren'){
729
- this.victimForm.get('commonChildrenNumber').clearValidators();
730
- this.victimForm.get('commonChildrenNumber').setValidators(Validators.required);
731
- }
732
- else if (type == 'cpo'){
733
- this.victimForm.get('cpoExpirationDate').clearValidators();
734
- this.victimForm.get('cpoExpirationDate').setValidators(Validators.required);
735
-
736
- }
737
- }
738
- radioSupportChange($event: MatRadioChange){
739
- if ($event.value === true) {
740
- this.supportInPlaceDivFlag = true;
741
- }
742
- else{
743
- this.supportInPlaceDivFlag = false;
744
- }
745
- }
746
- radioWeaponChange($event: MatRadioChange){
747
- if ($event.value === true) {
748
- this.weaponInvolvedDivFlag = true;
749
- }
750
- else{
751
- this.weaponInvolvedDivFlag = false;
752
- }
753
- }
754
- radioDrugChange($event: MatRadioChange){
755
- if ($event.value === true) {
756
- this.drugUseDivFlag = true;
757
- }
758
- else{
759
- this.drugUseDivFlag = false;
760
- }
761
- }
762
-
763
- radioCpoChange($event: MatRadioChange){
764
- if ($event.value === true) {
765
- this.cpoExpirationDivFlag = true;
766
- this.setValidators('cpo');
767
- }
768
- else{
769
- this.cpoExpirationDivFlag = false;
770
- }
771
- }
772
-
773
- handleDOBChange($event ){
774
- var ageDifMs = Date.now() - $event.value;
775
- var ageDate = new Date(ageDifMs);
776
- if( Math.abs(ageDate.getUTCFullYear() - 1970) <= 18){
777
-
778
- this.snackBar.open('Victim is a Minor. This information is a sensitive and should not be disclosed to any unauthorized parties. Contact the legal guardian.', '', {
779
- duration: 6000,});
780
- const minorControl = this.victimForm.get('minorFlag');
781
- minorControl.setValue(true);
782
- this.guardianTabFlag = true;
783
- }
784
-
785
- }
786
- checkOtherWeapon(WeaponUse){
787
-
788
- const otherWeaponControl = this.victimForm.get('otherWeapon');
789
- if (WeaponUse.includes("OTHER")){
790
- this.otherWeaponFlag = true;
791
- otherWeaponControl.setValidators(Validators.required)
792
-
793
- }else{
794
- this.otherWeaponFlag = false;
795
- otherWeaponControl.clearValidators();
796
- }
797
- otherWeaponControl.updateValueAndValidity();
798
- }
799
-
800
- checkOtherDrug(DrugUse){
801
-
802
- const otherDrugControl = this.victimForm.get('otherDrug');
803
- if (DrugUse.includes("OTHER")){
804
- this.otherDrugFlag = true;
805
- otherDrugControl.setValidators(Validators.required)
806
-
807
-
808
- }else{
809
- this.otherDrugFlag = false;
810
- otherDrugControl.clearValidators();
811
-
812
-
813
- }
814
- otherDrugControl.updateValueAndValidity();
815
- }
816
-
817
- //#region "save victim"
818
- saveVictim() {
819
-
820
- //guardian phone logic
821
- if (!this.victimForm.value.guardianNoPhoneFlag)
822
- {
823
- if (this.guardianHomePhoneControl.value){
824
- if (this.guardianHomePhoneControl.value !== null){
825
- if (this.guardianHomePhoneControl.value !== ""){
826
- this.guardianPhoneExistFlag = true;
827
- }
828
- }
829
- }
830
-
831
-
832
-
833
- if (this.guardianWorkPhoneControl.value !== undefined){
834
- if (this.guardianWorkPhoneControl.value !== null){
835
- if (this.guardianWorkPhoneControl.value !== ""){
836
- this.guardianPhoneExistFlag = true;
837
- }
838
- }
839
- }
840
-
841
-
842
- if (this.guardianCellPhoneControl.value){
843
- if (this.guardianCellPhoneControl.value!== null){
844
- if (this.guardianCellPhoneControl.value !== ""){
845
- this.guardianPhoneExistFlag = true;
846
- }
847
- }
848
- }
849
-
850
- }
851
-
852
- console.log('this.victimForm.value.guardianNoPhoneFlag');
853
- console.log(this.victimForm.value.guardianNoPhoneFlag);
854
- console.log('this.guardianPhoneExistFlag');
855
- console.log(this.guardianPhoneExistFlag);
856
-
857
-
858
- if (this.guardianPhoneExistFlag === false && this.victimForm.value.guardianNoPhoneFlag === false)
859
- {
860
- this.phoneValidationFlag = true;
861
- this.commonDialogService
862
- .warning('', 'Please check the guardian phone field. You have to fill one of the three phone fileds.', 'Ok')
863
- .subscribe(res => {this.result = res;
864
-
865
- });
866
- }
867
- console.log('this.phoneValidationFlag');
868
- console.log(this.phoneValidationFlag);
869
-
870
- //advocate phone logic
871
- if (!this.victimForm.value.advocateNoPhoneFlag)
872
- {
873
- if (this.advocateHomePhoneControl.value){
874
- if (this.advocateHomePhoneControl.value !== null){
875
- if (this.advocateHomePhoneControl.value !== ""){
876
- this.advocatePhoneExistFlag = true;
877
- }
878
- }
879
- }
880
-
881
-
882
-
883
- if (this.advocateWorkPhoneControl.value !== undefined){
884
- if (this.advocateWorkPhoneControl.value !== null){
885
- if (this.advocateWorkPhoneControl.value !== ""){
886
- this.advocatePhoneExistFlag = true;
887
- }
888
- }
889
- }
890
-
891
-
892
- if (this.advocateCellPhoneControl.value){
893
- if (this.advocateCellPhoneControl.value !== null){
894
- if (this.advocateCellPhoneControl.value !== ""){
895
- this.advocatePhoneExistFlag = true;
896
- }
897
- }
898
- }
899
-
900
- }
901
-
902
- console.log('this.victimForm.value.advocateNoPhoneFlag');
903
- console.log(this.victimForm.value.advocateNoPhoneFlag);
904
- console.log('this.advocatePhoneExistFlag');
905
- console.log(this.advocatePhoneExistFlag);
906
-
907
- if(this.advocatePhoneExistFlag === false && this.victimForm.value.advocateNoPhoneFlag === false)
908
- {
909
-
910
- this.phoneValidationFlag = true;
911
- this.commonDialogService
912
- .warning('', 'Please check the advocate phone field. You have to fill one of the three phone fileds.', 'Ok')
913
- .subscribe(res => {this.result = res;
914
-
915
- });
916
- }
917
-
918
-
919
- if (this.homePhoneControl.value){
920
- this.victimForm.value.homePhone = this.homePhoneControl.value.replace(/[()\s-]/g, '');
921
- }
922
- else{
923
- this.victimForm.value.homePhone = null;
924
- }
925
-
926
- if (this.cellPhoneControl.value){
927
- this.victimForm.value.cellPhone = this.cellPhoneControl.value.replace(/[()\s-]/g, '') ;
928
- }
929
- else{
930
- this.victimForm.value.cellPhone = null;
931
- }
932
-
933
- if (this.workPhoneControl.value){
934
- this.victimForm.value.workPhone = this.workPhoneControl.value.replace(/[()\s-]/g, '');
935
- }
936
- else{
937
- this.victimForm.value.workPhone= null;
938
- }
939
-
940
- if (this.guardianHomePhoneControl.value){
941
- this.victimForm.value.guardianHomePhone = this.guardianHomePhoneControl.value.replace(/[()\s-]/g, '');
942
- }
943
- else{
944
- this.victimForm.value.guardianHomePhone = null;
945
- }
946
-
947
- if (this.guardianCellPhoneControl.value){
948
- this.victimForm.value.guardianCellPhone = this.guardianCellPhoneControl.value.replace(/[()\s-]/g, '');
949
- }
950
- else{
951
- this.victimForm.value.guardianCellPhone = null;
952
- }
953
-
954
- if (this.guardianWorkPhoneControl.value){
955
- this.victimForm.value.guardianWorkPhone = this.guardianWorkPhoneControl.value.replace(/[()\s-]/g, '');
956
- }
957
- else{
958
- this.victimForm.value.guardianWorkPhone = null;
959
- }
960
-
961
-
962
- if (this.advocateHomePhoneControl.value){
963
- this.victimForm.value.advocateHomePhone = this.advocateHomePhoneControl.value.replace(/[()\s-]/g, '')
964
- }
965
- else{
966
- this.victimForm.value.advocateHomePhone = null;
967
- }
968
-
969
- if (this.advocateCellPhoneControl.value){
970
- this.victimForm.value.advocateCellPhone = this.advocateCellPhoneControl.value.replace(/[()\s-]/g, '')
971
- }
972
- else{
973
- this.victimForm.value.advocateCellPhone = null;
974
- }
975
-
976
- if (this.advocateWorkPhoneControl.value){
977
- this.victimForm.value.advocateWorkPhone = this.advocateWorkPhoneControl.value.replace(/[()\s-]/g, '')
978
- }
979
- else{
980
- this.victimForm.value.advocateWorkPhone = null;
981
- }
982
-
983
-
984
- if (this.emergencyContactPhoneControl.value){
985
- this.victimForm.value.emergencyContactPhone = this.emergencyContactPhoneControl.value.replace(/[()\s-]/g, '')
986
- }else{
987
- this.victimForm.value.emergencyContactPhone = null;
988
- }
989
- //data process
990
-
991
- console.log('this.phoneValidationFlag 1');
992
- console.log(this.phoneValidationFlag);
993
- if ( this.phoneValidationFlag === false){
994
- if (this.victimDetail === null){
995
- //insert new victim
996
-
997
- var myVictimSupports = [];
998
- if (this.victimForm.value.victimSupports){
999
- this.victimForm.value.victimSupports.forEach(element => {
1000
- const victimSupport= <VictimSupport>{};
1001
- victimSupport.victimId= this.victimForm.value.victimId;
1002
- victimSupport.victimSupportTypeId= element;
1003
- victimSupport.modifiedBy= this.staffId;
1004
- myVictimSupports.push(victimSupport);
1005
- });
1006
- }
1007
-
1008
- var myVictimDrugUses = [];
1009
- console.log('this.victimForm.value.victimDrugUses during save');
1010
- console.log(this.victimForm.value.victimDrugUses);
1011
- if (this.victimForm.value.victimDrugUses){
1012
- this.victimForm.value.victimDrugUses.forEach(element => {
1013
- const victimDrugUse = <VictimDrugUse>{};
1014
- victimDrugUse.drugTypeId = element;
1015
-
1016
- if (element ==="OTHER" || element === "" || element === null){
1017
- victimDrugUse.drugTypeId = null;
1018
- victimDrugUse.otherDrug = this.victimForm.value.otherDrug;
1019
- }
1020
- else{
1021
- victimDrugUse.drugTypeId = element;
1022
- victimDrugUse.otherDrug = null;
1023
- }
1024
-
1025
- victimDrugUse.modifiedBy = this.staffId;
1026
- victimDrugUse.victimId = this.victimForm.value.victimId;
1027
- myVictimDrugUses.push(victimDrugUse);
1028
- });
1029
- }
1030
-
1031
- console.log('this.victimForm.value.victimDrugUses during save 1');
1032
- console.log(this.victimForm.value.victimDrugUses);
1033
-
1034
- var myVictimWeaponUses = [];
1035
-
1036
- if (this.victimForm.value.victimWeaponUses){
1037
- this.victimForm.value.victimWeaponUses.forEach(element => {
1038
- const victimWeaponUse = <VictimWeaponUse>{};
1039
- victimWeaponUse.victimId= this.victimForm.value.victimId;
1040
- victimWeaponUse.weaponTypeId= element;
1041
-
1042
- if (element =="OTHER"){
1043
- victimWeaponUse.otherWeapon = this.victimForm.value.otherWeapon;
1044
- }
1045
- else{
1046
- victimWeaponUse.otherWeapon = null;
1047
- }
1048
- victimWeaponUse.modifiedBy= this.staffId;
1049
- myVictimWeaponUses.push(victimWeaponUse);
1050
- });
1051
- }
1052
-
1053
- const newVictim = {
1054
- victimId: 0,
1055
- offenderId: this.offenderId,
1056
- victimOffenderRelationshipTypeId:
1057
- this.victimForm.value.victimOffenderRelationshipTypeId,
1058
- lastName: this.victimForm.value.lastName,
1059
- firstName: this.victimForm.value.firstName,
1060
- middleName: this.victimForm.value.middleName
1061
- ? this.victimForm.value.middleName
1062
- : null,
1063
- prefixId: this.victimForm.value.prefixId
1064
- ? this.victimForm.value.prefixId
1065
- : null,
1066
- suffixId: this.victimForm.value.suffixId
1067
- ? this.victimForm.value.suffixId
1068
- : null,
1069
- birthDate: this.victimForm.value.birthDate
1070
- ? this.victimForm.value.birthDate
1071
- : null,
1072
- genderCode: this.victimForm.value.genderCode
1073
- ? this.victimForm.value.genderCode
1074
- : null,
1075
- underSupervisionFlag: this.victimForm.value.underSupervisionFlag,
1076
- minorFlag: this.victimForm.value.minorFlag,
1077
- victimAdvocateFlag: this.victimForm.value.victimAdvocateFlag,
1078
-
1079
- homePhone: this.victimForm.value.homePhone,
1080
- workPhone: this.victimForm.value.workPhone,
1081
- cellPhone: this.victimForm.value.cellPhone,
1082
- email: this.victimForm.value.email ? this.victimForm.value.email : null,
1083
- addressId: this.victimForm.value.addressId
1084
- ? this.victimForm.value.addressId
1085
- : 1,
1086
- emergencyContact: this.victimForm.value.emergencyContact
1087
- ? this.victimForm.value.emergencyContact
1088
- : null,
1089
- emergencyContactPhone: this.victimForm.value.emergencyContactPhone,
1090
- commonChildrenFlag: this.victimForm.value.commonChildrenFlag,
1091
- commonChildrenNumber: this.victimForm.value.commonChildrenNumber,
1092
- cpoExpirationFlag: this.victimForm.value.cpoExpirationFlag,
1093
- cpoExpirationDate: this.victimForm.value.cpoExpirationDate
1094
- ? this.datePipe.transform(this.victimForm.value.cpoExpirationDate, "short")
1095
- : null,
1096
- supportInPlaceFlag: this.victimForm.value.supportInPlaceFlag,
1097
- weaponInvolvedFlag: this.victimForm.value.weaponInvolvedFlag,
1098
- drugUseFlag: this.victimForm.value.drugUseFlag,
1099
- alcoholUseFlag: this.victimForm.value.alcoholUseFlag,
1100
- accessRisk: this.victimForm.value.accessRisk,
1101
- modifiedBy: this.staffId,
1102
- vVictimAdvocate: null,
1103
- vVictimGuardian: null,
1104
- victimDrugUses: myVictimDrugUses,
1105
- victimSupports: myVictimSupports,
1106
- victimWeaponUses: myVictimWeaponUses,
1107
-
1108
- advocateFirstName: null,
1109
- advocateLastName: null,
1110
- advocateEmail: null,
1111
- advocatePrefixId: null,
1112
- advocateSuffixId: null,
1113
- advocateNoPhoneFlag: null,
1114
- advocateHomePhone: null,
1115
- advocateWorkPhone: null,
1116
- advocateCellPhone: null,
1117
- advocateAddressId: null,
1118
- guardianFirstName: null,
1119
- guardianLastName: null,
1120
- guardianEmail: null,
1121
- guardianPrefixId: null,
1122
- guardianSuffixId: null,
1123
- guardianNoPhoneFlag: null,
1124
- guardianHomePhone: null,
1125
- guardianWorkPhone: null,
1126
- guardianCellPhone: null,
1127
- guardianAddressId: null,
1128
- guardianBirthDate: null,
1129
- relationship: null,
1130
- //relationship: this.victimForm.value.victimOffenderRelationshipTypeId? this.victimForm.value.victimOffenderRelationshipTypeId : null,
1131
- allowCsosaContactFlag: this.victimForm.value.allowCsosaContactFlag
1132
- ? this.victimForm.value.allowCsosaContactFlag
1133
- : null,
1134
- liveWithOffenderFlag: this.victimForm.value.liveWithOffenderFlag
1135
- ? this.victimForm.value.liveWithOffenderFlag
1136
- : null,
1137
- };
1138
-
1139
- if (this.addressId == 0){
1140
- newVictim.addressId = null;
1141
- } else {
1142
- newVictim.addressId = this.addressId;
1143
- }
1144
-
1145
- newVictim.advocateAddressId = this.advocateAddressId;
1146
- newVictim.guardianAddressId = this.guardianAddressId;
1147
-
1148
-
1149
- console.log('newVictim');
1150
- console.log(newVictim);
1151
- this.victimService.postVictims(newVictim).subscribe(
1152
- (items: any) => {
1153
-
1154
- const id = items ? items.victimId : '';
1155
-
1156
- if (this.victimForm.value.victimAdvocateFlag == "YS"){
1157
-
1158
- console.log('add advocate');
1159
- const victimAdvocate: VictimAdvocate = {
1160
- victimAdvocateId: id,
1161
- lastName: this.victimForm.value.advocateLastName,
1162
- firstName: this.victimForm.value.advocateFirstName,
1163
- prefixId: this.victimForm.value.advocatePrefixId,
1164
- suffixId: this.victimForm.value.advocateSuffixId,
1165
- addressId: this.advocateAddressId ? this.advocateAddressId: null,
1166
- noPhoneFlag: this.victimForm.value.advocateNoPhoneFlag ? this.victimForm.value.advocateNoPhoneFlag: null,
1167
- homePhone: this.victimForm.value.advocateHomePhone,
1168
- workPhone: this.victimForm.value.advocateWorkPhone,
1169
- cellPhone: this.victimForm.value.advocateCellPhone,
1170
- email: this.victimForm.value.advocateEmail,
1171
- modifiedBy: this.staffId
1172
- };
1173
-
1174
- this.victimService.postVictimAdvocate(id, victimAdvocate).subscribe();
1175
- }
1176
-
1177
- if (this.victimForm.value.minorFlag == true){
1178
- const victimGuardian: VictimGuardian = {
1179
- victimGuardianId: id,
1180
- lastName: this.victimForm.value.guardianLastName,
1181
- firstName: this.victimForm.value.guardianFirstName,
1182
- prefixId: this.victimForm.value.guardianPrefixId,
1183
- suffixId: this.victimForm.value.guardianSuffixId,
1184
- birthDate: this.victimForm.value.guardianBirthDate,
1185
- addressId: this.guardianAddressId? this.guardianAddressId: null,
1186
- noPhoneFlag: this.victimForm.value.guardianNoPhoneFlag? this.victimForm.value.guardianNoPhoneFlag: null,
1187
- homePhone: this.victimForm.value.guardianHomePhone,
1188
- workPhone: this.victimForm.value.guardianWorkPhone,
1189
- cellPhone: this.victimForm.value.guardianCellPhone,
1190
- email: this.victimForm.value.guardianEmail,
1191
- modifiedBy: this.staffId
1192
- };
1193
- this.victimService.postVictimGuardian(id, victimGuardian).subscribe();
1194
- }
1195
-
1196
- this.snackBar.open('Add Victim Successfully!', '', {
1197
- duration: 3000,
1198
- });
1199
- //insert new
1200
- if (this.isIntake===true){
1201
- this.router.navigate(['victimHome']);
1202
- }
1203
- else
1204
- {
1205
- this.router.navigate(['victimList']);
1206
- }
1207
- //this.onSave.emit(this.victimDetail);
1208
-
1209
- }
1210
- );
1211
-
1212
- }
1213
- else {
1214
- //update victim
1215
- this.victimDetail.underSupervisionFlag = this.victimForm.value.underSupervisionFlag;
1216
- this.victimDetail.victimOffenderRelationshipTypeId = this.victimForm.value.victimOffenderRelationshipTypeId;
1217
- this.victimDetail.lastName = this.victimForm.value.lastName;
1218
- this.victimDetail.firstName = this.victimForm.value.firstName;
1219
- this.victimDetail.middleName = this.victimForm.value.middleName;
1220
- this.victimDetail.prefixId = this.victimForm.value.prefixId ? this.victimForm.value.prefixId : null;
1221
- this.victimDetail.suffixId = this.victimForm.value.suffixId ? this.victimForm.value.suffixId : null;
1222
- this.victimDetail.birthDate = this.victimForm.value.birthDate;
1223
- this.victimDetail.genderCode = this.victimForm.value.genderCode;
1224
- this.victimDetail.minorFlag = this.victimForm.value.minorFlag;
1225
- this.victimDetail.homePhone = this.victimForm.value.homePhone;
1226
- this.victimDetail.workPhone = this.victimForm.value.workPhone;
1227
- this.victimDetail.cellPhone = this.victimForm.value.cellPhone;
1228
- this.victimDetail.email = this.victimForm.value.email;
1229
- this.victimDetail.victimAdvocateFlag = this.victimForm.value.victimAdvocateFlag;
1230
- this.victimDetail.emergencyContact = this.victimForm.value.emergencyContact;
1231
- this.victimDetail.emergencyContactPhone = this.victimForm.value.emergencyContactPhone;
1232
- this.victimDetail.commonChildrenFlag = this.victimForm.value.commonChildrenFlag;
1233
- this.victimDetail.commonChildrenNumber = this.victimForm.value.commonChildrenNumber;
1234
- this.victimDetail.cpoExpirationDate = this.victimForm.value.cpoExpirationDate;
1235
- this.victimDetail.cpoExpirationFlag = this.victimForm.value.cpoExpirationFlag;
1236
- this.victimDetail.supportInPlaceFlag = this.victimForm.value.supportInPlaceFlag;
1237
- this.victimDetail.weaponInvolvedFlag = this.victimForm.value.weaponInvolvedFlag;
1238
- this.victimDetail.drugUseFlag = this.victimForm.value.drugUseFlag;
1239
- this.victimDetail.alcoholUseFlag = this.victimForm.value.alcoholUseFlag;
1240
- this.victimDetail.accessRisk = this.victimForm.value.accessRisk;
1241
- this.victimDetail.addressId = this.addressId;
1242
- this.victimDetail.allowCsosaContactFlag = this.victimForm.value.allowCsosaContactFlag;
1243
- this.victimDetail.liveWithOffenderFlag = this.victimForm.value.liveWithOffenderFlag;
1244
-
1245
- this.victimDetail.victimSupports = [];
1246
- this.victimForm.value.victimSupports.forEach(element => {
1247
- const victimSupport= <VictimSupport>{};
1248
- victimSupport.victimId= this.victimDetail.victimId;
1249
- victimSupport.victimSupportTypeId= element;
1250
- victimSupport.modifiedBy= this.staffId;
1251
- this.victimDetail.victimSupports.push(victimSupport);
1252
- });
1253
-
1254
- this.victimDetail.victimDrugUses = [];
1255
-
1256
- this.victimForm.value.victimDrugUses.forEach(element => {
1257
- const victimDrugUse = <VictimDrugUse>{};
1258
- victimDrugUse.drugTypeId = element;
1259
- console.log('this.victimForm.value.victimDrugUses before')
1260
- console.log(this.victimForm.value.victimDrugUses)
1261
-
1262
- if (element === "OTHER" || element === "" ){
1263
- victimDrugUse.drugTypeId = null;
1264
- victimDrugUse.otherDrug = this.victimForm.value.otherDrug;
1265
- }
1266
- else{
1267
- victimDrugUse.drugTypeId = element;
1268
- victimDrugUse.otherDrug = null;
1269
- }
1270
-
1271
- victimDrugUse.modifiedBy = this.staffId;
1272
- victimDrugUse.victimId = this.victimDetail.victimId;
1273
- this.victimDetail.victimDrugUses.push(victimDrugUse);
1274
-
1275
- });
1276
- this.victimForm.value.victimDrugUses.filter(word => ( !(word.drugTypeId === null && word.otherDrug === null) ));
1277
-
1278
- this.victimDetail.victimWeaponUses = [];
1279
- this.victimForm.value.victimWeaponUses.forEach(element => {
1280
- const victimWeaponUse = <VictimWeaponUse>{};
1281
- victimWeaponUse.victimId= this.victimDetail.victimId;
1282
- victimWeaponUse.weaponTypeId= element;
1283
-
1284
- if (element =="OTHER"){
1285
- victimWeaponUse.otherWeapon=this.victimForm.value.otherWeapon;
1286
- }
1287
- else{
1288
- victimWeaponUse.otherWeapon = null;
1289
- }
1290
-
1291
- victimWeaponUse.modifiedBy= this.staffId;
1292
- this.victimDetail.victimWeaponUses.push(victimWeaponUse);
1293
-
1294
- });
1295
-
1296
- console.log('this.victimDetail before emit');
1297
- console.log(this.victimDetail);
1298
-
1299
-
1300
- this.victimService.putVictims(this.victimDetail.victimId,this.victimDetail).subscribe(
1301
- (items: any) => {
1302
- this.snackBar.open('Update Successfully!', '', {
1303
- duration: 3000,
1304
- });
1305
- //Advocate section
1306
- this.victimAdvocate.victimAdvocateId = this.victimDetail.victimId;
1307
- this.victimAdvocate.lastName= this.victimForm.value.advocateLastName;
1308
- this.victimAdvocate.firstName= this.victimForm.value.advocateFirstName;
1309
- this.victimAdvocate.prefixId= this.victimForm.value.advocatePrefixId ? this.victimForm.value.advocatePrefixId : null;
1310
- this.victimAdvocate.suffixId= this.victimForm.value.advocateSuffixId ? this.victimForm.value.advocateSuffixId : null;
1311
- this.victimAdvocate.addressId= this.advocateAddressId ? this.advocateAddressId : null;
1312
- this.victimAdvocate.noPhoneFlag= this.victimForm.value.advocateNoPhoneFlag? true: false;
1313
- this.victimAdvocate.homePhone= this.victimForm.value.advocateHomePhone;
1314
- this.victimAdvocate.workPhone= this.victimForm.value.advocateWorkPhone;
1315
- this.victimAdvocate.cellPhone= this.victimForm.value.advocateCellPhone;
1316
- this.victimAdvocate.email= this.victimForm.value.advocateEmail ? this.victimForm.value.advocateEmail : null;
1317
- this.victimAdvocate.modifiedBy= this.staffId;
1318
-
1319
- console.log('work on advocate part');
1320
- if (this.victimDetail.victimAdvocateFlag=='YS')
1321
- {
1322
- console.log('work on advocate flag is YS ');
1323
- if(this.victimDetail.advocateFirstName != null){
1324
- console.log('check advocate fisrt name ');
1325
- console.log(this.victimDetail.advocateFirstName);
1326
- this.victimService.putVictimAdvocate(this.victimDetail.victimId,this.victimAdvocate).subscribe(
1327
- resp=>{} );
1328
- }
1329
- else
1330
- {
1331
- console.log('add advocate');
1332
- console.log(this.victimAdvocate);
1333
- this.victimService.postVictimAdvocate(this.victimDetail.victimId, this.victimAdvocate).subscribe();
1334
- }
1335
- }
1336
-
1337
- // guardian section
1338
- this.victimGuardian.victimGuardianId = this.victimDetail.victimId;
1339
- this.victimGuardian.lastName = this.victimForm.value.guardianLastName;
1340
- this.victimGuardian.firstName = this.victimForm.value.guardianFirstName;
1341
- this.victimGuardian.prefixId = this.victimForm.value.guardianPrefixId ? this.victimForm.value.guardianPrefixId : null;
1342
- this.victimGuardian.suffixId = this.victimForm.value.guardianSuffixId ? this.victimForm.value.guardianSuffixId : null;
1343
- this.victimGuardian.addressId = this.guardianAddressId ? this.guardianAddressId : null;
1344
- this.victimGuardian.noPhoneFlag = this.victimForm.value.guardianNoPhoneFlag? true: false;
1345
- this.victimGuardian.homePhone = this.victimForm.value.guardianHomePhone;
1346
- this.victimGuardian.workPhone = this.victimForm.value.guardianWorkPhone;
1347
- this.victimGuardian.cellPhone = this.victimForm.value.guardianCellPhone;
1348
- this.victimGuardian.email = this.victimForm.value.guardianEmail ? this.victimForm.value.guardianEmail : null;
1349
- this.victimGuardian.modifiedBy = this.staffId;
1350
-
1351
- if (this.victimDetail.minorFlag == true)
1352
- {
1353
- if(this.victimDetail.guardianFirstName != null )
1354
- this.victimService.putVictimGuardian(this.victimDetail.victimId,this.victimGuardian).subscribe(
1355
- resp=>{
1356
- }
1357
- );
1358
- else
1359
- {
1360
- console.log('add gurdian');
1361
- console.log(this.victimGuardian);
1362
- this.victimService.postVictimGuardian(this.victimDetail.victimId, this.victimGuardian).subscribe();
1363
- }
1364
-
1365
- }
1366
- }
1367
-
1368
- );
1369
-
1370
- }
1371
- }//end of this.phoneValidationFlag = false
1372
-
1373
- console.log('this.victimDetail');
1374
- console.log(this.victimDetail);
1375
- this.onSave.emit(this.victimDetail);
1376
- }
1377
-
1378
- //#endregion "save victim"
1379
- addContact(){
1380
- this.router.navigate(['victimContact',this.victimId]);
1381
- }
1382
- formatLabel(value: number) {
1383
- return value;
1384
- }
1385
-
1386
-
1387
- }