-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathsnomed_tests.py
44 lines (37 loc) · 1.31 KB
/
snomed_tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# RxNorm unit testing
#
# 2014-04-18 Created
import sys
import os.path
thismodule = os.path.abspath(os.path.dirname(__file__))
if thismodule not in sys.path:
sys.path.insert(0, thismodule)
import unittest
from snomed import *
class SNOMEDLookupTest(unittest.TestCase):
""" Test :class:`SNOMEDLookup`.
"""
def setUp(self):
SNOMED.check_database()
def test_term_lookup(self):
""" Test term lookup.
"""
cpt = SNOMEDConcept('215350009')
self.assertEqual(cpt.term, 'Accident involving being caught in door of road vehicle NEC, occupant of tram injured (event)')
cpt = SNOMEDConcept('315004001')
self.assertEqual(cpt.term, 'Metastasis from malignant tumor of breast')
def test_hierarchy_isa(self):
""" Test hierarchical lookup.
"""
cpt = SNOMEDConcept('315004001') # Metastasis from malignant tumor of breast
child = SNOMEDConcept('128462008') # Metastatic neoplasm (disease)
self.assertTrue(cpt.isa(child.code))
child = SNOMEDConcept('363346000') # Malignant neoplastic disease (disorder)
self.assertTrue(cpt.isa(child))
child = SNOMEDConcept('55342001') # Neoplasia
self.assertTrue(cpt.isa(child.code))
child = SNOMEDConcept('408643008') # Infiltrating duct carcinoma of breast
self.assertFalse(cpt.isa(child.code))