Skip to content

Commit

Permalink
Merge branch 'main' into O3-3521
Browse files Browse the repository at this point in the history
  • Loading branch information
denniskigen authored Sep 3, 2024
2 parents a1adf2b + 5e7a458 commit b0fed05
Show file tree
Hide file tree
Showing 36 changed files with 753 additions and 352 deletions.
30 changes: 16 additions & 14 deletions e2e/specs/results-viewer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,21 +264,23 @@ test('Record and edit test results', async ({ page }) => {
await resultsViewerPage.goTo(patient.uuid);
});

await test.step('And I click on the `Panel` tab', async () => {
await page.getByRole('tab', { name: /panel/i }).click();
await test.step('And I click on the `Individual tests` tab', async () => {
await page.getByRole('tab', { name: /individual tests/i }).click();
});

await test.step('Then I should see the newly entered test results reflect in the results viewer', async () => {
for (const { resultsPageReference, value } of completeBloodCountData) {
await test.step(resultsPageReference, async () => {
const row = page.locator(`tr:has-text("${resultsPageReference}")`);
const valueCell = row.locator('td:nth-child(2)');
await expect(valueCell).toContainText(value);
});
}
await test.step('Then I should see the newly entered test results reflect in the results viewer', async () => {
for (const { resultsPageReference, value } of completeBloodCountData) {
await test.step(resultsPageReference, async () => {
const row = page.locator(`tr:has-text("${resultsPageReference}"):has(td:has-text("${value}"))`).first();
const valueCell = row.locator('td:nth-child(2)');
await expect(valueCell).toContainText(value);
});
}
});
for (const { resultsPageReference, value } of chemistryResultsData) {
await test.step(resultsPageReference, async () => {
const row = page.locator(`tr:has-text("${resultsPageReference}")`);
const row = page.locator(`tr:has-text("${resultsPageReference}"):has(td:has-text("${value}"))`).first();
const valueCell = row.locator('td:nth-child(2)');
await expect(valueCell).toContainText(value);
});
Expand Down Expand Up @@ -338,21 +340,21 @@ test('Record and edit test results', async ({ page }) => {
await resultsViewerPage.goTo(patient.uuid);
});

await test.step('And I click on the `Panel` tab', async () => {
await page.getByRole('tab', { name: /panel/i }).click();
await test.step('And I click on the `Individual tests` tab', async () => {
await page.getByRole('tab', { name: /individual tests/i }).click();
});

await test.step('Then I should see the updated results reflect in the results viewer', async () => {
for (const { resultsPageReference, updatedValue } of completeBloodCountData) {
await test.step(resultsPageReference, async () => {
const row = page.locator(`tr:has-text("${resultsPageReference}")`);
const row = page.locator(`tr:has-text("${resultsPageReference}"):has(td:has-text("${updatedValue}"))`).first();
const valueCell = row.locator('td:nth-child(2)');
await expect(valueCell).toContainText(updatedValue);
});
}
for (const { resultsPageReference, updatedValue } of chemistryResultsData) {
await test.step(resultsPageReference, async () => {
const row = page.locator(`tr:has-text("${resultsPageReference}")`);
const row = page.locator(`tr:has-text("${resultsPageReference}"):has(td:has-text("${updatedValue}"))`).first();
const valueCell = row.locator('td:nth-child(2)');
await expect(valueCell).toContainText(updatedValue);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import { useMutateAppointments } from '../hooks/useMutateAppointments';
import { useOfflineVisitType } from '../hooks/useOfflineVisitType';
import { useVisitAttributeTypes } from '../hooks/useVisitAttributeType';
import { useVisitQueueEntry } from '../queue-entry/queue.resource';
import { useVisits } from '../visits-widget/visit.resource';
import { useInfiniteVisits, useVisits } from '../visits-widget/visit.resource';
import BaseVisitType from './base-visit-type.component';
import LocationSelector from './location-selector.component';
import VisitAttributeTypeFields from './visit-attribute-type.component';
Expand Down Expand Up @@ -97,6 +97,7 @@ const StartVisitForm: React.FC<StartVisitFormProps> = ({
const { activePatientEnrollment, isLoading } = useActivePatientEnrollment(patientUuid);
const { mutate: mutateCurrentVisit } = useVisit(patientUuid);
const { mutateVisits } = useVisits(patientUuid);
const { mutateVisits: mutateInfiniteVisits } = useInfiniteVisits(patientUuid);
const { mutateAppointments } = useMutateAppointments();
const allVisitTypes = useConditionalVisitTypes();

Expand Down Expand Up @@ -482,6 +483,7 @@ const StartVisitForm: React.FC<StartVisitFormProps> = ({
if (status === 201) {
mutateCurrentVisit();
mutateVisits();
mutateInfiniteVisits();
mutateQueueEntry();
showSnackbar({
kind: 'success',
Expand All @@ -506,6 +508,7 @@ const StartVisitForm: React.FC<StartVisitFormProps> = ({
() => {
mutateCurrentVisit();
mutateVisits();
mutateInfiniteVisits();
mutateAppointments();
showSnackbar({
isLowContrast: true,
Expand Down Expand Up @@ -537,6 +540,7 @@ const StartVisitForm: React.FC<StartVisitFormProps> = ({
if (!attributesResponses.includes(undefined)) {
mutateCurrentVisit();
mutateVisits();
mutateInfiniteVisits();
closeWorkspace({ ignoreChanges: true });
showSnackbar({
isLowContrast: true,
Expand Down Expand Up @@ -623,6 +627,7 @@ const StartVisitForm: React.FC<StartVisitFormProps> = ({
mutateCurrentVisit,
mutateQueueEntry,
mutateVisits,
mutateInfiniteVisits,
patientUuid,
priority,
queueLocation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ import {
useSession,
userHasAccess,
} from '@openmrs/esm-framework';
import { EmptyState, PatientChartPagination, launchFormEntryOrHtmlForms } from '@openmrs/esm-patient-common-lib';
import type { HtmlFormEntryForm } from '@openmrs/esm-patient-forms-app/src/config-schema';
import {
type HtmlFormEntryForm,
EmptyState,
PatientChartPagination,
launchFormEntryOrHtmlForms,
} from '@openmrs/esm-patient-common-lib';
import { deleteEncounter } from './visits-table.resource';
import { type MappedEncounter } from '../../visit.resource';
import EncounterObservations from '../../encounter-observations';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function useInfiniteVisits(patientUuid: string) {
);

return {
visits: data ? [].concat(data?.flatMap((page) => page.data.results)) : null,
visits: data ? [].concat(data?.flatMap((page) => page?.data?.results)) : null,
error,
hasMore: data?.length ? !!data[data.length - 1].data?.links?.some((link) => link.rel === 'next') : false,
isLoading,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type HtmlFormEntryForm } from '@openmrs/esm-patient-forms-app/src/config-schema';
import { type HtmlFormEntryForm } from '../types';

export interface FormEntryProps {
encounterUuid?: string;
Expand Down
8 changes: 5 additions & 3 deletions packages/esm-patient-common-lib/src/orders/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export interface OrderBasketItem {
};
extractedOrderError?: ExtractedOrderErrorObject;
isOrderIncomplete?: boolean;
/**
* An optional identifier from the fulfiller (e.g., lab system) for the specimen or record associated with the order.
*/
accessionNumber?: string;
}

export interface OrderPost {
Expand Down Expand Up @@ -68,7 +72,7 @@ export interface OrderPost {
orderReasonNonCoded?: string;
orderReason?: string;
instructions?: string;
labReferenceNumber?: string;
accessionNumber?: string;
}

export interface PatientOrderFetchResponse {
Expand Down Expand Up @@ -146,7 +150,6 @@ export interface Order {
clinicalHistory: string;
numberOfRepeats: string;
type: string;
labReferenceNumber?: string;
}

export interface OrderTypeFetchResponse {
Expand Down Expand Up @@ -204,7 +207,6 @@ export interface LabOrderBasketItem extends OrderBasketItem {
label: string;
conceptUuid: string;
};
labReferenceNumber?: string;
urgency?: string;
instructions?: string;
previousOrder?: string;
Expand Down
10 changes: 8 additions & 2 deletions packages/esm-patient-common-lib/src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { type OpenmrsResource } from '@openmrs/esm-framework';

export * from './test-results';

export interface DashboardLinkConfig {
Expand Down Expand Up @@ -49,3 +47,11 @@ export interface DisplayMetadata {
links: Links;
uuid: string;
}

export interface HtmlFormEntryForm {
formUuid: string;
formName: string;
formUiResource: string;
formUiPage: 'enterHtmlFormWithSimpleUi' | 'enterHtmlFormWithStandardUi';
formEditUiPage: 'editHtmlFormWithSimpleUi' | 'editHtmlFormWithStandardUi';
}
9 changes: 1 addition & 8 deletions packages/esm-patient-forms-app/src/config-schema.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { validator, Type } from '@openmrs/esm-framework';
import { type HtmlFormEntryForm } from '@openmrs/esm-patient-common-lib';

export const configSchema = {
htmlFormEntryForms: {
Expand Down Expand Up @@ -133,14 +134,6 @@ export const configSchema = {
},
};

export interface HtmlFormEntryForm {
formUuid: string;
formName: string;
formUiResource: string;
formUiPage: 'enterHtmlFormWithSimpleUi' | 'enterHtmlFormWithStandardUi';
formEditUiPage: 'editHtmlFormWithSimpleUi' | 'editHtmlFormWithStandardUi';
}

export interface FormsSection {
name: string;
forms: Array<string>;
Expand Down
9 changes: 6 additions & 3 deletions packages/esm-patient-forms-app/src/form-entry-interop.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { navigate, type Visit } from '@openmrs/esm-framework';
import { type HtmlFormEntryForm } from './config-schema';
import isEmpty from 'lodash-es/isEmpty';
import { launchPatientWorkspace, launchStartVisitPrompt } from '@openmrs/esm-patient-common-lib';
import {
type HtmlFormEntryForm,
launchPatientWorkspace,
launchStartVisitPrompt,
} from '@openmrs/esm-patient-common-lib';
import { isEmpty } from 'lodash-es';

export function launchFormEntryOrHtmlForms(
currentVisit: Visit | undefined,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import useSWR from 'swr';
import { getDynamicOfflineDataEntries } from '@openmrs/esm-framework';
import { type HtmlFormEntryForm } from '@openmrs/esm-patient-common-lib';
import { type Form, type FormEncounterResource } from '../types';
import { type HtmlFormEntryForm } from '../config-schema';

/**
* Returns whether the given form encounter is valid for offline mode and can be cached.
Expand Down
7 changes: 0 additions & 7 deletions packages/esm-patient-labs-app/src/config-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ export const configSchema = {
},
],
},
showPrintButton: {
_type: Type.Boolean,
_default: true,
_description:
'Whether or not to display the print button in the Test Results dashboard. When set to `true`, a print button is shown alongside the panel and tree view content switcher. When clicked, a modal pops up showing a datatable with the available test results. Once the user selects an appropriate date range, they can click on the print button in the modal to print the data',
},
orders: {
labOrderTypeUuid: {
_type: Type.UUID,
Expand Down Expand Up @@ -97,7 +91,6 @@ export interface OrderReason {
}
export interface ConfigObject {
resultsViewerConcepts: Array<ObsTreeEntry>;
showPrintButton: boolean;
orders: {
labOrderTypeUuid: string;
labOrderableConcepts: Array<string>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@

button {
display: flex;
padding-left: 0 !important;
margin: 0 layout.$spacing-05;
margin-left: -(layout.$spacing-03);

svg {
order: 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ describe('AddLabOrder', () => {
display: 'CD4 COUNT',
urgency: 'STAT',
instructions: 'plz do it thx',
labReferenceNumber: 'lba-000124',
accessionNumber: 'lba-000124',
testType: { label: 'CD4 COUNT', conceptUuid: 'test-lab-uuid-2' },
orderer: mockSessionDataResponse.data.currentProvider.uuid,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export function LabOrderForm({
urgency: z.string().refine((value) => value !== '', {
message: translateFrom(moduleName, 'addLabOrderPriorityRequired', 'Priority is required'),
}),
labReferenceNumber: z.string().optional(),
accessionNumber: z.string().optional(),
testType: z.object(
{ label: z.string(), conceptUuid: z.string() },
{
Expand Down Expand Up @@ -182,7 +182,7 @@ export function LabOrderForm({
<Column lg={16} md={8} sm={4}>
<InputWrapper>
<Controller
name="labReferenceNumber"
name="accessionNumber"
control={control}
render={({ field: { onChange, onBlur, value } }) => (
<TextInput
Expand All @@ -193,8 +193,8 @@ export function LabOrderForm({
value={value}
onChange={onChange}
onBlur={onBlur}
invalid={errors.labReferenceNumber?.message}
invalidText={errors.labReferenceNumber?.message}
invalid={errors.accessionNumber?.message}
invalidText={errors.accessionNumber?.message}
/>
)}
/>
Expand Down
3 changes: 3 additions & 0 deletions packages/esm-patient-labs-app/src/lab-orders/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export function prepLabOrderPostData(
concept: order.testType.conceptUuid,
instructions: order.instructions,
orderReason: order.orderReason,
accessionNumber: order.accessionNumber,
};
} else if (order.action === 'REVISE') {
return {
Expand All @@ -105,6 +106,7 @@ export function prepLabOrderPostData(
instructions: order.instructions,
orderReason: order.orderReason,
previousOrder: order.previousOrder,
accessionNumber: order.accessionNumber,
};
} else if (order.action === 'DISCONTINUE') {
return {
Expand All @@ -117,6 +119,7 @@ export function prepLabOrderPostData(
concept: order.testType.conceptUuid,
orderReason: order.orderReason,
previousOrder: order.previousOrder,
accessionNumber: order.accessionNumber,
};
} else {
throw new Error(`Unknown order action: ${order.action}.`);
Expand Down
Loading

0 comments on commit b0fed05

Please sign in to comment.