Retrying a kept recording transcribed it and put the text on the clipboard, leaving you to find the right tab and paste. The app already had the answer: the module was recorded with the audio. Retry now opens that tab and puts the text in its transcript box. Two things had to be true first. The module was not actually being recorded. transcribeAudio never sent one, so the server stored its default for every upload — all 28 rows in audio_backups said "recording", and a retry had nowhere to send anything back to. Each module's call now tags its own upload. And the names disagreed. The recorders tagged 'encounter', 'soap', 'dictation' while the recording-started events said 'enc', 'sick', 'dict'. One table now holds the mapping and resolves the aliases, so the recorder that tags the upload, the backup row that labels it and the retry that delivers it cannot drift apart again. Existing text is appended to, never replaced: a retry usually recovers something on top of a live transcript, and overwriting would lose the words the browser did hear. The box only exists once its tab's markup has been fetched, so delivery polls briefly rather than guessing a delay, and falls back to the clipboard if the tab never opens. An empty result says so rather than claiming success. Backup rows now name their source and the button reads "Retry into SOAP Note" instead of "Retry". Verified in a browser: enc resolves to encounter, delivery switched tabs and produced 'existing live transcript\n\nRECOVERED TEXT'. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Dv6sqaY6Vq3ChZHMem3cnU
58 lines
2.4 KiB
JavaScript
58 lines
2.4 KiB
JavaScript
// ============================================================
|
|
// RECORDING MODULES
|
|
// Where a recording came from, and where its transcript belongs.
|
|
//
|
|
// Every recording is kept for 24 hours, so a transcription that fails or comes
|
|
// back empty can be retried later. Retrying used to hand you the text on the
|
|
// clipboard and leave you to find the right tab and paste it — which is work
|
|
// the app already has the answer to: the module was recorded with the audio.
|
|
//
|
|
// One table, because three things have to agree about a module: the recorder
|
|
// that tags the upload, the backup list that labels it, and the retry that
|
|
// delivers the transcript. They disagreed before — recorders tagged
|
|
// 'encounter' while the recording-started events said 'enc' — so this also
|
|
// normalises the aliases rather than leaving each caller to guess.
|
|
// ============================================================
|
|
|
|
(function () {
|
|
var MODULES = {
|
|
encounter: { tab: 'encounter', target: 'enc-transcript', label: 'Encounter HPI' },
|
|
dictation: { tab: 'dictation', target: 'dict-transcript', label: 'Dictation HPI' },
|
|
soap: { tab: 'soap', target: 'soap-transcript', label: 'SOAP Note' },
|
|
sick: { tab: 'sickvisit', target: 'sick-transcript', label: 'Sick Visit' },
|
|
wellvisit: { tab: 'wellvisit', target: 'wv-transcript', label: 'Well Visit' },
|
|
ed: { tab: 'ed', target: 'ed-transcript', label: 'ED Encounter' }
|
|
};
|
|
|
|
// The short names the recording-started/stopped events have always used, and
|
|
// the plain ones a person might see in a backup row.
|
|
var ALIASES = {
|
|
enc: 'encounter', dict: 'dictation', sickvisit: 'sick', 'sick-visit': 'sick',
|
|
wv: 'wellvisit', 'well-visit': 'wellvisit', 'ed-encounter': 'ed'
|
|
};
|
|
|
|
function normalize(module) {
|
|
var name = String(module == null ? '' : module).trim().toLowerCase();
|
|
return ALIASES[name] || name;
|
|
}
|
|
|
|
function lookup(module) {
|
|
return MODULES[normalize(module)] || null;
|
|
}
|
|
|
|
// A label for a backup row. Unknown modules keep their raw name rather than
|
|
// being hidden, because an unrecognised one is worth seeing.
|
|
function label(module) {
|
|
var entry = lookup(module);
|
|
if (entry) return entry.label;
|
|
var name = normalize(module);
|
|
return name && name !== 'recording' ? name : 'Recording';
|
|
}
|
|
|
|
window.RecordingModules = {
|
|
normalize: normalize,
|
|
lookup: lookup,
|
|
label: label,
|
|
known: function () { return Object.keys(MODULES); }
|
|
};
|
|
}());
|