Ejemplo n.º 1
0
    def folder_item(self, obj, item, index):
        batch = api.get_object(obj)
        # Doctor
        doctor = get_field_value(batch, "Doctor", None)
        item["Doctor"] = doctor and doctor.Title() or ""
        item["replace"]["Doctor"] = doctor and get_link(
            api.get_url(doctor), doctor.Title())
        # Onset Date
        onset = get_field_value(batch, "OnsetDate", None)
        item["OnsetDate"] = onset and self.listing.ulocalized_time(onset) or ""

        # Patient
        item["Patient"] = ""
        item["getPatientID"] = ""
        item["getClientPatientID"] = ""
        patient = get_field_value(batch, "Patient", None)
        if patient:
            url = api.get_url(patient)
            item["Patient"] = patient.Title()
            item["replace"]["Patient"] = get_link(url, patient.Title())

            item["getPatientID"] = patient.id
            item["replace"]["getPatientID"] = get_link(url, patient.id)

            pid = patient.getClientPatientID()
            pid_link = pid and get_link(url, pid) or ""
            item["getClientPatientID"] = pid or ""
            item["replace"]["getClientPatientID"] = pid_link

        return item
Ejemplo n.º 2
0
    def folder_item(self, obj, item, index):
        batch = api.get_object(obj)
        # Doctor
        doctor = get_field_value(batch, "Doctor", None)
        item["Doctor"] = doctor and doctor.Title() or ""
        item["replace"]["Doctor"] = doctor and get_link(api.get_url(doctor),
                                                        doctor.Title())
        # Onset Date
        onset = get_field_value(batch, "OnsetDate", None)
        item["OnsetDate"] = onset and self.listing.ulocalized_time(onset) or ""

        # Patient
        item["Patient"] = ""
        item["getPatientID"] = ""
        item["getClientPatientID"] = ""
        patient = get_field_value(batch, "Patient", None)
        if patient:
            url = api.get_url(patient)
            item["Patient"] = patient.Title()
            item["replace"]["Patient"] = get_link(url, patient.Title())

            item["getPatientID"] = patient.id
            item["replace"]["getPatientID"] = get_link(url, patient.id)

            pid = patient.getClientPatientID()
            pid_link = pid and get_link(url, pid) or ""
            item["getClientPatientID"] = pid or ""
            item["replace"]["getClientPatientID"] = pid_link

        return item
Ejemplo n.º 3
0
    def folderitem(self, obj, item, index):
        item = super(QCAnalysesView, self).folderitem(obj, item, index)

        obj = self.get_object(obj)

        # Fill Worksheet cell
        worksheet = obj.getWorksheet()
        if not worksheet:
            return item

        # Fill the Worksheet cell
        ws_id = api.get_id(worksheet)
        ws_url = api.get_url(worksheet)
        item["replace"]["Worksheet"] = get_link(ws_url, value=ws_id)

        if IDuplicateAnalysis.providedBy(obj):
            an_type = "d"
            img_name = "duplicate.png"
            parent = obj.getRequest()
        else:
            an_type = obj.getReferenceType()
            img_name = an_type == "c" and "control.png" or "blank.png"
            parent = obj.aq_parent

        # Render the image
        an_type = QCANALYSIS_TYPES.getValue(an_type)
        item['before']['Service'] = get_image(img_name, title=an_type)

        # Fill the Parent cell
        parent_url = api.get_url(parent)
        parent_id = api.get_id(parent)
        item["replace"]["Parent"] = get_link(parent_url, value=parent_id)

        return item
Ejemplo n.º 4
0
    def folderitem(self, obj, item, index):
        """Applies new properties to the item to be rendered
        """
        obj = api.get_object(obj)
        # Replace client name with the link
        item['getPrimaryReferrer'] = ""
        client = obj.getClient()
        if client:
            client_link = get_link(api.get_url(client), api.get_title(client))
            item["replace"]["getPrimaryReferrer"] = client_link

        # Replace doctor's full name with a link
        fullname = obj.getFullname()
        doctor_url = "{}/analysisrequests".format(api.get_url(obj))
        doctor_link = get_link(doctor_url, fullname)
        item["replace"]["getFullname"] = doctor_link
        doctor_link = get_link(doctor_url, obj.getDoctorID())
        item["replace"]["getDoctorID"] = doctor_link

        # Replace doctor's full name with a link
        email = obj.getEmailAddress()
        if email:
            item["replace"]['getEmailAddress'] = get_email_link(email)

        # 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():
            item["before"]["getFullname"] = get_client_aware_html_image(obj)

        return item
