def __call__(self, value, *args, **kwargs):
        instance = kwargs['instance']
        ts = getToolByName(instance, 'translation_service').translate

        if instance.REQUEST.get('validated', '') == self.name:
            return True
        else:
            instance.REQUEST['validated'] = self.name

        pmins = instance.REQUEST.get('minpanic', {})[0]
        pmaxs = instance.REQUEST.get('maxpanic', {})[0]
        uids = pmins.keys()
        for uid in uids:
            pmin = pmins.get(uid, '') == '' and '0' or pmins[uid]
            pmax = pmaxs.get(uid, '') == '' and '0' or pmaxs[uid]

            # Values must be numbers
            try:
                pmin = float(pmin)
            except:
                return ts(_("Validation failed: Panic min value must be "
                            "numeric"))

            try:
                pmax = float(pmax)
            except:
                return ts(_("Validation failed: Panic min value must be "
                            "numeric"))

            if pmin > pmax:
                return ts(_("Validation failed: Panic max value must be "
                            "greater than panic min value"))
        return True
示例#2
0
 def __call__(self):
     mtool = getToolByName(self.context, 'portal_membership')
     addPortalMessage = self.context.plone_utils.addPortalMessage
     if mtool.checkPermission(AddPatient, self.context):
         clients = self.context.clients.objectIds()
         if clients:
             self.context_actions[_('Add')] = {
                 'url': 'createObject?type_name=Patient',
                 'icon': '++resource++bika.lims.images/add.png'
             }
         else:
             msg = _("Cannot create patients without any system clients configured.")
             addPortalMessage(self.context.translate(msg))
     if mtool.checkPermission(ViewPatients, self.context):
         self.review_states[0]['transitions'].append({'id':'deactivate'})
         self.review_states.append(
             {'id': 'inactive',
              'title': _('Dormant'),
              'contentFilter': {'inactive_state': 'inactive'},
              'transitions': [{'id':'activate'}, ],
              'columns': ['getPatientID', 'getClientPatientID',
                          'Title', 'getGender', 'getAgeSplittedStr',
                          'getBirthDate', 'getCitizenship', 'getPrimaryReferrer']})
         self.review_states.append(
             {'id': 'all',
              'title': _('All'),
              'contentFilter':{},
              'transitions':[{'id':'empty'}, ],
              'columns': ['Title', 'getPatientID', 'getClientPatientID', 
                          'getGender', 'getAgeSplittedStr',
                          'getBirthDate', 'getCitizenship',
                          'getPrimaryReferrer']})
         stat = self.request.get("%s_review_state" % self.form_id, 'default')
         self.show_select_column = stat != 'all'
     return super(PatientsView, self).__call__()
    def __call__(self):
        self.context_actions = {}
        wf = getToolByName(self.context, 'portal_workflow')
        mtool = getToolByName(self.context, 'portal_membership')
        addPortalMessage = self.context.plone_utils.addPortalMessage
        PR = self.context.getPrimaryReferrer()
        if isActive(self.context):
            if mtool.checkPermission(AddAnalysisRequest, PR):
                #client contact required
                contacts = [
                    c for c in PR.objectValues('Contact')
                    if wf.getInfoFor(c, 'inactive_state', '') == 'active'
                ]
                if contacts:
                    self.context_actions[self.context.translate(_('Add'))] = {
                        'url': PR.absolute_url() + "/portal_factory/"
                        "AnalysisRequest/Request new analyses/ar_add",
                        'icon': '++resource++bika.lims.images/add.png'
                    }
                else:
                    msg = _(
                        "Client contact required before request may be submitted"
                    )
                    addPortalMessage(self.context.translate(msg))

        return super(AnalysisRequestsView, self).__call__()
示例#4
0
    def update(self):
        """Before template render hook
        """
        super(DoctorsView, self).update()

        if IDoctors.providedBy(self.context):
            # Top-level doctors listing
            self.request.set("disable_border", 1)

        elif "disable_border" in self.request:
            del (self.request["disable_border"])

        # By default, only users with AddDoctor permissions for the current
        # context can add doctors.
        self.context_actions = {
            _("Add"): {
                "url": "createObject?type_name=Doctor",
                "permission": AddDoctor,
                "icon": "++resource++bika.lims.images/add.png"
            }
        }

        # If current user is a client contact and current context is not a
        # Client, then modify the url for Add action so the Doctor gets created
        # inside the Client object the current user belongs to
        client = self.get_user_client()
        if client and check_permission(AddDoctor, client):
            add_url = self.context_actions[_("Add")]["url"]
            add_url = "{}/{}".format(api.get_url(client), add_url)
            self.context_actions[_("Add")]["url"] = add_url
            del (self.context_actions[_("Add")]["permission"])

        if self.get_client():
            # The current context is a Client, remove the client column
            self.remove_column('getPrimaryReferrer')
示例#5
0
    def before_render(self):
        # Rename columns BatchID and ClientBatchID
        self.listing.columns["BatchID"]["title"] = _("Case ID")
        self.listing.columns["ClientBatchID"]["title"] = _("Client Case ID")

        # Change the contentFilter and transitions from review_states
        self.update_review_states()

        # Additional review_satuses
        self.add_review_states()

        # Additional columns
        self.add_columns()

        # Remove unnecessary columns
        column_ids = [
            "Title",
            "BatchDate",
            "Description",
        ]
        if self.is_client_user or self.is_in_client:
            # Hide client-specific columns
            column_ids.extend(["Client", "ClientID"])

        self.hide_columns(column_ids)
示例#6
0
 def __call__(self):
     mtool = getToolByName(self.context, 'portal_membership')
     if mtool.checkPermission(AddDoctor, self.context):
         self.context_actions[_('Add')] = {
             'url': 'createObject?type_name=Doctor',
             'icon': '++resource++bika.lims.images/add.png'
         }
     if mtool.checkPermission(ManageDoctors, self.context):
         self.review_states[0]['transitions'].append({'id':'deactivate'})
         self.review_states.append(
             {'id':'inactive',
              'title': _('Dormant'),
              'contentFilter': {'inactive_state': 'inactive'},
              'transitions': [{'id':'activate'}, ],
              'columns': ['getDoctorID',
                          'getFullname',
                          'getEmailAddress',
                          'getBusinessPhone',
                          'getMobilePhone']})
         self.review_states.append(
             {'id':'all',
              'title': _('All'),
              'contentFilter':{},
              'transitions':[{'id':'empty'}],
              'columns': ['getDoctorID',
                          'getFullname',
                          'getEmailAddress',
                          'getBusinessPhone',
                          'getMobilePhone']})
         stat = self.request.get("%s_review_state"%self.form_id, 'default')
         self.show_select_column = stat != 'all'
     return super(DoctorsView, self).__call__()
