Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Additional buttons in Batch and Patient add/edit views #151

Merged
merged 6 commits into from
Oct 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Changelog

**Added**

- #151 Additional buttons in Batch and Patient add/edit views
- #134 ReferenceWidget for client searches in Add Patient form
- #130 Allow to deactivate/activate Doctors

Expand Down
33 changes: 6 additions & 27 deletions bika/health/setuphandlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,26 @@
import itertools

from Acquisition import aq_base
from Products.CMFCore import permissions
from Products.CMFCore.permissions import AccessContentsInformation
from Products.CMFCore.permissions import ListFolderContents
from Products.CMFCore.permissions import View
from Products.CMFCore.utils import getToolByName

from bika.health import logger
from bika.health.catalog import \
getCatalogDefinitions as getCatalogDefinitionsHealth
from bika.health.catalog import getCatalogExtensions
from bika.health.config import DEFAULT_PROFILE_ID
from bika.health.permissions import ViewPatients
from bika.health.subscribers.batch import purge_owners_for
from bika.lims import api
from bika.lims.catalog import \
getCatalogDefinitions as getCatalogDefinitionsLIMS
from bika.lims.catalog import setup_catalogs
from bika.lims.idserver import renameAfterCreation
from bika.lims.permissions import AddAnalysisRequest
from bika.lims.permissions import AddBatch
from bika.lims.upgrade.utils import commit_transaction
from bika.lims.utils import tmpID
from Products.CMFCore import permissions
from Products.CMFCore.permissions import AccessContentsInformation
from Products.CMFCore.permissions import ListFolderContents
from Products.CMFCore.permissions import View
from Products.CMFCore.utils import getToolByName


class Empty(object):
Expand Down Expand Up @@ -104,9 +103,6 @@ def post_install(portal_setup):
# Setup site structure
setup_site_structure(context)

# Setup "Owner" roles for batches to client contacts
setup_batches_ownership(portal)

# Setup javascripts
setup_javascripts(portal)

Expand Down Expand Up @@ -243,23 +239,6 @@ def setup_site_structure(context):
logger.info("Setup site structure [DONE]")


def setup_batches_ownership(portal):
"""Walks-through all batches and set the role "Owner" to all the client
contacts that belong to the same client as the batch, if any
"""
logger.info("Setup Batches/Cases ownership ...")
batches = portal.batches.objectValues("Batch")
total = len(batches)
for num, batch in enumerate(batches):
if num % 100 == 0:
logger.info("Setup Batches ownership {}/{}".format(num, total))
purge_owners_for(batch)

if num % 1000 == 0:
commit_transaction()
commit_transaction()


def setup_javascripts(portal):
# Plone's jQuery gets clobbered when jsregistry is loaded.
setup = portal.portal_setup
Expand Down
23 changes: 23 additions & 0 deletions bika/health/skins/bika_health/batch_edit.pt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
i18n:domain="senaite.health">
<body>
<metal:body define-macro="body">
<metal:default_body use-macro="here/edit_macros/macros/body">
<metal:block fill-slot="extra_buttons">

<!-- Save batch and redirect to Add Sample view -->
<input class="context"
type="submit"
name="form.button.new_sample"
value="Save and create Sample"
i18n:attributes="value"
tal:attributes="disabled python:test(isLocked, 'disabled', None);" />

</metal:block>
</metal:default_body>
</metal:body>
</body>
</html>
31 changes: 31 additions & 0 deletions bika/health/skins/bika_health/patient_edit.pt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
i18n:domain="senaite.health">
<body>
<metal:body define-macro="body">
<metal:default_body use-macro="here/edit_macros/macros/body">
<metal:block fill-slot="extra_buttons">

<!-- Save patient and redirect to Add Case view -->
<input class="context"
type="submit"
name="form.button.new_batch"
value="Save and create Clinical Case"
i18n:attributes="value"
tal:attributes="disabled python:test(isLocked, 'disabled', None);" />

<!-- Save patient and redirect to Add Sample view -->
<input class="context"
type="submit"
name="form.button.new_sample"
value="Save and create Sample"
i18n:attributes="value"
tal:attributes="disabled python:test(isLocked, 'disabled', None);" />

</metal:block>
</metal:default_body>
</metal:body>
</body>
</html>
32 changes: 4 additions & 28 deletions bika/health/skins/bika_health/validate_integrity.cpy
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
##bind subpath=traverse_subpath
##parameters=
##
from bika.health.utils import handle_after_submit

from Products.Archetypes import PloneMessageFactory as _
from Products.Archetypes.utils import addStatusMessage
Expand All @@ -20,37 +21,12 @@ if errors:
message = _(u'Please correct the indicated errors.')
addStatusMessage(request, message, type='error')
return state.set(status='failure', errors=errors)

else:
message = _(u'Changes saved.')
stat = 'created'