Ejemplo n.º 5
0
    def folderitem(self, obj, item, index):
        """Service triggered each time an item is iterated in folderitems.
        The use of this service prevents the extra-loops in child objects.
        :obj: the instance of the class to be foldered
        :item: dict containing the properties of the object to be used by
            the template
        :index: current index of the item
        """
        title = obj.Title()
        url = obj.absolute_url()

        item["replace"]["Title"] = get_link(url, value=title)

        sampletype = obj.getSampleType()
        if sampletype:
            title = sampletype.Title()
            url = sampletype.absolute_url()
            item["replace"]["SampleType"] = get_link(url, value=title)

        dynamic_spec = obj.getDynamicAnalysisSpec()
        if dynamic_spec:
            title = dynamic_spec.Title()
            url = api.get_url(dynamic_spec)
            item["replace"]["DynamicSpec"] = get_link(url, value=title)

        return item
Ejemplo n.º 6
0
    def folderitem(self, obj, item, index):
        item = super(AnalysisRequestsView, self)\
            .folderitem(obj, item, index)

        url = '{}/analysisrequests'.format(obj.getPatientURL)
        item['getPatientID'] = obj.getPatientID
        item['getPatientTitle'] = obj.getPatientTitle
        item['getClientPatientID'] = obj.getClientPatientID

        # Replace with Patient's URLs
        if obj.getClientPatientID:
            item['replace']['getClientPatientID'] = get_link(
                url, obj.getClientPatientID)

        if obj.getPatientTitle:
            item['replace']['getPatientTitle'] = get_link(
                url, obj.getPatientTitle)

        if obj.getPatientID:
            item['replace']['getPatientID'] = get_link(url, obj.getPatientID)

        # Doctor
        item['getDoctorTitle'] = obj.getDoctorTitle
        if obj.getDoctorURL:
            url = '{}/analysisrequests'.format(obj.getDoctorURL)
            item['replace']['getDoctorTitle'] = get_link(
                url, obj.getDoctorTitle)

        return item
Ejemplo n.º 7
0
    def folderitem(self, obj, item, index):
        """Service triggered each time an item is iterated in folderitems.
        The use of this service prevents the extra-loops in child objects.
        :obj: the instance of the class to be foldered
        :item: dict containing the properties of the object to be used by
            the template
        :index: current index of the item
        """
        obj = api.get_object(obj)
        title = obj.Title()
        description = obj.Description()
        url = obj.absolute_url()

        item["replace"]["Title"] = get_link(url, value=title)
        item["Description"] = description

        item["Manager"] = ""
        item["ManagerPhone"] = ""
        item["ManagerEmail"] = ""
        manager = obj.getManager()
        if manager:
            manager_name = manager.getFullname()
            item["Manager"] = manager_name

            manager_url = manager.absolute_url()
            item["replace"]["Manager"] = get_link(manager_url, manager_name)

            manager_email = manager.getEmailAddress()
            item["replace"]["ManagerEmail"] = get_email_link(
                manager_email, value=manager_email)

            item["ManagerPhone"] = manager.getBusinessPhone()

        return item
Ejemplo n.º 8
0
    def folderitem(self, obj, item, index):
        """Applies new properties to the item (Client) that is currently being
        rendered as a row in the list

        :param obj: client to be rendered as a row in the list
        :param item: dict representation of the client, suitable for the list
        :param index: current position of the item within the list
        :type obj: ATContentType/DexterityContentType
        :type item: dict
        :type index: int
        :return: the dict representation of the item
        :rtype: dict
        """
        # render a link to the defined start page
        link_url = "{}/{}".format(item["url"], self.landing_page)
        item["replace"]["title"] = get_link(link_url, item["title"])
        item["replace"]["getClientID"] = get_link(link_url,
                                                  item["getClientID"])
        # render an email link
        item["replace"]["EmailAddress"] = get_email_link(item["EmailAddress"])
        # translate True/FALSE values
        item["replace"]["BulkDiscount"] = obj.getBulkDiscount() and _(
            "Yes") or _("No")
        item["replace"][
            "MemberDiscountApplies"] = obj.getMemberDiscountApplies() and _(
                "Yes") or _("No")
        # render a phone link
        phone = obj.getPhone()
        if phone:
            item["replace"]["Phone"] = get_link("tel:{}".format(phone), phone)
        return item
