Skip to content

Commit

Permalink
Merge branch 'hotfix/3.1.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
Pau Soliva committed Nov 3, 2015
2 parents 5661aa4 + cfcf3ca commit d835ef2
Show file tree
Hide file tree
Showing 31 changed files with 604 additions and 480 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Bika Health LIS

Bika Laboratory Information Management System customised for use in Health laboratories.

Last stable version: **v3.1.7** · released: 2015-06-09
Last stable version: **v3.1.8** · released: 2015-11-03

[**Naringenin**](http://en.wikipedia.org/wiki/Naringenin) is a flavanone, a typeof flavonoid, that is considered to have a bioactive effect on human health as antioxidant, free radical scavenger, anti-inflammatory, carbohydrate metabolism promoter, and immune system modulator. It is the predominant flavanone in grapefruit.

Expand All @@ -12,7 +12,7 @@ Installation and upgrades
Bika Health can be installed on Windows, Mac OS X, Linux, BSD and other platforms:
https://github.com/bikalabs/bika.health/wiki/Installing-Bika-Health-Extension

**Bika Health LIS 3.1.7 is only compatible with Bika LIMS 3.1.8**. Follow the instructions [Installing Bika Health Extension](https://github.com/bikalabs/bika.health/wiki/Installing-Bika-Health-Extension).
Follow the instructions [Installing Bika Health Extension](https://github.com/bikalabs/bika.health/wiki/Installing-Bika-Health-Extension).

You might also find useful the following recipes:
- Installing Bika LIMS: https://github.com/bikalabs/Bika-LIMS/wiki/Bika-LIMS-Installation
Expand Down
12 changes: 9 additions & 3 deletions bika/health/browser/analysisrequest/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ def __init__(self, context, request):
self.w = AddressWidget()

def __call__(self):
# Hacking the template condition to display only the classic analysis
# request view because the standard one is not compatible with the new
# bikalisting
self.templatename = 'classic'
if self.templatename == 'classic':
return AnalysisRequestAddViewLIMS.__call__(self)

Expand Down Expand Up @@ -63,8 +67,11 @@ def categoryInDepartment(self, category, department):
:param department: The department UID
:return: True or False
"""
return getToolByName(self.context, 'bika_setup_catalog')(UID=category)[0]\
.getObject().getDepartment().UID() == department
obj = getToolByName(self.context, 'bika_setup_catalog')(UID=category)
if obj:
return obj[0].getObject().getDepartment().UID() == department
else:
return False

def getAvailableServices(self, categoryuid):
""" Return a list of services brains
Expand All @@ -75,4 +82,3 @@ def getAvailableServices(self, categoryuid):
inactive_state='active',
getCategoryUID=categoryuid)
return services

26 changes: 16 additions & 10 deletions bika/health/browser/analysisrequest/ajax.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
from bika.health import bikaMessageFactory as _
from bika.lims.utils import t
from bika.lims.browser.analysisrequest.add import ajaxAnalysisRequestSubmit as BaseClass
from bika.lims.utils import tmpID
from bika.lims.idserver import renameAfterCreation
from bika.lims.browser.analysisrequest.add import ajax_form_error
from Products.CMFCore.utils import getToolByName
import json


class AnalysisRequestSubmit(BaseClass):
Expand All @@ -14,19 +17,23 @@ def __call__(self):
bpc = getToolByName(self.context, 'bika_patient_catalog')
form = self.request.form
formc = self.request.form.copy()
for column in range(int(form['col_count'])):
arkey = "ar.%s" % column
values = form[arkey].copy()
patuid = values.get('Patient_uid', '')
if patuid == 'anonymous':
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_uid'])[0].getObject()
client = uc(UID=values['Client'])[0].getObject()
_id = client.patients.invokeFactory('Patient', id=tmpID())
patient = client.patients[_id]
patient.edit(Anonymous = 1,
Expand All @@ -40,9 +47,8 @@ def __call__(self):
client.reindexObject()
renameAfterCreation(patient)

values['Patient_uid']=patient.UID()
values['Patient']=patient.Title()
formc[arkey] = values

values['Patient']=patient.UID()
state[key] = values
formc['state'] = json.JSONEncoder().encode(state)
self.request.form = formc
return BaseClass.__call__(self)
8 changes: 8 additions & 0 deletions bika/health/browser/analysisrequest/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@
xmlns:zcml="http://namespaces.zope.org/browser"
xmlns:fss="http://namespaces.zope.org/browser"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:plone="http://namespaces.plone.org/plone"
xmlns:five="http://namespaces.zope.org/five">

<include package="plone.resource" file="meta.zcml"/>
<plone:static
directory="templates/reports"
type="reports"
name="bika.health"
/>

<browser:page
for="*"
name="email_popup"
Expand Down
69 changes: 0 additions & 69 deletions bika/health/browser/analysisrequest/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,75 +10,6 @@ class AnalysisRequestPublishView(_AnalysisRequestPublishView):
def __call__(self):
return super(AnalysisRequestPublishView, self).__call__()

def getAvailableFormats(self):
""" Overrides
Looks for templates inside bika.health's templates/reports
folder, as well as bika.lims's templates/reports directory
"""
# bika.lims templates
btempl = _AnalysisRequestPublishView.getAvailableFormats(self)
for tmpl in btempl:
tmpl['title'] = '%s: %s' % ('bika.lims', tmpl['title']);
tmpl['id'] = '%s:%s' % ('bika.lims', tmpl['id']);

# bika.health templates
tempath = self._getTemplatesResourcePath('*.pt')
templates = [t.split('/')[-1] for t in glob.glob(tempath)]
out = []
for template in templates:
out.append({
'id': '%s:%s' % ('bika.health', template),
'title': '%s: %s' % ('bika.health', template[:-3])})

out.extend(btempl)
return out

def getReportTemplate(self):
""" Overrides
Returns the template for the current ar and moves to the
next ar to be processed. Uses the selected template
specified in the request ('template' parameter)
"""
embedt = self.request.get('template', self._DEFAULT_TEMPLATE)
path = self._getTemplatesResourcePath(embedt)
embed = ViewPageTemplateFile(path)
reptemplate = ""
try:
reptemplate = embed(self)
except:
tbex = traceback.format_exc()
arid = self._ars[self._current_ar_index].id
reptemplate = "<div class='error-report'>%s - %s '%s':<pre>%s</pre></div>" % (arid, _("Unable to load the template"), embedt, tbex)
self.logger.error(tbex);
self._nextAnalysisRequest()
return reptemplate

def getReportStyle(self):
""" Overrides
Returns the CSS to be used in the current template
"""
embedt = self.request.get('template', self._DEFAULT_TEMPLATE)
path = "%s.css" % self._getTemplatesResourcePath(embedt)[:-3]
content = ''
with open(path, 'r') as content_file:
content = content_file.read()
return content

def _getTemplatesResourcePath(self, resource):
""" Returns the full path from any resource located inside
/templates/reports, either from inside bika.lims project
or bika.health project
"""
this_dir = os.path.dirname(os.path.abspath(__file__))
res = resource
if 'bika.lims:' in resource:
this_dir = str.replace(this_dir, "bika.health/bika/health", "bika.lims/bika/lims")
res = str.replace(resource, 'bika.lims:', '')
res = str.replace(res, 'bika.health:', '')
path = os.path.join(this_dir, 'templates/reports')
path = '%s/%s' % (path, res)
return path

def get_patient(self, ar):
return ar.Schema().getField('Patient').get(ar) \
if 'Patient' in ar.Schema() else None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,55 +21,106 @@
<br />

<table class="invoice-items" summary="Analyses List">
<thead>
<tr>
<th i18n:translate="">Analysis</th>
<th i18n:translate="">Price</th>
<th i18n:translate="">VAT</th>
<th i18n:translate="">Price incl VAT</th>
</tr>
</thead>
<tbody>
<tal:categories repeat="category view/analyses">
<tal:category>
<tr class="category">
<td colspan="4" tal:content="category/name"></td>
</tr>
<tal:analyses repeat="analysis category/analyses">
<tal:analysis>
<tr>
<td class="title" tal:content="analysis/title">Title</td>
<td class="currency">
<span tal:content="python:view.getPreferredCurrencyAbreviattion()">R</span>
<span tal:content="analysis/price">0.00</span>
</td>
<td class="currency">
<span tal:content="python:view.getPreferredCurrencyAbreviattion()">R</span>
<span tal:content="analysis/priceVat">0.00</span>
</td>
<td class="currency">
<span tal:content="python:view.getPreferredCurrencyAbreviattion()">R</span>
<span tal:content="analysis/priceTotal">0.00</span>
</td>
</tr>
</tal:analysis>
</tal:analyses>
</tal:category>
</tal:categories>
<tr class="totals">
<td class="title" i18n:translate="">Total</td>
<td class="currency">
<span tal:content="python:view.getPreferredCurrencyAbreviattion()">R</span>
<span tal:content="view/subtotal"></span>
</td>
<td class="currency">
<span tal:content="python:view.getPreferredCurrencyAbreviattion()">R</span>
<span tal:content="view/VATAmount"></span>
</td>
<td class="currency">
<span tal:content="python:view.getPreferredCurrencyAbreviattion()">R</span>
<span tal:content="view/totalPrice"></span>
</td>
</tr>
</tbody>
<thead>
<tr>
<th i18n:translate="">Analyses</th>
<th i18n:translate="">Price</th>
<th i18n:translate="">VAT</th>
<th i18n:translate="">Price incl VAT</th>
</tr>
</thead>
<tbody>
<!-- Displaying the analysis profiles. -->
<tal:profiles repeat="profile view/profiles">
<tal:profile>
<tr class="profile">
<td class="profile" tal:content="profile/name"></td>
<!-- If profile's checkbox "Use Analysis Profile Price" is enabled, the profile prices
will be displayed.-->

<td tal:condition="profile/price" class="currency">
<span tal:content="python:view.getPreferredCurrencyAbreviation()">R</span>
<span tal:content="profile/price">0.00</span>
</td>
<td tal:condition="profile/price" class="currency">
<span tal:content="python:view.getPreferredCurrencyAbreviation()">R</span>
<span tal:content="profile/priceVat">0.00</span>
</td>
<td tal:condition="profile/price" class="currency">
<span tal:content="python:view.getPreferredCurrencyAbreviation()">R</span>
<span tal:content="profile/priceTotal">0.00</span>
</td>
</tr>
<!-- Displaying profile's analysis services -->
<tal:panalyses repeat="analysis profile/analyses">
<tal:panalysis>
<tr class="panalysis">
<td class="title" tal:content="analysis/title">Title</td>
<!-- Analysis price -->
<td tal:condition="analysis/price" class="currency">
<span tal:content="python:view.getPreferredCurrencyAbreviation()">R</span>
<span tal:content="analysis/price">0.00</span>
</td>
<!-- Analysis VAT amount -->
<td tal:condition="analysis/price" class="currency">
<span tal:content="python:view.getPreferredCurrencyAbreviation()">R</span>
<span tal:content="analysis/priceVat">0.00</span>
</td>
<!-- Analysis price + VAT amount -->
<td tal:condition="analysis/price" class="currency">
<span tal:content="python:view.getPreferredCurrencyAbreviation()">R</span>
<span tal:content="analysis/priceTotal">0.00</span>
</td>
</tr>
</tal:panalysis>
</tal:panalyses>
</tal:profile>
</tal:profiles>
<!-- Displaying solo analysis. -->
<tal:categories repeat="category view/analyses">
<tal:category>
<tr class="category">
<td colspan="4" tal:content="category/name"></td>
</tr>
<tal:analyses repeat="analysis category/analyses">
<tal:analysis>
<tr>
<td class="title" tal:content="analysis/title">Title</td>
<!-- Analysis price -->
<td class="currency">
<span tal:content="python:view.getPreferredCurrencyAbreviation()">R</span>
<span tal:content="analysis/price">0.00</span>
</td>
<!-- Analysis VAT amount -->
<td class="currency">
<span tal:content="python:view.getPreferredCurrencyAbreviation()">R</span>
<span tal:content="analysis/priceVat">0.00</span>
</td>
<!-- Analysis price + VAT amount -->
<td class="currency">
<span tal:content="python:view.getPreferredCurrencyAbreviation()">R</span>
<span tal:content="analysis/priceTotal">0.00</span>
</td>
</tr>
</tal:analysis>
</tal:analyses>
</tal:category>
</tal:categories>
<!-- Last table line containing total prices -->
<tr class="totals">
<td class="title" i18n:translate="">Total</td>
<td class="currency">
<span tal:content="python:view.getPreferredCurrencyAbreviation()">R</span>
<span tal:content="view/subtotal"></span>
</td>
<td class="currency">
<span tal:content="python:view.getPreferredCurrencyAbreviation()">R</span>
<span tal:content="view/VATAmount"></span>
</td>
<td class="currency">
<span tal:content="python:view.getPreferredCurrencyAbreviation()">R</span>
<span tal:content="view/totalPrice"></span>
</td>
</tr>
</tbody>
</table>
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@

<metal:title fill-slot="content-title">
<!-- Load print page -->
<div class="ar-add-template-classic-button">
<div class="ar-add-template-classic-button" style="display: none;">
<input type="button" value="Print" id="print" i18n:translate=""/>
</div>
<!-- Show the classic bika template -->
<div class="ar-add-template-classic-button">
<div class="ar-add-template-classic-button" style="display: none;">
<a href="ar_add?tpl=classic" i18n:translate="">Classic template</a>
</div>
</metal:title>
Expand Down
Loading

0 comments on commit d835ef2

Please sign in to comment.