Skip to content

Commit

Permalink
Compatibility with core#2567 (AnalysisCategory to DX) (#107)
Browse files Browse the repository at this point in the history
* Compatibility with core#2567 (AnalysisCategory to DX)

* Changelog
  • Loading branch information
xispa authored Jun 16, 2024
1 parent 7f13ee7 commit 654d5c4
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 201 deletions.
17 changes: 15 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
Patients for SENAITE
====================

.. image:: https://img.shields.io/pypi/v/senaite.patient.svg?style=flat-square
:target: https://pypi.python.org/pypi/senaite.patient

.. image:: https://img.shields.io/github/actions/workflow/status/senaite/senaite.patient/build-and-test.yml?branch=2.x
:target: https://github.com/senaite/senaite.patient/actions/workflows/build-and-test.yml?query=branch:2.x

.. image:: https://img.shields.io/github/issues-pr/senaite/senaite.patient.svg?style=flat-square
:target: https://github.com/senaite/senaite.patient/pulls

.. image:: https://img.shields.io/github/issues/senaite/senaite.patient.svg?style=flat-square
:target: https://github.com/senaite/senaite.patient/issues

.. image:: https://img.shields.io/badge/Made%20for%20SENAITE-%E2%AC%A1-lightgrey.svg
:target: https://www.senaite.com

About
-----

SENAITE.PATIENT adds Patient handling to `SENAITE LIMS`_.

NOTE: This Add-on requires `senaite.lims >= 2.2.0`


License
-------
Expand Down
108 changes: 1 addition & 107 deletions buildout.cfg
Original file line number Diff line number Diff line change
@@ -1,109 +1,3 @@
[buildout]
index = https://pypi.org/simple/
extends = https://dist.plone.org/release/5.2-latest/versions.cfg
find-links =
https://dist.plone.org/release/5.2-latest/
https://dist.plone.org/thirdparty/

parts =
instance
test
omelette
i18ndude
zopepy
update_translations
update_sources
write_code_headers

eggs =
senaite.core
senaite.app.listing
senaite.app.spotlight
senaite.app.supermodel
senaite.patient
senaite.impress
senaite.jsonapi
senaite.lims
plone.reload
Products.PrintingMailHost

extensions = mr.developer

extends = https://raw.githubusercontent.com/senaite/senaite.core/2.x/buildout.base.cfg
package-name = senaite.patient

versions = versions
show-picked-versions = true

plone-user = admin:admin

develop = .
sources = sources
auto-checkout = *

[sources]
senaite.core = git https://github.com/senaite/senaite.core.git pushurl[email protected]:senaite/senaite.core.git branch=2.x
senaite.app.listing = git https://github.com/senaite/senaite.app.listing.git pushurl[email protected]:senaite/senaite.app.listing.git branch=2.x
senaite.app.spotlight = git https://github.com/senaite/senaite.app.spotlight.git pushurl[email protected]:senaite/senaite.app.spotlight.git branch=2.x
senaite.app.supermodel = git https://github.com/senaite/senaite.app.supermodel.git pushurl[email protected]:senaite/senaite.app.supermodel.git branch=2.x
senaite.impress = git https://github.com/senaite/senaite.impress.git pushurl[email protected]:senaite/senaite.impress.git branch=2.x
senaite.jsonapi = git https://github.com/senaite/senaite.jsonapi.git pushurl[email protected]:senaite/senaite.jsonapi.git branch=2.x
senaite.lims = git https://github.com/senaite/senaite.lims.git pushurl[email protected]:senaite/senaite.lims.git branch=2.x

[instance]
recipe = plone.recipe.zope2instance
http-address = 127.0.0.1:8080
user = ${buildout:plone-user}
wsgi = off
eggs =
Plone
plone.app.upgrade
${buildout:package-name}
${buildout:eggs}
deprecation-warnings = on
environment-vars =
zope_i18n_compile_mo_files true
zcml =

[i18ndude]
unzip = true
recipe = zc.recipe.egg
eggs = i18ndude

[update_translations]
recipe = collective.recipe.template
output = ${buildout:directory}/bin/update_translations
input = ${buildout:directory}/templates/update_translations.in
mode = 755