示例#7
0
    def add_review_states(self):
        if self.is_external_user:
            # If the logged in user is external, there is no need to display
            # shared/private filters, it might cause confusion
            return

        # Do not display the filters unless current context is not inside an
        # external client
        if not is_from_external_client(self.context):
            self.listing.review_states.insert(
                1, {
                    "id": "shared",
                    "title": _("Open (shared)"),
                    "contentFilter": {
                        "review_state": "shared"
                    },
                    "transitions": [],
                    "columns": self.listing.columns.keys(),
                })
            self.listing.review_states.insert(
                2, {
                    "id": "private",
                    "title": _("Open (private)"),
                    "contentFilter": {
                        "review_state": "private"
                    },
                    "transitions": [],
                    "columns": self.listing.columns.keys(),
                })
示例#8
0
    def __init__(self, context, request):
        super(SamplesView, self).__init__(context, request)

        # Add Patient fields
        self.columns['getPatientID'] = {
            'title': _('Patient ID'),
            'sortable': False,
            'toggle': True
        }
        self.columns['getClientPatientID'] = {
            'title': _("Client PID"),
            'sortable': False,
            'toggle': True
        }
        self.columns['getPatient'] = {
            'title': _('Patient'),
            'sortable': False,
            'toggle': True
        }
        self.columns['getDoctor'] = {
            'title': _('Doctor'),
            'sortable': False,
            'toggle': True
        }
        for rs in self.review_states:
            i = rs['columns'].index('getSampleID') + 1
            rs['columns'].insert(i, 'getClientPatientID')
            rs['columns'].insert(i, 'getPatientID')
            rs['columns'].insert(i, 'getPatient')
            rs['columns'].insert(i, 'getDoctor')
示例#9
0
 def __call__(self, context):
     items = [
         (_('Email'),'email'),
         (_('PDF'), 'pdf')
     ]
     for name, item in getAdapters((context, ), ICustomPubPref):
         items.append(item)
     return SimpleVocabulary.fromItems(items)
示例#10
0
    def __init__(self, context, request):
        super(PatientsView, self).__init__(context, request)

        self.catalog = 'bika_patient_catalog'

        self.contentFilter = {'portal_type': 'Patient',
                              'sort_on': 'sortable_title'}
        self.context_actions = {}
        self.title = _("Patients")
        self.icon = self.portal_url + "/++resource++bika.health.images/patient_big.png"
        self.description = ""
        self.show_sort_column = False
        self.show_select_row = False
        self.show_select_column = False
        self.pagesize = 25

        self.columns = {

            'Title': {'title': _('Patient'),
                      'index': 'sortable_title'},

            'getPatientID': {'title': _('Patient ID'),
                             'index': 'getPatientID'},

            'getClientPatientID': {'title': _('Client PID'),
                            'index': 'getClientPatientID'},

            'getGender': {'title': _('Gender'),
                          'index': 'getGender',
                          'toggle': True},

            'getAgeSplittedStr': {'title': _('Age'),
                                  'index': 'getAgeSplittedStr',
                                  'toggle': True},

            'getBirthDate': {'title': _('BirthDate'),
                             'index': 'getBirthDate',
                             'toggle': True},

            'getCitizenship': {'title': _('Citizenship'),
                               'index': 'getCitizenship',
                               'toggle': True},

            'getPrimaryReferrer': {'title': _('Primary Referrer'),
                                   'index': 'getPrimaryReferrerTitle',
                                   'toggle': True},

        }

        self.review_states = [
            {'id': 'default',
             'title': _('Active'),
             'contentFilter': {'inactive_state': 'active'},
             'transitions': [],
             'columns': ['getPatientID', 'getClientPatientID',
                         'Title', 'getGender', 'getAgeSplittedStr',
                         'getBirthDate', 'getCitizenship', 'getPrimaryReferrer']},
        ]
示例#11
0
    def __init__(self, context, request):
        super(InsuranceCompaniesView, self).__init__(context, request)
        self.catalog = 'bika_setup_catalog'
        self.contentFilter = {'portal_type': 'InsuranceCompany',
                              'sort_on': 'sortable_title'}
        self.context_actions = {_('Add'):
                                {'url': 'createObject?type_name=InsuranceCompany',
                                 'icon': '++resource++bika.lims.images/add.png'}}
        self.title = self.context.translate(_("Insurance Companies"))
        self.icon = self.portal_url + "/++resource++bika.lims.images/laboratory_big.png"
        self.description = ""
        self.show_sort_column = False
        self.show_select_row = False
        self.show_select_column = True
        self.pagesize = 25

        self.columns = {
            'Name': {'title': _('Company Name'),
                      'index':'sortable_title'},
            'EmailAddress': {'title': _('Email'),
                      'toggle': True},
            'Phone': {'title': _('Phone'),
                      'toggle': True},
            'Fax': {'title': _('Fax'),
                    'toggle': False},
            'Description': {'title': _('Description'),
                            'index': 'description',
                            'toggle': False},
        }

        self.review_states = [
            {'id':'default',
             'title': _('Active'),
             'contentFilter': {'is_active': True},
             'transitions': [{'id':'deactivate'}, ],
             'columns': ['Name',
                         'EmailAddress',
                         'Phone',
                         'Fax',
                         'Description']},
            {'id':'inactive',
             'title': _('Dormant'),
             'contentFilter': {'is_active': False},
             'transitions': [{'id':'activate'}, ],
             'columns': ['Name',
                         'EmailAddress',
                         'Phone',
                         'Fax',
                         'Description']},
            {'id':'all',
             'title': _('All'),
             'contentFilter':{},
             'columns': ['Name',
                         'EmailAddress',
                         'Phone',
                         'Fax',
                         'Description']},
        ]
示例#12
0
    def __call__(self):
        workflow = getToolByName(self.context, 'portal_workflow')
        translate = self.context.translate
        plone.protect.CheckAuthenticator(self.request)
        bc = getToolByName(self.context, 'bika_catalog')
        ar = bc(UID=self.request.get('uid', None))

        if ar:
            ar = ar[0].getObject()
            self.ccs = []
            self.recipients = []

            contact = ar.getContact()
            if contact:
                email = contact.getEmailAddress()
                if email:
                    self.recipients = [{'uid': contact.UID(),
                                        'name': contact.Title(),
                                        'email': email}]
            for cc in ar.getCCContact():
                ccemail = cc.getEmailAddress()
                if ccemail:
                    self.ccs.append({'uid': cc.UID(),
                                     'name': cc.Title(),
                                     'email': ccemail})
            analyses = ar.getAnalyses()
            strans = []
            for analysis in analyses:
                analysis = analysis.getObject()
                astate = workflow.getInfoFor(analysis, 'review_state')
                if astate == 'retracted':
                    continue
                panic_alerts = ResultOutOfRange(analysis)()
                if panic_alerts:
                    serviceTitle = analysis.getServiceTitle()
                    result = analysis.getResult()
                    strans.append("- {0}, {1}: {2}".format(
                        serviceTitle, translate(_("Result")), result))
            stran = "\n".join(strans)

            laboratory = self.context.bika_setup.laboratory
            lab_address = "\n".join(laboratory.getPrintAddress())

            self.body = translate(
                _("Some results from the Analysis Request ${ar} "
                  "exceeded the panic levels that may indicate an "
                  "imminent life-threatening condition: \n\n${arlist}\n"
                  "\n\n${lab_address}",
                  mapping={'ar': ar.getRequestID(),
                           'arlist': stran,
                           'lab_address': lab_address})
            )
            self.subject = translate(
                _("Some results from ${ar} exceeded panic range",
                  mapping={'ar': ar.getRequestID()})
            )

        return self.template()
