From 0ada54409ae7968a1a7b529afb1dd9dd7b6552ee Mon Sep 17 00:00:00 2001 From: 5Amogh Date: Tue, 16 Dec 2025 16:20:10 +0530 Subject: [PATCH 01/13] fix: amm-1990, 1985, 1972, 1982, 1989, 1983, 1987,1986 --- .../create-family-tagging.component.html | 2 +- .../consent-form/consent-form.component.html | 6 +-- .../location-information.component.html | 49 ++++++++++++------- .../registration/registration.component.html | 26 +++++----- .../search-dialog.component.html | 2 +- 5 files changed, 48 insertions(+), 37 deletions(-) diff --git a/src/registrar/family-tagging/create-family-tagging/create-family-tagging.component.html b/src/registrar/family-tagging/create-family-tagging/create-family-tagging.component.html index 95fcea8..15d51de 100644 --- a/src/registrar/family-tagging/create-family-tagging/create-family-tagging.component.html +++ b/src/registrar/family-tagging/create-family-tagging/create-family-tagging.component.html @@ -114,7 +114,7 @@

{{ currentLanguageSet?.createFamilyTagging }}

- + diff --git a/src/registrar/registration/location-information/location-information.component.html b/src/registrar/registration/location-information/location-information.component.html index 726cfc5..6e45106 100644 --- a/src/registrar/registration/location-information/location-information.component.html +++ b/src/registrar/registration/location-information/location-information.component.html @@ -7,15 +7,16 @@ *ngIf="item?.fieldType?.toLowerCase() === 'text'" > - {{ item.fieldTitle }} + {{ item.fieldTitle | titlecase }} + formControlName="{{ item.fieldName }}" + /> @@ -75,16 +76,16 @@ - {{ item.fieldTitle }} + {{ item.fieldTitle | titlecase }} - {{ option }} + {{ option | titlecase }} @@ -110,18 +111,22 @@ *ngFor="let option of item.options" [value]="option" > - {{ option }} + {{ option | titlecase }} -
- - - {{ item.fieldTitle }} +
+ + {{ item.fieldTitle | titlecase }} - - - - {{ option }} + + + {{ option | titlecase }}
- +
diff --git a/src/registrar/registration/registration.component.html b/src/registrar/registration/registration.component.html index ee5612e..f15623e 100644 --- a/src/registrar/registration/registration.component.html +++ b/src/registrar/registration/registration.component.html @@ -18,15 +18,16 @@ - Personal Information + {{currentLanguageSet?.ro?.personalInfo?.personalInformation}} - Personal Information + {{currentLanguageSet?.ro?.personalInfo?.personalInformation}} + [formData]="personalInfoData" [patientRevisit]="patientRevisit" [revisitData]="revisitData" + [currentLanguageSet]="currentLanguageSet">
@@ -41,15 +42,15 @@ - Location Information + {{currentLanguageSet?.ro?.locInfo?.locInformation}} - Location Information + {{currentLanguageSet?.ro?.locInfo?.locInformation}} + [formData]="locationInfoData" [currentLanguageSet]="currentLanguageSet">
@@ -66,15 +67,15 @@ - Other Information + {{currentLanguageSet?.ro?.otherInfo?.otherInformation}} - Other Information + {{currentLanguageSet?.ro?.otherInfo?.otherInformation}} + [formData]="otherInfoData" [currentLanguageSet]="currentLanguageSet">
@@ -92,14 +93,15 @@ - ABHA Information + {{currentLanguageSet?.ro?.abhaInfo?.abhaInformation}} - ABHA Information + {{currentLanguageSet?.ro?.abhaInfo?.abhaInformation}} - +
diff --git a/src/registrar/search-dialog/search-dialog.component.html b/src/registrar/search-dialog/search-dialog.component.html index d870741..57f388d 100644 --- a/src/registrar/search-dialog/search-dialog.component.html +++ b/src/registrar/search-dialog/search-dialog.component.html @@ -135,7 +135,7 @@

{{ currentLanguageSet?.common?.advanceBeneficiarySearch }}