[update_sources]
recipe = collective.recipe.template
output = ${buildout:directory}/bin/update_sources
input = ${buildout:directory}/templates/update_sources.in
mode = 755

[write_code_headers]
recipe = collective.recipe.template
output = ${buildout:directory}/bin/write_code_headers
input = ${buildout:directory}/templates/write_code_headers.py.in
mode = 755

[test]
recipe = zc.recipe.testrunner
defaults = ['--auto-color', '--auto-progress']
eggs =
senaite.patient [test]

[omelette]
recipe = collective.recipe.omelette
eggs = ${buildout:eggs}

[zopepy]
recipe = zc.recipe.egg
eggs = ${instance:eggs}
interpreter = zopepy
scripts = zopepy

[versions]
# versions taken from requirements.txt
setuptools =
zc.buildout =
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
1.5.0 (unreleased)
------------------

- #107 Compatibility with core#2567 (AnalysisCategory to DX)
- #106 Skip patient creation if the user has no permissions
- #95 Support for dynamic analysis specs with MinAge, MaxAge and Sex columns
- #98 Allow to flag patients as deceased
Expand Down
86 changes: 10 additions & 76 deletions src/senaite/patient/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,108 +19,42 @@
# Some rights reserved, see README and LICENSE.

import transaction
import unittest2 as unittest
from plone.app.testing import PLONE_FIXTURE
from plone.app.testing import TEST_USER_ID
from plone.app.testing import TEST_USER_NAME
from plone.app.testing import TEST_USER_PASSWORD
from plone.app.testing import FunctionalTesting
from plone.app.testing import PloneSandboxLayer
from plone.app.testing import applyProfile
from plone.app.testing import setRoles
from plone.app.testing import FunctionalTesting
from plone.testing import zope
from plone.testing.z2 import Browser
from senaite.core.tests.base import BaseTestCase
from senaite.core.tests.layers import BaseLayer


class SimpleTestLayer(PloneSandboxLayer):
"""Setup Plone with installed AddOn only
"""
defaultBases = (PLONE_FIXTURE,)
class SimpleTestLayer(BaseLayer):

def setUpZope(self, app, configurationContext):
super(SimpleTestLayer, self).setUpZope(app, configurationContext)

import bika.lims
import senaite.app.listing
import senaite.app.spotlight
import senaite.core
import senaite.impress
import senaite.lims
import senaite.patient

# Load ZCML
self.loadZCML(package=bika.lims)
self.loadZCML(package=senaite.lims)
self.loadZCML(package=senaite.core)
self.loadZCML(package=senaite.app.listing)
self.loadZCML(package=senaite.impress)
self.loadZCML(package=senaite.app.spotlight)
import senaite.patient
self.loadZCML(package=senaite.patient)

# Install product and call its initialize() function
zope.installProduct(app, "bika.lims")
zope.installProduct(app, "senaite.lims")
zope.installProduct(app, "senaite.core")
zope.installProduct(app, "senaite.app.listing")
zope.installProduct(app, "senaite.impress")
zope.installProduct(app, "senaite.app.spotlight")
zope.installProduct(app, "senaite.patient")

def setUpPloneSite(self, portal):
super(SimpleTestLayer, self).setUpPloneSite(portal)
applyProfile(portal, "senaite.core:default")
applyProfile(portal, "senaite.patient:default")
transaction.commit()


###
# Use for simple tests (w/o contents)
###
SIMPLE_FIXTURE = SimpleTestLayer()
SIMPLE_TEST_LAYER_FIXTURE = SimpleTestLayer()
SIMPLE_TESTING = FunctionalTesting(
bases=(SIMPLE_FIXTURE, ),
bases=(SIMPLE_TEST_LAYER_FIXTURE, ),
name="senaite.patient:SimpleTesting"
)


class SimpleTestCase(unittest.TestCase):
class SimpleTestCase(BaseTestCase):
"""Use for test cases which do not rely on demo data
"""
layer = SIMPLE_TESTING

def setUp(self):
super(SimpleTestCase, self).setUp()

