Skip to content

Commit

Permalink
Merge pull request #457 from udsm-dhis2-lab/feature/remote-patient-hi…
Browse files Browse the repository at this point in the history
…story

Feature/remote patient history
  • Loading branch information
josephatJ authored Oct 15, 2024
2 parents 8368ebb + a36b666 commit 151d49d
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,10 @@ public class ICareConfig {
public static final String ORDER_TO_SKIP_BILLING_ADVISOR = "iCare.billing.orderTypes.skipBillingOrderAdvisor";

public static final String MACHINE_INTEGRATION_PRIMARY_CONCEPT_SOURCE = "icare.laboratory.concept.mappings.machineIntegration.conceptSourceUuid";

public static final String ALLOW_REMOTE_HISTORY = "iCare.interoperability.settings.allowRemoteHistory";

public static final String DATA_EXCHANGE_LOCATION_TAG = "iCare.interoperability.settings.exchangeLocationsTag";

public static final String HFRCODE_LOCATION_ATTRIBUTE_TYPE_UUID = "icare.location.attributes.hfrCode.attributeUuid";
}
22 changes: 21 additions & 1 deletion omods/core/omod/src/main/resources/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,27 @@
For storing concept source used to map test from machine results
</description>
</globalProperty>

<globalProperty>
<property>iCare.interoperability.settings.allowRemoteHistory</property>
<defaultValue>false</defaultValue>
<description>
</description>
</globalProperty>
<globalProperty>
<property>iCare.interoperability.settings.exchangeLocationsTag</property>
<defaultValue>HDU API Exchange</defaultValue>
<description>
Location tag for facilities allowed for health data universal exchange
</description>
</globalProperty>
<globalProperty>
<property>icare.location.attributes.hfrCode.attributeUuid</property>
<defaultValue>UUID</defaultValue>
<description>
HFRCODE Location Attribute type UUID
</description>
</globalProperty>

<!-- Internationalization -->
<!-- All message codes should start with @MODULE_ID@.* -->
<messages>
Expand Down
52 changes: 26 additions & 26 deletions ui/src/app/core/services/location.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,32 +205,32 @@ export class LocationService {
if (parameters?.v) {
othersParameters += `&v=${parameters?.v}`;
}
return this.httpClient
.get(
"location?tag=" +
tagName +
(othersParameters != "" ? othersParameters : "&v=full&limit=100")
)
.pipe(
map((response) => {
return (
response?.results?.filter((res: any) => !res?.retired) || []
).map((result) => {
return {
...result,
childLocations:
result?.childLocations?.filter(
(childLoc: any) => !childLoc?.retired
) || [],
attributes:
result?.attributes && result?.attributes?.length > 0
? result?.attributes.filter((attribute) => !attribute?.voided)
: [],
};
});
}),
catchError((error) => of(error))
);
const path =
"location?tag=" +
tagName +
(othersParameters != "" ? othersParameters : "&v=full&limit=100");
return this.httpClient.get(path).pipe(
map((response) => {
return (
response?.results?.filter((res: any) => !res?.retired) || []
).map((result) => {
return {
...result,
childLocations:
result?.childLocations?.filter(
(childLoc: any) => !childLoc?.retired
) || [],
attributes:
result?.attributes && result?.attributes?.length > 0
? result?.attributes.filter((attribute) => !attribute?.voided)
: [],
};
});
}),
catchError((error) => {
return of(error);
})
);
}

getLocationsByTagNames(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
visitEndingControlStatusesConcept:
visitEndingControlStatusesConcept$ | async,
patientInvoice: patientInvoice$ | async,
latestRound: latestRound$ | async
latestRound: latestRound$ | async,
shouldAllowRemoteHistory: shouldAllowRemoteHistory$ | async,
dataExchangeLocations: dataExchangeLocations$ | async,
hfrCodeLocationAttribute: hfrCodeLocationAttribute$ | async
} as dashboardParams"
>
<div
Expand Down Expand Up @@ -405,7 +408,13 @@
[activeVisit]="activeVisit"
></app-shared-visit-history-summary> -->
<div class="w-100" *ngIf="showHistoryDetails">
<mat-radio-group aria-label="History options">
<mat-radio-group
aria-label="History options"
*ngIf="
dashboardParams?.shouldAllowRemoteHistory ==
'true'
"
>
<mat-radio-button
color="primary"
[checked]="
Expand Down Expand Up @@ -460,10 +469,20 @@
</mat-panel-title>
</mat-expansion-panel-header>
<app-shared-remote-patient-history
*ngIf="
dashboardParams?.dataExchangeLocations &&
dashboardParams?.hfrCodeLocationAttribute
"
[patient]="
dashboardParams?.currentPatient?.patient
"
[activeVisit]="dashboardParams?.activeVisit"
[dataExchangeLocations]="
dashboardParams?.dataExchangeLocations
"
[hfrCodeLocationAttribute]="
dashboardParams?.hfrCodeLocationAttribute
"
></app-shared-remote-patient-history>
</mat-expansion-panel>
</mat-accordion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,13 @@ import { UserService } from "src/app/modules/maintenance/services/users.service"
import { ConceptsService } from "../../resources/concepts/services/concepts.service";
import { VisitConsultationStatusModalComponent } from "../../dialogs/visit-consultation-status-modal/visit-consultation-status-modal.component";
import { BillingService } from "src/app/modules/billing/services/billing.service";
import { map, map as rxMap } from "rxjs/operators";
import { map, map as rxMap, switchMap } from "rxjs/operators";
import { keyBy, orderBy } from "lodash";
import { loadActiveVisit } from "src/app/store/actions/visit.actions";
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";

