def __init__(self, context, request): super(ASTPanelView, self).__init__(context, request) self.title = _("AST Panel") self.catalog = SETUP_CATALOG self.contentFilter = { "portal_type": "Microorganism", "is_active": True, "sort_on": "sortable_title", "sort_order": "ascending", } self.omit_form = True self.show_search = True self.show_select_column = False self.show_categories = False self.show_column_toggles = False self.fetch_transitions_on_select = False self.show_workflow_action_buttons = False # Only the first column is defined here, the rest of columns, that are # the antibiotics abbreviations are added dynamically self.columns = collections.OrderedDict((("Microorganism", { "title": _("Microorganism"), }), )) self.review_states = [{ "id": "default", "title": _("All microorganisms"), "contentFilter": {}, "columns": self.columns.keys(), }]
def __init__(self, context, request): super(ASTPanelFolderView, self).__init__(context, request) self.catalog = SETUP_CATALOG self.contentFilter = { "portal_type": "ASTPanel", "sort_on": "sortable_title", "sort_order": "ascending", } self.context_actions = { _c("Add"): { "url": "++add++ASTPanel", "icon": "add.png"} } self.show_select_column = True self.columns = collections.OrderedDict(( ("Title", { "title": _c("Title"), "index": "sortable_title" }), ("Description", { "title": _c("Description"), "index": "Description" }), ("Microorganisms", { "title": _("Microorganisms"), }), ("Antibiotics", { "title": _("Antibiotics"), }) )) self.review_states = [ { "id": "default", "title": _c("Active"), "contentFilter": {"is_active": True}, "transitions": [], "columns": self.columns.keys(), }, { "id": "inactive", "title": _c("Inactive"), "contentFilter": {'is_active': False}, "transitions": [], "columns": self.columns.keys(), }, { "id": "all", "title": _c("All"), "contentFilter": {}, "columns": self.columns.keys(), }, ]
def handle_save(self): """Handles the save action """ form = self.request.form # Key uids are antibiotics (columns) uids = filter(api.is_uid, form.keys()) antibiotics = map(api.get_object_by_uid, uids) # Generate a transposed dict microorganism->antibiotics # Add all microorganisms, so analyses without any antibiotic selected # can also be removed microorganisms = self.get_microorganisms() mapping = dict(map(lambda m: (api.get_uid(m), []), microorganisms)) for antibiotic in antibiotics: abx_uid = api.get_uid(antibiotic) for uid in form[abx_uid].keys(): mapping.setdefault(uid, []).append(antibiotic) # Update existing analyses and create new ones for uid, abx in mapping.items(): microorganism = self.get_object(uid) self.update_analyses(microorganism, abx) return self.redirect(_("AST analyses updated"))
class ASTAnalysesViewlet(LabAnalysesViewlet): """AST Analyses section viewlet for Sample view """ title = _("Antibiotic Sensitivities") icon_name = "ast_panel" capture = "ast" def available(self): """Returns true if senaite.ast is installed """ return is_installed()
class IMicroorganismBehavior(model.Schema): gram_stain = schema.Choice( title=_(u"Gram stain"), vocabulary="senaite.microorganism.vocabularies.gram_stains", ) glass = schema.Bool( title=_(u"GLASS organism"), description=_( "Whether this is an infectious organism included in the Global " "Antimicrobial Resistance Surveillance System (GLASS) for the " "the collection, analysis and sharing of Antimicrobial Resistance " "(AMR) data at a global level"), required=False, ) multi_resistant = schema.Bool( title=_(u"MRO Organism"), description=_( "Whether this organism is considered multi resistant (MRO)", ), required=False, ) mro_phenotype = schema.TextLine( title=_(u"MRO phenotype"), required=False, )
def __init__(self, context, request): super(ManageResultsView, self).__init__(context, request) self.contentFilter.update({ "getPointOfCapture": "ast", "getAncestorsUIDs": [api.get_uid(context)], "sort_on": "title", "sort_order": "ascending", }) self.form_id = "ast_analyses" self.allow_edit = True self.show_workflow_action_buttons = True self.show_search = False # Add the Microorganism column new_columns = (("Microorganism", { "title": _("Microorganism"), "sortable": False }), ) old_columns = self.columns.items() self.columns = OrderedDict(list(new_columns) + list(old_columns)) self.columns["Service"].update({ "title": _("Result"), }) # Remove the columns we are not interested in from review_states hide = [ "Method", "Instrument", "Analyst", "DetectionLimitOperand", "Specification", "Uncertainty", "retested", "Attachments", "DueDate", "Result", "Hidden" ] all_columns = self.columns.keys() all_columns = filter(lambda c: c not in hide, all_columns) for review_state in self.review_states: review_state.update({"columns": all_columns})
def get_microorganism_info(self, uid_brain_object): uid = api.get_uid(uid_brain_object) obj = api.get_object(uid_brain_object) title = api.get_title(obj) params = { "href": api.get_url(obj), "value": title, } if obj.multi_resistant: params.update({ "value": "{}*".format(title), "title": _("Multi-resistant (MRO)") }) return { "uid": uid, "link": get_link(**params), "title": title, }
def after_initialize(analysis): """Event fired when an analysis is initialized """ if analysis.getKeyword() != IDENTIFICATION_KEY: return # Get the names list of active microorganisms query = {"portal_type": "Microorganism", "is_active": True} names = sorted(map(api.get_title, api.search(query, SETUP_CATALOG))) # Maybe no microorganisms where identified names.insert(0, _("No culture growth obtained")) # Generate the analysis result options options = zip(range(len(names)), names) options = map(lambda m: {"ResultValue": m[0], "ResultText": m[1]}, options) analysis.setResultOptions(options) analysis.setResultOptionsType("multiselect") analysis.reindexObject()
class IASTPanelBehavior(model.Schema): microorganisms = schema.List( title=_(u"Microorganisms"), description=_( "The names of selected microorganisms are displayed as row headers " "in the sensitivity results entry view. From all microorganisms " "selected here, only those identified in the Sample are added in " "results entry view"), required=True, value_type=schema.Choice( source="senaite.ast.vocabularies.microorganisms")) antibiotics = schema.List( title=_(u"Antibiotics"), description=_( "The abbreviations of selected antibiotics are displayed as " "column headers in the sensitivity results entry view"), required=True, value_type=schema.Choice( source="senaite.ast.vocabularies.antibiotics")) zone_size = schema.Bool( title=_(u"Include zone size in mm"), description=_( "When enabled, an additional row for the introduction of the zone " "size (in mm) is displayed in the results entry view, below " "resistance call options"), default=True, ) selective_reporting = schema.Bool( title=_(u"Selective reporting"), description=_( "When enabled, an additional row to indicate whether the " "resistance result for each microorganism-antibiotic tuple has to " "be reported in results report or not"), default=True, )
def before_render(self): # If there are microorganisms identified for the current sample, # display a new filter "Identified microorganisms" and make it the # default, so only identified microorganisms are listed microorganisms = utils.get_identified_microorganisms(self.context) if microorganisms: # Get the microorganisms uids uids = map(api.get_uid, microorganisms) # Make the original review state not default's self.listing.review_states[0].update({ "id": "all" }) # Insert the new "default" review state self.listing.review_states.insert(0, { "id": "default", "title": _("Identified microorganisms"), "contentFilter": {"UID": uids}, "columns": self.listing.columns.keys() })
# This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. # # You should have received a copy of the GNU General Public License along with # this program; if not, write to the Free Software Foundation, Inc., 51 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # Copyright 2020 by it's authors. # Some rights reserved, see README and LICENSE. from senaite.ast import messageFactory as _ # Analysis Category name AST Services will be added into SERVICE_CATEGORY = _("Antibiotic Sensitivity Testing (AST)") # Keyword of the Analysis Service to be used as the template for the creation # of zone size (mm) results. This service is automatically created on install # and is not editable ZONE_SIZE_KEY = "senaite_ast_zone" # Keyword of the Analysis Service to be used as the template for the creation # of AST analyses. This Service is automatically created on install and is not # editable RESISTANCE_KEY = "senaite_ast_resistance" # Keyword of the Analysis Service to be used as the template for the creation # of analyses that will be used to tell whether the AST result has to be # reported in results report or not REPORT_KEY = "senaite_ast_report"
def __init__(self, context, request): super(ASTPanelReportingView, self).__init__(context, request) self.title = _("AST Panel Selective Reporting") self.show_search = False