示例#13
0
    def __init__(self, context, request):
        super(ContactsView, self).__init__(context, request)
        self.catalog = "portal_catalog"
        self.contentFilter = {
            'portal_type': 'VaccinationCenterContact',
            'sort_on':'sortable_title',
            'path': {
                "query": "/".join(context.getPhysicalPath()),
                "level" : 0
            }
        }
        self.context_actions = {_('Add'):
            {'url': 'createObject?type_name=VaccinationCenterContact',
             'icon': '++resource++bika.lims.images/add.png'}
        }
        self.show_table_only = False
        self.show_sort_column = False
        self.show_select_row = False
        self.show_select_column = True
        self.pagesize = 50
        self.icon = self.portal_url + "/++resource++bika.health.images/vaccinationcenter_contact_big.png"
        self.title = _b("Contacts")

        self.columns = {
            'getFullname': {'title': _('Full Name')},
            'getEmailAddress': {'title': _('Email Address')},
            'getBusinessPhone': {'title': _('Business Phone')},
            'getMobilePhone': {'title': _('Mobile Phone')},
            'getFax': {'title': _('Fax')},
        }

        self.review_states = [
            {'id':'default',
             'title': _('Active'),
             'contentFilter': {'inactive_state': 'active'},
             'transitions': [{'id':'deactivate'}, ],
             'columns': ['getFullname',
                         'getEmailAddress',
                         'getBusinessPhone',
                         'getMobilePhone',
                         'getFax']},
            {'id':'inactive',
             'title': _('Dormant'),
             'contentFilter': {'inactive_state': 'inactive'},
             'transitions': [{'id':'activate'}, ],
             'columns': ['getFullname',
                         'getEmailAddress',
                         'getBusinessPhone',
                         'getMobilePhone',
                         'getFax']},
            {'id':'all',
             'title': _('All'),
             'contentFilter':{},
             'columns': ['getFullname',
                         'getEmailAddress',
                         'getBusinessPhone',
                         'getMobilePhone',
                         'getFax']},
        ]
示例#14
0
    def __init__(self, context, request):
        super(SamplesView, self).__init__(context, request)

        # Add Patient fields
        self.columns['getPatientID'] = {'title': _('Patient ID'), 'toggle': True}
        self.columns['getClientPatientID'] = {'title': _("Client PID"), 'toggle': True}
        self.columns['getPatient'] = {'title': _('Patient'), 'toggle': True}
        for rs in self.review_states:
            i = rs['columns'].index('getClientSampleID') + 1
            rs['columns'].insert(i, 'getClientPatientID')
            rs['columns'].insert(i, 'getPatientID')
            rs['columns'].insert(i, 'getPatient')
示例#15
0
    def __init__(self, context, request):
        super(PatientsView, self).__init__(context, request)

        self.catalog = 'bika_patient_catalog'

        self.contentFilter = {'portal_type': 'Patient',
                              'sort_on': 'sortable_title'}
        self.context_actions = {}
        self.title = self.context.translate(_("Patients"))
        self.icon = self.portal_url + "/++resource++bika.health.images/patient_big.png"
        self.description = ""
        self.show_sort_column = False
        self.show_select_row = False
        self.show_select_column = False
        self.pagesize = 25

        self.columns = {

            'Title': {'title': _('Patient'),
                      'index': 'sortable_title'},

            'getPatientID': {'title': _('Patient ID'),
                             'index': 'getPatientID'},

            'getClientPatientID': {'title': _('Client PID'),
                            'index': 'getClientPatientID'},

            'getGender': {'title': _('Gender'),
                          'index': 'getGender',
                          'toggle': True},

            'getAgeSplittedStr': {'title': _('Age'),
                                  'index': 'getAgeSplittedStr',
                                  'toggle': True},

            'getBirthDate': {'title': _('BirthDate'),
                             'index': 'getBirthDate',
                             'toggle': True},

            'getCitizenship': {'title': _('Citizenship'),
                               'index': 'getCitizenship',
                               'toggle': True},

            'getPrimaryReferrer': {'title': _('Primary Referrer'),
                                   'index': 'getPrimaryReferrerTitle',
                                   'toggle': True},

        }

        self.review_states = [
            {'id': 'default',
             'title': _b('Active'),
             'contentFilter': {'inactive_state': 'active'},
             'transitions': [],
             'columns': ['getPatientID', 'getClientPatientID',
                         'Title', 'getGender', 'getAgeSplittedStr',
                         'getBirthDate', 'getCitizenship', 'getPrimaryReferrer']},
        ]
示例#16
0
    def __init__(self, context, request):
        super(AnalysisRequestsView, self).__init__(context, request)
        self.columns["BatchID"]["title"] = _("Case ID")

        # Add Client Patient fields
        self.columns["getPatientID"] = {"title": _("Patient ID"), "toggle": True}
        self.columns["getClientPatientID"] = {"title": _("Client PID"), "toggle": True}
        self.columns["getPatient"] = {"title": _("Patient"), "toggle": True}
        for rs in self.review_states:
            i = rs["columns"].index("BatchID") + 1
            rs["columns"].insert(i, "getClientPatientID")
            rs["columns"].insert(i, "getPatientID")
            rs["columns"].insert(i, "getPatient")
示例#17
0
    def __init__(self, context, request):
        super(SamplesView, self).__init__(context, request)

        # Add Patient fields
        self.columns["getPatientID"] = {"title": _("Patient ID"), "toggle": True}
        self.columns["getClientPatientID"] = {"title": _("Client PID"), "toggle": True}
        self.columns["getPatient"] = {"title": _("Patient"), "toggle": True}
        self.columns["getDoctor"] = {"title": _("Doctor"), "toggle": True}
        for rs in self.review_states:
            i = rs["columns"].index("getSampleID") + 1
            rs["columns"].insert(i, "getClientPatientID")
            rs["columns"].insert(i, "getPatientID")
            rs["columns"].insert(i, "getPatient")
            rs["columns"].insert(i, "getDoctor")
示例#18
0
def getImmunizationForms(context):
    """ Return the current list of immunization forms
    """
    # Active immunization entails the introduction of a foreign molecule into the body,
    # which causes the body itself to generate immunity against the target. Vaccination
    # is an active form of immunization.
    # Passive immunization is where pre-synthesized elements of the immune system are
    # transferred to a person so that the body does not need to produce these elements
    # itself. Currently, antibodies can be used for passive immunization.
    types = [
        ('active', context.translate(_('Active immunization'))),
        ('passive', context.translate(_('Passive immunization'))),
    ]
    return DisplayList(types)
