From 80edbf8fbc8ee718653346a5cfbf9cba6caf429a Mon Sep 17 00:00:00 2001 From: SnehaRH <77656297+snehar-nd@users.noreply.github.com> Date: Fri, 27 Feb 2026 12:21:23 +0530 Subject: [PATCH 1/5] Moving 1979,2159 from Release 3.6.2 to Release 3.6.1 (#255) * fix: aam-2159 changed text from advancesearch to advanced search * fix: amm-1979 validation for prescription * Correct spelling in 'advanceBeneficiarySearch' --------- Co-authored-by: 5Amogh Co-authored-by: Amoghavarsh <93114621+5Amogh@users.noreply.github.com> --- .../prescription/prescription.component.ts | 51 ++++++++++++++++++ .../workarea/workarea.component.ts | 52 +++++++++++++++++++ src/assets/English.json | 6 +-- src/assets/language.json | 2 +- 4 files changed, 107 insertions(+), 4 deletions(-) diff --git a/src/app/app-modules/nurse-doctor/case-record/general-case-record/prescription/prescription.component.ts b/src/app/app-modules/nurse-doctor/case-record/general-case-record/prescription/prescription.component.ts index 88ffbeeb..9a007bcf 100644 --- a/src/app/app-modules/nurse-doctor/case-record/general-case-record/prescription/prescription.component.ts +++ b/src/app/app-modules/nurse-doctor/case-record/general-case-record/prescription/prescription.component.ts @@ -390,10 +390,61 @@ export class PrescriptionComponent implements OnInit, DoCheck, OnDestroy { } submitForUpload() { + const validationErrors = this.validateCurrentPrescription(); + + if (validationErrors.length > 0) { + const errorMessage = + 'Please fill the following required fields:\n' + + validationErrors.map((e, i) => `${i + 1}. ${e}`).join('\n'); + this.confirmationService.alert(errorMessage, 'error'); + return; + } + this.addMedicine(); this.clearCurrentaddDetails(); } + validateCurrentPrescription(): string[] { + const errors: string[] = []; + + if (!this.currentPrescription.formName) { + errors.push('Medicine Form'); + } + if (!this.currentPrescription.drugName || !this.tempDrugName) { + errors.push('Medicine Name'); + } + if (!this.currentPrescription.dose) { + errors.push('Dosage'); + } + if (!this.currentPrescription.frequency) { + errors.push('Frequency'); + } + + // Conditional validations + if ( + this.currentPrescription.frequency && + this.currentPrescription.frequency !== 'SOS' + ) { + if (!this.currentPrescription.duration) { + errors.push('Duration'); + } + if (!this.currentPrescription.unit) { + errors.push('Unit'); + } + } + + // Quantity required for non-liquid forms + if ( + this.currentPrescription.formID && + this.currentPrescription.formID > 2 && + !this.currentPrescription.qtyPrescribed + ) { + errors.push('Quantity'); + } + + return errors; + } + addMedicine() { const medicine: FormArray = ( this.drugPrescriptionForm.controls['prescribedDrugs'] diff --git a/src/app/app-modules/nurse-doctor/workarea/workarea.component.ts b/src/app/app-modules/nurse-doctor/workarea/workarea.component.ts index fbba9152..9de001b2 100644 --- a/src/app/app-modules/nurse-doctor/workarea/workarea.component.ts +++ b/src/app/app-modules/nurse-doctor/workarea/workarea.component.ts @@ -2930,6 +2930,33 @@ export class WorkareaComponent } } } + // Ensure doctor has added at least one prescription + if (this.attendant === 'doctor') { + try { + const drugPrescriptionForm = ( + (caseRecordForm && caseRecordForm.controls + ? caseRecordForm.controls['drugPrescriptionForm'] + : null) + ); + if (drugPrescriptionForm) { + let prescribedDrugs = + drugPrescriptionForm.value && + drugPrescriptionForm.value.prescribedDrugs + ? drugPrescriptionForm.value.prescribedDrugs + : []; + prescribedDrugs = prescribedDrugs.filter((d: any) => !!d.createdBy); + if (!prescribedDrugs || prescribedDrugs.length === 0) { + required.push( + this.current_language_set?.Prescription?.prescriptionRequired || + 'Please add at least one prescription', + ); + } + } + } catch (err) { + console.warn('Error validating prescription presence', err); + } + } + if (required.length) { this.confirmationService.notify( this.current_language_set.alerts.info.belowFields, @@ -3723,6 +3750,31 @@ export class WorkareaComponent } } } + // For quick consult doctor flow, ensure at least one prescription exists + if (this.attendant === 'doctor') { + try { + const prescription = + form && form.controls ? form.controls['prescription'] : null; + if (prescription) { + let prescribedDrugs = + prescription.value && prescription.value.prescribedDrugs + ? prescription.value.prescribedDrugs + : []; + prescribedDrugs = prescribedDrugs.filter((d: any) => !!d.createdBy); + if (!prescribedDrugs || prescribedDrugs.length === 0) { + required.push( + this.current_language_set?.Prescription?.prescriptionRequired || + 'Please add at least one prescription', + ); + } + } + } catch (err) { + console.warn( + 'Error validating quick consult prescription presence', + err, + ); + } + } if (required.length) { this.confirmationService.notify( diff --git a/src/assets/English.json b/src/assets/English.json index 21231850..c3961778 100644 --- a/src/assets/English.json +++ b/src/assets/English.json @@ -113,7 +113,7 @@ "district": "District / Village", "registrationDate": "Registration Date", "image": "Image", - "advanceSearch": "Advance Search", + "advanceSearch": "Advanced Search", "externalSearch": "Higher Health Facility Search", "status": "Status", "visitCategory": "Visit Category / Visit No", @@ -308,7 +308,7 @@ "toTime": "To Time", "Kindlyuploadthefiles": "Kindly upload the files", "clearslots":"Clear Slot", - "advanceBeneficiarySearch": "Advance Beneficiary Search", + "advanceBeneficiarySearch": "Advanced Beneficiary Search", "externalBeneficiarySearch": "External Beneficiary Search", "firstNameisrequired": "First Name is required", "pleaseprovideatleast2character": "Please provide atleast 2 character", @@ -2145,4 +2145,4 @@ } -} \ No newline at end of file +} diff --git a/src/assets/language.json b/src/assets/language.json index 57a0d1f9..5723cbdb 100644 --- a/src/assets/language.json +++ b/src/assets/language.json @@ -87,7 +87,7 @@ "district": "District / Village", "registrationDate": "Registration Date", "image": "Image", - "advanceSearch": "Advance Search", + "advanceSearch": "Advanced Search", "status": "Status", "visitCategory": "Visit Category / Visit No", "tcDate": "TC Date", From 33501e5677bfe9458867d530d075be473d114c71 Mon Sep 17 00:00:00 2001 From: SnehaRH Date: Mon, 2 Mar 2026 13:16:12 +0530 Subject: [PATCH 2/5] fix: amm-2192 remove mandatory for prescription --- .../prescription/prescription.component.html | 5 ---- .../workarea/workarea.component.ts | 26 ------------------- 2 files changed, 31 deletions(-) diff --git a/src/app/app-modules/nurse-doctor/case-record/general-case-record/prescription/prescription.component.html b/src/app/app-modules/nurse-doctor/case-record/general-case-record/prescription/prescription.component.html index fe8657ef..9c83ab6b 100644 --- a/src/app/app-modules/nurse-doctor/case-record/general-case-record/prescription/prescription.component.html +++ b/src/app/app-modules/nurse-doctor/case-record/general-case-record/prescription/prescription.component.html @@ -70,7 +70,6 @@ getFormValueChanged(); trackFieldInteraction('Medicine Form Selection') " - required > ( - (caseRecordForm && caseRecordForm.controls - ? caseRecordForm.controls['drugPrescriptionForm'] - : null) - ); - if (drugPrescriptionForm) { - let prescribedDrugs = - drugPrescriptionForm.value && - drugPrescriptionForm.value.prescribedDrugs - ? drugPrescriptionForm.value.prescribedDrugs - : []; - prescribedDrugs = prescribedDrugs.filter((d: any) => !!d.createdBy); - if (!prescribedDrugs || prescribedDrugs.length === 0) { - required.push( - this.current_language_set?.Prescription?.prescriptionRequired || - 'Please add at least one prescription', - ); - } - } - } catch (err) { - console.warn('Error validating prescription presence', err); - } - } if (required.length) { this.confirmationService.notify( From 95ba793554b18fc85fa6b25cfa8340bf6be469a9 Mon Sep 17 00:00:00 2001 From: SnehaRH Date: Wed, 18 Mar 2026 20:18:32 +0530 Subject: [PATCH 3/5] fix: removed prescription data is required condition --- .../quick-consult.component.html | 7 -- .../workarea/workarea.component.ts | 85 +++++++++---------- 2 files changed, 40 insertions(+), 52 deletions(-) diff --git a/src/app/app-modules/nurse-doctor/quick-consult/quick-consult.component.html b/src/app/app-modules/nurse-doctor/quick-consult/quick-consult.component.html index b85450f3..2e9a3f7f 100644 --- a/src/app/app-modules/nurse-doctor/quick-consult/quick-consult.component.html +++ b/src/app/app-modules/nurse-doctor/quick-consult/quick-consult.component.html @@ -725,7 +725,6 @@

name="form" [(ngModel)]="tempform" (selectionChange)="getFormValueChanged()" - required > [(ngModel)]="tempDrugName" (keyup)="filterMedicine(tempDrugName)" (blur)="reEnterMedicine()" - required [matAutocomplete]="autoGroup" /> name="dose" [(ngModel)]="currentPrescription.dose" [disabled]="!currentPrescription.drugID" - required > name="frequency" [(ngModel)]="currentPrescription.frequency" [disabled]="!currentPrescription.drugID" - required > name="duration" [(ngModel)]="currentPrescription.duration" [disabled]="!currentPrescription.drugID" - required > name="unit" [(ngModel)]="currentPrescription.unit" [disabled]="!currentPrescription.drugID" - required > name="quantity" [(ngModel)]="currentPrescription.qtyPrescribed" [disabled]="!currentPrescription.drugID" - required > { if (res.statusCode === 200 && res.data !== null) { this.confirmationService.alert( - this.current_language_set.alerts.info.datafillSuccessfully, + this.current_language_set?.alerts?.info?.datafillSuccessfully ?? + 'Data saved successfully', 'success', ); this.navigateToNurseWorklist(); @@ -3724,31 +3725,6 @@ export class WorkareaComponent } } } - // For quick consult doctor flow, ensure at least one prescription exists - if (this.attendant === 'doctor') { - try { - const prescription = - form && form.controls ? form.controls['prescription'] : null; - if (prescription) { - let prescribedDrugs = - prescription.value && prescription.value.prescribedDrugs - ? prescription.value.prescribedDrugs - : []; - prescribedDrugs = prescribedDrugs.filter((d: any) => !!d.createdBy); - if (!prescribedDrugs || prescribedDrugs.length === 0) { - required.push( - this.current_language_set?.Prescription?.prescriptionRequired || - 'Please add at least one prescription', - ); - } - } - } catch (err) { - console.warn( - 'Error validating quick consult prescription presence', - err, - ); - } - } if (required.length) { this.confirmationService.notify( @@ -3846,13 +3822,15 @@ export class WorkareaComponent labTestOrders.length > 0 ) { this.confirmationService.alert( - this.current_language_set.alerts.info.datafillSuccessfully, + this.current_language_set?.alerts?.info + ?.datafillSuccessfully ?? 'Data saved successfully', 'success', ); this.navigateToSpecialistWorklist(); } else { this.getHealthIDDetails( - this.current_language_set.alerts.info.datafillSuccessfully, + this.current_language_set?.alerts?.info + ?.datafillSuccessfully ?? 'Data saved successfully', ); } } else { @@ -3864,13 +3842,15 @@ export class WorkareaComponent this.schedulerData !== null) ) { this.confirmationService.alert( - this.current_language_set.alerts.info.datafillSuccessfully, + this.current_language_set?.alerts?.info + ?.datafillSuccessfully ?? 'Data saved successfully', 'success', ); this.navigateToDoctorWorklist(); } else { this.getHealthIDDetails( - this.current_language_set.alerts.info.datafillSuccessfully, + this.current_language_set?.alerts?.info + ?.datafillSuccessfully ?? 'Data saved successfully', ); } } @@ -4024,7 +4004,8 @@ export class WorkareaComponent (res: any) => { if (res.statusCode === 200 && res.data !== null) { this.confirmationService.alert( - this.current_language_set.alerts.info.datafillSuccessfully, + this.current_language_set?.alerts?.info?.datafillSuccessfully ?? + 'Data saved successfully', 'success', ); this.navigateToNurseWorklist(); @@ -4100,7 +4081,8 @@ export class WorkareaComponent (res: any) => { if (res.statusCode === 200 && res.data !== null) { this.confirmationService.alert( - this.current_language_set.alerts.info.datafillSuccessfully, + this.current_language_set?.alerts?.info?.datafillSuccessfully ?? + 'Data saved successfully', 'success', ); this.navigateToNurseWorklist(); @@ -4133,7 +4115,8 @@ export class WorkareaComponent (res: any) => { if (res.statusCode === 200 && res.data !== null) { this.confirmationService.alert( - this.current_language_set.alerts.info.datafillSuccessfully, + this.current_language_set?.alerts?.info?.datafillSuccessfully ?? + 'Data saved successfully', 'success', ); this.navigateToNurseWorklist(); @@ -4169,7 +4152,8 @@ export class WorkareaComponent (res: any) => { if (res.statusCode === 200 && res.data !== null) { this.confirmationService.alert( - this.current_language_set.alerts.info.datafillSuccessfully, + this.current_language_set?.alerts?.info?.datafillSuccessfully ?? + 'Data saved successfully', 'success', ); this.navigateToNurseWorklist(); @@ -4230,13 +4214,15 @@ export class WorkareaComponent this.schedulerData !== null) ) { this.confirmationService.alert( - this.current_language_set.alerts.info.datafillSuccessfully, + this.current_language_set?.alerts?.info + ?.datafillSuccessfully ?? 'Data saved successfully', 'success', ); this.navigateToDoctorWorklist(); } else { this.getHealthIDDetails( - this.current_language_set.alerts.info.datafillSuccessfully, + this.current_language_set?.alerts?.info + ?.datafillSuccessfully ?? 'Data saved successfully', ); } } @@ -4310,7 +4296,8 @@ export class WorkareaComponent (res: any) => { if (res.statusCode === 200 && res.data !== null) { this.confirmationService.alert( - this.current_language_set.alerts.info.datafillSuccessfully, + this.current_language_set?.alerts?.info?.datafillSuccessfully ?? + 'Data saved successfully', 'success', ); this.navigateToNurseWorklist(); @@ -4344,7 +4331,8 @@ export class WorkareaComponent (res: any) => { if (res.statusCode === 200 && res.data !== null) { this.confirmationService.alert( - this.current_language_set.alerts.info.datafillSuccessfully, + this.current_language_set?.alerts?.info?.datafillSuccessfully ?? + 'Data saved successfully', 'success', ); this.navigateToNurseWorklist(); @@ -4387,13 +4375,15 @@ export class WorkareaComponent this.testsPrescribed.laboratoryList.length > 0 ) { this.confirmationService.alert( - this.current_language_set.alerts.info.datafillSuccessfully, + this.current_language_set?.alerts?.info?.datafillSuccessfully ?? + 'Data saved successfully', 'success', ); this.navigateToSpecialistWorklist(); } else { this.getHealthIDDetails( - this.current_language_set.alerts.info.datafillSuccessfully, + this.current_language_set?.alerts?.info?.datafillSuccessfully ?? + 'Data saved successfully', ); } } @@ -4411,13 +4401,15 @@ export class WorkareaComponent (this.schedulerData !== undefined && this.schedulerData !== null) ) { this.confirmationService.alert( - this.current_language_set.alerts.info.datafillSuccessfully, + this.current_language_set?.alerts?.info?.datafillSuccessfully ?? + 'Data saved successfully', 'success', ); this.navigateToDoctorWorklist(); } else { this.getHealthIDDetails( - this.current_language_set.alerts.info.datafillSuccessfully, + this.current_language_set?.alerts?.info?.datafillSuccessfully ?? + 'Data saved successfully', ); } } @@ -5552,7 +5544,8 @@ export class WorkareaComponent (res: any) => { if (res.statusCode === 200 && res.data !== null) { this.confirmationService.alert( - this.current_language_set.alerts.info.datafillSuccessfully, + this.current_language_set?.alerts?.info?.datafillSuccessfully ?? + 'Data saved successfully', 'success', ); this.navigateToNurseWorklist(); @@ -5585,7 +5578,8 @@ export class WorkareaComponent (res: any) => { if (res.statusCode === 200 && res.data !== null) { this.confirmationService.alert( - this.current_language_set.alerts.info.datafillSuccessfully, + this.current_language_set?.alerts?.info?.datafillSuccessfully ?? + 'Data saved successfully', 'success', ); this.navigateToNurseWorklist(); @@ -5615,7 +5609,8 @@ export class WorkareaComponent (res: any) => { if (res.statusCode === 200 && res.data !== null) { this.confirmationService.alert( - this.current_language_set.alerts.info.datafillSuccessfully, + this.current_language_set?.alerts?.info?.datafillSuccessfully ?? + 'Data saved successfully', 'success', ); this.navigateToNurseWorklist(); From 349da217b741d50d4636727b2dfebcf3c582d06f Mon Sep 17 00:00:00 2001 From: SnehaRH Date: Mon, 23 Mar 2026 19:36:17 +0530 Subject: [PATCH 4/5] fix: amm-2127 clinical observation search not working as expected --- .../findings/findings.component.html | 287 +++++++++--------- .../findings/findings.component.ts | 73 +++++ 2 files changed, 211 insertions(+), 149 deletions(-) diff --git a/src/app/app-modules/nurse-doctor/case-record/general-case-record/findings/findings.component.html b/src/app/app-modules/nurse-doctor/case-record/general-case-record/findings/findings.component.html index f8348a9f..62b66d48 100644 --- a/src/app/app-modules/nurse-doctor/case-record/general-case-record/findings/findings.component.html +++ b/src/app/app-modules/nurse-doctor/case-record/general-case-record/findings/findings.component.html @@ -263,87 +263,84 @@
-
- -
-
- - {{ - current_language_set?.casesheet?.clinicalObs - }} - - search - -
+ +
+ + {{ + current_language_set?.casesheet?.clinicalObs + }} + + -
- + {{ obs.term }} + + +
- -
+
+ + +
@@ -351,92 +348,84 @@
-
- -
-
- - {{ - current_language_set?.casesheet?.significantFind - }} - - - search - -
+ +
+ + {{ + current_language_set?.casesheet?.significantFind + }} + + -
- + {{ finding.term }} + + +
- -
+
+ + +
diff --git a/src/app/app-modules/nurse-doctor/case-record/general-case-record/findings/findings.component.ts b/src/app/app-modules/nurse-doctor/case-record/general-case-record/findings/findings.component.ts index 094b8a87..01ce4573 100644 --- a/src/app/app-modules/nurse-doctor/case-record/general-case-record/findings/findings.component.ts +++ b/src/app/app-modules/nurse-doctor/case-record/general-case-record/findings/findings.component.ts @@ -83,6 +83,9 @@ export class FindingsComponent implements OnInit, DoCheck, OnDestroy { current_language_set: any; enableIsHistory = false; enableProvisionalDiag = false; + + suggestedObservationsList: any = []; + suggestedFindingsSearchList: any = []; displayedColumns: any = [ 'chiefComplaintsDetails', 'duration', @@ -692,6 +695,76 @@ export class FindingsComponent implements OnInit, DoCheck, OnDestroy { ); } } + // --- Clinical Observations: Autocomplete search --- + onObservationInputKeyup(value: string, index: number) { + const term = (value || '').trim(); + if (term.length >= 3) { + this.masterdataService.searchDiagnosisBasedOnPageNo(term, 0).subscribe({ + next: (results: any) => { + this.suggestedObservationsList[index] = + results?.data?.sctMaster ?? []; + }, + error: () => { + console.error('Error fetching observation data'); + }, + }); + } else { + this.suggestedObservationsList[index] = []; + } + } + + displayObservation(obs: any): string { + return typeof obs === 'string' ? obs : obs?.term || ''; + } + + onObservationSelected(selected: any, index: number) { + const observationsFormArray = this.generalFindingsForm.get( + 'clinicalObservationsList', + ) as FormArray; + const observationsFormGroup = observationsFormArray.at(index) as FormGroup; + observationsFormGroup.patchValue({ + clinicalObservationsProvided: selected, + conceptID: selected?.conceptID || null, + term: selected?.term || null, + }); + } + + // --- Significant Findings: Autocomplete search --- + onFindingsInputKeyup(value: string, index: number) { + const term = (value || '').trim(); + this.resetFindingsCheckbox(term); + if (term.length >= 3) { + this.masterdataService.searchDiagnosisBasedOnPageNo(term, 0).subscribe({ + next: (results: any) => { + this.suggestedFindingsSearchList[index] = + results?.data?.sctMaster ?? []; + }, + error: () => { + console.error('Error fetching findings data'); + }, + }); + } else { + this.suggestedFindingsSearchList[index] = []; + } + } + + displayFindings(finding: any): string { + return typeof finding === 'string' ? finding : finding?.term || ''; + } + + onFindingsSelected(selected: any, index: number) { + const findingsFormArray = this.generalFindingsForm.get( + 'significantFindingsList', + ) as FormArray; + const findingsFormGroup = findingsFormArray.at(index) as FormGroup; + findingsFormGroup.patchValue({ + significantFindingsProvided: selected, + conceptID: selected?.conceptID || null, + term: selected?.term || null, + }); + this.resetFindingsCheckbox(selected?.term); + } + ngOnDestroy() { if (this.doctorMasterDataSubscription) this.doctorMasterDataSubscription.unsubscribe(); From e5983162aaf304487055ae75a3b6f93a9cc9308e Mon Sep 17 00:00:00 2001 From: SnehaRH Date: Wed, 25 Mar 2026 10:39:15 +0530 Subject: [PATCH 5/5] fix: resolve coderabbit review comments on findings autocomplete and care context - Fix race condition in clinical observations and significant findings autocomplete by tracking latest query per row index and discarding stale responses - Fix text/SNOMED code desync by storing only term string on selection and clearing conceptID/term fields on keyup before new selection - Fix checkbox visibility by scanning entire significantFindingsList array instead of relying on the last-edited row's transient state - Add null-safe optional chaining in getHealthIDDetails() before confirmCareContext() Co-Authored-By: Claude Sonnet 4.6 --- .../findings/findings.component.ts | 78 +++++++++---------- .../workarea/workarea.component.ts | 4 +- 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/app/app-modules/nurse-doctor/case-record/general-case-record/findings/findings.component.ts b/src/app/app-modules/nurse-doctor/case-record/general-case-record/findings/findings.component.ts index 01ce4573..2ff6c858 100644 --- a/src/app/app-modules/nurse-doctor/case-record/general-case-record/findings/findings.component.ts +++ b/src/app/app-modules/nurse-doctor/case-record/general-case-record/findings/findings.component.ts @@ -86,6 +86,8 @@ export class FindingsComponent implements OnInit, DoCheck, OnDestroy { suggestedObservationsList: any = []; suggestedFindingsSearchList: any = []; + private latestObservationQuery: Map = new Map(); + private latestFindingsQuery: Map = new Map(); displayedColumns: any = [ 'chiefComplaintsDetails', 'duration', @@ -621,11 +623,7 @@ export class FindingsComponent implements OnInit, DoCheck, OnDestroy { findingsList.reset(); } this.generalFindingsForm.markAsDirty(); - this.resetFindingsCheckbox( - this.generalFindingsForm.controls[ - 'significantFindingsList' - ].value.at(0).term, - ); + this.resetFindingsCheckbox(); } }); } else { @@ -634,10 +632,7 @@ export class FindingsComponent implements OnInit, DoCheck, OnDestroy { } else { findingsList.reset(); } - this.resetFindingsCheckbox( - this.generalFindingsForm.controls['significantFindingsList'].value.at(0) - .term, - ); + this.resetFindingsCheckbox(); } } patchCapturedClinicalObservations(clinicalObservations: any) { @@ -689,20 +684,25 @@ export class FindingsComponent implements OnInit, DoCheck, OnDestroy { ].disable(); if (findingsList.length < savedFindings.length) this.addFindings(); } - this.resetFindingsCheckbox( - this.generalFindingsForm.controls['significantFindingsList'].value.at(0) - .term, - ); + this.resetFindingsCheckbox(); } } // --- Clinical Observations: Autocomplete search --- onObservationInputKeyup(value: string, index: number) { const term = (value || '').trim(); + this.latestObservationQuery.set(index, term); + const observationsFormArray = this.generalFindingsForm.get( + 'clinicalObservationsList', + ) as FormArray; + const observationsFormGroup = observationsFormArray.at(index) as FormGroup; + observationsFormGroup.patchValue({ conceptID: null, term: null }); if (term.length >= 3) { this.masterdataService.searchDiagnosisBasedOnPageNo(term, 0).subscribe({ next: (results: any) => { - this.suggestedObservationsList[index] = - results?.data?.sctMaster ?? []; + if (this.latestObservationQuery.get(index) === term) { + this.suggestedObservationsList[index] = + results?.data?.sctMaster ?? []; + } }, error: () => { console.error('Error fetching observation data'); @@ -723,7 +723,7 @@ export class FindingsComponent implements OnInit, DoCheck, OnDestroy { ) as FormArray; const observationsFormGroup = observationsFormArray.at(index) as FormGroup; observationsFormGroup.patchValue({ - clinicalObservationsProvided: selected, + clinicalObservationsProvided: selected?.term || null, conceptID: selected?.conceptID || null, term: selected?.term || null, }); @@ -732,12 +732,20 @@ export class FindingsComponent implements OnInit, DoCheck, OnDestroy { // --- Significant Findings: Autocomplete search --- onFindingsInputKeyup(value: string, index: number) { const term = (value || '').trim(); - this.resetFindingsCheckbox(term); + this.latestFindingsQuery.set(index, term); + const findingsFormArray = this.generalFindingsForm.get( + 'significantFindingsList', + ) as FormArray; + const findingsFormGroup = findingsFormArray.at(index) as FormGroup; + findingsFormGroup.patchValue({ conceptID: null, term: null }); + this.resetFindingsCheckbox(); if (term.length >= 3) { this.masterdataService.searchDiagnosisBasedOnPageNo(term, 0).subscribe({ next: (results: any) => { - this.suggestedFindingsSearchList[index] = - results?.data?.sctMaster ?? []; + if (this.latestFindingsQuery.get(index) === term) { + this.suggestedFindingsSearchList[index] = + results?.data?.sctMaster ?? []; + } }, error: () => { console.error('Error fetching findings data'); @@ -758,11 +766,11 @@ export class FindingsComponent implements OnInit, DoCheck, OnDestroy { ) as FormArray; const findingsFormGroup = findingsFormArray.at(index) as FormGroup; findingsFormGroup.patchValue({ - significantFindingsProvided: selected, + significantFindingsProvided: selected?.term || null, conceptID: selected?.conceptID || null, term: selected?.term || null, }); - this.resetFindingsCheckbox(selected?.term); + this.resetFindingsCheckbox(); } ngOnDestroy() { @@ -775,26 +783,18 @@ export class FindingsComponent implements OnInit, DoCheck, OnDestroy { } } - resetFindingsCheckbox(significantFindingsProvidedValue: any) { - if ( - this.generalFindingsForm.controls['significantFindingsList'].value - .length === 1 && - (significantFindingsProvidedValue === undefined || - significantFindingsProvidedValue === null || - significantFindingsProvidedValue === '') - ) { - this.generalFindingsForm.controls['isForHistory'].patchValue(null); - this.enableIsHistory = false; - } - - if ( - this.generalFindingsForm.controls['significantFindingsList'].value - .length > 0 && - significantFindingsProvidedValue !== null && - significantFindingsProvidedValue !== '' - ) { + resetFindingsCheckbox() { + const findingsList = this.generalFindingsForm.get( + 'significantFindingsList', + ) as FormArray; + const hasAnyFinding = findingsList.controls.some((ctrl) => { + const val = (ctrl as FormGroup).get('significantFindingsProvided')?.value; + return val !== null && val !== undefined && val !== ''; + }); + if (hasAnyFinding) { this.enableIsHistory = true; } else { + this.generalFindingsForm.controls['isForHistory'].patchValue(null); this.enableIsHistory = false; } } diff --git a/src/app/app-modules/nurse-doctor/workarea/workarea.component.ts b/src/app/app-modules/nurse-doctor/workarea/workarea.component.ts index cb0f155c..c4698659 100644 --- a/src/app/app-modules/nurse-doctor/workarea/workarea.component.ts +++ b/src/app/app-modules/nurse-doctor/workarea/workarea.component.ts @@ -2938,7 +2938,6 @@ export class WorkareaComponent } } - if (required.length) { this.confirmationService.notify( this.current_language_set.alerts.info.belowFields, @@ -4500,7 +4499,8 @@ export class WorkareaComponent 'info', successResponseFromAPI + '. ' + - this.current_language_set.common.doYouWantToLinkCareContext, + (this.current_language_set?.common?.doYouWantToLinkCareContext ?? + 'Do you want to link care context?'), ) .subscribe((res) => { if (res) {