Ejemplo n.º 9
0
    def folderitem(self, obj, item, idx):
        """
        Replace or add the required/wanted fields for each invoice
        in the item dictionary

        :param obj: the instance of the class to be foldered. In our case, an
                    Invoice
        :param item: dict containing the properties of the object to be used by
                     the template
        :return: dictionary with the updated fields of the invoice being processed
        """
        currency = currency_format(self.context, 'en')
        item['replace']['id'] = get_link(api.get_url(obj), obj.getId())
        client = obj.getClient()
        if client:
            item['client'] = client.Title()
            item['replace']['client'] = get_link(client.absolute_url(),
                                                 item['client'])
            item['email'] = client.getEmailAddress()
            item['replace']['email'] = get_email_link(client.getEmailAddress())
            item['phone'] = client.getPhone()
        else:
            item['client'] = ''
            item['email'] = ''
            item['phone'] = ''

        item['invoicedate'] = self.ulocalized_time(obj.getInvoiceDate())
        item['startdate'] = self.ulocalized_time(obj.getBatchStartDate())
        item['enddate'] = self.ulocalized_time(obj.getBatchEndDate())
        item['subtotal'] = currency(obj.getSubtotal())
        item['vatamount'] = currency(obj.getVATAmount())
        item['total'] = currency(obj.getTotal())

        return item
Ejemplo n.º 10
0
    def folderitem(self, obj, item, index):
        item = super(AnalysisRequestsView, self)\
            .folderitem(obj, item, index)

        url = '{}/analysisrequests'.format(obj.getPatientURL)
        item['getPatientID'] = obj.getPatientID
        item['getPatientTitle'] = obj.getPatientTitle
        item['getClientPatientID'] = obj.getClientPatientID

        # Replace with Patient's URLs
        if obj.getClientPatientID:
            item['replace']['getClientPatientID'] = get_link(
                url, obj.getClientPatientID)

        if obj.getPatientTitle:
            item['replace']['getPatientTitle'] = get_link(
                url, obj.getPatientTitle)

        if obj.getPatientID:
            item['replace']['getPatientID'] = get_link(url, obj.getPatientID)

        # Doctor
        item['getDoctorTitle'] = obj.getDoctorTitle
        if obj.getDoctorURL:
            url = '{}/analysisrequests'.format(obj.getDoctorURL)
            item['replace']['getDoctorTitle'] = get_link(url, obj.getDoctorTitle)

        return item
Ejemplo n.º 11
0
    def folderitem(self, obj, item, index):
        obj = api.get_object(obj)
        url = api.get_url(obj)

        # MRN
        mrn = obj.get_mrn().encode("utf8")
        item["mrn"] = mrn
        item["replace"]["mrn"] = get_link(url, value=mrn)

        # Patient ID
        patient_id = obj.get_patient_id().encode("utf8")
        item["patient_id"] = patient_id
        if patient_id:
            item["replace"]["patient_id"] = get_link(url, value=patient_id)

        # Fullname
        fullname = obj.get_fullname().encode("utf8")
        item["fullname"] = fullname
        if fullname:
            item["replace"]["fullname"] = get_link(url, value=fullname)

        # Email
        email = obj.get_email()
        item["email"] = email
        if email:
            item["replace"]["email"] = get_email_link(email, value=email)

        # Gender
        item["gender"] = obj.get_gender()

        # Birthdate
        birthdate = obj.get_birthdate()
        item["birthdate"] = self.ulocalized_time(birthdate, long_format=0)

        return item
Ejemplo n.º 12
0
    def folderitem(self, obj, item, index):
        item = super(InstrumentReferenceAnalysesView,
                     self).folderitem(obj, item, index)
        analysis = api.get_object(obj)

        # Partition is used to group/toggle QC Analyses
        sample = analysis.getSample()
        item["replace"]["Partition"] = get_link(api.get_url(sample),
                                                api.get_id(sample))

        # Get retractions field
        item["Retractions"] = ""
        report = analysis.getRetractedAnalysesPdfReport()
        if report:
            url = api.get_url(analysis)
            href = "{}/at_download/RetractedAnalysesPdfReport".format(url)
            attrs = {"class": "pdf", "target": "_blank"}
            title = _("Retractions")
            link = get_link(href, title, **attrs)
            item["Retractions"] = title
            item["replace"]["Retractions"] = link

        # Add the analysis to the QC Chart
        self.chart.add_analysis(analysis)

        return item
Ejemplo n.º 13
0
    def folderitem(self, obj, item, index):
        """Service triggered each time an item is iterated in folderitems.
        The use of this service prevents the extra-loops in child objects.
        :obj: the instance of the class to be foldered
        :item: dict containing the properties of the object to be used by
            the template
        :index: current index of the item
        """
        item["Description"] = obj.Description()
        item["replace"]["Title"] = get_link(item["url"], item["Title"])

        instrument = obj.getInstrument()
        if instrument:
            instrument_url = api.get_url(instrument)
            instrument_title = api.get_title(instrument)
            item["Instrument"] = instrument_title
            item["replace"]["Instrument"] = get_link(
                instrument_url, value=instrument_title)

        # Method
        method_uid = obj.getMethodUID()
        if method_uid:
            method = api.get_object_by_uid(method_uid)
            method_url = api.get_url(method)
            method_title = api.get_title(method)
            item["Method"] = method_title
            item["replace"]["Method"] = get_link(
                method_url, value=method_title)

        return item
