oship-dev team mailing list archive
-
oship-dev team
-
Mailing list archive
-
Message #01600
[Branch ~oship-dev/oship/devel] Rev 507: Fix Bug #623594. Removed archetypeIdValid and rmVersionValid in IArchetyped and changed methods _...
------------------------------------------------------------
revno: 507
committer: Eduardo
branch nick: local
timestamp: Mon 2010-11-15 00:52:48 -0200
message:
Fix Bug #623594. Removed archetypeIdValid and rmVersionValid in IArchetyped and changed methods __eq__ and __hash__ back to the default implementation.
modified:
src/oship/openehr/rm/common/archetyped/__init__.py
src/oship/openehr/rm/common/archetyped/interfaces.py
src/oship/usecaseone_tests/usecaseonetest.py
--
lp:oship
https://code.launchpad.net/~oship-dev/oship/devel
Your team OSHIP Development Team is subscribed to branch lp:oship.
To unsubscribe from this branch go to https://code.launchpad.net/~oship-dev/oship/devel/+edit-subscription
=== modified file 'src/oship/openehr/rm/common/archetyped/__init__.py'
--- src/oship/openehr/rm/common/archetyped/__init__.py 2010-10-29 14:35:25 +0000
+++ src/oship/openehr/rm/common/archetyped/__init__.py 2010-11-15 02:52:48 +0000
@@ -82,6 +82,58 @@
self.feederAudit=fdraudit
self.links=links
+ def isArchetypeRoot(self):
+ """True if this node is the root of an archetyped structure. At
+ specification there's a requiment for archetypeDetails in all root
+ points in data """
+ return self.archetypeDetails is not None
+
+ def concept(self):
+ """
+ Clinical concept of the archetype as a whole (= derived from the
+ 'archetype_node_id' of the root node) isArchetypeRoot must be True.
+ """
+ if (self.isArchetypeRoot()):
+ return DvText(self.archetypeDetails.archetypeId.conceptName())
+ raise TypeError('Not root node')
+
+ def nameValid(self):
+ """ name is not None"""
+ return self.name is not None
+
+ def linksValid(self):
+ """ links is not None and links != []"""
+ if self.links is not None:
+ return self.links != []
+ return self.links is None
+
+ def archetypedValid(self):
+ """ isArchetypeRoot xor archetypeDetails = None """
+ return xor(self.isArchetypeRoot(), self.archetypeDetails is None)
+
+ def archetypeNodeIdValid(self):
+ """ archetypeNodeId is not None and archetypeNodeId != '' """
+ if(self.archetypeNodeId is not None):
+ return self.archetypeNodeId != ''
+ return self.archetypeNodeId is None
+
+ def __eq__(self, obj):
+ if self is obj:
+ return True
+ if isinstance(obj, Locatable):
+ return obj.uid == self.uid and obj.archetypeNodeId == self.archetypeNodeId and obj.name == self.name and obj.archetypeDetails == self.archetypeDetails and obj.feederAudit == self.feederAudit and obj.links == self.links
+ return False
+
+ def __hash__(self):
+ result = 17
+ result += 31 * result + hash(self.uid)
+ result += 31 * result + hash(self.archetypeNodeId)
+ result += 31 * result + hash(self.name)
+ result += 31 * result + hash(self.archetypeDetails)
+ result += 31 * result + hash(self.feederAudit)
+ result += 31 * result + hash(self.links)
+ return result
+
class Archetyped(grok.Model):
"""
@@ -106,6 +158,20 @@
def rmVersionValid():
""" rmVersion is not None and rmVersion != '' """
+ #def __eq__(self, obj):
+ # if obj is self:
+ # return True
+ # if isinstance(obj, Archetyped):
+ # return obj.archetypeId == self.archetypeId and obj.templateId == self.templateId and obj.rmVersion == self.rmVersion
+ # return False
+ #
+ #def __hash__(self):
+ # result = 17
+ # result = 31 * result + hash(self.archetypeId)
+ # result = 31 * result + hash(self.templateId)
+ # result = 31 * result + hash(self.rmVersion)
+ # return result
+
class FeederAuditDetails(grok.Model):
u"""
@@ -149,28 +215,13 @@
class Link(persistent.Persistent):
- """
- The LINK type defines a logical relationship between two items, such as two
- ENTRYs or an ENTRY and a COMPOSITION. Links can be used across composi-
- tions, and across EHRs. Links can potentially be used between interior
- (i.e. non archetype root) nodes, although this probably should be prevented
- in archetypes. Multiple LINKs can be attached to the root object of any
- archetyped structure to give the effect of a 1->N link 1:1 and 1:N
- relationships between archetyped content elements (e.g. ENTRYs) can be
- expressed by using one, or more than one, respectively, DV_LINKs. Chains of
- links can be used to see "problem threads" or other logical groupings of
- items. Links should be between archetyped structures only, i.e. between
- objects representing complete domain concepts because relationships between
- sub-elements of whole concepts are not necessarily meaningful, and may be
- downright confusing. Sensible links only exist between whole ENTRYs,
- SECTIONs, COMPOSITIONs and so on. """
grok.implements(ILink)
- def __init__(self, meaning, type, target):
+ def __init__(self, meaning, type_, target):
self.meaning=meaning
- self.type=type
+ self.type=type_
self.target=target
self.meaningValid()
self.typeValid()
@@ -185,9 +236,10 @@
"""Return type is not None """
if self.type is None:
raise ValueError(u'type cannot be None')
-
+
def targetValid(self):
"""Return target is not None """
if self.target is None:
raise ValueError(u'target cannot be None')
-
+
+
=== modified file 'src/oship/openehr/rm/common/archetyped/interfaces.py'
--- src/oship/openehr/rm/common/archetyped/interfaces.py 2010-10-29 14:35:25 +0000
+++ src/oship/openehr/rm/common/archetyped/interfaces.py 2010-11-15 02:52:48 +0000
@@ -220,12 +220,6 @@
"1.0", "1.2.4". """),
)
- def archetypeIdValid():
- """ archetypeId is not None """
-
- def rmVersionValid():
- """ rmVersion is not None and rmVersion != '' """
-
class IPathable(Interface):
"""
@@ -340,27 +334,28 @@
required=False,
)
-
- def nameValid(obj):
- """ name is not None"""
- if self.name is None:
- raise Invalid("The name attribute cannot be None.")
-
-
- def linksValid(obj):
- """ links is not None and links != []"""
- if self.links is None:
- raise Invalid("The links attribute cannot be None.")
-
- def archetypedValid(obj):
- """ isArchetypeRoot xor archetypeDetails = None """
- return xor(self.isArchetypeRoot(), self.archetypeDetails is None)
-
- def archetypeNodeIdValid(obj):
- """ archetypeNodeId is not None and archetypeNodeId != '' """
- if self.archetypeNodeId is None and self.archetypeNodeId == '':
- raise Invalid("The archetypeNodeId attribute cannot be empty if not None")
-
+ def isArchetypeRoot():
+ u"""True if this node is the root of an archetyped structure."""
+
+ def concept():
+ u"""
+ Clinical concept of the archetype as a whole (= derived from the
+ 'archetype_node_id' of the root node) isArchetypeRoot must be True.
+ """
+
+ def nameValid():
+ u""" name is not None"""
+
+ def linksValid():
+ u""" links is not None and links != []"""
+
+ def archetypedValid():
+ u""" isArchetypeRoot xor archetypeDetails = None """
+
+ def archetypeNodeIdValid():
+ u""" archetypeNodeId is not None and archetypeNodeId != '' """
+
+
class IFeederAuditDetails(Interface):
u"""
Audit details for any system in a feeder system chain. Audit details here
=== modified file 'src/oship/usecaseone_tests/usecaseonetest.py'
--- src/oship/usecaseone_tests/usecaseonetest.py 2010-10-29 14:35:25 +0000
+++ src/oship/usecaseone_tests/usecaseonetest.py 2010-11-15 02:52:48 +0000
@@ -36,7 +36,6 @@
self.assertEqual(self.role1.timeValidity, None)
self.assertEqual(self.role1.performer, self.createRole1Performer())
self.assertEqual(self.role1.uid, self.createRole1Uid())
- #self.assertEqual(self.role1.identities, self.createRole1Identities())
self.assertEqual(self.role1.contacts, None)
self.assertEqual(self.role1.relationships, None)
self.assertEqual(self.role1.reverseRelationships, None)
@@ -46,25 +45,21 @@
self.assertEqual(self.role1.feederAudit, None)
self.assertEqual(self.role1.links, None)
anotherRole1 = self.createRole1()
- #self.assertEqual(self.role1, anotherRole1)
def testCreatePerson1(self):
person1 = self.createPerson1()
self.assertEqual(self.person1.roles, self.createPerson1Roles())
self.assertEqual(self.person1.languages, None)
self.assertEqual(self.person1.uid, self.createPerson1Uid())
- #self.assertEqual(self.person1.identities, self.createPerson1Identities())
self.assertEqual(self.person1.contacts, None)
self.assertEqual(self.person1.relationships, None)
self.assertEqual(self.person1.reverseRelationships, None)
self.assertEqual(self.person1.details, None)
self.assertEqual(self.person1.archetypeNodeId, self.createPerson1ArchetypeNodeId())
self.assertEqual(self.person1.name, self.createPerson1Name())
- #self.assertEqual(self.person1.archetypeDetails, self.createPerson1ArchetypeDetails())
self.assertEqual(self.person1.feederAudit, None)
self.assertEqual(self.person1.links, None)
anotherPerson1 = self.createPerson1()
- #self.assertEqual(self.person1, anotherPerson1)
def testCreateEvaluation(self):
self.createEvaluation()