@csmart/ngc-smart-victim 1.18.6 → 1.18.8
Sign up to get free protection for your applications and to get access to all the features.
- package/karma.conf.js +32 -0
- package/ng-package.json +7 -0
- package/package.json +6 -22
- package/src/lib/caseNote/caseNote.component.css +20 -0
- package/src/lib/caseNote/caseNote.component.html +188 -0
- package/src/lib/caseNote/caseNote.component.ts +265 -0
- package/src/lib/common-dialog/common-dialog.component.css +10 -0
- package/src/lib/common-dialog/common-dialog.component.html +23 -0
- package/src/lib/common-dialog/common-dialog.component.spec.ts +25 -0
- package/src/lib/common-dialog/common-dialog.component.ts +21 -0
- package/src/lib/common-dialog/common-dialog.module.ts +22 -0
- package/src/lib/common-dialog/common-dialog.service.ts +35 -0
- package/src/lib/contact/contact.component.css +20 -0
- package/src/lib/contact/contact.component.html +124 -0
- package/src/lib/contact/contact.component.ts +176 -0
- package/src/lib/email-notification.service.ts +42 -0
- package/src/lib/email.services.ts +51 -0
- package/src/lib/http.service.ts +34 -0
- package/src/lib/intake.service.ts +82 -0
- package/src/lib/loader.service.ts +11 -0
- package/src/lib/safetyPlan/serviceProvider.component.ts +94 -0
- package/src/lib/safetyPlan/victimSafetyPlan.component.css +27 -0
- package/src/lib/safetyPlan/victimSafetyPlan.component.html +85 -0
- package/src/lib/safetyPlan/victimSafetyPlan.component.ts +178 -0
- package/src/lib/safetyPlan/victimSafetyPlanDetail.component.html +234 -0
- package/src/lib/safetyPlan/victimSafetyPlanDetail.component.ts +492 -0
- package/src/lib/shared/app.shared.module.ts +111 -0
- package/src/lib/shared/validators/date.validator.ts +73 -0
- package/src/lib/shared/validators/index.ts +1 -0
- package/src/lib/smart-victim-delete-confirm.component.ts +35 -0
- package/src/lib/smart-victim-detail/smart-victim-detail.component.css +43 -0
- package/src/lib/smart-victim-detail/smart-victim-detail.component.html +869 -0
- package/src/lib/smart-victim-detail/smart-victim-detail.component.spec.ts +25 -0
- package/src/lib/smart-victim-detail/smart-victim-detail.component.ts +1384 -0
- package/src/lib/smart-victim.component.css +192 -0
- package/src/lib/smart-victim.component.html +138 -0
- package/src/lib/smart-victim.component.spec.ts +25 -0
- package/src/lib/smart-victim.component.ts +329 -0
- package/src/lib/smart-victim.model.ts +301 -0
- package/src/lib/smart-victim.module.ts +110 -0
- package/src/lib/smart-victim.service.spec.ts +12 -0
- package/src/lib/smart-victim.service.ts +557 -0
- package/src/lib/victim-routing.module.ts +35 -0
- package/{lib/victimSearch/VictimSearchFilter.d.ts → src/lib/victimSearch/VictimSearchFilter.ts} +9 -7
- package/src/lib/victimSearch/victimSearchForm.component.html +35 -0
- package/src/lib/victimSearch/victimSearchForm.component.ts +41 -0
- package/{public-api.d.ts → src/public-api.ts} +12 -7
- package/src/test.ts +22 -0
- package/tsconfig.lib.json +37 -0
- package/tsconfig.spec.json +17 -0
- package/tslint.json +17 -0
- package/esm2022/csmart-ngc-smart-victim.mjs +0 -5
- package/esm2022/lib/caseNote/caseNote.component.mjs +0 -194
- package/esm2022/lib/common-dialog/common-dialog.component.mjs +0 -23
- package/esm2022/lib/common-dialog/common-dialog.module.mjs +0 -34
- package/esm2022/lib/common-dialog/common-dialog.service.mjs +0 -33
- package/esm2022/lib/contact/contact.component.mjs +0 -140
- package/esm2022/lib/email.services.mjs +0 -42
- package/esm2022/lib/intake.service.mjs +0 -57
- package/esm2022/lib/safetyPlan/serviceProvider.component.mjs +0 -99
- package/esm2022/lib/safetyPlan/victimSafetyPlan.component.mjs +0 -116
- package/esm2022/lib/safetyPlan/victimSafetyPlanDetail.component.mjs +0 -340
- package/esm2022/lib/shared/app.shared.module.mjs +0 -215
- package/esm2022/lib/shared/validators/date.validator.mjs +0 -59
- package/esm2022/lib/shared/validators/index.mjs +0 -2
- package/esm2022/lib/smart-victim-delete-confirm.component.mjs +0 -44
- package/esm2022/lib/smart-victim-detail/smart-victim-detail.component.mjs +0 -1104
- package/esm2022/lib/smart-victim.component.mjs +0 -316
- package/esm2022/lib/smart-victim.model.mjs +0 -133
- package/esm2022/lib/smart-victim.module.mjs +0 -128
- package/esm2022/lib/smart-victim.service.mjs +0 -352
- package/esm2022/lib/victim-routing.module.mjs +0 -41
- package/esm2022/lib/victimSearch/VictimSearchFilter.mjs +0 -3
- package/esm2022/lib/victimSearch/victimSearchForm.component.mjs +0 -38
- package/esm2022/public-api.mjs +0 -11
- package/fesm2022/csmart-ngc-smart-victim.mjs +0 -3263
- package/fesm2022/csmart-ngc-smart-victim.mjs.map +0 -1
- package/index.d.ts +0 -5
- package/lib/caseNote/caseNote.component.d.ts +0 -51
- package/lib/common-dialog/common-dialog.component.d.ts +0 -14
- package/lib/common-dialog/common-dialog.module.d.ts +0 -8
- package/lib/common-dialog/common-dialog.service.d.ts +0 -11
- package/lib/contact/contact.component.d.ts +0 -40
- package/lib/email.services.d.ts +0 -11
- package/lib/intake.service.d.ts +0 -57
- package/lib/safetyPlan/serviceProvider.component.d.ts +0 -19
- package/lib/safetyPlan/victimSafetyPlan.component.d.ts +0 -54
- package/lib/safetyPlan/victimSafetyPlanDetail.component.d.ts +0 -62
- package/lib/shared/app.shared.module.d.ts +0 -33
- package/lib/shared/validators/date.validator.d.ts +0 -9
- package/lib/shared/validators/index.d.ts +0 -1
- package/lib/smart-victim-delete-confirm.component.d.ts +0 -12
- package/lib/smart-victim-detail/smart-victim-detail.component.d.ts +0 -129
- package/lib/smart-victim.component.d.ts +0 -69
- package/lib/smart-victim.model.d.ts +0 -205
- package/lib/smart-victim.module.d.ts +0 -49
- package/lib/smart-victim.service.d.ts +0 -71
- package/lib/victim-routing.module.d.ts +0 -7
- package/lib/victimSearch/victimSearchForm.component.d.ts +0 -14
@@ -0,0 +1,1384 @@
|
|
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' ) && y.relationship !== 'AY'
|
600
|
+
&& y.relationship !== 'VT'
|
601
|
+
&& y.relationship !== 'CME'
|
602
|
+
&& y.relationship !== 'HH'
|
603
|
+
&& y.relationship !== 'NC'
|
604
|
+
&& y.relationship !== 'CL'
|
605
|
+
&& y.relationship !== 'OP'));
|
606
|
+
}
|
607
|
+
);
|
608
|
+
this.victimService.getSupportTypes().subscribe(
|
609
|
+
(items: any) => {
|
610
|
+
this.victimSupportTypes = items;
|
611
|
+
}
|
612
|
+
);
|
613
|
+
this.victimService.getWeaponTypes().subscribe(
|
614
|
+
(items: any) => {
|
615
|
+
this.weaponTypes = items;
|
616
|
+
}
|
617
|
+
);
|
618
|
+
this.victimService.getDrugsTypes().subscribe(
|
619
|
+
(items: any) => {
|
620
|
+
console.log('drug lookup items');
|
621
|
+
console.log(items);
|
622
|
+
this.drugs = items;
|
623
|
+
this.drugs.push({drugTypeId: 'OTHER', name: 'Other'});
|
624
|
+
console.log(this.drugs);
|
625
|
+
}
|
626
|
+
);
|
627
|
+
// this.victimService.getDocketList(this.offenderId).subscribe(
|
628
|
+
// (items: any) => {
|
629
|
+
// this.docketlist = items;
|
630
|
+
// }
|
631
|
+
// );
|
632
|
+
|
633
|
+
this.victimForm.get('minorFlag').valueChanges
|
634
|
+
.subscribe(value => {
|
635
|
+
this.victimForm.get('guardianFirstName').updateValueAndValidity();
|
636
|
+
this.victimForm.get('guardianLastName').updateValueAndValidity();
|
637
|
+
this.victimForm.get('guardianWorkPhone').updateValueAndValidity();
|
638
|
+
this.victimForm.get('guardianHomePhone').updateValueAndValidity();
|
639
|
+
this.victimForm.get('guardianCellPhone').updateValueAndValidity();
|
640
|
+
});
|
641
|
+
|
642
|
+
this.victimForm.get('victimAdvocateFlag').valueChanges
|
643
|
+
.subscribe(value => {
|
644
|
+
this.victimForm.get('advocateFirstName').updateValueAndValidity();
|
645
|
+
this.victimForm.get('advocateLastName').updateValueAndValidity();
|
646
|
+
this.victimForm.get('advocateWorkPhone').updateValueAndValidity();
|
647
|
+
this.victimForm.get('advocateHomePhone').updateValueAndValidity();
|
648
|
+
this.victimForm.get('advocateCellPhone').updateValueAndValidity();
|
649
|
+
});
|
650
|
+
|
651
|
+
}
|
652
|
+
|
653
|
+
back(){
|
654
|
+
//this.onSave.emit(this.victimDetail);
|
655
|
+
this.router.navigate(['victimList']);
|
656
|
+
}
|
657
|
+
|
658
|
+
deleteVictim() {
|
659
|
+
this.commonDialogService
|
660
|
+
.confirm('', 'Do you want to delete this Victim?', 'Yes', 'No')
|
661
|
+
.subscribe(res => {this.result = res;
|
662
|
+
if (this.result) {
|
663
|
+
this.victimService.deleteVictims(this.victimDetail.victimId, this.staffId)
|
664
|
+
.subscribe(result => {
|
665
|
+
this.snackBar.open('Delete Successfully!', '', {
|
666
|
+
duration: 3000, });
|
667
|
+
|
668
|
+
|
669
|
+
}
|
670
|
+
);
|
671
|
+
|
672
|
+
// this.onSave.emit(this.victimDetail);
|
673
|
+
// this.router.navigate(['victim']);
|
674
|
+
setTimeout(()=>{
|
675
|
+
window.location.reload();
|
676
|
+
},1500);
|
677
|
+
|
678
|
+
|
679
|
+
}
|
680
|
+
});
|
681
|
+
}
|
682
|
+
|
683
|
+
radioMinorChange($event: MatRadioChange){
|
684
|
+
if ($event.value === true) {
|
685
|
+
this.guardianTabFlag = true;
|
686
|
+
}
|
687
|
+
else{
|
688
|
+
this.guardianTabFlag = false;
|
689
|
+
}
|
690
|
+
|
691
|
+
}
|
692
|
+
|
693
|
+
radioAdvocateChange($event: MatRadioChange){
|
694
|
+
|
695
|
+
const advocateLastNameControl = this.victimForm.get('advocateLastName');
|
696
|
+
const advocateFirstNameControl = this.victimForm.get('advocateFirstName');
|
697
|
+
|
698
|
+
if ($event.value === "YS") {
|
699
|
+
this.advocateTabFlag = true;
|
700
|
+
advocateLastNameControl.setValidators(Validators.required);
|
701
|
+
advocateFirstNameControl.setValidators(Validators.required);
|
702
|
+
}
|
703
|
+
else{
|
704
|
+
this.advocateTabFlag = false;
|
705
|
+
advocateLastNameControl.clearValidators();
|
706
|
+
advocateFirstNameControl.clearValidators();
|
707
|
+
}
|
708
|
+
advocateLastNameControl.updateValueAndValidity();
|
709
|
+
advocateFirstNameControl.updateValueAndValidity();
|
710
|
+
|
711
|
+
}
|
712
|
+
|
713
|
+
radioCicChange($event: MatRadioChange){
|
714
|
+
if ($event.value === true) {
|
715
|
+
this.commonChildrenDivFlag = true;
|
716
|
+
// requrie field
|
717
|
+
this.setValidators('commonChildren');
|
718
|
+
}
|
719
|
+
else{
|
720
|
+
this.commonChildrenDivFlag = false;
|
721
|
+
}
|
722
|
+
}
|
723
|
+
|
724
|
+
setValidators(type) {
|
725
|
+
if(type == 'commonChildren'){
|
726
|
+
this.victimForm.get('commonChildrenNumber').clearValidators();
|
727
|
+
this.victimForm.get('commonChildrenNumber').setValidators(Validators.required);
|
728
|
+
}
|
729
|
+
else if (type == 'cpo'){
|
730
|
+
this.victimForm.get('cpoExpirationDate').clearValidators();
|
731
|
+
this.victimForm.get('cpoExpirationDate').setValidators(Validators.required);
|
732
|
+
|
733
|
+
}
|
734
|
+
}
|
735
|
+
radioSupportChange($event: MatRadioChange){
|
736
|
+
if ($event.value === true) {
|
737
|
+
this.supportInPlaceDivFlag = true;
|
738
|
+
}
|
739
|
+
else{
|
740
|
+
this.supportInPlaceDivFlag = false;
|
741
|
+
}
|
742
|
+
}
|
743
|
+
radioWeaponChange($event: MatRadioChange){
|
744
|
+
if ($event.value === true) {
|
745
|
+
this.weaponInvolvedDivFlag = true;
|
746
|
+
}
|
747
|
+
else{
|
748
|
+
this.weaponInvolvedDivFlag = false;
|
749
|
+
}
|
750
|
+
}
|
751
|
+
radioDrugChange($event: MatRadioChange){
|
752
|
+
if ($event.value === true) {
|
753
|
+
this.drugUseDivFlag = true;
|
754
|
+
}
|
755
|
+
else{
|
756
|
+
this.drugUseDivFlag = false;
|
757
|
+
}
|
758
|
+
}
|
759
|
+
|
760
|
+
radioCpoChange($event: MatRadioChange){
|
761
|
+
if ($event.value === true) {
|
762
|
+
this.cpoExpirationDivFlag = true;
|
763
|
+
this.setValidators('cpo');
|
764
|
+
}
|
765
|
+
else{
|
766
|
+
this.cpoExpirationDivFlag = false;
|
767
|
+
}
|
768
|
+
}
|
769
|
+
|
770
|
+
handleDOBChange($event ){
|
771
|
+
var ageDifMs = Date.now() - $event.value;
|
772
|
+
var ageDate = new Date(ageDifMs);
|
773
|
+
if( Math.abs(ageDate.getUTCFullYear() - 1970) <= 18){
|
774
|
+
|
775
|
+
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.', '', {
|
776
|
+
duration: 6000,});
|
777
|
+
const minorControl = this.victimForm.get('minorFlag');
|
778
|
+
minorControl.setValue(true);
|
779
|
+
this.guardianTabFlag = true;
|
780
|
+
}
|
781
|
+
|
782
|
+
}
|
783
|
+
checkOtherWeapon(WeaponUse){
|
784
|
+
|
785
|
+
const otherWeaponControl = this.victimForm.get('otherWeapon');
|
786
|
+
if (WeaponUse.includes("OTHER")){
|
787
|
+
this.otherWeaponFlag = true;
|
788
|
+
otherWeaponControl.setValidators(Validators.required)
|
789
|
+
|
790
|
+
}else{
|
791
|
+
this.otherWeaponFlag = false;
|
792
|
+
otherWeaponControl.clearValidators();
|
793
|
+
}
|
794
|
+
otherWeaponControl.updateValueAndValidity();
|
795
|
+
}
|
796
|
+
|
797
|
+
checkOtherDrug(DrugUse){
|
798
|
+
|
799
|
+
const otherDrugControl = this.victimForm.get('otherDrug');
|
800
|
+
if (DrugUse.includes("OTHER")){
|
801
|
+
this.otherDrugFlag = true;
|
802
|
+
otherDrugControl.setValidators(Validators.required)
|
803
|
+
|
804
|
+
|
805
|
+
}else{
|
806
|
+
this.otherDrugFlag = false;
|
807
|
+
otherDrugControl.clearValidators();
|
808
|
+
|
809
|
+
|
810
|
+
}
|
811
|
+
otherDrugControl.updateValueAndValidity();
|
812
|
+
}
|
813
|
+
|
814
|
+
//#region "save victim"
|
815
|
+
saveVictim() {
|
816
|
+
|
817
|
+
//guardian phone logic
|
818
|
+
if (!this.victimForm.value.guardianNoPhoneFlag)
|
819
|
+
{
|
820
|
+
if (this.guardianHomePhoneControl.value){
|
821
|
+
if (this.guardianHomePhoneControl.value !== null){
|
822
|
+
if (this.guardianHomePhoneControl.value !== ""){
|
823
|
+
this.guardianPhoneExistFlag = true;
|
824
|
+
}
|
825
|
+
}
|
826
|
+
}
|
827
|
+
|
828
|
+
|
829
|
+
|
830
|
+
if (this.guardianWorkPhoneControl.value !== undefined){
|
831
|
+
if (this.guardianWorkPhoneControl.value !== null){
|
832
|
+
if (this.guardianWorkPhoneControl.value !== ""){
|
833
|
+
this.guardianPhoneExistFlag = true;
|
834
|
+
}
|
835
|
+
}
|
836
|
+
}
|
837
|
+
|
838
|
+
|
839
|
+
if (this.guardianCellPhoneControl.value){
|
840
|
+
if (this.guardianCellPhoneControl.value!== null){
|
841
|
+
if (this.guardianCellPhoneControl.value !== ""){
|
842
|
+
this.guardianPhoneExistFlag = true;
|
843
|
+
}
|
844
|
+
}
|
845
|
+
}
|
846
|
+
|
847
|
+
}
|
848
|
+
|
849
|
+
console.log('this.victimForm.value.guardianNoPhoneFlag');
|
850
|
+
console.log(this.victimForm.value.guardianNoPhoneFlag);
|
851
|
+
console.log('this.guardianPhoneExistFlag');
|
852
|
+
console.log(this.guardianPhoneExistFlag);
|
853
|
+
|
854
|
+
|
855
|
+
if (this.guardianPhoneExistFlag === false && this.victimForm.value.guardianNoPhoneFlag === false)
|
856
|
+
{
|
857
|
+
this.phoneValidationFlag = true;
|
858
|
+
this.commonDialogService
|
859
|
+
.warning('', 'Please check the guardian phone field. You have to fill one of the three phone fileds.', 'Ok')
|
860
|
+
.subscribe(res => {this.result = res;
|
861
|
+
|
862
|
+
});
|
863
|
+
}
|
864
|
+
console.log('this.phoneValidationFlag');
|
865
|
+
console.log(this.phoneValidationFlag);
|
866
|
+
|
867
|
+
//advocate phone logic
|
868
|
+
if (!this.victimForm.value.advocateNoPhoneFlag)
|
869
|
+
{
|
870
|
+
if (this.advocateHomePhoneControl.value){
|
871
|
+
if (this.advocateHomePhoneControl.value !== null){
|
872
|
+
if (this.advocateHomePhoneControl.value !== ""){
|
873
|
+
this.advocatePhoneExistFlag = true;
|
874
|
+
}
|
875
|
+
}
|
876
|
+
}
|
877
|
+
|
878
|
+
|
879
|
+
|
880
|
+
if (this.advocateWorkPhoneControl.value !== undefined){
|
881
|
+
if (this.advocateWorkPhoneControl.value !== null){
|
882
|
+
if (this.advocateWorkPhoneControl.value !== ""){
|
883
|
+
this.advocatePhoneExistFlag = true;
|
884
|
+
}
|
885
|
+
}
|
886
|
+
}
|
887
|
+
|
888
|
+
|
889
|
+
if (this.advocateCellPhoneControl.value){
|
890
|
+
if (this.advocateCellPhoneControl.value !== null){
|
891
|
+
if (this.advocateCellPhoneControl.value !== ""){
|
892
|
+
this.advocatePhoneExistFlag = true;
|
893
|
+
}
|
894
|
+
}
|
895
|
+
}
|
896
|
+
|
897
|
+
}
|
898
|
+
|
899
|
+
console.log('this.victimForm.value.advocateNoPhoneFlag');
|
900
|
+
console.log(this.victimForm.value.advocateNoPhoneFlag);
|
901
|
+
console.log('this.advocatePhoneExistFlag');
|
902
|
+
console.log(this.advocatePhoneExistFlag);
|
903
|
+
|
904
|
+
if(this.advocatePhoneExistFlag === false && this.victimForm.value.advocateNoPhoneFlag === false)
|
905
|
+
{
|
906
|
+
|
907
|
+
this.phoneValidationFlag = true;
|
908
|
+
this.commonDialogService
|
909
|
+
.warning('', 'Please check the advocate phone field. You have to fill one of the three phone fileds.', 'Ok')
|
910
|
+
.subscribe(res => {this.result = res;
|
911
|
+
|
912
|
+
});
|
913
|
+
}
|
914
|
+
|
915
|
+
|
916
|
+
if (this.homePhoneControl.value){
|
917
|
+
this.victimForm.value.homePhone = this.homePhoneControl.value.replace(/[()\s-]/g, '');
|
918
|
+
}
|
919
|
+
else{
|
920
|
+
this.victimForm.value.homePhone = null;
|
921
|
+
}
|
922
|
+
|
923
|
+
if (this.cellPhoneControl.value){
|
924
|
+
this.victimForm.value.cellPhone = this.cellPhoneControl.value.replace(/[()\s-]/g, '') ;
|
925
|
+
}
|
926
|
+
else{
|
927
|
+
this.victimForm.value.cellPhone = null;
|
928
|
+
}
|
929
|
+
|
930
|
+
if (this.workPhoneControl.value){
|
931
|
+
this.victimForm.value.workPhone = this.workPhoneControl.value.replace(/[()\s-]/g, '');
|
932
|
+
}
|
933
|
+
else{
|
934
|
+
this.victimForm.value.workPhone= null;
|
935
|
+
}
|
936
|
+
|
937
|
+
if (this.guardianHomePhoneControl.value){
|
938
|
+
this.victimForm.value.guardianHomePhone = this.guardianHomePhoneControl.value.replace(/[()\s-]/g, '');
|
939
|
+
}
|
940
|
+
else{
|
941
|
+
this.victimForm.value.guardianHomePhone = null;
|
942
|
+
}
|
943
|
+
|
944
|
+
if (this.guardianCellPhoneControl.value){
|
945
|
+
this.victimForm.value.guardianCellPhone = this.guardianCellPhoneControl.value.replace(/[()\s-]/g, '');
|
946
|
+
}
|
947
|
+
else{
|
948
|
+
this.victimForm.value.guardianCellPhone = null;
|
949
|
+
}
|
950
|
+
|
951
|
+
if (this.guardianWorkPhoneControl.value){
|
952
|
+
this.victimForm.value.guardianWorkPhone = this.guardianWorkPhoneControl.value.replace(/[()\s-]/g, '');
|
953
|
+
}
|
954
|
+
else{
|
955
|
+
this.victimForm.value.guardianWorkPhone = null;
|
956
|
+
}
|
957
|
+
|
958
|
+
|
959
|
+
if (this.advocateHomePhoneControl.value){
|
960
|
+
this.victimForm.value.advocateHomePhone = this.advocateHomePhoneControl.value.replace(/[()\s-]/g, '')
|
961
|
+
}
|
962
|
+
else{
|
963
|
+
this.victimForm.value.advocateHomePhone = null;
|
964
|
+
}
|
965
|
+
|
966
|
+
if (this.advocateCellPhoneControl.value){
|
967
|
+
this.victimForm.value.advocateCellPhone = this.advocateCellPhoneControl.value.replace(/[()\s-]/g, '')
|
968
|
+
}
|
969
|
+
else{
|
970
|
+
this.victimForm.value.advocateCellPhone = null;
|
971
|
+
}
|
972
|
+
|
973
|
+
if (this.advocateWorkPhoneControl.value){
|
974
|
+
this.victimForm.value.advocateWorkPhone = this.advocateWorkPhoneControl.value.replace(/[()\s-]/g, '')
|
975
|
+
}
|
976
|
+
else{
|
977
|
+
this.victimForm.value.advocateWorkPhone = null;
|
978
|
+
}
|
979
|
+
|
980
|
+
|
981
|
+
if (this.emergencyContactPhoneControl.value){
|
982
|
+
this.victimForm.value.emergencyContactPhone = this.emergencyContactPhoneControl.value.replace(/[()\s-]/g, '')
|
983
|
+
}else{
|
984
|
+
this.victimForm.value.emergencyContactPhone = null;
|
985
|
+
}
|
986
|
+
//data process
|
987
|
+
|
988
|
+
console.log('this.phoneValidationFlag 1');
|
989
|
+
console.log(this.phoneValidationFlag);
|
990
|
+
if ( this.phoneValidationFlag === false){
|
991
|
+
if (this.victimDetail === null){
|
992
|
+
//insert new victim
|
993
|
+
|
994
|
+
var myVictimSupports = [];
|
995
|
+
if (this.victimForm.value.victimSupports){
|
996
|
+
this.victimForm.value.victimSupports.forEach(element => {
|
997
|
+
const victimSupport= <VictimSupport>{};
|
998
|
+
victimSupport.victimId= this.victimForm.value.victimId;
|
999
|
+
victimSupport.victimSupportTypeId= element;
|
1000
|
+
victimSupport.modifiedBy= this.staffId;
|
1001
|
+
myVictimSupports.push(victimSupport);
|
1002
|
+
});
|
1003
|
+
}
|
1004
|
+
|
1005
|
+
var myVictimDrugUses = [];
|
1006
|
+
console.log('this.victimForm.value.victimDrugUses during save');
|
1007
|
+
console.log(this.victimForm.value.victimDrugUses);
|
1008
|
+
if (this.victimForm.value.victimDrugUses){
|
1009
|
+
this.victimForm.value.victimDrugUses.forEach(element => {
|
1010
|
+
const victimDrugUse = <VictimDrugUse>{};
|
1011
|
+
victimDrugUse.drugTypeId = element;
|
1012
|
+
|
1013
|
+
if (element ==="OTHER" || element === "" || element === null){
|
1014
|
+
victimDrugUse.drugTypeId = null;
|
1015
|
+
victimDrugUse.otherDrug = this.victimForm.value.otherDrug;
|
1016
|
+
}
|
1017
|
+
else{
|
1018
|
+
victimDrugUse.drugTypeId = element;
|
1019
|
+
victimDrugUse.otherDrug = null;
|
1020
|
+
}
|
1021
|
+
|
1022
|
+
victimDrugUse.modifiedBy = this.staffId;
|
1023
|
+
victimDrugUse.victimId = this.victimForm.value.victimId;
|
1024
|
+
myVictimDrugUses.push(victimDrugUse);
|
1025
|
+
});
|
1026
|
+
}
|
1027
|
+
|
1028
|
+
console.log('this.victimForm.value.victimDrugUses during save 1');
|
1029
|
+
console.log(this.victimForm.value.victimDrugUses);
|
1030
|
+
|
1031
|
+
var myVictimWeaponUses = [];
|
1032
|
+
|
1033
|
+
if (this.victimForm.value.victimWeaponUses){
|
1034
|
+
this.victimForm.value.victimWeaponUses.forEach(element => {
|
1035
|
+
const victimWeaponUse = <VictimWeaponUse>{};
|
1036
|
+
victimWeaponUse.victimId= this.victimForm.value.victimId;
|
1037
|
+
victimWeaponUse.weaponTypeId= element;
|
1038
|
+
|
1039
|
+
if (element =="OTHER"){
|
1040
|
+
victimWeaponUse.otherWeapon = this.victimForm.value.otherWeapon;
|
1041
|
+
}
|
1042
|
+
else{
|
1043
|
+
victimWeaponUse.otherWeapon = null;
|
1044
|
+
}
|
1045
|
+
victimWeaponUse.modifiedBy= this.staffId;
|
1046
|
+
myVictimWeaponUses.push(victimWeaponUse);
|
1047
|
+
});
|
1048
|
+
}
|
1049
|
+
|
1050
|
+
const newVictim = {
|
1051
|
+
victimId: 0,
|
1052
|
+
offenderId: this.offenderId,
|
1053
|
+
victimOffenderRelationshipTypeId:
|
1054
|
+
this.victimForm.value.victimOffenderRelationshipTypeId,
|
1055
|
+
lastName: this.victimForm.value.lastName,
|
1056
|
+
firstName: this.victimForm.value.firstName,
|
1057
|
+
middleName: this.victimForm.value.middleName
|
1058
|
+
? this.victimForm.value.middleName
|
1059
|
+
: null,
|
1060
|
+
prefixId: this.victimForm.value.prefixId
|
1061
|
+
? this.victimForm.value.prefixId
|
1062
|
+
: null,
|
1063
|
+
suffixId: this.victimForm.value.suffixId
|
1064
|
+
? this.victimForm.value.suffixId
|
1065
|
+
: null,
|
1066
|
+
birthDate: this.victimForm.value.birthDate
|
1067
|
+
? this.victimForm.value.birthDate
|
1068
|
+
: null,
|
1069
|
+
genderCode: this.victimForm.value.genderCode
|
1070
|
+
? this.victimForm.value.genderCode
|
1071
|
+
: null,
|
1072
|
+
underSupervisionFlag: this.victimForm.value.underSupervisionFlag,
|
1073
|
+
minorFlag: this.victimForm.value.minorFlag,
|
1074
|
+
victimAdvocateFlag: this.victimForm.value.victimAdvocateFlag,
|
1075
|
+
|
1076
|
+
homePhone: this.victimForm.value.homePhone,
|
1077
|
+
workPhone: this.victimForm.value.workPhone,
|
1078
|
+
cellPhone: this.victimForm.value.cellPhone,
|
1079
|
+
email: this.victimForm.value.email ? this.victimForm.value.email : null,
|
1080
|
+
addressId: this.victimForm.value.addressId
|
1081
|
+
? this.victimForm.value.addressId
|
1082
|
+
: 1,
|
1083
|
+
emergencyContact: this.victimForm.value.emergencyContact
|
1084
|
+
? this.victimForm.value.emergencyContact
|
1085
|
+
: null,
|
1086
|
+
emergencyContactPhone: this.victimForm.value.emergencyContactPhone,
|
1087
|
+
commonChildrenFlag: this.victimForm.value.commonChildrenFlag,
|
1088
|
+
commonChildrenNumber: this.victimForm.value.commonChildrenNumber,
|
1089
|
+
cpoExpirationFlag: this.victimForm.value.cpoExpirationFlag,
|
1090
|
+
cpoExpirationDate: this.victimForm.value.cpoExpirationDate
|
1091
|
+
? this.datePipe.transform(this.victimForm.value.cpoExpirationDate, "short")
|
1092
|
+
: null,
|
1093
|
+
supportInPlaceFlag: this.victimForm.value.supportInPlaceFlag,
|
1094
|
+
weaponInvolvedFlag: this.victimForm.value.weaponInvolvedFlag,
|
1095
|
+
drugUseFlag: this.victimForm.value.drugUseFlag,
|
1096
|
+
alcoholUseFlag: this.victimForm.value.alcoholUseFlag,
|
1097
|
+
accessRisk: this.victimForm.value.accessRisk,
|
1098
|
+
modifiedBy: this.staffId,
|
1099
|
+
vVictimAdvocate: null,
|
1100
|
+
vVictimGuardian: null,
|
1101
|
+
victimDrugUses: myVictimDrugUses,
|
1102
|
+
victimSupports: myVictimSupports,
|
1103
|
+
victimWeaponUses: myVictimWeaponUses,
|
1104
|
+
|
1105
|
+
advocateFirstName: null,
|
1106
|
+
advocateLastName: null,
|
1107
|
+
advocateEmail: null,
|
1108
|
+
advocatePrefixId: null,
|
1109
|
+
advocateSuffixId: null,
|
1110
|
+
advocateNoPhoneFlag: null,
|
1111
|
+
advocateHomePhone: null,
|
1112
|
+
advocateWorkPhone: null,
|
1113
|
+
advocateCellPhone: null,
|
1114
|
+
advocateAddressId: null,
|
1115
|
+
guardianFirstName: null,
|
1116
|
+
guardianLastName: null,
|
1117
|
+
guardianEmail: null,
|
1118
|
+
guardianPrefixId: null,
|
1119
|
+
guardianSuffixId: null,
|
1120
|
+
guardianNoPhoneFlag: null,
|
1121
|
+
guardianHomePhone: null,
|
1122
|
+
guardianWorkPhone: null,
|
1123
|
+
guardianCellPhone: null,
|
1124
|
+
guardianAddressId: null,
|
1125
|
+
guardianBirthDate: null,
|
1126
|
+
relationship: null,
|
1127
|
+
//relationship: this.victimForm.value.victimOffenderRelationshipTypeId? this.victimForm.value.victimOffenderRelationshipTypeId : null,
|
1128
|
+
allowCsosaContactFlag: this.victimForm.value.allowCsosaContactFlag
|
1129
|
+
? this.victimForm.value.allowCsosaContactFlag
|
1130
|
+
: null,
|
1131
|
+
liveWithOffenderFlag: this.victimForm.value.liveWithOffenderFlag
|
1132
|
+
? this.victimForm.value.liveWithOffenderFlag
|
1133
|
+
: null,
|
1134
|
+
};
|
1135
|
+
|
1136
|
+
if (this.addressId == 0){
|
1137
|
+
newVictim.addressId = null;
|
1138
|
+
} else {
|
1139
|
+
newVictim.addressId = this.addressId;
|
1140
|
+
}
|
1141
|
+
|
1142
|
+
newVictim.advocateAddressId = this.advocateAddressId;
|
1143
|
+
newVictim.guardianAddressId = this.guardianAddressId;
|
1144
|
+
|
1145
|
+
|
1146
|
+
console.log('newVictim');
|
1147
|
+
console.log(newVictim);
|
1148
|
+
this.victimService.postVictims(newVictim).subscribe(
|
1149
|
+
(items: any) => {
|
1150
|
+
|
1151
|
+
const id = items ? items.victimId : '';
|
1152
|
+
|
1153
|
+
if (this.victimForm.value.victimAdvocateFlag == "YS"){
|
1154
|
+
|
1155
|
+
console.log('add advocate');
|
1156
|
+
const victimAdvocate: VictimAdvocate = {
|
1157
|
+
victimAdvocateId: id,
|
1158
|
+
lastName: this.victimForm.value.advocateLastName,
|
1159
|
+
firstName: this.victimForm.value.advocateFirstName,
|
1160
|
+
prefixId: this.victimForm.value.advocatePrefixId,
|
1161
|
+
suffixId: this.victimForm.value.advocateSuffixId,
|
1162
|
+
addressId: this.advocateAddressId ? this.advocateAddressId: null,
|
1163
|
+
noPhoneFlag: this.victimForm.value.advocateNoPhoneFlag ? this.victimForm.value.advocateNoPhoneFlag: null,
|
1164
|
+
homePhone: this.victimForm.value.advocateHomePhone,
|
1165
|
+
workPhone: this.victimForm.value.advocateWorkPhone,
|
1166
|
+
cellPhone: this.victimForm.value.advocateCellPhone,
|
1167
|
+
email: this.victimForm.value.advocateEmail,
|
1168
|
+
modifiedBy: this.staffId
|
1169
|
+
};
|
1170
|
+
|
1171
|
+
this.victimService.postVictimAdvocate(id, victimAdvocate).subscribe();
|
1172
|
+
}
|
1173
|
+
|
1174
|
+
if (this.victimForm.value.minorFlag == true){
|
1175
|
+
const victimGuardian: VictimGuardian = {
|
1176
|
+
victimGuardianId: id,
|
1177
|
+
lastName: this.victimForm.value.guardianLastName,
|
1178
|
+
firstName: this.victimForm.value.guardianFirstName,
|
1179
|
+
prefixId: this.victimForm.value.guardianPrefixId,
|
1180
|
+
suffixId: this.victimForm.value.guardianSuffixId,
|
1181
|
+
birthDate: this.victimForm.value.guardianBirthDate,
|
1182
|
+
addressId: this.guardianAddressId? this.guardianAddressId: null,
|
1183
|
+
noPhoneFlag: this.victimForm.value.guardianNoPhoneFlag? this.victimForm.value.guardianNoPhoneFlag: null,
|
1184
|
+
homePhone: this.victimForm.value.guardianHomePhone,
|
1185
|
+
workPhone: this.victimForm.value.guardianWorkPhone,
|
1186
|
+
cellPhone: this.victimForm.value.guardianCellPhone,
|
1187
|
+
email: this.victimForm.value.guardianEmail,
|
1188
|
+
modifiedBy: this.staffId
|
1189
|
+
};
|
1190
|
+
this.victimService.postVictimGuardian(id, victimGuardian).subscribe();
|
1191
|
+
}
|
1192
|
+
|
1193
|
+
this.snackBar.open('Add Victim Successfully!', '', {
|
1194
|
+
duration: 3000,
|
1195
|
+
});
|
1196
|
+
//insert new
|
1197
|
+
if (this.isIntake===true){
|
1198
|
+
this.router.navigate(['victimHome']);
|
1199
|
+
}
|
1200
|
+
else
|
1201
|
+
{
|
1202
|
+
this.router.navigate(['victimList']);
|
1203
|
+
}
|
1204
|
+
//this.onSave.emit(this.victimDetail);
|
1205
|
+
|
1206
|
+
}
|
1207
|
+
);
|
1208
|
+
|
1209
|
+
}
|
1210
|
+
else {
|
1211
|
+
//update victim
|
1212
|
+
this.victimDetail.underSupervisionFlag = this.victimForm.value.underSupervisionFlag;
|
1213
|
+
this.victimDetail.victimOffenderRelationshipTypeId = this.victimForm.value.victimOffenderRelationshipTypeId;
|
1214
|
+
this.victimDetail.lastName = this.victimForm.value.lastName;
|
1215
|
+
this.victimDetail.firstName = this.victimForm.value.firstName;
|
1216
|
+
this.victimDetail.middleName = this.victimForm.value.middleName;
|
1217
|
+
this.victimDetail.prefixId = this.victimForm.value.prefixId ? this.victimForm.value.prefixId : null;
|
1218
|
+
this.victimDetail.suffixId = this.victimForm.value.suffixId ? this.victimForm.value.suffixId : null;
|
1219
|
+
this.victimDetail.birthDate = this.victimForm.value.birthDate;
|
1220
|
+
this.victimDetail.genderCode = this.victimForm.value.genderCode;
|
1221
|
+
this.victimDetail.minorFlag = this.victimForm.value.minorFlag;
|
1222
|
+
this.victimDetail.homePhone = this.victimForm.value.homePhone;
|
1223
|
+
this.victimDetail.workPhone = this.victimForm.value.workPhone;
|
1224
|
+
this.victimDetail.cellPhone = this.victimForm.value.cellPhone;
|
1225
|
+
this.victimDetail.email = this.victimForm.value.email;
|
1226
|
+
this.victimDetail.victimAdvocateFlag = this.victimForm.value.victimAdvocateFlag;
|
1227
|
+
this.victimDetail.emergencyContact = this.victimForm.value.emergencyContact;
|
1228
|
+
this.victimDetail.emergencyContactPhone = this.victimForm.value.emergencyContactPhone;
|
1229
|
+
this.victimDetail.commonChildrenFlag = this.victimForm.value.commonChildrenFlag;
|
1230
|
+
this.victimDetail.commonChildrenNumber = this.victimForm.value.commonChildrenNumber;
|
1231
|
+
this.victimDetail.cpoExpirationDate = this.victimForm.value.cpoExpirationDate;
|
1232
|
+
this.victimDetail.cpoExpirationFlag = this.victimForm.value.cpoExpirationFlag;
|
1233
|
+
this.victimDetail.supportInPlaceFlag = this.victimForm.value.supportInPlaceFlag;
|
1234
|
+
this.victimDetail.weaponInvolvedFlag = this.victimForm.value.weaponInvolvedFlag;
|
1235
|
+
this.victimDetail.drugUseFlag = this.victimForm.value.drugUseFlag;
|
1236
|
+
this.victimDetail.alcoholUseFlag = this.victimForm.value.alcoholUseFlag;
|
1237
|
+
this.victimDetail.accessRisk = this.victimForm.value.accessRisk;
|
1238
|
+
this.victimDetail.addressId = this.addressId;
|
1239
|
+
this.victimDetail.allowCsosaContactFlag = this.victimForm.value.allowCsosaContactFlag;
|
1240
|
+
this.victimDetail.liveWithOffenderFlag = this.victimForm.value.liveWithOffenderFlag;
|
1241
|
+
|
1242
|
+
this.victimDetail.victimSupports = [];
|
1243
|
+
this.victimForm.value.victimSupports.forEach(element => {
|
1244
|
+
const victimSupport= <VictimSupport>{};
|
1245
|
+
victimSupport.victimId= this.victimDetail.victimId;
|
1246
|
+
victimSupport.victimSupportTypeId= element;
|
1247
|
+
victimSupport.modifiedBy= this.staffId;
|
1248
|
+
this.victimDetail.victimSupports.push(victimSupport);
|
1249
|
+
});
|
1250
|
+
|
1251
|
+
this.victimDetail.victimDrugUses = [];
|
1252
|
+
|
1253
|
+
this.victimForm.value.victimDrugUses.forEach(element => {
|
1254
|
+
const victimDrugUse = <VictimDrugUse>{};
|
1255
|
+
victimDrugUse.drugTypeId = element;
|
1256
|
+
console.log('this.victimForm.value.victimDrugUses before')
|
1257
|
+
console.log(this.victimForm.value.victimDrugUses)
|
1258
|
+
|
1259
|
+
if (element === "OTHER" || element === "" ){
|
1260
|
+
victimDrugUse.drugTypeId = null;
|
1261
|
+
victimDrugUse.otherDrug = this.victimForm.value.otherDrug;
|
1262
|
+
}
|
1263
|
+
else{
|
1264
|
+
victimDrugUse.drugTypeId = element;
|
1265
|
+
victimDrugUse.otherDrug = null;
|
1266
|
+
}
|
1267
|
+
|
1268
|
+
victimDrugUse.modifiedBy = this.staffId;
|
1269
|
+
victimDrugUse.victimId = this.victimDetail.victimId;
|
1270
|
+
this.victimDetail.victimDrugUses.push(victimDrugUse);
|
1271
|
+
|
1272
|
+
});
|
1273
|
+
this.victimForm.value.victimDrugUses.filter(word => ( !(word.drugTypeId === null && word.otherDrug === null) ));
|
1274
|
+
|
1275
|
+
this.victimDetail.victimWeaponUses = [];
|
1276
|
+
this.victimForm.value.victimWeaponUses.forEach(element => {
|
1277
|
+
const victimWeaponUse = <VictimWeaponUse>{};
|
1278
|
+
victimWeaponUse.victimId= this.victimDetail.victimId;
|
1279
|
+
victimWeaponUse.weaponTypeId= element;
|
1280
|
+
|
1281
|
+
if (element =="OTHER"){
|
1282
|
+
victimWeaponUse.otherWeapon=this.victimForm.value.otherWeapon;
|
1283
|
+
}
|
1284
|
+
else{
|
1285
|
+
victimWeaponUse.otherWeapon = null;
|
1286
|
+
}
|
1287
|
+
|
1288
|
+
victimWeaponUse.modifiedBy= this.staffId;
|
1289
|
+
this.victimDetail.victimWeaponUses.push(victimWeaponUse);
|
1290
|
+
|
1291
|
+
});
|
1292
|
+
|
1293
|
+
console.log('this.victimDetail before emit');
|
1294
|
+
console.log(this.victimDetail);
|
1295
|
+
|
1296
|
+
|
1297
|
+
this.victimService.putVictims(this.victimDetail.victimId,this.victimDetail).subscribe(
|
1298
|
+
(items: any) => {
|
1299
|
+
this.snackBar.open('Update Successfully!', '', {
|
1300
|
+
duration: 3000,
|
1301
|
+
});
|
1302
|
+
//Advocate section
|
1303
|
+
this.victimAdvocate.victimAdvocateId = this.victimDetail.victimId;
|
1304
|
+
this.victimAdvocate.lastName= this.victimForm.value.advocateLastName;
|
1305
|
+
this.victimAdvocate.firstName= this.victimForm.value.advocateFirstName;
|
1306
|
+
this.victimAdvocate.prefixId= this.victimForm.value.advocatePrefixId ? this.victimForm.value.advocatePrefixId : null;
|
1307
|
+
this.victimAdvocate.suffixId= this.victimForm.value.advocateSuffixId ? this.victimForm.value.advocateSuffixId : null;
|
1308
|
+
this.victimAdvocate.addressId= this.advocateAddressId ? this.advocateAddressId : null;
|
1309
|
+
this.victimAdvocate.noPhoneFlag= this.victimForm.value.advocateNoPhoneFlag? true: false;
|
1310
|
+
this.victimAdvocate.homePhone= this.victimForm.value.advocateHomePhone;
|
1311
|
+
this.victimAdvocate.workPhone= this.victimForm.value.advocateWorkPhone;
|
1312
|
+
this.victimAdvocate.cellPhone= this.victimForm.value.advocateCellPhone;
|
1313
|
+
this.victimAdvocate.email= this.victimForm.value.advocateEmail ? this.victimForm.value.advocateEmail : null;
|
1314
|
+
this.victimAdvocate.modifiedBy= this.staffId;
|
1315
|
+
|
1316
|
+
console.log('work on advocate part');
|
1317
|
+
if (this.victimDetail.victimAdvocateFlag=='YS')
|
1318
|
+
{
|
1319
|
+
console.log('work on advocate flag is YS ');
|
1320
|
+
if(this.victimDetail.advocateFirstName != null){
|
1321
|
+
console.log('check advocate fisrt name ');
|
1322
|
+
console.log(this.victimDetail.advocateFirstName);
|
1323
|
+
this.victimService.putVictimAdvocate(this.victimDetail.victimId,this.victimAdvocate).subscribe(
|
1324
|
+
resp=>{} );
|
1325
|
+
}
|
1326
|
+
else
|
1327
|
+
{
|
1328
|
+
console.log('add advocate');
|
1329
|
+
console.log(this.victimAdvocate);
|
1330
|
+
this.victimService.postVictimAdvocate(this.victimDetail.victimId, this.victimAdvocate).subscribe();
|
1331
|
+
}
|
1332
|
+
}
|
1333
|
+
|
1334
|
+
// guardian section
|
1335
|
+
this.victimGuardian.victimGuardianId = this.victimDetail.victimId;
|
1336
|
+
this.victimGuardian.lastName = this.victimForm.value.guardianLastName;
|
1337
|
+
this.victimGuardian.firstName = this.victimForm.value.guardianFirstName;
|
1338
|
+
this.victimGuardian.prefixId = this.victimForm.value.guardianPrefixId ? this.victimForm.value.guardianPrefixId : null;
|
1339
|
+
this.victimGuardian.suffixId = this.victimForm.value.guardianSuffixId ? this.victimForm.value.guardianSuffixId : null;
|
1340
|
+
this.victimGuardian.addressId = this.guardianAddressId ? this.guardianAddressId : null;
|
1341
|
+
this.victimGuardian.noPhoneFlag = this.victimForm.value.guardianNoPhoneFlag? true: false;
|
1342
|
+
this.victimGuardian.homePhone = this.victimForm.value.guardianHomePhone;
|
1343
|
+
this.victimGuardian.workPhone = this.victimForm.value.guardianWorkPhone;
|
1344
|
+
this.victimGuardian.cellPhone = this.victimForm.value.guardianCellPhone;
|
1345
|
+
this.victimGuardian.email = this.victimForm.value.guardianEmail ? this.victimForm.value.guardianEmail : null;
|
1346
|
+
this.victimGuardian.modifiedBy = this.staffId;
|
1347
|
+
|
1348
|
+
if (this.victimDetail.minorFlag == true)
|
1349
|
+
{
|
1350
|
+
if(this.victimDetail.guardianFirstName != null )
|
1351
|
+
this.victimService.putVictimGuardian(this.victimDetail.victimId,this.victimGuardian).subscribe(
|
1352
|
+
resp=>{
|
1353
|
+
}
|
1354
|
+
);
|
1355
|
+
else
|
1356
|
+
{
|
1357
|
+
console.log('add gurdian');
|
1358
|
+
console.log(this.victimGuardian);
|
1359
|
+
this.victimService.postVictimGuardian(this.victimDetail.victimId, this.victimGuardian).subscribe();
|
1360
|
+
}
|
1361
|
+
|
1362
|
+
}
|
1363
|
+
}
|
1364
|
+
|
1365
|
+
);
|
1366
|
+
|
1367
|
+
}
|
1368
|
+
}//end of this.phoneValidationFlag = false
|
1369
|
+
|
1370
|
+
console.log('this.victimDetail');
|
1371
|
+
console.log(this.victimDetail);
|
1372
|
+
this.onSave.emit(this.victimDetail);
|
1373
|
+
}
|
1374
|
+
|
1375
|
+
//#endregion "save victim"
|
1376
|
+
addContact(){
|
1377
|
+
this.router.navigate(['victimContact',this.victimId]);
|
1378
|
+
}
|
1379
|
+
formatLabel(value: number) {
|
1380
|
+
return value;
|
1381
|
+
}
|
1382
|
+
|
1383
|
+
|
1384
|
+
}
|