def action_default(self): """Render the details for the specified patient information, including controls to modify""" userId = int(self.requestData["sim_user_id"]) patientId = int(self.requestData["sim_patient_id"]) simTime = int(self.requestData["sim_time"]) manager = SimManager() userModel = manager.loadUserInfo([userId])[0] # Assume found good single match patientModel = manager.loadPatientInfo([patientId], simTime)[0] #print >> sys.stderr, "Loaded %(sim_patient_id)s in state %(sim_state_id)s at %(relative_time_start)s" % patientModel for key, value in userModel.iteritems(): self.requestData["sim_user." + key] = value for key, value in patientModel.iteritems(): self.requestData["sim_patient." + key] = value self.requestData["sim_time.format"] = ( BASE_TIME + timedelta(0, simTime)).strftime(TIME_FORMAT) subData = self.pageClassByName[self.requestData["currentDataPage"]]() subData.requestData["sim_user_id"] = self.requestData["sim_user_id"] subData.requestData["sim_patient_id"] = self.requestData[ "sim_patient_id"] subData.requestData["sim_time"] = self.requestData["sim_time"] subData.action_default() self.requestData["currentDataTable"] = subData.populatedTemplate() subData = NewOrders() subData.action_default() self.requestData["dataEntryTable"] = subData.populatedTemplate()
def action_default(self): """Render the details for the specified patient information, including controls to modify""" userId = int(self.requestData["sim_user_id"]); patientId = int(self.requestData["sim_patient_id"]); simTime = None; manager = SimManager(); userModel = manager.loadUserInfo([userId])[0]; # Assume found good single match try: simTime = int(self.requestData["sim_time"]); except ValueError: # Unable to parse any explicit simulation time. # Lookup the last activity (order) time for the patient and start just after that to resume the simulation simTime = manager.loadPatientLastEventTime(patientId) + 60; # Advance by one minute to avoid confusing states where multiple events happening within zero time. self.requestData["sim_time"] = simTime; # So sub-pages have access patientModel = manager.loadPatientInfo([patientId], simTime)[0]; #print >> sys.stderr, "Loaded %(sim_patient_id)s in state %(sim_state_id)s at %(relative_time_start)s" % patientModel for key, value in userModel.iteritems(): self.requestData["sim_user."+key] = value; for key, value in patientModel.iteritems(): self.requestData["sim_patient."+key] = value; self.requestData["sim_time.format"] = (BASE_TIME + timedelta(0,simTime)).strftime(TIME_FORMAT); subData = self.pageClassByName[self.requestData["currentDataPage"]](); subData.requestData["sim_user_id"] = self.requestData["sim_user_id"]; subData.requestData["sim_patient_id"] = self.requestData["sim_patient_id"]; subData.requestData["sim_time"] = self.requestData["sim_time"]; subData.action_default(); self.requestData["currentDataTable"] = subData.populatedTemplate(); subData = NewOrders(); subData.action_default(); self.requestData["dataEntryTable"] = subData.populatedTemplate();
def action_signOrders(self): """Call sub-page action to update information before proceeding to default render""" subData = NewOrders() subData.requestData["sim_user_id"] = self.requestData["sim_user_id"] subData.requestData["sim_patient_id"] = self.requestData[ "sim_patient_id"] subData.requestData["sim_time"] = self.requestData["sim_time"] subData.requestData["newOrderItemId"] = self.requestData[ "newOrderItemId"] subData.requestData["discontinuePatientOrderId"] = self.requestData[ "discontinuePatientOrderId"] subData.action_signOrders() # Advance the simulated time after orders signed. # Otherwise bizarre patterns where simulation states can undergo multiple changes within zero time. # Advance one minute (60) seconds per item ordered simTime = int(self.requestData["sim_time"]) deltaSeconds = len(subData.requestData["newOrderItemId"]) * 60 self.requestData["sim_time"] = simTime + deltaSeconds
def action_signOrders(self): """Call sub-page action to update information before proceeding to default render""" subData = NewOrders(); subData.requestData["sim_user_id"] = self.requestData["sim_user_id"]; subData.requestData["sim_patient_id"] = self.requestData["sim_patient_id"]; subData.requestData["sim_time"] = self.requestData["sim_time"]; subData.requestData["newOrderItemId"] = self.requestData["newOrderItemId"]; subData.requestData["discontinuePatientOrderId"] = self.requestData["discontinuePatientOrderId"]; subData.action_signOrders(); # Advance the simulated time after orders signed. # Otherwise bizarre patterns where simulation states can undergo multiple changes within zero time. # Advance one minute (60) seconds per item ordered simTime = int(self.requestData["sim_time"]); deltaSeconds = len(subData.requestData["newOrderItemId"]) * 60; self.requestData["sim_time"] = simTime + deltaSeconds; # Revert back to the NotesReview page to catch any state change notes self.requestData["currentDataPage"] = NotesReview.__name__;