Skip to content

Commit

Permalink
Merge branch 'main' into ft-O3-4009
Browse files Browse the repository at this point in the history
  • Loading branch information
usamaidrsk authored Nov 6, 2024
2 parents 6c33fe7 + 9cb0db5 commit c15e806
Show file tree
Hide file tree
Showing 17 changed files with 329 additions and 244 deletions.
26 changes: 13 additions & 13 deletions packages/esm-form-engine-app/translations/pt.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"cancel": "Cancel",
"closeThisPanel": "Close this panel",
"collapseAll": "Collapse all",
"deleteQuestion": "Delete question",
"deleteQuestionConfirmation": "Are you sure you want to delete this question?",
"deleteQuestionExplainerText": "This action cannot be undone.",
"errorTitle": "There was an error with this form",
"expandAll": "Expand all",
"loading": "Loading",
"or": "or",
"thisList": "this list",
"toggleCollapseOrExpand": "Toggle collapse or expand",
"tryAgainMessage": "Try opening another form from"
"cancel": "Cancelar",
"closeThisPanel": "Fechar este painel",
"collapseAll": "Colapsar tudo",
"deleteQuestion": "Apagar a questão",
"deleteQuestionConfirmation": "Tem certeza de que deseja esta questão?",
"deleteQuestionExplainerText": "Esta ação não pode ser desfeita.",
"errorTitle": "Houve um erro com este formulário",
"expandAll": "Expandir tudo",
"loading": "Carregando",
"or": "ou",
"thisList": "esta lista",
"toggleCollapseOrExpand": "Alternar colapsar ou expandir",
"tryAgainMessage": "Tente abrir outro formulário em"
}
2 changes: 1 addition & 1 deletion packages/esm-form-entry-app/translations/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"saveAndCloseButton": "Salvar e fechar",
"selectWeeks": "Selecionar semanas",
"set": "Definir",
"submitting": "Enviando",
"submitting": "Submetendo",
"to": "Para",
"tryOpeningAnotherForm": "Tente abrir outro formulário",
"useValue": "Usar valor",
Expand Down
5 changes: 4 additions & 1 deletion packages/esm-patient-common-lib/src/orders/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ export interface OrderBasketItem {
accessionNumber?: string;
}

export type OrderUrgency = 'ROUTINE' | 'STAT' | 'ON_SCHEDULED_DATE';

