forked from ohcnetwork/care_fe
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcare.config.ts
More file actions
213 lines (178 loc) · 5.89 KB
/
care.config.ts
File metadata and controls
213 lines (178 loc) · 5.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
import {
ENCOUNTER_CLASS,
EncounterClass,
EncounterDischargeDisposition,
} from "@/types/emr/encounter/encounter";
import { NonEmptyArray } from "@/Utils/types";
import { CountryCode } from "libphonenumber-js/types.cjs";
const env = import.meta.env;
interface ILogo {
light: string;
dark: string;
}
const boolean = (key: string, fallback = false) => {
if (env[key] === "true") return true;
if (env[key] === "false") return false;
return fallback;
};
const logo = (value?: string, fallback?: ILogo) => {
if (!value) {
return fallback;
}
try {
return JSON.parse(value) as ILogo;
} catch {
return fallback;
}
};
const careConfig = {
apiUrl: env.REACT_CARE_API_URL,
sbomBaseUrl: env.REACT_SBOM_BASE_URL || "https://sbom.ohc.network",
urls: {
github: env.REACT_GITHUB_URL || "https://github.com/ohcnetwork",
ohcn: env.REACT_OHCN_URL || "https://ohc.network?ref=care",
},
mainLogo: logo(env.REACT_MAIN_LOGO, {
light: "/images/care_logo.svg",
dark: "/images/care_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,
availableLocales: (env.REACT_ALLOWED_LOCALES || "")
.split(",")
.map((l) => l.trim()),
encounterClasses: (env.REACT_ALLOWED_ENCOUNTER_CLASSES?.split(",") ??
ENCOUNTER_CLASS) as NonEmptyArray<EncounterClass>,
defaultEncounterType:
(env.REACT_DEFAULT_ENCOUNTER_TYPE as EncounterClass) ||
(env.REACT_ALLOWED_ENCOUNTER_CLASSES?.split(",").length === 1
? (env.REACT_ALLOWED_ENCOUNTER_CLASSES?.split(",")[0] as EncounterClass)
: undefined),
defaultDischargeDisposition: env.REACT_DEFAULT_DISCHARGE_DISPOSITION as
| EncounterDischargeDisposition
| undefined,
mapFallbackUrlTemplate:
env.REACT_MAPS_FALLBACK_URL_TEMPLATE ||
"https://www.openstreetmap.org/?mlat={lat}&mlon={long}&zoom=15",
reCaptchaSiteKey: env.REACT_RECAPTCHA_SITE_KEY,
auth: {
tokenRefreshInterval: env.REACT_JWT_TOKEN_REFRESH_INTERVAL
? parseInt(env.REACT_JWT_TOKEN_REFRESH_INTERVAL)
: 5 * 60e3,
},
// Plugins related configs...
sentry: {
dsn:
env.REACT_SENTRY_DSN ||
"https://8801155bd0b848a09de9ebf6f387ebc8@sentry.io/5183632",
environment: env.REACT_SENTRY_ENVIRONMENT || "staging",
},
/**
* Relative number of days to show in the encounters page by default.
* 0 means today.
*/
encounterDateFilter: env.REACT_ENCOUNTER_DEFAULT_DATE_FILTER
? parseInt(env.REACT_ENCOUNTER_DEFAULT_DATE_FILTER)
: 0,
appointments: {
/**
* Relative number of days to show in the appointments page by default.
* 0 means today, positive for future days, negative for past days.
*/
defaultDateFilter: env.REACT_APPOINTMENTS_DEFAULT_DATE_FILTER
? parseInt(env.REACT_APPOINTMENTS_DEFAULT_DATE_FILTER)
: 0,
// Kill switch in-case the heatmap API doesn't scale as expected
useAvailabilityStatsAPI: boolean(
"REACT_APPOINTMENTS_USE_AVAILABILITY_STATS_API",
true,
),
},
/**
* Flag to make location field mandatory for payment reconciliation
*/
paymentLocationRequired: boolean("REACT_PAYMENT_LOCATION_REQUIRED", true),
careApps: env.REACT_ENABLED_APPS
? env.REACT_ENABLED_APPS.split(",").map((app) => {
const [module, cdn] = app.split("@");
const [org, repo] = module.split("/");
if (!org || !repo) {
throw new Error(
`Invalid plug configuration: ${module}. Expected 'org/repo@url'.`,
);
}
let url = "";
if (!cdn) {
url = `https://${org}.github.io/${repo}`;
}
if (!url.startsWith("http")) {
url = `${cdn.includes("localhost") ? "http" : "https"}://${cdn}`;
}
return {
url: new URL(url).toString(),
name: repo,
package: module,
};
})
: [],
plotsConfigUrl:
env.REACT_OBSERVATION_PLOTS_CONFIG_URL || "/config/plots.json",
defaultCountry: {
code: (env.REACT_DEFAULT_COUNTRY || "IN") as CountryCode,
name: env.REACT_DEFAULT_COUNTRY_NAME || "India",
},
resendOtpTimeout: env.REACT_APP_RESEND_OTP_TIMEOUT
? parseInt(env.REACT_APP_RESEND_OTP_TIMEOUT, 10)
: 30,
imageUploadMaxSizeInMB: env.REACT_APP_MAX_IMAGE_UPLOAD_SIZE_MB
? parseInt(env.REACT_APP_MAX_IMAGE_UPLOAD_SIZE_MB, 10)
: 2,
/**
* Disable patient login if set to "true"
*/
disablePatientLogin: boolean("REACT_DISABLE_PATIENT_LOGIN", false),
patientRegistration: {
/**
* Minimum number of geo-organization levels the user must select
* during patient registration.
*
* If not set, all levels are required.
*/
minGeoOrganizationLevelsRequired:
env.REACT_PATIENT_REG_MIN_GEO_ORG_LEVELS_REQUIRED
? Math.max(
parseInt(env.REACT_PATIENT_REG_MIN_GEO_ORG_LEVELS_REQUIRED, 10),
1,
)
: undefined,
defaultGeoOrganization: env.REACT_PATIENT_REGISTRATION_DEFAULT_GEO_ORG,
minimalPatientRegistration: boolean(
"REACT_ENABLE_MINIMAL_PATIENT_REGISTRATION",
false,
),
},
i18nUrl: env.REACT_CUSTOM_REMOTE_I18N_URL,
/**
* Custom shortcuts configuration from environment variables
* Format: JSON string with array of shortcut objects
* Each shortcut can have: title, description, href, icon (optional)
* Placeholders like {facilityId}, {userId} will be replaced at runtime
*/
customShortcuts: env.REACT_CUSTOM_SHORTCUTS
? JSON.parse(env.REACT_CUSTOM_SHORTCUTS)
: [],
/**
* System identifier for patient phone number configuration
*/
phoneNumberConfigSystem: "system.care.ohc.network/patient-phone-number",
/**
* Enable automatic invoice sheet after dispensing items
*/
enableAutoInvoiceAfterDispense: boolean(
"REACT_ENABLE_AUTO_INVOICE_AFTER_DISPENSE",
false,
),
} as const;
export default careConfig;