Skip to content

Commit

Permalink
Add location meta tags to inventory resources (#1540)
Browse files Browse the repository at this point in the history
* Add location meta tags to inventory resources

* Fix test failures

* Deprecate data imports for products and inventory
  • Loading branch information
peterMuriuki authored Feb 13, 2025
1 parent baddc52 commit 9cf90ec
Show file tree
Hide file tree
Showing 18 changed files with 177 additions and 137 deletions.
1 change: 0 additions & 1 deletion .github/workflows/automation-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ jobs:
REACT_APP_ENABLE_FHIR_ORGANIZATION=true
REACT_APP_ENABLE_FHIR_TEAMS=true
REACT_APP_FHIR_ROOT_LOCATION_ID=eff94f33-c356-4634-8795-d52340706ba9
REACT_APP_FHIR_INVENTORY_LIST_ID=81b674df-e958-4684-8931-8feefa74d6fb
REACT_APP_FHIR_PATIENT_SORT_FIELDS=-_lastUpdated
REACT_APP_FHIR_PATIENT_BUNDLE_SIZE=5000
REACT_APP_ENABLE_FHIR_HEALTHCARE_SERVICES=false
Expand Down
1 change: 0 additions & 1 deletion app/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,3 @@ REACT_APP_COMMODITIES_LIST_RESOURCE_ID="uuid"
REACT_APP_PRACTITIONER_TO_ORG_ASSIGNMENT_STRATEGY=ONE_TO_MANY
REACT_APP_AUTHZ_STRATEGY=keycloak
REACT_APP_FHIR_ROOT_LOCATION_ID=uuid
REACT_APP_FHIR_INVENTORY_LIST_ID=uuid
2 changes: 0 additions & 2 deletions app/src/App/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
DISABLE_TEAM_MEMBER_REASSIGNMENT,
FHIR_API_BASE_URL,
KEYCLOAK_USERS_PAGE_SIZE,
FHIR_INVENTORY_LIST_ID,
} from '../configs/env';