Ejemplo n.º 14
0
    def folderitem(self, obj, item, index):
        """Service triggered each time an item is iterated in folderitems.

        The use of this service prevents the extra-loops in child objects.

        :obj: the instance of the class to be foldered
        :item: dict containing the properties of the object to be used by
            the template
        :index: current index of the item
        """
        # ensure we have an object and not a brain
        obj = api.get_object(obj)
        uid = api.get_uid(obj)
        url = api.get_url(obj)
        title = api.get_title(obj)

        # get the category
        if self.show_categories_enabled():
            category = obj.getCategoryTitle()
            if category not in self.categories:
                self.categories.append(category)
            item["category"] = category

        config = self.configuration.get(uid, {})
        hidden = config.get("hidden", False)

        item["replace"]["Title"] = get_link(url, value=title)
        item["Price"] = self.format_price(obj.Price)
        item["allow_edit"] = self.get_editable_columns()
        item["selected"] = False
        item["Hidden"] = hidden
        item["selected"] = uid in self.configuration

        # Add methods
        methods = obj.getMethods()
        if methods:
            links = map(
                lambda m: get_link(
                    m.absolute_url(), value=m.Title(), css_class="link"),
                methods)
            item["replace"]["Methods"] = ", ".join(links)
        else:
            item["methods"] = ""

        # Icons
        after_icons = ""
        if obj.getAccredited():
            after_icons += get_image(
                "accredited.png", title=_("Accredited"))
        if obj.getAttachmentOption() == "r":
            after_icons += get_image(
                "attach_reqd.png", title=_("Attachment required"))
        if obj.getAttachmentOption() == "n":
            after_icons += get_image(
                "attach_no.png", title=_("Attachment not permitted"))
        if after_icons:
            item["after"]["Title"] = after_icons

        return item
Ejemplo n.º 15
0
    def folderitem(self, obj, item, index):
        """Service triggered each time an item is iterated in folderitems.

        The use of this service prevents the extra-loops in child objects.

        :obj: the instance of the class to be foldered
        :item: dict containing the properties of the object to be used by
            the template
        :index: current index of the item
        """

        title = obj.Title()
        description = obj.Description()
        url = obj.absolute_url()

        item["Description"] = description

        item["replace"]["Title"] = get_link(url, value=title)

        retention_period = obj.getRetentionPeriod()
        if retention_period:
            hours = retention_period.get("hours", "0")
            minutes = retention_period.get("minutes", "0")
            days = retention_period.get("days", "0")
            item["RetentionPeriod"] = _(
                "hours: {} minutes: {} days: {}".format(hours, minutes, days))
        else:
            item["RetentionPeriod"] = ""

        sample_matrix = obj.getSampleMatrix()
        if sample_matrix:
            title = sample_matrix.Title()
            url = sample_matrix.absolute_url()
            item["SampleMatrix"] = title
            item["replace"]["SampleMatrix"] = get_link(url, value=title)
        else:
            item["SampleMatrix"] = ""

        container_type = obj.getContainerType()
        if container_type:
            title = container_type.Title()
            url = container_type.absolute_url()
            item["ContainerType"] = title
            item["replace"]["ContainerType"] = get_link(url, value=title)
        else:
            item["ContainerType"] = ""

        sample_points = obj.getSamplePoints()
        if sample_points:
            links = map(
                lambda sp: get_link(
                    sp.absolute_url(), value=sp.Title(), css_class="link"),
                sample_points)
            item["replace"]["getSamplePoints"] = ", ".join(links)
        else:
            item["getSamplePoints"] = ""

        return item
Ejemplo n.º 16
0
 def folderitem(self, obj, item, index):
     """Applies new properties to the item to be rendered
     """
     item = super(DoctorsView, self).folderitem(obj, item, index)
     url = item.get("url")
     doctor_id = item.get("getDoctorID")
     item['replace']['getDoctorID'] = get_link(url, value=doctor_id)
     item['getPrimaryReferrer'] = ""
     doctor = api.get_object(obj)
     pri = doctor.getPrimaryReferrer()
     if pri:
         pri_url = pri.absolute_url()
         pri = pri.Title()
         item['replace']['getPrimaryReferrer'] = get_link(pri_url, value=pri)
     return item