self.app = self.layer["app"]
self.portal = self.layer["portal"]
self.request = self.layer["request"]
self.request["ACTUAL_URL"] = self.portal.absolute_url()
setRoles(self.portal, TEST_USER_ID, ["LabManager", "Manager"])

def getBrowser(self,
username=TEST_USER_NAME,
password=TEST_USER_PASSWORD,
loggedIn=True):

# Instantiate and return a testbrowser for convenience
browser = Browser(self.portal)
browser.addHeader("Accept-Language", "en-US")
browser.handleErrors = False
if loggedIn:
browser.open(self.portal.absolute_url())
browser.getControl("Login Name").value = username
browser.getControl("Password").value = password
browser.getControl("Log in").click()
self.assertTrue("You are now logged in" in browser.contents)
return browser


class FunctionalTestCase(unittest.TestCase):
layer = SIMPLE_TESTING

def setUp(self):
super(FunctionalTestCase, self).setUp()

self.app = self.layer["app"]
self.portal = self.layer["portal"]
self.request = self.layer["request"]
self.request["ACTUAL_URL"] = self.portal.absolute_url()
setRoles(self.portal, TEST_USER_ID, ["LabManager", "Member"])
5 changes: 5 additions & 0 deletions src/senaite/patient/tests/doctests/API.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Needed Imports:
>>> from bika.lims.api import get_review_status
>>> from datetime import date
>>> from dateutil.relativedelta import relativedelta
>>> from plone.app.testing import setRoles
>>> from plone.app.testing import TEST_USER_ID
>>> from senaite.core.api import dtime
>>> from senaite.patient import api

Expand All @@ -23,6 +25,9 @@ Variables:
>>> portal = self.portal
>>> request = self.request

Assign default roles for the user to test with:

>>> setRoles(portal, TEST_USER_ID, ['LabManager',])

Test fixture:

Expand Down
8 changes: 7 additions & 1 deletion src/senaite/patient/tests/doctests/AgeDateOfBirthField.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Needed Imports:
>>> from bika.lims.utils.analysisrequest import create_analysisrequest
>>> from DateTime import DateTime
>>> from datetime import datetime
>>> from plone.app.testing import setRoles
>>> from plone.app.testing import TEST_USER_ID
>>> from senaite.core.api import dtime
>>> from senaite.patient.api import to_ymd

Expand All @@ -39,6 +41,10 @@ Variables:
>>> sampled = DateTime("2020-12-01")
>>> birth_date = DateTime("1979-12-07")

Assign default roles for the user to test with:

>>> setRoles(portal, TEST_USER_ID, ['LabManager',])

Test fixture:

>>> import os
Expand All @@ -51,7 +57,7 @@ We need to create some basic objects for the test:
>>> sampletype = api.create(bika_setup.bika_sampletypes, "SampleType", title="Blood", Prefix="B")
>>> labcontact = api.create(bika_setup.bika_labcontacts, "LabContact", Firstname="Lab", Lastname="Manager")
>>> department = api.create(setup.departments, "Department", title="Clinical Lab", Manager=labcontact)
>>> category = api.create(bika_setup.bika_analysiscategories, "AnalysisCategory", title="Blood", Department=department)
>>> category = api.create(setup.analysiscategories, "AnalysisCategory", title="Blood", Department=department)
>>> malaria = api.create(bika_setup.bika_analysisservices, "AnalysisService", title="Malaria Count", Keyword="MC", Price="10", Category=category.UID(), Accredited=True)
>>> sample = new_sample([malaria], client, contact, sampletype, sampled, DateOfBirth=birth_date)

Expand Down
2 changes: 1 addition & 1 deletion src/senaite/patient/tests/doctests/DynamicResultRanges.rst
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Create some baseline objects for the test:
>>> sampletype = api.create(bika_setup.bika_sampletypes, "SampleType", title="EDTA", Prefix="EDTA")
>>> labcontact = api.create(bika_setup.bika_labcontacts, "LabContact", Firstname="Lab", Lastname="Manager")
>>> department = api.create(setup.departments, "Department", title="Biochemistry", Manager=labcontact)
>>> category = api.create(bika_setup.bika_analysiscategories, "AnalysisCategory", title="Biochemistry", Department=department)
>>> category = api.create(setup.analysiscategories, "AnalysisCategory", title="Biochemistry", Department=department)
>>> Ht = api.create(bika_setup.bika_analysisservices, "AnalysisService", title="Hematocrit", Keyword="Ht", Category=category)