@Component({
selector: "app-shared-patient-dashboard",
Expand Down Expand Up @@ -157,6 +158,10 @@ export class SharedPatientDashboardComponent implements OnInit {
useSideBar: boolean = false;

selectedHistoryCategory: string = "local";

shouldAllowRemoteHistory$: Observable<any>;
dataExchangeLocations$: Observable<any>;
hfrCodeLocationAttribute$: Observable<any>;
constructor(
private store: Store<AppState>,
private dialog: MatDialog,
Expand All @@ -166,7 +171,8 @@ export class SharedPatientDashboardComponent implements OnInit {
private userService: UserService,
private conceptService: ConceptsService,
private billingService: BillingService,
private googleAnalyticsService: GoogleAnalyticsService
private googleAnalyticsService: GoogleAnalyticsService,
private locationService: LocationService
) {
this.store.dispatch(loadEncounterTypes());
}
Expand Down Expand Up @@ -273,6 +279,33 @@ export class SharedPatientDashboardComponent implements OnInit {
this.systemSettingsService.getSystemSettingsByKey(
"iCare.ipd.encounterType.observationChart"
);

this.shouldAllowRemoteHistory$ =
this.systemSettingsService.getSystemSettingsByKey(
"iCare.interoperability.settings.allowRemoteHistory"
);

this.hfrCodeLocationAttribute$ =
this.systemSettingsService.getSystemSettingsByKey(
"icare.location.attributes.hfrCode.attributeUuid"
);

this.dataExchangeLocations$ = this.systemSettingsService
.getSystemSettingsByKey(
"iCare.interoperability.settings.exchangeLocationsTag"
)
.pipe(
switchMap((response: any) => {
return response != "none"
? this.locationService.getLocationsByTagName(response).pipe(
map((locationsResponse: any) => {
return locationsResponse;
})
)
: "";
})
);

this.facilityDetails$ = this.configService.getFacilityDetails();
this.facilityDetails$ = this.userService.getLoginLocations();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
</div>
<div class="d-flex justify-content-end">
<app-form
[fields]="[identifierFormField]"
[fields]="[identifierFormField, locationFormField]"
[isFormHorizontal]="true"
(formUpdate)="onFormUpdate($event)"
></app-form>
</div>
Expand All @@ -32,6 +33,12 @@ <h4>
- {{ history?.demographicDetails?.lastName }}
</p>
<p>Gender: {{ history?.demographicDetails?.gender }}</p>
<h5 class="mt-2">Visit summary</h5>
<p>ID: {{ history?.visitDetails?.id }}</p>
<p>Visit date: {{ history?.visitDetails?.visitDate | date }}</p>
<p>
Visit closed date: {{ history?.visitDetails?.closedDate | date }}
</p>
</div>
<div class="col-md-6 col-sm-12 col-sx-12">
<h5>Facility details</h5>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,17 @@ import { FormValue } from "../../modules/form/models/form-value.model";
export class SharedRemotePatientHistoryComponent implements OnInit {
@Input() patient: any;
@Input() activeVisit: any;
@Input() dataExchangeLocations: any[];
@Input() hfrCodeLocationAttribute: string;
selectedIdentifier: string;
selectedHFRCode: string;
remotePatientHistory$: Observable<any>;
identifierFormField: any;
locationFormField: any;
constructor(private httpClientService: OpenmrsHttpClientService) {}

ngOnInit(): void {
// console.log(this.dataExchangeLocations);
this.selectedIdentifier = this.getPreferredIdentifier(
this.patient?.identifiers
);
Expand All @@ -27,30 +32,58 @@ export class SharedRemotePatientHistoryComponent implements OnInit {
label: "Identifier Types",
options: this.patient?.identifiers?.map((identifier: any) => {
return {
id: identifier?.identifierType?.display,
key: identifier?.identifierType?.display,
name: identifier?.identifierType?.display,
label: identifier?.identifierType?.display,
value: identifier?.identifier,
value: identifier?.identifierType?.display,
};
}),
});
// console.log("dataExchangeLocations", this.dataExchangeLocations);
this.locationFormField = new Dropdown({
id: "location",
key: "location",
label: "Health Facility",
options: this.dataExchangeLocations?.map((location: any) => {
return {
key: location?.uuid,
name: location?.display,
label: location?.display,
value: this.getHFRCode(location?.attributes),
};
}),
});
this.getRemoteHistory();
}

getHFRCode(locationAttributes: any): string {
return (locationAttributes?.filter(
(location: any) =>
location?.attributeType?.uuid === this.hfrCodeLocationAttribute
) || [])[0]?.value;
}

getRemoteHistory(): void {
this.remotePatientHistory$ = this.httpClientService.get(
`icare/sharedrecords?id=` + this.selectedIdentifier
`icare/sharedrecords?id=${this.selectedIdentifier}${
this.selectedHFRCode ? "&hfrCode=" + this.selectedHFRCode : ""
}`
);
}

onFormUpdate(formValue: FormValue): void {
const values = formValue.getValues();
const identifierType = values?.identifierType?.value;
const identifierType = values?.identifierType?.value
? values?.identifierType?.value
: "MRN";
this.selectedHFRCode = values?.location?.value;
if (identifierType) {
this.selectedIdentifier = this.getIdentifierByIdentifierType(
identifierType,
this.patient?.identifiers
);
}
if (this.selectedHFRCode || this.selectedIdentifier) {
this.getRemoteHistory();
}
}
Expand All @@ -59,6 +92,8 @@ export class SharedRemotePatientHistoryComponent implements OnInit {
identifierType: string,
identifiers: any[]
): string {
console.log(identifiers);
console.log(identifierType);
return (identifiers?.filter(
(identifier: any) =>
identifier?.identifierType?.display === identifierType
Expand Down

0 comments on commit 151d49d

Please sign in to comment.