Skip to content

Commit 8368ebb

Browse files
authored
Merge pull request #456 from udsm-dhis2-lab/feature/remote-patient-history
Feature/remote patient history
2 parents 76a7dfd + 77efed6 commit 8368ebb

12 files changed

+240
-23
lines changed

omods/core/api/src/main/java/org/openmrs/module/icare/core/impl/ICareServiceImpl.java

+14
Original file line numberDiff line numberDiff line change
@@ -1492,6 +1492,20 @@ public String getSharedRecordsFromExternalMediator(String hfrCode,
14921492
String username = administrationService.getGlobalProperty(authReferenceKey + ".username");
14931493
String password = administrationService.getGlobalProperty(authReferenceKey + ".password");
14941494

1495+
if (id != null) {
1496+
mediatorUrl += "?id=" + id;
1497+
}
1498+
1499+
if (hfrCode != null) {
1500+
if (mediatorUrl.contains("?")) {
1501+
mediatorUrl += "&hfrCode="+ hfrCode;
1502+
}
1503+
}
1504+
if (idType != null) {
1505+
if (mediatorUrl.contains("?")) {
1506+
mediatorUrl += "&idType="+ idType;
1507+
}
1508+
}
14951509
// Construct the URL for the GET request
14961510
URL url = new URL(instance.concat(mediatorUrl));
14971511
HttpURLConnection con = (HttpURLConnection) url.openConnection();

ui/src/app/shared/components/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ import { GenericDrugsListComponent } from "./generic-drugs-list/generic-drugs-li
131131
import { UnitsOfMeasureSettingsComponent } from "./units-of-measure-settings/units-of-measure-settings.component";
132132
import { SharedDisplayOrderedTestsNamesComponent } from "./shared-display-ordered-tests-names/shared-display-ordered-tests-names.component";
133133
import { SharedCollectedAmountComponent } from "./shared-collected-amount/shared-collected-amount.component";
134+
import { SharedRemotePatientHistoryComponent } from "./shared-remote-patient-history/shared-remote-patient-history.component";
134135

135136
export const components: any[] = [
136137
PatientAddressComponent,
@@ -266,6 +267,7 @@ export const components: any[] = [
266267
UnitsOfMeasureSettingsComponent,
267268
SharedDisplayOrderedTestsNamesComponent,
268269
SharedCollectedAmountComponent,
270+
SharedRemotePatientHistoryComponent,
269271
];
270272

271273
export const sharedEntryComponents: any[] = [

ui/src/app/shared/components/patient-history-data/patient-history-data.component.ts

-2
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,6 @@ export class PatientHistoryDataComponent implements OnInit {
242242
this.specificDrugConceptUuid,
243243
this.prescriptionArrangementFields
244244
);
245-
console.log("visitHistory?.visitOrderedData ..........................");
246-
console.log(this.visitHistory?.visitOrderedData);
247245
}
248246

249247
onPrint(e: any, visitData: any): void {

ui/src/app/shared/components/patient-history/patient-history.component.ts

-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ export class PatientHistoryComponent implements OnInit {
8484
) {}
8585

8686
ngOnInit(): void {
87-
console.log(this.patient);
8887
this.loadData();
8988
}
9089

ui/src/app/shared/components/shared-patient-dashboard/shared-patient-dashboard.component.html

+45-3
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@
263263
>
264264
Refer
265265
</button>
266-
<button
266+
<!-- <button
267267
mat-menu-item
268268
[disabled]="
269269
activeVisitDeathStatus || !dashboardParams?.provider
@@ -278,7 +278,7 @@
278278
"
279279
>
280280
Get remote history
281-
</button>
281+
</button> -->
282282
<button
283283
mat-menu-item
284284
[disabled]="
@@ -405,7 +405,29 @@
405405
[activeVisit]="activeVisit"
406406
></app-shared-visit-history-summary> -->
407407
<div class="w-100" *ngIf="showHistoryDetails">
408-
<mat-accordion>
408+
<mat-radio-group aria-label="History options">
409+
<mat-radio-button
410+
color="primary"
411+
[checked]="
412+
selectedHistoryCategory === 'local'
413+
"
414+
[value]="'local'"
415+
(change)="onToggleHistoryType($event)"
416+
>Local</mat-radio-button
417+
>
418+
<mat-radio-button
419+
color="primary"
420+
[checked]="
421+
selectedHistoryCategory === 'remote'
422+
"
423+
[value]="'remote'"
424+
(change)="onToggleHistoryType($event)"
425+
>Remote</mat-radio-button
426+
>
427+
</mat-radio-group>
428+
<mat-accordion
429+
*ngIf="selectedHistoryCategory === 'local'"
430+
>
409431
<mat-expansion-panel
410432
class="mb-2 border p-0"
411433
[expanded]="true"
@@ -425,6 +447,26 @@
425447
></app-patient-history>
426448
</mat-expansion-panel>
427449
</mat-accordion>
450+
<mat-accordion
451+
*ngIf="selectedHistoryCategory === 'remote'"
452+
>
453+
<mat-expansion-panel
454+
class="mb-2 border p-0"
455+
[expanded]="true"
456+
>
457+
<mat-expansion-panel-header>
458+
<mat-panel-title
459+
>Remote Patient History
460+
</mat-panel-title>
461+
</mat-expansion-panel-header>
462+
<app-shared-remote-patient-history
463+
[patient]="
464+
dashboardParams?.currentPatient?.patient
465+
"
466+
[activeVisit]="dashboardParams?.activeVisit"
467+
></app-shared-remote-patient-history>
468+
</mat-expansion-panel>
469+
</mat-accordion>
428470
</div>
429471
</div>
430472
</div>

ui/src/app/shared/components/shared-patient-dashboard/shared-patient-dashboard.component.ts

+7
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ import { keyBy, orderBy } from "lodash";
8181
import { loadActiveVisit } from "src/app/store/actions/visit.actions";
8282
import { GoogleAnalyticsService } from "src/app/google-analytics.service";
8383
import { SharedRemotePatientHistoryModalComponent } from "../../dialogs/shared-remote-patient-history-modal/shared-remote-patient-history-modal.component";
84+
import { MatRadioChange } from "@angular/material/radio";
8485

8586
@Component({
8687
selector: "app-shared-patient-dashboard",
@@ -154,6 +155,8 @@ export class SharedPatientDashboardComponent implements OnInit {
154155
tabsToShow: string[] = ["LABORATORY", "PROCEDURE", "RADIOLOGY"];
155156
currentFormDetails: any = {};
156157
useSideBar: boolean = false;
158+
159+
selectedHistoryCategory: string = "local";
157160
constructor(
158161
private store: Store<AppState>,
159162
private dialog: MatDialog,
@@ -597,4 +600,8 @@ export class SharedPatientDashboardComponent implements OnInit {
597600
},
598601
});
599602
}
603+
604+
onToggleHistoryType(event: MatRadioChange): void {
605+
this.selectedHistoryCategory = event?.value;
606+
}
600607
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<ng-container
2+
*ngIf="{ remotePatientHistory: remotePatientHistory$ | async } as params"
3+
>
4+
<div class="text-center" *ngIf="!params?.remotePatientHistory">
5+
<div>Requesting client history from HDU API...</div>
6+
<div class="mt-3 d-flex justify-content-center w-100">
7+
<mat-spinner diameter="50" strokeWidth="2"></mat-spinner>
8+
</div>
9+
</div>
10+
<div class="d-flex justify-content-end">
11+
<app-form
12+
[fields]="[identifierFormField]"
13+
(formUpdate)="onFormUpdate($event)"
14+
></app-form>
15+
</div>
16+
<div *ngIf="params?.remotePatientHistory">
17+
<h4>
18+
{{ patient?.display }}
19+
</h4>
20+
<hr />
21+
<div
22+
class="mb-2"
23+
*ngFor="let history of params?.remotePatientHistory?.results"
24+
>
25+
<div class="row">
26+
<div class="col-md-6 col-sm-12 col-sx-12">
27+
<p style="margin-bottom: 0px">
28+
Names: {{ history?.demographicDetails?.firstName }}
29+
<span *ngIf="history?.demographicDetails?.middleName">
30+
- {{ history?.demographicDetails?.lastName }}
31+
</span>
32+
- {{ history?.demographicDetails?.lastName }}
33+
</p>
34+
<p>Gender: {{ history?.demographicDetails?.gender }}</p>
35+
</div>
36+
<div class="col-md-6 col-sm-12 col-sx-12">
37+
<h5>Facility details</h5>
38+
<p>Name: {{ history?.facilityDetails?.name }}</p>
39+
<p>HFR Code: {{ history?.facilityDetails?.code }}</p>
40+
</div>
41+
</div>
42+
</div>
43+
</div>
44+
</ng-container>

ui/src/app/shared/components/shared-remote-patient-history/shared-remote-patient-history.component.scss

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { SharedRemotePatientHistoryComponent } from './shared-remote-patient-history.component';
4+
5+
describe('SharedRemotePatientHistoryComponent', () => {
6+
let component: SharedRemotePatientHistoryComponent;
7+
let fixture: ComponentFixture<SharedRemotePatientHistoryComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
imports: [SharedRemotePatientHistoryComponent]
12+
})
13+
.compileComponents();
14+
15+
fixture = TestBed.createComponent(SharedRemotePatientHistoryComponent);
16+
component = fixture.componentInstance;
17+
fixture.detectChanges();
18+
});
19+
20+
it('should create', () => {
21+
expect(component).toBeTruthy();
22+
});
23+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import { Component, Input, OnInit } from "@angular/core";
2+
import { OpenmrsHttpClientService } from "../../modules/openmrs-http-client/services/openmrs-http-client.service";
3+
import { Observable } from "rxjs";
4+
import { Dropdown } from "../../modules/form/models/dropdown.model";
5+
import { FormValue } from "../../modules/form/models/form-value.model";
6+
7+
@Component({
8+
selector: "app-shared-remote-patient-history",
9+
templateUrl: "./shared-remote-patient-history.component.html",
10+
styleUrl: "./shared-remote-patient-history.component.scss",
11+
})
12+
export class SharedRemotePatientHistoryComponent implements OnInit {
13+
@Input() patient: any;
14+
@Input() activeVisit: any;
15+
selectedIdentifier: string;
16+
remotePatientHistory$: Observable<any>;
17+
identifierFormField: any;
18+
constructor(private httpClientService: OpenmrsHttpClientService) {}
19+
20+
ngOnInit(): void {
21+
this.selectedIdentifier = this.getPreferredIdentifier(
22+
this.patient?.identifiers
23+
);
24+
this.identifierFormField = new Dropdown({
25+
id: "identifierType",
26+
key: "identifierType",
27+
label: "Identifier Types",
28+
options: this.patient?.identifiers?.map((identifier: any) => {
29+
return {
30+
id: identifier?.identifierType?.display,
31+
key: identifier?.identifierType?.display,
32+
label: identifier?.identifierType?.display,
33+
value: identifier?.identifier,
34+
};
35+
}),
36+
});
37+
this.getRemoteHistory();
38+
}
39+
40+
getRemoteHistory(): void {
41+
this.remotePatientHistory$ = this.httpClientService.get(
42+
`icare/sharedrecords?id=` + this.selectedIdentifier
43+
);
44+
}
45+
46+
onFormUpdate(formValue: FormValue): void {
47+
const values = formValue.getValues();
48+
const identifierType = values?.identifierType?.value;
49+
if (identifierType) {
50+
this.selectedIdentifier = this.getIdentifierByIdentifierType(
51+
identifierType,
52+
this.patient?.identifiers
53+
);
54+
this.getRemoteHistory();
55+
}
56+
}
57+
58+
getIdentifierByIdentifierType(
59+
identifierType: string,
60+
identifiers: any[]
61+
): string {
62+
return (identifiers?.filter(
63+
(identifier: any) =>
64+
identifier?.identifierType?.display === identifierType
65+
) || [])[0]?.identifier;
66+
}
67+
68+
getPreferredIdentifier(identifiers: any[]): string {
69+
return (identifiers?.filter((identifier: any) => identifier?.preferred) ||
70+
[])[0]?.identifier;
71+
}
72+
}
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
1-
<mat-toolbar color="primary">
2-
<span>Remote patient history</span>
3-
<span class="toolbar-spacer"></span>
4-
<button mat-icon-button mat-dialog-close matTooltip="close">
5-
<mat-icon>close</mat-icon>
6-
</button>
7-
</mat-toolbar>
1+
<ng-container
2+
*ngIf="{ remotePatientHistory: remotePatientHistory$ | async } as params"
3+
>
4+
<mat-toolbar color="primary">
5+
<span
6+
>Remote patient history -
7+
{{ data?.currentPatient?.patient?.display }}</span
8+
>
9+
<span class="toolbar-spacer"></span>
10+
<button mat-icon-button mat-dialog-close matTooltip="close">
11+
<mat-icon>close</mat-icon>
12+
</button>
13+
</mat-toolbar>
814

9-
<mat-dialog-content class="mat-typography">
10-
<div>
11-
<h5>Remote patient history</h5>
12-
</div>
13-
</mat-dialog-content>
15+
<mat-dialog-content class="mat-typography">
16+
<div class="text-center" *ngIf="!params?.remotePatientHistory">
17+
<div>Requesting client history from HDU API...</div>
18+
<div class="mt-3 d-flex justify-content-center w-100">
19+
<mat-spinner diameter="50" strokeWidth="2"></mat-spinner>
20+
</div>
21+
</div>
22+
<div *ngIf="params?.remotePatientHistory">
23+
<h5>Remote patient history</h5>
24+
</div>
25+
</mat-dialog-content>
26+
</ng-container>
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
11
import { Component, Inject, OnInit } from "@angular/core";
22
import { MAT_DIALOG_DATA } from "@angular/material/dialog";
33
import { OpenmrsHttpClientService } from "../../modules/openmrs-http-client/services/openmrs-http-client.service";
4+
import { Observable } from "rxjs";
45

56
@Component({
67
selector: "app-shared-remote-patient-history-modal",
78
templateUrl: "./shared-remote-patient-history-modal.component.html",
89
styleUrl: "./shared-remote-patient-history-modal.component.scss",
910
})
1011
export class SharedRemotePatientHistoryModalComponent implements OnInit {
12+
remotePatientHistory$: Observable<any>;
1113
constructor(
1214
@Inject(MAT_DIALOG_DATA) public data: any,
1315
private httpClientService: OpenmrsHttpClientService
1416
) {}
1517

1618
ngOnInit(): void {
1719
console.log(this.data);
18-
this.httpClientService
19-
.get("icare/sharedRecords")
20-
.subscribe((response: any) => {
21-
console.log(response);
22-
});
20+
this.remotePatientHistory$ = this.httpClientService.get(
21+
`icare/sharedrecords?id=` +
22+
(this.data?.currentPatient?.patient?.identifiers?.filter(
23+
(identifier: any) => identifier?.identifierType?.display === "MRN"
24+
) || [])[0]?.identifier
25+
);
2326
}
2427
}

0 commit comments

Comments
 (0)