示例#19
0
def getImmunizationForms(context):
    """ Return the current list of immunization forms
    """
    # Active immunization entails the introduction of a foreign molecule into the body,
    # which causes the body itself to generate immunity against the target. Vaccination
    # is an active form of immunization.
    # Passive immunization is where pre-synthesized elements of the immune system are
    # transferred to a person so that the body does not need to produce these elements
    # itself. Currently, antibodies can be used for passive immunization.
    types = [
             ('active', context.translate(_('Active immunization'))),
             ('passive', context.translate(_('Passive immunization'))),
             ]
    return DisplayList(types)
示例#20
0
    def __init__(self, context, request):
        super(DoctorsView, self).__init__(context, request)

        # Add new column definitions
        self.columns.extend({
            'AFerret': {'title': _('A Ferret')},
            'AField': {'title': _('A Field')},
        })

        # all dicts in self.review_states have a list of columns,
        # which we must update.  We will choose to show the new
        # fields in all filter states:
        for i in len(self.review_states):
            self.review_states[i]['columns'].append('AFerret', 'AField')
示例#21
0
    def fiddle(self, schema):

        # Add panic alert range columns
        validator = AnalysisSpecificationPanicValidator()
        schema["ResultsRange"].subfields += ("minpanic", "maxpanic")
        schema["ResultsRange"].subfield_validators["minpanic"] = validator
        schema["ResultsRange"].subfield_validators["maxpanic"] = validator
        schema["ResultsRange"].subfield_labels["minpanic"] = _("Min panic")
        schema["ResultsRange"].subfield_labels["maxpanic"] = _("Max panic")
        srcwidget = schema["ResultsRange"].widget
        schema["ResultsRange"].widget = AnalysisSpecificationWidget(
            checkbox_bound=srcwidget.checkbox_bound, label=srcwidget.label, description=srcwidget.description
        )
        return schema
示例#22
0
 def __init__(self, context, request):
     super(AnalysisRequestsView, self).__init__(context, request)
     self.patient_catalog = None
     self.columns['BatchID']['title'] = _('Case ID')
     # Add Client Patient fields
     self.columns['getPatientID'] = {
         'title': _('Patient ID'),
     }
     self.columns['getClientPatientID'] = {
         'title': _("Client PID"),
         'sortable': False,
     }
     self.columns['getPatient'] = {
         'title': _('Patient'),
     }
示例#23
0
 def sendAlertEmail(self):
     # Send an alert email
     laboratory = self.context.bika_setup.laboratory
     subject = self.request.get('subject')
     to = self.request.get('to')
     body = self.request.get('body')
     body = "<br/>".join(body.split("\r\n"))
     mime_msg = MIMEMultipart('related')
     mime_msg['Subject'] = subject
     mime_msg['From'] = formataddr(
                 (encode_header(laboratory.getName()),
                  laboratory.getEmailAddress()))
     mime_msg['To'] = to
     msg_txt = MIMEText(safe_unicode(body).encode('utf-8'),
                        _subtype='html')
     mime_msg.preamble = 'This is a multi-part MIME message.'
     mime_msg.attach(msg_txt)
     succeed = False
     try:
         host = getToolByName(self.context, 'MailHost')
         host.send(mime_msg.as_string(), immediate=True)
     except Exception, msg:
         ar = self.context.id
         logger.error("Panic level email %s: %s" % (ar, str(msg)))
         message = _('Unable to send an email to alert client '
                     'that some results exceeded the panic levels') \
                                          + (": %s" % str(msg))
         self.addMessage(message, 'warning')
示例#24
0
    def __call__(self):
        url = self.portal.absolute_url()
        self.context_actions[_('Add')] = dict(
            url="{}{}".format(url, "/batches/createObject?type_name=Batch"),
            icon="{}{}".format(url, "/++resource++bika.lims.images/add.png"))

        return HealthBatchesView.__call__(self)
示例#25
0
 def _initFormParams(self):
     mtool = getToolByName(self.context, 'portal_membership')
     addPortalMessage = self.context.plone_utils.addPortalMessage
     if mtool.checkPermission(AddPatient, self.context):
         clients = self.context.clients.objectIds()
         if clients:
             self.context_actions[_b('Add')] = {
                 'url': 'createObject?type_name=Patient',
                 'icon': '++resource++bika.lims.images/add.png'
             }
         else:
             msg = _("Cannot create patients without any system clients configured.")
             addPortalMessage(self.context.translate(msg))
     if mtool.checkPermission(ViewPatients, self.context):
         self.review_states[0]['transitions'].append({'id':'deactivate'})
         self.review_states.append(
             {'id': 'inactive',
              'title': _b('Dormant'),
              'contentFilter': {'inactive_state': 'inactive'},
              'transitions': [{'id':'activate'}, ],
              'columns': ['getPatientID', 'getClientPatientID',
                          'Title', 'getGender', 'getAgeSplittedStr',
                          'getBirthDate', 'getCitizenship', 'getPrimaryReferrer']})
         self.review_states.append(
             {'id': 'all',
              'title': _b('All'),
              'contentFilter':{},
              'transitions':[{'id':'empty'}, ],
              'columns': ['Title', 'getPatientID', 'getClientPatientID',
                          'getGender', 'getAgeSplittedStr',
                          'getBirthDate', 'getCitizenship',
                          'getPrimaryReferrer']})
         stat = self.request.get("%s_review_state" % self.form_id, 'default')
         self.show_select_column = stat != 'all'
示例#26
0
    def before_render(self):
        """Called before the listing renders
        """
        super(DoctorBatchListingViewAdapter, self).before_render()

        # Remove unnecessary columns
        hide = [
            "Doctor",
        ]
        self.hide_columns(hide)

        # Filter by doctor
        query = dict(getDoctorUID=api.get_uid(self.context))
        self.listing.contentFilter.update(query)
        for rv in self.listing.review_states:
            if "contentFilter" not in rv:
                rv["contentFilter"] = {}
            rv["contentFilter"].update(query)

        url = api.get_url(self.context)
        self.listing.context_actions = {
            _("Add"): {
                "url": "{}/createObject?type_name=Batch".format(url),
                "permission": AddBatch,
                "icon": "++resource++bika.lims.images/add.png"
            }
        }
示例#27
0
    def update(self):
        """Called before the listings renders
        """
        super(PatientsView, self).update()

        # Render the Add button. We need to do this here because patients live
        # inside site.patients folder
        self.context_actions = {}
        patients = api.get_portal().patients
        if security.check_permission(AddPatient, patients):
            self.context_actions = {
                _("Add"): {
                    "url": "createObject?type_name=Patient",
                    "icon": "++resource++bika.lims.images/add.png"}
            }

        # If the current user is a client contact, display those patients that
        # belong to same client or that do not belong to any client
        client = api.get_current_client()
        if client:
            query = dict(client_uid=[api.get_uid(client), "-1"])
            # We add UID "-1" to also include Patients w/o Client assigned
            self.contentFilter.update(query)
            for rv in self.review_states:
                rv["contentFilter"].update(query)

        # If the current context is a Client, remove the title column
        if IClient.providedBy(self.context):
            self.remove_column('getPrimaryReferrerTitle')
