Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add initial erx modifications without breaking #349

Merged
merged 17 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from 14 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
5 changes: 5 additions & 0 deletions packages/ehr-utils/lib/fhir/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@ export const FHIR_EXTENSION = {
url: `${PRIVATE_EXTENSION_BASE_URL}/date-of-birth-not-confirmed`,
},
},
Patient: {
weight: {
url: `${PRIVATE_EXTENSION_BASE_URL}/weight`,
},
},
};
54 changes: 53 additions & 1 deletion packages/ehr-utils/lib/fhir/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BatchInputRequest, FhirClient } from '@zapehr/sdk';
import { Operation } from 'fast-json-patch';
import { Coding, Patient, Person, Practitioner, RelatedPerson, Resource, Appointment } from 'fhir/r4';
import { Coding, Patient, Person, Practitioner, RelatedPerson, Resource, Appointment, Extension } from 'fhir/r4';
import { FHIR_EXTENSION } from './constants';
export * from './chat';

Expand Down Expand Up @@ -70,6 +70,58 @@ export const getPatchOperationForNewMetaTag = (resource: Resource, newTag: Codin
}
};

export const getPatchOperationToUpdateExtension = (
resource: { extension?: Extension[] },
newExtension: {
url: Extension['url'];
valueString?: Extension['valueString'];
valueBoolean?: Extension['valueBoolean'];
},
): Operation | undefined => {
if (!resource.extension) {
return {
op: 'add',
path: '/extension',
value: [newExtension],
};
}

const extension = resource.extension;
let requiresUpdate = false;

if (extension.length > 0) {
const existingExtIndex = extension.findIndex((ext) => ext.url === newExtension.url);
// check if formUser exists and needs to be updated and if so, update
if (
existingExtIndex >= 0 &&
(extension[existingExtIndex].valueString !== newExtension.valueString ||
extension[existingExtIndex].valueBoolean !== newExtension.valueBoolean)
) {
extension[existingExtIndex] = newExtension;
requiresUpdate = true;
} else if (existingExtIndex < 0) {
// if form user does not exist within the extension
// push to patientExtension array
extension.push(newExtension);
requiresUpdate = true;
}
} else {
// since no extensions exist, it must be added via patch operations
extension.push(newExtension);
requiresUpdate = true;
}

if (requiresUpdate) {
return {
op: 'replace',
path: '/extension',
value: extension,
};
}

return undefined;
};

