Skip to content

Commit

Permalink
remove node libs usage from some utils package files, move auth relat…
Browse files Browse the repository at this point in the history
…ed functions that were brought out to utils back into individual zambda folders (cause soon zambdas packages will be unified), remove node types from ui apps components
  • Loading branch information
VladMstv committed Jan 30, 2025
1 parent 5406bf1 commit 27c1703
Show file tree
Hide file tree
Showing 101 changed files with 380 additions and 482 deletions.
8 changes: 4 additions & 4 deletions apps/ehr/src/telemed/state/appointment/appointment.queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import { useAuth0 } from '@auth0/auth0-react';
import {
Appointment,
Bundle,
Coding,
DocumentReference,
Encounter,
FhirResource,
InsurancePlan,
Location,
Medication,
Patient,
QuestionnaireResponse,
RelatedPerson,
Coding,
Medication,
} from 'fhir/r4b';
import { DateTime } from 'luxon';
import { enqueueSnackbar } from 'notistack';
Expand All @@ -21,6 +21,7 @@ import {
ChartDataRequestedFields,
GetMedicationOrdersResponse,
INVENTORY_MEDICATION_TYPE_CODE,
IcdSearchRequestParams,
InstructionType,
MEDICATION_IDENTIFIER_NAME_SYSTEM,
MeetingData,
Expand All @@ -33,14 +34,13 @@ import {
createSmsModel,
filterResources,
relatedPersonAndCommunicationMaps,
IcdSearchRequestParams,
} from 'utils';
import { APPOINTMENT_REFRESH_INTERVAL, CHAT_REFETCH_INTERVAL, QUERY_STALE_TIME } from '../../../constants';
import { useApiClients } from '../../../hooks/useAppClients';
import { useAuthToken } from '../../../hooks/useAuthToken';
import useEvolveUser, { EvolveUser } from '../../../hooks/useEvolveUser';
import { getSelectors } from '../../../shared/store/getSelectors';
import { PromiseReturnType, OystehrTelemedAPIClient } from '../../data';
import { OystehrTelemedAPIClient, PromiseReturnType } from '../../data';
import { useGetAppointmentAccessibility } from '../../hooks';
import { useZapEHRAPIClient } from '../../hooks/useOystehrAPIClient';
import { createRefreshableAppointmentData, extractReviewAndSignAppointmentData } from '../../utils';
Expand Down
6 changes: 6 additions & 0 deletions apps/intake/src/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@ declare module 'object.hasown' {
// eslint-disable-next-line @typescript-eslint/no-empty-function
export const shim = (): void => {};
}

declare global {
interface Window {
global: any;
}
}
6 changes: 3 additions & 3 deletions apps/intake/src/hooks/useSetLastActiveTime.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect } from 'react';
import { zapehrApi } from '../api';
import { DateTime } from 'luxon';
import { useEffect } from 'react';
import { ZambdaClient } from 'ui-components/lib/hooks/useUCZambdaClient';
import { zapehrApi } from '../api';

