From f29c8ee88fb239efb74f24a57d2f49a92f4c4a5d Mon Sep 17 00:00:00 2001 From: JohansenCoder Date: Thu, 16 Jan 2025 23:51:02 -0800 Subject: [PATCH 1/3] Fixed issue #501 --- ui/package.json | 4 +- .../patient-medication-summary.component.ts | 73 ++++++++++++------- 2 files changed, 50 insertions(+), 27 deletions(-) diff --git a/ui/package.json b/ui/package.json index b12050c82..7a46ebd0b 100644 --- a/ui/package.json +++ b/ui/package.json @@ -3,8 +3,8 @@ "version": "0.0.0", "scripts": { "ng": "ng", - "start": "NODE_OPTIONS=--max_old_space_size=8192 ng serve", - "build": "NODE_OPTIONS=--max_old_space_size=8192 ng build", + "start": "set NODE_OPTIONS=--max_old_space_size=8192 && ng serve", + "build": "set NODE_OPTIONS=--max_old_space_size=8192 && ng build", "build:prod": "ng build --aot --configuration production", "test": "ng test", "test:headless": "ng test --no-watch --no-progress --browsers=ChromeHeadlessCI", diff --git a/ui/src/app/shared/components/patient-medication-summary/patient-medication-summary.component.ts b/ui/src/app/shared/components/patient-medication-summary/patient-medication-summary.component.ts index 968cf3469..493cf15af 100644 --- a/ui/src/app/shared/components/patient-medication-summary/patient-medication-summary.component.ts +++ b/ui/src/app/shared/components/patient-medication-summary/patient-medication-summary.component.ts @@ -35,6 +35,7 @@ export class PatientMedicationSummaryComponent implements OnInit { patientDrugOrdersStatuses$: Observable; filteredDrugOrders$: Observable; visitDetails$: Observable; + constructor( private store: Store, private ordersService: OrdersService, @@ -145,32 +146,54 @@ export class PatientMedicationSummaryComponent implements OnInit { onAddOrder(e: Event) { e.stopPropagation(); - const dialog = this.dialog.open(DispensingFormComponent, { - width: "80%", - disableClose: true, - data: { - drugOrder: null, - patient: this.patientVisit?.patientUuid, - patientUuid: this.patientVisit?.patientUuid, - visit: this.patientVisit, - location: localStorage.getItem("currentLocation") - ? JSON.parse(localStorage.getItem("currentLocation")) - : null, - encounterUuid: JSON.parse(localStorage.getItem("patientConsultation"))[ - "encounterUuid" - ], - fromDispensing: this.fromDispensing, - showAddButton: false, - forConsultation: this.forConsultation, - }, - }); + + // Check for active orders before allowing new order + const activeOrders = this.filteredDrugOrders$; // You already have the filtered drug orders + activeOrders.subscribe((ordersData) => { + const activeMedication = ordersData.toBeDispensedDrugOrders.find( + (order) => new Date(order.stopDatetime) > new Date() + ); - dialog.afterClosed().subscribe((data) => { - this.loadVisit(); - if (data?.updateConsultationOrder) { - this.updateMedicationComponent.emit(); - this.updateConsultationOrder.emit(); + if (activeMedication) { + // Show error dialog: There's an active medication that needs to be completed + this.dialog.open(DispensingFormComponent, { + width: "80%", + disableClose: true, + data: { + message: "Cannot add a new dosage until the previous one is completed.", + }, + }); + return; // Prevent adding a new dosage } + + // Proceed to open the dispensing form if no active medication is found + const dialog = this.dialog.open(DispensingFormComponent, { + width: "80%", + disableClose: true, + data: { + drugOrder: null, + patient: this.patientVisit?.patientUuid, + patientUuid: this.patientVisit?.patientUuid, + visit: this.patientVisit, + location: localStorage.getItem("currentLocation") + ? JSON.parse(localStorage.getItem("currentLocation")) + : null, + encounterUuid: JSON.parse(localStorage.getItem("patientConsultation"))[ + "encounterUuid" + ], + fromDispensing: this.fromDispensing, + showAddButton: false, + forConsultation: this.forConsultation, + }, + }); + + dialog.afterClosed().subscribe((data) => { + this.loadVisit(); + if (data?.updateConsultationOrder) { + this.updateMedicationComponent.emit(); + this.updateConsultationOrder.emit(); + } + }); }); } -} +} \ No newline at end of file From 7bf44d83f3db3f4995c2b84b0763180f45991eb3 Mon Sep 17 00:00:00 2001 From: Alexioscreed Date: Fri, 17 Jan 2025 00:40:50 -0800 Subject: [PATCH 2/3] Fixing issue #501 --- .../patient-medication-summary.component.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/src/app/shared/components/patient-medication-summary/patient-medication-summary.component.ts b/ui/src/app/shared/components/patient-medication-summary/patient-medication-summary.component.ts index 493cf15af..cc8abba76 100644 --- a/ui/src/app/shared/components/patient-medication-summary/patient-medication-summary.component.ts +++ b/ui/src/app/shared/components/patient-medication-summary/patient-medication-summary.component.ts @@ -146,6 +146,7 @@ export class PatientMedicationSummaryComponent implements OnInit { onAddOrder(e: Event) { e.stopPropagation(); + // function to trigger add prescription // Check for active orders before allowing new order const activeOrders = this.filteredDrugOrders$; // You already have the filtered drug orders From 8afa87e8072bdc627fd57c171c0a2a81b25b1e0d Mon Sep 17 00:00:00 2001 From: ElionaRobinson Date: Fri, 17 Jan 2025 14:09:45 -0800 Subject: [PATCH 3/3] Fixing issue #501 --- .../patient-medication-summary.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/src/app/shared/components/patient-medication-summary/patient-medication-summary.component.ts b/ui/src/app/shared/components/patient-medication-summary/patient-medication-summary.component.ts index cc8abba76..31c2ee0a0 100644 --- a/ui/src/app/shared/components/patient-medication-summary/patient-medication-summary.component.ts +++ b/ui/src/app/shared/components/patient-medication-summary/patient-medication-summary.component.ts @@ -146,7 +146,7 @@ export class PatientMedicationSummaryComponent implements OnInit { onAddOrder(e: Event) { e.stopPropagation(); - // function to trigger add prescription + // function to add prescription // Check for active orders before allowing new order const activeOrders = this.filteredDrugOrders$; // You already have the filtered drug orders