# redirect to Patient's ARs view when saving a newly created patient
patient_redirection = ''
if context.portal_type == 'Patient':
patient_redirection = '/'.join(['/patients', context.getPatientID(), 'analysisrequests'])

# Redirection after saving edition forms
redirects = {'AetiologicAgent' : '/bika_setup/bika_aetiologicagents',
'BatchLabel' : '/bika_setup/bika_batchlabels',
'CaseOutcome': '/bika_setup/bika_caseoutcomes',
'CaseSyndromicClassification' : '/bika_setup/bika_casesyndromicclassifications',
'CaseStatus': '/bika_setup/bika_casestatuses',
'Disease': '/bika_setup/bika_diseases',
'Drug': '/bika_setup/bika_drugs',
'DrugProhibition': '/bika_setup/bika_drugprohibitions',
'Immunization': '/bika_setup/bika_immunizations',
'Treatment': '/bika_setup/bika_treatments',
'VaccionationCenter': '/bika_setup/bika_vaccionationcenters',
'InsuranceCompany': '/bika_setup/bika_insurancecompanies',
'IdentifierType': '/bika_setup/bika_identifiertypes',
'Symptom': '/bika_setup/bika_symptoms',
'Patient': patient_redirection}

if context.portal_type in redirects:
redirect = 'redirect_to:string:${portal_url}' + redirects[context.portal_type]
state.setNextAction(redirect)
else:
stat = 'success'

# Handles actions from extra_buttons slot
handle_after_submit(context, request, state)
addStatusMessage(request, message)
return state.set(status=stat)
80 changes: 0 additions & 80 deletions bika/health/subscribers/batch.py

This file was deleted.

17 changes: 0 additions & 17 deletions bika/health/subscribers/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,4 @@
handler=".patient.ObjectModifiedEventHandler"
/>

<!-- Batch creation. If a client has been assigned to the batch, client
contacts become the Owners of the Batch, so besides lab personnel, only
contacts of same client will be able to view and edit the batch -->
<subscriber
for="bika.lims.interfaces.IBatch
Products.Archetypes.interfaces.IObjectInitializedEvent"
handler=".batch.ObjectInitializedEventHandler"
/>

<!-- Batch modification. Purges role "Owner" for this batch from client
contacts that do not belong to the same client the batch is assigned to -->
<subscriber
for="bika.lims.interfaces.IBatch
zope.lifecycleevent.interfaces.IObjectModifiedEvent"
handler=".batch.ObjectModifiedEventHandler"
/>

</configure>
17 changes: 9 additions & 8 deletions bika/health/upgrade/v01_02_000.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,18 @@
from bika.health import logger
from bika.health.catalog.patient_catalog import CATALOG_PATIENTS
from bika.health.config import PROJECTNAME
from bika.health.setuphandlers import setup_id_formatting, \
setup_content_actions, remove_action, setup_roles_permissions, \
setup_batches_ownership
from bika.health.setuphandlers import remove_action
from bika.health.setuphandlers import setup_content_actions
from bika.health.setuphandlers import setup_id_formatting
from bika.health.setuphandlers import setup_roles_permissions
from bika.health.subscribers.patient import purge_owners_for
from bika.health.upgrade.utils import setup_catalogs, del_index, del_column
from bika.health.upgrade.utils import del_column
from bika.health.upgrade.utils import del_index
from bika.health.upgrade.utils import setup_catalogs
from bika.lims import api
from bika.lims.upgrade import upgradestep
from bika.lims.upgrade.utils import UpgradeUtils, commit_transaction
from bika.lims.upgrade.utils import UpgradeUtils
from bika.lims.upgrade.utils import commit_transaction

version = '1.2.0'
profile = 'profile-{0}:default'.format(PROJECTNAME)
Expand Down Expand Up @@ -109,9 +113,6 @@ def upgrade(tool):
# Setup "Owner" roles for patients to client contacts
setup_patients_ownership(portal)

# Setup "Owner" roles for batches to client contacts
setup_batches_ownership(portal)

# Update workflows
update_workflows(portal)

Expand Down
9 changes: 1 addition & 8 deletions bika/health/upgrade/v01_02_001.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,9 @@
# Some rights reserved, see README and LICENSE.

from bika.health import logger
from bika.health.catalog.patient_catalog import CATALOG_PATIENTS
from bika.health.config import PROJECTNAME
from bika.health.setuphandlers import setup_id_formatting, \
setup_content_actions, remove_action, setup_roles_permissions, \
setup_batches_ownership
from bika.health.subscribers.patient import purge_owners_for
from bika.health.upgrade.utils import setup_catalogs, del_index, del_column
from bika.lims import api
from bika.lims.upgrade import upgradestep
from bika.lims.upgrade.utils import UpgradeUtils, commit_transaction
from bika.lims.upgrade.utils import UpgradeUtils

version = '1.2.1'
profile = 'profile-{0}:default'.format(PROJECTNAME)
Expand Down
Loading