Ejemplo n.º 17
0
 def folderitem(self, obj, item, index):
     """Applies new properties to the item to be rendered
     """
     item = super(DoctorsView, self).folderitem(obj, item, index)
     url = item.get("url")
     doctor_id = item.get("getDoctorID")
     item['replace']['getDoctorID'] = get_link(url, value=doctor_id)
     item['getPrimaryReferrer'] = ""
     doctor = api.get_object(obj)
     pri = doctor.getPrimaryReferrer()
     if pri:
         pri_url = pri.absolute_url()
         pri = pri.Title()
         item['replace']['getPrimaryReferrer'] = get_link(pri_url, value=pri)
     return item
Ejemplo n.º 18
0
    def folderitem(self, obj, item, index):
        """Service triggered each time an item is iterated in folderitems.

        The use of this service prevents the extra-loops in child objects.

        :obj: the instance of the class to be foldered
        :item: dict containing the properties of the object to be used by
            the template
        :index: current index of the item
        """

        layout = obj.getLayout
        title = api.get_title(obj)
        url = api.get_url(obj)

        item["CreationDate"] = self.ulocalized_time(obj.created)
        if len(obj.getAnalysesUIDs) == 0:
            item["table_row_class"] = "state-empty-worksheet"

        title_link = "{}/{}".format(url, "add_analyses")
        if len(layout) > 0:
            title_link = "{}/{}".format(url, "manage_results")

        item["Title"] = title
        item["replace"]["Title"] = get_link(title_link, value=title)

        pos_parent = {}
        for slot in layout:
            # compensate for bad data caused by a stupid bug.
            if type(slot["position"]) in (list, tuple):
                slot["position"] = slot["position"][0]
            if slot["position"] == "new":
                continue
            if slot["position"] in pos_parent:
                continue
            pos_parent[slot["position"]] =\
                self.rc.lookupObject(slot.get("container_uid"))

        # Total QC Analyses
        item["NumQCAnalyses"] = str(obj.getNumberOfQCAnalyses)
        # Total Routine Analyses
        item["NumRegularAnalyses"] = str(obj.getNumberOfRegularAnalyses)
        # Total Number of Samples
        item["NumRegularSamples"] = str(obj.getNumberOfRegularSamples)

        # Progress
        progress_perc = obj.getProgressPercentage
        item["replace"]["Progress"] = get_progress_bar_html(progress_perc)

        review_state = item["review_state"]
        if self.can_reassign and review_state == "open":
            item["Analyst"] = obj.getAnalyst
            item["allow_edit"] = ["Analyst"]
            item["required"] = ["Analyst"]
            item["choices"] = {"Analyst": self.analyst_choices}
        else:
            fullname = user_fullname(self.context, obj.getAnalyst)
            item["Analyst"] = fullname

        return item
Ejemplo n.º 19
0
 def folderitem(self, obj, item, index):
     obj = api.get_object(obj)
     url = api.get_url(obj)
     title = api.get_title(obj)
     item["replace"]["Title"] = get_link(url, value=title)
     item["query_type"] = getattr(obj, "query_type", None)
     return item
Ejemplo n.º 20
0
    def folderitem(self, obj, item, index):
        """Augment folder listing item
        """
        url = item.get("url")
        title = item.get("Title")
        calibrator = obj.getCalibrator()

        item["getDownFrom"] = self.localize_date(obj.getDownFrom())
        item["getDownTo"] = self.localize_date(obj.getDownTo())
        item["getCalibrator"] = ""
        if calibrator:
            props = api.get_user_properties(calibrator)
            name = props.get("fullname", calibrator)
            item["getCalibrator"] = name
        item["replace"]["Title"] = get_link(url, value=title)

        # calibration with the most remaining days
        if obj == self.latest_calibration:
            item["state_class"] = "state-published"
        # running calibrations
        elif obj in self.active_calibrations:
            item["state_class"] = "state-active"
        # inactive calibrations
        else:
            item["state_class"] = "state-inactive"

        return item
Ejemplo n.º 21
0
 def folderitem(self, obj, item, index):
     item['Description'] = obj.Description()
     item['replace']['Title'] = get_link(item['url'], item['Title'])
     item['Instrument'] = ''
     instrument = obj.getInstrument()
     item['Instrument'] = instrument and instrument.Title() or ''
     return item
Ejemplo n.º 22
0
 def folderitem(self, obj, item, index):
     item['Description'] = obj.Description()
     item['replace']['Title'] = get_link(item['url'], item['Title'])
     item['Instrument'] = ''
     instrument = obj.getInstrument()
     item['Instrument'] = instrument and instrument.Title() or ''
     return item