export interface GetPatchBinaryInput {
resourceId: string;
resourceType: string;
Expand Down
7 changes: 6 additions & 1 deletion packages/ehr-utils/lib/helpers/practitioner.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Encounter, Practitioner } from 'fhir/r4';
import { Encounter, Identifier, Practitioner } from 'fhir/r4';
import {
FHIR_IDENTIFIER_NPI,
PRACTITIONER_QUALIFICATION_CODE_SYSTEM,
PRACTITIONER_QUALIFICATION_EXTENSION_URL,
PRACTITIONER_QUALIFICATION_STATE_SYSTEM,
Expand Down Expand Up @@ -54,3 +55,7 @@ export const checkIsEncounterForPractitioner = (encounter: Encounter, practition

return !!practitioner && !!encounterPractitioner && practitionerId === encounterPractitionerId;
};

export const getPractitionerNPIIdentitifier = (practitioner: Practitioner | undefined): Identifier | undefined => {
return practitioner?.identifier?.find((existIdentifier) => existIdentifier.system === FHIR_IDENTIFIER_NPI);
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface ChartDataFields {
ros?: FreeTextNoteDTO;
conditions?: MedicalConditionDTO[];
medications?: MedicationDTO[];
prescribedMedications?: PrescribedMedicationDTO[];
allergies?: AllergyDTO[];
procedures?: ProcedureDTO[];
proceduresNote?: FreeTextNoteDTO;
Expand Down Expand Up @@ -41,6 +42,11 @@ export interface MedicationDTO extends SaveableDTO {
id?: string;
}

export interface PrescribedMedicationDTO extends SaveableDTO {
name?: string;
instructions?: string;
}

export interface ProcedureDTO extends SaveableDTO {
name?: string;
}
Expand Down
1 change: 1 addition & 0 deletions packages/ehr-utils/lib/types/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ export * from './change-telemed-appointment-status';
export * from './chart-data';
export * from './get-telemed-appointments';
export * from './icd-search';
export * from './sync-user';
export * from './init-telemed-session';
export * from './patient-instructions';
1 change: 1 addition & 0 deletions packages/ehr-utils/lib/types/api/sync-user/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './sync-user.types';
4 changes: 4 additions & 0 deletions packages/ehr-utils/lib/types/api/sync-user/sync-user.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface SyncUserResponse {
message: string;
updated: boolean;
}
2 changes: 1 addition & 1 deletion packages/ehr-utils/lib/types/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const TELEMED_VIDEO_ROOM_CODE = 'chime-video-meetings';
export const PHOTON_PATIENT_IDENTIFIER_SYSTEM = 'http://api.zapehr.com/photon-patient-id';
export const ERX_PATIENT_IDENTIFIER_SYSTEM = 'http://api.zapehr.com/photon-patient-id';

export const PRACTITIONER_QUALIFICATION_EXTENSION_URL =
'http://hl7.org/fhir/us/davinci-pdex-plan-net/StructureDefinition/practitioner-qualification';
Expand Down
3 changes: 3 additions & 0 deletions packages/ehr-utils/lib/types/practitioner.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,3 +281,6 @@ export interface PractitionerLicense {
code: PractitionerQualificationCode;
active: boolean;
}

export const ERX_PRESCRIBER_SYSTEM_URL = 'http://api.zapehr.com/photon-prescriber-id';
export const ERX_PRACTITIONER_ENROLLED = 'http://api.zapehr.com/photon-practitioner-enrolled';
5 changes: 4 additions & 1 deletion packages/telemed-ehr/app/env/.env.local-template
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ VITE_APP_GET_APPOINTMENTS_ZAMBDA_ID=get-appointments
VITE_APP_CREATE_APPOINTMENT_ZAMBDA_ID=create-appointment
VITE_APP_UPDATE_USER_ZAMBDA_ID=update-user
VITE_APP_GET_USER_ZAMBDA_ID=get-user
VITE_APP_SYNC_USER_ZAMBDA_ID=sync-user
VITE_APP_DEACTIVATE_USER_ZAMBDA_ID=deactivate-user
VITE_APP_GET_EMPLOYEES_ZAMBDA_ID=get-employees
VITE_APP_GET_TELEMED_APPOINTMENTS_ZAMBDA_ID=get-telemed-appointments
Expand All @@ -28,4 +29,6 @@ VITE_APP_CHANGE_TELEMED_APPOINTMENT_STATUS_ZAMBDA_ID=change-telemed-appointment-
VITE_APP_DELETE_CHART_DATA_ZAMBDA_ID=delete-chart-data
VITE_APP_GET_TOKEN_FOR_CONVERSATION_ZAMBDA_ID=get-token-for-conversation
VITE_APP_CANCEL_TELEMED_APPOINTMENT_ZAMBDA_ID=cancel-appointment
VITE_APP_QRS_URL=http://localhost:3002
VITE_APP_QRS_URL=http://localhost:3002
VITE_APP_PHOTON_ORG_ID=
VITE_APP_PHOTON_CLIENT_ID=
4 changes: 2 additions & 2 deletions packages/telemed-ehr/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="./public/favicon.ico" />
<link rel="icon" href="./public/ottehr-icon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="Web site created using create-react-app" />
<link rel="apple-touch-icon" href="./public/logo192.png" />
<link rel="apple-touch-icon" href="./public/ottehr-icon-256.png" />
<link rel="manifest" href="./public/manifest.json" />
<title>Ottehr EHR</title>
</head>
Expand Down
3 changes: 2 additions & 1 deletion packages/telemed-ehr/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@
"@mui/x-data-grid-pro": "^6.3.0",
"@mui/x-date-pickers": "^5.0.20",
"@mui/x-date-pickers-pro": "^5.0.20",
"@photonhealth/elements": "^0.9.1-rc.1",
"@photonhealth/elements": "^0.12.2",
"@twilio/conversations": "^2.4.1",
"@zapehr/sdk": "1.0.15",
"amazon-chime-sdk-component-library-react": "^3.7.0",
"amazon-chime-sdk-js": "^3.20.0",
"chart.js": "^4.4.1",
"notistack": "^3.0.1",
"fast-json-patch": "^3.1.1",
"react-chartjs-2": "^5.2.0",
"react-draggable": "^4.4.6",
Expand Down
4 changes: 2 additions & 2 deletions packages/telemed-ehr/app/public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"name": "Ottehr EHR",
"icons": [
{
"src": "favicon.ico",
"sizes": "32x32 16x16",
"src": "ottehr-icon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
}
],
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/telemed-ehr/app/public/ottehr-icon.ico
Binary file not shown.
18 changes: 8 additions & 10 deletions packages/telemed-ehr/app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { LoadingScreen } from './components/LoadingScreen';
import Navbar from './components/navigation/Navbar';
import { ProtectedRoute } from './components/routing/ProtectedRoute';
import { useApiClients } from './hooks/useAppClients';
import useOttehrUser from './hooks/useOttehrUser';
import useOttehrUser, { useProviderERXStateStore } from './hooks/useOttehrUser';
import AddPatient from './pages/AddPatient';
import AppointmentsPage from './pages/Appointments';
import EditEmployeePage from './pages/EditEmployee';
Expand All @@ -22,16 +22,10 @@ import { TelemedAdminPage } from './pages/TelemedAdminPage';
import { useNavStore } from './state/nav.store';
import EditInsurance from './telemed/features/telemed-admin/EditInsurance';
import EditStatePage from './telemed/features/telemed-admin/EditState';
import { isLocalOrDevOrTestingOrTrainingEnv } from './telemed/utils/env.helper';
import { RoleType } from './types/types';
import { AppointmentPage } from './pages/AppointmentPage';
import AddSchedulePage from './pages/AddSchedulePage';

const enablePhoton = false && isLocalOrDevOrTestingOrTrainingEnv;

if (enablePhoton) {
import('@photonhealth/elements').catch(console.log);
}
import('@photonhealth/elements').catch(console.log);
GiladSchneider marked this conversation as resolved.
Show resolved Hide resolved

const TelemedTrackingBoardPageLazy = lazy(async () => {
const TrackingBoardPage = await import('./telemed/pages/TrackingBoardPage');
Expand All @@ -53,8 +47,11 @@ if (MUI_X_LICENSE_KEY != null) {
function App(): ReactElement {
useApiClients();
const currentUser = useOttehrUser();
// console.log(currentUser);
rzinger marked this conversation as resolved.
Show resolved Hide resolved
const currentTab = useNavStore((state: any) => state.currentTab) || 'In Person';

const wasEnrolledInERX = useProviderERXStateStore((state) => state.wasEnrolledInERX);

const roleUnknown =
!currentUser || !currentUser.hasRole([RoleType.Administrator, RoleType.Staff, RoleType.Manager, RoleType.Provider]);

Expand All @@ -71,11 +68,12 @@ function App(): ReactElement {
<ProtectedRoute
showWhenAuthenticated={
<>
{currentUser?.hasRole([RoleType.Provider]) && enablePhoton ? (
{(currentUser?.hasRole([RoleType.Provider]) && currentUser.isPractitionerEnrolledInERX) ||
wasEnrolledInERX ? (
<photon-client
id={import.meta.env.VITE_APP_PHOTON_CLIENT_ID}
org={import.meta.env.VITE_APP_PHOTON_ORG_ID}
dev-mode="true"
dev-mode={import.meta.env.MODE === 'production' ? 'false' : 'true'}
auto-login="true"
redirect-uri={window.location.origin}
>
Expand Down
Loading
Loading