diff --git a/src/app/app-modules/nurse-doctor/anc/anc.component.ts b/src/app/app-modules/nurse-doctor/anc/anc.component.ts index 17d68ec..82e3ed3 100644 --- a/src/app/app-modules/nurse-doctor/anc/anc.component.ts +++ b/src/app/app-modules/nurse-doctor/anc/anc.component.ts @@ -134,6 +134,46 @@ export class AncComponent implements OnInit, OnChanges, OnDestroy, DoCheck { visitCode: this.sessionstorage.getItem('visitCode'), }; + const immunizationForm = patientANCForm.get('patientANCImmunizationForm'); + + if (immunizationForm) { + const ttDateFields = [ + 'dateReceivedForTT_1', + 'dateReceivedForTT_2', + 'dateReceivedForTT_3', + ]; + + ttDateFields.forEach((field) => { + const value = immunizationForm.get(field)?.value; + + if (value) { + immunizationForm.patchValue({ + [field]: this.normalizeToUTCMidnight(new Date(value)), + }); + } + }); + } + + const ancDetailsForm = patientANCForm.get('patientANCDetailsForm'); + + if (ancDetailsForm) { + const lmpDateValue = ancDetailsForm.get('lmpDate')?.value; + + if (lmpDateValue) { + ancDetailsForm.patchValue({ + lmpDate: this.normalizeToUTCMidnight(new Date(lmpDateValue)), + }); + } + + const expDelDtValue = ancDetailsForm.get('expDelDt')?.value; + + if (expDelDtValue) { + ancDetailsForm.patchValue({ + expDelDt: this.normalizeToUTCMidnight(new Date(expDelDtValue)), + }); + } + } + this.updateANCDetailsSubs = this.doctorService .updateANCDetails(patientANCForm, temp) .subscribe( @@ -152,6 +192,16 @@ export class AncComponent implements OnInit, OnChanges, OnDestroy, DoCheck { ); } + private normalizeToUTCMidnight(date: Date | null | undefined): string | null { + if (!date) return null; + + const d = new Date(date); + const utcDate = new Date( + Date.UTC(d.getFullYear(), d.getMonth(), d.getDate(), 0, 0, 0, 0) + ); + return utcDate.toISOString(); + } + getHRPDetails() { const beneficiaryRegID = this.sessionstorage.getItem('beneficiaryRegID'); const visitCode = this.sessionstorage.getItem('visitCode'); diff --git a/src/app/app-modules/nurse-doctor/history/general-opd-history/personal-history/personal-history.component.ts b/src/app/app-modules/nurse-doctor/history/general-opd-history/personal-history/personal-history.component.ts index 1817385..89290fb 100644 --- a/src/app/app-modules/nurse-doctor/history/general-opd-history/personal-history/personal-history.component.ts +++ b/src/app/app-modules/nurse-doctor/history/general-opd-history/personal-history/personal-history.component.ts @@ -213,6 +213,15 @@ export class GeneralPersonalHistoryComponent history.data.PersonalHistory ) { this.personalHistoryData = history.data.PersonalHistory; + if ( + this.personalHistoryData && + this.personalHistoryData.riskySexualPracticesStatus !== null + ) { + this.personalHistoryData.riskySexualPracticesStatus = + this.personalHistoryData.riskySexualPracticesStatus == '1' + ? true + : false; + } this.generalPersonalHistoryForm.patchValue(this.personalHistoryData); this.handlePersonalTobaccoHistoryData(); this.handlePersonalAlcoholHistoryData(); @@ -420,44 +429,63 @@ export class GeneralPersonalHistoryComponent const formArray = this.generalPersonalHistoryForm.controls[ 'allergicList' ] as FormArray; + if (this.personalHistoryData && this.personalHistoryData.allergicList) { const temp = this.personalHistoryData.allergicList.slice(); + while (formArray.length > 0) { + formArray.removeAt(0); + } + + for (let i = 0; i < temp.length; i++) { + formArray.push(this.initAllergyList()); + } + + this.allerySelectList = []; + this.previousSelectedAlleryList = []; + for (let i = 0; i < temp.length; i++) { const allergyType = this.allergyMasterData.filter((item) => { return item.allergyType === temp[i].allergyType; }); + if (allergyType.length > 0) temp[i].allergyType = allergyType[0]; - if (this.masterData.AllergicReactionTypes !== undefined) { - temp[i].typeOfAllergicReactions = - this.masterData.AllergicReactionTypes.filter((item: any) => { - let flag = false; - temp[i].typeOfAllergicReactions.forEach((element: any) => { - if (element.name === item.name) flag = true; - }); - return flag; + temp[i].typeOfAllergicReactions = + this.masterData.AllergicReactionTypes.filter((item: any) => { + let flag = false; + temp[i].typeOfAllergicReactions.forEach((element: any) => { + if (element.name === item.name) flag = true; }); - } + return flag; + }); if (temp[i].otherAllergicReaction) temp[i].enableOtherAllergy = true; + const selectedAllergies = temp + .filter((t: any, idx: any) => idx !== i && t.allergyType) + .map((t: any) => t.allergyType.allergyType); + + const availableAllergies = this.allergyMasterData.filter( + (item) => !selectedAllergies.includes(item.allergyType), + ); + + this.allerySelectList.push(availableAllergies.slice()); + if (temp[i].allergyType) { - const k: any = formArray.get('' + i); + this.previousSelectedAlleryList[i] = temp[i].allergyType; + } + + const k: any = formArray.get('' + i); + if (k) { k.patchValue(temp[i]); k.markAsTouched(); - k.markAsDirty(); - this.filterAlleryList(temp[i].allergyType, i); - if ( - k?.get('snomedTerm')?.value !== null && - k?.get('typeOfAllergicReactions')?.value !== null - ) { - k?.get('snomedTerm')?.enable(); - k?.get('typeOfAllergicReactions')?.enable(); + + if (temp[i].allergyType) { + k.get('snomedTerm')?.enable(); + k.get('typeOfAllergicReactions')?.enable(); } } - - if (i + 1 < temp.length) this.addAllergy(); } } } diff --git a/src/app/app-modules/nurse-doctor/pnc/pnc.component.ts b/src/app/app-modules/nurse-doctor/pnc/pnc.component.ts index 13e14f6..49bed08 100644 --- a/src/app/app-modules/nurse-doctor/pnc/pnc.component.ts +++ b/src/app/app-modules/nurse-doctor/pnc/pnc.component.ts @@ -158,13 +158,25 @@ export class PncComponent implements OnInit, DoCheck, OnChanges, OnDestroy { })[0]; } - tempPNCData.dDate = new Date(tempPNCData.dateOfDelivery); + tempPNCData.dDate = this.normalizeToUTCMidnight( + new Date(tempPNCData.dateOfDelivery), + ); const patchPNCdata = Object.assign({}, tempPNCData); this.patientPNCForm.patchValue(tempPNCData); }); } + private normalizeToUTCMidnight(date: Date | null | undefined): string | null { + if (!date) return null; + + const d = new Date(date); + const utcDate = new Date( + Date.UTC(d.getFullYear(), d.getMonth(), d.getDate(), 0, 0, 0, 0) + ); + return utcDate.toISOString(); + } + updatePatientPNC(patientPNCForm: any) { const temp = { beneficiaryRegID: this.sessionstorage.getItem('beneficiaryRegID'), @@ -174,6 +186,14 @@ export class PncComponent implements OnInit, DoCheck, OnChanges, OnDestroy { visitCode: this.sessionstorage.getItem('visitCode'), }; + const dDate = patientPNCForm.get('dDate')?.value; + if (dDate) { + patientPNCForm.patchValue({ + dateOfDelivery: this.normalizeToUTCMidnight(new Date(dDate)), + dDate: this.normalizeToUTCMidnight(new Date(dDate)), + }); + } + this.doctorService.updatePNCDetails(patientPNCForm, temp).subscribe( (res: any) => { if (res.statusCode === 200 && res.data !== null) { diff --git a/src/app/app-modules/nurse-doctor/shared/services/nurse.service.ts b/src/app/app-modules/nurse-doctor/shared/services/nurse.service.ts index 9dcdb4a..b73a8d5 100644 --- a/src/app/app-modules/nurse-doctor/shared/services/nurse.service.ts +++ b/src/app/app-modules/nurse-doctor/shared/services/nurse.service.ts @@ -694,6 +694,17 @@ export class NurseService { }; } + private normalizeToUTCMidnight(date: Date | null | undefined): string | null { + if (!date) return null; + + const d = new Date(date); + + const utcDate = new Date( + Date.UTC(d.getFullYear(), d.getMonth(), d.getDate(), 0, 0, 0, 0) + ); + return utcDate.toISOString(); + } + postANCDetailForm(patientANCForm: any, benVisitID: any) { const detailedANC = JSON.parse( JSON.stringify(patientANCForm.controls.patientANCDetailsForm.value), @@ -702,11 +713,15 @@ export class NurseService { JSON.stringify(patientANCForm.controls.obstetricFormulaForm.value), ); if (detailedANC.lmpDate) { - const lmpDate = new Date(detailedANC.lmpDate); - const adjustedDate = new Date( - lmpDate.getTime() - lmpDate.getTimezoneOffset() * 60000, + detailedANC.lmpDate = this.normalizeToUTCMidnight( + new Date(detailedANC.lmpDate) + ); + } + + if (detailedANC.expDelDt) { + detailedANC.expDelDt = this.normalizeToUTCMidnight( + new Date(detailedANC.expDelDt) ); - detailedANC.lmpDate = adjustedDate.toISOString(); } const combinedANCForm = Object.assign({}, detailedANC, { @@ -726,7 +741,29 @@ export class NurseService { } postANCImmunizationForm(patientANCImmunizationForm: any, benVisitID: any) { - const immunizationForm = Object.assign({}, patientANCImmunizationForm, { + const immunizationFormValue = JSON.parse( + JSON.stringify(patientANCImmunizationForm) + ); + + if (immunizationFormValue.dateReceivedForTT_1) { + immunizationFormValue.dateReceivedForTT_1 = this.normalizeToUTCMidnight( + new Date(immunizationFormValue.dateReceivedForTT_1) + ); + } + + if (immunizationFormValue.dateReceivedForTT_2) { + immunizationFormValue.dateReceivedForTT_2 = this.normalizeToUTCMidnight( + new Date(immunizationFormValue.dateReceivedForTT_2) + ); + } + + if (immunizationFormValue.dateReceivedForTT_3) { + immunizationFormValue.dateReceivedForTT_3 = this.normalizeToUTCMidnight( + new Date(immunizationFormValue.dateReceivedForTT_3) + ); + } + + const immunizationForm = Object.assign({}, immunizationFormValue, { beneficiaryRegID: this.sessionstorage.getItem('beneficiaryRegID'), benVisitID: benVisitID, providerServiceMapID: this.sessionstorage.getItem('providerServiceID'), @@ -1264,11 +1301,7 @@ export class NurseService { if (!temp.lMPDate) { temp.lMPDate = undefined; } else { - const lmpDate = new Date(temp.lMPDate); - const adjustedDate = new Date( - lmpDate.getTime() - lmpDate.getTimezoneOffset() * 60000, - ); - temp.lMPDate = adjustedDate.toISOString(); + temp.lMPDate = this.normalizeToUTCMidnight(new Date(temp.lMPDate)); } const menstrualHistoryData = Object.assign({}, temp, otherDetails); @@ -1894,6 +1927,11 @@ export class NurseService { temp.newBornHealthStatus = temp.newBornHealthStatus.newBornHealthStatus; } + if (temp.dDate) { + temp.dateOfDelivery = this.normalizeToUTCMidnight(new Date(temp.dDate)); + temp.dDate = temp.dateOfDelivery; + } + const patientPNCDetails = Object.assign({}, temp, { beneficiaryRegID: this.sessionstorage.getItem('beneficiaryRegID'), benVisitID: benVisitID, 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 27773c0..740fad9 100644 --- a/src/app/app-modules/nurse-doctor/workarea/workarea.component.ts +++ b/src/app/app-modules/nurse-doctor/workarea/workarea.component.ts @@ -2122,6 +2122,34 @@ 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, @@ -2231,7 +2259,7 @@ export class WorkareaComponent !this.schedulerData ) required.push(this.current_language_set.nurseData.scheduleTM); - + if (required.length) { this.confirmationService.notify( this.current_language_set.alerts.info.belowFields, @@ -2680,6 +2708,37 @@ export class WorkareaComponent } } + // For quick consult doctor flow, ensure at least one prescription exists + if (this.attendant === 'doctor') { + try { + const caseRecordForm = ( + this.patientMedicalForm.controls['patientCaseRecordForm'] + ); + const prescription = + caseRecordForm && caseRecordForm.controls + ? caseRecordForm.controls['drugPrescriptionForm'] + : 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( this.current_language_set.alerts.info.belowFields, diff --git a/src/assets/English.json b/src/assets/English.json index 0673d7a..b338253 100644 --- a/src/assets/English.json +++ b/src/assets/English.json @@ -105,7 +105,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", @@ -298,7 +298,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",