Skip to content

Commit

Permalink
Merge branch 'develop' into sainak/feat/use-managed-media-source
Browse files Browse the repository at this point in the history
  • Loading branch information
nihal467 authored Sep 4, 2024
2 parents b9ce4b3 + 6db5703 commit b0151a9
Show file tree
Hide file tree
Showing 76 changed files with 1,287 additions and 928 deletions.
6 changes: 4 additions & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# Whitelabelling envs

REACT_APP_TITLE=CARE
REACT_APP_META_DESCRIPTION=Revolutionizing EMR with AI: Open Healthcare Network develops free, open-source tools to enhance efficiency in global healthcare delivery. Our EMR system is recognized as a Digital Public Good by the United Nations.
REACT_APP_META_DESCRIPTION="Revolutionizing EMR with AI: Open Healthcare Network develops free, open-source tools to enhance efficiency in global healthcare delivery. Our EMR system is recognized as a Digital Public Good by the United Nations."
REACT_APP_COVER_IMAGE=https://cdn.ohc.network/care_logo.svg
REACT_APP_COVER_IMAGE_ALT=https://cdn.ohc.network/care_logo.svg
REACT_PUBLIC_URL=https://care.ohc.network

# Care API URL without the /api prefix
REACT_CARE_API_URL=https://careapi.ohc.network

# Dev envs
ESLINT_NO_DEV_ERRORS=true

CARE_CDN_URL="https://egov-s3-facility-10bedicu.s3.amazonaws.com https://egov-s3-patient-data-10bedicu.s3.amazonaws.com http://localhost:4566"
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
dotenv
test -f .env.local && dotenv .env.local
79 changes: 79 additions & 0 deletions .example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Backend URL
REACT_CARE_API_URL=https://careapi.ohc.network

# Dashboard URL
REACT_DASHBOARD_URL=

# GitHub URL (default: https://github.com/ohcnetwork)
REACT_GITHUB_URL=

# OHCN URL (default: https://ohc.network?ref=care)
REACT_OHCN_URL=

# Plausible site domain (default: care.ohc.network)
REACT_PLAUSIBLE_SITE_DOMAIN=

# Plausible server URL (default: https://plausible.10bedicu.in)
REACT_PLAUSIBLE_SERVER_URL=


# Main logo (JSON string with light and dark properties)
REACT_HEADER_LOGO=

# Main logo (JSON string with light and dark properties)
# Example: REACT_MAIN_LOGO="{\"light\": \"https://cdn.ohc.network/light-logo.svg\", \"dark\": \"https://cdn.ohc.network/dark-logo.svg\"}"
REACT_MAIN_LOGO=

# State logo (JSON string with light and dark properties)
REACT_STATE_LOGO=

# Custom logo (JSON string with light and dark properties)
REACT_CUSTOM_LOGO=

# Custom alternative logo (JSON string with light and dark properties)
REACT_CUSTOM_LOGO_ALT=

# Custom description
REACT_CUSTOM_DESCRIPTION=

# Google Maps API key
REACT_GMAPS_API_KEY=

# Government data API key
REACT_GOV_DATA_API_KEY=

# reCAPTCHA site key
REACT_RECAPTCHA_SITE_KEY=

# Sentry DSN
REACT_SENTRY_DSN=

# Sentry environment (default: staging)
REACT_SENTRY_ENVIRONMENT=

# KASP settings
REACT_KASP_ENABLED=true
REACT_KASP_STRING=KASP
REACT_KASP_FULL_STRING=Karunya Arogya Suraksha Padhathi

# Sample format file paths
REACT_SAMPLE_FORMAT_ASSET_IMPORT=/asset-import-template.xlsx
REACT_SAMPLE_FORMAT_EXTERNAL_RESULT_IMPORT=/External-Results-Template.csv

# Camera feed, still watching idle timeout (in seconds; default: 180)
REACT_STILL_WATCHING_IDLE_TIMEOUT=

# Camera feed, still watching prompt duration (in seconds; default: 30)
REACT_STILL_WATCHING_PROMPT_DURATION=

# Feature flags
REACT_ENABLE_HCX=true
REACT_ENABLE_ABDM=true
REACT_ENABLE_SCRIBE=true
REACT_WARTIME_SHIFTING=true

# JWT token refresh interval (in milliseconds) (default: 5 minutes)
REACT_JWT_TOKEN_REFRESH_INTERVAL=

# Minimum encounter date (default: 2020-01-01)
REACT_MIN_ENCOUNTER_DATE=
7 changes: 4 additions & 3 deletions .github/workflows/cypress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jobs:
fail-fast: false
matrix:
containers: [1, 2, 3, 4, 5, 6, 7, 8]
env:
REACT_CARE_API_URL: http://localhost:9000
steps:
- name: Checkout 📥
uses: actions/checkout@v3
Expand All @@ -42,6 +44,7 @@ jobs:
run: |
cd care
echo DISABLE_RATELIMIT=True >> docker/.prebuilt.env
echo "CORS_ALLOWED_ORIGINS=\"[\\\"http://localhost:4000\\\"]\"" >> docker/.prebuilt.env
make docker_config_file=docker-compose.pre-built.yaml up
make docker_config_file=docker-compose.pre-built.yaml load-dummy-data
cd ..
Expand All @@ -66,7 +69,7 @@ jobs:
- name: Install dependencies 📦
run: npm install