示例#28
0
    def before_render(self):
        # Additional columns
        self.add_columns()
        # Remove unnecessary columns
        self.hide_columns()

        # Apply client filter, if necessary
        client = api.get_current_client()
        if client:
            query = dict(getClientUID=api.get_uid(client))
            self.listing.contentFilter.update(query)
            for rv in self.listing.review_states:
                if "contentFilter" not in rv:
                    rv["contentFilter"] = {}
                rv["contentFilter"].update(query)

        # Render the Add button
        self.listing.context_actions = {}
        batches = api.get_portal().batches
        if security.check_permission(AddBatch, batches):
            url = api.get_url(batches)
            self.listing.context_actions = {
                _("Add"): {
                    "url": "{}/createObject?type_name=Batch".format(url),
                    "icon": "++resource++bika.lims.images/add.png"
                }
            }
示例#29
0
 def __call__(self):
     self.context_actions[_('Add')] = \
             {'url': self.portal.absolute_url() \
                     + '/batches/createObject?type_name=Batch',
              'icon': self.portal.absolute_url() \
                     + '/++resource++bika.lims.images/add.png'}
     return BatchFolderContentsView.__call__(self)
示例#30
0
    def before_render(self):
        # Additional columns
        self.add_columns()
        # Remove unnecessary columns
        self.hide_columns()

        # Apply client filter, if necessary
        client = api.get_current_client()
        if client:
            query = dict(getClientUID=api.get_uid(client))
            self.listing.contentFilter.update(query)
            for rv in self.listing.review_states:
                if "contentFilter" not in rv:
                    rv["contentFilter"] = {}
                rv["contentFilter"].update(query)

        # Render the Add button
        self.listing.context_actions = {}
        batches = api.get_portal().batches
        if security.check_permission(AddBatch, batches):
            url = api.get_url(batches)
            self.listing.context_actions = {
                _("Add"): {
                    "url": "{}/createObject?type_name=Batch".format(url),
                    "icon": "++resource++bika.lims.images/add.png"}
            }
示例#31
0
 def sendAlertEmail(self):
     # Send an alert email
     laboratory = self.context.bika_setup.laboratory
     subject = self.request.get('subject')
     to = self.request.get('to')
     body = self.request.get('body')
     body = "<br/>".join(body.split("\r\n"))
     mime_msg = MIMEMultipart('related')
     mime_msg['Subject'] = subject
     mime_msg['From'] = formataddr((encode_header(laboratory.getName()),
                                    laboratory.getEmailAddress()))
     mime_msg['To'] = to
     msg_txt = MIMEText(safe_unicode(body).encode('utf-8'), _subtype='html')
     mime_msg.preamble = 'This is a multi-part MIME message.'
     mime_msg.attach(msg_txt)
     succeed = False
     try:
         host = getToolByName(self.context, 'MailHost')
         host.send(mime_msg.as_string(), immediate=True)
     except Exception, msg:
         ar = self.context.id
         logger.error("Panic level email %s: %s" % (ar, str(msg)))
         message = _('Unable to send an email to alert client '
                     'that some results exceeded the panic levels') \
                                          + (": %s" % str(msg))
         self.addMessage(message, 'warning')
示例#32
0
    def fiddle(self, schema):

        # Add panic alert range columns
        validator = AnalysisSpecificationPanicValidator()
        schema['ResultsRange'].subfields += ('minpanic', 'maxpanic')
        schema['ResultsRange'].subfield_validators['minpanic'] = validator
        schema['ResultsRange'].subfield_validators['maxpanic'] = validator
        schema['ResultsRange'].subfield_labels['minpanic'] = _('Min panic')
        schema['ResultsRange'].subfield_labels['maxpanic'] = _('Max panic')
        srcwidget = schema['ResultsRange'].widget
        schema['ResultsRange'].widget = AnalysisSpecificationWidget(
                    checkbox_bound=srcwidget.checkbox_bound,
                    label=srcwidget.label,
                    description=srcwidget.description,
        )
        return schema
示例#33
0
    def update(self):
        """Called before the listings renders
        """
        super(PatientsView, self).update()

        # Render the Add button. We need to do this here because patients live
        # inside site.patients folder
        self.context_actions = {}
        patients = api.get_portal().patients
        if security.check_permission(AddPatient, patients):
            self.context_actions = {
                _("Add"): {
                    "url": "createObject?type_name=Patient",
                    "icon": "++resource++bika.lims.images/add.png"
                }
            }

        # If the current user is a client contact, display those patients that
        # belong to same client or that do not belong to any client
        client = api.get_current_client()
        if client:
            query = dict(client_uid=[api.get_uid(client), "-1"])
            # We add UID "-1" to also include Patients w/o Client assigned
            self.contentFilter.update(query)
            for rv in self.review_states:
                rv["contentFilter"].update(query)

        # If the current context is a Client, remove the title column
        if IClient.providedBy(self.context):
            self.remove_column('getPrimaryReferrerTitle')
示例#34
0
    def folderitem(self, obj, item, index):
        # Date of Birth
        dob = obj.getBirthDate
        item['getBirthDate'] = dob and self.ulocalized_time(dob) or ""
        try:
            item["age"] = dob and get_age_ymd(dob) or ""
        except:
            # Wrong date??
            msg = _("Date of Birth might be wrong")
            img = get_image("exclamation.png", title=msg)
            item["replace"]["age"] = img

        # make the columns patient title, patient ID and client patient ID
        # redirect to the Analysis Requests of the patient
        ars_url = "{}/{}".format(api.get_url(obj), "analysisrequests")
        for column in ['Title', 'getPatientID', 'getClientPatientID']:
            value = getattr(obj, column, None)
            if value:
                item["replace"][column] = get_link(ars_url, value)

        # Display the internal/external icons, but only if the logged-in user
        # does not belong to an external client
        if not self.is_external_user():
            # Renders an icon (shared/private/warn) next to the title of the
            # item based on the client
            item["before"]["Title"] = get_client_aware_html_image(obj)

        return item
示例#35
0
    def process_form(self):

        num_analyses = 0
        uids_arr = [
            ar.get('Analyses', []) for ar in self.valid_states.values()
        ]
        for arr in uids_arr:
            num_analyses += len(arr)

        if num_analyses < 50:
            # Do not process Asynchronously
            return AnalysisRequestSubmit.process_form(self)

        # Only load asynchronously if queue ar-create is available
        task_queue = queryUtility(ITaskQueue, name='ar-create')
        if task_queue is None:
            # ar-create queue not registered, create synchronously
            return AnalysisRequestSubmit.process_form(self)
        else:
            # ar-create queue registered, create asynchronously
            path = self.request.PATH_INFO
            path = path.replace('_submit_async', '_submit')
            task_queue.add(path, method='POST')
            msg = _('One job added to the Analysis Request creation queue')
            self.context.plone_utils.addPortalMessage(msg, 'info')
            return json.dumps({'success': 'With taskqueue'})