export interface OrderPost {
urgency?: OrderUrgency;
action?: OrderAction;
patient?: string;
careSetting?: string;
Expand Down Expand Up @@ -207,7 +210,7 @@ export interface LabOrderBasketItem extends OrderBasketItem {
label: string;
conceptUuid: string;
};
urgency?: string;
urgency?: OrderUrgency;
instructions?: string;
previousOrder?: string;
orderReason?: string;
Expand Down
14 changes: 7 additions & 7 deletions packages/esm-patient-flags-app/translations/pt.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"activeFirst": "Active first",
"activeFirst": "Activo em primeiro",
"alphabetically": "A - Z",
"clearSearch": "Clear search",
"closeFlagsBar": "Close flags bar",
"disableFlagError": "Disable flag error",
"disablingFlag": "Disabling flag...",
"discard": "Discard",
"edit": "Edit",
"clearSearch": "Limpar pesquisa",
"closeFlagsBar": "Fechar barra de sinalizadores",
"disableFlagError": "Desactivar erro de sinalização",
"disablingFlag": "Desactivando sinalizador...",
"discard": "Descartar",
"edit": "Editar",
"editFlags": "Edit flags",
"editPatientFlags": "Edit patient flags",
"enabledFlag": "Enabled flag",
Expand Down
58 changes: 29 additions & 29 deletions packages/esm-patient-immunizations-app/translations/pt.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
{
"add": "Add",
"cancel": "Cancel",
"doseNumber": "Dose number within series",
"doseNumberWithinSeries": "Dose number within series",
"edit": "Edit",
"error": "Error",
"errorSaving": "Error saving vaccination",
"expirationDate": "Expiration Date",
"goToSummary": "Go to Summary",
"immunization": "Immunization",
"immunizations": "Immunizations",
"Immunizations": "Immunizations",
"immunizations__lower": "immunizations",
"immunizationWorkspaceTitle": "Immunization Form",
"lotNumber": "Lot Number",
"manufacturer": "Manufacturer",
"pleaseSelect": "Please select",
"recentVaccination": "Recent vaccination",
"save": "Save",
"seeAll": "See all",
"sequence": "Sequence",
"singleDoseOn": "Single Dose on",
"time": "Time",
"timeFormat ": "Time Format",
"vaccinationDate": "Vaccination date",
"vaccinationDateRequired": "Vaccination date required",
"vaccinationSaved": "Vaccination saved successfully",
"vaccine": "Vaccine",
"vaccineRequired": "Vaccine required"
"add": "Adicionar",
"cancel": "Cancelar",
"doseNumber": "Número da dose dentro da série",
"doseNumberWithinSeries": "Número da dose dentro da série",
"edit": "Editar",
"error": "Erro",
"errorSaving": "Erro ao salvar a vacinação",
"expirationDate": "Data de validade",
"goToSummary": "Ir para o resumo",
"immunization": "Imunização",
"immunizations": "Imunizações",
"Immunizations": "Imunizações",
"immunizations__lower": "imunizações",
"immunizationWorkspaceTitle": "Formulário de Imunização",
"lotNumber": "Número de Lote",
"manufacturer": "Fabricante",
"pleaseSelect": "Por favor selecione",
"recentVaccination": "Vacinação recente",
"save": "Salvar",
"seeAll": "Ver tudo",
"sequence": "Sequencia",
"singleDoseOn": "Dose única activada",
"time": "Tempo",
"timeFormat ": "Formato de hora",
"vaccinationDate": "Data de vacinação",
"vaccinationDateRequired": "Data de vacinação é obrigatória",
"vaccinationSaved": "Vacinação gravada com sucesso",
"vaccine": "Vacina",
"vaccineRequired": "Vacina é obrigatória"
}
72 changes: 36 additions & 36 deletions packages/esm-patient-programs-app/translations/pt.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
{
"actions": "Actions",
"active": "Active",
"activePrograms": "Active programs",
"add": "Add",
"addPrograms": "Add programs",
"cancel": "Cancel",
"carePrograms": "Care Programs",
"chooseProgram": "Choose a program",
"chooseStatus": "Choose a program status",
"completedOn": "Completed On",
"configurePrograms": "Please configure programs to continue.",
"dateCompleted": "Date completed",
"dateEnrolled": "Date enrolled",
"editProgram": "Edit Program",
"enrollmentLocation": "Enrollment location",
"enrollmentNowVisible": "It is now visible in the Programs table",
"enrollmentSaved": "Program enrollment saved",
"enrollmentUpdated": "Program enrollment updated",
"enrollmentUpdatesNowVisible": "Changes to the program are now visible in the Programs table",
"fullyEnrolled": "Enrolled in all programs",
"location": "Location",
"noEligibleEnrollments": "There are no more programs left to enroll this patient in",
"noProgramsConfigured": "No programs configured",
"programEnrollments": "Program enrollments",
"programEnrollmentSaveError": "Error saving program enrollment",
"programEnrollmentWorkspaceTitle": "Record program enrollment",
"programName": "Program name",
"programRequired": "Program is required",
"programs": "Program enrollments",
"Programs": "Programs",
"programStatus": "Program status",
"saveAndClose": "Save and close",
"saving": "Saving",
"seeAll": "See all",
"state": "State",
"status": "Status"
"actions": "Ações",
"active": "Ativo",
"activePrograms": "Programas actiivos",
"add": "Adicionar",
"addPrograms": "Adicionar programas",
"cancel": "Cancelar",
"carePrograms": "Programas de cuidados",
"chooseProgram": "Selecione um programa",
"chooseStatus": "Selecione um estado do programa",
"completedOn": "Concluído em",
"configurePrograms": "Favor de configurar programas para continuar.",
"dateCompleted": "Data de conclusão",
"dateEnrolled": "Data de inscrição",
"editProgram": "Editar Programa",
"enrollmentLocation": "Local de inscrição",
"enrollmentNowVisible": "Está agora visível na tabela de Programas",
"enrollmentSaved": "Inscrição no programa gravado",
"enrollmentUpdated": "Inscrição no programa actualizado",
"enrollmentUpdatesNowVisible": "As alterações do programa estão agora visíveis na tabela Programas",
"fullyEnrolled": "Inscrever em todos programas",
"location": "Local",
"noEligibleEnrollments": "Não há mais programas para inscrever este utente",
"noProgramsConfigured": "Nenhum programa configurado",
"programEnrollments": "Inscrições no programa",
"programEnrollmentSaveError": "Erro ao gravar inscrição no programa",
"programEnrollmentWorkspaceTitle": "Registar inscrição no programa",
"programName": "Nome do programa",
"programRequired": "Programa é obrigatório",
"programs": "Inscrições no programa",
"Programs": "Programas",
"programStatus": "Estados do programa",
"saveAndClose": "Salvar e fechar",
"saving": "Gravando",
"seeAll": "Ver tudo",
"state": "Estado",
"status": "Estado"
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { type LabOrderBasketItem } from '@openmrs/esm-patient-common-lib';
import { type LabOrderBasketItem, type OrderUrgency } from '@openmrs/esm-patient-common-lib';
import { type TestType } from './useTestTypes';

type LabOrderRequest = Pick<LabOrderBasketItem, 'action' | 'testType'>;

type PriorityOption = {
label: string;
value: OrderUrgency;
};

// See the Urgency enum in https://github.com/openmrs/openmrs-core/blob/492dcd35b85d48730bd19da48f6db146cc882c22/api/src/main/java/org/openmrs/Order.java
export const priorityOptions = [
export const priorityOptions: PriorityOption[] = [
{ value: 'ROUTINE', label: 'Routine' },
{ value: 'STAT', label: 'Stat' },
];
Expand All @@ -13,7 +18,7 @@ export const priorityOptions = [
export function createEmptyLabOrder(testType: TestType, orderer: string): LabOrderBasketItem {
return {
action: 'NEW',
urgency: priorityOptions[0].value,
urgency: priorityOptions[0].value as OrderUrgency,
display: testType.label,
testType,
orderer,
Expand Down
3 changes: 3 additions & 0 deletions packages/esm-patient-tests-app/src/lab-orders/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export function prepLabOrderPostData(
instructions: order.instructions,
orderReason: order.orderReason,
accessionNumber: order.accessionNumber,
urgency: order.urgency,
};
} else if (order.action === 'REVISE') {
return {
Expand All @@ -107,6 +108,7 @@ export function prepLabOrderPostData(
orderReason: order.orderReason,
previousOrder: order.previousOrder,
accessionNumber: order.accessionNumber,
urgency: order.urgency,
};
} else if (order.action === 'DISCONTINUE') {
return {
Expand All @@ -120,6 +122,7 @@ export function prepLabOrderPostData(
orderReason: order.orderReason,
previousOrder: order.previousOrder,
accessionNumber: order.accessionNumber,
urgency: order.urgency,
};
} else {
throw new Error(`Unknown order action: ${order.action}.`);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import userEvent from '@testing-library/user-event';
import { screen, render } from '@testing-library/react';
import { type LabOrderBasketItem, type OrderBasketItem } from '@openmrs/esm-patient-common-lib';
import { type LabOrderBasketItem } from '@openmrs/esm-patient-common-lib';
import LabOrderBasketPanel from './lab-order-basket-panel.extension';

const mockUseOrderBasket = jest.fn();
Expand Down Expand Up @@ -44,7 +44,7 @@ describe('LabOrderBasketPanel', () => {
},
];
let orders = [...labs];
const mockSetOrders = jest.fn((newOrders: Array<OrderBasketItem>) => {
const mockSetOrders = jest.fn((newOrders: Array<LabOrderBasketItem>) => {
orders = newOrders;
});
mockUseOrderBasket.mockImplementation(() => ({
Expand All @@ -55,10 +55,12 @@ describe('LabOrderBasketPanel', () => {
expect(screen.getByText(/Lab orders \(2\)/i)).toBeInTheDocument();
expect(screen.getByText(/HIV VIRAL LOAD/i)).toBeInTheDocument();
expect(screen.getByText(/CD4 COUNT/i)).toBeInTheDocument();

const removeHivButton = screen.getAllByRole('button', { name: /remove from basket/i })[0];
expect(removeHivButton).toBeVisible();

await user.click(removeHivButton);
rerender(<LabOrderBasketPanel />); // re-render because the mocked hook does not trigger a render
rerender(<LabOrderBasketPanel />);
await expect(screen.getByText(/Lab orders \(1\)/i)).toBeInTheDocument();
expect(screen.getByText(/CD4 COUNT/i)).toBeInTheDocument();
expect(screen.queryByText(/HIV VIRAL LOAD/i)).not.toBeInTheDocument();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
type TimelineData,
} from './filter-types';
import reducer from './filter-reducer';
import { type MappedObservation, type TestResult, type GroupedObservation, type Observation } from '../../types';

const initialState: ReducerState = {
checkboxes: {},
Expand All @@ -22,6 +23,7 @@ const initialContext = {
state: initialState,
...initialState,
timelineData: null,
tableData: null,
trendlineData: null,
activeTests: [],
someChecked: false,
Expand Down Expand Up @@ -93,6 +95,50 @@ const FilterProvider = ({ roots, children }: FilterProviderProps) => {
};
}, [activeTests, state.tests]);

const tableData = useMemo<GroupedObservation[]>(() => {
const flattenedObs: Observation[] = [];

for (const key in state.tests) {
const test = state.tests[key] as TestResult;
if (test.obs && Array.isArray(test.obs)) {
test.obs.forEach((obs) => {
const flattenedEntry = {
...obs,
key: key,
...test,
};
flattenedObs.push(flattenedEntry);
});
}
}

const groupedObs: Record<string, GroupedObservation> = {};

flattenedObs.forEach((curr: MappedObservation) => {
const flatNameParts = curr.flatName.split('-');
const groupKey = flatNameParts.length > 1 ? flatNameParts[1].trim() : flatNameParts[0].trim();
const dateKey = new Date(curr.obsDatetime).toISOString().split('T')[0];

const compositeKey = `${groupKey}__${dateKey}`;
if (!groupedObs[compositeKey]) {
groupedObs[compositeKey] = {
key: groupKey,
date: dateKey,
flatName: curr.flatName,
entries: [],
};
}

groupedObs[compositeKey].entries.push(curr);
});

const resultArray = Object.values(groupedObs).sort(
(a, b) => new Date(b.date).getTime() - new Date(a.date).getTime(),
);

return resultArray;
}, [state.tests]);

useEffect(() => {
if (roots?.length && !Object.keys(state?.parents).length) {
actions.initialize(roots);
Expand All @@ -113,6 +159,7 @@ const FilterProvider = ({ roots, children }: FilterProviderProps) => {
value={{
...state,
timelineData,
tableData,
activeTests,
someChecked,
totalResultsCount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export interface TimelineData {

export interface FilterContextProps extends ReducerState {
timelineData: TimelineData;
tableData?: any;
activeTests: string[];
someChecked: boolean;
totalResultsCount: number;
Expand Down
Loading

0 comments on commit c15e806

Please sign in to comment.