- name: Build & Compile rescript files ⚙️
- name: Build ⚙️
run: npm run build

- name: Install Specific Chrome Version
Expand All @@ -89,7 +92,6 @@ jobs:
parallel: true
group: "UI-Chrome"
env:
CARE_API: http://localhost:9000
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_OPTIONS: --max_old_space_size=4096
Expand All @@ -111,7 +113,6 @@ jobs:
group: "UI-Chrome"
env:
CYPRESS_SPLIT_TESTS: "true"
CARE_API: http://localhost:9000
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_OPTIONS: --max_old_space_size=4096
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ To ensure the quality of our pull requests, we use a variety of tools:

To run cypress tests locally, you'll need to setup the backend to run locally and load dummy data required for cypress to the database. See [docs](https://github.com/ohcnetwork/care#self-hosting).

Once backend is running locally, you'll have to ensure your local front-end is connected to local backend, by setting the `CARE_API` env.
Once backend is running locally, you'll have to ensure your local front-end is connected to local backend, by setting the `REACT_CARE_API_URL` env.

```env
#.env
CARE_API=http://127.0.0.1:9000
REACT_CARE_API_URL=http://127.0.0.1:9000
```

Once done, start the development server by running
Expand Down
112 changes: 112 additions & 0 deletions care.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
const env = import.meta.env;

interface ILogo {
light: string;
dark: string;
}

const logo = (value?: string, fallback?: ILogo) => {
if (!value) {
return fallback;
}

try {
return JSON.parse(value) as ILogo;
} catch {
// TODO: define vite plugin to validate care.config.ts during build step
return fallback;
}
};
const careConfig = {
apiUrl: env.REACT_CARE_API_URL,

urls: {
dashboard: env.REACT_DASHBOARD_URL,
github: env.REACT_GITHUB_URL || "https://github.com/ohcnetwork",
ohcn: env.REACT_OHCN_URL || "https://ohc.network?ref=care",
},

headerLogo: logo(env.REACT_HEADER_LOGO, {
light: "https://cdn.ohc.network/header_logo.png",
dark: "https://cdn.ohc.network/header_logo.png",
}),
mainLogo: logo(env.REACT_MAIN_LOGO, {
light: "https://cdn.ohc.network/light-logo.svg",
dark: "https://cdn.ohc.network/black-logo.svg",
}),
stateLogo: logo(env.REACT_STATE_LOGO),
customLogo: logo(env.REACT_CUSTOM_LOGO),
customLogoAlt: logo(env.REACT_CUSTOM_LOGO_ALT),
customDescription: env.REACT_CUSTOM_DESCRIPTION,

gmapsApiKey:
env.REACT_GMAPS_API_KEY || "AIzaSyDsBAc3y7deI5ZO3NtK5GuzKwtUzQNJNUk",

govDataApiKey:
env.REACT_GOV_DATA_API_KEY ||
"579b464db66ec23bdd000001cdd3946e44ce4aad7209ff7b23ac571b",
reCaptchaSiteKey:
env.REACT_RECAPTCHA_SITE_KEY || "6LdvxuQUAAAAADDWVflgBqyHGfq-xmvNJaToM0pN",

kasp: {
enabled: env.REACT_KASP_ENABLED === "true",
string: env.REACT_KASP_STRING || "KASP",
fullString:
env.REACT_KASP_FULL_STRING || "Karunya Arogya Suraksha Padhathi",
},

sampleFormats: {
assetImport:
env.REACT_SAMPLE_FORMAT_ASSET_IMPORT || "/asset-import-template.xlsx",
externalResultImport:
env.REACT_SAMPLE_FORMAT_EXTERNAL_RESULT_IMPORT ||
"/External-Results-Template.csv",
},

wartimeShifting: env.REACT_WARTIME_SHIFTING === "true",

stillWatching: {
idleTimeout: env.REACT_STILL_WATCHING_IDLE_TIMEOUT
? parseInt(env.REACT_STILL_WATCHING_IDLE_TIMEOUT)
: 3 * 60,
promptDuration: env.REACT_STILL_WATCHING_PROMPT_DURATION
? parseInt(env.REACT_STILL_WATCHING_PROMPT_DURATION)
: 30,
},

auth: {
tokenRefreshInterval: env.REACT_JWT_TOKEN_REFRESH_INTERVAL
? parseInt(env.REACT_JWT_TOKEN_REFRESH_INTERVAL)
: 5 * 60e3,
},

minEncounterDate: new Date(env.REACT_MIN_ENCOUNTER_DATE || "2020-01-01"),

// Plugins related configs...

plausible: {
server: env.REACT_PLAUSIBLE_SERVER_URL || "https://plausible.10bedicu.in",
domain: env.REACT_PLAUSIBLE_SITE_DOMAIN || "care.ohc.network",
},

sentry: {
dsn:
env.REACT_SENTRY_DSN ||
"https://[email protected]/5183632",
environment: env.REACT_SENTRY_ENVIRONMENT || "staging",
},

hcx: {
enabled: env.REACT_ENABLE_HCX === "true",
},

abdm: {
enabled: (env.REACT_ENABLE_ABDM ?? "true") === "true",
},

scribe: {
enabled: env.REACT_ENABLE_SCRIBE === "true",
},
} as const;