示例#36
0
    def _initFormParams(self):
        mtool = getToolByName(self.context, 'portal_membership')
        addPortalMessage = self.context.plone_utils.addPortalMessage
        can_add_patients = mtool.checkPermission(AddPatient, self.context)

        if not can_add_patients and IClient.providedBy(self.context):
            # The user logged in is a Contact from this Client?
            # Tip: when a client contact is created, bika.lims assigns that
            # contact as the owner of the client, so he/she can access to the
            # Client he/she is owner of but not to the rest of Clients.
            # See bika.lims.browser.contact._link_user(userid)
            client = self.context
            owners = client.users_with_local_role('Owner')
            member = mtool.getAuthenticatedMember()
            can_add_patients = member.id in owners

        if can_add_patients:
            # TODO Performance tweak. Is this really needed?
            clients = self.context.clients.objectIds()
            if clients:
                add_patient_url = '{}/patients/createObject?type_name=Patient'\
                                  .format(self.portal_url)
                self.context_actions[_b('Add')] = {
                    'url': add_patient_url,
                    'icon': '++resource++bika.lims.images/add.png'
                }
            else:
                msg = _("Cannot create patients without any system clients "
                        "configured.")
                addPortalMessage(self.context.translate(msg))

        if mtool.checkPermission(ViewPatients, self.context):
            self.review_states[0]['transitions'].append({'id': 'deactivate'})
            self.review_states.append({
                'id': 'inactive',
                'title': _b('Dormant'),
                'contentFilter': {
                    'inactive_state': 'inactive'
                },
                'transitions': [
                    {
                        'id': 'activate'
                    },
                ],
                'columns': self.get_columns()
            })
            self.review_states.append({
                'id': 'all',
                'title': _b('All'),
                'contentFilter': {},
                'transitions': [
                    {
                        'id': 'empty'
                    },
                ],
                'columns': self.get_columns()
            })
            stat = self.request.get("%s_review_state" % self.form_id,
                                    'default')
            self.show_select_column = stat != 'all'
示例#37
0
    def fiddle(self, schema):

        # Add panic alert range columns
        validator = AnalysisSpecificationPanicValidator()
        schema['ResultsRange'].subfields += ('minpanic', 'maxpanic')
        schema['ResultsRange'].subfield_validators['minpanic'] = validator
        schema['ResultsRange'].subfield_validators['maxpanic'] = validator
        schema['ResultsRange'].subfield_labels['minpanic'] = _('Min panic')
        schema['ResultsRange'].subfield_labels['maxpanic'] = _('Max panic')
        srcwidget = schema['ResultsRange'].widget
        schema['ResultsRange'].widget = AnalysisSpecificationWidget(
                    checkbox_bound=srcwidget.checkbox_bound,
                    label=srcwidget.label,
                    description=srcwidget.description,
        )
        return schema
示例#38
0
 def __call__(self):
     self.context_actions[_('Add')] = \
             {'url': self.portal.absolute_url() \
                     + '/batches/createObject?type_name=Batch',
              'icon': self.portal.absolute_url() \
                     + '/++resource++bika.lims.images/add.png'}
     return BatchFolderContentsView.__call__(self)
示例#39
0
    def validate_form(self):
        # Create new Anonymous Patients as needed
        uc = getToolByName(self.context, 'uid_catalog')
        cpt = getToolByName(self.context, CATALOG_PATIENT_LISTING)
        form = self.request.form
        formc = self.request.form.copy()
        state = json.loads(formc.get('state'))
        if not state:
            # BaseClass deals with state
            BaseClass.validate_form(self)
            return

        for key in state.keys():
            values = state[key].copy()
            patuid = values.get('Patient', '')
            if patuid == '' and values.get('Analyses') != []:
                msg = t(_('Required fields have no values: Patient'))
                ajax_form_error(self.errors, arnum=key, message=msg)
                continue
            elif patuid == 'anonymous':
                clientpatientid = values.get('ClientPatientID', '')
                # Check if has already been created
                proxies = cpt(getClientPatientID=clientpatientid)
                if proxies and len(proxies) > 0:
                    patient = proxies[0].getObject()
                else:
                    # Create an anonymous patient
                    client = uc(UID=values['Client'])[0].getObject()
                    _id = client.patients.invokeFactory('Patient', id=tmpID())
                    patient = client.patients[_id]
                    patient.edit(Anonymous=1,
                                 Gender="dk",
                                 PrimaryReferrer=client.UID(),
                                 Firstname=_("AP"),
                                 Surname=clientpatientid,
                                 ClientPatientID=clientpatientid)
                    patient.unmarkCreationFlag()
                    patient.reindexObject()
                    client.reindexObject()
                    renameAfterCreation(patient)

                values['Patient'] = patient.UID()
                state[key] = values
        formc['state'] = json.JSONEncoder().encode(state)
        self.request.form = formc
        BaseClass.validate_form(self)
示例#40
0
def get_client_aware_html_image(obj):
    """Renders an icon based on the client the object belongs to
    """
    if is_from_external_client(obj):
        icon_info = ("lock.png", _("Private, from an external client"))

    elif is_from_internal_client(obj):
        if api.get_review_status(obj) == "shared":
            icon_info = ("share.png", _("Shared, from an internal client"))
        else:
            icon_info = ("share_lock.png",
                         _("From an internal client, but not shared"))
    else:
        logger.warn("No client assigned for {}".format(repr(obj)))
        icon_info = ("exclamation_red.png", _("No client assigned"))

    return get_html_image(icon_info[0], title=icon_info[1])
示例#41
0
 def __init__(self, context, request):
     super(HistoricResultsView, self).__init__(context, request)
     self._rows = None
     self._dates = None
     path = "/++resource++bika.health.images"
     self.icon = self.portal_url + path + "/historicresults_big.png"
     self.title = self.context.translate(_("Historic Results"))
     self.description = ""
示例#42
0
 def fiddle(self, schema):
     schema['title'].required = False
     schema['title'].widget.visible = False
     schema['description'].required = False
     schema['description'].widget.visible = False
     schema['BatchLabels'].widget.visible = False
     schema['ClientBatchID'].widget.label = _("Client Case ID")
     return schema
示例#43
0
 def __init__(self, context, request):
     super(AnalysisRequestsView, self).__init__(context, request)
     self.columns['BatchID']['title'] = _('Case ID')
     # Add Client Patient fields
     self.columns['getPatientID'] = {
         'title': _('Patient ID'),
     }
     self.columns['getClientPatientID'] = {
         'title': _("Client PID"),
         'sortable': False,
     }
     self.columns['getPatientTitle'] = {
         'title': _('Patient'),
     }
     self.columns['getDoctorTitle'] = {
         'title': _('Doctor'),
     }
