Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion vim--ai-scribe--react/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ functions/**/*.js
*.ntvs*
*.njsproj
*.sln
*.sw?
*.sw?
*.tsbuildinfo
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ export const SoapSection = ({
fullWidth
className="py-3 w-2/3 self-center"
disabled={!isWriteAvailable}
tooltip={!isWriteAvailable ? "EHR write access missing" : "" }
tooltip={
!isWriteAvailable ? "Can't write to EHR in current state" : ""
}
>
Push to EHR
</Button>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,157 +1,31 @@
import { useUpdateEncounterSubscription } from "@/vimOs/useUpdateEncounter";
import { SoapSection } from "../../molecules/SoapSection";
import type {
SectionTypes,
TranscriptionSegment,
} from "../ai-scribe-demo/transcription.mock";
import { useNoteFormContext } from "@/providers/NoteFormContext";
import { useUpdateEncounter } from "./useSectionWriteAvailability";

interface NotePanelProps {
hoveredSegment: number | null;
transcriptionSegments: TranscriptionSegment[];
renderHighlightedText: (text: string) => JSX.Element;
}

const useUpdateSubjective = () => {
const encounterUpdates = useUpdateEncounterSubscription<"subjective">(
{
subjective: {
generalNotes: true,
chiefComplaintNotes: true,
historyOfPresentIllnessNotes: true,
reviewOfSystemsNotes: true,
},
},
"subjective",
{
subjective: ["chiefComplaintNotes", "reviewOfSystemsNotes"],
}
);

const { updateSubscriptionField, canUpdateSubscriptionParams } =
encounterUpdates;
const { watch } = useNoteFormContext();

const updateSubjectiveNote = () => {
if (canUpdateSubscriptionParams) {
const formValues = watch();

updateSubscriptionField(formValues.subjective);
}
};

return {
canUpdateSubjectiveNote: canUpdateSubscriptionParams,
updateSubjectiveNote,
};
};

const useUpdateObjective = () => {
const encounterUpdates = useUpdateEncounterSubscription<"objective">(
{
objective: {
generalNotes: true,
physicalExamNotes: true,
},
},
"objective",
{
objective: ["generalNotes", "physicalExamNotes"],
}
);

const { updateSubscriptionField, canUpdateSubscriptionParams } =
encounterUpdates;
const { watch } = useNoteFormContext();

const updateObjectiveNote = () => {
if (canUpdateSubscriptionParams) {
const formValues = watch();

updateSubscriptionField(formValues.objective);
}
};

return {
canUpdateObjectiveNote: canUpdateSubscriptionParams,
updateObjectiveNote,
};
};

const useUpdateAssessment = () => {
const encounterUpdates = useUpdateEncounterSubscription<"assessment">(
{
assessment: {
generalNotes: true,
},
},
"assessment",
{
assessment: ["generalNotes"],
}
);

const { updateSubscriptionField, canUpdateSubscriptionParams } =
encounterUpdates;
const { watch } = useNoteFormContext();

const updateAssessmentNote = () => {
if (canUpdateSubscriptionParams) {
const formValues = watch();

updateSubscriptionField(formValues.assessment);
}
};

return {
canUpdateAssessmentNote: canUpdateSubscriptionParams,
updateAssessmentNote,
};
};

const useUpdatePlan = () => {
const encounterUpdates = useUpdateEncounterSubscription<"plan">(
{
plan: {
generalNotes: true,
},
},
"plan",
{
plan: ["generalNotes"],
}
);

const { updateSubscriptionField, canUpdateSubscriptionParams } =
encounterUpdates;
const { watch } = useNoteFormContext();

const updatePlanNote = () => {
if (canUpdateSubscriptionParams) {
const formValues = watch();

updateSubscriptionField(formValues.plan);
}
};

return {
canUpdatePlanNote: canUpdateSubscriptionParams,
updatePlanNote,
};
};

export const NotesSections = ({
hoveredSegment,
transcriptionSegments,
renderHighlightedText,
}: NotePanelProps) => {
const { updateSubjectiveNote, canUpdateSubjectiveNote } =
useUpdateSubjective();
const { updateObjectiveNote, canUpdateObjectiveNote } = useUpdateObjective();
const { updateAssessmentNote, canUpdateAssessmentNote } =
useUpdateAssessment();
const { updatePlanNote, canUpdatePlanNote } = useUpdatePlan();

const {
canUpdateSubjectiveNote,
canUpdateObjectiveNote,
canUpdateAssessmentNote,
canUpdatePlanNote,
updateSubjectiveNote,
updateObjectiveNote,
updateAssessmentNote,
updatePlanNote,
} = useUpdateEncounter();
const isHighlighted = (section: SectionTypes) => {
if (hoveredSegment === null) return false;
return transcriptionSegments[hoveredSegment].affectedSections.includes(
Expand All @@ -167,33 +41,31 @@ export const NotesSections = ({
isHighlighted={isHighlighted("subjective")}
isWriteAvailable={canUpdateSubjectiveNote}
renderHighlightedText={renderHighlightedText}
onPushToEHR={() => {
updateSubjectiveNote();
}}
onPushToEHR={updateSubjectiveNote}
/>
<SoapSection
title="Objective"
fieldName="objective"
isHighlighted={isHighlighted("objective")}
isWriteAvailable={canUpdateObjectiveNote}
renderHighlightedText={renderHighlightedText}
onPushToEHR={() => updateObjectiveNote()}
onPushToEHR={updateObjectiveNote}
/>
<SoapSection
title="Assessment"
fieldName="assessment"
isHighlighted={isHighlighted("assessment")}
isWriteAvailable={canUpdateAssessmentNote}
renderHighlightedText={renderHighlightedText}
onPushToEHR={() => updateAssessmentNote()}
onPushToEHR={updateAssessmentNote}
/>
<SoapSection
title="Plan"
fieldName="plan"
isHighlighted={isHighlighted("plan")}
isWriteAvailable={canUpdatePlanNote}
renderHighlightedText={renderHighlightedText}
onPushToEHR={() => updatePlanNote()}
onPushToEHR={updatePlanNote}
/>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { useState } from "react";
import { useNoteFormContext } from "@/providers/NoteFormContext";
import { useVimOsContext } from "@/providers/VimOSContext";
import { useState } from "react";
import { Button } from "../../atoms/Button";
import { DebugView } from "../../templates/DebugView";
import { MOCK_TRANSCRIPTION } from "../ai-scribe-demo/transcription.mock";
import { NotesSections } from "./NotesSections";
import { useUpdateEncounter } from "./useSectionWriteAvailability";

export const NotesTab = ({
patientName,
Expand All @@ -21,6 +22,15 @@ export const NotesTab = ({
const { watch } = useNoteFormContext();
const currentNote = watch();

const updateEncounterState = useUpdateEncounter();

// Only enable the button if all are true
const canPushAll =
updateEncounterState.canUpdateSubjectiveNote &&
updateEncounterState.canUpdateObjectiveNote &&
updateEncounterState.canUpdateAssessmentNote &&
updateEncounterState.canUpdatePlanNote;

const toggleDebugMode = () => {
setIsDebugMode(!isDebugMode);
vimOS.hub.setDynamicAppSize(isDebugMode ? "CLASSIC" : "LARGE");
Expand All @@ -41,7 +51,9 @@ export const NotesTab = ({
>
Transcription
</Button>
<Button onClick={handleFullEhrUpdate}>Push all to EHR</Button>
<Button onClick={handleFullEhrUpdate} disabled={!canPushAll}>
Push all to EHR
</Button>
</div>
<div className="text-sm text-gray-500">Note saved automatically</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import { useUpdateEncounterSubscription } from "@/vimOs/useUpdateEncounter";
import { useNoteFormContext } from "@/providers/NoteFormContext";

export const useUpdateSubjective = () => {
const { updateSubscriptionField, canUpdateSubscriptionParams } =
useUpdateEncounterSubscription("subjective", [
"chiefComplaintNotes",
"reviewOfSystemsNotes",
]);

const { watch } = useNoteFormContext();

const updateSubjectiveNote = () => {
if (canUpdateSubscriptionParams) {
const formValues = watch();
updateSubscriptionField(formValues.subjective);
}
};

return {
canUpdateSubjectiveNote: canUpdateSubscriptionParams,
updateSubjectiveNote,
};
};

export const useUpdateObjective = () => {
const encounterUpdates = useUpdateEncounterSubscription("objective", [
"generalNotes",
"physicalExamNotes",
]);

const { updateSubscriptionField, canUpdateSubscriptionParams } =
encounterUpdates;
const { watch } = useNoteFormContext();

const updateObjectiveNote = () => {
if (canUpdateSubscriptionParams) {
const formValues = watch();
updateSubscriptionField(formValues.objective);
}
};

return {
canUpdateObjectiveNote: canUpdateSubscriptionParams,
updateObjectiveNote,
};
};

export const useUpdateAssessment = () => {
const { updateSubscriptionField, canUpdateSubscriptionParams } =
useUpdateEncounterSubscription("assessment", ["generalNotes"]);

const { watch } = useNoteFormContext();

const updateAssessmentNote = () => {
if (canUpdateSubscriptionParams) {
const formValues = watch();
updateSubscriptionField(formValues.assessment);
}
};

return {
canUpdateAssessmentNote: canUpdateSubscriptionParams,
updateAssessmentNote,
};
};

export const useUpdatePlan = () => {
const { updateSubscriptionField, canUpdateSubscriptionParams } =
useUpdateEncounterSubscription("plan", ["generalNotes"]);

const { watch } = useNoteFormContext();

const updatePlanNote = () => {
if (canUpdateSubscriptionParams) {
const formValues = watch();
updateSubscriptionField(formValues.plan);
}
};

return {
canUpdatePlanNote: canUpdateSubscriptionParams,
updatePlanNote,
};
};

export const useUpdateEncounter = () => {
const { canUpdateSubjectiveNote, updateSubjectiveNote } =
useUpdateSubjective();
const { canUpdateObjectiveNote, updateObjectiveNote } = useUpdateObjective();
const { canUpdateAssessmentNote, updateAssessmentNote } =
useUpdateAssessment();
const { canUpdatePlanNote, updatePlanNote } = useUpdatePlan();
return {
canUpdateSubjectiveNote,
updateSubjectiveNote,
canUpdateObjectiveNote,
updateObjectiveNote,
canUpdateAssessmentNote,
updateAssessmentNote,
canUpdatePlanNote,
updatePlanNote,
};
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { TranscriptionSegment } from "../organisms/ai-scribe-demo/transcription.mock";
import { TranscriptionPanel } from "../organisms/transcription-panel/TranscriptionPanel";
import { NotesSections } from "../organisms/notes-tab/NotesSections";
import type { TranscriptionSegment } from "../organisms/ai-scribe-demo/transcription.mock";

interface DebugViewProps {
transcriptionSegments: TranscriptionSegment[];
Expand Down
Loading