export const BaseProps = {
Expand Down Expand Up @@ -114,6 +113,5 @@ export const commmodityProps = {

export const fhirCreateEditLocationProps = {
...BaseProps,
listId: FHIR_INVENTORY_LIST_ID,
commodityListId: COMMODITIES_LIST_RESOURCE_ID,
};
2 changes: 0 additions & 2 deletions app/src/configs/dispatchConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
PRACTITIONER_TO_ORG_ASSIGNMENT_STRATEGY,
AUTHZ_STRATEGY,
COMMODITIES_LIST_RESOURCE_ID,
FHIR_INVENTORY_LIST_ID,
OPENSRP_CLIENT_ID,
} from './env';
import { URL_BACKEND_LOGIN, URL_REACT_LOGIN } from '../constants';
Expand All @@ -39,7 +38,6 @@ const configObject: ConfigState = {
practToOrgAssignmentStrategy: PRACTITIONER_TO_ORG_ASSIGNMENT_STRATEGY,
rbacStrategy: AUTHZ_STRATEGY,
productListId: COMMODITIES_LIST_RESOURCE_ID,
inventoryListId: FHIR_INVENTORY_LIST_ID,
};

setAllConfigs(configObject);
2 changes: 0 additions & 2 deletions app/src/configs/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@ export const FHIR_PATIENT_BUNDLE_SIZE = Number(setEnv('REACT_APP_FHIR_PATIENT_BU

export const FHIR_ROOT_LOCATION_ID = setEnv('REACT_APP_FHIR_ROOT_LOCATION_ID', '');

export const FHIR_INVENTORY_LIST_ID = setEnv('REACT_APP_FHIR_INVENTORY_LIST_ID', '');

export const OPENSRP_WEB_VERSION = setEnv('REACT_APP_OPENSRP_WEB_VERSION', '');

export const SENTRY_CONFIGS = JSON.parse(setEnv('REACT_APP_SENTRY_CONFIG_JSON', '{}'));
Expand Down
1 change: 0 additions & 1 deletion docker/config.js.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ window._env_ = {
REACT_APP_SENTRY_CONFIG_JSON: "{{ getv "/react/app/opensrp/sentry/config/json" "" }}",
REACT_APP_ENABLE_FHIR_LOCATIONS: "{{ getv "/react/app/enable/fhir/locations" "false" }}",
REACT_APP_FHIR_ROOT_LOCATION_ID: "{{ getv "react/app/fhir/root/location/id" "" }}",
REACT_APP_FHIR_INVENTORY_LIST_ID: "{{ getv "react/app/fhir/inventory/list/id" "" }}",
REACT_APP_ENABLE_QUEST: "{{ getv "react/app/enable/quest" "false" }}",
REACT_APP_ENABLE_FHIR_HEALTHCARE_SERVICES: "{{ getv "/react/app/enable/fhir/healthcare/services" "false" }}",
REACT_APP_ENABLE_FHIR_GROUP: "{{ getv "/react/app/enable/fhir/group" "false" }}",
Expand Down
5 changes: 0 additions & 5 deletions docs/env.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,3 @@ Below is a list of currently supported environment variables:
- defines which authorization strategy to use. This affects how roles and permissions fetched from the Authorization server are parsed and used in the web app.Currently only keycloak is supported which means Role based acces will only work when using keycloak as the IAM server.
- **Required**(`keycloak`).
- default: `keycloak`

- **REACT_APP_FHIR_INVENTORY_LIST_ID**

- Id of List that will hold all created inventories for a given web instance
- **Optional**_(`string`)_
1 change: 0 additions & 1 deletion docs/fhir-web-docker-deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ We use different technologies to deploy fhir-web. This documentation will focus
// UUID's
REACT_APP_FHIR_ROOT_LOCATION_ID: '<id-of-the-root-location-on-the-HAPI-server>',
REACT_APP_COMMODITIES_LIST_RESOURCE_ID: '<id-of-a-list-on-HAPI-fhir-server>',
REACT_APP_FHIR_INVENTORY_LIST_ID: '<id-of-inventory-list-resource-on-HAPI--fhir-server>',
// toggle fhir-web modules
REACT_APP_ENABLE_FHIR_CARE_TEAM: 'false',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ const { Item: FormItem } = Form;
export interface LocationInventoryFormProps {
fhirBaseURL: string;
initialValues: GroupFormFields;
listResourceId: string;
servicePointObj: ILocation;
cancelUrl?: string;
successUrl?: string;
Expand Down Expand Up @@ -90,7 +89,6 @@ const AddLocationInventoryForm = (props: LocationInventoryFormProps) => {
fhirBaseURL,
initialValues,
inventoryId,
listResourceId,
inventoryResourceObj,
servicePointObj,
commodityListId,
Expand All @@ -107,8 +105,13 @@ const AddLocationInventoryForm = (props: LocationInventoryFormProps) => {

const { mutate, isLoading } = useMutation(
async (values: GroupFormFields) => {
const payload = getLocationInventoryPayload(values, editMode, inventoryResourceObj);
return postLocationInventory(fhirBaseURL, payload, editMode, listResourceId, servicePointObj);
const payload = getLocationInventoryPayload(
values,
editMode,
servicePointObj,
inventoryResourceObj
);
return postLocationInventory(fhirBaseURL, payload, editMode, servicePointObj);
},
{
onError: (error: Error) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { ILocation } from '@smile-cdr/fhirts/dist/FHIR-R4/interfaces/ILocation';

interface AddLocationInventoryProps {
fhirBaseURL: string;
listId?: string;
commodityListId?: string;
}

Expand All @@ -30,7 +29,7 @@ export interface RouteParams {
* @returns returns form to add location inventories
*/
export const AddLocationInventory = (props: AddLocationInventoryProps) => {
const { fhirBaseURL, listId, commodityListId } = props;
const { fhirBaseURL, commodityListId } = props;
const { t } = useTranslation();
const { inventoryId, servicePointId } = useParams<RouteParams>();
const pageTitle = inventoryId
Expand Down Expand Up @@ -73,7 +72,6 @@ export const AddLocationInventory = (props: AddLocationInventoryProps) => {

const formProps = {
fhirBaseURL,
listResourceId: listId as string,
inventoryId,
initialValues: initialValues as GroupFormFields,
inventoryResourceObj: inventoryResource.data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,21 @@ export const locationResourcePayload = {
active: true,
actual: false,
type: 'substance',
meta: {
tag: [
{
code: 'service-point-id',
display: 'Related Entity Location',
system: 'https://smartregister.org/related-entity-location-tag-id',
},
{
code: 'service-point-id',
display: 'Practitioner Location',
system: 'https://smartregister.org/location-tag-id',
},
],
},

identifier: [
{
use: 'secondary',
Expand Down Expand Up @@ -209,8 +224,20 @@ export const locationInventoryList = {
],
text: 'Supply Inventory List',
},
title: 'Service Point',
subject: { reference: 'Location/46bb8a3f-cf50-4cc2-b421-fe4f77c3e75d' },
meta: {
tag: [
{
system: 'https://smartregister.org/related-entity-location-tag-id',
display: 'Related Entity Location',
code: '46bb8a3f-cf50-4cc2-b421-fe4f77c3e75d',
},
{
system: 'https://smartregister.org/location-tag-id',
display: 'Practitioner Location',
code: '46bb8a3f-cf50-4cc2-b421-fe4f77c3e75d',
},
],
},
entry: [
{
flag: {
Expand All @@ -227,6 +254,8 @@ export const locationInventoryList = {
item: { reference: 'Group/67bb848e-f049-41f4-9c75-3b726664db67' },
},
],
title: 'Service Point',
subject: { reference: 'Location/46bb8a3f-cf50-4cc2-b421-fe4f77c3e75d' },
};

export const locationInventoryList1384 = {
Expand Down Expand Up @@ -297,6 +326,20 @@ export const updatedLocationInventoryList1 = {
],
text: 'Supply Inventory List',
},
meta: {
tag: [
{
system: 'https://smartregister.org/related-entity-location-tag-id',
display: 'Related Entity Location',
code: '46bb8a3f-cf50-4cc2-b421-fe4f77c3e75d',
},
{
system: 'https://smartregister.org/location-tag-id',
display: 'Practitioner Location',
code: '46bb8a3f-cf50-4cc2-b421-fe4f77c3e75d',
},
],
},
entry: [
{
flag: {
Expand Down Expand Up @@ -1241,6 +1284,20 @@ export const unicefDonorsValueSet = {
};

export const createdInventoryGroup1 = {
meta: {
tag: [
{
system: 'https://smartregister.org/related-entity-location-tag-id',
display: 'Related Entity Location',
code: '46bb8a3f-cf50-4cc2-b421-fe4f77c3e75d',
},
{
system: 'https://smartregister.org/location-tag-id',
display: 'Practitioner Location',
code: '46bb8a3f-cf50-4cc2-b421-fe4f77c3e75d',
},
],
},
resourceType: 'Group',
id: '67bb848e-f049-41f4-9c75-3b726664db67',
active: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
formValues,
locationResourcePayload,
locationInventoryList,
allInventoryList,
productsList,
unicefDonorsValueSet,
unicefSectionValueSet,
Expand Down Expand Up @@ -67,13 +66,11 @@ const queryClient = new QueryClient({
},
});

const listResourceId = 'list-resource-id';
const props = {
fhirBaseURL: 'http://test.server.org',
// eslint-disable-next-line @typescript-eslint/no-explicit-any
initialValues: {} as any,
inventoryId: undefined,
listResourceId,
inventoryResourceObj: undefined,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
servicePointObj: servicePointDatum as any,
Expand Down Expand Up @@ -182,12 +179,6 @@ test('creates new inventory as expected', async () => {
code: `${smartregisterSystemUri}|${servicePointProfileInventoryListCoding.code}`,
})
.reply(404, { message: 'Not found' })
.get(`/${listResourceType}/${listResourceId}`)
.reply(404, { message: 'Not found' })
.put(`/${listResourceType}/${listResourceId}`, { ...allInventoryList, entry: [] })
.reply(201, { ...allInventoryList, entry: [] })
.put(`/${listResourceType}/${listResourceId}`, allInventoryList)
.reply(201, allInventoryList)
.persist();

const successNoticeMock = jest
Expand Down Expand Up @@ -260,6 +251,7 @@ test('creates new inventory as expected', async () => {

await waitFor(() => {
expect(postCreationalScope.isDone()).toBeTruthy();
expect(preFetchScope.isDone()).toBeTruthy();
expect(errorNoticeMock).not.toHaveBeenCalled();
expect(successNoticeMock.mock.calls).toEqual([['Location inventory created successfully']]);
});
Expand Down Expand Up @@ -297,13 +289,6 @@ test('#1384 - correctly updates location inventory', async () => {
.reply(200, unicefDonorsValueSet)
.persist();

const updatedAllInventoryList = {
...allInventoryList,
entry: [
...allInventoryList.entry,
{ item: { reference: 'List/9f4edfe3-ac84-449f-8640-f0d297e75ff5' } },
],
};
const postCreationalScope = nock(props.fhirBaseURL)
.put(`/${groupResourceType}/${mockResourceId}`, createdInventoryGroup1)
.reply(201, createdInventoryGroup1)
Expand All @@ -313,12 +298,8 @@ test('#1384 - correctly updates location inventory', async () => {
code: `${smartregisterSystemUri}|${servicePointProfileInventoryListCoding.code}`,
})
.reply(200, locationInventoryList1384Bundle)
.get(`/${listResourceType}/${listResourceId}`)
.reply(200, allInventoryList)
.put(`/${listResourceType}/${updatedLocationInventoryList1.id}`, updatedLocationInventoryList1)
.reply(201, updatedLocationInventoryList1)
.put(`/${listResourceType}/${listResourceId}`, updatedAllInventoryList)
.reply(201, updatedAllInventoryList)
.persist();

const successNoticeMock = jest
Expand Down Expand Up @@ -393,6 +374,7 @@ test('#1384 - correctly updates location inventory', async () => {

await waitFor(() => {
expect(postCreationalScope.isDone()).toBeTruthy();
expect(preFetchScope.isDone()).toBeTruthy();
expect(errorNoticeMock).not.toHaveBeenCalled();
expect(successNoticeMock.mock.calls).toEqual([['Location inventory created successfully']]);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ describe('fhir-group-management/src/components/LocationInventory/utils', () => {
});

it('generate location inventory payload works as expected', () => {
expect(getLocationInventoryPayload(formValues, false)).toEqual(locationResourcePayload);
expect(getLocationInventoryPayload(formValues, false, { id: 'service-point-id' })).toEqual(
locationResourcePayload
);
});
});
Loading

0 comments on commit 9cf90ec

Please sign in to comment.