1
|
|
|
# -*- coding: utf-8 -*- |
2
|
|
|
# |
3
|
|
|
# This file is part of SENAITE.HEALTH. |
4
|
|
|
# |
5
|
|
|
# SENAITE.HEALTH is free software: you can redistribute it and/or modify it |
6
|
|
|
# under the terms of the GNU General Public License as published by the Free |
7
|
|
|
# Software Foundation, version 2. |
8
|
|
|
# |
9
|
|
|
# This program is distributed in the hope that it will be useful, but WITHOUT |
10
|
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
11
|
|
|
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
12
|
|
|
# details. |
13
|
|
|
# |
14
|
|
|
# You should have received a copy of the GNU General Public License along with |
15
|
|
|
# this program; if not, write to the Free Software Foundation, Inc., 51 |
16
|
|
|
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
17
|
|
|
# |
18
|
|
|
# Copyright 2018-2019 by it's authors. |
19
|
|
|
# Some rights reserved, see README and LICENSE. |
20
|
|
|
|
21
|
|
|
from zope.i18nmessageid import MessageFactory |
22
|
|
|
bikaMessageFactory = MessageFactory('senaite.health') |
23
|
|
|
_ = MessageFactory('senaite.health') |
24
|
|
|
|
25
|
|
|
import logging |
26
|
|
|
logger = logging.getLogger('senaite.health') |
27
|
|
|
|
28
|
|
|
from bika.health.validators import * |
29
|
|
|
from bika.health.config import * |
30
|
|
|
from bika.health import permissions |
31
|
|
|
from Products.CMFCore.permissions import AddPortalContent |
32
|
|
|
|
33
|
|
|
from AccessControl import allow_module |
34
|
|
|
from Products.Archetypes.atapi import process_types, listTypes |
35
|
|
|
from Products.CMFCore import utils as plone_utils |
36
|
|
|
|
37
|
|
|
|
38
|
|
|
|
39
|
|
|
# Make senaite.health modules importable by through-the-web |
40
|
|
|
# https://docs.plone.org/develop/plone/security/sandboxing.html |
41
|
|
|
# https://docs.zope.org/zope2/zdgbook/Security.html |
42
|
|
|
# This allows Script python (e.g. guards from skins) to access to these modules. |
43
|
|
|
# To provide access to a module inside of a package, we need to provide security |
44
|
|
|
# declarations for all of the the packages and sub-packages along the path |
45
|
|
|
# used to access the module. Thus, all the modules from the path passed in to |
46
|
|
|
# `allow_module` will be available. |
47
|
|
|
# TODO Check if we really need to allow utils module |
48
|
|
|
allow_module('bika.health') |
49
|
|
|
allow_module('bika.health.utils') |
50
|
|
|
|
51
|
|
|
|
52
|
|
|
def initialize(context): |
53
|
|
|
|
54
|
|
|
from content.aetiologicagent import AetiologicAgent |
55
|
|
|
from content.caseoutcome import CaseOutcome |
56
|
|
|
from content.casestatus import CaseStatus |
57
|
|
|
from content.ethnicity import Ethnicity |
58
|
|
|
from content.casesyndromicclassification import CaseSyndromicClassification |
59
|
|
|
from content.disease import Disease |
60
|
|
|
from content.doctor import Doctor |
61
|
|
|
from content.doctors import Doctors |
62
|
|
|
from content.drug import Drug |
63
|
|
|
from content.drugprohibition import DrugProhibition |
64
|
|
|
from content.identifiertype import IdentifierType |
65
|
|
|
from content.immunization import Immunization |
66
|
|
|
from content.insurancecompany import InsuranceCompany |
67
|
|
|
from content.patient import Patient |
68
|
|
|
from content.patients import Patients |
69
|
|
|
from content.symptom import Symptom |
70
|
|
|
from content.treatment import Treatment |
71
|
|
|
from content.vaccinationcenter import VaccinationCenter |
72
|
|
|
from content.vaccinationcentercontact import VaccinationCenterContact |
73
|
|
|
|
74
|
|
|
from controlpanel.bika_aetiologicagents import AetiologicAgents |
75
|
|
|
from controlpanel.bika_caseoutcomes import CaseOutcomes |
76
|
|
|
from controlpanel.bika_casesyndromicclassifications import CaseSyndromicClassifications |
77
|
|
|
from controlpanel.bika_casestatuses import CaseStatuses |
78
|
|
|
from controlpanel.bika_diseases import Diseases |
79
|
|
|
from controlpanel.bika_drugprohibitions import DrugProhibitions |
80
|
|
|
from controlpanel.bika_drugs import Drugs |
81
|
|
|
from controlpanel.bika_identifiertypes import IdentifierTypes |
82
|
|
|
from controlpanel.bika_immunizations import Immunizations |
83
|
|
|
from controlpanel.bika_treatments import Treatments |
84
|
|
|
from controlpanel.bika_insurancecompanies import InsuranceCompanies |
85
|
|
|
from controlpanel.bika_ethnicities import Ethnicities |
86
|
|
|
from controlpanel.bika_vaccinationcenters import VaccinationCenters |
87
|
|
|
|
88
|
|
|
content_types, constructors, ftis = process_types( |
89
|
|
|
listTypes(PROJECTNAME), |
90
|
|
|
PROJECTNAME) |
91
|
|
|
|
92
|
|
|
allTypes = zip(content_types, constructors) |
93
|
|
|
for atype, constructor in allTypes: |
94
|
|
|
kind = "%s: Add %s" % (config.PROJECTNAME, atype.portal_type) |
|
|
|
|
95
|
|
|
perm_name = "Add{}".format(atype.portal_type) |
96
|
|
|
perm = getattr(permissions, perm_name, AddPortalContent) |
97
|
|
|
plone_utils.ContentInit(kind, |
98
|
|
|
content_types = (atype,), |
99
|
|
|
permission = perm, |
100
|
|
|
extra_constructors = (constructor,), |
101
|
|
|
fti = ftis, |
102
|
|
|
).initialize(context) |
103
|
|
|
|