← Back to team overview

oship-dev team mailing list archive

[Branch ~oship-dev/oship/devel] Rev 525: Fixed code that uses the TerminologyService.

 

------------------------------------------------------------
revno: 525
committer: Diego Manhães Pinheiro <me@xxxxxxxxxxxxxx>
branch nick: trunk
timestamp: Tue 2010-12-14 20:55:47 -0200
message:
  Fixed code that uses the TerminologyService.
modified:
  src/oship/openehr/rm/common/change_control/__init__.py
  src/oship/openehr/rm/common/change_control/tests/originalversion.py
  src/oship/openehr/rm/datatypes/text/__init__.py
  src/oship/openehr/rm/datatypes/text/tests/dvtext.py
  src/oship/openehr/rm/datatypes/text/tests/termmapping.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/change_control/__init__.py'
--- src/oship/openehr/rm/common/change_control/__init__.py	2010-12-04 00:30:48 +0000
+++ src/oship/openehr/rm/common/change_control/__init__.py	2010-12-14 22:55:47 +0000
@@ -37,7 +37,7 @@
 
     grok.implements(IVersion)
 
-    def __init__(self, uid, preVid, data, lcstate, caudit, contribution, sig, terminologyService=None):
+    def __init__(self, uid, preVid, data, lcstate, caudit, contribution, sig, term_service=None):
         if uid.versionTreeId().isFirst() == (preVid!=None):
             raise ValueError(u"If this is the first version it's not possible to have a preceding version uid and vice-versa.")
         if contribution == None or contribution.type != 'CONTRIBUTION':
@@ -46,8 +46,11 @@
             raise AttributeError(u'lcstate must not be None')
 
         #TODO remove this consistence when we finish implementing the terminologyService
-        if terminologyService is not None:
-            if not terminologyService.terminology(TerminologyService.OPENEHR).hasCodeForGroupId('group_id_version_lifecycle_state', lcstate.definingCode):
+        if term_service is not None:
+            OPENEHR_TERMINOLOGY_NAME = TerminologyService.TERMINOLOGY_ID
+            openehr_terminology = term_service.terminology(OPENEHR_TERMINOLOGY_NAME)
+            GROUP_ID_TERM_MAPPING_PURPOSE = TerminologyService.GROUP_ID_TERM_MAPPING_PURPOSE
+            if not openehr_terminology.has_code_for_group_id(GROUP_ID_TERM_MAPPING_PURPOSE, lcstate.definingCode):
                 raise AttributeError(u'lifecycle state must be in terminology service')
         self.uid=uid
         self.precedingVersionId=preVid

=== modified file 'src/oship/openehr/rm/common/change_control/tests/originalversion.py'
--- src/oship/openehr/rm/common/change_control/tests/originalversion.py	2010-11-21 03:20:28 +0000
+++ src/oship/openehr/rm/common/change_control/tests/originalversion.py	2010-12-14 22:55:47 +0000
@@ -79,7 +79,7 @@
     def __init__(self, returnValue):
         self.returnValue = returnValue
 
-    def hasCodeForGroupId(self, groupId,code):
+    def has_code_for_group_id(self, groupId,code):
         return self.returnValue
 
 

=== modified file 'src/oship/openehr/rm/datatypes/text/__init__.py'
--- src/oship/openehr/rm/datatypes/text/__init__.py	2010-11-21 03:23:52 +0000
+++ src/oship/openehr/rm/datatypes/text/__init__.py	2010-12-14 22:55:47 +0000
@@ -24,7 +24,8 @@
     def __init__(self,target,match,purpose, terminologyService=None):
         self.target = target
         if purpose is not None:
-            if not terminologyService.terminology(TerminologyService.OPENEHR).hasCodeForGroupId('Group Id Term Mapping Purpose', purpose.definingCode):
+            openehr_terminology = terminologyService.terminology(TerminologyService.TERMINOLOGY_ID)
+            if not openehr_terminology.has_code_for_group_id(TerminologyService.GROUP_ID_TERM_MAPPING_PURPOSE, purpose.definingCode):
                 raise AttributeError(u'Terminology service must have the purpose defining code')
         self.purpose = purpose
         if match in ['<','>','=','?']:
@@ -92,9 +93,13 @@
 
         #TODO we need to remove this consistence when we finish the terminologyService
         if terminologyService is not None:
-            if language is not None and not terminologyService.codeSetForId(u'code_set_id_languages').hasCode(language):
+            CODE_SET_ID_LANGUAGES = TerminologyService.CODE_SET_ID_LANGUAGES
+            code_set = terminologyService.code_set_for_id(CODE_SET_ID_LANGUAGES)
+            if language is not None and not code_set.has_code(language):
                 raise AttributeError(u'language must be in the language code set of the terminology service')
-            if encoding is not None and not terminologyService.codeSetForId(u'code_set_id_character_sets').hasCode(encoding):
+            CODE_SET_ID_CHARACTER_SETS = TerminologyService.CODE_SET_ID_CHARACTER_SETS
+            code_set = terminologyService.code_set_for_id(CODE_SET_ID_CHARACTER_SETS)
+            if encoding is not None and not code_set.has_code(encoding):
                 raise AttributeError(u'encoding must be in the character code set of the terminology service')
         self.value=value
         self.mappings=mappings

=== modified file 'src/oship/openehr/rm/datatypes/text/tests/dvtext.py'
--- src/oship/openehr/rm/datatypes/text/tests/dvtext.py	2010-11-21 02:17:24 +0000
+++ src/oship/openehr/rm/datatypes/text/tests/dvtext.py	2010-12-14 22:55:47 +0000
@@ -83,7 +83,7 @@
     def __init__(self, returnValue):
         self.returnValue = returnValue
 
-    def codeSetForId(self, id):
+    def code_set_for_id(self, id):
         return DummyCodeSetAccess(self.returnValue)
 
 class DummyCodeSetAccess(object):
@@ -91,6 +91,6 @@
     def __init__(self, returnValue):
         self.returnValue = returnValue
 
-    def hasCode(self, code):
+    def has_code(self, code):
         return self.returnValue
 

=== modified file 'src/oship/openehr/rm/datatypes/text/tests/termmapping.py'
--- src/oship/openehr/rm/datatypes/text/tests/termmapping.py	2010-11-21 01:25:08 +0000
+++ src/oship/openehr/rm/datatypes/text/tests/termmapping.py	2010-12-14 22:55:47 +0000
@@ -41,6 +41,7 @@
     def __init__(self, returnValue):
         self.returnValue = returnValue
 
-    def hasCodeForGroupId(self, groupId, code):
+    def has_code_for_group_id(self, groupId, code):
         return self.returnValue
 
+