Skip to content

Commit

Permalink
WIP... ok workflow complete... loading app, recording UX,transcripti…
Browse files Browse the repository at this point in the history
…on... and stubbed eval return for now, will try real eval next
  • Loading branch information
irvins committed Dec 26, 2024
1 parent e4d5850 commit eb8f728
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 112 deletions.
67 changes: 0 additions & 67 deletions MVP/dist/assets/index-BzFOPH08.js

This file was deleted.

67 changes: 67 additions & 0 deletions MVP/dist/assets/index-Cf4utoDq.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions MVP/dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css"
rel="stylesheet"
>
<script type="module" crossorigin src="/assets/index-BzFOPH08.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-CQjQgnaq.css">
<script type="module" crossorigin src="/assets/index-Cf4utoDq.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-upKjlbhk.css">
</head>
<body>
<div id="clinicalcoach_ui_container"></div>
Expand Down
2 changes: 1 addition & 1 deletion MVP/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function App() {
<Router>
<div id="clinicalcoachmvp_container">
<Routes>
<Route path="/" element={<Report />} />
<Route path="/" element={<Title />} />
<Route path="/home" element={<Home />} />
<Route path="/recording" element={<Recording />} />
<Route path="/thinking-habits" element={<THM />} />
Expand Down
15 changes: 3 additions & 12 deletions MVP/src/components/VoiceRecorder.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ const VoiceRecorder = ({ navigate }) => {
const canvasRef = useRef(null); // To draw the waveform
const animationFrameRef = useRef(null); // To manage the animation frame
const [isUploading, setIsUploading] = useState(false); // Tracks the uploading state
const [sessionTranscriptions, setSessionTranscriptions] = useState([]); // Stores transcriptions in memory
const { showConfirmModal } = useConfirmModal();
const { selectedStudent, updateTranscription } = useStudents();
const { selectedStudent, updateStudent } = useStudents();

// Function to clear the timer and reset elapsed time
const clearTimer = () => {
Expand Down Expand Up @@ -226,14 +225,8 @@ const VoiceRecorder = ({ navigate }) => {
if (transcription) {
console.log("[SUCCESS TRANSCRIPTION RECEIVED]:", transcription);

// Update transcription in Students context
updateTranscription(selectedStudent.id, transcription);

// Add transcription to session or UI
setSessionTranscriptions((prev) => [
...prev,
{ id: Date.now(), transcription },
]);
// Update transcription in Students context using updateStudent
updateStudent(selectedStudent.id, { transcription: transcription });

// Show confirmation modal and redirect
const postSubmitConfirm = await showConfirmModal({
Expand All @@ -253,13 +246,11 @@ const VoiceRecorder = ({ navigate }) => {
console.error("[ERROR HANDLING TRANSCRIPTION RESPONSE]:", error);
}
});

} catch (error) {
console.error("Error submitting recording:", error);
}
};


const startRecording = async () => {
try {
console.log('Starting recording process...');
Expand Down
31 changes: 21 additions & 10 deletions MVP/src/contexts/Students.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const StudentsProvider = ({ children }) => {
name: "Dennis Johnson",
reflections: {},
profilePicture: null,
transcription: "The patient is a 45-year-old male with a history of Type 2 diabetes and hypertension, presenting with worsening left-sided ear pain and discharge over the past two weeks...",
transcription: "",
description: '8-minute case presentation patient with mastoiditis and complications.',
time: '12:00 PM',
thm_summary: "No summary available.",
Expand All @@ -113,22 +113,33 @@ export const StudentsProvider = ({ children }) => {
};

const updateStudent = (studentId, updatedData) => {
setStudents((prevStudents) =>
prevStudents.map((student) =>
if (!studentId || !updatedData || typeof updatedData !== "object") {
console.error("Invalid arguments passed to updateStudent:", { studentId, updatedData });
return;
}

console.log("Updating student:", { studentId, updatedData });

// Update the main `students` array
setStudents((prevStudents) => {
const updatedStudents = prevStudents.map((student) =>
student.id === studentId
? { ...student, ...updatedData }
? { ...student, ...updatedData } // Merge updates for the matched student
: student
)
);
);
console.log("Updated students array:", updatedStudents);
return updatedStudents;
});

// Update the currently `selectedStudent` if it matches the updated student
if (selectedStudent?.id === studentId) {
setSelectedStudent((prevSelected) => ({
...prevSelected,
...updatedData,
}));
const updatedSelected = { ...selectedStudent, ...updatedData };
console.log("Updated selectedStudent:", updatedSelected);
setSelectedStudent(updatedSelected);
}
};


useEffect(() => {
if (selectedStudent) {
const updatedStudent = students.find((s) => s.id === selectedStudent.id);
Expand Down
10 changes: 5 additions & 5 deletions MVP/src/views/Report.css
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ main#report {
}

.expandable-button {
padding: 0.8rem;
font-size: 0.9rem;
padding: .3rem .5rem;
font-size: 0.8rem;
text-align: left;
border: 1px solid #ccc;
border-bottom: 5px solid #666; /* Add thick bottom border */
Expand Down Expand Up @@ -202,7 +202,7 @@ main#report {
color: white;
font-weight: bold;
text-transform: uppercase;
min-width:70px;
min-width:80px;
text-align: center;
border-bottom: 5px solid #3c8c3c; /* Thick border under the pill */
}
Expand Down Expand Up @@ -301,7 +301,7 @@ main#report {
}

.action-left {
font-size: 0.9rem;
font-size: 0.7rem;
font-weight: bold;
text-transform: uppercase;
color: #333;
Expand Down Expand Up @@ -337,7 +337,7 @@ main#report {
background-color: #d9534f;
color: white;
border: none;
font-size: 0.9rem;
font-size: 0.8rem;
text-transform: uppercase;
font-weight: bold;
padding: 0.5rem 1rem;
Expand Down
31 changes: 17 additions & 14 deletions MVP/src/views/Report.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,8 @@ import Header from '../components/Header';
import Footer from '../components/Footer';
import './Report.css';

const getRandomColor = () => {
const colors = ['green', 'yellow', 'red'];
return colors[Math.floor(Math.random() * colors.length)];
};

export default function Report() {
const { students, selectStudent, selectedStudent, updateStudent } = useStudents();
const {students, selectStudent, selectedStudent, updateStudent } = useStudents();
const [expandedAnalysis, setExpandedAnalysis] = useState(false);

useEffect(() => {
Expand All @@ -30,6 +25,11 @@ export default function Report() {

// HandleAIAnalysis updates the correct student and persists changes
const handleAIAnalysis = () => {
if (!selectedStudent?.transcription) {
console.warn("No transcription available for analysis.");
return;
}

const payload = {
transcription: selectedStudent.transcription,
};
Expand Down Expand Up @@ -57,7 +57,7 @@ export default function Report() {
return { category, description };
});

// ** Compute habitsData first **
// Compute habitsData
const habitsData = final.thinkingHabitsScore.split('|').map((habitScore) => {
const [label, colorEmoji] = habitScore.split(' ');
const colorMap = { '🔴': 'red', '🟡': 'yellow', '🟢': 'green' };
Expand Down Expand Up @@ -86,19 +86,22 @@ export default function Report() {
isNew: true,
};

// Build the updated student object
const updatedStudent = {
...selectedStudent,
// Use `updateStudent` to update the context
updateStudent(selectedStudent.id, {
thm_summary,
strengths,
habitsData,
promptsData,
notifications: [...selectedStudent.notifications, notification],
};

updateStudent(updatedStudent); // Update the student in the context
});

console.log("Updated Student Data:", updatedStudent);
console.log("Updated Student Data:", {
thm_summary,
strengths,
habitsData,
promptsData,
notifications: [...selectedStudent.notifications, notification],
});
},
(error) => {
console.error("AI Analysis Error:", error);
Expand Down

0 comments on commit eb8f728

Please sign in to comment.