- {{ currentLanguageSet?.village }} + {{ currentLanguageSet?.ro?.locInfo?.village }} From f45369358ebf0c9c57deee0a39482022a1007849 Mon Sep 17 00:00:00 2001 From: 5Amogh Date: Thu, 18 Dec 2025 14:11:39 +0530 Subject: [PATCH 02/13] remove langauge input which the components were not expecting --- src/registrar/registration/registration.component.html | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/registrar/registration/registration.component.html b/src/registrar/registration/registration.component.html index f15623e..ed7d4a9 100644 --- a/src/registrar/registration/registration.component.html +++ b/src/registrar/registration/registration.component.html @@ -27,7 +27,7 @@ + >
@@ -50,7 +50,7 @@ + [formData]="locationInfoData">
@@ -75,7 +75,7 @@ + [formData]="otherInfoData">
@@ -100,8 +100,7 @@ {{currentLanguageSet?.ro?.abhaInfo?.abhaInformation}} - +
From 20a21fc58bac618d8acbee1453e1699176603921 Mon Sep 17 00:00:00 2001 From: SnehaRH Date: Fri, 19 Dec 2025 14:51:46 +0530 Subject: [PATCH 03/13] fix: elastic search changes --- src/registrar/search/search.component.html | 9 +- src/registrar/search/search.component.ts | 177 +++++++++++++++++++- src/registrar/services/registrar.service.ts | 8 + 3 files changed, 185 insertions(+), 9 deletions(-) diff --git a/src/registrar/search/search.component.html b/src/registrar/search/search.component.html index 083e407..7622138 100644 --- a/src/registrar/search/search.component.html +++ b/src/registrar/search/search.component.html @@ -9,12 +9,13 @@
-
+
\ No newline at end of file diff --git a/src/registrar/search/search.component.ts b/src/registrar/search/search.component.ts index 814ea12..ade2baf 100644 --- a/src/registrar/search/search.component.ts +++ b/src/registrar/search/search.component.ts @@ -27,6 +27,7 @@ import { ViewChild, DoCheck, AfterViewChecked, + OnDestroy, } from '@angular/core'; import { Router, ActivatedRoute } from '@angular/router'; import { SearchDialogComponent } from '../search-dialog/search-dialog.component'; @@ -45,6 +46,8 @@ import * as moment from 'moment'; import { environment } from 'src/environments/environment'; import { SessionStorageService } from '../services/session-storage.service'; import { HealthIdDisplayModalComponent } from '../abha-components/health-id-display-modal/health-id-display-modal.component'; +import { Subject } from 'rxjs'; +import { debounceTime, distinctUntilChanged, switchMap } from 'rxjs/operators'; export interface Consent { consentGranted: string; @@ -55,7 +58,7 @@ export interface Consent { templateUrl: './search.component.html', styleUrls: ['./search.component.css'], }) -export class SearchComponent implements OnInit, DoCheck, AfterViewChecked { +export class SearchComponent implements OnInit, DoCheck, AfterViewChecked, OnDestroy { rowsPerPage = 5; activePage = 1; pagedList = []; @@ -69,6 +72,7 @@ export class SearchComponent implements OnInit, DoCheck, AfterViewChecked { currentLanguageSet: any; searchPattern!: string; consentGranted: any; + isEnableES: boolean = false; displayedColumns: string[] = [ 'edit', 'beneficiaryID', @@ -86,6 +90,10 @@ export class SearchComponent implements OnInit, DoCheck, AfterViewChecked { dataSource = new MatTableDataSource(); searchCategory: any; + // Add these for debounced search + private searchSubject$ = new Subject(); + private searchSubscription: any; + constructor( private changeDetectorRef: ChangeDetectorRef, private dialog: MatDialog, @@ -94,20 +102,178 @@ export class SearchComponent implements OnInit, DoCheck, AfterViewChecked { private registrarService: RegistrarService, private cameraService: CameraService, private router: Router, - private sessionstorage:SessionStorageService, + private sessionstorage: SessionStorageService, private beneficiaryDetailsService: BeneficiaryDetailsService, ) {} ngOnInit() { this.fetchLanguageResponse(); - this.searchPattern = '/^[a-zA-Z0-9](.|@|-)*$/;'; + this.isEnableES = environment.isEnableES || false; + console.log("IsEnable:", this.isEnableES); + + + this.searchPattern = this.isEnableES ? '/^[a-zA-Z0-9]*$/;' : '/^[a-zA-Z0-9](.|@|-)*$/;'; + if (this.isEnableES) { + this.setupDebouncedSearch(); + } } ngAfterViewChecked() { this.changeDetectorRef.detectChanges(); } + ngOnDestroy() { + if (this.searchSubscription) { + this.searchSubscription.unsubscribe(); + } + } + + // Setup debounced search for typing + setupDebouncedSearch() { + this.searchSubscription = this.searchSubject$ + .pipe( + debounceTime(500), // 500ms delay after typing stops + distinctUntilChanged(), // Only emit if value changed + switchMap((searchTerm: string) => { + console.log('switchMap called with:', searchTerm); // Debug log + // Validate alphanumeric + const alphanumericPattern = /^[a-zA-Z0-9]*$/; + if (!alphanumericPattern.test(searchTerm)) { + this.confirmationService.alert( + 'Please enter valid alphanumeric input', + 'info' + ); + return []; + } + console.log('Calling API with:', { search: searchTerm }); // Debug log + // Call new ES API + return this.registrarService.identityQuickSearchES({ search: searchTerm }); + }) + ) + .subscribe( + (response: any) => { + console.log('API Response:', response); // Debug log + this.handleESSearchResponse(response); + }, + (error: any) => { + console.error('API Error:', error); // Debug log + this.confirmationService.alert(error, 'error'); + } + ); + } + + // Method to handle input changes with debounce (for typing) + onSearchInputChange(searchTerm: string) { + console.log('common UI onSearchInputChange called with:', searchTerm); // Debug log + const trimmed = searchTerm?.trim() || ''; + console.log('Trimmed length:', trimmed.length); // Debug log + if (trimmed.length >= 3) { + console.log('Emitting to searchSubject$'); // Debug log + this.searchSubject$.next(trimmed); + } else if (trimmed.length === 0) { + this.resetWorklist(); + } + } + + // Method for search button click (immediate search, no debounce) + onSearchButtonClick(searchTerm: any) { + if (this.isEnableES) { + // ES Flow: Immediate search with alphanumeric validation + console.log('ES: Button click with:', searchTerm); + if (!searchTerm || searchTerm.trim().length < 3) { + this.confirmationService.alert( + 'Please enter at least 3 characters', + 'info' + ); + this.resetWorklist(); + return; + } + + const trimmed = searchTerm.trim(); + const alphanumericPattern = /^[a-zA-Z0-9]*$/; + if (!alphanumericPattern.test(trimmed)) { + this.confirmationService.alert( + 'Please enter valid alphanumeric input', + 'info' + ); + return; + } + + console.log('ES: Calling API directly with:', { search: trimmed }); + this.registrarService.identityQuickSearchES({ search: trimmed }) + .subscribe( + (response: any) => { + console.log('ES: Button API Response:', response); + this.handleESSearchResponse(response); + }, + (error: any) => { + console.error('ES: Button API Error:', error); + this.confirmationService.alert(error, 'error'); + } + ); + } else { + // Old Flow: Use existing identityQuickSearch method + console.log('Old API: Button click with:', searchTerm); + this.identityQuickSearch(searchTerm); + } + } + + + // Common method to handle ES API response + handleESSearchResponse(response: any) { + if (!response?.data || response.data.length === 0) { + this.resetWorklist(); + this.confirmationService.alert( + this.currentLanguageSet?.alerts?.info?.beneficiarynotfound || 'Beneficiary not found', + 'info' + ); + } else { + this.beneficiaryList = this.searchRestructES(response.data); + this.filteredBeneficiaryList = this.beneficiaryList; + this.dataSource.data = this.beneficiaryList; + this.dataSource.paginator = this.paginator; + console.log('Updated dataSource:', this.dataSource.data); // Debug log + this.changeDetectorRef.detectChanges(); + } + } + + // Restructure ES API response + searchRestructES(benList: any[]) { + const requiredBenData: any[] = []; + benList.forEach((element: any) => { + requiredBenData.push({ + beneficiaryID: element.beneficiaryID, + beneficiaryRegID: element.beneficiaryRegID, + benName: `${element.firstName} ${element.lastName || ''}`, + genderName: element.m_gender?.genderName || element.genderName || 'Not Available', + fatherName: element.fatherName || 'Not Available', + districtName: element.i_bendemographics?.districtName || 'Not Available', + villageName: element.i_bendemographics?.villageName || + element.i_bendemographics?.districtBranchName || 'Not Available', + phoneNo: element.benPhoneMaps?.[0]?.phoneNo || 'Not Available', + age: moment(element.dob || element.dOB).fromNow(true) === 'a few seconds' + ? 'Not Available' + : moment(element.dob || element.dOB).fromNow(true), + registeredOn: moment(element.createdDate).format('DD-MM-YYYY'), + benObject: element, + }); + }); + console.log('Restructured data:', requiredBenData); // Debug log + return requiredBenData; + } + + // Reset worklist + resetWorklist() { + this.beneficiaryList = []; + this.filteredBeneficiaryList = []; + this.dataSource.data = []; + this.pagedList = []; + } + + // Keep old method for backward compatibility (used in advanced search, etc.) identityQuickSearch(searchTerm: any) { + console.log("Entered old search"); + const searchObject = { beneficiaryRegID: null, beneficiaryID: null, @@ -242,7 +408,7 @@ export class SearchComponent implements OnInit, DoCheck, AfterViewChecked { } getCorrectPhoneNo(phoneMaps: any[], benObject: any): string { - if (!phoneMaps.length) { + if (!phoneMaps || !phoneMaps.length) { return 'Not Available'; } @@ -429,6 +595,7 @@ export class SearchComponent implements OnInit, DoCheck, AfterViewChecked { } }); } + navigateTORegistrar() { const link = '/registrar/registration'; const currentRoute = this.router.routerState.snapshot.url; @@ -469,4 +636,4 @@ export class SearchComponent implements OnInit, DoCheck, AfterViewChecked { this.currentLanguageSet = this.languageComponent.currentLanguageObject; } //--End-- -} +} \ No newline at end of file diff --git a/src/registrar/services/registrar.service.ts b/src/registrar/services/registrar.service.ts index 640429f..aa55910 100644 --- a/src/registrar/services/registrar.service.ts +++ b/src/registrar/services/registrar.service.ts @@ -121,6 +121,14 @@ export class RegistrarService { return this.http.post(environment.identityQuickSearchUrl, searchTerm); } + identityQuickSearchES(searchTerm: any) { + // const requestBody = { + // search: searchTerm + // }; + console.log("entered elastic search"); + + return this.http.post(environment.elasticSearchUrl, searchTerm); + } clearBeneficiaryEditDetails() { this.beneficiaryEditDetails.next(null); } From ef7fa1a5ae31600081b4ef11a6470e57fd8fbffa Mon Sep 17 00:00:00 2001 From: SnehaRH Date: Fri, 19 Dec 2025 18:44:43 +0530 Subject: [PATCH 04/13] fix: handled placeholder value --- src/registrar/search/search.component.html | 2 +- src/registrar/services/registrar.service.ts | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/registrar/search/search.component.html b/src/registrar/search/search.component.html index 7622138..aee7d32 100644 --- a/src/registrar/search/search.component.html +++ b/src/registrar/search/search.component.html @@ -11,7 +11,7 @@ id="searchbox" pattern="[a-zA-Z0-9]*" maxlength="32" - placeholder="{{ currentLanguageSet?.ro?.benIDOrPhNo }}" + placeholder="{{ isEnableES ? currentLanguageSet?.ro?.benIDOrPhNo : currentLanguageSet?.ro?.benIDOrPhNo }}" class="pull-left search_textbox" [(ngModel)]="quicksearchTerm" (ngModelChange)="onSearchInputChange($event)" diff --git a/src/registrar/services/registrar.service.ts b/src/registrar/services/registrar.service.ts index aa55910..b9cfef8 100644 --- a/src/registrar/services/registrar.service.ts +++ b/src/registrar/services/registrar.service.ts @@ -122,12 +122,7 @@ export class RegistrarService { } identityQuickSearchES(searchTerm: any) { - // const requestBody = { - // search: searchTerm - // }; - console.log("entered elastic search"); - - return this.http.post(environment.elasticSearchUrl, searchTerm); + return this.http.post(environment.elasticSearchUrl, searchTerm); } clearBeneficiaryEditDetails() { this.beneficiaryEditDetails.next(null); From 09f42028ac5f9fc8ec307ade87da13fe4ef53818 Mon Sep 17 00:00:00 2001 From: SnehaRH Date: Fri, 19 Dec 2025 18:53:05 +0530 Subject: [PATCH 05/13] fix: removed unwanted logs --- src/registrar/search/search.component.ts | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/src/registrar/search/search.component.ts b/src/registrar/search/search.component.ts index ade2baf..f216f70 100644 --- a/src/registrar/search/search.component.ts +++ b/src/registrar/search/search.component.ts @@ -135,7 +135,6 @@ export class SearchComponent implements OnInit, DoCheck, AfterViewChecked, OnDes debounceTime(500), // 500ms delay after typing stops distinctUntilChanged(), // Only emit if value changed switchMap((searchTerm: string) => { - console.log('switchMap called with:', searchTerm); // Debug log // Validate alphanumeric const alphanumericPattern = /^[a-zA-Z0-9]*$/; if (!alphanumericPattern.test(searchTerm)) { @@ -145,18 +144,14 @@ export class SearchComponent implements OnInit, DoCheck, AfterViewChecked, OnDes ); return []; } - console.log('Calling API with:', { search: searchTerm }); // Debug log - // Call new ES API return this.registrarService.identityQuickSearchES({ search: searchTerm }); }) ) .subscribe( (response: any) => { - console.log('API Response:', response); // Debug log this.handleESSearchResponse(response); }, (error: any) => { - console.error('API Error:', error); // Debug log this.confirmationService.alert(error, 'error'); } ); @@ -164,22 +159,16 @@ export class SearchComponent implements OnInit, DoCheck, AfterViewChecked, OnDes // Method to handle input changes with debounce (for typing) onSearchInputChange(searchTerm: string) { - console.log('common UI onSearchInputChange called with:', searchTerm); // Debug log const trimmed = searchTerm?.trim() || ''; - console.log('Trimmed length:', trimmed.length); // Debug log if (trimmed.length >= 3) { - console.log('Emitting to searchSubject$'); // Debug log this.searchSubject$.next(trimmed); } else if (trimmed.length === 0) { this.resetWorklist(); } } - // Method for search button click (immediate search, no debounce) onSearchButtonClick(searchTerm: any) { if (this.isEnableES) { - // ES Flow: Immediate search with alphanumeric validation - console.log('ES: Button click with:', searchTerm); if (!searchTerm || searchTerm.trim().length < 3) { this.confirmationService.alert( 'Please enter at least 3 characters', @@ -199,21 +188,16 @@ export class SearchComponent implements OnInit, DoCheck, AfterViewChecked, OnDes return; } - console.log('ES: Calling API directly with:', { search: trimmed }); this.registrarService.identityQuickSearchES({ search: trimmed }) .subscribe( (response: any) => { - console.log('ES: Button API Response:', response); this.handleESSearchResponse(response); }, (error: any) => { - console.error('ES: Button API Error:', error); this.confirmationService.alert(error, 'error'); } ); } else { - // Old Flow: Use existing identityQuickSearch method - console.log('Old API: Button click with:', searchTerm); this.identityQuickSearch(searchTerm); } } @@ -232,7 +216,6 @@ export class SearchComponent implements OnInit, DoCheck, AfterViewChecked, OnDes this.filteredBeneficiaryList = this.beneficiaryList; this.dataSource.data = this.beneficiaryList; this.dataSource.paginator = this.paginator; - console.log('Updated dataSource:', this.dataSource.data); // Debug log this.changeDetectorRef.detectChanges(); } } @@ -270,10 +253,8 @@ export class SearchComponent implements OnInit, DoCheck, AfterViewChecked, OnDes this.pagedList = []; } - // Keep old method for backward compatibility (used in advanced search, etc.) identityQuickSearch(searchTerm: any) { - console.log("Entered old search"); - + const searchObject = { beneficiaryRegID: null, beneficiaryID: null, From fb6b49b0eb2789803931fc72eee1ccc1f7c75e08 Mon Sep 17 00:00:00 2001 From: SnehaRH Date: Mon, 29 Dec 2025 18:12:53 +0530 Subject: [PATCH 06/13] fix: 2038 integrated elastic search and advance es --- .../beneficiary-details.component.ts | 103 +++++++++++---- .../family-tagging-details.component.ts | 54 ++++++-- .../personal-information.component.ts | 125 ++++++++++++------ src/registrar/search/search.component.html | 5 +- src/registrar/search/search.component.ts | 73 +++++++--- src/registrar/services/registrar.service.ts | 5 + 6 files changed, 266 insertions(+), 99 deletions(-) diff --git a/src/registrar/beneficiary-details/beneficiary-details.component.ts b/src/registrar/beneficiary-details/beneficiary-details.component.ts index 938470f..228e4f8 100644 --- a/src/registrar/beneficiary-details/beneficiary-details.component.ts +++ b/src/registrar/beneficiary-details/beneficiary-details.component.ts @@ -37,6 +37,7 @@ import { import { HttpServiceService } from 'src/app/app-modules/core/services/http-service.service'; import { RegistrarService } from '../services/registrar.service'; import { SessionStorageService } from '../services/session-storage.service'; +import { environment } from 'src/environments/environment'; @Component({ selector: 'app-beneficiary-details', @@ -61,6 +62,7 @@ export class BeneficiaryDetailsComponent implements OnInit, DoCheck, OnDestroy { firstName: any; lastName: any; regDate: any; + isEnableES: boolean = false; constructor( private router: Router, @@ -73,6 +75,7 @@ export class BeneficiaryDetailsComponent implements OnInit, DoCheck, OnDestroy { ) {} ngOnInit() { + this.isEnableES = environment.isEnableES || false; this.assignSelectedLanguage(); this.today = new Date(); this.getHealthIDDetails(); @@ -134,34 +137,80 @@ export class BeneficiaryDetailsComponent implements OnInit, DoCheck, OnDestroy { }); } - getBenFamilyDetails() { + getBenFamilyDetails() { this.route.params.subscribe((param) => { - const reqObj = { - beneficiaryRegID: null, - beneficiaryName: null, - beneficiaryID: param['beneficiaryId'], - phoneNo: null, - HealthID: null, - HealthIDNumber: null, - familyId: null, - identity: null, - }; - this.registrarService - .identityQuickSearch(reqObj) - .subscribe((res: any) => { - if (res && res.data.length === 1) { - this.beneficiary = res.data[0]; - this.benFamilyId = res.data[0].familyId; - this.beneficiaryName = - this.beneficiary.firstName + - (this.beneficiary.lastName !== undefined - ? ' ' + this.beneficiary.lastName - : ''); - this.regDate = moment - .utc(this.beneficiary.createdDate) - .format('DD-MM-YYYY hh:mm A'); - } - }); + if (this.isEnableES) { + // Use Elasticsearch search + const searchTerm = param['beneficiaryId']; + this.registrarService + .identityQuickSearchES({ search: searchTerm }) + .subscribe( + (res: any) => { + if (res && res.data && res.data.length === 1) { + this.beneficiary = res.data[0]; + this.benFamilyId = res.data[0].familyID || res.data[0].familyId; + this.beneficiaryName = + this.beneficiary.firstName + + (this.beneficiary.lastName !== undefined && + this.beneficiary.lastName !== null && + this.beneficiary.lastName !== '' + ? ' ' + this.beneficiary.lastName + : ''); + this.regDate = moment + .utc(this.beneficiary.createdDate) + .format('DD-MM-YYYY hh:mm A'); + } else if (res && res.data && res.data.length > 1) { + // Multiple results found + this.confirmationService.alert( + 'Multiple beneficiaries found with this ID. Please use advanced search.', + 'info', + ); + } else { + this.confirmationService.alert( + this.current_language_set?.alerts?.info?.beneficiarynotfound || + 'Beneficiary not found', + 'info', + ); + } + }, + (err: any) => { + this.confirmationService.alert( + 'Error fetching beneficiary details', + 'error', + ); + }, + ); + } else { + // Use traditional search + const reqObj = { + beneficiaryRegID: null, + beneficiaryName: null, + beneficiaryID: param['beneficiaryId'], + phoneNo: null, + HealthID: null, + HealthIDNumber: null, + familyId: null, + identity: null, + }; + this.registrarService + .identityQuickSearch(reqObj) + .subscribe((res: any) => { + if (res && res.data.length === 1) { + this.beneficiary = res.data[0]; + this.benFamilyId = res.data[0].familyId; + this.beneficiaryName = + this.beneficiary.firstName + + (this.beneficiary.lastName !== undefined + ? ' ' + this.beneficiary.lastName + : ''); + this.regDate = moment + .utc(this.beneficiary.createdDate) + .format('DD-MM-YYYY hh:mm A'); + } + }); + } + + // Fetch beneficiary image (common for both ES and non-ES) const benFlowID: any = param['beneficiaryRegID']; this.beneficiaryDetailsService .getBeneficiaryImage(benFlowID) diff --git a/src/registrar/family-tagging/family-tagging-details/family-tagging-details.component.ts b/src/registrar/family-tagging/family-tagging-details/family-tagging-details.component.ts index cd79ace..f696e78 100644 --- a/src/registrar/family-tagging/family-tagging-details/family-tagging-details.component.ts +++ b/src/registrar/family-tagging/family-tagging-details/family-tagging-details.component.ts @@ -38,6 +38,8 @@ import { FamilyTaggingService } from '../../services/familytagging.service'; import { RegistrarService } from '../../services/registrar.service'; import { SearchFamilyComponent } from '../../search-family/search-family.component'; import { SessionStorageService } from '../../services/session-storage.service'; +import { environment } from 'src/environments/environment'; + @Component({ selector: 'app-family-tagging-details', @@ -97,6 +99,7 @@ export class FamilyTaggingDetailsComponent benStateId: any; benDistrictId: any; benBlockId: any; + isEnableES: boolean = false; constructor( private dialog: MatDialog, @@ -110,6 +113,8 @@ export class FamilyTaggingDetailsComponent ) {} ngOnInit() { + + this.isEnableES = environment.isEnableES || false; this.assignSelectedLanguage(); this.benFamilyId = this.route.snapshot.paramMap.get('familyId'); this.benFamilyName = this.route.snapshot.paramMap.get('familyName'); @@ -373,17 +378,43 @@ export class FamilyTaggingDetailsComponent }); } - getBeneficiaryDetailsAfterFamilyTag() { - const benReqObj = { - beneficiaryRegID: null, - beneficiaryID: this.beneficiaryId, - phoneNo: null, - HealthID: null, - HealthIDNumber: null, - familyId: null, - identity: null, - }; + getBeneficiaryDetailsAfterFamilyTag() { + const benReqObj = { + beneficiaryRegID: null, + beneficiaryID: this.beneficiaryId, + phoneNo: null, + HealthID: null, + HealthIDNumber: null, + familyId: null, + identity: null, + }; + if (this.isEnableES) { + // Use Elasticsearch when enabled + const esSearchReqObj = { + search: this.beneficiaryId + }; + + this.registrarService.identityQuickSearchES(esSearchReqObj).subscribe( + (beneficiaryDetails: any) => { + if (beneficiaryDetails && beneficiaryDetails.statusCode === 200 && + beneficiaryDetails.data && beneficiaryDetails.data.length === 1) { + this.benFamilyId = + beneficiaryDetails.data[0].familyID !== undefined && + beneficiaryDetails.data[0].familyID !== null + ? beneficiaryDetails.data[0].familyID + : null; + this.registrarService.getBenFamilyDetails(this.benFamilyId); + } else { + this.benFamilyId = null; + } + }, + (error: string) => { + this.confirmationService.alert(error, 'error'); + } + ); + } else { + // Use regular search when Elasticsearch is disabled this.registrarService.identityQuickSearch(benReqObj).subscribe( (beneficiaryDetails: any) => { if (beneficiaryDetails && beneficiaryDetails.data.length === 1) { @@ -399,7 +430,8 @@ export class FamilyTaggingDetailsComponent }, (error: string) => { this.confirmationService.alert(error, 'error'); - }, + } ); } } +} diff --git a/src/registrar/registration/personal-information/personal-information.component.ts b/src/registrar/registration/personal-information/personal-information.component.ts index f90d181..1d0cca2 100644 --- a/src/registrar/registration/personal-information/personal-information.component.ts +++ b/src/registrar/registration/personal-information/personal-information.component.ts @@ -28,6 +28,7 @@ import { import { HttpServiceService } from 'src/app/app-modules/core/services/http-service.service'; import { AmritTrackingService } from 'Common-UI/src/tracking'; import { Injector } from '@angular/core'; +import { environment } from 'src/environments/environment'; @Component({ @@ -83,6 +84,7 @@ export class PersonalInformationComponent { ageforMarriage = 12; maritalStatusMaster: any; personalInfoSubscription!: Subscription; + isEnableES: boolean = false; constructor( private fb: FormBuilder, @@ -116,6 +118,7 @@ export class PersonalInformationComponent { } ngOnInit() { + this.isEnableES = environment.isEnableES || false; this.fetchLanguageResponse(); this.formData.forEach((item: any) => { if (item.fieldName && item.allowText) { @@ -333,55 +336,96 @@ export class PersonalInformationComponent { /** * Phone Number Parent Relations */ - getParentDetails() { + getParentDetails() { const searchTerm = this.personalInfoFormGroup.value.phoneNo; - const searchObject = { - beneficiaryRegID: null, - beneficiaryID: null, - phoneNo: null, - }; + if (searchTerm && searchTerm.trim().length === 10) { - searchObject['phoneNo'] = searchTerm; - this.registrarService.identityQuickSearch(searchObject).subscribe( - (beneficiaryList: any) => { - if ( - beneficiaryList && - beneficiaryList.length > 0 && - beneficiaryList[0].benPhoneMaps.length > 0 - ) { - console.log( - 'ta d ad a d a', - JSON.stringify(beneficiaryList, null, 4) - ); - this.personalInfoFormGroup.patchValue({ - parentRegID: beneficiaryList[0].benPhoneMaps[0].parentBenRegID, - parentRelation: 11, - }); - console.log(this.personalInfoFormGroup.value.parentRegID); - } else { + if (this.isEnableES) { + // Use Elasticsearch search + this.registrarService.identityQuickSearchES({ search: searchTerm }).subscribe( + (response: any) => { + if ( + response && + response.data && + response.data.length > 0 && + response.data[0].benPhoneMaps && + response.data[0].benPhoneMaps.length > 0 + ) { + console.log('ES Parent search result:', JSON.stringify(response, null, 4)); + this.personalInfoFormGroup.patchValue({ + parentRegID: response.data[0].benPhoneMaps[0].parentBenRegID, + parentRelation: 11, + }); + console.log('Parent Reg ID (ES):', this.personalInfoFormGroup.value.parentRegID); + } else { + this.personalInfoFormGroup.patchValue({ + parentRegID: null, + parentRelation: 1, + }); + console.log('No parent found (ES):', this.personalInfoFormGroup.value.parentRegID); + + if (this.patientRevisit) { + this.personalInfoFormGroup.patchValue({ + parentRegID: this.personalInfoFormGroup.value.beneficiaryRegID, + }); + console.log('Patient revisit parent (ES):', this.personalInfoFormGroup.value.parentRegID); + } + } + }, + error => { + this.confirmationService.alert(error, 'error'); this.personalInfoFormGroup.patchValue({ parentRegID: null, parentRelation: 1, + phoneNo: null, }); - console.log(this.personalInfoFormGroup.value.parentRegID); - - if (this.patientRevisit) { + } + ); + } else { + const searchObject = { + beneficiaryRegID: null, + beneficiaryID: null, + phoneNo: searchTerm, + }; + + this.registrarService.identityQuickSearch(searchObject).subscribe( + (beneficiaryList: any) => { + if ( + beneficiaryList && + beneficiaryList.length > 0 && + beneficiaryList[0].benPhoneMaps.length > 0 + ) { + console.log('Traditional search result:', JSON.stringify(beneficiaryList, null, 4)); + this.personalInfoFormGroup.patchValue({ + parentRegID: beneficiaryList[0].benPhoneMaps[0].parentBenRegID, + parentRelation: 11, + }); + console.log('Parent Reg ID:', this.personalInfoFormGroup.value.parentRegID); + } else { this.personalInfoFormGroup.patchValue({ - parentRegID: this.personalInfoFormGroup.value.beneficiaryRegID, + parentRegID: null, + parentRelation: 1, }); - console.log(this.personalInfoFormGroup.value.parentRegID); + console.log('No parent found:', this.personalInfoFormGroup.value.parentRegID); + + if (this.patientRevisit) { + this.personalInfoFormGroup.patchValue({ + parentRegID: this.personalInfoFormGroup.value.beneficiaryRegID, + }); + console.log('Patient revisit parent:', this.personalInfoFormGroup.value.parentRegID); + } } + }, + error => { + this.confirmationService.alert(error, 'error'); + this.personalInfoFormGroup.patchValue({ + parentRegID: null, + parentRelation: 1, + phoneNo: null, + }); } - }, - error => { - this.confirmationService.alert(error, 'error'); - this.personalInfoFormGroup.patchValue({ - parentRegID: null, - parentRelation: 1, - phoneNo: null, - }); - } - ); + ); + } } else { if (this.patientRevisit) { this.personalInfoFormGroup.patchValue({ @@ -398,7 +442,8 @@ export class PersonalInformationComponent { } } } - /** + + /** * * Age Entered in Input */ diff --git a/src/registrar/search/search.component.html b/src/registrar/search/search.component.html index aee7d32..d57063f 100644 --- a/src/registrar/search/search.component.html +++ b/src/registrar/search/search.component.html @@ -156,7 +156,10 @@