{"id":26559,"date":"2024-04-19T21:17:05","date_gmt":"2024-04-19T21:17:05","guid":{"rendered":"https:\/\/myairclinic.com\/app\/?page_id=26559"},"modified":"2024-07-21T20:37:22","modified_gmt":"2024-07-21T20:37:22","slug":"osce-simulator","status":"publish","type":"page","link":"https:\/\/myairclinic.com\/app\/osce-simulator\/","title":{"rendered":"OSCE Simulator"},"content":{"rendered":"<div class='mwai-chatbot-container' data-params='{&quot;aiName&quot;:&quot;&quot;,&quot;userName&quot;:&quot;&quot;,&quot;guestName&quot;:&quot;Guest:&quot;,&quot;aiAvatar&quot;:1,&quot;userAvatar&quot;:1,&quot;textSend&quot;:&quot;Send\\u25b6\\ufe0f&quot;,&quot;textClear&quot;:&quot;Reset&quot;,&quot;multiUpload&quot;:&quot;&quot;,&quot;mode&quot;:&quot;chat&quot;,&quot;textInputPlaceholder&quot;:&quot;Type your message...&quot;,&quot;textInputMaxLength&quot;:5000,&quot;textCompliance&quot;:&quot;Remember this is AI. there may be some reasonable errors.&quot;,&quot;startSentence&quot;:&quot;Hi! I&#039;m the OSCE Simulator. Say \\&quot;hello\\&quot; let&#039;s start a case scenario.&quot;,&quot;localMemory&quot;:1,&quot;themeId&quot;:&quot;messages&quot;,&quot;window&quot;:&quot;&quot;,&quot;icon&quot;:&quot;chat-traditional-2.svg&quot;,&quot;iconText&quot;:&quot;&quot;,&quot;iconTextDelay&quot;:1,&quot;iconAlt&quot;:&quot;AI Chatbot Avatar&quot;,&quot;iconPosition&quot;:&quot;bottom-right&quot;,&quot;iconBubble&quot;:&quot;&quot;,&quot;fullscreen&quot;:&quot;&quot;,&quot;copyButton&quot;:&quot;&quot;,&quot;headerSubtitle&quot;:&quot;Discuss with&quot;}' data-system='{&quot;botId&quot;:&quot;chatbot-p9a1ar&quot;,&quot;customId&quot;:&quot;&quot;,&quot;userData&quot;:null,&quot;sessionId&quot;:&quot;69ea3d7c7f68a&quot;,&quot;restNonce&quot;:null,&quot;contextId&quot;:26559,&quot;pluginUrl&quot;:&quot;https:\\\/\\\/myairclinic.com\\\/app\\\/wp-content\\\/plugins\\\/ai-engine-pro\\\/&quot;,&quot;restUrl&quot;:&quot;https:\\\/\\\/myairclinic.com\\\/app\\\/wp-json&quot;,&quot;stream&quot;:true,&quot;debugMode&quot;:false,&quot;eventLogs&quot;:false,&quot;speech_recognition&quot;:true,&quot;speech_synthesis&quot;:false,&quot;typewriter&quot;:false,&quot;virtual_keyboard_fix&quot;:true,&quot;actions&quot;:[],&quot;blocks&quot;:[],&quot;shortcuts&quot;:[]}' data-theme='{&quot;type&quot;:&quot;internal&quot;,&quot;name&quot;:&quot;Messages&quot;,&quot;themeId&quot;:&quot;messages&quot;,&quot;settings&quot;:{&quot;backgroundHeaderColor&quot;:&quot;#0084ff&quot;,&quot;backgroundAiColor&quot;:&quot;#fccb00&quot;,&quot;backgroundUserColor&quot;:&quot;#3366cc&quot;,&quot;iconTextBackgroundColor&quot;:&quot;#3366cc&quot;,&quot;fontSize&quot;:&quot;18px&quot;,&quot;spacing&quot;:&quot;12px&quot;},&quot;style&quot;:&quot;&quot;}'><\/div>\n\n\n<script>document.addEventListener('DOMContentLoaded', () => {\r\nlet currentUtterance = null;\r\nlet fullText = '';\r\nlet lastSpokenIndex = 0; \/\/ Track the last spoken index\r\n\r\n\/\/ Function to speak text using the Speech Synthesis API\r\nfunction speakText(text) {\r\nif ('speechSynthesis' in window) {\r\nif (currentUtterance) {\r\nwindow.speechSynthesis.cancel(); \/\/ Cancel any ongoing speech\r\n}\r\n\/\/ Clean the text to remove full stops and add pauses for new paragraphs, bullet points, and colons\r\nconst cleanedText = text\r\n.replace(\/\\.\/g, '. ') \/\/ Remove full stops\r\n.replace(\/\\n\\n\/g, '<break time=\"1000ms\"\/> ') \/\/ Add pause for MD new paragraphs\r\n.replace(\/^\\s*([-*])\\s*\/gm, '. ') \/\/ Add pause for MD bullet points\r\n.replace(\/:\/g, '. ') \/\/ Add pause for colons\r\n.replace(\/Dr\/g, 'Doctor') \/\/ Add Doctor\r\n.replace(\/IV\/g, 'I,V') \/\/ Add IV\r\n.replace(\/IM\/g, 'I,M') \/\/ Add IM\r\n.replace(\/OSCE\/g, 'os,Ki') \/\/ Add OSCE \r\n.replace(\/OBGYN\/g, 'O,B,Guy,Na') \/\/ Add OB\r\n.replace(\/!\/g, '. ') \/\/ Add pause for exclamation\r\n.replace(\/\\+\/g, '. ') \/\/ Add pause for plus\r\n.replace(\/\\b\\d{5,}\\b\/g, match => match.split('').join(' ')) \/\/ Speak numbers with more than two digits as individual digits with spaces\r\n.replace(\/\\b\\d\\b\/g, match => match.split('').join(' ')); \/\/ Speak single digits as individual digits with spaces\r\n\r\n\/\/ Extract the new portion of the text to speak\r\nconst newText = cleanedText.substring(lastSpokenIndex);\r\n\r\n\/\/ Create a new utterance for the new text portion\r\ncurrentUtterance = new SpeechSynthesisUtterance(newText);\r\ncurrentUtterance.onend = () => {\r\n\/\/ Update the last spoken index when the utterance ends\r\nlastSpokenIndex = text.length;\r\n\/\/ Turn on the microphone once speech synthesis is done\r\nactivateMicrophone();\r\n};\r\nwindow.speechSynthesis.speak(currentUtterance);\r\n} else {\r\nconsole.error(\"Speech Synthesis API is not supported in this browser.\");\r\n}\r\n}\r\n\r\n\/\/ Function to activate the microphone\r\nfunction activateMicrophone() {\r\nconst microphone = document.querySelector(\"#mwai-chatbot-default > div.mwai-content > div.mwai-input > div > div\");\r\nif (microphone) {\r\nmicrophone.click(); \/\/ Simulate a click event to activate the microphone\r\n} else {\r\nconsole.error(\"Microphone element not found.\");\r\n}\r\n}\r\n\r\n\/\/ Function to handle streaming messages\r\nfunction handleStreamingMessage(node) {\r\nif (node) {\r\n\/\/ Update the full text with the new content\r\nfullText = node.textContent.trim();\r\n\r\n\/\/ Start speaking as soon as the text is non-empty\r\nif (fullText.length > 0) {\r\nspeakText(fullText);\r\n}\r\n\r\n\/\/ Continuously update the speech as the text changes\r\nconst observer = new MutationObserver(() => {\r\nconst newText = node.textContent.trim();\r\nif (newText.length > fullText.length) {\r\nfullText = newText;\r\nspeakText(newText);\r\n}\r\n});\r\n\r\nobserver.observe(node, { characterData: true, subtree: true, childList: true });\r\n}\r\n}\r\n\r\n\/\/ MutationObserver callback to monitor for new messages\r\nfunction observeMessages(mutationsList) {\r\nfor (const mutation of mutationsList) {\r\nif (mutation.type === 'childList') {\r\nmutation.addedNodes.forEach(node => {\r\nif (node.classList && node.classList.contains('mwai-ai')) {\r\nhandleStreamingMessage(node);\r\n}\r\n});\r\n}\r\n}\r\n}\r\n\r\n\/\/ Set up the MutationObserver to watch for changes in the chat container\r\nconst chatContainer = document.querySelector('#mwai-chatbot-chatbot-p9a1ar');\r\nif (chatContainer) {\r\n    const observer = new MutationObserver(observeMessages);\r\n    observer.observe(chatContainer, { childList: true, subtree: true });\r\n} else {\r\n    console.error(\"ChatOSCE container not found.\");\r\n}\r\n});<\/script>\n\n\n<script>document.addEventListener('DOMContentLoaded', () => {\r\n  \/\/ Specify the link where you want to hide the element\r\n  var targetLink = \"https:\/\/myairclinic.com\/app\/osce-simulator\/\"; \/\/ Replace with your specific page link\r\n\r\n  \/\/ Log the current URL to verify it\r\n  console.log(\"Current URL: \" + window.location.href);\r\n\r\n  \/\/ Create a function to normalize the URL for comparison\r\n  function normalizeUrl(url) {\r\n    return url.split('?')[0].split('#')[0];\r\n  }\r\n\r\n  \/\/ Check if the current URL matches the target link\r\n  if (normalizeUrl(window.location.href) === normalizeUrl(targetLink)) {\r\n    \/\/ Hide the mwai-chatbot-default element\r\n    var chatbotElement = document.querySelector('#mwai-chatbot-default > div.mwai-open-button');\r\n    if (chatbotElement) {\r\n      chatbotElement.style.display = 'none';\r\n      console.log(\"Element-OSCE hidden.\");\r\n    } else {\r\n      console.log(\"Element not found.\");\r\n    }\r\n  } else {\r\n    console.log(\"URL does not match.\");\r\n  }\r\n\r\n\tif (normalizeUrl(window.location.href) === normalizeUrl(targetLink)) {\r\n    \/\/ Hide the inputButtons element\r\n    var inputButtonElement = document.querySelector('.mwai-input-buttons');\r\n    if (inputButtonElement) {\r\n      inputButtonElement.style.display = 'none';\r\n      console.log(\"inputButtonElement hidden.\");\r\n\t}\r\n }\r\n\t\r\n});\r\n<\/script>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-26559","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/myairclinic.com\/app\/wp-json\/wp\/v2\/pages\/26559","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/myairclinic.com\/app\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/myairclinic.com\/app\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/myairclinic.com\/app\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/myairclinic.com\/app\/wp-json\/wp\/v2\/comments?post=26559"}],"version-history":[{"count":2,"href":"https:\/\/myairclinic.com\/app\/wp-json\/wp\/v2\/pages\/26559\/revisions"}],"predecessor-version":[{"id":27452,"href":"https:\/\/myairclinic.com\/app\/wp-json\/wp\/v2\/pages\/26559\/revisions\/27452"}],"wp:attachment":[{"href":"https:\/\/myairclinic.com\/app\/wp-json\/wp\/v2\/media?parent=26559"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}