export default careConfig;
3 changes: 3 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,7 @@ export default defineConfig({
requestTimeout: 15000,
excludeSpecPattern: "**/*roles.cy.ts",
},
env: {
API_URL: process.env.REACT_CARE_API_URL ?? "http://localhost:9000",
},
});
2 changes: 1 addition & 1 deletion cypress/e2e/facility_spec/facility_creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe("Facility Creation", () => {
const totalOccupancy = "10";
const doctorCapacity = "5";
const totalDoctor = "10";
const facilityName = "cypress facility";
const facilityName = "Cypress Facility";
const facilityName2 = "Dummy Facility 40";
const facilityAddress = "cypress address";
const facilityUpdateAddress = "cypress updated address";
Expand Down
8 changes: 5 additions & 3 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import "cypress-localstorage-commands";

import { Cypress, cy } from "local-cypress";

const apiUrl = Cypress.env("API_URL");

Cypress.Commands.add("login", (username: string, password: string) => {
cy.log(`Logging in the user: ${username}:${password}`);
cy.visit("/");
Expand All @@ -14,7 +16,7 @@ Cypress.Commands.add("login", (username: string, password: string) => {
Cypress.Commands.add("refreshApiLogin", (username, password) => {
cy.request({
method: "POST",
url: "/api/v1/auth/login/",
url: `${apiUrl}/api/v1/auth/login/`,
body: {
username,
password,
Expand Down Expand Up @@ -43,7 +45,7 @@ Cypress.Commands.add("loginByApi", (username, password) => {
if (tkn && token.access && token.username === username) {
cy.request({
method: "POST",
url: "/api/v1/auth/token/verify/",
url: `${apiUrl}/api/v1/auth/token/verify/`,
body: {
token: token.access,
},
Expand All @@ -69,7 +71,7 @@ Cypress.Commands.add("loginByApi", (username, password) => {
Cypress.Commands.add(
"awaitUrl",
(url: string, disableLoginVerification = false) => {
cy.intercept(/currentuser/).as("currentuser");
cy.intercept(/getcurrentuser/).as("currentuser");
cy.visit(url);
disableLoginVerification
? cy.wait("@currentuser")
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<meta property="og:title" content="%REACT_APP_TITLE%" />
<meta property="og:description" content="%REACT_APP_META_DESCRIPTION%" />
<meta property="og:image" content="%REACT_APP_COVER_IMAGE%" />
<meta property=" og:url" content="%REACT_PUBLIC_URL%" />
<meta property="og:url" content="%REACT_PUBLIC_URL%" />
<meta property="og:site_name" content="%REACT_APP_TITLE%" />
<meta name="twitter:title" content="%REACT_APP_TITLE%" />
<meta name="twitter:description" content="%REACT_APP_META_DESCRIPTION%" />
Expand Down
6 changes: 0 additions & 6 deletions netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ NODE_VERSION = "20.12.0"
NPM_FLAGS = "--legacy-peer-deps"
NODE_OPTIONS = "--max_old_space_size=4096"

[[redirects]]
from = "/api/*"
to = "https://careapi.ohc.network/api/:splat"
status = 200
force = true

[[redirects]]
from = "/*"
to = "/index.html"
Expand Down
21 changes: 8 additions & 13 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
import { Suspense } from "react";
import Routers from "./Routers";
import {
AppConfigProvider,
AuthUserProvider,
HistoryAPIProvider,
} from "./Providers";
import ThemedFavicon from "./CAREUI/misc/ThemedFavicon";
import Intergrations from "./Integrations";
import Loading from "./Components/Common/Loading";
import HistoryAPIProvider from "./Providers/HistoryAPIProvider";
import AuthUserProvider from "./Providers/AuthUserProvider";

const App = () => {
return (
<Suspense fallback={<Loading />}>
<ThemedFavicon />
<HistoryAPIProvider>
<AppConfigProvider>
<AuthUserProvider unauthorized={<Routers.SessionRouter />}>
<Routers.AppRouter />
</AuthUserProvider>
<AuthUserProvider unauthorized={<Routers.SessionRouter />}>
<Routers.AppRouter />
</AuthUserProvider>

{/* Integrations */}
<Intergrations.Sentry disabled={!import.meta.env.PROD} />
<Intergrations.Plausible />
</AppConfigProvider>
{/* Integrations */}
<Intergrations.Sentry disabled={!import.meta.env.PROD} />
<Intergrations.Plausible />
</HistoryAPIProvider>
</Suspense>
);
Expand Down
Loading

0 comments on commit b0151a9

Please sign in to comment.