Create a default specification for the Sample type `EDTA`:
Expand Down
6 changes: 6 additions & 0 deletions src/senaite/patient/tests/doctests/Patient.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Test Setup
Needed Imports:

>>> from bika.lims import api
>>> from plone.app.testing import setRoles
>>> from plone.app.testing import TEST_USER_ID

Variables:

Expand All @@ -20,6 +22,10 @@ Variables:
>>> setup = api.get_setup()
>>> patients = portal.patients

Assign default roles for the user to test with:

>>> setRoles(portal, TEST_USER_ID, ['LabManager',])


Patients
--------
Expand Down
7 changes: 5 additions & 2 deletions src/senaite/patient/tests/doctests/PatientSample.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,23 @@ Variables:
>>> birthdate = DateTime("1980-02-25")
>>> sampled = DateTime("2023-05-19")

Assign default roles for the user to test with:

>>> setRoles(portal, TEST_USER_ID, ['LabManager',])

Test fixture:

>>> import os
>>> os.environ["TZ"] = "CET"

We need to create some basic objects for the test:

>>> setRoles(portal, TEST_USER_ID, ['LabManager',])
>>> client = api.create(portal.clients, "Client", Name="General Hospital", ClientID="GH", MemberDiscountApplies=False)
>>> contact = api.create(client, "Contact", Firstname="Rita", Lastname="Mohale")
>>> sampletype = api.create(bika_setup.bika_sampletypes, "SampleType", title="Blood", Prefix="B")
>>> labcontact = api.create(bika_setup.bika_labcontacts, "LabContact", Firstname="Lab", Lastname="Manager")
>>> department = api.create(setup.departments, "Department", title="Clinical Lab", Manager=labcontact)
>>> category = api.create(bika_setup.bika_analysiscategories, "AnalysisCategory", title="Blood", Department=department)
>>> category = api.create(setup.analysiscategories, "AnalysisCategory", title="Blood", Department=department)
>>> MC = api.create(bika_setup.bika_analysisservices, "AnalysisService", title="Malaria Count", Keyword="MC", Price="10", Category=category.UID(), Accredited=True)
>>> MS = api.create(bika_setup.bika_analysisservices, "AnalysisService", title="Malaria Species", Keyword="MS", Price="10", Category=category.UID(), Accredited=True)

Expand Down
7 changes: 5 additions & 2 deletions src/senaite/patient/tests/doctests/PatientWorkflow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,18 @@ Variables:
>>> bika_setup = api.get_bika_setup()
>>> patients = portal.patients

We need to create some basic objects for the test:
Assign default roles for the user to test with:

>>> setRoles(portal, TEST_USER_ID, ['LabManager',])

We need to create some basic objects for the test:

>>> client = api.create(portal.clients, "Client", Name="General Hospital", ClientID="GH", MemberDiscountApplies=False)
>>> contact = api.create(client, "Contact", Firstname="Rita", Lastname="Mohale")
>>> sampletype = api.create(bika_setup.bika_sampletypes, "SampleType", title="Blood", Prefix="B")
>>> labcontact = api.create(bika_setup.bika_labcontacts, "LabContact", Firstname="Lab", Lastname="Manager")
>>> department = api.create(setup.departments, "Department", title="Clinical Lab", Manager=labcontact)
>>> category = api.create(bika_setup.bika_analysiscategories, "AnalysisCategory", title="Blood", Department=department)
>>> category = api.create(setup.analysiscategories, "AnalysisCategory", title="Blood", Department=department)
>>> MC = api.create(bika_setup.bika_analysisservices, "AnalysisService", title="Malaria Count", Keyword="MC", Price="10", Category=category.UID(), Accredited=True)
>>> MS = api.create(bika_setup.bika_analysisservices, "AnalysisService", title="Malaria Species", Keyword="MS", Price="10", Category=category.UID(), Accredited=True)

Expand Down
Loading

0 comments on commit 654d5c4

Please sign in to comment.