Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/dashboard/DashboardController.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class DashboardController extends React.Component {

_createRecord = () => {
{
/*TODO bug on cancel it doesnt return to dashboard but to patient records */
/*TODO bug on cancel it doesnt return to dashboard but to records */
}
this.props.transitionToWithOpts(Routes.createRecord, {
handlers: {
Expand Down
10 changes: 5 additions & 5 deletions src/components/institution/Institution.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "react";
import { Button, Card } from "react-bootstrap";
import { FormattedMessage, injectIntl } from "react-intl";
import InstitutionMembers from "./InstitutionMembers";
import InstitutionPatients from "./InstitutionPatients";
import InstitutionRecords from "./InstitutionRecords.jsx";
import withI18n from "../../i18n/withI18n";
import HorizontalInput from "../HorizontalInput";
import PropTypes from "prop-types";
Expand All @@ -13,7 +13,7 @@ import { LoaderSmall } from "../Loader";
import InstitutionValidator from "../../validation/InstitutionValidator";
import HelpIcon from "../HelpIcon";
import PromiseTrackingMask from "../misc/PromiseTrackingMask";
import { canReadInstitutionPatients, canReadInstitutionUsers, canWriteInstitution } from "../../utils/RoleUtils.js";
import { canReadInstitutionRecords, canReadInstitutionUsers, canWriteInstitution } from "../../utils/RoleUtils.js";

/**
* Institution detail. Editable only for admins.
Expand Down Expand Up @@ -87,11 +87,11 @@ class Institution extends React.Component {
{this._renderButtons()}
</form>
{!institution.isNew && canReadInstitutionUsers(currentUser, institution.key) && this._renderMembers()}
{!institution.isNew && canReadInstitutionPatients(currentUser, institution.key) && (
<InstitutionPatients
{!institution.isNew && canReadInstitutionRecords(currentUser, institution.key) && (
<InstitutionRecords
recordsLoaded={recordsLoaded}
formTemplatesLoaded={formTemplatesLoaded}
onEdit={this.props.handlers.onEditPatient}
onEdit={this.props.handlers.onEditRecord}
onExport={this.props.handlers.onExportRecords}
currentUser={currentUser}
filterAndSort={this.props.filterAndSort}
Expand Down
10 changes: 5 additions & 5 deletions src/components/institution/InstitutionController.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { trackPromise } from "react-promise-tracker";
import { INITIAL_PAGE } from "../misc/Pagination";
import BrowserStorage from "../../utils/BrowserStorage";
import PropTypes from "prop-types";
import { canReadInstitutionPatients } from "../../utils/RoleUtils.js";
import { canReadInstitutionRecords } from "../../utils/RoleUtils.js";

class InstitutionController extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -63,7 +63,7 @@ class InstitutionController extends React.Component {

if (
this.props.status === ACTION_STATUS.SUCCESS &&
canReadInstitutionPatients(this.props.currentUser, institutionKey)
canReadInstitutionRecords(this.props.currentUser, institutionKey)
) {
this._loadRecords();
}
Expand Down Expand Up @@ -162,8 +162,8 @@ class InstitutionController extends React.Component {
});
};

_onEditPatient = (patient) => {
this.props.transitionToWithOpts(Routes.editRecord, { params: { key: patient.key } });
_onEditRecord = (record) => {
this.props.transitionToWithOpts(Routes.editRecord, { params: { key: record.key } });
};

_onExportRecords = (exportType) => {
Expand Down Expand Up @@ -206,7 +206,7 @@ class InstitutionController extends React.Component {
onChange: this._onChange,
onEditUser: this._onEditUser,
onAddNewUser: this._onAddNewUser,
onEditPatient: this._onEditPatient,
onEditRecord: this._onEditRecord,
onExportRecords: this._onExportRecords,
onDelete: this._onDeleteUser,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import ExportRecordsDropdown from "../record/ExportRecordsDropdown";
import { useI18n } from "../../hooks/useI18n";
import { COLUMNS } from "../../constants/DefaultConstants.js";

const InstitutionPatients = (props) => {
const InstitutionRecords = (props) => {
const { recordsLoaded, formTemplatesLoaded, onEdit, onExport, currentUser, filterAndSort } = props;
const { i18n } = useI18n();

return (
<Card variant="info" className="mt-3">
<Card.Header className="text-light bg-primary" as="h6">
{i18n("institution.patients.panel-title")}
{i18n("institution.records.panel-title")}
</Card.Header>
<Card.Body>
<RecordTable
Expand All @@ -33,7 +33,7 @@ const InstitutionPatients = (props) => {
);
};

InstitutionPatients.propTypes = {
InstitutionRecords.propTypes = {
recordsLoaded: PropTypes.object.isRequired,
formTemplatesLoaded: PropTypes.object.isRequired,
onEdit: PropTypes.func.isRequired,
Expand All @@ -42,4 +42,4 @@ InstitutionPatients.propTypes = {
filterAndSort: PropTypes.object.isRequired,
};

export default InstitutionPatients;
export default InstitutionRecords;
2 changes: 1 addition & 1 deletion src/components/record/RecordController.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class RecordController extends React.Component {
constructor(props) {
super(props);
this.state = {
record: this._isNew() ? EntityFactory.initNewPatientRecord() : null,
record: this._isNew() ? EntityFactory.initNewRecord() : null,
saved: false,
showAlert: false,
};
Expand Down
6 changes: 3 additions & 3 deletions src/i18n/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export default {
"institution.email": "Kontaktní email",
"institution.created": "Instituce zaregistrována {date}",
"institution.members.panel-title": "Zaměstnanci instituce",
"institution.patients.panel-title": "Záznamy instituce",
"institution.records.panel-title": "Záznamy instituce",
"institution.save-success": "Instituce úspěšně uložena.",
"institution.save-error": "Instituci se nepodařilo uložit. {error}",
"institution.delete-success": "Instituce úspěšně odstraněna",
Expand Down Expand Up @@ -258,7 +258,7 @@ export default {
"Username cannot contain special characters.": "Přezdívka nesmí obsahovat speciální znaky",
"Cannot encode an empty password.": "Nelze zašifrovat prázné heslo.",
"Unable to fetch remote data.": "Nelze načíst vzdálená data.",
"User with patient records cannot be deleted.": "Uživatel s vyplněným záznamem nelze odstranit.",
"User with records cannot be deleted.": "Uživatel s vyplněným záznamem nelze odstranit.",
"Cannot update user URI.": "Nelze aktualizovat uživatelské URI.",
"The passed username already exists.": "Zadané uživatelské jméno již existuje.",
"User with specified username already exists.": "Uživatel s touto přezdívkou již existuje.",
Expand All @@ -269,7 +269,7 @@ export default {
or: " nebo",
"error.record.localNameOfRecordIsNotUnique": "Formulářové pole 'Název/Česky' není unikátní napříč všemi záznamy.",
"error.record.localNameOfRecordIsEmpty": "Formulářové pole 'Název/Česky' je prázdne.",
"error.institution.remove.institutionWithMembersOrPatientRecordsCannotBeDeleted":
"error.institution.remove.institutionWithMembersOrRecordsCannotBeDeleted":
"Instituci se zaměstnanci nebo se záznamy nelze odstranit.",
"error.password.validation.thePassedUsersCurrentPasswordIsDifferentFromTheSpecifiedOne":
"Původní heslo uživatele neodpovídá heslu uloženému.",
Expand Down
10 changes: 5 additions & 5 deletions src/i18n/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export default {
"institution.email": "Contact email",
"institution.created": "Institution registered on {date}",
"institution.members.panel-title": "Institution's members",
"institution.patients.panel-title": "Institution's records",
"institution.records.panel-title": "Institution's records",
"institution.save-success": "Institution successfully saved.",
"institution.save-error": "Unable to save institution. {error}",
"institution.delete-success": "Institution deleted successfully",
Expand Down Expand Up @@ -172,7 +172,7 @@ export default {
"records.create-tile": "Create",
"records.opened-study.create-tooltip": "Create new record",
"records.closed-study.create-tooltip":
"Study is closed for addition of patient records. Please, contact a study coordinator in case you need to add new patient record.",
"Study is closed for addition of records. Please, contact a study coordinator in case you need to add new record.",
"records.export": "Export",
"records.export.excel": "Export to MS Excel",
"records.export.json": "Export to JSON",
Expand Down Expand Up @@ -262,7 +262,7 @@ export default {
"Username cannot contain special characters.": "Username cannot contain special characters.",
"Cannot encode an empty password.": "Cannot encode an empty password.",
"Unable to fetch remote data.": "Unable to fetch remote data.",
"User with patient records cannot be deleted.": "User with records cannot be deleted.",
"User with records cannot be deleted.": "User with records cannot be deleted.",
"Cannot update user URI.": "Cannot update user URI:",
"The passed username already exists.": "The passed username already exists.",
"User with specified username already exists.": "User with specified username already exists.",
Expand All @@ -273,8 +273,8 @@ export default {
or: " or",
"error.record.localNameOfRecordIsNotUnique": "Name is not unique.",
"error.record.localNameOfRecordIsEmpty": "Name is empty.",
"error.institution.remove.institutionWithMembersOrPatientRecordsCannotBeDeleted":
"Institution with members or patient records cannot be deleted.",
"error.institution.remove.institutionWithMembersOrRecordsCannotBeDeleted":
"Institution with members or records cannot be deleted.",
"error.password.validation.thePassedUsersCurrentPasswordIsDifferentFromTheSpecifiedOne":
"The user's current password is different from the specified one.",

Expand Down
2 changes: 1 addition & 1 deletion src/reducers/RecordReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ACTION_STATUS } from "../constants/DefaultConstants";
import without from "lodash/without";

const initialState = {
institutionPatients: {},
institutionRecords: {},
recordDeleted: {},
recordLoaded: {},
recordSaved: {},
Expand Down
2 changes: 1 addition & 1 deletion src/utils/EntityFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function initNewInstitution() {
};
}

export function initNewPatientRecord() {
export function initNewRecord() {
return {
localName: "",
formTemplate: "",
Expand Down
2 changes: 1 addition & 1 deletion src/utils/RoleUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function hasSupersetOfPrivileges(u1, u2) {
return [...u2RoleSet].every((role) => u1RoleSet.has(role));
}

export function canReadInstitutionPatients(currentUser, institutionKey) {
export function canReadInstitutionRecords(currentUser, institutionKey) {
return (
hasRole(currentUser, ROLE.READ_ALL_RECORDS) ||
(hasRole(currentUser, ROLE.READ_ORGANIZATION_RECORDS) && currentUser.institution?.key === institutionKey)
Expand Down
2 changes: 1 addition & 1 deletion tests/__tests__/actions/StatisticsActions.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const mockStore = configureMockStore(middlewares);

describe("Statistics asynchronous actions", function () {
let store, mockApi;
const payload = { numberOfPatients: 5, numberOfInstitutions: 10 },
const payload = { numberOfRecords: 5, numberOfInstitutions: 10 },
error = {
message: "An error has occurred.",
};
Expand Down
22 changes: 11 additions & 11 deletions tests/__tests__/components/Institution.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { describe, expect, it, vi, beforeEach } from "vitest";
import InstitutionValidator from "../../../src/validation/InstitutionValidator.jsx";
import { getMessageByKey, renderWithIntl } from "../../utils/utils.jsx";
import {
canReadInstitutionPatients,
canReadInstitutionRecords,
canReadInstitutionUsers,
canWriteInstitution,
} from "../../../src/utils/RoleUtils.js";
Expand All @@ -30,7 +30,7 @@ const defaultProps = {
onChange: vi.fn(),
onSave: vi.fn(),
onCancel: vi.fn(),
onEditPatient: vi.fn(),
onEditRecord: vi.fn(),
onExportRecords: vi.fn(),
onDelete: vi.fn(),
onEditUser: vi.fn(),
Expand All @@ -48,7 +48,7 @@ const defaultProps = {
vi.mock("../../../src/utils/RoleUtils.js", () => ({
canWriteInstitution: vi.fn(),
canReadInstitutionUsers: vi.fn(),
canReadInstitutionPatients: vi.fn(),
canReadInstitutionRecords: vi.fn(),
}));

vi.mock("../../../src/validation/InstitutionValidator.jsx", () => {
Expand All @@ -63,8 +63,8 @@ vi.mock("../../../src/components/institution/InstitutionMembers", () => ({
default: () => <div data-testid="institution-members">Members</div>,
}));

vi.mock("../../../src/components/institution/InstitutionPatients", () => ({
default: () => <div data-testid="institution-patients">Patients</div>,
vi.mock("../../../src/components/institution/InstitutionRecords", () => ({
default: () => <div data-testid="institution-records">Records</div>,
}));

const renderComponent = (props = {}) => {
Expand All @@ -76,7 +76,7 @@ describe("Institution", function () {
vi.clearAllMocks();
canWriteInstitution.mockReturnValue(true);
canReadInstitutionUsers.mockReturnValue(true);
canReadInstitutionPatients.mockReturnValue(true);
canReadInstitutionRecords.mockReturnValue(true);
InstitutionValidator.isValid.mockReturnValue(true);
});

Expand Down Expand Up @@ -117,15 +117,15 @@ describe("Institution", function () {
expect(screen.getByText(getMessageByKey("save"))).toBeDisabled();
});

it("renders InstitutionPatients when current user has ReadInstitutionPatients permission", () => {
it("renders InstitutionRecords when current user has ReadInstitutionRecords permission", () => {
renderComponent();
expect(screen.getByTestId("institution-patients")).toBeInTheDocument();
expect(screen.getByTestId("institution-records")).toBeInTheDocument();
});

it("does not render InstitutionPatients when current user lacks read permission", () => {
canReadInstitutionPatients.mockReturnValue(false);
it("does not render InstitutionRecords when current user lacks read permission", () => {
canReadInstitutionRecords.mockReturnValue(false);
renderComponent();
expect(screen.queryByTestId("institution-patients")).not.toBeInTheDocument();
expect(screen.queryByTestId("institution-records")).not.toBeInTheDocument();
});

it("renders InstitutionMembers when current user has ReadInstitutionUsers permission", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import InstitutionPatients from "../../../src/components/institution/InstitutionPatients";
import InstitutionRecords from "../../../src/components/institution/InstitutionRecords.jsx";
import { describe, expect, it, vi } from "vitest";
import { getMessageByKey, renderWithIntl } from "../../utils/utils.jsx";
import { screen } from "@testing-library/react";
Expand Down Expand Up @@ -30,17 +30,17 @@ vi.mock("../../../src/components/record/ExportRecordsDropdown", () => ({
}));

const renderComponent = (props = {}) => {
return renderWithIntl(<InstitutionPatients {...defaultProps} {...props} />);
return renderWithIntl(<InstitutionRecords {...defaultProps} {...props} />);
};

describe("InstitutionPatients", function () {
describe("InstitutionRecords", function () {
beforeEach(() => {
vi.clearAllMocks();
});

it("renders the correct panel title", () => {
renderComponent();
expect(screen.getByText(getMessageByKey("institution.patients.panel-title"))).toBeInTheDocument();
expect(screen.getByText(getMessageByKey("institution.records.panel-title"))).toBeInTheDocument();
});

it("renders the RecordTable component", () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/__tests__/components/RecordRow.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const defaultProps = {
onEdit: vi.fn(),
onDelete: vi.fn(),
record: {
uri: "http://onto.fel.cvut.cz/ontologies/record-manager/patient-record#instance456619208",
uri: "http://onto.fel.cvut.cz/ontologies/record-manager/record#instance456619208",
key: "159968282553298775",
localName: "Test",
dateCreated: 1520956570035,
Expand Down
4 changes: 2 additions & 2 deletions tests/__tests__/components/Records.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ const defaultProps = {
status: ACTION_STATUS.SUCCESS,
records: [
{
uri: "http://onto.fel.cvut.cz/ontologies/record-manager/patient-record#instance456619209",
uri: "http://onto.fel.cvut.cz/ontologies/record-manager/record#instance456619209",
key: "159968282553298774",
localName: "Test1",
dateCreated: "1520956570034",
author: { username: "test" },
institution: { key: 12345678 },
},
{
uri: "http://onto.fel.cvut.cz/ontologies/record-manager/patient-record#instance456619208",
uri: "http://onto.fel.cvut.cz/ontologies/record-manager/record#instance456619208",
key: "159968282553298775",
localName: "Test2",
dateCreated: "1520956570035",
Expand Down