// Update last active time for paperwork-in-progress flag every minute
export function useSetLastActiveTime(
Expand All @@ -10,7 +10,7 @@ export function useSetLastActiveTime(
zambdaClient: ZambdaClient | null
): void {
useEffect(() => {
let interval: NodeJS.Timeout;
let interval: ReturnType<typeof setInterval>;
try {
if (zambdaClient && appointmentID && paperworkPage) {
interval = setInterval(async () => {
Expand Down
2 changes: 2 additions & 0 deletions apps/intake/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import App from './App';
import './index.css';
import './lib/i18n';

window.global ||= window; // https://stackoverflow.com/questions/72795666/how-to-fix-vite-build-parser-error-unexpected-token-in-third-party-dependenc

// polyfill for fixing missing hasOwn Object property in some browsers
// https://www.npmjs.com/package/object.hasown
if (!Object.hasOwn) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { FC, useCallback, useEffect, useRef, useState } from 'react';
import { Box, Card, FormControl, IconButton, InputLabel, MenuItem, Select, Typography } from '@mui/material';
import KeyboardVoiceOutlinedIcon from '@mui/icons-material/KeyboardVoiceOutlined';
import GraphicEqIcon from '@mui/icons-material/GraphicEq';
import KeyboardVoiceIcon from '@mui/icons-material/KeyboardVoice';
import ReplayIcon from '@mui/icons-material/Replay';
import PlayArrowIcon from '@mui/icons-material/PlayArrow';
import KeyboardVoiceOutlinedIcon from '@mui/icons-material/KeyboardVoiceOutlined';
import PauseIcon from '@mui/icons-material/Pause';
import PlayArrowIcon from '@mui/icons-material/PlayArrow';
import ReplayIcon from '@mui/icons-material/Replay';
import StopIcon from '@mui/icons-material/Stop';
import GraphicEqIcon from '@mui/icons-material/GraphicEq';
import { Box, Card, FormControl, IconButton, InputLabel, MenuItem, Select, Typography } from '@mui/material';
import { FC, useCallback, useEffect, useRef, useState } from 'react';
import { otherColors } from '../../../IntakeThemeProvider';

type MicrophoneSettingsProps = {
Expand Down Expand Up @@ -77,7 +77,7 @@ export const MicrophoneSettings: FC<MicrophoneSettingsProps> = (props) => {
}, [audioChunks]);

useEffect(() => {
let timeout: NodeJS.Timeout | null = null;
let timeout: ReturnType<typeof setTimeout> | null = null;
if (recordingStatus === 'recording') {
timeout = setTimeout(() => {
stopRecording();
Expand Down
8 changes: 3 additions & 5 deletions apps/intake/src/telemed/pages/VideoChatPage.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
window.global ||= window; // https://stackoverflow.com/questions/72795666/how-to-fix-vite-build-parser-error-unexpected-token-in-third-party-dependenc

import { Container } from '@mui/material';
import {
DeviceLabels,
GlobalStyles,
MeetingProvider,
lightTheme,
useMeetingManager,
useAudioInputs,
useAudioVideo,
useLocalVideo,
useAudioInputs,
useMeetingManager,
useVideoInputs,
} from 'amazon-chime-sdk-component-library-react';
import { MeetingSessionConfiguration } from 'amazon-chime-sdk-js';
Expand All @@ -21,7 +19,7 @@ import { intakeFlowPageRoute } from '../../App';
import { CallSideCard, LoadingSpinner } from '../components';
import { useAppointmentStore } from '../features/appointments';
import { CustomContainer, useIntakeCommonStore } from '../features/common';
import { VideoRoom, useJoinCall, useVideoCallStore, useCallSettingsStore } from '../features/video-call';
import { VideoRoom, useCallSettingsStore, useJoinCall, useVideoCallStore } from '../features/video-call';
import { useZapEHRAPIClient } from '../utils';

const VideoChatPage: FC = () => {
Expand Down
37 changes: 12 additions & 25 deletions package-lock.json

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

4 changes: 3 additions & 1 deletion packages/ehr/zambdas/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
"fast-json-patch": "^3.1.1",
"luxon": "^3.4.3",
"query-string": "^8.1.0",
"short-uuid": "^4.2.2"
"short-uuid": "^4.2.2",
"utils": "*",
"zambda-utils": "*"
},
"devDependencies": {
"@types/luxon": "^3.3.2",
Expand Down
8 changes: 7 additions & 1 deletion packages/ehr/zambdas/scripts/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
Resource,
Substance,
} from 'fhir/r4b';
import { createOystehrClientFromSecrets, Secrets } from 'utils';
import { createOystehrClient, getSecret, Secrets, SecretsKeys } from 'utils';
import { getAuth0Token } from '../src/shared';

export const fhirApiUrlFromAuth0Audience = (auth0Audience: string): string => {
Expand Down Expand Up @@ -209,3 +209,9 @@ export const createOystehrClientFromConfig = async (config: Secrets): Promise<Oy
if (!token) throw new Error('Failed to fetch auth token.');
return createOystehrClientFromSecrets(token, config);
};

function createOystehrClientFromSecrets(token: string, secrets: Secrets | null): Oystehr {
const FHIR_API = getSecret(SecretsKeys.FHIR_API, secrets).replace(/\/r4/g, '');
const PROJECT_API = getSecret(SecretsKeys.PROJECT_API, secrets);
return createOystehrClient(token, FHIR_API, PROJECT_API);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { AssignPractitionerInput } from 'utils';
import { SecretsKeys, getSecret } from '../shared';
import { AssignPractitionerInput, SecretsKeys, getSecret } from 'utils';
import { ZambdaInput } from '../types';

export function validateRequestParameters(input: ZambdaInput): AssignPractitionerInput & { userToken: string } {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,26 @@ import { ChargeItem, DocumentReference, Task } from 'fhir/r4b';
import {
ChangeTelemedAppointmentStatusInput,
ChangeTelemedAppointmentStatusResponse,
SecretsKeys,
TelemedAppointmentStatusEnum,
getQuestionnaireResponseByLinkId,
getSecret,
mapStatusToTelemed,
} from 'utils';

import { getChartData } from '../get-chart-data';
import { SecretsKeys, getSecret, parseCreatedResourcesBundle, saveResourceRequest } from '../shared';
import { parseCreatedResourcesBundle, saveResourceRequest } from '../shared';
import { checkOrCreateM2MClientToken, createOystehrClient } from '../shared/helpers';
import { getVideoResources } from '../shared/pdf/visit-details-pdf/get-video-resources';
import { makeVisitNotePdfDocumentReference } from '../shared/pdf/visit-details-pdf/make-visit-note-pdf-document-reference';
import { composeAndCreateVisitNotePdf } from '../shared/pdf/visit-details-pdf/visit-note-pdf-creation';
import { getMyPractitionerId } from '../shared/practitioners';
import { ZambdaInput } from '../types';
import { createClaim } from './helpers/claim';
import { getInsurancePlan } from './helpers/fhir-utils';
import { changeStatusIfPossible, makeAppointmentChargeItem, makeReceiptPdfDocumentReference } from './helpers/helpers';
import { composeAndCreateReceiptPdf, getPaymentDataRequest, postChargeIssueRequest } from './helpers/payments';
import { validateRequestParameters } from './validateRequestParameters';
import { composeAndCreateVisitNotePdf } from '../shared/pdf/visit-details-pdf/visit-note-pdf-creation';
import { makeVisitNotePdfDocumentReference } from '../shared/pdf/visit-details-pdf/make-visit-note-pdf-document-reference';

// Lifting up value to outside of the handler allows it to stay in memory across warm lambda invocations
let m2mtoken: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ChangeTelemedAppointmentStatusInput, TelemedCallStatusesArr } from 'utils';
import { SecretsKeys, getSecret } from '../shared';
import { getSecret, SecretsKeys } from 'zambda-utils';
import { ZambdaInput } from '../types';

export function validateRequestParameters(
Expand Down
18 changes: 7 additions & 11 deletions packages/ehr/zambdas/src/communication-subscription/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import { Secrets } from 'utils';
import { ZambdaInput } from '../types';
import { BatchInputGetRequest } from '@oystehr/sdk';
import { APIGatewayProxyResult } from 'aws-lambda';
import { Bundle, Communication, Group, Location, Practitioner } from 'fhir/r4b';
import { COMMUNICATION_ISSUE_REPORT_CODE, getFullestAvailableName, getSecret, Secrets, SecretsKeys } from 'utils';
import { getAuth0Token } from '../shared';
import { sendgridEmail, sendSlackNotification, topLevelCatch } from '../shared/errors';
import { createOystehrClient } from '../shared/helpers';
import { topLevelCatch } from '../shared/errors';
import { ZambdaInput } from '../types';
import { bundleResourcesConfig, codingContainedInList, getEmailsFromGroup } from './helpers';
import { validateRequestParameters } from './validateRequestParameters';
import { APIGatewayProxyResult } from 'aws-lambda';
import { Communication, Group, Bundle, Location, Practitioner } from 'fhir/r4b';
import { COMMUNICATION_ISSUE_REPORT_CODE } from 'utils';
import { codingContainedInList, getEmailsFromGroup, bundleResourcesConfig } from './helpers';
import { sendSlackNotification, sendgridEmail } from '../shared/errors';
import { getSecret, SecretsKeys } from '../shared';
import { BatchInputGetRequest } from '@oystehr/sdk';
import { getFullestAvailableName } from 'utils';

export interface CommunicationSubscriptionInput {
communication: Communication;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import { ZambdaInput } from '../types';
import { UpdateMedicationOrderInput } from 'utils';
import { ZambdaInput } from '../types';

export function validateRequestParameters(
input: ZambdaInput
): UpdateMedicationOrderInput & Pick<ZambdaInput, 'secrets'> {
console.group('validateRequestParameters');

// if (getSecret(SecretsKeys.PROJECT_API, input.secrets) === undefined) {
// throw new Error('"PROJECT_API" configuration not provided');
// }

if (!input.body) {
throw new Error('No request body provided');
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ClaimsQueueGetRequest } from 'utils';
import { ClaimsQueueGetRequest, SecretsKeys, getSecret } from 'utils';
import { ZambdaInput } from '../types';
import { SecretsKeys, getSecret } from '../shared';

export function validateRequestParameters(input: ZambdaInput): ClaimsQueueGetRequest & Pick<ZambdaInput, 'secrets'> {
console.group('validateRequestParameters');
Expand Down
4 changes: 3 additions & 1 deletion packages/ehr/zambdas/src/get-conversation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ import { Bundle, Communication, Device, Patient, Practitioner, RelatedPerson } f
import { DateTime } from 'luxon';
import {
Secrets,
SecretsKeys,
chunkThings,
getFirstName,
getFullestAvailableName,
getLastName,
getMessageFromComm,
getMessageHasBeenRead,
getSecret,
} from 'utils';
import { SecretsKeys, getAuth0Token, getSecret } from '../shared';
import { getAuth0Token } from '../shared';
import { topLevelCatch } from '../shared/errors';
import { createOystehrClient } from '../shared/helpers';
import { ZambdaInput } from '../types';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import { ZambdaInput } from '../types';
import { GetMedicationOrdersInput } from 'utils';
import { ZambdaInput } from '../types';

export function validateRequestParameters(input: ZambdaInput): GetMedicationOrdersInput & Pick<ZambdaInput, 'secrets'> {
console.group('validateRequestParameters');

// if (getSecret(SecretsKeys.PROJECT_API, input.secrets) === undefined) {
// throw new Error('"PROJECT_API" configuration not provided');
// }

if (!input.body) {
throw new Error('No request body provided');
}
Expand Down
2 changes: 1 addition & 1 deletion packages/ehr/zambdas/src/get-patient-instructions/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { APIGatewayProxyResult } from 'aws-lambda';
import { SecretsKeys, getSecret } from '../shared';
import { SecretsKeys, getSecret } from 'utils';
import { makeCommunicationDTO } from '../shared/chart-data/chart-data-helpers';
import { checkOrCreateM2MClientToken, createOystehrClient } from '../shared/helpers';
import { ZambdaInput } from '../types';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { APIGatewayProxyResult } from 'aws-lambda';
import { Secrets } from 'utils';
import { getSecret, SecretsKeys } from '../shared';
import { getSecret, Secrets, SecretsKeys } from 'utils';
import { topLevelCatch } from '../shared/errors';
import { checkOrCreateM2MClientToken } from '../shared/helpers';
import { createPresignedUrl } from '../shared/z3Utils';
import { ZambdaInput } from '../types';
import { validateRequestParameters } from './validateRequestParameters';
import { createPresignedUrl } from '../shared/z3Utils';

const logIt = (msg: string): void => {
console.log(`PatientProfilePhoto: ${msg}`);
Expand Down
3 changes: 1 addition & 2 deletions packages/ehr/zambdas/src/icd-search/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { APIGatewayProxyResult } from 'aws-lambda';
import { IcdSearchResponse } from 'utils';
import { SecretsKeys, getSecret } from '../shared';
import { IcdSearchResponse, SecretsKeys, getSecret } from 'utils';
import { ZambdaInput } from '../types';
import { validateRequestParameters } from './validateRequestParameters';

Expand Down
3 changes: 1 addition & 2 deletions packages/ehr/zambdas/src/init-telemed-session/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import Oystehr from '@oystehr/sdk';
import { APIGatewayProxyResult } from 'aws-lambda';
import { Appointment, Encounter } from 'fhir/r4b';
import { InitTelemedSessionResponse, MeetingData, Secrets } from 'utils';
import { SecretsKeys, getSecret } from '../shared';
import { InitTelemedSessionResponse, MeetingData, Secrets, SecretsKeys, getSecret } from 'utils';
import { checkOrCreateM2MClientToken, createOystehrClient, getVideoRoomResourceExtension } from '../shared/helpers';
import { ZambdaInput } from '../types';
import { validateRequestParameters } from './validateRequestParameters';
Expand Down
Loading

0 comments on commit 27c1703

Please sign in to comment.