Skip to content

Commit

Permalink
Merge branch 'develop' into fix/OH2-374-patient-exams-feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveGT96 committed Sep 10, 2024
2 parents 834bbef + 8f06d5d commit b501689
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 90 deletions.
59 changes: 31 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ _This project is still in early stages. For a more mature user interface of Open
This project is based on React. To learn React, check out the [React documentation](https://reactjs.org/).
To install the project dependencies, issue:

- npm i
npm i

**It has to be done before any of the following activities**

Expand All @@ -29,29 +29,32 @@ Examples:

- you want to develop using real api instead of mocked: use this `.env.local` file

```
# .env.local
REACT_APP_USE_MOCK_API=
```
```
# .env.local
REACT_APP_USE_MOCK_API=
```

- then: `npm start`
then `npm start`

- you want to connect your local dev environment to docker api:
```
# .env.local
REACT_APP_USE_MOCK_API=
REACT_APP_BASE_PATH=http://localhost:8080/oh-api
```
- then: `docker-compose up && npm start`

```
# .env.local
REACT_APP_USE_MOCK_API=
REACT_APP_BASE_PATH=http://localhost:8080/oh-api
```

then `docker-compose up database backend && npm start`

## Run local development environment

- npm start
npm start

## Run full stack environment locally

You can run a full OH2 stack locally using [Docker](https://www.docker.com/) (required) using this command:
( - docker-compose up

docker-compose up

Then you can access to:

Expand All @@ -61,7 +64,7 @@ Then you can access to:

## How to publish on Web Server

- npm run build:staging
npm run build:staging

Then connect to the Intesys VPN and open FileZilla.

Expand All @@ -82,39 +85,39 @@ Once you are logged in, go under /home/httpd/open-hospital/shared/public and rep

Easy step:

- git push intesys-remote develop
git push intesys-remote develop

Old method:

- npm run build:gh-pages
- git commit
npm run build:gh-pages
git commit

then
then

- git subtree push --prefix build intesys-oh gh-pages
git subtree push --prefix build intesys-oh gh-pages

or
or

- git subtree split --prefix build develop
- git push intesys-oh GIT_ID:gh-pages --force
git subtree split --prefix build develop
git push intesys-oh GIT_ID:gh-pages --force

## How to launch the application

You can run a development build of the application by issuing:

- npm start
npm start

## How to run unit tests

To run unit tests, issue:

- npm test
npm test

## How to launch the e2e tests

Run:

- npm run e2e
npm run e2e

it launches application in development mode and starts cypress, in a single process.

Expand All @@ -123,10 +126,10 @@ it launches application in development mode and starts cypress, in a single proc
If you want more control over **Cypress e2e tests**, use two different processes: one for serving the app (**process #1**) and one for running the Cypress Test Runner (**process #2**). You can launch it by issuing the following commands in two different intances of your terminal:

//process #1
- npm start
npm start

//process #2
- npm run cypress:open
npm run cypress:open

Once the app is compiled and served, and the Cypress Test Runner is launched, click on _Run all specs_

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ x-mariadb: &mariadb-env
MARIADB_ROOT_PASSWORD: root
MARIADB_USER: isf
MARIADB_PASSWORD: isf123
OH_DEMO_LANG: en
OH_DB_LANG: en
x-ui: &ui-env
<<: *repository-args
PUBLIC_URL: /
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.backend
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ RUN --mount=type=cache,target=/root/.m2 mvn clean install -DskipTests=true

# CMD mvn spring-boot:run
WORKDIR /openhospital-api/target
CMD java -cp "openhospital-api-0.1.0.jar:rsc/:static/" org.springframework.boot.loader.JarLauncher
CMD java -cp "openhospital-api-0.1.0.jar:rsc/:static/" org.springframework.boot.loader.launch.JarLauncher
17 changes: 9 additions & 8 deletions docker/Dockerfile.database
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
FROM mariadb:10.6.11

ARG OH_DB_LANG=en

ARG GITHUB_ORG=informatici
ARG OH_CORE_BRANCH=develop
ARG MARIADB_PORT
ARG MARIADB_DATABASE
ARG MARIADB_ROOT_PASSWORD
ARG MARIADB_USER
ARG MARIADB_PASSWORD
ARG OH_DEMO_LANG
# ENV MYSQL_DATABASE=oh
# ENV MYSQL_ROOT_PASSWORD=root
# ENV MYSQL_USER=isf
# ENV MYSQL_PASSWORD=isf123

RUN apt-get update
RUN apt-get install git -y
Expand All @@ -22,8 +19,8 @@ EXPOSE 3306

RUN cp sql/step_01_create_structure.sql /docker-entrypoint-initdb.d/
RUN cp sql/step_02_dump_menu.sql /docker-entrypoint-initdb.d/
RUN cp sql/step_03_dump_default_data_en.sql /docker-entrypoint-initdb.d/
#RUN cp sql/step_04_all_following_steps.sql /docker-entrypoint-initdb.d/
RUN cp sql/step_03_dump_default_data_${OH_DB_LANG}.sql /docker-entrypoint-initdb.d/
#COPY sql/step_04_all_following_steps.sql /docker-entrypoint-initdb.d/
RUN cp sql/step_05_update_menu_i18n.sql /docker-entrypoint-initdb.d/
RUN cp sql/step_06_opd_extended.sql /docker-entrypoint-initdb.d/
RUN cp sql/step_07_modifiche_matiri.sql /docker-entrypoint-initdb.d/
Expand All @@ -39,7 +36,11 @@ RUN cp sql/step_7* /docker-entrypoint-initdb.d/
RUN cp sql/step_8* /docker-entrypoint-initdb.d/
RUN cp sql/step_9* /docker-entrypoint-initdb.d/
RUN cp sql/step_a1* /docker-entrypoint-initdb.d/
RUN mkdir data_en && cp sql/data_en/* data_en/
RUN mkdir data_${OH_DB_LANG} && cp sql/data_${OH_DB_LANG}/* data_${OH_DB_LANG}/
RUN cp sql/step_03_dump_vaccine_data_${OH_DB_LANG}.sql /docker-entrypoint-initdb.d/step_z100_dump_vaccine_data_${OH_DB_LANG}.sql
RUN cp sql/step_03_dump_dicomtype_data_${OH_DB_LANG}.sql /docker-entrypoint-initdb.d/step_z101_dump_dicomtype_data_${OH_DB_LANG}.sql

# optional steps
#RUN cp sql/delete_all_data.sql /docker-entrypoint-initdb.d/step_9990_delete_all_data.sql
#RUN cp sql/load_demo_data.sql /docker-entrypoint-initdb.d/step_9991_load_demo_data.sql
#RUN cp sql/extra/reset_admin_password_strong.sql /docker-entrypoint-initdb.d/step_9992_reset_admin_password_strong.sql
35 changes: 24 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 27 additions & 31 deletions src/components/accessories/admission/PatientAdmission.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { useAppDispatch, useAppSelector } from "libraries/hooks/redux";
import { isEmpty } from "lodash";
import React, { FC, useEffect, useMemo, useRef, useState } from "react";
import React, { FC, useEffect, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import { useParams } from "react-router";
import { getPatient } from "state/patients";
import checkIcon from "../../../assets/check-icon.png";
import { AdmissionDTO, PatientDTOStatusEnum } from "../../../generated";
import { usePermission } from "../../../libraries/permissionUtils/usePermission";
Expand All @@ -10,11 +12,11 @@ import {
createAdmission,
createAdmissionReset,
getCurrentAdmission,
getCurrentAdmissionReset,
updateAdmission,
updateAdmissionReset,
} from "../../../state/admissions";
import { getLastOpd } from "../../../state/opds";
import { getPatient } from "../../../state/patients";
import { IState } from "../../../types";
import ConfirmationDialog from "../confirmationDialog/ConfirmationDialog";
import { CurrentAdmission } from "../currentAdmission/CurrentAdmission";
Expand All @@ -29,6 +31,8 @@ const PatientAdmission: FC = () => {
const { t } = useTranslation();
const dispatch = useAppDispatch();
const canCreate = usePermission("admissions.create");
const canUpdate = usePermission("admissions.update");
const { id } = useParams();
const infoBoxRef = useRef<HTMLDivElement>(null);
const [shouldResetForm, setShouldResetForm] = useState(false);
const [creationMode, setCreationMode] = useState(true);
Expand All @@ -52,10 +56,6 @@ const PatientAdmission: FC = () => {
(state: IState) => state.admissions.currentAdmissionByPatientId.data
);

const currentAdmissionStatus = useAppSelector(
(state: IState) => state.admissions.currentAdmissionByPatientId.status
);

const createStatus = useAppSelector(
(state) => state.admissions.createAdmission.status
);
Expand All @@ -81,15 +81,10 @@ const PatientAdmission: FC = () => {

useEffect(() => {
if (patientCode && creationMode) {
dispatch(getLastOpd(patientCode ?? -1));
dispatch(getLastOpd(parseInt(id!!)));
}
}, [dispatch, patientCode, creationMode]);

const open = useMemo(() => {
if (creationMode) return showForm && canCreate;
return showForm;
}, [showForm, canCreate, creationMode]);

const fields = useFields(admissionToEdit, lastOpd?.disease);

const onSubmit = (adm: AdmissionDTO) => {
Expand Down Expand Up @@ -143,31 +138,27 @@ const PatientAdmission: FC = () => {
}, [dispatch]);

useEffect(() => {
if (!creationMode) {
setShowForm(true);
} else if (
creationMode &&
currentAdmissionStatus !== "SUCCESS" &&
currentAdmissionStatus !== "IDLE" &&
!currentAdmission
) {
setShowForm(true);
} else setShowForm(false);
}, [currentAdmissionStatus, currentAdmission, creationMode]);
if (creationMode && !!currentAdmission) {
setShowForm(false);
} else setShowForm(true);
}, [currentAdmission, creationMode]);

useEffect(() => {
if (activityTransitionState === "TO_RESET") {
dispatch(getPatient((patient?.code ?? 0).toString()));
setCreationMode(true);
setAdmissionToEdit(undefined);
dispatch(createAdmissionReset());
dispatch(updateAdmissionReset());
dispatch(getCurrentAdmission(patient?.code));
setShouldUpdateTable(true);
setShouldResetForm(true);
}
}, [dispatch, patient, activityTransitionState]);

useEffect(() => {
if (createStatus === "SUCCESS" || updateStatus === "SUCCESS") {
dispatch(getPatient(id!!));
dispatch(getCurrentAdmission(parseInt(id!!)));
}
}, [createStatus, updateStatus]);

const resetFormCallback = () => {
setCreationMode(true);
setShouldResetForm(false);
Expand All @@ -178,8 +169,11 @@ const PatientAdmission: FC = () => {
};

useEffect(() => {
dispatch(getCurrentAdmission(patient?.code));
}, [patient, dispatch]);
dispatch(getCurrentAdmission(parseInt(id!!)));
return () => {
dispatch(getCurrentAdmissionReset());
};
}, [dispatch]);

const onEdit = (row: AdmissionDTO) => {
setAdmissionToEdit(row);
Expand All @@ -196,8 +190,10 @@ const PatientAdmission: FC = () => {
{patient?.status === PatientDTOStatusEnum.I && (
<InfoBox type="info" message={t("admission.patientalreadyadmitted")} />
)}
{!open && <CurrentAdmission onEditChange={onCurrentAdmissionChange} />}
{open && (
{!showForm && currentAdmission && (
<CurrentAdmission onEditChange={onCurrentAdmissionChange} />
)}
{showForm && (creationMode ? canCreate : canUpdate) && (
<AdmissionForm
fields={fields}
onSubmit={onSubmit}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { usePermission } from "../../../../libraries/permissionUtils/usePermissi
import { getOpdsWithOperationRows } from "../../../../state/opds";
import InfoBox from "../../infoBox/InfoBox";
import Table from "../../table/Table";

interface IOwnProps {
shouldUpdateTable: boolean;
handleEdit: (row: any) => void;
Expand Down
Loading

0 comments on commit b501689

Please sign in to comment.