//////////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2013-2017 Dawson Dean // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // //////////////////////////////////////////////////////////////////////////////// // // This is the top-level module. It initiates the entire UI and also does all // the layout of HTML elements in the UI. This layout is done initially when the // UI opens, but also may change the UI elements dynamically in response to user // actions. // ///////////////////////////////////////////////////////////////////////////// // // StartNoteBuilder() // OnPlanButton(button) // ResetNotebuilderState() // OnPlanTypeButton(button) // WritePlanHeader() // WritePlanFooter() // WritePlanBody() // StartNewPlanSection(problemName, controlPanelID) // WriteComment(str) // WriteAction(str) // WriteActionEx(str, reccStr) // MedNote_ImportLabs(sourceEMRName) // OnShowWindowButton(button) // MedNote_OnCloseChildWindow(button) // OnOptionButton(button) // InferPlanItemsBasedOnLabs() // ClearInferredPlanItems() // SetInferredPlanState(planNameStr) // InitPlanState(planNameStr, printFunctionArg) // MedNote_RefreshQuantState() // // NB_ToggleCPButton ///////////////////////////////////////////////////////////////////////////// ///////////////////////// // HTML Elements - many other HTML elements are declared in // These are the main windows that we show/hide to expose different subgroups of funtions and outputs. var g_PlanDivElement = null; var g_PlanTableElement = null; var g_DiagnosisButtonsDivElement = null; var g_HelpDivElement = null; var g_PatientListWindowDivElement = null; var g_OptionWindowDivElement = null; var g_ImportWindowDivElement = null; var g_TextEditWindowDivElement = null; var g_ComputedResultsDivElement = null; var g_RecommendationsDivElement = null; var g_InpatientTableElement = null; var g_HelpButtonElement = null; var g_ToolBarElement = null; var g_LabsTableElement = null; var g_RefreshBtnElement = null; var g_ClearStateBtnElement = null; var g_ShowCalculatorButtonElement = null; var g_ControlPanelCatalogElement = null; // Runtime state for rebuilding a plan. var g_CurrentPlanSectionElement = null; var g_CurrentPlanSectionTableRow = null; ////////////////// // User Options var g_InPatient = true; var g_OptionsInferProblems = true; var g_OptionsShowBillingInfo = false; var g_IsPrimary = false; var g_EmitBoilerplate = true; ///////////////////////// var g_PlanStateArray = []; var g_AllPlansDeclaration = { // Chief Complaints "DyspneaPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "DyspneaPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "DyspneaCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "ChestPain" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "ChestPain", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "ChestPain", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "DKAPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "DKAPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "DKACP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "GIBleedPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "GIBleedPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "GIBleedCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "SepsisPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "SepsisPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "SepsisCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "StrokePlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "StrokePlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "StrokeCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "EncephalopathyPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "EncephalopathyPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "EncephalopathyCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "SyncopePlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "SyncopePlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "SyncopeCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "OncologyPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "OncologyPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "OncologyCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "HepatitisPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "HepatitisPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "HepatitisCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "PancPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "PancPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "PancCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "PneumoniaPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "PneumoniaPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "PneumoniaCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "CADPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "CADPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "CADCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "CHFPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "CHFPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "CHFCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "COPDPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "COPDPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "COPDCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "AFibPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "AFibPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "AFibCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "PreopPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "PreopPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "PreopCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, // Complex Comorbidities "CirrhosisPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "CirrhosisPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "CirrhosisCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "HemoDialysisPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "HemoDialysisPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "HemoDialysisCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "PeritonealDialysisPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "PeritonealDialysisPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "PeritonealDialysisCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "CVVHPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "CVVHPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "CVVHCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "RenalTransplantPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "RenalTransplantPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "RenalTransplantCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, // "CVVHDPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "CVVHDPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "CVVHDCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, // Renal "AKIPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "AKIPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "AKICP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "CKDPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "CKDPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "CKDCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "NephroticPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "NephroticPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "NephroticCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "IVContrastPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "IVContrastPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "IVContrastCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "VolumePlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "VolumePlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "VolumeCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "FreeWaterPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "FreeWaterPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "FreeWaterCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "CKDAnemiaPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "CKDAnemiaPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "CKDAnemiaCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "MBDPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "MBDPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "MBDCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "HTNPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "HTNPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "HTNCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "AcidBasePlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "AcidBasePlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "AcidBaseCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "HypokalemiaPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "HypokalemiaPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "HypokalemiaCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "HyperkalemiaPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "HyperkalemiaPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "HyperkalemiaCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "HyponatremiaPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "HyponatremiaPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "HyponatremiaCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "HypERnatremiaPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "HypERnatremiaPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "HypERnatremiaCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "ParathyroidectomyPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "ParathyroidectomyPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "ParathyroidectomyCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "VitDPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "VitDPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "VitDCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, // Non-Complex Comorbidities "AsthmaPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "AsthmaPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "AsthmaCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "OSAPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "OSAPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "OSACP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "HypothyroidPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "HypothyroidPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "HypothyroidCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "DiabetesPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "DiabetesPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "DiabetesCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "AnemiaPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "AnemiaPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "AnemiaCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "GoutPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "GoutPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "GoutCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "GERDPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "GERDPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "GERDCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "BPHPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "BPHPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "BPHCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, // Lifestyle "EtOHPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "EtOHPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "EtOHCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "OpioidPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "OpioidPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "OpioidCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "TobaccoPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "TobaccoPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "TobaccoCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "DepressionPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "DepressionPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "DepressionCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "AnxietyPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "AnxietyPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "AnxietyCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "ObesityPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "ObesityPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "ObesityCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "MalnutritionPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "MalnutritionPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "MalnutritionCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "PalliativePlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "PalliativePlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "PalliativeCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, // Not used "MigrainePlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "MigrainePlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "MigraineCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "MenorrhagiaPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "MenorrhagiaPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "MenorrhagiaCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "Polyarthropathy" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "Polyarthropathy", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "PolyarthropathyCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "BackPainPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "BackPainPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "BackPainCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "HipPainPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "HipPainPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "HipPainCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "KneePainPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "KneePainPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "KneePainCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "ShoulderPainPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "ShoulderPainPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "ShoulderPainCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "ElbowPainPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "ElbowPainPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "ElbowPainCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null}, "JointPainPlan" : { "isSelected" : 0, "planSelectStatusHTMLElementID" : "JointPainPlan", "planSelectStatusHTMLElement" : null, "ProblemListEntry" : null, "PrintFunction" : null, "controlPanelID" : "JointPainCP", "controlPanelElement" : null, "activeControlPanel" : null, "planTextTableRowElement" : null} }; // g_AllPlansDeclaration //////////////////////////////////////////////////////////////////////////////// // // [StartNoteBuilder] // // This is called by the browser to initialize the entire UI. //////////////////////////////////////////////////////////////////////////////// function StartNoteBuilder() { //LogEvent("StartNoteBuilder"); MedNote_InitQuantState(); //LogEvent("StartNoteBuilder. MedNote_InitQuantState finished"); StartNBFiles(); //LogEvent("StartNoteBuilder. StartNBFiles finished"); // These are the main windows that we show/hide to expose different subgroups of funtions and outputs. g_PlanDivElement = document.getElementById("NotePlanWindow"); g_PlanTableElement = document.getElementById("PlanTable"); g_DiagnosisButtonsDivElement = document.getElementById("DiagnosisButtons"); g_HelpDivElement = document.getElementById("HelpWindow"); g_PatientListWindowDivElement = document.getElementById("PatientListWindow"); g_OptionWindowDivElement = document.getElementById("OptionWindow"); g_ImportWindowDivElement = document.getElementById("ImportWindow"); g_TextEditWindowDivElement = document.getElementById("TextEditWindow"); g_ComputedResultsDivElement = document.getElementById("ComputedValueResultsBlock"); g_ControlPanelCatalogElement = document.getElementById("ControlPanelCatalog"); // Get some useful elements from the HTML; these will be used for input and output. g_InpatientTableElement = document.getElementById("InPatientTable"); g_HelpButtonElement = document.getElementById("HelpButtonID"); g_ToolBarElement = document.getElementById("ToolBar"); g_LabsTableElement = document.getElementById("LabsTable"); g_RefreshBtnElement = document.getElementById("RefreshBtnID"); g_ClearStateBtnElement = document.getElementById("ClearStateBtnID"); g_ShowCalculatorButtonElement = document.getElementById("ShowCalculatorButton"); //LogEvent("StartNoteBuilder. Got html elements"); g_InPatient = true; g_IsPrimary = true; if (g_InpatientTableElement) { g_InpatientTableElement.style.display = "inline"; } if (g_HelpDivElement) { g_HelpDivElement.style.display = "None"; } if (g_RefreshBtnElement) { g_RefreshBtnElement.style.display = "None"; } if (g_ClearStateBtnElement) { g_ClearStateBtnElement.style.display = "inline"; } //LogEvent("StartNoteBuilder. Initialized html elements"); //LogEvent("StartNoteBuilder. Initialized Plan states 0% new"); //LogEvent("StartNoteBuilder. Initialized Plan states WriteHemodialysisPlan = " + WriteHemodialysisPlan); // Initialize the global state. // This goes in ORDER of the order in which problems typically appear in the plan. // So, put the highest priority items first, and the lowest priority items last. //////////////////////////////////// // Chief Complaints InitPlanState("DyspneaPlan", WriteRespFailurePlan); InitPlanState("ChestPain", WriteChestPainPlan); InitPlanState("DKAPlan", WriteDKAPlan); InitPlanState("GIBleedPlan", WriteGIBleedPlan); //LogEvent("StartNoteBuilder. Initialized Plan states 5%"); InitPlanState("SepsisPlan", WriteSepsisPlan); InitPlanState("StrokePlan", WriteStrokePlan); InitPlanState("EncephalopathyPlan", WriteEncephalopathyPlan); InitPlanState("SyncopePlan", WriteSyncopePlan); InitPlanState("OncologyPlan", WriteOncologyPlan); InitPlanState("HepatitisPlan", WriteHepatitisPlan); InitPlanState("PancPlan", WritePancreatitisPlan); //LogEvent("StartNoteBuilder. Initialized Plan states 12%"); InitPlanState("PneumoniaPlan", WritePneumoniaPlan); InitPlanState("CADPlan", WriteCADPlan); InitPlanState("CHFPlan", WriteCHFPlan); InitPlanState("COPDPlan", WriteCOPDPlan); InitPlanState("PreopPlan", WritePreOpPlan); //////////////////////////////////// // Complex Comorbidities //LogEvent("StartNoteBuilder. Initialized Plan states 25%"); InitPlanState("CirrhosisPlan", WriteCirrhosisPlan); InitPlanState("HemoDialysisPlan", WriteHemodialysisPlan); InitPlanState("PeritonealDialysisPlan", WritePeritonealDialysisPlan); InitPlanState("CVVHPlan", WriteCVVHPlan); InitPlanState("RenalTransplantPlan", WriteRenalTransplantPlan); //////////////////////////////////// // Renal InitPlanState("AKIPlan", PrintAKIPlan); InitPlanState("CKDPlan", PrintCKDPlan); InitPlanState("NephroticPlan", WriteNephroticPlan); InitPlanState("IVContrastPlan", WriteIVContrastPlan); InitPlanState("VolumePlan", WriteVolumePlan); InitPlanState("FreeWaterPlan", WriteFreeWaterPlan); InitPlanState("CKDAnemiaPlan", WriteCKDAnemiaPlan); InitPlanState("MBDPlan", WriteMBDPlan); InitPlanState("HTNPlan", WriteHTNPlan); InitPlanState("AcidBasePlan", WriteAcidBasePlan); InitPlanState("HypokalemiaPlan", WriteHypokalemiaPlan); InitPlanState("HyperkalemiaPlan", WriteHypERkalemiaPlan); InitPlanState("HyponatremiaPlan", WriteHyponatremiaPlan); InitPlanState("HypERnatremiaPlan", PrintHyperNatremiaPlan); InitPlanState("ParathyroidectomyPlan", WriteParathyroidectomyPlan); InitPlanState("VitDPlan", WriteVitaminDPlan); //////////////////////////////////// // Non-Complex Comorbidities InitPlanState("DiabetesPlan", PrintDiabetesPlan); InitPlanState("AsthmaPlan", WriteAsthmaPlan); InitPlanState("OSAPlan", WriteOSAPlan); InitPlanState("AFibPlan", WriteAFibPlan); InitPlanState("AnemiaPlan", WriteAnemiaPlan); InitPlanState("HypothyroidPlan", WriteHypothyroidPlan); InitPlanState("GoutPlan", WriteGoutPlan); InitPlanState("GERDPlan", WriteGERDPlan); InitPlanState("BPHPlan", WriteBPHPlan); //////////////////////////////////// // Lifestyle InitPlanState("EtOHPlan", WriteEtOHPlan); InitPlanState("OpioidPlan", WriteOpioidPlan); InitPlanState("TobaccoPlan", WriteTobaccoPlan); InitPlanState("MalnutritionPlan", WriteMalnutritionPlan); InitPlanState("PalliativePlan", WritePalliativePlan); InitPlanState("ObesityPlan", WriteObesityPlan); InitPlanState("DepressionPlan", WriteDepressionPlan); InitPlanState("AnxietyPlan", WriteAnxietyPlan); //////////////////////////////////// // Not Used InitPlanState("MenorrhagiaPlan", WriteMenorrhagiaPlan); InitPlanState("MigrainePlan", WriteMigrainePlan); InitPlanState("Polyarthropathy", WritePolyarthropathyPlan); InitPlanState("BackPainPlan", WriteBackPainPlan); InitPlanState("HipPainPlan", WriteHipPainPlan); InitPlanState("KneePainPlan", WriteKneePainPlan); InitPlanState("ShoulderPainPlan", WriteShoulderPainPlan); InitPlanState("ElbowPainPlan", WriteElbowPainPlan); InitPlanState("JointPainPlan", WriteJointPainPlan); //LogEvent("StartNoteBuilder. Initialized plan states"); WritePlanBody(); } // StartNoteBuilder //////////////////////////////////////////////////////////////////////////////// // // [OnPlanButton] // // button.id is the name of the plan state. //////////////////////////////////////////////////////////////////////////////// function OnPlanButton(button) { //LogEvent("OnPlanButton. button.id=" + button.id); var valueEntry = g_AllPlansDeclaration[button.id]; if (!valueEntry) { LogEvent("OnPlanButton. null valueEntry"); return; } //LogEvent("OnPlanButton. valueEntry=" + valueEntry); if (!(valueEntry.planSelectStatusHTMLElement)) { LogEvent("OnPlanButton. null valueEntry.planSelectStatusHTMLElement"); return; } //LogEvent("OnPlanButton. valueEntry.planSelectStatusHTMLElement=" + valueEntry.planSelectStatusHTMLElement); //LogEvent("OnPlanButton. valueEntry.planSelectStatusHTMLElement.className=" + valueEntry.planSelectStatusHTMLElement.className); //LogEvent("OnPlanButton. valueEntry.planSelectStatusHTMLElement.className=" + valueEntry.planSelectStatusHTMLElement.className.toUpperCase()); if (valueEntry.planSelectStatusHTMLElement.className.toUpperCase() == "PLANOFFSTYLE") { //LogEvent("OnPlanButton. Turn the option on. button.id=" + button.id); valueEntry.isSelected = 1; valueEntry.planSelectStatusHTMLElement.className = "planOnStyle"; } else { //LogEvent("OnPlanButton. Turn the option off. button.id=" + button.id); valueEntry.isSelected = 0; valueEntry.planSelectStatusHTMLElement.className = "planOffStyle"; // Hide any active control panels. if (valueEntry.activeControlPanel) { var parentNode = valueEntry.activeControlPanel.parentNode; if (parentNode) { parentNode.removeChild(valueEntry.activeControlPanel); } valueEntry.activeControlPanel = null; } } WritePlanBody(); } // OnPlanButton //////////////////////////////////////////////////////////////////////////////// // // [ResetNotebuilderState] // //////////////////////////////////////////////////////////////////////////////// function ResetNotebuilderState() { //LogEvent("ResetNotebuilderState"); var index; for (index = 0; index < g_PlanStateArray.length; index++) { var valueEntry = g_PlanStateArray[index]; if (valueEntry) { valueEntry.isSelected = 0; if (valueEntry.planSelectStatusHTMLElement) { valueEntry.planSelectStatusHTMLElement.className = "planOffStyle"; } // Hide any active control panels. if (valueEntry.activeControlPanel) { var parentNode = valueEntry.activeControlPanel.parentNode; if (parentNode) { parentNode.removeChild(valueEntry.activeControlPanel); } valueEntry.activeControlPanel = null; } } // if (valueEntry) } // for (index = 0; index < g_PlanStateArray.length; index++) MedNote_ReInitializeQuantState(); WritePlanBody(); } // ResetNotebuilderState //////////////////////////////////////////////////////////////////////////////// // // [OnPlanTypeButton] // //////////////////////////////////////////////////////////////////////////////// function OnPlanTypeButton(button) { //LogEvent("OnPlanTypeButton"); //LogEvent("button.id = " + button.id); //////////////////////////////////// if (button.id == "FullPlanOption") { if (button.value == "Full Note") { button.className="OptionBtnStyle"; button.value="Plan Only"; g_EmitBoilerplate = false; } else { button.className="optionOnStyle"; button.value="Full Note"; g_EmitBoilerplate = true; } //////////////////////////////////// } else if (button.id == "BillingModeOption") { if (button.value == "Billing Hints") { button.className="OptionBtnStyle"; button.value="No Billing Hints"; g_OptionsShowBillingInfo = false; } else { button.className="optionOnStyle"; button.value="Billing Hints"; g_OptionsShowBillingInfo = true; } //////////////////////////////////// } else if (button.id == "RoleOption") { if (button.value == "Consultant") { button.className="OptionBtnStyle"; button.value="Primary"; g_IsPrimary = true; } else { button.className="optionOnStyle"; button.value="Consultant"; g_IsPrimary = false; } } WritePlanBody(); } // OnPlanTypeButton //////////////////////////////////////////////////////////////////////////////// // // [WritePlanHeader] // //////////////////////////////////////////////////////////////////////////////// function WritePlanHeader() { //LogEvent("WritePlanHeader"); StartNewPlanSection(null, null); WriteComment("Chief Complaint: "); WriteComment("History of Present Illness:"); WriteComment(""); WriteComment(""); WriteComment("Baseline:"); WriteComment("The patient does not use home oxygen."); WriteComment("The patient ambulates without a cane or walker, and has been compliant with medications and diet."); WriteComment("The patient can/cannot perform exercise equivalent to 4 mets (walking up 2 flights of stairs, making a bed)."); WriteComment(""); WriteComment("Review of Systems:"); WriteComment("General: No fevers, no weakness, no fatigue, normal appetite"); WriteComment("Neurologic: no headaches, no dizziness"); WriteComment("Cardiovascular: no chest pain, no palpitations, no edema"); WriteComment("Pulmonary: no shortness of breath, no dyspnea on exertion, no cough, no change in sputum production"); WriteComment("Gastrointestinal: no nausea, no vomiting, no diarrhea, no constipation, no abdominal pain"); WriteComment("Genitourinary: no urinary straining, no partial voiding, no weak stream, no urinary hesitancy, no hematuria, no dysuria"); WriteComment("Dermatologic: no rashes"); WriteComment("Musculoskeletal: no back pain, no shoulder pain, no hip pain, no knee pain"); WriteComment("All other review of systems are negative."); WriteComment(""); WriteComment("Medical History:"); WriteComment(""); WriteComment("Surgical History:"); WriteComment(""); WriteComment("Social History:"); WriteComment("- Tobacco: "); WriteComment("- EtOH: "); WriteComment("- Illicits: None"); WriteComment(""); WriteComment("Family History:"); WriteComment("Mother:"); WriteComment("Father:"); WriteComment("Siblings:"); WriteComment(""); WriteComment("Home Medications:"); WriteComment(""); WriteComment("Allergies: NKDA"); WriteComment(""); WriteComment("OBJECTIVE"); if (g_InPatient) { WriteComment("Vitals: T=, HR=, BP=/, RR=20, SpO2=100% on RA, Wt="); } else { WriteComment("Vitals: T=, HR=, BP=/, SpO2=100% on RA, Wt="); } WriteComment("Gen: AOx3, no acute distress, well-nourished"); WriteComment("HEENT: OPC, oral mucosa moist, anicteric"); WriteComment("Neck: supple, no thyromegaly, no carotid bruits, no cervical lymphadenopathy"); WriteComment("Cardiovascular: Regular s1/s2, no murmurs, no JVD, no lower extremity edema"); WriteComment("Pulmonary: Clear bilaterally, no rales, no wheezes, good air movement, non-labored breathing"); WriteComment("Abd: +Bowel Sounds, soft, non-tender, non-distended, no rebound tenderness"); WriteComment("Muskuloskeletal: 100 percent RoM in bilateral elbows, shoulders, hips"); WriteComment("Neurologic: No asterixis, CN II-XII are grossly intact, 5/5 strength in bilateral upper and lower extremities, 2+ reflexes patella and brachial, tactile sensation intact in bilateral upper and lower extremities, Negative Babinski"); WriteComment("Dermatologic: No rashes, lesions, or ulcers"); WriteComment(""); // Insert all internal values here //PrintDataLineInPlan(); WriteComment(""); WriteComment("IMAGING:"); WriteComment(""); WriteComment("ASSESSMENT/PLAN"); } // WritePlanHeader //////////////////////////////////////////////////////////////////////////////// // // [WritePlanFooter] // //////////////////////////////////////////////////////////////////////////////// function WritePlanFooter() { //LogEvent("WritePlanFooter. g_InPatient=" + g_InPatient); //LogEvent("WritePlanFooter. g_IsPrimary=" + g_IsPrimary); StartNewPlanSection(null, null); WriteComment(""); if (g_IsPrimary) { WriteComment("#) Fluids/Electrolytes/Nutrition"); WriteAction("- 2g sodium diet"); WriteComment(""); WriteComment("#) Prophylaxis"); WriteAction("- Enoxaparin subcu"); WriteAction("- Heparin subcu (d/t CKD)"); WriteAction("- SCD's (d/t suspected bleed)"); WriteComment(""); WriteComment("#) Dispo"); WriteComment("- Admit to"); WriteAction("- PT/OT"); WriteComment(""); WriteComment("#) Code Status"); WriteComment("- Full Code"); } if (!g_InPatient) { WriteComment(" "); WriteComment(" "); WriteComment(" "); WriteComment("PLANS FOR NEXT CLINIC APPOINTMENT:"); WriteComment(" "); WriteComment(" "); WriteComment("SUMMARY OF ACTIONS IN THIS CLINIC APPOINTMENT:"); WriteComment("- Return to clinic in :"); } else if (!g_IsPrimary) { WriteComment(" "); WriteComment(" "); WriteComment(" "); WriteComment("RECOMMENDATIONS:"); if (g_RecommendationsDivElement) { var childElement = g_RecommendationsDivElement.firstChild; while (childElement) { var nextChildElement = childElement.nextSibling; g_RecommendationsDivElement.removeChild(childElement); g_CurrentPlanSectionElement.appendChild(childElement); childElement = nextChildElement; } // while (childElement) g_RecommendationsDivElement = null; } } WriteComment(""); //WriteComment("Dawson Dean (312-1226)"); //WriteComment("Staff: "); //WriteComment(""); } // WritePlanFooter //////////////////////////////////////////////////////////////////////////////// // // [WritePlanBody] // //////////////////////////////////////////////////////////////////////////////// function WritePlanBody() { //LogEvent("WritePlanBody"); var index; // Read any inputs and calculate any possible derived results. MedNote_CalculateAllValues(); if (g_OptionsInferProblems) { InferPlanItemsBasedOnLabs(); } // Clear the output and prepare to write a new plan. if (g_PlanDivElement) { Util_RemoveAllChildNodes(g_PlanTableElement); } if (g_RecommendationsDivElement) { Util_RemoveAllChildNodes(g_RecommendationsDivElement); } g_CurrentPlanSectionElement = g_PlanDivElement; if (g_EmitBoilerplate) { WritePlanHeader(); } for (index = 0; index < g_PlanStateArray.length; index++) { var valueEntry = g_PlanStateArray[index]; if ((valueEntry.isSelected) && (valueEntry.PrintFunction)) { valueEntry.PrintFunction(); } } // For now, we always include prevention in outpatient plans. if (!g_InPatient) { WritePreventionPlan(); } WritePlanFooter(); WriteComment(" "); WriteComment(" "); ClearInferredPlanItems(); } // WritePlanBody //////////////////////////////////////////////////////////////////////////////// // // [StartNewPlanSection] // //////////////////////////////////////////////////////////////////////////////// function StartNewPlanSection(problemName, configStateID) { //LogEvent("StartNewPlanSection. problemName=" + problemName); //LogEvent("StartNewPlanSection. configStateID=" + configStateID); var newRow; var leftColumnTableCell; var rightColumnTableCell; var brNode; var textNode; var controlPanelID; var configState = null; //////////////////////////////////////// // Make a new row for this section. This allows items in the left and right // columns to scroll up and down together and always be vertically aligned. // // We do NOT do this if we are just regenerating a single plan section. In // that case, the row already exists, because it is used to hold our place in // the plan body between when we remove the old text and insert the newly regenerated // text. if (g_CurrentPlanSectionTableRow) { newRow = g_CurrentPlanSectionTableRow; } else { newRow = document.createElement("TR"); g_PlanTableElement.appendChild(newRow); } leftColumnTableCell = document.createElement("TD"); newRow.appendChild(leftColumnTableCell); rightColumnTableCell = document.createElement("TD"); newRow.setAttribute('style', "vertical-align:top;"); newRow.appendChild(rightColumnTableCell); g_CurrentPlanSectionElement = leftColumnTableCell; // g_PlanDivElement; //////////////////////////////////////// // Print the section header for the plan. // There will not be a section header for "special" sections like the note header or footer. if (problemName) { // if ((g_OptionsShowBillingInfo) && (null != strWithBilling)) { // problemName = problemName + strWithBilling; brNode = document.createElement("br"); g_CurrentPlanSectionElement.appendChild(brNode); textNode = document.createTextNode("#) " + problemName); g_CurrentPlanSectionElement.appendChild(textNode); } // if (problemName) //////////////////////////////////////// if (configStateID) { configState = g_AllPlansDeclaration[configStateID]; } if (configState) { // Save the table row in the plan state. This will let us just regerate one plan section. configState.planTextTableRowElement = newRow; // If there is a control panel, then make sure we have one cached. if ((configState.controlPanelID) && (!(configState.controlPanelElement))) { //LogEvent("Look for control panel. g_ControlPanelCatalogElement: " + g_ControlPanelCatalogElement); var currentControlPanel = Util_GetChildNode(g_ControlPanelCatalogElement, 'div'); while (currentControlPanel) { // Get the name of this control panel. var currentID = currentControlPanel.getAttribute('id'); //LogEvent("Look for control panel. currentID: " + currentID); if ((currentID) && (currentID == configState.controlPanelID)) { //LogEvent("Found control panel. currentID: " + currentID); configState.controlPanelElement = currentControlPanel.cloneNode(true); break; } // if (currentID) currentControlPanel = Util_GetPeerNode(currentControlPanel, "div"); } // while (currentControlPanel) } // Cache the control panel. // If there is a control panel, then display it. if (configState.controlPanelElement) { configState.activeControlPanel = configState.controlPanelElement; rightColumnTableCell.appendChild(configState.controlPanelElement); } } // if (configState) } // StartNewPlanSection //////////////////////////////////////////////////////////////////////////////// // // [WriteComment] // //////////////////////////////////////////////////////////////////////////////// function WriteComment(str) { //LogEvent("WriteComment. g_CurrentPlanSectionElement=" + g_CurrentPlanSectionElement); var brNode; var textNode; brNode = document.createElement("br"); g_CurrentPlanSectionElement.appendChild(brNode); textNode = document.createTextNode(str); g_CurrentPlanSectionElement.appendChild(textNode); } // WriteComment //////////////////////////////////////////////////////////////////////////////// // // [WriteAction] // //////////////////////////////////////////////////////////////////////////////// function WriteAction(str) { WriteActionEx(str, str); } // WriteAction //////////////////////////////////////////////////////////////////////////////// // // [WriteActionEx] // //////////////////////////////////////////////////////////////////////////////// function WriteActionEx(str, reccStr) { WriteComment(str); if ((!g_IsPrimary) && (reccStr)) { var brNode; var textNode; if (!g_RecommendationsDivElement) { g_RecommendationsDivElement = document.createElement("div"); //g_RecommendationsDivElement = document.createDocumentFragment(); } brNode = document.createElement("br"); g_RecommendationsDivElement.appendChild(brNode); textNode = document.createTextNode(reccStr); g_RecommendationsDivElement.appendChild(textNode); } } // WriteActionEx //////////////////////////////////////////////////////////////////////////////// // // [MedNote_ImportLabs] // //////////////////////////////////////////////////////////////////////////////// function MedNote_ImportLabs(sourceEMRName) { //LogEvent("MedNote_ImportLabs"); var scraperTextBox = document.getElementById("ScraperInput"); var lineArray = scraperTextBox.value.split('\n'); MedNote_ReInitializeQuantState(); //LogEvent("MedNote_ImportLabs. sourceEMRName=" + sourceEMRName); if (sourceEMRName == "Epic") { } else if (sourceEMRName == "SCM") { MedNote_ImportSCMLabs(lineArray); g_LabDataAvailable = true; } else if (sourceEMRName == "CPRS") { MedNote_ImportCPRSLabs(lineArray); } else if (sourceEMRName == "Cerner") { } MedNote_CalculateAllValues(); MedNote_OnCloseChildWindow(null); WritePlanBody(); } // MedNote_ImportLabs //////////////////////////////////////////////////////////////////////////////// // // [OnShowWindowButton] // //////////////////////////////////////////////////////////////////////////////// function OnShowWindowButton(button) { //LogEvent("OnShowWindowButton"); //LogEvent("button.id = " + button.id); //////////////////////////////////// if (button.id == "HelpButtonID") { g_ToolBarElement.style.display = "None"; g_ComputedResultsDivElement.style.display = "None"; g_PlanDivElement.style.display = "None"; g_DiagnosisButtonsDivElement.style.display = "None"; g_HelpDivElement.style.display = "inline"; g_PatientListWindowDivElement.style.display = "None"; g_OptionWindowDivElement.style.display = "None"; g_ImportWindowDivElement.style.display = "None"; g_TextEditWindowDivElement.style.display = "None"; g_LabsTableElement.style.display = "None"; //////////////////////////////////// } else if (button.id == "TextEditButtonID") { g_ToolBarElement.style.display = "None"; g_ComputedResultsDivElement.style.display = "None"; g_PlanDivElement.style.display = "None"; g_DiagnosisButtonsDivElement.style.display = "None"; g_HelpDivElement.style.display = "None"; g_PatientListWindowDivElement.style.display = "None"; g_OptionWindowDivElement.style.display = "None"; g_ImportWindowDivElement.style.display = "None"; g_TextEditWindowDivElement.style.display = "inline"; g_LabsTableElement.style.display = "None"; //////////////////////////////////// } else if (button.id == "ImportButtonID") { g_ToolBarElement.style.display = "None"; g_ComputedResultsDivElement.style.display = "None"; g_PlanDivElement.style.display = "None"; g_DiagnosisButtonsDivElement.style.display = "None"; g_HelpDivElement.style.display = "None"; g_PatientListWindowDivElement.style.display = "None"; g_OptionWindowDivElement.style.display = "None"; g_ImportWindowDivElement.style.display = "inline"; g_TextEditWindowDivElement.style.display = "None"; g_LabsTableElement.style.display = "None"; var scraperTextBox = document.getElementById("ScraperInput"); if (scraperTextBox) { scraperTextBox.focus(); } //////////////////////////////////// } else if (button.id == "ShowCalculatorButton") { if (button.value == "Show Calculator") { button.value="Hide Calculator"; g_LabsTableElement.style.display = "inline"; g_RefreshBtnElement.style.display = "inline"; g_LabDataAvailable = true; } else { //button.className="CalcOnStyle"; button.value="Show Calculator"; g_LabsTableElement.style.display = "None"; g_RefreshBtnElement.style.display = "None"; MedNote_CalculateAllValues(); } //LogEvent("Hit ShowCalculatorButton button. g_LabDataAvailable=" + g_LabDataAvailable); } return(false); } // OnShowWindowButton //////////////////////////////////////////////////////////////////////////////// // // [MedNote_OnCloseChildWindow] // //////////////////////////////////////////////////////////////////////////////// function MedNote_OnCloseChildWindow(button) { g_ToolBarElement.style.display = "inline"; g_ComputedResultsDivElement.style.display = "inline"; g_DiagnosisButtonsDivElement.style.display = "inline"; g_PlanDivElement.style.display = "inline"; g_HelpDivElement.style.display = "None"; g_PatientListWindowDivElement.style.display = "None"; g_OptionWindowDivElement.style.display = "None"; g_ImportWindowDivElement.style.display = "None"; g_TextEditWindowDivElement.style.display = "None"; g_LabsTableElement.style.display = "None"; g_RefreshBtnElement.style.display = "None"; } // MedNote_OnCloseChildWindow //////////////////////////////////////////////////////////////////////////////// // // [OnOptionButton] // //////////////////////////////////////////////////////////////////////////////// function OnOptionButton(button) { //LogEvent("OnOptionButton. button.id = " + button.id); if (button.id == "sexOption") { NBQuant_ToggleBooleanButton("IsMale"); } else if (button.id == "RaceOption") { NBQuant_ToggleBooleanButton("IsCaucasian"); } else if (button.id == "HTNOption") { NBQuant_ToggleBooleanButton("OnHTNMeds"); } else if (button.id == "DMOption") { NBQuant_ToggleBooleanButton("IsDiabetic"); } else if (button.id == "SmokerOption") { NBQuant_ToggleBooleanButton("IsSmoker"); } else if (button.id == "OnDialysisOption") { NBQuant_ToggleBooleanButton("IsOnDialysis"); } WritePlanBody(); } // OnOptionButton //////////////////////////////////////////////////////////////////////////////// // // [InferPlanItemsBasedOnLabs] // //////////////////////////////////////////////////////////////////////////////// function InferPlanItemsBasedOnLabs() { ////////////////////////////// if ((GetLabValue("SystolicBP") > 155) || (GetLabValue("DiastolicBP") > 100)) { SetInferredPlanState("HTNPlan"); } ////////////////////////////// var sodium = GetLabValue("Sodium"); if ((sodium > 1) && (sodium < 133)) { SetInferredPlanState("HyponatremiaPlan"); SetInferredPlanState("FreeWaterPlan"); } if ((sodium > 1) && (sodium > 147)) { SetInferredPlanState("HypERnatremiaPlan"); } ////////////////////////////// var potassium = GetLabValue("Potassium"); if ((potassium > 1) && (potassium < 3.3)) { SetInferredPlanState("HypokalemiaPlan"); } if ((potassium > 1) && (potassium > 4.8)) { SetInferredPlanState("HyperkalemiaPlan"); } ////////////////////////////// if (((GetLabValue("HCO3") > 1) && (GetLabValue("HCO3") < 21)) || ((GetLabValue('pH') > 1) && (GetLabValue('pH') < 7.28)) || ((GetLabValue('PaCO2') > 1) && (GetLabValue('PaCO2') < 33))) { SetInferredPlanState("AcidBasePlan"); } ////////////////////////////// if (GetLabValue("Creatinine") > 1.5) { SetInferredPlanState("AKIPlan"); } ////////////////////////////// if (((GetLabValue("PTH") > 1) && (GetLabValue("PTH") > 200)) || ((GetLabValue("Phos") > 1) && (GetLabValue("Phos") > 7)) || ((GetLabValue("Calcium") > 1) && (GetLabValue("Calcium") < 7.5))) { SetInferredPlanState("MBDPlan"); } if ((GetLabValue("VitD") > 1) && (GetLabValue("VitD") < 20)) { SetInferredPlanState("VitDPlan"); } ////////////////////////////// if ((GetLabValue('HgbA1c') > 1) && (GetLabValue('HgbA1c') > 7.2)) { SetInferredPlanState("DiabetesPlan"); } ////////////////////////////// if ((GetLabValue("WeightInKg") > 1) && (GetLabValue("WeightInKg") > 150)) { SetInferredPlanState("ObesityPlan"); } ////////////////////////////// if ((GetLabValue('CBCHgb') > 1) && (GetLabValue('CBCHgb') < 10)) { SetInferredPlanState("AnemiaPlan"); } } // InferPlanItemsBasedOnLabs //////////////////////////////////////////////////////////////////////////////// // // [ClearInferredPlanItems] // //////////////////////////////////////////////////////////////////////////////// function ClearInferredPlanItems() { //LogEvent("ClearInferredPlanItems"); var index; for (index = 0; index < g_PlanStateArray.length; index++) { var valueEntry = g_PlanStateArray[index]; if ((valueEntry) && (valueEntry.isSelected == 2)) { valueEntry.isSelected = 0; } } } // ClearInferredPlanItems //////////////////////////////////////////////////////////////////////////////// // // [SetInferredPlanState] // //////////////////////////////////////////////////////////////////////////////// function SetInferredPlanState(planNameStr) { //LogEvent("SetInferredPlanState. planNameStr=" + planNameStr); var valueEntry = g_AllPlansDeclaration[planNameStr]; if (!valueEntry.isSelected) { valueEntry.isSelected = 2; } } // SetInferredPlanState //////////////////////////////////////////////////////////////////////////////// // // [InitPlanState] // //////////////////////////////////////////////////////////////////////////////// function InitPlanState(planNameStr, printFunctionArg) { //LogEvent("InitPlanState."); //LogEvent("InitPlanState. planNameStr=" + planNameStr); var valueEntry = g_AllPlansDeclaration[planNameStr]; valueEntry.isSelected = 0; valueEntry.PrintFunction = printFunctionArg; valueEntry.planSelectStatusHTMLElement = document.getElementById(valueEntry.planSelectStatusHTMLElementID); //LogEvent("InitPlanState. valueEntry.planSelectStatusHTMLElement= " + valueEntry.planSelectStatusHTMLElement); if (valueEntry.planSelectStatusHTMLElement) { valueEntry.planSelectStatusHTMLElement.className = "planOffStyle"; } // if (valueEntry.planSelectStatusHTMLElement) // I seem to need an array that is accessed by index in addition to the associative-array that is accessed by name. // There must be a way, but for now I do not know how to enumerate the named elements of an associative array using an integer index. g_PlanStateArray.push(valueEntry); } // InitPlanState //////////////////////////////////////////////////////////////////////////////// // // [NB_ToggleCPButton] // //////////////////////////////////////////////////////////////////////////////// function NB_ToggleCPButton(buttonNode, stateName, statusHTMLElementID) { var valueEntry = null; var spanNode; var textNode; var pStr = null; var fToggleState = false; //LogEvent("NB_ToggleCPButton, buttonNode = " + buttonNode); if (!buttonNode) { LogEvent("NB_ToggleCPButton: Null buttonNode"); return; } if (stateName) { valueEntry = g_AllPlansDeclaration[stateName]; } ///////////////////////////////////// // Get the span node. We store the state in the HTML so it is always consistent. if (statusHTMLElementID) { spanNode = document.getElementById(statusHTMLElementID); } else { spanNode = buttonNode.nextSibling; while (spanNode) { // Look further at elements of type html-object/tag if (spanNode.nodeType == 1) { var currentName = spanNode.tagName; if (currentName.toUpperCase() == "SPAN") { break; } } spanNode = spanNode.nextSibling; } // while (spanNode) } if (!spanNode) { LogEvent("NB_ToggleCPButton: Null spanNode"); return; } ///////////////////////////////////// // Get the current state and invert it. pStr = Util_GetNodeText(spanNode); //LogEvent("NB_ToggleCPButton, pStr = " + pStr); if (pStr) { pStr = pStr.toUpperCase(); if (pStr == "ON") { fToggleState = false; } else { fToggleState = true; } } ///////////////////////////////////// // Store the new state in the html Util_RemoveAllChildNodes(spanNode); if (fToggleState) { textNode = document.createTextNode("ON"); spanNode.style="background-color:#00FF00;" } else { textNode = document.createTextNode("OFF"); spanNode.style="background-color:#FF0000;" } spanNode.appendChild(textNode); ///////////////////////////////////// // Regenerate the text for just this part of the plan. if (valueEntry) { // Save the table row in the plan state. This will let us just regerate one plan section. if (valueEntry.planTextTableRowElement) { g_CurrentPlanSectionTableRow = valueEntry.planTextTableRowElement; Util_RemoveAllChildNodes(valueEntry.planTextTableRowElement); if ((valueEntry.isSelected) && (valueEntry.PrintFunction)) { valueEntry.PrintFunction(); } g_CurrentPlanSectionTableRow = null; } } // if (valueEntry) } // NB_ToggleCPButton //////////////////////////////////////////////////////////////////////////////// // // [NB_GetRadioButtonValue] // //////////////////////////////////////////////////////////////////////////////// function NB_GetRadioButtonValue(radioGroupTableName) { var radioGroupTableElement; var newValue; radioGroupTableElement = document.getElementById(radioGroupTableName); if (!radioGroupTableElement) { LogEvent("NB_GetRadioButtonValue error. null button element"); return; } // Save the state. newValue = radioGroupTableElement.getAttribute('xVal'); return(newValue); } // NB_GetRadioButtonValue //////////////////////////////////////////////////////////////////////////////// // // [NB_CPRadioButton] // //////////////////////////////////////////////////////////////////////////////// function NB_CPRadioButton(buttonElement, stateName) { //LogEvent("NB_GetRadioButtonValue. buttonElement=" + buttonElement); //LogEvent("NB_GetRadioButtonValue. stateName=" + stateName); var parentNode; var radioGroupTableElement; var rowElement; var tdElement; var buttonElement; var newValue; if (!buttonElement) { LogEvent("NB_GetRadioButtonValue error. null button element"); return; } newValue = buttonElement.getAttribute('xVal'); /////////////////////////////////////////// // Get the surrounding parts of the same Radio button group. parentNode = buttonElement.parentNode; while (parentNode) { var currentName = parentNode.tagName; if (currentName.toUpperCase() == 'TR') { rowElement = parentNode; } else if (currentName.toUpperCase() == 'TABLE') { radioGroupTableElement = parentNode; break; } parentNode = parentNode.parentNode; } // while (parentNode) //LogEvent("NB_GetRadioButtonValue. rowElement=" + rowElement); //LogEvent("NB_GetRadioButtonValue. radioGroupTableElement=" + radioGroupTableElement); /////////////////////////////////////////// // Turn on/off the buttons of this Radio button group. tdElement = Util_GetChildNode(rowElement, 'TD'); //LogEvent("NB_GetRadioButtonValue. tdElement=" + tdElement); while (tdElement) { // Get the name of this control panel. var currentButton = Util_GetChildNode(tdElement, 'input'); if (currentButton) { var currentValue = currentButton.getAttribute('xVal'); //LogEvent("NB_GetRadioButtonValue. currentValue=" + currentValue); //LogEvent("NB_GetRadioButtonValue. currentButton=" + currentButton); if (currentValue == newValue) { currentButton.className = "ToggleBtnStyle"; } else { currentButton.className = "ToggleBtnStyle"; } } // if (currentButton) tdElement = Util_GetPeerNode(tdElement, "TD"); } // while (tdElement) // Save the state. newRow.setAttribute('xVal', newValue); ///////////////////////////////////// // Regenerate the text for just this part of the plan. if (stateName) { valueEntry = g_AllPlansDeclaration[stateName]; } if (valueEntry) { // Save the table row in the plan state. This will let us just regerate one plan section. if (valueEntry.planTextTableRowElement) { g_CurrentPlanSectionTableRow = valueEntry.planTextTableRowElement; Util_RemoveAllChildNodes(valueEntry.planTextTableRowElement); if ((valueEntry.isSelected) && (valueEntry.PrintFunction)) { valueEntry.PrintFunction(); } g_CurrentPlanSectionTableRow = null; } } // if (valueEntry) } // NB_CPRadioButton //////////////////////////////////////////////////////////////////////////////// // // [MedNote_RefreshQuantState] // //////////////////////////////////////////////////////////////////////////////// function MedNote_RefreshQuantState() { MedNote_CalculateAllValues(); PrintPlan(); } // MedNote_RefreshQuantState