Ejemplo n.º 23
0
    def folderitem(self, obj, item, index):
        """Applies new properties to the item (Client) that is currently being
        rendered as a row in the list

        :param obj: client to be rendered as a row in the list
        :param item: dict representation of the client, suitable for the list
        :param index: current position of the item within the list
        :type obj: ATContentType/DexterityContentType
        :type item: dict
        :type index: int
        :return: the dict representation of the item
        :rtype: dict
        """

        url = obj.absolute_url()
        title = obj.Title()

        item['Description'] = obj.Description()
        item["replace"]["Title"] = get_link(url, value=title)

        # Icons
        after_icons = ""
        if obj.getBlank():
            after_icons += get_image("blank.png", title=t(_("Blank")))
        if obj.getHazardous():
            after_icons += get_image("hazardous.png", title=t(_("Hazardous")))
        if after_icons:
            item["after"]["Title"] = after_icons

        return item
Ejemplo n.º 24
0
    def _folder_item_assigned_worksheet(self, analysis_brain, item):
        """Adds an icon to the item dict if the analysis is assigned to a
        worksheet and if the icon is suitable for the current context

        :param analysis_brain: Brain that represents an analysis
        :param item: analysis' dictionary counterpart that represents a row
        """
        if not IAnalysisRequest.providedBy(self.context):
            # We want this icon to only appear if the context is an AR
            return

        if analysis_brain.worksheetanalysis_review_state != 'assigned':
            # No need to go further. This analysis is not assigned to any WS
            return

        analysis_obj = self.get_object(analysis_brain)
        worksheet = analysis_obj.getBackReferences('WorksheetAnalysis')
        if not worksheet:
            # No worksheet assigned. Do nothing
            return

        worksheet = worksheet[0]
        title = t(
            _("Assigned to: ${worksheet_id}",
              mapping={'worksheet_id': safe_unicode(worksheet.id)}))
        img = get_image('worksheet.png', title=title)
        anchor = get_link(worksheet.absolute_url(), img)
        self._append_html_element(item, 'state_title', anchor)
Ejemplo n.º 25
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
Ejemplo n.º 26
0
    def folderitem(self, obj, item, index):
        """Service triggered each time an item is iterated in folderitems.

        The use of this service prevents the extra-loops in child objects.

        :obj: the instance of the class to be foldered
        :item: dict containing the properties of the object to be used by
            the template
        :index: current index of the item
        """
        item = super(ReferenceSamplesView, self).folderitem(obj, item, index)

        # ensure we have an object and not a brain
        obj = api.get_object(obj)
        url = api.get_url(obj)
        title = api.get_title(obj)

        item["Title"] = title
        item["replace"]["Title"] = get_link(url, value=title)
        item["allow_edit"] = self.get_editable_columns()

        # Supported Services
        supported_services_choices = self.make_supported_services_choices(obj)
        item["choices"]["SupportedServices"] = supported_services_choices

        # Position
        item["Position"] = "new"
        item["choices"]["Position"] = self.make_position_choices()

        return item
Ejemplo n.º 27
0
    def folderitem(self, obj, item, index):
        """Applies new properties to the item (Client) that is currently being
        rendered as a row in the list

        :param obj: client to be rendered as a row in the list
        :param item: dict representation of the client, suitable for the list
        :param index: current position of the item within the list
        :type obj: ATContentType/DexterityContentType
        :type item: dict
        :type index: int
        :return: the dict representation of the item
        :rtype: dict
        """

        obj = api.get_object(obj)
        url = obj.absolute_url()
        title = obj.Title()

        item["replace"]["Title"] = get_link(url, value=title)

        item["getEffectiveDate"] = self.ulocalized_time(
            obj.getEffectiveDate())

        item["getExpirationDate"] = self.ulocalized_time(
            obj.getExpirationDate())

        return item
Ejemplo n.º 28
0
    def folderitem(self, obj, item, index):
        """Augment folder listing item
        """
        url = item.get("url")
        title = item.get("Title")

        item["replace"]["Title"] = get_link(url, value=title)
        item["getType"] = _(obj.getType()[0])
        item["getDownFrom"] = self.localize_date(obj.getDownFrom())
        item["getDownTo"] = self.localize_date(obj.getDownTo())
        item["getMaintainer"] = obj.getMaintainer()

        status = obj.getCurrentState()
        statustext = obj.getCurrentStateI18n()
        statusimg = ""

        if status == mstatus.CLOSED:
            statusimg = "instrumentmaintenance_closed.png"
            item["state_class"] = "state-inactive"
        elif status == mstatus.CANCELLED:
            statusimg = "instrumentmaintenance_cancelled.png"
            item["state_class"] = "state-cancelled"
        elif status == mstatus.INQUEUE:
            statusimg = "instrumentmaintenance_inqueue.png"
            item["state_class"] = "state-open"
        elif status == mstatus.OVERDUE:
            statusimg = "instrumentmaintenance_overdue.png"
            item["state_class"] = "state-open"
        elif status == mstatus.PENDING:
            statusimg = "instrumentmaintenance_pending.png"
            item["state_class"] = "state-pending"

        item["replace"]["getCurrentState"] = get_image(statusimg,
                                                       title=statustext)
        return item
