Skip to content

Commit

Permalink
Merge pull request #494 from udsm-dhis2-lab/feature/clinic-notes
Browse files Browse the repository at this point in the history
Merge improvement to adding time to fill form also UI Improvement on clinic forms
  • Loading branch information
iamgaspardev authored Dec 13, 2024
2 parents 466be63 + e3566ec commit c41c53b
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
*ngIf="params?.savingObservations"
mode="indeterminate"
></mat-progress-bar>
<!-- on observation use useFilledObsData ? clinicalObservations :null in case populate data on form-->
<app-capture-form-data
*ngIf="
currentCustomForm &&
Expand All @@ -42,7 +41,7 @@
clinicConfigurations?.forms[currentCustomForm?.uuid]?.dependsOn
?.length == 0)
"
[observations]="useFilledObsData ? null : null"
[observations]="useFilledObsData ? clinicalObservations : null"
[form]="currentCustomForm"
[visit]="visit"
[patient]="patient"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { indexOf, keyBy, orderBy } from "lodash";

import * as moment from "moment";
import { GoogleAnalyticsService } from "src/app/google-analytics.service";
import { GlobalSettingService } from "../../resources/global-setting/services";

@Component({
selector: "app-clinical-notes",
Expand All @@ -36,6 +37,7 @@ export class ClinicalNotesComponent implements OnInit {
@Input() provider: any;
@Input() clinicConfigurations: any;
@Input() forms: any[];
@Input() clearingFormTime?: number;
savingObservations$: Observable<boolean>;
ordersUpdates$: Observable<any>;

Expand All @@ -45,6 +47,7 @@ export class ClinicalNotesComponent implements OnInit {
currentCustomFormName: string;
formData: any;
searchingText: string;

atLeastOneFieldHasData: boolean = false;
currentFormHasRequiredData: boolean = false;
dependedFormHasData: boolean = false;
Expand All @@ -57,11 +60,11 @@ export class ClinicalNotesComponent implements OnInit {
constructor(
private store: Store<AppState>,
private observationService: ObservationService,
private globalSettingService: GlobalSettingService,
private googleAnalyticsService: GoogleAnalyticsService
) {}

ngOnInit(): void {

this.clinicConfigurations = {
...this.clinicConfigurations,
forms: keyBy(
Expand All @@ -87,7 +90,7 @@ export class ClinicalNotesComponent implements OnInit {
(key) => this.clinicalObservations[key]?.latest
);
const concepts = identifyConceptsFromFormattedForm(this.currentCustomForm);
console.log("forms data",this.currentCustomForm);
// this.loadGlobalProperty();
// this.currentFormHasRequiredData =
// (
// Object.keys(this.clinicalObservations).filter(
Expand Down Expand Up @@ -118,7 +121,10 @@ export class ClinicalNotesComponent implements OnInit {
moment(new Date()).diff(moment(latestObsTime))
);
// TODO: Add support to use configured time for the 2 hrs constant
this.useFilledObsData = duration.asHours() > 2 ? false : true;
console.log("clearingFormTime .....",this.clearingFormTime);

this.useFilledObsData = duration.asHours() > this.clearingFormTime ? false : true;
console.log("useFilledObsData .....",this.useFilledObsData);
}

this.dependedFormHasData = this.evaluateFormDependency(
Expand Down Expand Up @@ -241,7 +247,7 @@ export class ClinicalNotesComponent implements OnInit {
)?.length > 0;
}

onConfirm(e: Event, visit: any,form:any): void {
onConfirm(e: Event, visit: any, form: any): void {
e.stopPropagation();
this.updateConsultationOrder.emit();
let obs = getObservationsFromForm(
Expand Down Expand Up @@ -279,8 +285,7 @@ export class ClinicalNotesComponent implements OnInit {
this.saveObservations.emit();
}

this.trackActionForAnalytics(`${this.currentCustomForm?.name}: Save`);

this.trackActionForAnalytics(`${this.currentCustomForm?.name}: Save`);
});
// this.saveObservations.emit(
// getObservationsFromForm(
Expand All @@ -298,13 +303,8 @@ export class ClinicalNotesComponent implements OnInit {

trackActionForAnalytics(eventname: any) {
// Send data to Google Analytics
this.googleAnalyticsService.sendAnalytics(
"Clinic",
eventname,
"Clinic"
);
this.googleAnalyticsService.sendAnalytics("Clinic", eventname, "Clinic");
}


onClear(event: Event, form: any): void {
event.stopPropagation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,33 @@
<mat-icon>arrow_back</mat-icon>
Back to Client List
</button>
<a mat-icon-button class="mr-4" (click)="toggleSideBarMenu($event)">

<div class="row">
<div *ngFor="let form of dashboardParams?.forms" class="form-button-wrapper">
<button
class="buttonstyle"
mat-stroked-button
[ngClass]="{
'selected-form':
(selectedForm &&
!showHistoryDetails &&
selectedForm?.uuid === form?.uuid) ||
(!selectedForm &&
!showHistoryDetails &&
dashboardParams?.forms[0] &&
dashboardParams?.forms[0]?.uuid === form?.uuid)
}"
(click)="getSelectedForm($event, form)"
>
{{ form?.name }}
</button>
</div>
</div>


<!-- <a mat-icon-button class="mr-4" (click)="toggleSideBarMenu($event)">
<mat-icon>menu</mat-icon>
</a>
</a> -->
<ng-container *ngIf="!useSideBar"> </ng-container>
</div>

Expand Down Expand Up @@ -509,6 +533,7 @@
[shouldUseOwnFormSelection]="false"
[clinicConfigurations]="clinicConfigurations"
[provider]="dashboardParams?.provider"
[clearingFormTime]="clearingFormTime"
(updateConsultationOrder)="onUpdateConsultationOrder()"
[selectedForm]="
selectedForm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ button:hover {
button {
outline: none !important;
}
.buttonstyle{
margin-left: 10px;
}

.patient-dashboard-container {
padding-bottom: 5px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ import { GoogleAnalyticsService } from "src/app/google-analytics.service";
import { SharedRemotePatientHistoryModalComponent } from "../../dialogs/shared-remote-patient-history-modal/shared-remote-patient-history-modal.component";
import { MatRadioChange } from "@angular/material/radio";
import { LocationService } from "src/app/core/services";
import { GlobalSettingService } from "../../resources/global-setting/services";

@Component({
selector: "app-shared-patient-dashboard",
Expand Down Expand Up @@ -156,6 +157,7 @@ export class SharedPatientDashboardComponent implements OnInit {
tabsToShow: string[] = ["LABORATORY", "PROCEDURE", "RADIOLOGY"];
currentFormDetails: any = {};
useSideBar: boolean = false;
clearingFormTime: number = 0.5;

selectedHistoryCategory: string = "local";

Expand All @@ -171,6 +173,7 @@ export class SharedPatientDashboardComponent implements OnInit {
private userService: UserService,
private conceptService: ConceptsService,
private billingService: BillingService,
private globalSettingService: GlobalSettingService,
private googleAnalyticsService: GoogleAnalyticsService,
private locationService: LocationService
) {
Expand All @@ -187,7 +190,6 @@ export class SharedPatientDashboardComponent implements OnInit {
obs?.concept?.uuid === this.visitEndingControlStatusesConceptUuid
) || [])[0]?.valueObject;
}
// console.log("Active visit are .............................................",this.activeVisit);
this.onStartConsultation(this.activeVisit);
this.store.dispatch(loadOrderTypes());
this.orderTypes$ = this.store.select(getAllOrderTypes);
Expand Down Expand Up @@ -366,9 +368,19 @@ export class SharedPatientDashboardComponent implements OnInit {
event.stopPropagation();
this.useSideBar = !this.useSideBar;
}
async loadGlobalProperty() {
try {
const globalProperty = await this.globalSettingService.getSpecificGlobalProperties("ed9dac4a-5b2a-4a5f-8ee2-ca0d88b08506").toPromise();
const minutes = parseInt(globalProperty?.value ?? "0", 10);
this.clearingFormTime = isNaN(minutes / 60) ? 0.5 : minutes / 60;
console.log("time received :",this.clearingFormTime);
} catch (error) {
console.error("Error occurred:", error);
this.clearingFormTime = 0.5;
}
}

onToggleVitalsSummary(event: Event): void {
console.log("data tracing ...............");
console.log(event);
event.stopPropagation();
this.trackActionForAnalytics(`View Vitals: Open`);
Expand All @@ -377,6 +389,7 @@ export class SharedPatientDashboardComponent implements OnInit {

getSelectedForm(event: Event, form: any): void {
this.trackActionForAnalytics(`${form?.name}: Open`);
this.loadGlobalProperty();
this.readyForClinicalNotes = false;
if (event) {
event.stopPropagation();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* tslint:disable:no-unused-variable */

import { TestBed, inject, waitForAsync } from '@angular/core/testing';
import { GlobalSettingService } from './globalsetting.service';

describe('Service: Observation', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [GlobalSettingService]
});
});

it('should ...', inject([GlobalSettingService], (service: GlobalSettingService) => {
expect(service).toBeTruthy();
}));
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Injectable } from "@angular/core";
import { from, Observable, of, zip } from "rxjs";
import { catchError, map, switchMap, tap } from "rxjs/operators";
import { OpenmrsHttpClientService } from "src/app/shared/modules/openmrs-http-client/services/openmrs-http-client.service";
import { Api, ObsCreate, ObsGetFull, ObsUpdate } from "../../openmrs";

import { omit } from "lodash";
import { HttpClient } from "@angular/common/http";
import { Observation } from "../../observation/models/observation.model";

@Injectable({
providedIn: "root",
})
export class GlobalSettingService {
constructor(
private api: Api,
private httpClient: OpenmrsHttpClientService,
private http: HttpClient
) {}


getSpecificGlobalProperties(uuid: string): Observable<any> {
const endpoint = `systemsetting/${uuid}`;
return this.httpClient.get(endpoint).pipe(
map((response: any) => {
return response;
}),
catchError((error) => {
console.error("Failed to fetch global property:", error);
return of(null);
})
);
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { GlobalSettingService } from './/globalsetting.service';

0 comments on commit c41c53b

Please sign in to comment.