@csmart/ngc-smart-victim 1.18.12 → 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 -876
  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 -1469
  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 -311
  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 -576
  93. package/src/lib/victim-routing.module.ts +0 -36
  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,1469 +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,VictimRelationship } 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
- victimRelationships: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
-
308
- var relationshipsData =[];
309
- this.editVictim.victimRelationships.forEach( t=>{relationshipsData.push(t.victimRelationshipTypeId); } )
310
- const victimOffenderRelationshipControl = this.victimForm.get('victimRelations');
311
- victimOffenderRelationshipControl.setValue(relationshipsData);
312
-
313
-
314
- var weaponUsesData =[];
315
- var otherWeapon = "";
316
- this.editVictim.victimWeaponUses.forEach( t=>{
317
- weaponUsesData.push(t.weaponTypeId);
318
- if (t.weaponTypeId == "OTHER"){
319
- otherWeapon = t.otherWeapon;
320
- this.otherWeaponFlag = true;
321
- }
322
-
323
- } )
324
-
325
-
326
- const victimWeaponUsesControl = this.victimForm.get('victimWeaponUses');
327
- victimWeaponUsesControl.setValue(weaponUsesData);
328
-
329
- const otherWeaponControl = this.victimForm.get('otherWeapon');
330
- otherWeaponControl.setValue(otherWeapon);
331
-
332
- var drugUseData =[];
333
- var otherDrug = "";
334
-
335
- console.log('load this.editVictim.victimDrugUses');
336
- console.log(this.editVictim.victimDrugUses);
337
- this.editVictim.victimDrugUses.forEach( t=>{
338
-
339
- if (t.drugTypeId === null){
340
- otherDrug = t.otherDrug;
341
- this.otherDrugFlag = true;
342
- t.drugTypeId ='OTHER';
343
- }
344
- drugUseData.push(t.drugTypeId);
345
-
346
- } )
347
-
348
- console.log('this.editVictim.victimDrugUses after push');
349
- console.log(drugUseData);
350
-
351
-
352
- if (drugUseData){
353
- const victimDrugUsesControl = this.victimForm.get('victimDrugUses');
354
- victimDrugUsesControl.setValue(drugUseData);
355
-
356
- }
357
-
358
- if (otherDrug){
359
- const otherDrugControl = this.victimForm.get('otherDrug');
360
- otherDrugControl.setValue(otherDrug);
361
- }
362
-
363
- //contact
364
- this.victimService.getContacts(this.victimId).subscribe(
365
- contactList => {
366
- console.log('contactList');
367
- console.log(contactList);
368
- this.contactList = contactList;
369
- this.contactDataSource.data = this.contactList;
370
- }
371
- );
372
-
373
- //no phone field
374
-
375
- if ( this.editVictim.guardianNoPhoneFlag === false ){
376
- this.victimForm.patchValue({guardianNoPhoneFlag: false});
377
- }
378
- if ( this.editVictim.advocateNoPhoneFlag === false ){
379
- this.victimForm.patchValue({advocateNoPhoneFlag: false});
380
- }
381
-
382
- this.homePhoneControl.setValue(
383
- !this.editVictim.homePhone ? "" : this.editVictim.homePhone
384
- );
385
-
386
- this.cellPhoneControl.setValue(
387
- !this.editVictim.cellPhone ? "" : this.editVictim.cellPhone
388
- );
389
-
390
- this.workPhoneControl.setValue(
391
- !this.editVictim.workPhone ? "" : this.editVictim.workPhone
392
- );
393
-
394
- this.guardianHomePhoneControl.setValue(
395
- !this.editVictim.guardianHomePhone ? "" : this.editVictim.guardianHomePhone
396
- );
397
-
398
- this.guardianCellPhoneControl.setValue(
399
- !this.editVictim.guardianCellPhone ? "" : this.editVictim.guardianCellPhone
400
- );
401
-
402
- this.guardianWorkPhoneControl.setValue(
403
- !this.editVictim.guardianWorkPhone ? "" : this.editVictim.guardianWorkPhone
404
- );
405
-
406
-
407
- this.advocateHomePhoneControl.setValue(
408
- !this.editVictim.advocateHomePhone ? "" : this.editVictim.advocateHomePhone
409
- );
410
-
411
- this.advocateCellPhoneControl.setValue(
412
- !this.editVictim.advocateCellPhone ? "" : this.editVictim.advocateCellPhone
413
- );
414
-
415
- this.advocateWorkPhoneControl.setValue(
416
- !this.editVictim.advocateWorkPhone ? "" : this.editVictim.advocateWorkPhone
417
- );
418
-
419
- this.emergencyContactPhoneControl .setValue(
420
- !this.editVictim.emergencyContactPhone ? "" : this.editVictim.emergencyContactPhone
421
- );
422
-
423
- }, error => {
424
- this.snackBar.open("Error occured while retriving Victim Information. Please try again.");
425
- });
426
- return;
427
- } else {
428
- //new
429
-
430
- }
431
- }
432
-
433
- ngOnChanges() {
434
-
435
- }
436
-
437
- onClear() {
438
- if (this.addressComponent) this.addressComponent.reset();
439
- }
440
-
441
- showAddress(value){
442
-
443
- if (value.checked){
444
-
445
- this.victimService.getCurrentHousing(this.offenderId).subscribe(
446
- (item: any) => {
447
- this.addressId = item.housing.addressId;
448
- this.victimForm.patchValue({addressId: this.addressId})
449
- })
450
- }
451
- else{
452
- this.addressComponent.reset();
453
- this.editVictim.allowCsosaContactFlag = false;
454
- this.addressId = null;
455
- }
456
-
457
- }
458
-
459
- onAddressChange(addressId) {
460
- this.victimForm.patchValue({addressId: addressId})
461
- this.addressId = addressId;
462
- }
463
- onGuardianAddressChange(MyGuardianAddressId) {
464
- this.victimForm.patchValue({guardianAddressId: MyGuardianAddressId})
465
- this.guardianAddressId = MyGuardianAddressId;
466
- }
467
- onAdvocateAddressChange(MyAdvocateAddressId) {
468
- this.victimForm.patchValue({advocateAddressId: MyAdvocateAddressId})
469
- this.advocateAddressId = MyAdvocateAddressId;
470
- }
471
- cancel() {
472
- this.victimForm.reset();
473
- }
474
- ngOnInit() {
475
- this.homePhoneControl.valueChanges.subscribe((hpn: string) => {
476
- const newValue = hpn.replace(/\D/g, '');
477
- this.editVictim.homePhone= newValue;
478
- });
479
-
480
- this.cellPhoneControl.valueChanges.subscribe((hpn: string) => {
481
- const newValue = hpn.replace(/\D/g, '');
482
- this.editVictim.cellPhone= newValue;
483
- });
484
-
485
-
486
- this.workPhoneControl.valueChanges.subscribe((hpn: string) => {
487
- const newValue = hpn.replace(/\D/g, '');
488
- this.editVictim.workPhone= newValue;
489
- });
490
-
491
-
492
- this.guardianHomePhoneControl.valueChanges.subscribe((hpn: string) => {
493
- const newValue = hpn.replace(/\D/g, '');
494
- this.editVictim.guardianHomePhone= newValue;
495
- });
496
-
497
-
498
- this.guardianCellPhoneControl.valueChanges.subscribe((hpn: string) => {
499
- const newValue = hpn.replace(/\D/g, '');
500
- this.editVictim.guardianCellPhone= newValue;
501
- });
502
-
503
- this.guardianWorkPhoneControl.valueChanges.subscribe((hpn: string) => {
504
- const newValue = hpn.replace(/\D/g, '');
505
- this.editVictim.guardianWorkPhone= newValue;
506
- });
507
-
508
- this.advocateHomePhoneControl.valueChanges.subscribe((hpn: string) => {
509
- const newValue = hpn.replace(/\D/g, '');
510
- this.editVictim.advocateHomePhone= newValue;
511
- });
512
-
513
- this.advocateCellPhoneControl.valueChanges.subscribe((hpn: string) => {
514
- const newValue = hpn.replace(/\D/g, '');
515
- this.editVictim.advocateCellPhone= newValue;
516
- });
517
-
518
- this.advocateWorkPhoneControl.valueChanges.subscribe((hpn: string) => {
519
- const newValue = hpn.replace(/\D/g, '');
520
- this.editVictim.advocateWorkPhone= newValue;
521
- });
522
-
523
- this.emergencyContactPhoneControl .valueChanges.subscribe((hpn: string) => {
524
- const newValue = hpn.replace(/\D/g, '');
525
- this.editVictim.emergencyContactPhone= newValue;
526
- });
527
-
528
- console.log('show offenderId');
529
- console.log(this.offenderId);
530
- console.log('show staffId');
531
- console.log(this.staffId);
532
- console.log('show isIntake');
533
- console.log(this.isIntake);
534
-
535
- //required field
536
- const requiredImplementation = {get:function():boolean{if(this._required){return this._required;}
537
- if(this.ngControl&&this.ngControl.control&&this.ngControl.control.validator
538
- ){const emptyValueControl=Object.assign({},
539
- this.ngControl.control);(emptyValueControl as any).value=null;
540
- return('required'in(this.ngControl.control.validator(emptyValueControl)||{}));}
541
- return false;},set:function(value:boolean){this._required=coerceBooleanProperty(value);},};
542
- Object.defineProperty(MatInput.prototype,'required',requiredImplementation,);
543
- Object.defineProperty(MatSelect.prototype,'required',requiredImplementation,);
544
- Object.defineProperty(MatRadioGroup.prototype,'required',requiredImplementation,);
545
- //required field end
546
-
547
- if (this.victimDetail!=null) {
548
- // edit record
549
- this.editMode = true;
550
- this.showDelete= true;
551
- this.victimId = this.victimDetail.victimId;
552
- this.guardianTabFlag = this.victimDetail.minorFlag;
553
-
554
- if (this.victimDetail.victimAdvocateFlag=='YS'){
555
- this.advocateTabFlag = true;
556
- }
557
-
558
- if (this.otherWeaponFlag == true){
559
- const otherWeaponControl = this.victimForm.get('otherWeapon');
560
- otherWeaponControl.setValidators(Validators.required);
561
- }
562
-
563
- if (this.otherDrugFlag == true){
564
- const otherDrugControl = this.victimForm.get('otherDrug');
565
- otherDrugControl.setValidators(Validators.required);
566
- }
567
-
568
- this.cpoExpirationDivFlag =this.victimDetail.cpoExpirationFlag;
569
- this.commonChildrenDivFlag = this.victimDetail.commonChildrenFlag;
570
- this.supportInPlaceDivFlag= this.victimDetail.supportInPlaceFlag;
571
- this.weaponInvolvedDivFlag= this.victimDetail.weaponInvolvedFlag;
572
- this.drugUseDivFlag= this.victimDetail.drugUseFlag;
573
- this.addressId = this.victimDetail.addressId;
574
- this.guardianAddressId = this.victimDetail.guardianAddressId;
575
- this.advocateAddressId = this.victimDetail.advocateAddressId;
576
- this._getVictim();
577
-
578
- } else {
579
- //add new record
580
- this.victimForm.patchValue({guardianNoPhoneFlag: true});
581
- this.victimForm.patchValue({advocateNoPhoneFlag: true});
582
- }
583
-
584
- this.victimService.getFlagOptionYesNoUnknowns().subscribe(
585
- (items: any) => {
586
- this.flagOption = items;
587
- }
588
- );
589
- this.victimService.getGenders().subscribe(
590
- (items: any) => {
591
- this.genders = items;
592
- }
593
- );
594
- this.victimService.getPrefixes().subscribe(
595
- (items: any) => {
596
- this.prefixes = items;
597
- }
598
- );
599
- this.victimService.getSuffixes().subscribe(
600
- (items: any) => {
601
- this.suffixes = items;
602
- }
603
- );
604
- this.victimService.getRelationshipTypes().subscribe(
605
- (items: any) => {
606
-
607
- this.relationshipTypes = items.filter( (y) => ((y.relationshipCategoryId === 'ST' || y.relationshipCategoryId === 'FM' )
608
- && y.relationship !== 'AY'
609
- && y.relationship !== 'VT'
610
- && y.relationship !== 'CME'
611
- && y.relationship !== 'HH'
612
- && y.relationship !== 'NC'
613
- && y.relationship !== 'CL'
614
- && y.relationship !== 'OP'
615
-
616
- ));
617
- }
618
- );
619
- this.victimService.getSupportTypes().subscribe(
620
- (items: any) => {
621
- this.victimSupportTypes = items;
622
- }
623
- );
624
- this.victimService.getWeaponTypes().subscribe(
625
- (items: any) => {
626
- this.weaponTypes = items;
627
- }
628
- );
629
- this.victimService.getDrugsTypes().subscribe(
630
- (items: any) => {
631
- console.log('drug lookup items');
632
- console.log(items);
633
- this.drugs = items;
634
- this.drugs.push({drugTypeId: 'OTHER', name: 'Other'});
635
- console.log(this.drugs);
636
- }
637
- );
638
- // this.victimService.getDocketList(this.offenderId).subscribe(
639
- // (items: any) => {
640
- // this.docketlist = items;
641
- // }
642
- // );
643
-
644
- this.victimForm.get('minorFlag').valueChanges
645
- .subscribe(value => {
646
- this.victimForm.get('guardianFirstName').updateValueAndValidity();
647
- this.victimForm.get('guardianLastName').updateValueAndValidity();
648
- this.victimForm.get('guardianWorkPhone').updateValueAndValidity();
649
- this.victimForm.get('guardianHomePhone').updateValueAndValidity();
650
- this.victimForm.get('guardianCellPhone').updateValueAndValidity();
651
- });
652
-
653
- this.victimForm.get('victimAdvocateFlag').valueChanges
654
- .subscribe(value => {
655
- this.victimForm.get('advocateFirstName').updateValueAndValidity();
656
- this.victimForm.get('advocateLastName').updateValueAndValidity();
657
- this.victimForm.get('advocateWorkPhone').updateValueAndValidity();
658
- this.victimForm.get('advocateHomePhone').updateValueAndValidity();
659
- this.victimForm.get('advocateCellPhone').updateValueAndValidity();
660
- });
661
-
662
- }
663
-
664
- back(){
665
- //this.onSave.emit(this.victimDetail);
666
- this.router.navigate(['victimList']);
667
- }
668
-
669
- deleteVictim() {
670
- this.commonDialogService
671
- .confirm('', 'Do you want to delete this Victim?', 'Yes', 'No')
672
- .subscribe(res => {this.result = res;
673
- if (this.result) {
674
- this.victimService.deleteVictims(this.victimDetail.victimId, this.staffId)
675
- .subscribe(result => {
676
- this.snackBar.open('Delete Successfully!', '', {
677
- duration: 3000, });
678
-
679
-
680
- }
681
- );
682
-
683
- // this.onSave.emit(this.victimDetail);
684
- // this.router.navigate(['victim']);
685
- setTimeout(()=>{
686
- window.location.reload();
687
- },1500);
688
-
689
-
690
- }
691
- });
692
- }
693
-
694
- radioMinorChange($event: MatRadioChange){
695
- if ($event.value === true) {
696
- this.guardianTabFlag = true;
697
- }
698
- else{
699
- this.guardianTabFlag = false;
700
- }
701
-
702
- }
703
-
704
- radioAdvocateChange($event: MatRadioChange){
705
-
706
- const advocateLastNameControl = this.victimForm.get('advocateLastName');
707
- const advocateFirstNameControl = this.victimForm.get('advocateFirstName');
708
-
709
- if ($event.value === "YS") {
710
- this.advocateTabFlag = true;
711
- advocateLastNameControl.setValidators(Validators.required);
712
- advocateFirstNameControl.setValidators(Validators.required);
713
- }
714
- else{
715
- this.advocateTabFlag = false;
716
- advocateLastNameControl.clearValidators();
717
- advocateFirstNameControl.clearValidators();
718
- }
719
- advocateLastNameControl.updateValueAndValidity();
720
- advocateFirstNameControl.updateValueAndValidity();
721
-
722
- }
723
-
724
- radioCicChange($event: MatRadioChange){
725
- if ($event.value === true) {
726
- this.commonChildrenDivFlag = true;
727
- // requrie field
728
- this.setValidators('commonChildren');
729
- }
730
- else{
731
- this.commonChildrenDivFlag = false;
732
- }
733
- }
734
-
735
- setValidators(type) {
736
- if(type == 'commonChildren'){
737
- this.victimForm.get('commonChildrenNumber').clearValidators();
738
- this.victimForm.get('commonChildrenNumber').setValidators(Validators.required);
739
- }
740
- else if (type == 'cpo'){
741
- this.victimForm.get('cpoExpirationDate').clearValidators();
742
- this.victimForm.get('cpoExpirationDate').setValidators(Validators.required);
743
-
744
- }
745
- }
746
- radioSupportChange($event: MatRadioChange){
747
- if ($event.value === true) {
748
- this.supportInPlaceDivFlag = true;
749
- }
750
- else{
751
- this.supportInPlaceDivFlag = false;
752
- }
753
- }
754
- radioWeaponChange($event: MatRadioChange){
755
- if ($event.value === true) {
756
- this.weaponInvolvedDivFlag = true;
757
- }
758
- else{
759
- this.weaponInvolvedDivFlag = false;
760
- }
761
- }
762
- radioDrugChange($event: MatRadioChange){
763
- if ($event.value === true) {
764
- this.drugUseDivFlag = true;
765
- }
766
- else{
767
- this.drugUseDivFlag = false;
768
- }
769
- }
770
-
771
- radioCpoChange($event: MatRadioChange){
772
- if ($event.value === true) {
773
- this.cpoExpirationDivFlag = true;
774
- this.setValidators('cpo');
775
- }
776
- else{
777
- this.cpoExpirationDivFlag = false;
778
- }
779
- }
780
-
781
- handleDOBChange($event ){
782
- var ageDifMs = Date.now() - $event.value;
783
- var ageDate = new Date(ageDifMs);
784
- if( Math.abs(ageDate.getUTCFullYear() - 1970) <= 18){
785
-
786
- 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.', '', {
787
- duration: 6000,});
788
- const minorControl = this.victimForm.get('minorFlag');
789
- minorControl.setValue(true);
790
- this.guardianTabFlag = true;
791
- }
792
-
793
- }
794
- checkOtherWeapon(WeaponUse){
795
-
796
- const otherWeaponControl = this.victimForm.get('otherWeapon');
797
- if (WeaponUse.includes("OTHER")){
798
- this.otherWeaponFlag = true;
799
- otherWeaponControl.setValidators(Validators.required)
800
-
801
- }else{
802
- this.otherWeaponFlag = false;
803
- otherWeaponControl.clearValidators();
804
- }
805
- otherWeaponControl.updateValueAndValidity();
806
- }
807
-
808
- checkOtherDrug(DrugUse){
809
-
810
- const otherDrugControl = this.victimForm.get('otherDrug');
811
- if (DrugUse.includes("OTHER")){
812
- this.otherDrugFlag = true;
813
- otherDrugControl.setValidators(Validators.required)
814
-
815
-
816
- }else{
817
- this.otherDrugFlag = false;
818
- otherDrugControl.clearValidators();
819
-
820
-
821
- }
822
- otherDrugControl.updateValueAndValidity();
823
- }
824
-
825
- //#region "save victim"
826
- saveVictim() {
827
-
828
- //guardian phone logic
829
- if (!this.victimForm.value.guardianNoPhoneFlag)
830
- {
831
- if (this.guardianHomePhoneControl.value){
832
- if (this.guardianHomePhoneControl.value !== null){
833
- if (this.guardianHomePhoneControl.value !== ""){
834
- this.guardianPhoneExistFlag = true;
835
- }
836
- }
837
- }
838
-
839
-
840
-
841
- if (this.guardianWorkPhoneControl.value !== undefined){
842
- if (this.guardianWorkPhoneControl.value !== null){
843
- if (this.guardianWorkPhoneControl.value !== ""){
844
- this.guardianPhoneExistFlag = true;
845
- }
846
- }
847
- }
848
-
849
-
850
- if (this.guardianCellPhoneControl.value){
851
- if (this.guardianCellPhoneControl.value!== null){
852
- if (this.guardianCellPhoneControl.value !== ""){
853
- this.guardianPhoneExistFlag = true;
854
- }
855
- }
856
- }
857
-
858
- }
859
-
860
- console.log('this.victimForm.value.guardianNoPhoneFlag');
861
- console.log(this.victimForm.value.guardianNoPhoneFlag);
862
- console.log('this.guardianPhoneExistFlag');
863
- console.log(this.guardianPhoneExistFlag);
864
-
865
-
866
- if (this.guardianPhoneExistFlag === false && this.victimForm.value.guardianNoPhoneFlag === false)
867
- {
868
- this.phoneValidationFlag = true;
869
- this.commonDialogService
870
- .warning('', 'Please check the guardian phone field. You have to fill one of the three phone fileds.', 'Ok')
871
- .subscribe(res => {this.result = res;
872
-
873
- });
874
- }
875
- console.log('this.phoneValidationFlag');
876
- console.log(this.phoneValidationFlag);
877
-
878
- //advocate phone logic
879
- if (!this.victimForm.value.advocateNoPhoneFlag)
880
- {
881
- if (this.advocateHomePhoneControl.value){
882
- if (this.advocateHomePhoneControl.value !== null){
883
- if (this.advocateHomePhoneControl.value !== ""){
884
- this.advocatePhoneExistFlag = true;
885
- }
886
- }
887
- }
888
-
889
-
890
-
891
- if (this.advocateWorkPhoneControl.value !== undefined){
892
- if (this.advocateWorkPhoneControl.value !== null){
893
- if (this.advocateWorkPhoneControl.value !== ""){
894
- this.advocatePhoneExistFlag = true;
895
- }
896
- }
897
- }
898
-
899
-
900
- if (this.advocateCellPhoneControl.value){
901
- if (this.advocateCellPhoneControl.value !== null){
902
- if (this.advocateCellPhoneControl.value !== ""){
903
- this.advocatePhoneExistFlag = true;
904
- }
905
- }
906
- }
907
-
908
- }
909
-
910
- console.log('this.victimForm.value.advocateNoPhoneFlag');
911
- console.log(this.victimForm.value.advocateNoPhoneFlag);
912
- console.log('this.advocatePhoneExistFlag');
913
- console.log(this.advocatePhoneExistFlag);
914
-
915
- if(this.advocatePhoneExistFlag === false && this.victimForm.value.advocateNoPhoneFlag === false)
916
- {
917
-
918
- this.phoneValidationFlag = true;
919
- this.commonDialogService
920
- .warning('', 'Please check the advocate phone field. You have to fill one of the three phone fileds.', 'Ok')
921
- .subscribe(res => {this.result = res;
922
-
923
- });
924
- }
925
-
926
-
927
- if (this.homePhoneControl.value){
928
- this.victimForm.value.homePhone = this.homePhoneControl.value.replace(/[()\s-]/g, '');
929
- }
930
- else{
931
- this.victimForm.value.homePhone = null;
932
- }
933
-
934
- if (this.cellPhoneControl.value){
935
- this.victimForm.value.cellPhone = this.cellPhoneControl.value.replace(/[()\s-]/g, '') ;
936
- }
937
- else{
938
- this.victimForm.value.cellPhone = null;
939
- }
940
-
941
- if (this.workPhoneControl.value){
942
- this.victimForm.value.workPhone = this.workPhoneControl.value.replace(/[()\s-]/g, '');
943
- }
944
- else{
945
- this.victimForm.value.workPhone= null;
946
- }
947
-
948
- if (this.guardianHomePhoneControl.value){
949
- this.victimForm.value.guardianHomePhone = this.guardianHomePhoneControl.value.replace(/[()\s-]/g, '');
950
- }
951
- else{
952
- this.victimForm.value.guardianHomePhone = null;
953
- }
954
-
955
- if (this.guardianCellPhoneControl.value){
956
- this.victimForm.value.guardianCellPhone = this.guardianCellPhoneControl.value.replace(/[()\s-]/g, '');
957
- }
958
- else{
959
- this.victimForm.value.guardianCellPhone = null;
960
- }
961
-
962
- if (this.guardianWorkPhoneControl.value){
963
- this.victimForm.value.guardianWorkPhone = this.guardianWorkPhoneControl.value.replace(/[()\s-]/g, '');
964
- }
965
- else{
966
- this.victimForm.value.guardianWorkPhone = null;
967
- }
968
-
969
-
970
- if (this.advocateHomePhoneControl.value){
971
- this.victimForm.value.advocateHomePhone = this.advocateHomePhoneControl.value.replace(/[()\s-]/g, '')
972
- }
973
- else{
974
- this.victimForm.value.advocateHomePhone = null;
975
- }
976
-
977
- if (this.advocateCellPhoneControl.value){
978
- this.victimForm.value.advocateCellPhone = this.advocateCellPhoneControl.value.replace(/[()\s-]/g, '')
979
- }
980
- else{
981
- this.victimForm.value.advocateCellPhone = null;
982
- }
983
-
984
- if (this.advocateWorkPhoneControl.value){
985
- this.victimForm.value.advocateWorkPhone = this.advocateWorkPhoneControl.value.replace(/[()\s-]/g, '')
986
- }
987
- else{
988
- this.victimForm.value.advocateWorkPhone = null;
989
- }
990
-
991
-
992
- if (this.emergencyContactPhoneControl.value){
993
- this.victimForm.value.emergencyContactPhone = this.emergencyContactPhoneControl.value.replace(/[()\s-]/g, '')
994
- }else{
995
- this.victimForm.value.emergencyContactPhone = null;
996
- }
997
- //data process
998
-
999
-
1000
- var myVictimRelationships = [];
1001
-
1002
- console.log('this.victimForm.value.victimRelationships'+this.victimForm.value.victimRelationships)
1003
- if (this.victimForm.value.victimRelationships){
1004
- console.log('this.victimForm.value.victimRelationships 1'+this.victimForm.value.victimRelationships)
1005
-
1006
- this.victimForm.value.victimRelationships.forEach(element => {
1007
- const victimRelationship= <VictimRelationship>{};
1008
- victimRelationship.victimId= 0;
1009
- victimRelationship.victimRelationshipTypeId= element;
1010
- victimRelationship.modifiedBy= 2929;
1011
- myVictimRelationships.push(victimRelationship);
1012
- console.log('this.victimForm.value.victimRelationships 2'+this.victimForm.value.victimId)
1013
- console.log('this.victimForm.value.victimRelationships 3'+this.staffId)
1014
- console.log('this.victimForm.value.victimRelationships 4'+element)
1015
-
1016
- });
1017
- }
1018
-
1019
- console.log('myVictimRelationships'+myVictimRelationships)
1020
-
1021
-
1022
- console.log('this.phoneValidationFlag 1');
1023
- console.log(this.phoneValidationFlag);
1024
- if ( this.phoneValidationFlag === false){
1025
- if (this.victimDetail === null){
1026
-
1027
- //insert new victim
1028
-
1029
-
1030
- var myVictimRelationships = [];
1031
-
1032
- console.log('this.victimForm.value.victimRelationships'+this.victimForm.value.victimRelationships)
1033
- if (this.victimForm.value.victimRelationships){
1034
- console.log('this.victimForm.value.victimRelationships 1'+this.victimForm.value.victimRelationships)
1035
-
1036
- this.victimForm.value.victimRelationships.forEach(element => {
1037
- const victimRelationship= <VictimRelationship>{};
1038
- victimRelationship.victimId= this.victimForm.value.victimId;
1039
- victimRelationship.victimRelationshipTypeId= element;
1040
- victimRelationship.modifiedBy= this.staffId;
1041
- myVictimRelationships.push(victimRelationship);
1042
- console.log('this.victimForm.value.victimRelationships 2'+this.victimForm.value.victimId)
1043
- console.log('this.victimForm.value.victimRelationships 3'+this.staffId)
1044
- console.log('this.victimForm.value.victimRelationships 4'+element)
1045
-
1046
- });
1047
- }
1048
-
1049
- console.log('myVictimRelationships'+myVictimRelationships)
1050
-
1051
- var myVictimSupports = [];
1052
- if (this.victimForm.value.victimSupports){
1053
- this.victimForm.value.victimSupports.forEach(element => {
1054
- const victimSupport= <VictimSupport>{};
1055
- victimSupport.victimId= this.victimForm.value.victimId;
1056
- victimSupport.victimSupportTypeId= element;
1057
- victimSupport.modifiedBy= this.staffId;
1058
- myVictimSupports.push(victimSupport);
1059
- });
1060
- }
1061
-
1062
-
1063
- var myVictimDrugUses = [];
1064
- console.log('this.victimForm.value.victimDrugUses during save');
1065
- console.log(this.victimForm.value.victimDrugUses);
1066
- if (this.victimForm.value.victimDrugUses){
1067
- this.victimForm.value.victimDrugUses.forEach(element => {
1068
- const victimDrugUse = <VictimDrugUse>{};
1069
- victimDrugUse.drugTypeId = element;
1070
-
1071
- if (element ==="OTHER" || element === "" || element === null){
1072
- victimDrugUse.drugTypeId = null;
1073
- victimDrugUse.otherDrug = this.victimForm.value.otherDrug;
1074
- }
1075
- else{
1076
- victimDrugUse.drugTypeId = element;
1077
- victimDrugUse.otherDrug = null;
1078
- }
1079
-
1080
- victimDrugUse.modifiedBy = this.staffId;
1081
- victimDrugUse.victimId = this.victimForm.value.victimId;
1082
- myVictimDrugUses.push(victimDrugUse);
1083
- });
1084
- }
1085
-
1086
- console.log('this.victimForm.value.victimDrugUses during save 1');
1087
- console.log(this.victimForm.value.victimDrugUses);
1088
-
1089
- var myVictimWeaponUses = [];
1090
-
1091
- if (this.victimForm.value.victimWeaponUses){
1092
- this.victimForm.value.victimWeaponUses.forEach(element => {
1093
- const victimWeaponUse = <VictimWeaponUse>{};
1094
- victimWeaponUse.victimId= this.victimForm.value.victimId;
1095
- victimWeaponUse.weaponTypeId= element;
1096
-
1097
- if (element =="OTHER"){
1098
- victimWeaponUse.otherWeapon = this.victimForm.value.otherWeapon;
1099
- }
1100
- else{
1101
- victimWeaponUse.otherWeapon = null;
1102
- }
1103
- victimWeaponUse.modifiedBy= this.staffId;
1104
- myVictimWeaponUses.push(victimWeaponUse);
1105
- });
1106
- }
1107
-
1108
- const newVictim = {
1109
- victimId: 0,
1110
- offenderId: this.offenderId,
1111
- // victimOffenderRelationshipTypeId:
1112
- // this.victimForm.value.victimOffenderRelationshipTypeId,
1113
- lastName: this.victimForm.value.lastName,
1114
- firstName: this.victimForm.value.firstName,
1115
- middleName: this.victimForm.value.middleName
1116
- ? this.victimForm.value.middleName
1117
- : null,
1118
- prefixId: this.victimForm.value.prefixId
1119
- ? this.victimForm.value.prefixId
1120
- : null,
1121
- suffixId: this.victimForm.value.suffixId
1122
- ? this.victimForm.value.suffixId
1123
- : null,
1124
- birthDate: this.victimForm.value.birthDate
1125
- ? this.victimForm.value.birthDate
1126
- : null,
1127
- genderCode: this.victimForm.value.genderCode
1128
- ? this.victimForm.value.genderCode
1129
- : null,
1130
- underSupervisionFlag: this.victimForm.value.underSupervisionFlag,
1131
- minorFlag: this.victimForm.value.minorFlag,
1132
- victimAdvocateFlag: this.victimForm.value.victimAdvocateFlag,
1133
-
1134
- homePhone: this.victimForm.value.homePhone,
1135
- workPhone: this.victimForm.value.workPhone,
1136
- cellPhone: this.victimForm.value.cellPhone,
1137
- email: this.victimForm.value.email ? this.victimForm.value.email : null,
1138
- addressId: this.victimForm.value.addressId
1139
- ? this.victimForm.value.addressId
1140
- : 1,
1141
- emergencyContact: this.victimForm.value.emergencyContact
1142
- ? this.victimForm.value.emergencyContact
1143
- : null,
1144
- emergencyContactPhone: this.victimForm.value.emergencyContactPhone,
1145
- commonChildrenFlag: this.victimForm.value.commonChildrenFlag,
1146
- commonChildrenNumber: this.victimForm.value.commonChildrenNumber,
1147
- cpoExpirationFlag: this.victimForm.value.cpoExpirationFlag,
1148
- cpoExpirationDate: this.victimForm.value.cpoExpirationDate
1149
- ? this.datePipe.transform(this.victimForm.value.cpoExpirationDate, "short")
1150
- : null,
1151
- supportInPlaceFlag: this.victimForm.value.supportInPlaceFlag,
1152
- weaponInvolvedFlag: this.victimForm.value.weaponInvolvedFlag,
1153
- drugUseFlag: this.victimForm.value.drugUseFlag,
1154
- alcoholUseFlag: this.victimForm.value.alcoholUseFlag,
1155
- accessRisk: this.victimForm.value.accessRisk,
1156
- modifiedBy: this.staffId,
1157
- vVictimAdvocate: null,
1158
- vVictimGuardian: null,
1159
- victimDrugUses: myVictimDrugUses,
1160
- victimSupports: myVictimSupports,
1161
- victimOffenderRelationships: myVictimRelationships,
1162
- victimWeaponUses: myVictimWeaponUses,
1163
-
1164
- advocateFirstName: null,
1165
- advocateLastName: null,
1166
- advocateEmail: null,
1167
- advocatePrefixId: null,
1168
- advocateSuffixId: null,
1169
- advocateNoPhoneFlag: null,
1170
- advocateHomePhone: null,
1171
- advocateWorkPhone: null,
1172
- advocateCellPhone: null,
1173
- advocateAddressId: null,
1174
- guardianFirstName: null,
1175
- guardianLastName: null,
1176
- guardianEmail: null,
1177
- guardianPrefixId: null,
1178
- guardianSuffixId: null,
1179
- guardianNoPhoneFlag: null,
1180
- guardianHomePhone: null,
1181
- guardianWorkPhone: null,
1182
- guardianCellPhone: null,
1183
- guardianAddressId: null,
1184
- guardianBirthDate: null,
1185
- //relationship: null,
1186
- //relationship: this.victimForm.value.victimOffenderRelationshipTypeId? this.victimForm.value.victimOffenderRelationshipTypeId : null,
1187
- allowCsosaContactFlag: this.victimForm.value.allowCsosaContactFlag
1188
- ? this.victimForm.value.allowCsosaContactFlag
1189
- : null,
1190
- liveWithOffenderFlag: this.victimForm.value.liveWithOffenderFlag
1191
- ? this.victimForm.value.liveWithOffenderFlag
1192
- : null,
1193
- };
1194
-
1195
- if (this.addressId == 0){
1196
- newVictim.addressId = null;
1197
- } else {
1198
- newVictim.addressId = this.addressId;
1199
- }
1200
-
1201
- newVictim.advocateAddressId = this.advocateAddressId;
1202
- newVictim.guardianAddressId = this.guardianAddressId;
1203
-
1204
-
1205
- console.log('newVictim');
1206
- console.log(newVictim);
1207
- this.victimService.postVictims(newVictim).subscribe(
1208
- (items: any) => {
1209
-
1210
- const id = items ? items.victimId : '';
1211
-
1212
- if (this.victimForm.value.victimAdvocateFlag == "YS"){
1213
-
1214
- console.log('add advocate');
1215
- const victimAdvocate: VictimAdvocate = {
1216
- victimAdvocateId: id,
1217
- lastName: this.victimForm.value.advocateLastName,
1218
- firstName: this.victimForm.value.advocateFirstName,
1219
- prefixId: this.victimForm.value.advocatePrefixId,
1220
- suffixId: this.victimForm.value.advocateSuffixId,
1221
- addressId: this.advocateAddressId ? this.advocateAddressId: null,
1222
- noPhoneFlag: this.victimForm.value.advocateNoPhoneFlag ? this.victimForm.value.advocateNoPhoneFlag: null,
1223
- homePhone: this.victimForm.value.advocateHomePhone,
1224
- workPhone: this.victimForm.value.advocateWorkPhone,
1225
- cellPhone: this.victimForm.value.advocateCellPhone,
1226
- email: this.victimForm.value.advocateEmail,
1227
- modifiedBy: this.staffId
1228
- };
1229
-
1230
- this.victimService.postVictimAdvocate(id, victimAdvocate).subscribe();
1231
- }
1232
-
1233
- if (this.victimForm.value.minorFlag == true){
1234
- const victimGuardian: VictimGuardian = {
1235
- victimGuardianId: id,
1236
- lastName: this.victimForm.value.guardianLastName,
1237
- firstName: this.victimForm.value.guardianFirstName,
1238
- prefixId: this.victimForm.value.guardianPrefixId,
1239
- suffixId: this.victimForm.value.guardianSuffixId,
1240
- birthDate: this.victimForm.value.guardianBirthDate,
1241
- addressId: this.guardianAddressId? this.guardianAddressId: null,
1242
- noPhoneFlag: this.victimForm.value.guardianNoPhoneFlag? this.victimForm.value.guardianNoPhoneFlag: null,
1243
- homePhone: this.victimForm.value.guardianHomePhone,
1244
- workPhone: this.victimForm.value.guardianWorkPhone,
1245
- cellPhone: this.victimForm.value.guardianCellPhone,
1246
- email: this.victimForm.value.guardianEmail,
1247
- modifiedBy: this.staffId
1248
- };
1249
- this.victimService.postVictimGuardian(id, victimGuardian).subscribe();
1250
- }
1251
-
1252
- this.snackBar.open('Add Victim Successfully!', '', {
1253
- duration: 3000,
1254
- });
1255
- //insert new
1256
- if (this.isIntake===true){
1257
- this.router.navigate(['victimHome']);
1258
- }
1259
- else
1260
- {
1261
- this.router.navigate(['victimList']);
1262
- }
1263
- //this.onSave.emit(this.victimDetail);
1264
-
1265
- }
1266
- );
1267
-
1268
- }
1269
- else {
1270
- //update victim
1271
- this.victimDetail.underSupervisionFlag = this.victimForm.value.underSupervisionFlag;
1272
- //this.victimDetail.victimOffenderRelationshipTypeId = this.victimForm.value.victimOffenderRelationshipTypeId;
1273
- this.victimDetail.lastName = this.victimForm.value.lastName;
1274
- this.victimDetail.firstName = this.victimForm.value.firstName;
1275
- this.victimDetail.middleName = this.victimForm.value.middleName;
1276
- this.victimDetail.prefixId = this.victimForm.value.prefixId ? this.victimForm.value.prefixId : null;
1277
- this.victimDetail.suffixId = this.victimForm.value.suffixId ? this.victimForm.value.suffixId : null;
1278
- this.victimDetail.birthDate = this.victimForm.value.birthDate;
1279
- this.victimDetail.genderCode = this.victimForm.value.genderCode;
1280
- this.victimDetail.minorFlag = this.victimForm.value.minorFlag;
1281
- this.victimDetail.homePhone = this.victimForm.value.homePhone;
1282
- this.victimDetail.workPhone = this.victimForm.value.workPhone;
1283
- this.victimDetail.cellPhone = this.victimForm.value.cellPhone;
1284
- this.victimDetail.email = this.victimForm.value.email;
1285
- this.victimDetail.victimAdvocateFlag = this.victimForm.value.victimAdvocateFlag;
1286
- this.victimDetail.emergencyContact = this.victimForm.value.emergencyContact;
1287
- this.victimDetail.emergencyContactPhone = this.victimForm.value.emergencyContactPhone;
1288
- this.victimDetail.commonChildrenFlag = this.victimForm.value.commonChildrenFlag;
1289
- this.victimDetail.commonChildrenNumber = this.victimForm.value.commonChildrenNumber;
1290
- this.victimDetail.cpoExpirationDate = this.victimForm.value.cpoExpirationDate;
1291
- this.victimDetail.cpoExpirationFlag = this.victimForm.value.cpoExpirationFlag;
1292
- this.victimDetail.supportInPlaceFlag = this.victimForm.value.supportInPlaceFlag;
1293
- this.victimDetail.weaponInvolvedFlag = this.victimForm.value.weaponInvolvedFlag;
1294
- this.victimDetail.drugUseFlag = this.victimForm.value.drugUseFlag;
1295
- this.victimDetail.alcoholUseFlag = this.victimForm.value.alcoholUseFlag;
1296
- this.victimDetail.accessRisk = this.victimForm.value.accessRisk;
1297
- this.victimDetail.addressId = this.addressId;
1298
- this.victimDetail.allowCsosaContactFlag = this.victimForm.value.allowCsosaContactFlag;
1299
- this.victimDetail.liveWithOffenderFlag = this.victimForm.value.liveWithOffenderFlag;
1300
-
1301
- this.victimDetail.victimSupports = [];
1302
- this.victimForm.value.victimSupports.forEach(element => {
1303
- const victimSupport= <VictimSupport>{};
1304
- victimSupport.victimId= this.victimDetail.victimId;
1305
- victimSupport.victimSupportTypeId= element;
1306
- victimSupport.modifiedBy= this.staffId;
1307
- this.victimDetail.victimSupports.push(victimSupport);
1308
- });
1309
-
1310
-
1311
- this.victimDetail.victimRelationships = [];
1312
- this.victimForm.value.victimRelationships.forEach(element => {
1313
- const victimRelationship= <VictimRelationship>{};
1314
- victimRelationship.victimId= this.victimDetail.victimId;
1315
- victimRelationship.victimRelationshipTypeId= element;
1316
- victimRelationship.modifiedBy= this.staffId;
1317
- this.victimDetail.victimRelationships.push(victimRelationship);
1318
- });
1319
-
1320
-
1321
- this.victimDetail.victimDrugUses = [];
1322
-
1323
- this.victimForm.value.victimDrugUses.forEach(element => {
1324
- const victimDrugUse = <VictimDrugUse>{};
1325
- victimDrugUse.drugTypeId = element;
1326
- console.log('this.victimForm.value.victimDrugUses before')
1327
- console.log(this.victimForm.value.victimDrugUses)
1328
-
1329
- if (element === "OTHER" || element === "" ){
1330
- victimDrugUse.drugTypeId = null;
1331
- victimDrugUse.otherDrug = this.victimForm.value.otherDrug;
1332
- }
1333
- else{
1334
- victimDrugUse.drugTypeId = element;
1335
- victimDrugUse.otherDrug = null;
1336
- }
1337
-
1338
- victimDrugUse.modifiedBy = this.staffId;
1339
- victimDrugUse.victimId = this.victimDetail.victimId;
1340
- this.victimDetail.victimDrugUses.push(victimDrugUse);
1341
-
1342
- });
1343
- this.victimForm.value.victimDrugUses.filter(word => ( !(word.drugTypeId === null && word.otherDrug === null) ));
1344
-
1345
- this.victimDetail.victimWeaponUses = [];
1346
- this.victimForm.value.victimWeaponUses.forEach(element => {
1347
- const victimWeaponUse = <VictimWeaponUse>{};
1348
- victimWeaponUse.victimId= this.victimDetail.victimId;
1349
- victimWeaponUse.weaponTypeId= element;
1350
-
1351
- if (element =="OTHER"){
1352
- victimWeaponUse.otherWeapon=this.victimForm.value.otherWeapon;
1353
- }
1354
- else{
1355
- victimWeaponUse.otherWeapon = null;
1356
- }
1357
-
1358
- victimWeaponUse.modifiedBy= this.staffId;
1359
- this.victimDetail.victimWeaponUses.push(victimWeaponUse);
1360
-
1361
- });
1362
-
1363
- console.log('this.victimDetail before emit');
1364
- console.log(this.victimDetail);
1365
-
1366
-
1367
- this.victimService.putVictims(this.victimDetail.victimId,this.victimDetail).subscribe(
1368
- (items: any) => {
1369
- this.snackBar.open('Update Successfully!', '', {
1370
- duration: 3000,
1371
- });
1372
- //Advocate section
1373
- this.victimAdvocate.victimAdvocateId = this.victimDetail.victimId;
1374
- this.victimAdvocate.lastName= this.victimForm.value.advocateLastName;
1375
- this.victimAdvocate.firstName= this.victimForm.value.advocateFirstName;
1376
- this.victimAdvocate.prefixId= this.victimForm.value.advocatePrefixId ? this.victimForm.value.advocatePrefixId : null;
1377
- this.victimAdvocate.suffixId= this.victimForm.value.advocateSuffixId ? this.victimForm.value.advocateSuffixId : null;
1378
- this.victimAdvocate.addressId= this.advocateAddressId ? this.advocateAddressId : null;
1379
- this.victimAdvocate.noPhoneFlag= this.victimForm.value.advocateNoPhoneFlag? true: false;
1380
- this.victimAdvocate.homePhone= this.victimForm.value.advocateHomePhone;
1381
- this.victimAdvocate.workPhone= this.victimForm.value.advocateWorkPhone;
1382
- this.victimAdvocate.cellPhone= this.victimForm.value.advocateCellPhone;
1383
- this.victimAdvocate.email= this.victimForm.value.advocateEmail ? this.victimForm.value.advocateEmail : null;
1384
- this.victimAdvocate.modifiedBy= this.staffId;
1385
-
1386
- console.log('work on advocate part');
1387
- if (this.victimDetail.victimAdvocateFlag=='YS')
1388
- {
1389
- console.log('work on advocate flag is YS ');
1390
- if(this.victimDetail.advocateFirstName != null){
1391
- console.log('check advocate fisrt name ');
1392
- console.log(this.victimDetail.advocateFirstName);
1393
- this.victimService.putVictimAdvocate(this.victimDetail.victimId,this.victimAdvocate).subscribe(
1394
- resp=>{} );
1395
- }
1396
- else
1397
- {
1398
- console.log('add advocate');
1399
- console.log(this.victimAdvocate);
1400
- this.victimService.postVictimAdvocate(this.victimDetail.victimId, this.victimAdvocate).subscribe();
1401
- }
1402
- }
1403
-
1404
- // guardian section
1405
- this.victimGuardian.victimGuardianId = this.victimDetail.victimId;
1406
- this.victimGuardian.lastName = this.victimForm.value.guardianLastName;
1407
- this.victimGuardian.firstName = this.victimForm.value.guardianFirstName;
1408
- this.victimGuardian.prefixId = this.victimForm.value.guardianPrefixId ? this.victimForm.value.guardianPrefixId : null;
1409
- this.victimGuardian.suffixId = this.victimForm.value.guardianSuffixId ? this.victimForm.value.guardianSuffixId : null;
1410
- this.victimGuardian.addressId = this.guardianAddressId ? this.guardianAddressId : null;
1411
- this.victimGuardian.noPhoneFlag = this.victimForm.value.guardianNoPhoneFlag? true: false;
1412
- this.victimGuardian.homePhone = this.victimForm.value.guardianHomePhone;
1413
- this.victimGuardian.workPhone = this.victimForm.value.guardianWorkPhone;
1414
- this.victimGuardian.cellPhone = this.victimForm.value.guardianCellPhone;
1415
- this.victimGuardian.email = this.victimForm.value.guardianEmail ? this.victimForm.value.guardianEmail : null;
1416
- this.victimGuardian.modifiedBy = this.staffId;
1417
-
1418
- if (this.victimDetail.minorFlag == true)
1419
- {
1420
- if(this.victimDetail.guardianFirstName != null )
1421
- this.victimService.putVictimGuardian(this.victimDetail.victimId,this.victimGuardian).subscribe(
1422
- resp=>{
1423
- }
1424
- );
1425
- else
1426
- {
1427
- console.log('add gurdian');
1428
- console.log(this.victimGuardian);
1429
- this.victimService.postVictimGuardian(this.victimDetail.victimId, this.victimGuardian).subscribe();
1430
- }
1431
-
1432
- }
1433
- }
1434
-
1435
- );
1436
-
1437
- }
1438
- }//end of this.phoneValidationFlag = false
1439
-
1440
- console.log('this.victimDetail');
1441
- console.log(this.victimDetail);
1442
- this.onSave.emit(this.victimDetail);
1443
- }
1444
-
1445
- //#endregion "save victim"
1446
- addContact(){
1447
- this.router.navigate(['victimContact',this.victimId]);
1448
- }
1449
- formatLabel(value: number) {
1450
- return value;
1451
- }
1452
-
1453
-
1454
-
1455
- update() {
1456
- // this.task.update(task => {
1457
- // if (index === undefined) {
1458
- // task.completed = completed;
1459
- // task.subtasks?.forEach(t => (t.completed = completed));
1460
- // } else {
1461
- // task.subtasks![index].completed = completed;
1462
- // task.completed = task.subtasks?.every(t => t.completed) ?? true;
1463
- // }
1464
- // return {...task};
1465
- // });
1466
- }
1467
-
1468
-
1469
- }