Ejemplo n.º 29
0
    def folder_item(self, obj, item, index):
        batch = api.get_object(obj)
        # Doctor
        doctor = get_field_value(batch, "Doctor", None)
        item["Doctor"] = doctor and doctor.Title() or ""
        item["replace"]["Doctor"] = doctor and get_link(
            api.get_url(doctor), doctor.Title())
        # Onset Date
        onset = get_field_value(batch, "OnsetDate", None)
        item["OnsetDate"] = onset and self.listing.ulocalized_time(onset) or ""

        # Patient
        item["Patient"] = ""
        item["getPatientID"] = ""
        item["getClientPatientID"] = ""
        item["PatientAgeOnsetDate"] = ""
        patient = get_field_value(batch, "Patient", None)
        if patient:
            url = api.get_url(patient)
            item["Patient"] = patient.Title()
            item["replace"]["Patient"] = get_link(url, patient.Title())

            item["getPatientID"] = patient.id
            item["replace"]["getPatientID"] = get_link(url, patient.id)

            pid = patient.getClientPatientID()
            pid_link = pid and get_link(url, pid) or ""
            item["getClientPatientID"] = pid or ""
            item["replace"]["getClientPatientID"] = pid_link

            dob = patient.getBirthDate()
            if onset and dob:
                try:
                    age_ymd = get_age_ymd(patient.getBirthDate(), onset)
                    item["replace"]["PatientAgeOnsetDate"] = age_ymd
                except:
                    # Wrong date??
                    msg = _("Date of Birth or Case Onset Date are wrong")
                    img = get_image("exclamation.png", title=msg)
                    item["replace"]["PatientAgeOnsetDate"] = img

        # 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:
            item["before"]["BatchID"] = get_client_aware_html_image(obj)

        return item
Ejemplo n.º 30
0
    def folderitem(self, obj, item, index):
        """Applies new properties to the item (Batch) that is currently being
        rendered as a row in the list

        :param obj: client to be rendered as a row in the list
        :param item: dict representation of the batch, suitable for the list
        :param index: current position of the item within the list
        :type obj: ATContentType/DexterityContentType
        :type item: dict
        :type index: int
        :return: the dict representation of the item
        :rtype: dict
        """

        obj = api.get_object(obj)
        url = "{}/analysisrequests".format(api.get_url(obj))
        bid = api.get_id(obj)
        cbid = obj.getClientBatchID()
        title = api.get_title(obj)
        client = obj.getClient()
        created = api.get_creation_date(obj)
        date = obj.getBatchDate()

        # total sample progress
        progress = obj.getProgress()
        item["Progress"] = progress
        item["replace"]["Progress"] = get_progress_bar_html(progress)

        item["BatchID"] = bid
        item["ClientBatchID"] = cbid
        item["replace"]["BatchID"] = get_link(url, bid)
        item["Title"] = title
        item["replace"]["Title"] = get_link(url, title)
        item["created"] = self.ulocalized_time(created, long_format=True)
        item["BatchDate"] = self.ulocalized_time(date, long_format=True)

        if client:
            client_url = api.get_url(client)
            client_name = client.getName()
            client_id = client.getClientID()
            item["Client"] = client_name
            item["ClientID"] = client_id
            item["replace"]["Client"] = get_link(client_url, client_name)
            item["replace"]["ClientID"] = get_link(client_url, client_id)

        return item
Ejemplo n.º 31
0
    def folderitem(self, obj, item, index):
        """Applies new properties to the item (Client) that is currently being
        rendered as a row in the list

        :param obj: client to be rendered as a row in the list
        :param item: dict representation of the client, suitable for the list
        :param index: current position of the item within the list
        :type obj: ATContentType/DexterityContentType
        :type item: dict
        :type index: int
        :return: the dict representation of the item
        :rtype: dict
        """

        obj = api.get_object(obj)

        # XXX Refactor expiration to a proper place
        # ---------------------------- 8< -------------------------------------
        if item.get("review_state", "current") == "current":
            # Check expiry date
            exdate = obj.getExpiryDate()
            if exdate:
                expirydate = DT2dt(exdate).replace(tzinfo=None)
                if (datetime.today() > expirydate):
                    # Trigger expiration
                    self.workflow.doActionFor(obj, "expire")
                    item["review_state"] = "expired"
                    item["obj"] = obj

        if self.contentFilter.get('review_state', '') \
           and item.get('review_state', '') == 'expired':
            # This item must be omitted from the list
            return None
        # ---------------------------- >8 -------------------------------------

        url = api.get_url(obj)
        id = api.get_id(obj)

        item["ID"] = id
        item["replace"]["ID"] = get_link(url, value=id)
        item["DateSampled"] = self.ulocalized_time(
            obj.getDateSampled(), long_format=True)
        item["DateReceived"] = self.ulocalized_time(obj.getDateReceived())
        item["DateOpened"] = self.ulocalized_time(obj.getDateOpened())
        item["ExpiryDate"] = self.ulocalized_time(obj.getExpiryDate())

        # Icons
        after_icons = ''
        if obj.getBlank():
            after_icons += get_image(
                "blank.png", title=t(_("Blank")))
        if obj.getHazardous():
            after_icons += get_image(
                "hazardous.png", title=t(_("Hazardous")))
        if after_icons:
            item["after"]["ID"] = after_icons

        return item