示例#44
0
    def __init__(self, context, request):
        super(VaccinationCentersView, self).__init__(context, request)
        self.catalog = 'bika_setup_catalog'
        self.contentFilter = {'portal_type': 'VaccinationCenter',
                              'sort_on': 'getName'}
        self.context_actions = {_('Add'):
                                {'url': 'createObject?type_name=VaccinationCenter',
                                 'icon': '++resource++bika.lims.images/add.png'}}
        self.title = self.context.translate(_("Vaccination Centers"))
        self.icon = self.portal_url + "/++resource++bika.health.images/vaccinationcenter_big.png"
        self.description = ""
        self.show_sort_column = False
        self.show_select_row = False
        self.show_select_column = True
        self.pagesize = 50

        self.columns = {
            'Name': {'title': _('Name'),
                     'index': 'getName'},
            'Email': {'title': _('Email'),
                      'toggle': True},
            'Phone': {'title': _('Phone'),
                      'toggle': True},
            'Fax': {'title': _('Fax'),
                    'toggle': True},
        }
        self.review_states = [
            {'id':'default',
             'title': _('Active'),
             'contentFilter': {'is_active': True},
             'transitions': [{'id':'deactivate'}, ],
             'columns': ['Name',
                         'Email',
                         'Phone',
                         'Fax']},
            {'id':'inactive',
             'title': _('Dormant'),
             'contentFilter': {'is_active': False},
             'transitions': [{'id':'activate'}, ],
             'columns': ['Name',
                         'Email',
                         'Phone',
                         'Fax']},
            {'id':'all',
             'title': _('All'),
             'contentFilter':{},
             'columns': ['Name',
                         'Email',
                         'Phone',
                         'Fax']},
        ]
示例#45
0
def setup_panic_alerts(portal):
    """Setups the template texts for panic alert email's subject and body
    """
    email_body = _(
        "Some results from the Sample ${sample_id} exceeded the panic levels "
        "that may indicate an imminent life-threatening condition:\n\n"
        "${analyses}\n\n--\n${lab_address}")
    ploneapi.portal.set_registry_record("senaite.panic.email_body", email_body)
示例#46
0
    def __init__(self, context, request):
        super(DoctorsView, self).__init__(context, request)
        self.contentFilter = {'portal_type': 'Doctor',
                              'sort_on': 'sortable_title'}
        self.context_actions = {}
        self.title = self.context.translate(_("Doctors"))
        self.icon = self.portal_url + "/++resource++bika.health.images/doctor_big.png"
        self.description = ""
        self.show_sort_column = False
        self.show_select_row = False
        self.show_select_column = False
        self.pagesize = 50

        self.columns = {
            'getDoctorID': {'title': _('Doctor ID'),
                            'index': 'getDoctorID'},
            'getFullname': {'title': _('Full Name'),
                            'index': 'getFullname'},
            'getEmailAddress': {'title': _('Email Address')},
            'getBusinessPhone': {'title': _('Business Phone')},
            'getMobilePhone': {'title': _('Mobile Phone')},
        }

        self.review_states = [
            {'id':'default',
             'title': _('Active'),
             'contentFilter': {'inactive_state': 'active'},
             'transitions': [],
             'columns': ['getDoctorID',
                         'getFullname',
                         'getEmailAddress',
                         'getBusinessPhone',
                         'getMobilePhone']},
        ]
示例#47
0
 def __call__(self):
     mtool = getToolByName(self.context, 'portal_membership')
     if mtool.checkPermission(AddDoctor, self.context):
         self.context_actions[_('Add')] = {
             'url': 'createObject?type_name=Doctor',
             'icon': '++resource++bika.lims.images/add.png'
         }
     if mtool.checkPermission(ManageDoctors, self.context):
         self.review_states[0]['transitions'].append({'id': 'deactivate'})
         self.review_states.append({
             'id':
             'inactive',
             'title':
             _('Dormant'),
             'contentFilter': {
                 'inactive_state': 'inactive'
             },
             'transitions': [
                 {
                     'id': 'activate'
                 },
             ],
             'columns': [
                 'getDoctorID', 'getFullname', 'getEmailAddress',
                 'getBusinessPhone', 'getMobilePhone'
             ]
         })
         self.review_states.append({
             'id':
             'all',
             'title':
             _('All'),
             'contentFilter': {},
             'transitions': [{
                 'id': 'empty'
             }],
             'columns': [
                 'getDoctorID', 'getFullname', 'getEmailAddress',
                 'getBusinessPhone', 'getMobilePhone'
             ]
         })
         stat = self.request.get("%s_review_state" % self.form_id,
                                 'default')
         self.show_select_column = stat != 'all'
     return super(DoctorsView, self).__call__()
示例#48
0
 def getEthnicitiesVocabulary(self, instance=None):
     """
     Obtain all the ethnicities registered in the system and returns them as a list
     """
     bsc = getToolByName(self, "bika_setup_catalog")
     items = [(c.UID, c.Title) for c in bsc(portal_type="Ethnicity", inactive_state="active")]
     items.sort(lambda x, y: cmp(x[1], y[1]))
     items.insert(0, ("", t(_(""))))
     return DisplayList(items)
示例#49
0
    def __init__(self, context, request):
        super(DoctorsView, self).__init__(context, request)

        # Add new column definitions
        self.columns.extend({
            'AFerret': {
                'title': _('A Ferret')
            },
            'AField': {
                'title': _('A Field')
            },
        })

        # all dicts in self.review_states have a list of columns,
        # which we must update.  We will choose to show the new
        # fields in all filter states:
        for i in len(self.review_states):
            self.review_states[i]['columns'].append('AFerret', 'AField')
示例#50
0
    def __init__(self,context,request):
        super(SymptomsView,self).__init__(context,request)
        self.catalog='bika_setup_catalog'
        self.contentFilter={'portal_type': 'Symptom',
                              'sort_on': 'sortable_title'}
        self.context_actions={_('Add'):
                                {'url': 'createObject?type_name=Symptom',
                                 'icon': '++resource++bika.lims.images/add.png'}}
        self.title=_("Symptoms")
        self.icon = self.portal_url + "/++resource++bika.health.images/symptom_big.png"
        self.description=_("Additional Symptoms not covered by ICD codes, can be entered here.")
        self.show_sort_column=False
        self.show_select_row=False
        self.show_select_column=True
        self.pagesize=25

        self.columns={
            'Title': {'title': _('Symptom'),
                      'index':'sortable_title'},
            'Description': {'title': _('Description'),
                            'index': 'description',
                            'toggle': True},
            'Gender': {'title': _('Gender'),
                            'index': 'gender',
                            'toggle': True},
        }

        self.review_states=[
            {'id':'default',
             'title': _('Active'),
             'contentFilter': {'inactive_state': 'active'},
             'transitions': [{'id':'deactivate'},],
             'columns': ['Title',
                         'Description',
                         'Gender']},
            {'id':'inactive',
             'title': _('Dormant'),
             'contentFilter': {'inactive_state': 'inactive'},
             'transitions': [{'id':'activate'},],
             'columns': ['Title',
                         'Description',
                         'Gender']},
            {'id':'all',
             'title': _('All'),
             'contentFilter':{},
             'columns': ['Title',
                         'Description',
                         'Gender']},
        ]
