Hi Leo,
Thanks for your great feedback regarding senaite.databox
!
It is good to hear that it serves as a valuable tool for you.
However, it has it flaws and limitations as you already found out, e.g. that it can currently only query one type and complex joins are not really possible.
It might be (technically) possible to allow a databox inside another databox, so that it inherits the results from the parent and operates only on this result set for another (related) content type.
E.g. to “feed” the result UIDs of the parent query into an appropriate index of an analysis query. Unfortunately, this was not further investigated.
Therefore, the only chance you have is to query from bottom upwards and add the required indexes and filters on the analysis itself, e.g. to have an index there for Patient gender as well.
Alternatively, you need to copy the sample IDs from your “sample databox” export manually into your “analysis databox” inside the getRequestID
index as a list.
The other way, and probably the more faster one, is to create a Script (Python)
via the ZMI portal_skins
tool inside the custom
folder and export the data as CSV:
from Products.CMFCore.utils import getToolByName
from DateTime import DateTime
request = container.REQUEST
response = request.response
catalog = getToolByName(context, "senaite_catalog_sample")
header = [
"Client Name",
"Client ID",
"SampleID",
"Created",
"Received",
"Published",
]
print ",".join(header)
results = catalog({
"sort_on": "created",
"review_state": "published",
"sort_order": "descending",
})
def to_date(date):
dt = DateTime(date)
return dt.strftime("%d.%m.%Y %H:%M")
for result in results:
sample = result.getObject()
client = sample.getClient()
created = sample.created()
received = sample.getDateReceived()
published = sample.getDatePublished()
row = [
'"{}"'.format(client.getName()),
'"{}"'.format(client.getClientID()),
'"{}"'.format(sample.getId()),
to_date(created),
to_date(received),
to_date(published),
]
print ",".join(row)
return printed
Well, not the most elegant way to create a CSV, but it get you to a result.
Just take care of unicode decoding by maybe using api.to_utf8(...)
for the client name or other values.
Finally, you could consider do all the things above in an browser listing view;)
Hope that helps
Best regards,
Ramon