Ejemplo n.º 32
0
 def folderitem(self, obj, item, index):
     obj = api.get_object(obj)
     item["replace"].update({
         "getFullName":
         get_link(item["url"], obj.getFullName()),
         "getEmailAddress":
         get_email_link(obj.getEmailAddress())
     })
     return item
Ejemplo n.º 33
0
    def folderitem(self, obj, item, index):
        obj = api.get_object(obj)
        method = obj.getMethod()
        if method:
            item["Method"] = api.get_title(method)
            item["replace"]["Method"] = get_link_for(method)

        item["replace"]["Title"] = get_link(item["url"], item["Title"])
        return item
Ejemplo n.º 34
0
    def folderitem(self, obj, item, index):
        """Applies new properties to the item (Client) that is currently being
        rendered as a row in the list

        :param obj: client to be rendered as a row in the list
        :param item: dict representation of the client, suitable for the list
        :param index: current position of the item within the list
        :type obj: ATContentType/DexterityContentType
        :type item: dict
        :type index: int
        :return: the dict representation of the item
        :rtype: dict
        """

        obj = api.get_object(obj)
        url = obj.absolute_url()
        title = obj.Title()

        item["replace"]["Title"] = get_link(url, value=title)

        instruments = obj.getInstruments()
        if instruments:
            links = map(
                lambda i: get_link(i.absolute_url(), i.Title()), instruments)
            item["replace"]["Instrument"] = ", ".join(links)
        else:
            item["Instrument"] = ""

        calculation = obj.getCalculation()
        if calculation:
            title = calculation.Title()
            url = calculation.absolute_url()
            item["Calculation"] = title
            item["replace"]["Calculation"] = get_link(url, value=title)
        else:
            item["Calculation"] = ""

        manual_entry_of_results_allowed = obj.isManualEntryOfResults()
        item["ManualEntry"] = manual_entry_of_results_allowed
        item["replace"]["ManualEntry"] = " "
        if manual_entry_of_results_allowed:
            item["replace"]["ManualEntry"] = get_image("ok.png")

        return item
Ejemplo n.º 35
0
 def folderitem(self, obj, item, index):
     item['getBirthDate'] = self.ulocalized_time(obj.getBirthDate)
     # 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)
     return item
Ejemplo n.º 36
0
    def folderitem(self, obj, item, index):
        """Augment folder listing item with additional data
        """
        url = item.get("url")
        title = item.get("DocumentID")

        item["replace"]["DocumentID"] = get_link(url, title)

        item["FileDownload"] = ""
        item["replace"]["FileDownload"] = ""
        file = self.get_file(obj)
        if file and file.get_size() > 0:
            filename = file.filename
            download_url = "{}/at_download/File".format(url)
            anchor = get_link(download_url, filename)
            item["FileDownload"] = filename
            item["replace"]["FileDownload"] = anchor

        item["DocumentVersion"] = obj.getDocumentVersion()
        item["DocumentLocation"] = obj.getDocumentLocation()
        item["DocumentType"] = obj.getDocumentType()
        return item
Ejemplo n.º 37
0
 def folderitem(self, obj, item, index):
     """
     Applies new properties to the item (Client) that is currently being
     rendered as a row in the list
     :param obj: client to be rendered as a row in the list
     :param item: dict representation of the client, suitable for the list
     :param index: current position of the item within the list
     :type obj: ATContentType/DexterityContentType
     :type item: dict
     :type index: int
     :return: the dict representation of the item
     :rtype: dict
     """
     link_url = "{}/{}".format(item['url'], self.landing_page)
     item['replace']['title'] = get_link(link_url, item['title'])
     item['replace']['EmailAddress'] = get_email_link(item['EmailAddress'])
     return item