示例#51
0
    def __init__(self,context,request):
        super(SymptomsView,self).__init__(context,request)
        self.catalog='bika_setup_catalog'
        self.contentFilter={'portal_type': 'Symptom',
                              'sort_on': 'sortable_title'}
        self.context_actions={_('Add'):
                                {'url': 'createObject?type_name=Symptom',
                                 'icon': '++resource++bika.lims.images/add.png'}}
        self.title=self.context.translate(_("Symptoms"))
        self.icon = self.portal_url + "/++resource++bika.health.images/symptom_big.png"
        self.description=_("Additional Symptoms not covered by ICD codes, can be entered here.")
        self.show_sort_column=False
        self.show_select_row=False
        self.show_select_column=True
        self.pagesize=25

        self.columns={
            'Title': {'title': _('Symptom'),
                      'index':'sortable_title'},
            'Description': {'title': _('Description'),
                            'index': 'description',
                            'toggle': True},
            'Gender': {'title': _('Gender'),
                            'index': 'getGender',
                            'toggle': True},
        }

        self.review_states=[
            {'id':'default',
             'title': _('Active'),
             'contentFilter': {'is_active': True},
             'transitions': [{'id':'deactivate'},],
             'columns': ['Title',
                         'Description',
                         'Gender']},
            {'id':'inactive',
             'title': _('Dormant'),
             'contentFilter': {'is_active': False},
             'transitions': [{'id':'activate'},],
             'columns': ['Title',
                         'Description',
                         'Gender']},
            {'id':'all',
             'title': _('All'),
             'contentFilter':{},
             'columns': ['Title',
                         'Description',
                         'Gender']},
        ]
    def __init__(self, context, request):
        super(EpidemiologicalYearsView, self).__init__(context, request)
        self.catalog = 'bika_setup_catalog'
        self.contentFilter = {'portal_type': 'EpidemiologicalYear',
                              'sort_on': 'sortable_title'}
        self.context_actions = {_('Add'):
                                {'url': 'createObject?type_name=EpidemiologicalYear',
                                 'icon': '++resource++bika.lims.images/add.png'}}
        self.title = self.context.translate(_("Epidemiological Years"))
        self.icon = self.portal_url + "/++resource++bika.health.images/epidemiologicalyear_big.png"
        self.description = _("Epidemiological year calendars")
        self.show_sort_column = False
        self.show_select_row = False
        self.show_select_column = True
        self.pagesize = 25

        self.columns = {
            'Title': {'title': _('Title'),
                     'index':'sortable_title'},

            'getStartDate': {'title':_('Start Date'),
                             'index':'getStartDate'},

            'getEndDate': {'title':_('End Date'),
                           'index': 'getEndDate'},
        }

        self.review_states = [
            {'id':'default',
             'title': _('Active'),
             'contentFilter': {'inactive_state': 'active'},
             'transitions': [{'id':'deactivate'}, ],
             'columns': ['Title',
                         'getStartDate',
                         'getEndDate']},
            {'id':'inactive',
             'title': _('Dormant'),
             'contentFilter': {'inactive_state': 'inactive'},
             'transitions': [{'id':'activate'}, ],
             'columns': ['Title',
                         'getStartDate',
                         'getEndDate']},
            {'id':'all',
             'title': _('All'),
             'contentFilter':{},
             'columns': ['Title',
                         'getStartDate',
                         'getEndDate']},
        ]
示例#53
0
 def __init__(self, context, request):
     BrowserView.__init__(self, context, request)
     self.context = context
     self.request = request
     self._rows = None
     self._dates = None
     path = "/++resource++bika.health.images"
     self.icon = self.portal_url + path + "/historicresults_big.png"
     self.title = self.context.translate(_("Historic Results"))
     self.description = ""
示例#54
0
 def fiddle(self, schema):
     schema['title'].required = False
     schema['title'].widget.visible = False
     schema['description'].required = False
     schema['description'].widget.visible = False
     schema['BatchLabels'].widget.visible = False
     schema['ClientBatchID'].widget.label = _("Client Case ID")
     schema['BatchDate'].widget.visible = False
     schema['InheritedObjectsUI'].widget.visible = False
     return schema
示例#55
0
 def getEthnicitiesVocabulary(self, instance=None):
     """
     Obtain all the ethnicities registered in the system and returns them as a list
     """
     bsc = getToolByName(self, 'bika_setup_catalog')
     items = [(c.UID, c.Title)
              for c in bsc(portal_type='Ethnicity', is_active=True)]
     items.sort(lambda x, y: cmp(x[1], y[1]))
     items.insert(0, ('', t(_(''))))
     return DisplayList(items)
示例#56
0
    def __call__(self):

        # Create new Anonymous Patients as needed
        uc = getToolByName(self.context, 'uid_catalog')
        bpc = getToolByName(self.context, 'bika_patient_catalog')
        form = self.request.form
        formc = self.request.form.copy()
        state = json.loads(formc['state'])
        for key in state.keys():
            values = state[key].copy()
            patuid = values.get('Patient', '')
            if patuid == '' and values.get('Analyses') != []:
                msg = t(_('Required fields have no values: Patient'))
                ajax_form_error(self.errors, arnum=key, message=msg)
                continue
            elif patuid == 'anonymous':
                clientpatientid = values.get('ClientPatientID', '')
                # Check if has already been created
                proxies = bpc(getClientPatientID=clientpatientid)
                if proxies and len(proxies) > 0:
                    patient = proxies[0].getObject()
                else:
                    # Create an anonymous patient
                    client = uc(UID=values['Client'])[0].getObject()
                    _id = client.patients.invokeFactory('Patient', id=tmpID())
                    patient = client.patients[_id]
                    patient.edit(Anonymous = 1,
                                 Gender = "dk",
                                 PrimaryReferrer = client.UID(),
                                 Firstname = _("AP"),
                                 Surname = clientpatientid,
                                 ClientPatientID = clientpatientid)
                    patient.unmarkCreationFlag()
                    patient.reindexObject()
                    client.reindexObject()
                    renameAfterCreation(patient)

                values['Patient']=patient.UID()
                state[key] = values
        formc['state'] = json.JSONEncoder().encode(state)
        self.request.form = formc
        return BaseClass.__call__(self)
示例#57
0
 def getEthnicitiesVocabulary(self, instance=None):
     """
     Obtain all the ethnicities registered in the system and returns them as a list
     """
     bsc = getToolByName(self, 'bika_setup_catalog')
     items = [(c.UID, c.Title)
              for c in bsc(portal_type='Ethnicity',
                           is_active=True)]
     items.sort(lambda x, y: cmp(x[1], y[1]))
     items.insert(0, ('', t(_(''))))
     return DisplayList(items)
示例#58
0
 def fiddle(self, schema):
     schema['title'].required = False
     schema['title'].widget.visible = False
     schema['description'].required = False
     schema['description'].widget.visible = False
     schema['BatchLabels'].widget.visible = False
     schema['ClientBatchID'].widget.label = _("Client Case ID")
     schema['BatchDate'].widget.visible = False
     schema['InheritedObjectsUI'].widget.visible = False
     schema['Doctor'].required = isCaseDoctorIsMandatory()
     return schema