#LyX 2.0 created this file. For more info see http://www.lyx.org/
\lyxformat 413
\begin_document
\begin_header
\textclass article
\begin_preamble
\usepackage{ae,aecompl}
\end_preamble
\use_default_options false
\maintain_unincluded_children false
\language english
\language_package default
\inputencoding auto
\fontencoding global
\font_roman default
\font_sans default
\font_typewriter default
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100

\graphics default
\default_output_format default
\output_sync 0
\bibtex_command default
\index_command default
\paperfontsize default
\spacing single
\use_hyperref false
\papersize a4paper
\use_geometry true
\use_amsmath 1
\use_esint 0
\use_mhchem 0
\use_mathdots 1
\cite_engine basic
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\use_refstyle 0
\index Index
\shortcut idx
\color #008000
\end_index
\leftmargin 1cm
\topmargin 1cm
\rightmargin 1cm
\bottommargin 2cm
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\paragraph_indentation default
\quotes_language english
\papercolumns 1
\papersides 1
\paperpagestyle default
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\end_header

\begin_body

\begin_layout Title
PyMedTermino
\end_layout

\begin_layout Author
Jean-Baptiste Lamy
\end_layout

\begin_layout Standard
\begin_inset ERT
status open

\begin_layout Plain Layout


\backslash
sloppy
\end_layout

\end_inset


\end_layout

\begin_layout Section
Introduction
\end_layout

\begin_layout Standard
PyMedTermino (Medical Terminologies for Python) is a Python module for easy
 access to the main medical terminologies in Python.
 The following terminologies are available:
\end_layout

\begin_layout Itemize
SNOMED CT
\end_layout

\begin_layout Itemize
ICD10
\end_layout

\begin_layout Itemize
UMLS
\end_layout

\begin_layout Itemize
VCM icons (an iconic terminology developped at Paris 13 University)
\end_layout

\begin_layout Standard
The main features of PyMedTermino are:
\end_layout

\begin_layout Itemize
A single API for accessing all terminologies
\end_layout

\begin_layout Itemize
Optimized full-text search
\end_layout

\begin_layout Itemize
Access to label, synonyms and translations
\end_layout

\begin_layout Itemize
Manage concepts and relations between concepts
\end_layout

\begin_layout Itemize
Mappings between terminologies, through UMLS or manual mapping files
\end_layout

\begin_layout Standard
\begin_inset space ~
\end_inset


\end_layout

\begin_layout Standard
For SNOMED CT and ICD10, the data are not included (because they are not
 freely redistribuable) but they can be downloaded for free in XML format.
 PyMedTermino includes scripts for exporting these data into SQLite3 databases.
\end_layout

\begin_layout Standard
For UMLS, data are not included (for the same reasons, and because they
 are voluminous).
 Thus, PyMedTermino need to be connected to a MySQL server including UMLS
 data, as provided by the NLM.
\end_layout

\begin_layout Standard
For VCM icons, the whole terminologies are provided as OWL ontologies and
 SQLite3 databases.
 However, the icons' image files are not included and must be downloaded
 separately (or you can use the VCM iconic server to generate icons dynamically)
: PyMedTermino only include the terminological part of VCM.
\end_layout

\begin_layout Standard
\begin_inset space ~
\end_inset


\end_layout

\begin_layout Standard
PyMedTermino has been created at the LIM&BIO reseach lab, Paris 13 University,
 Sorbonne Paris Cité, by Jean-Baptiste Lamy.
 PyMedTermino is available under the GNU LGPL licence.
\end_layout

\begin_layout Standard
\begin_inset space ~
\end_inset


\end_layout

\begin_layout Standard
Here is an example of what you can do with PyMedTermino:
\end_layout

\begin_layout Standard
\begin_inset space ~
\end_inset


\end_layout

\begin_layout LyX-Code
>>> SNOMEDCT.search("tachycardia*")
\end_layout

\begin_layout LyX-Code
[SNOMEDCT[3424008]  # Tachycardia (finding)
\end_layout

\begin_layout LyX-Code
, SNOMEDCT[4006006]  # Fetal tachycardia affecting management of mother
 (disorder)
\end_layout

\begin_layout LyX-Code
, SNOMEDCT[6456007]  # Supraventricular tachycardia (disorder)
\end_layout

\begin_layout LyX-Code
...]
\end_layout

\begin_layout LyX-Code
 
\end_layout

\begin_layout LyX-Code
>>> SNOMEDCT[3424008].parents
\end_layout

\begin_layout LyX-Code
[SNOMEDCT[301113001]  # Finding of heart rate (finding)
\end_layout

\begin_layout LyX-Code
]
\end_layout

\begin_layout LyX-Code
 
\end_layout

\begin_layout LyX-Code
>>> SNOMEDCT[3424008].children
\end_layout

\begin_layout LyX-Code
[SNOMEDCT[11092001]  # Sinus tachycardia (finding)
\end_layout

\begin_layout LyX-Code
, SNOMEDCT[278086000]  # Baseline tachycardia (finding)
\end_layout

\begin_layout LyX-Code
, SNOMEDCT[162992001]  # On examination - pulse rate tachycardia (finding)
\end_layout

\begin_layout LyX-Code
...]
\end_layout

\begin_layout LyX-Code
 
\end_layout

\begin_layout LyX-Code
>>> list(SNOMEDCT[3424008].ancestors_no_double())
\end_layout

\begin_layout LyX-Code
[SNOMEDCT[301113001]  # Finding of heart rate (finding)
\end_layout

\begin_layout LyX-Code
, SNOMEDCT[106066004]  # Cardiac rhythm AND/OR rate finding (finding)
\end_layout

\begin_layout LyX-Code
, SNOMEDCT[250171008]  # Clinical history and observation findings (finding)
\end_layout

\begin_layout LyX-Code
, SNOMEDCT[404684003]  # Clinical finding (finding)
\end_layout

\begin_layout LyX-Code
, SNOMEDCT[138875005]  # SNOMED CT Concept (SNOMED RT+CTV3)
\end_layout

\begin_layout LyX-Code
...]
\end_layout

\begin_layout LyX-Code
 
\end_layout

\begin_layout LyX-Code
>>> SNOMEDCT[3424008].relations
\end_layout

\begin_layout LyX-Code
set(['INVERSE_has_definitional_manifestation', 'finding_site', 'interprets',
 'has_interpretation', 'INVERSE_associated_with'])
\end_layout

\begin_layout LyX-Code
 
\end_layout

\begin_layout LyX-Code
>>> SNOMEDCT[3424008].finding_site
\end_layout

\begin_layout LyX-Code
[SNOMEDCT[24964005]  # Cardiac conducting system structure (body structure)
\end_layout

\begin_layout LyX-Code
]
\end_layout

\begin_layout LyX-Code
 
\end_layout

\begin_layout LyX-Code
>>> SNOMEDCT[3424008] >> VCM   # Maps the SNOMED CT concept to VCM icon
\end_layout

\begin_layout LyX-Code
Concepts([
\end_layout

\begin_layout LyX-Code
  VCM[u"current--hyper--heart_rhythm"]  # 
\end_layout

\begin_layout LyX-Code
])
\end_layout

\begin_layout Section
Installation
\end_layout

\begin_layout Enumerate
Uncompress PyMedTermino-X.Y.tar.bz2
\end_layout

\begin_layout Enumerate
After registration with NLM, download SNOMED CT data:
\end_layout

\begin_deeper
\begin_layout Itemize
\begin_inset CommandInset href
LatexCommand href
target "http://www.nlm.nih.gov/research/umls/licensedcontent/snomedctfiles.html"

\end_inset


\begin_inset Newline newline
\end_inset

(download 
\begin_inset Quotes eld
\end_inset

SnomedCT_Release_INT_<date>.zip
\begin_inset Quotes erd
\end_inset

 and unzip)
\end_layout

\begin_layout Itemize
\begin_inset CommandInset href
LatexCommand href
target "http://www.nlm.nih.gov/research/umls/Snomed/core_subset.html"

\end_inset


\begin_inset Newline newline
\end_inset

(download 
\begin_inset Quotes eld
\end_inset

SNOMEDCT_CORE_SUBSET_<date>
\begin_inset Quotes erd
\end_inset

 and unzip)
\end_layout

\end_deeper
\begin_layout Enumerate
After registration, download CIM10 data and its translations:
\end_layout

\begin_deeper
\begin_layout Itemize
\begin_inset CommandInset href
LatexCommand href
target "http://apps.who.int/classifications/apps/icd/ClassificationDownload/DLArea/Download.aspx"

\end_inset


\begin_inset Newline newline
\end_inset

(download ICD10 - 
\begin_inset Quotes eld
\end_inset

ClaML
\begin_inset Quotes erd
\end_inset

 format and unzip)
\end_layout

\begin_layout Itemize
\begin_inset CommandInset href
LatexCommand href
target "http://www.icd10.ch/"

\end_inset


\begin_inset Newline newline
\end_inset

(optional, for French and Deutch translations; download the XML format and
 unzip)
\end_layout

\end_deeper
\begin_layout Enumerate
Edit the setup.py file and indicate the 4 paths where you have uncompressed
 the data, for example:
\end_layout

\begin_deeper
\begin_layout LyX-Code
SNOMEDCT_DIR = "/home/jiba/telechargements/base_med/SnomedCT_Release_INT_2013073
1"
\end_layout

\begin_layout LyX-Code
SNOMEDCT_CORE_FILE = "/home/jiba/telechargements/base_med/SNOMEDCT_CORE_SUBSET_2
01308.txt"
\end_layout

\begin_layout LyX-Code
ICD10_DIR = "/home/jiba/telechargements/base_med/icd10"
\end_layout

\begin_layout LyX-Code
CIM10_DIR = "/home/jiba/telechargements/base_med/cim10"
\end_layout

\begin_layout Standard
Note: you can put empty strings if you don't want to instal the corresponding
 terminologies.
\end_layout

\end_deeper
\begin_layout Enumerate
Compile PyMedTermino and convert the downloaded data in SQLite3 SQL databases:
\end_layout

\begin_deeper
\begin_layout LyX-Code
python setup.py build
\end_layout

\begin_layout Standard
Caution : the database creation require an important disk space (~1-2 Gb).
\end_layout

\end_deeper
\begin_layout Enumerate
Obtain root permissions.
 Under Linux, depending on your distribution, use one of the following commands:
\end_layout

\begin_deeper
\begin_layout LyX-Code
su # Mageia,...
\end_layout

\begin_layout LyX-Code
sudo -i # Ubuntu, Linux Mint,...
\end_layout

\end_deeper
\begin_layout Enumerate
Instal PyMedTermino:
\end_layout

\begin_deeper
\begin_layout LyX-Code
python setup.py install
\end_layout

\end_deeper
\begin_layout Enumerate
Clean the installation directory (optional, but frees an important disk
 space!):
\end_layout

\begin_deeper
\begin_layout LyX-Code
python setup.py clean
\end_layout

\end_deeper
\begin_layout Subsection
Troubleshooting
\end_layout

\begin_layout Subsubsection
OperationalError: no such module: fts4
\end_layout

\begin_layout Standard
Under Windows, if you encounter this problem during install, you need to
 update the Sqlite3 DLL.
 For this, download the last version from 
\begin_inset CommandInset href
LatexCommand href
target "http://www.sqlite.org/download.html"

\end_inset

, and replace the DLL in the Python27/DLLs directory by the downloaded version.
\end_layout

\begin_layout Subsubsection
IOError: [Errno 22] Invalid argument
\end_layout

\begin_layout Standard
Under Windows, you get this error if the voluminous SNOMED CT files are
 in a shared directory.
 This limitation is due to the Microsoft system, thus you must put SNOMED
 CT files in a local directory (or use a real OS man :).
\end_layout

\begin_layout Section
Loading modules and setting global parameters
\end_layout

\begin_layout LyX-Code
>>> import pymedtermino
\end_layout

\begin_layout LyX-Code
>>> pymedtermino.LANGUAGE = "en"
\end_layout

\begin_layout LyX-Code
>>> pymedtermino.REMOVE_SUPPRESSED_CONCEPTS = 1
\end_layout

\begin_layout Standard
The following global parameters are available :
\end_layout

\begin_layout Itemize
pymedtermino.DATA_DIR : the directory where SQLite3 database files containing
 terminologies are located.
 Default : PyMedTermino directory.
\end_layout

\begin_layout Itemize
pymedtermino.LANGUAGE : the default language used for terms, when several
 translations are available.
 If the desired language is not available, it defaults to English.
 CAUTION : this parameter must be set BEFORE loading terminologies.
 Default : "en" (English).
\end_layout

\begin_layout Itemize
pymedtermino.REMOVE_SUPPRESSED_CONCEPTS : if true, concepts tagged as suppressed
 or depreciated in terminologies are skipped.
 Default : 1 (true).
\end_layout

\begin_layout Itemize
pymedtermino.REMOVE_SUPPRESSED_TERMS : if true, terms (=translations) tagged
 as suppressed or depreciated in terminologies are skipped.
 Default : 1 (true).
\end_layout

\begin_layout Itemize
pymedtermino.REMOVE_SUPPRESSED_RELATIONS : if true, relations tagged as suppresse
d or depreciated in terminologies are skipped.
 Default : 1 (true).
\end_layout

\begin_layout Section
SNOMED CT
\end_layout

\begin_layout Subsection
Loading modules
\end_layout

\begin_layout Standard
It is now possible to import SNOMED CT in Python:
\end_layout

\begin_layout LyX-Code
>>> from pymedtermino import * 
\end_layout

\begin_layout LyX-Code
>>> from pymedtermino.snomedct import *
\end_layout

\begin_layout Subsection
Concepts
\end_layout

\begin_layout Standard
The SNOMEDCT object represents the SNOMED CT terminology.
 A SNOMED CT concept can be obtained from its code (in the following example,
 302509004, which is the code for the heart concept) by indexing this object
 with curly brackets:
\end_layout

\begin_layout LyX-Code
>>> concept = SNOMEDCT[302509004]
\end_layout

\begin_layout LyX-Code
>>> concept
\end_layout

\begin_layout LyX-Code
SNOMEDCT[302509004]  # Entire heart (body structure)
\end_layout

\begin_layout Standard
The has_concept() method can be used to verify if a code corresponds to
 a concept or not:
\end_layout

\begin_layout LyX-Code
>>> SNOMEDCT.has_concept("invalid_code")
\end_layout

\begin_layout LyX-Code
False
\end_layout

\begin_layout Standard
Each concept has a code and a term (= label corresponding to the preferred
 term) :
\end_layout

\begin_layout LyX-Code
>>> concept.code
\end_layout

\begin_layout LyX-Code
302509004
\end_layout

\begin_layout LyX-Code
 
\end_layout

\begin_layout LyX-Code
>>> concept.term
\end_layout

\begin_layout LyX-Code
u'Entire heart (body structure)'
\end_layout

\begin_layout Standard
SNOMED CT also proposes synonym terms (notice the 
\begin_inset Quotes eld
\end_inset

s
\begin_inset Quotes erd
\end_inset

 on 
\begin_inset Quotes eld
\end_inset

terms
\begin_inset Quotes erd
\end_inset

) :
\end_layout

\begin_layout LyX-Code
>>> concept.terms
\end_layout

\begin_layout LyX-Code
[u'Heart', u'Entire heart', u'Entire heart (body structure)']
\end_layout

\begin_layout LyX-Code

\end_layout

\begin_layout Subsection
Full-text search
\end_layout

\begin_layout Standard
The search() method allows full-text search in SNOMED CT terms (including
 synonyms):
\end_layout

\begin_layout LyX-Code
>>> SNOMEDCT.search("Cardiac structure")
\end_layout

\begin_layout LyX-Code
[ SNOMEDCT[80891009] # Heart structure (body structure)
\end_layout

\begin_layout LyX-Code
, SNOMEDCT[308793001] # Embryonic cardiac structure (body structure)
\end_layout

\begin_layout LyX-Code
...]
\end_layout

\begin_layout Standard
Full-text search uses the FTS engine of SQLite, it is thus possible to use
 its functionalities.
 For example, for searching for all words beginning by a given prefix:
\end_layout

\begin_layout LyX-Code
>>> SNOMEDCT.search("osteo*")
\end_layout

\begin_layout LyX-Code
[ SNOMEDCT[1551001]  # Osteomyelitis of femur (disorder)
\end_layout

\begin_layout LyX-Code
, SNOMEDCT[4598005]  # Osteomalacia (disorder)
\end_layout

\begin_layout LyX-Code
...]
\end_layout

\begin_layout Subsection
Is-a relations: parent and child concepts
\end_layout

\begin_layout Standard
The 
\begin_inset Quotes eld
\end_inset

parents
\begin_inset Quotes erd
\end_inset

 and 
\begin_inset Quotes eld
\end_inset

children
\begin_inset Quotes erd
\end_inset

 attributes return the list of parent and child concepts (i.e.
 the concepts with is-a relations):
\end_layout

\begin_layout LyX-Code
>>> concept.parents
\end_layout

\begin_layout LyX-Code
[SNOMEDCT[116004006]  # Hollow viscus (body structure)
\end_layout

\begin_layout LyX-Code
, SNOMEDCT[80891009]  # Heart structure (body structure)
\end_layout

\begin_layout LyX-Code
, SNOMEDCT[187639008]  # Entire thoracic viscus (body structure)
\end_layout

\begin_layout LyX-Code
]
\end_layout

\begin_layout LyX-Code
>>> concept.children
\end_layout

\begin_layout LyX-Code
[SNOMEDCT[195591003]  # Entire transplanted heart (body structure)
\end_layout

\begin_layout LyX-Code
]
\end_layout

\begin_layout Standard
The ancestors() and descendants() methods return all the ancestor concepts
 (parents, parents of parents, and so on) and the descendant concepts (children,
 children of children, and so on) :
\end_layout

\begin_layout LyX-Code
>>> for ancestor in concept.ancestors(): print ancestor
\end_layout

\begin_layout LyX-Code
SNOMEDCT[116004006]  # Hollow viscus (body structure)
\end_layout

\begin_layout LyX-Code
SNOMEDCT[118760003]  # Entire viscus (body structure)
\end_layout

\begin_layout LyX-Code
SNOMEDCT[272625005]  # Entire body organ (body structure)
\end_layout

\begin_layout LyX-Code
[...]
\end_layout

\begin_layout Standard
The ancestors() and descendants() methods return Python generators; to obtain
 a list of ancestors or descendants, you should use the list() function:
\end_layout

\begin_layout LyX-Code
>>> concept.ancestors()
\end_layout

\begin_layout LyX-Code
<generator object ancestors at 0xb3f734c>
\end_layout

\begin_layout LyX-Code
 
\end_layout

\begin_layout LyX-Code
>>> list(concept.ancestors())
\end_layout

\begin_layout LyX-Code
[SNOMEDCT[116004006]  # Hollow viscus (body structure)
\end_layout

\begin_layout LyX-Code
, SNOMEDCT[118760003]  # Entire viscus (body structure)
\end_layout

\begin_layout LyX-Code
, SNOMEDCT[272625005]  # Entire body organ (body structure)
\end_layout

\begin_layout LyX-Code
,...]
\end_layout

\begin_layout LyX-Code
 
\end_layout

\begin_layout LyX-Code
>>> list(concept.descendants())
\end_layout

\begin_layout LyX-Code
[SNOMEDCT[195591003]  # Entire transplanted heart (body structure)
\end_layout

\begin_layout LyX-Code
]
\end_layout

\begin_layout LyX-Code

\end_layout

\begin_layout Standard
ancestors_no_double() and descendants_no_double() methods behave identically
 but without duplicates.
 self_and_ancestors() and self_and_descendants() methods behave identically
 but include the concept itself in the returned concepts.
 self_and_ancestors_no_double() and self_and_descendants_no_double() methods
 combine both behaviors.
\end_layout

\begin_layout Standard
Finally, the is_a() method returns True if a concept is a descendant of
 another:
\end_layout

\begin_layout LyX-Code
>>> concept.is_a(SNOMEDCT[272625005])
\end_layout

\begin_layout LyX-Code
True
\end_layout

\begin_layout Subsection
Part-of relations
\end_layout

\begin_layout Standard
\begin_inset Quotes eld
\end_inset

part_of
\begin_inset Quotes erd
\end_inset

 and 
\begin_inset Quotes eld
\end_inset

INVERSE_part_of
\begin_inset Quotes erd
\end_inset

 attributes provide access to subparts or superpart of the concept:
\end_layout

\begin_layout LyX-Code
>>> concept.part_of
\end_layout

\begin_layout LyX-Code
[SNOMEDCT[362010009] # Entire heart AND pericardium (body structure)
\end_layout

\begin_layout LyX-Code
]
\end_layout

\begin_layout LyX-Code
 
\end_layout

\begin_layout LyX-Code
>>> concept.INVERSE_part_of
\end_layout

\begin_layout LyX-Code
[SNOMEDCT[102298001] # Structure of chordae tendineae cordis (body structure)
\end_layout

\begin_layout LyX-Code
, SNOMEDCT[181285005] # Entire heart valve (body structure)
\end_layout

\begin_layout LyX-Code
, SNOMEDCT[181288007] # Entire tricuspid valve (body structure)
\end_layout

\begin_layout LyX-Code
, SNOMEDCT[181293005] # Entire cardiac wall (body structure)
\end_layout

\begin_layout LyX-Code
,...]
\end_layout

\begin_layout Standard
ancestor_parts() and descendant_parts() methods return a Python generator
 with all super- or subparts of the concept:
\end_layout

\begin_layout LyX-Code
>>> list(concept.ancestor_parts())
\end_layout

\begin_layout LyX-Code
[SNOMEDCT[362010009] # Entire heart AND pericardium (body structure)
\end_layout

\begin_layout LyX-Code
, SNOMEDCT[362688008] # Entire middle mediastinum (body structure)
\end_layout

\begin_layout LyX-Code
, SNOMEDCT[181217005] # Entire mediastinum (body structure)
\end_layout

\begin_layout LyX-Code
, SNOMEDCT[302551006] # Entire thorax (body structure)
\end_layout

\begin_layout LyX-Code
,...]
\end_layout

\begin_layout LyX-Code
 
\end_layout

\begin_layout LyX-Code
>>> list(concept.descendant_parts())
\end_layout

\begin_layout LyX-Code
[SNOMEDCT[181285005]  # Entire heart valve (body structure)
\end_layout

\begin_layout LyX-Code
, SNOMEDCT[192664000]  # Entire cardiac valve leaflet (body structure)
\end_layout

\begin_layout LyX-Code
, SNOMEDCT[192747009]  # Structure of cardiac valve cusp (body structure)
\end_layout

\begin_layout LyX-Code
,...]
\end_layout

\begin_layout Standard
Finally, the is_part_of() method return True if a concept is a part-of another
 (recursively) :
\end_layout

\begin_layout LyX-Code
>>> concept.is_part_of(SNOMEDCT[91744000])
\end_layout

\begin_layout LyX-Code
False
\end_layout

\begin_layout Subsection
\begin_inset CommandInset label
LatexCommand label
name "sub:Autres-relations-SNOMEDCT"

\end_inset

Other relations
\end_layout

\begin_layout Standard
The 
\begin_inset Quotes eld
\end_inset

relations
\begin_inset Quotes erd
\end_inset

 attribute contains the list of relations available for a given concept.
 Is-a relations are never included in this list, and are handled with the
 
\begin_inset Quotes eld
\end_inset

parents
\begin_inset Quotes erd
\end_inset

 and 
\begin_inset Quotes eld
\end_inset

children
\begin_inset Quotes erd
\end_inset

 attributes previously seen, however part-of relations are included.
 Inverse relations are prefixed by 
\begin_inset Quotes eld
\end_inset

INVERSE_
\begin_inset Quotes erd
\end_inset

.
\end_layout

\begin_layout LyX-Code
>>> concept = SNOMEDCT[3424008]
\end_layout

\begin_layout LyX-Code
>>> concept
\end_layout

\begin_layout LyX-Code
SNOMEDCT[3424008] # Tachycardia (finding)
\end_layout

\begin_layout LyX-Code
 
\end_layout

\begin_layout LyX-Code
>>> concept.relations
\end_layout

\begin_layout LyX-Code
set([u'INVERSE_has_definitional_manifestation', u'finding_site', u'interprets',
 u'has_interpretation', u'INVERSE_associated_with'])
\end_layout

\begin_layout Standard
Each relation corresponds to an attribute in the concept, which returns
 a list with the corresponding values:
\end_layout

\begin_layout LyX-Code
>>> concept.finding_site
\end_layout

\begin_layout LyX-Code
[SNOMEDCT[24964005] # Cardiac conducting system structure (body structure)
\end_layout

\begin_layout LyX-Code
]
\end_layout

\begin_layout LyX-Code
>>> concept.interprets
\end_layout

\begin_layout LyX-Code
[SNOMEDCT[364075005]  # Heart rate (observable entity)
\end_layout

\begin_layout LyX-Code
]
\end_layout

\begin_layout LyX-Code
>>> concept.INVERSE_has_definitional_manifestation
\end_layout

\begin_layout LyX-Code
[ SNOMEDCT[413342000]  # Neonatal tachycardia (disorder)
\end_layout

\begin_layout LyX-Code
, SNOMEDCT[195069001]  # Paroxysmal atrial tachycardia (disorder)
\end_layout

\begin_layout LyX-Code
, SNOMEDCT[195070000]  # Paroxysmal atrioventricular tachycardia (disorder)
\end_layout

\begin_layout LyX-Code
,...]
\end_layout

\begin_layout Subsection
Relation groups
\end_layout

\begin_layout Standard
In SNOMED CT, relations can be grouped together.
 The 
\begin_inset Quotes eld
\end_inset

groups
\begin_inset Quotes erd
\end_inset

 attribute returns the list of groups.
 It is then possible to access to the group's relation.
\end_layout

\begin_layout LyX-Code
>>> SNOMEDCT[186675001]
\end_layout

\begin_layout LyX-Code
SNOMEDCT[186675001]  # Viral pharyngoconjunctivitis (disorder)
\end_layout

\begin_layout LyX-Code
 
\end_layout

\begin_layout LyX-Code
>>> SNOMEDCT[186675001].groups
\end_layout

\begin_layout LyX-Code
[<Group associated_morphology Inflammation (morphologic abnormality); finding_si
te Conjunctival structure (body structure)>, <Group associated_morphology
 Inflammation (morphologic abnormality); finding_site Pharyngeal structure
 (body structure)>]
\end_layout

\begin_layout LyX-Code
 
\end_layout

\begin_layout LyX-Code
>>> SNOMEDCT[186675001].groups[0].relations
\end_layout

\begin_layout LyX-Code
set([u'associated_morphology', u'finding_site'])
\end_layout

\begin_layout LyX-Code
>>> SNOMEDCT[186675001].groups[0].finding_site
\end_layout

\begin_layout LyX-Code
Concepts([
\end_layout

\begin_layout LyX-Code
  SNOMEDCT[29445007]  # Conjunctival structure (body structure)
\end_layout

\begin_layout LyX-Code
])
\end_layout

\begin_layout LyX-Code
>>> SNOMEDCT[186675001].groups[0].associated_morphology
\end_layout

\begin_layout LyX-Code
Concepts([
\end_layout

\begin_layout LyX-Code
  SNOMEDCT[23583003]  # Inflammation (morphologic abnormality)
\end_layout

\begin_layout LyX-Code
])
\end_layout

\begin_layout Standard
Relations that do not belong to a group are gathered into a 
\begin_inset Quotes eld
\end_inset

out-of-group
\begin_inset Quotes erd
\end_inset

 group (which is not included in the 
\begin_inset Quotes eld
\end_inset

groups
\begin_inset Quotes erd
\end_inset

 list).
\end_layout

\begin_layout LyX-Code
>>> SNOMEDCT[186675001].out_of_group
\end_layout

\begin_layout LyX-Code
<Group causative_agent Virus (organism); pathological_process Infectious
 process (qualifier value)>
\end_layout

\begin_layout Subsection
Iterating over SNOMED CT
\end_layout

\begin_layout Standard
To obtain the terminology's first level concepts (i.e.
 the root concepts), use the first_levels() method:
\end_layout

\begin_layout LyX-Code
>>> SNOMEDCT.first_levels()
\end_layout

\begin_layout LyX-Code
[ SNOMEDCT[123037004] # Body structure (body structure)
\end_layout

\begin_layout LyX-Code
, SNOMEDCT[404684003] # Clinical finding (finding)
\end_layout

\begin_layout LyX-Code
, SNOMEDCT[308916002] # Environment or geographical location (environment
 / location)
\end_layout

\begin_layout LyX-Code
,...]
\end_layout

\begin_layout Standard
The all_concepts() method returns a Python generator that iterates over
 all concepts in SNOMED CT.
\end_layout

\begin_layout LyX-Code
>>> for concept in SNOMEDCT.all_concepts(): [...]
\end_layout

\begin_layout Standard
The all_concepts_no_double() method behaves similarly, but removes duplicates.
\end_layout

\begin_layout LyX-Code
>>> for concept in SNOMEDCT.all_concepts_no_double(): [...]
\end_layout

\begin_layout Subsection
CORE Problem List
\end_layout

\begin_layout Standard
The CORE Problem List is a subset of SNOMED CT appropriated for coding clinical
 information.
 The 
\begin_inset Quotes eld
\end_inset

is_in_core
\begin_inset Quotes erd
\end_inset

 attribute is true if a concept belongs to the CORE Problem List:
\end_layout

\begin_layout LyX-Code
>>> concept.is_in_core
\end_layout

\begin_layout LyX-Code
1
\end_layout

\begin_layout Standard
To iterate through all concepts in CORE Problem List:
\end_layout

\begin_layout LyX-Code
>>> for core_concept in SNOMEDCT.CORE_problem_list(): [...]
\end_layout

\begin_layout Subsection
Clinical signs associated to a concept
\end_layout

\begin_layout Standard
The associated_clinical_findings() method lists all clinical signs associated
 to an anatomical concept (a 
\emph on
body structure
\emph default
) or a morphology, including their descendants or descendant parts.
 For example for listing all clinical findings affecting cardiac structures:
\end_layout

\begin_layout LyX-Code
>>> SNOMEDCT[80891009]
\end_layout

\begin_layout LyX-Code
SNOMEDCT[80891009]  # Heart structure (body structure)
\end_layout

\begin_layout LyX-Code
 
\end_layout

\begin_layout LyX-Code
>>> SNOMEDCT[80891009].associated_clinical_findings()
\end_layout

\begin_layout LyX-Code
Concepts([
\end_layout

\begin_layout LyX-Code
  SNOMEDCT[250981008]  # Abnormal aortic cusp (disorder)
\end_layout

\begin_layout LyX-Code
, SNOMEDCT[250982001]  # Commissural fusion of aortic cusp (disorder)
\end_layout

\begin_layout LyX-Code
, SNOMEDCT[250984000]  # Torn aortic cusp (disorder)
\end_layout

\begin_layout LyX-Code
,...]
\end_layout

\begin_layout Section
ICD10
\end_layout

\begin_layout Subsection
Loading modules
\end_layout

\begin_layout LyX-Code
>>> from pymedtermino import * 
\end_layout

\begin_layout LyX-Code
>>> from pymedtermino.icd10 import *
\end_layout

\begin_layout Subsection
Concepts
\end_layout

\begin_layout Standard
The ICD10 object allows to access to ICD10 concepts.
 This object behaves similarly to the SNOMED CT terminology previously described.
\end_layout

\begin_layout LyX-Code
>>> ICD10["E10"]
\end_layout

\begin_layout LyX-Code
ICD10[u"E10"]  # Insulin-dependent diabetes mellitus
\end_layout

\begin_layout LyX-Code
 
\end_layout

\begin_layout LyX-Code
>>> ICD10["E10"].parents
\end_layout

\begin_layout LyX-Code
[ICD10[u"E10-E14"]  # Diabetes mellitus
\end_layout

\begin_layout LyX-Code
]
\end_layout

\begin_layout LyX-Code
 
\end_layout

\begin_layout LyX-Code
>>> list(ICD10["E10"].ancestors())
\end_layout

\begin_layout LyX-Code
[ ICD10[u"E10-E14"]  # Diabetes mellitus
\end_layout

\begin_layout LyX-Code
, ICD10[u"IV"]  # Endocrine, nutritional and metabolic diseases 
\end_layout

\begin_layout LyX-Code
]
\end_layout

\begin_layout Standard
ICD10 being monoaxial, the parents list includes at most one parent.
\end_layout

\begin_layout Subsection
Translations
\end_layout

\begin_layout Standard
ICD10 is available in several languages.
 The get_translation() method returns the translation in a given language:
\end_layout

\begin_layout LyX-Code
>>> print(ICD10["E10"].get_translation("fr"))
\end_layout

\begin_layout LyX-Code
diabète sucré insulino-dépendant
\end_layout

\begin_layout LyX-Code
 
\end_layout

\begin_layout LyX-Code
>>> print(ICD10["E10"].get_translation("en"))
\end_layout

\begin_layout LyX-Code
Insulin-dependent diabetes mellitus
\end_layout

\begin_layout Standard
The default language is defined by the pymedtermino.LANGUAGE global parameter
 (this parameter MUST be set BEFORE loading concepts).
\end_layout

\begin_layout Subsection
Relations
\end_layout

\begin_layout Standard
ICD10 inclusions and exclusions can be accessed as relations.
\end_layout

\begin_layout LyX-Code
>>> ICD10["E10"].relations
\end_layout

\begin_layout LyX-Code
set([u'inclusion', u'exclusion', u'modifierlink'])
\end_layout

\begin_layout LyX-Code
 
\end_layout

\begin_layout LyX-Code
>>> ICD10["E10"].exclusion
\end_layout

\begin_layout LyX-Code
[Text(ICD10[u"E10"]  # Insulin-dependent diabetes mellitus
\end_layout

\begin_layout LyX-Code
, 'exclusion', u'diabetes mellitus (in) malnutrition-related E12.-', 0, ICD10[u"E
12"]  # Malnutrition-related diabetes mellitus
\end_layout

\begin_layout LyX-Code
)...]
\end_layout

\begin_layout Section
UMLS
\end_layout

\begin_layout Subsection
Loading modules
\end_layout

\begin_layout LyX-Code
>>> from pymedtermino import * 
\end_layout

\begin_layout LyX-Code
>>> from pymedtermino.umls import * 
\end_layout

\begin_layout Standard
After importing modules, you need to connect to a MySQL database containing
 UMLS data, as following:
\end_layout

\begin_layout LyX-Code
>>> connect_to_umls_db(host, user, password, database_name = "umls", encoding
 = "latin1")
\end_layout

\begin_layout Standard
host, user, password must be specified.
\end_layout

\begin_layout Subsection
UMLS concepts (CUI)
\end_layout

\begin_layout Standard
In UMLS, CUI correspond to concepts: a given concept gathers equivalent
 terms or codes from various terminologies.
\end_layout

\begin_layout Standard
CUI can be accessed with the UMLS_CUI terminology:
\end_layout

\begin_layout LyX-Code
>>> UMLS_CUI[u"C0085580"]
\end_layout

\begin_layout LyX-Code
UMLS_CUI[u"C0085580"]  # Essential Hypertension (MDRJPN, SNOMEDCT, ICD10,
 BI, CCS, MDRPOR, COSTAR, ICD10DUT, KCD5, RCD, MDRGER, AOD, MDRFRE, MDRCZE,
 SCTSPA, DMDICD10, ICPC2P, OMIM, MDRITA, MDR, MEDCIN, ICD10CM, MDRDUT, ICD10AM,
 MTH, CSP, MDRSPA, SNM, DXP, NCI, PSY, SNMI, ICD9CM, CCPSS)
\end_layout

\begin_layout LyX-Code
 
\end_layout

\begin_layout LyX-Code
>>> UMLS_CUI[u"C0085580"].term
\end_layout

\begin_layout LyX-Code
u'Essential Hypertension'
\end_layout

\begin_layout LyX-Code
 
\end_layout

\begin_layout LyX-Code
>>> UMLS_CUI[u"C0085580"].terms
\end_layout

\begin_layout LyX-Code
['Essential Hypertension', 'HYPERTENSION, ESSENTIAL', 'HYPERTENSION ESSENTIAL',
 'Hypertension;essential', 'Essential hypertension, NOS', ...] 
\end_layout

\begin_layout LyX-Code
 
\end_layout

\begin_layout LyX-Code
>>> UMLS_CUI[u"C0085580"].original_terminologies
\end_layout

\begin_layout LyX-Code
set(['MDRJPN', 'SNOMEDCT', 'ICD10', 'BI', 'CCS', 'MDRPOR', 'COSTAR', 'ICD10DUT',
 'KCD5', 'RCD', 'MDRGER', 'AOD', 'MDRFRE', 'MDRCZE', 'SCTSPA', 'DMDICD10',
 'ICPC2P', 'OMIM', 'MDRITA', 'MDR', 'MEDCIN', 'ICD10CM', 'MDRDUT', 'ICD10AM',
 'MTH', 'CSP', 'MDRSPA', 'SNM', 'DXP', 'NCI', 'PSY', 'SNMI', 'ICD9CM', 'CCPSS'])
\end_layout

\begin_layout LyX-Code

\end_layout

\begin_layout Standard
Relations of CUI are handled in the same way than for SNOMED CT (see section
 
\begin_inset CommandInset ref
LatexCommand ref
reference "sub:Autres-relations-SNOMEDCT"

\end_inset

), for example:
\end_layout

\begin_layout LyX-Code
>>> UMLS_CUI[u"C0085580"].relations
\end_layout

\begin_layout LyX-Code
set(['has_finding_site', 'INVERSE_translation_of', 'SIB', 'INVERSE_has_alias',
 'may_be_a', None, 'RQ', 'INVERSE_mapped_from',...])
\end_layout

\begin_layout LyX-Code
 
\end_layout

\begin_layout LyX-Code
>>> UMLS_CUI[u"C0085580"].has_finding_site
\end_layout

\begin_layout LyX-Code
[UMLS_CUI[u"C0459964"]  # Systemic arterial structure (RCD, SCTSPA, SNOMEDCT)
\end_layout

\begin_layout Subsection
UMLS concept form source terminologies (AUI)
\end_layout

\begin_layout Standard
The UMLS_AUI terminology allows to access to UMLS atoms.
 A UMLS atom corresponds to a concept in a given source terminology; e.g.
 
\begin_inset Quotes eld
\end_inset

type 2 diabetes in ICD10
\begin_inset Quotes erd
\end_inset

 is a different atom from 
\begin_inset Quotes eld
\end_inset

type 2 diabetes in SNOMED CT
\begin_inset Quotes erd
\end_inset

.
\end_layout

\begin_layout LyX-Code
>>> UMLS_AUI[u"A0930328"]
\end_layout

\begin_layout LyX-Code
UMLS_AUI[u"A0930328"] # Essential (primary) hypertension (ICD10)
\end_layout

\begin_layout LyX-Code
 
\end_layout

\begin_layout LyX-Code
>>> UMLS_AUI[u"A0930328"].original_terminologies
\end_layout

\begin_layout LyX-Code
set(['ICD10'])
\end_layout

\begin_layout Subsection
Extracting terminologies from UMLS
\end_layout

\begin_layout Standard
PyMedTermino can extract terminologies from UMLS, and use them with the
 source terminology codes (rather than AUI), for example to extract SNOMED
 CT, ICD10 and ICPC2 :
\end_layout

\begin_layout LyX-Code
>>> UMLS_SNOMEDCT  = UMLS_AUI.extract_terminology("SNOMEDCT", has_int_code
 = 1)
\end_layout

\begin_layout LyX-Code
>>> UMLS_ICD10     = UMLS_AUI.extract_terminology("ICD10")
\end_layout

\begin_layout LyX-Code
>>> UMLS_ICPC2EENG = UMLS_AUI.extract_terminology("ICPC2EENG")
\end_layout

\begin_layout Standard
The first parameter of the UMLS_AUI.extract_terminology() function is the
 name of the terminology to extract (they can be found in the list of UMLS
 sources).
 The optional parameter 
\begin_inset Quotes eld
\end_inset

has_int_code = 1
\begin_inset Quotes erd
\end_inset

 indicates that the codes of the source terminology are numeric; this allows
 to remove quote around them.
\end_layout

\begin_layout Standard
Extracted terminologies can be used as usual:
\end_layout

\begin_layout LyX-Code
>>> UMLS_ICD10["I10"]
\end_layout

\begin_layout LyX-Code
UMLS_ICD10[u"I10"]  # Essential (primary) hypertension (ICD10)
\end_layout

\begin_layout Standard
It is possible to access to relations (when they exist) like previously.
\end_layout

\begin_layout Subsection
Mapping between UMLS terminologies
\end_layout

\begin_layout Standard
PyMedTermino automatically defines mapping between terminologies extracted
 from UMLS, for example:
\end_layout

\begin_layout LyX-Code
>>> UMLS_ICD10["I10"] >> UMLS_SNOMEDCT
\end_layout

\begin_layout LyX-Code
Concepts([
\end_layout

\begin_layout LyX-Code
  UMLS_SNOMEDCT[u"59621000"]  # Essential hypertension (SNOMEDCT)
\end_layout

\begin_layout LyX-Code
])
\end_layout

\begin_layout Standard
For more information on mapping in PyMedTermino, see section 
\begin_inset CommandInset ref
LatexCommand ref
reference "sec:Correspondances"

\end_inset

.
\end_layout

\begin_layout Section
VCM
\end_layout

\begin_layout Subsection
Loading modules
\end_layout

\begin_layout LyX-Code
>>> from pymedtermino import * 
\end_layout

\begin_layout LyX-Code
>>> from pymedtermino.vcm import *
\end_layout

\begin_layout Standard
Databases describing VCM terminologies are already included with PyMedTermino.
\end_layout

\begin_layout Subsection
VCM icons
\end_layout

\begin_layout Standard
The VCM object is a terminology for accessing VCM icons, identified by their
 code, in French or English:
\end_layout

\begin_layout LyX-Code
>>> icon = VCM["en_cours--patho--coeur"]
\end_layout

\begin_layout LyX-Code
>>> icon = VCM["current--patho--heart"]
\end_layout

\begin_layout LyX-Code
>>> icon =  VCM["en_cours--patho-vaisseau--coeur--traitement--medicament--rien--
rien"]
\end_layout

\begin_layout LyX-Code

\end_layout

\begin_layout Standard
The icon code includes up to 7 components, separated by two dashes (--):
\end_layout

\begin_layout Enumerate
The central color
\end_layout

\begin_layout Enumerate
The shape modifier(s) (separated by a single dash if there are several of
 them)
\end_layout

\begin_layout Enumerate
The central pictogram
\end_layout

\begin_layout Enumerate
The top-right color
\end_layout

\begin_layout Enumerate
The top-right pictogram
\end_layout

\begin_layout Enumerate
The second top-right pictogram
\end_layout

\begin_layout Enumerate
The shadow
\end_layout

\begin_layout Standard
The possible values for each component are listed in the graphical lexicon
 (see the VCM pictogram lexicon, or the VCM_LEXICON terminology below).
 Missing components in the code of the icon are replaced by 
\begin_inset Quotes eld
\end_inset

empty
\begin_inset Quotes erd
\end_inset

.
\end_layout

\begin_layout Standard
Various attributes return the icon's components:
\end_layout

\begin_layout LyX-Code
>>> icon.central_color
\end_layout

\begin_layout LyX-Code
VCM_LEXICON[496] # Red_color
\end_layout

\begin_layout LyX-Code
>>> icon.modifiers
\end_layout

\begin_layout LyX-Code
Concepts([
\end_layout

\begin_layout LyX-Code
  VCM_LEXICON[536]  # Modifier_vessel
\end_layout

\begin_layout LyX-Code
, VCM_LEXICON[504]  # Modifier_patho
\end_layout

\begin_layout LyX-Code
])
\end_layout

\begin_layout LyX-Code
>>> icon.central_pictogram
\end_layout

\begin_layout LyX-Code
VCM_LEXICON[549]  # Pictogramme_heart
\end_layout

\begin_layout LyX-Code
>>> icon.central_pictogram.text_code
\end_layout

\begin_layout LyX-Code
heart
\end_layout

\begin_layout LyX-Code
 
\end_layout

\begin_layout LyX-Code
>>> icon.top_right_color
\end_layout

\begin_layout LyX-Code
VCM_LEXICON[690]  # Green_color
\end_layout

\begin_layout LyX-Code
>>> icon.top_right_pictogram
\end_layout

\begin_layout LyX-Code
VCM_LEXICON[697]  # Drug_top_right_pictogram
\end_layout

\begin_layout LyX-Code
>>> icon.second_top_right_pictogram
\end_layout

\begin_layout LyX-Code
VCM_LEXICON[718]  # No_second_top_right_pictogram
\end_layout

\begin_layout LyX-Code
>>> icon.shadow
\end_layout

\begin_layout LyX-Code
VCM_LEXICON[722]  # No_shadow
\end_layout

\begin_layout Standard
The 
\begin_inset Quotes eld
\end_inset

lexs
\begin_inset Quotes erd
\end_inset

 attribute returns a set with all the components of the icon:
\end_layout

\begin_layout LyX-Code
>>> icon.lexs
\end_layout

\begin_layout LyX-Code
Concepts([
\end_layout

\begin_layout LyX-Code
  VCM_LEXICON[536]  # Modifier_vessel
\end_layout

\begin_layout LyX-Code
, VCM_LEXICON[549]  # Pictogramme_heart
\end_layout

\begin_layout LyX-Code
, VCM_LEXICON[722]  # No_shadow
\end_layout

\begin_layout LyX-Code
, VCM_LEXICON[496]  # Red_color
\end_layout

\begin_layout LyX-Code
, VCM_LEXICON[504]  # Modifier_patho
\end_layout

\begin_layout LyX-Code
, VCM_LEXICON[718]  # No_second_top_right_pictogram
\end_layout

\begin_layout LyX-Code
, VCM_LEXICON[697]  # Drug_top_right_pictogram
\end_layout

\begin_layout LyX-Code
, VCM_LEXICON[690]  # Green_color
\end_layout

\begin_layout LyX-Code
])
\end_layout

\begin_layout Standard
The following attributes returns the shape modifiers of a specific category:
 pathological modifiers, etiology,...:
\end_layout

\begin_layout LyX-Code
>>> icon.physio
\end_layout

\begin_layout LyX-Code
>>> icon.patho
\end_layout

\begin_layout LyX-Code
>>> icon.etiology
\end_layout

\begin_layout LyX-Code
>>> icon.quantitative
\end_layout

\begin_layout LyX-Code
>>> icon.process
\end_layout

\begin_layout LyX-Code
>>> icon.transverse
\end_layout

\begin_layout Standard
The 
\begin_inset Quotes eld
\end_inset

consistent
\begin_inset Quotes erd
\end_inset

 attribute is True if the icon is consistent (according to the VCM ontology,
 as described in this article: J-B Lamy et al., Validating the semantics
 of a medical iconic language using ontological reasoning
\begin_inset Foot
status open

\begin_layout Plain Layout
J-B Lamy et al., Validating the semantics of a medical iconic language using
 ontological reasoning, Journal of Biomedical Informatics 2013, 46(1):56-67
\end_layout

\begin_layout Plain Layout
\begin_inset CommandInset href
LatexCommand href
target "http://www.sciencedirect.com/science/article/pii/S153204641200130X"

\end_inset


\end_layout

\end_inset

):
\end_layout

\begin_layout LyX-Code
>>> icon.consistent
\end_layout

\begin_layout LyX-Code
True
\end_layout

\begin_layout LyX-Code

\end_layout

\begin_layout Subsection
Graphical lexicon
\end_layout

\begin_layout Standard
The VCM_LEXICON terminology describes the lexicon of the VCM graphical primitive
s: pictograms, colors and shapes.
 Each primitive is identified by an arbitrary numeric code, for example
 for the heart pictogram:
\end_layout

\begin_layout LyX-Code
>>> heart = VCM_LEXICON[549]
\end_layout

\begin_layout LyX-Code
>>> heart
\end_layout

\begin_layout LyX-Code
VCM_LEXICON[549] # Pictogramme_heart
\end_layout

\begin_layout Standard
Each concept of the lexicon also has a textual code (easier to memorize,
 and available in French and English), and a category:
\end_layout

\begin_layout LyX-Code
>>> heart.text_code
\end_layout

\begin_layout LyX-Code
u'heart'
\end_layout

\begin_layout LyX-Code
>>> heart.text_codes
\end_layout

\begin_layout LyX-Code
[u'heart', u'coeur'] 
\end_layout

\begin_layout LyX-Code
>>> heart.category
\end_layout

\begin_layout LyX-Code
2 
\end_layout

\begin_layout Standard
The categories correspond to the various parts of the VCM icons:
\end_layout

\begin_layout Description
0 Central color
\end_layout

\begin_layout Description
1 Shape modifier
\end_layout

\begin_layout Description
2 Central pictogram
\end_layout

\begin_layout Description
3 Top-right color
\end_layout

\begin_layout Description
4 Top-right pictogram
\end_layout

\begin_layout Description
5 Second top-right pictogram
\end_layout

\begin_layout Description
6 Shadow
\end_layout

\begin_layout Standard
You can also use the category and the textual code to obtain a lexicon concept:
\end_layout

\begin_layout LyX-Code
>>> VCM_LEXICON[2, "heart"]
\end_layout

\begin_layout LyX-Code
VCM_LEXICON[549] # Pictogramme_heart 
\end_layout

\begin_layout Standard
Relations are handled as usual in (see the section about SNOMED CT: parents,
 children, is_a(), ancestors(), descendants(),...).
 In addition the graphical_is_a relation indicates the other graphical primitive
 that are reused by th the lexicon concept.
 For example the heart rhythm pictogram reuse the heart pictogram:
\end_layout

\begin_layout LyX-Code
>>> heart_rhythm = VCM_LEXICON[2, "heart_rhythm"]
\end_layout

\begin_layout LyX-Code
>>> heart_rhythm.graphical_is_a
\end_layout

\begin_layout LyX-Code
[VCM_LEXICON[549]  # Pictogramme_heart
\end_layout

\begin_layout LyX-Code
]
\end_layout

\begin_layout Standard
The 
\begin_inset Quotes eld
\end_inset

graphical_children
\begin_inset Quotes erd
\end_inset

 and 
\begin_inset Quotes eld
\end_inset

graphical_parents
\begin_inset Quotes erd
\end_inset

 attributes return the list of lexicon concepts that re-use or are reused
 by the concept.
\end_layout

\begin_layout Subsubsection
Creating a VCM icon from lexicon concepts
\end_layout

\begin_layout Standard
A set of lexicon concepts can be assembled into a VCM icon:
\end_layout

\begin_layout LyX-Code
>>> Concepts([VCM_LEXICON[549], VCM_LEXICON[496], VCM_LEXICON[504]]) >>
 VCM
\end_layout

\begin_layout LyX-Code
Concepts([
\end_layout

\begin_layout LyX-Code
  VCM[u"current--patho--heart"]  # 
\end_layout

\begin_layout LyX-Code
])
\end_layout

\begin_layout Subsection
Medical concepts
\end_layout

\begin_layout Standard
VCM_CONCEPT is a terminology that represents the medical concepts described
 by VCM.
 Each medical concept is defined by an arbitrary numeric code, for example
 for the heart:
\end_layout

\begin_layout LyX-Code
>>> heart = VCM_CONCEPT[266]
\end_layout

\begin_layout LyX-Code
>>> heart
\end_layout

\begin_layout LyX-Code
VCM_CONCEPT[266] # Cardiac_structure
\end_layout

\begin_layout Standard
Relations are handled as usual in PyMedTermino (see the section about SNOMED
 CT: parents, children, is_a(), ancestors(), descendants(), relations...).
\end_layout

\begin_layout Standard
VCM_CONCEPT_MONOAXIAL is a terminology identical to VCM_CONCEPT, but monoaxial.
 The concepts are thus the same, but with at maximum a single parent for
 each concept.
 This terminology is mostly used in intern for mapping from VCM_CONCEPT
 (multiaxial) to VCM_LEXICON (monoaxial).
\end_layout

\begin_layout Section
\begin_inset CommandInset label
LatexCommand label
name "sec:Correspondances"

\end_inset

Mappings
\end_layout

\begin_layout Standard
A mapping allows to transcode one or more concepts from a source terminology
 to a destination terminology.
 PyMedTermino uses the >> operator for mapping, in the following way:
\end_layout

\begin_layout LyX-Code
concept(s) >> DESTINATION_TERMINOLOGY
\end_layout

\begin_layout Standard
where concept(s) can be a concept of the source terminology, or a set of
 concepts (see section 
\begin_inset CommandInset ref
LatexCommand ref
reference "sec:Ensembles-de-concepts"

\end_inset

).
 The >> operator returns a set of concepts in the destination terminology.
 The >> operators can thus be chained:
\end_layout

\begin_layout LyX-Code
concept(s) >> INTERMEDIARY_TERMINOLOGY >> DESTINATION_TERMINOLOGY
\end_layout

\begin_layout Standard
PyMedTermino includes several mappings, described in the following subsections.
\end_layout

\begin_layout Subsection
UMLS mappings
\end_layout

\begin_layout Subsubsection
UMLS_CUI <=> UMLS_AUI
\end_layout

\begin_layout Standard
PyMedTermino can map CUI to AUI, and vice versa:
\end_layout

\begin_layout LyX-Code
>>> UMLS_CUI[u"C0085580"] >> UMLS_AUI
\end_layout

\begin_layout LyX-Code
Concepts([
\end_layout

\begin_layout LyX-Code
  UMLS_AUI[u"A16015049"]  # Hypertension primitive (MDRFRE)
\end_layout

\begin_layout LyX-Code
, UMLS_AUI[u"A11101884"]  # Hypertension essentielle, non précisée (MDRFRE)
\end_layout

\begin_layout LyX-Code
, UMLS_AUI[u"A11089284"]  # Hypertension essentielle non précisée (MDRFRE)
\end_layout

\begin_layout LyX-Code
...])
\end_layout

\begin_layout Subsubsection
Terminology extracted from UMLS <=> CUI or AUI
\end_layout

\begin_layout Standard
PyMedTermino can map concepts of terminology extracted from UMLS to CUI
 or AUI, and vice versa:
\end_layout

\begin_layout LyX-Code
>>> UMLS_ICD10["I10"] >> UMLS_CUI
\end_layout

\begin_layout LyX-Code
Concepts([
\end_layout

\begin_layout LyX-Code
  UMLS_CUI[u"C0085580"]  # Essential Hypertension (MDRJPN, SNOMEDCT, ICD10,
 BI, CCS, MDRPOR, COSTAR, ICD10DUT, KCD5, RCD, MDRGER, AOD, MDRFRE, MDRCZE,
 SCTSPA, DMDICD10, ICPC2P, OMIM, MDRITA, MDR, MEDCIN, ICD10CM, MDRDUT, ICD10AM,
 MTH, CSP, MDRSPA, SNM, DXP, NCI, PSY, SNMI, ICD9CM, CCPSS)
\end_layout

\begin_layout LyX-Code
])
\end_layout

\begin_layout Subsubsection
Terminology extracted from UMLS <=> source terminology
\end_layout

\begin_layout Standard
PyMedTermino can map concepts of terminology extracted from UMLS to the
 source terminology, and vice versa:
\end_layout

\begin_layout LyX-Code
>>> ICD10["I10"] >> UMLS_ICD10
\end_layout

\begin_layout LyX-Code
Concepts([
\end_layout

\begin_layout LyX-Code
  UMLS_ICD10[u"I10"]  # Essential (primary) hypertension (ICD10)
\end_layout

\begin_layout LyX-Code
])
\end_layout

\begin_layout Subsubsection
Terminology extracted from UMLS <=> another terminology extracted from UMLS
\end_layout

\begin_layout Standard
PyMedTermino automatically create mapping between the terminologies extracted
 from UMLS with UMLS_AUI.extract_terminology():
\end_layout

\begin_layout LyX-Code
>>> UMLS_ICD10["I10"] >> UMLS_SNOMEDCT
\end_layout

\begin_layout LyX-Code
Concepts([
\end_layout

\begin_layout LyX-Code
  UMLS_SNOMEDCT[u"59621000"]  # Essential hypertension (SNOMEDCT)
\end_layout

\begin_layout LyX-Code
])
\end_layout

\begin_layout LyX-Code

\end_layout

\begin_layout Subsection
SNOMEDCT <=> VCM
\end_layout

\begin_layout Standard
This mapping maps SNOMED CT concepts to (or from) VCM icons.
 It has been built automatically from the SNOMEDCT <=> VCM_CONCEPT and VCM_CONCE
PT <=> VCM_LEXICON mappings (as described in this article: J-B Lamy et al.,
 A Semi-automatic Semantic Method for Mapping SNOMED CT Concepts to VCM
 Icons 
\begin_inset Foot
status collapsed

\begin_layout Plain Layout
J-B Lamy et al., A Semi-automatic Semantic Method for Mapping SNOMED CT Concepts
 to VCM Icons, Studies in health technology and informatics 2013, 192:42-6
\end_layout

\begin_layout Plain Layout
\begin_inset CommandInset href
LatexCommand href
target "http://ebooks.iospress.nl/publication/33954"

\end_inset


\end_layout

\end_inset

).
\end_layout

\begin_layout LyX-Code
>>> from pymedtermino.snomedct_2_vcm import *
\end_layout

\begin_layout LyX-Code
 
\end_layout

\begin_layout LyX-Code
>>> SNOMEDCT[3424008]
\end_layout

\begin_layout LyX-Code
SNOMEDCT[3424008]  # Tachycardia (finding)
\end_layout

\begin_layout LyX-Code
 
\end_layout

\begin_layout LyX-Code
>>> SNOMEDCT[3424008] >> VCM
\end_layout

\begin_layout LyX-Code
Concepts([
\end_layout

\begin_layout LyX-Code
  VCM[u"current--hyper--heart_rhythm"]  # 
\end_layout

\begin_layout LyX-Code
])
\end_layout

\begin_layout Subsection
VCM_LEXICON => VCM
\end_layout

\begin_layout Standard
A set of VCM lexicon element (pictogram, color,...) can be assembled into a
 VCM icon:
\end_layout

\begin_layout LyX-Code
>>> Concepts([VCM_LEXICON[549], VCM_LEXICON[496], VCM_LEXICON[504]]) >>
 VCM
\end_layout

\begin_layout LyX-Code
Concepts([
\end_layout

\begin_layout LyX-Code
  VCM[u"current--patho--heart"]  # 
\end_layout

\begin_layout LyX-Code
])
\end_layout

\begin_layout Subsection
VCM_CONCEPT <=> VCM_LEXICON
\end_layout

\begin_layout Standard
This mapping maps VCM medical concepts to (or from) VCM lexicon elements.
 It has been built manually, and is part of the VCM ontology.
\end_layout

\begin_layout LyX-Code
>>> VCM_CONCEPT[266] >> VCM_LEXICON
\end_layout

\begin_layout LyX-Code
Concepts([
\end_layout

\begin_layout LyX-Code
  VCM_LEXICON[549]  # Pictogramme_heart
\end_layout

\begin_layout LyX-Code
])
\end_layout

\begin_layout LyX-Code
>>> VCM_LEXICON[549] >> VCM_CONCEPT
\end_layout

\begin_layout LyX-Code
Concepts([
\end_layout

\begin_layout LyX-Code
  VCM_CONCEPT[266]  # Cardiac_structure
\end_layout

\begin_layout LyX-Code
, VCM_CONCEPT[102]  # Cardiac_function
\end_layout

\begin_layout LyX-Code
])
\end_layout

\begin_layout Subsection
SNOMEDCT <=> VCM_CONCEPT
\end_layout

\begin_layout Standard
This mapping maps SNOMED CT concepts (mostly body structures and morphologies)
 to (or from) VCM medical concepts.
 It has been built manually.
\end_layout

\begin_layout LyX-Code
>>> SNOMEDCT[302509004]
\end_layout

\begin_layout LyX-Code
SNOMEDCT[302509004] # Entire heart (body structure)
\end_layout

\begin_layout LyX-Code
 
\end_layout

\begin_layout LyX-Code
>>> SNOMEDCT[302509004] >> VCM_CONCEPT
\end_layout

\begin_layout LyX-Code
Concepts([
\end_layout

\begin_layout LyX-Code
  VCM_CONCEPT[266] # Cardiac_structure
\end_layout

\begin_layout LyX-Code
, VCM_CONCEPT[239] # Thorax_region
\end_layout

\begin_layout LyX-Code
])
\end_layout

\begin_layout Standard
\begin_inset Note Comment
status open

\begin_layout Subsection
SNOMEDCT <=> ICD10
\end_layout

\begin_layout Plain Layout
This mapping maps SNOMED CT concepts to ICD10 concepts.
 It has been built automatically from the SNOMEDCT => ICD10 mapping provided
 by the NLM, by retaining only mappings that do not require the intervention
 of an expert (and thus it is not complete).
 You need to install this mapping with the scripts/import_snomedct_2_icd10.py
 scripts.
\end_layout

\begin_layout LyX-Code
>>> from pymedtermino.snomedct_2_icd10 import *
\end_layout

\begin_layout LyX-Code
 
\end_layout

\begin_layout LyX-Code
>>> SNOMEDCT[3424008] >> ICD10
\end_layout

\begin_layout LyX-Code
Concepts([
\end_layout

\begin_layout LyX-Code
  ICD10[u"R00.0"]  # Tachycardia, unspecified
\end_layout

\begin_layout LyX-Code
])
\end_layout

\begin_layout Subsection
ICD10 <=> VCM
\end_layout

\begin_layout Plain Layout
Cette correspondance associe des icônes VCM aux concepts de la CIM10.
 Elle a été construite de manière automatique à partir des correspondances
 SNOMEDCT <=> VCM et SNOMEDCT <=> ICD10.
\end_layout

\begin_layout LyX-Code
from pymedtermino.icd10_2_vcm import *
\end_layout

\end_inset


\end_layout

\begin_layout Subsection
Examples
\end_layout

\begin_layout Standard
By chaining several mapping, it is possible to map an ICD10 concept to SNOMED
 CT via UMLS:
\end_layout

\begin_layout LyX-Code
>>> ICD10["I10"] >> UMLS_ICD10 >> UMLS_SNOMEDCT >> SNOMEDCT
\end_layout

\begin_layout LyX-Code
Concepts([
\end_layout

\begin_layout LyX-Code
  SNOMEDCT[59621000]  # Essential hypertension (disorder)
\end_layout

\begin_layout LyX-Code
])
\end_layout

\begin_layout Standard
If you want to use this method as a default mapping from ICD10 to SNOMED
 CT, you can register this mapping as following:
\end_layout

\begin_layout LyX-Code
>>> (ICD10 >> UMLS_ICD10 >> UMLS_SNOMEDCT >> SNOMEDCT).register()
\end_layout

\begin_layout LyX-Code
 
\end_layout

\begin_layout LyX-Code
>>> ICD10["I10"] >> SNOMEDCT
\end_layout

\begin_layout LyX-Code
Concepts([
\end_layout

\begin_layout LyX-Code
  SNOMEDCT[59621000]  # Essential hypertension (disorder)
\end_layout

\begin_layout LyX-Code
])
\end_layout

\begin_layout Section
\begin_inset CommandInset label
LatexCommand label
name "sec:Ensembles-de-concepts"

\end_inset

Set of concepts
\end_layout

\begin_layout Standard
The Concepts() class represents set of concepts.
 Such a set can contain each concept only once, and it inherits from Python's
 set() the methods for computing intersection, union, difference, ..., of two
 sets.
 It also proposes the following methods:
\end_layout

\begin_layout Itemize
Concepts.find(parent_concept) : returns the first concept of the set that
 is a descendant of concept_parent (including concept_parent itself).
\end_layout

\begin_layout Itemize
Concepts.extract(parent_concept) : returns all concepts of the set that are
 descendant of concept_parent (including concept_parent itself).
\end_layout

\begin_layout Itemize
Concepts.subtract(parent_concept) : returns a new set after removing all
 concepts that are descendant of parent_concept (including concept_parent
 itself).
\end_layout

\begin_layout Itemize
Concepts.subtract_update(parent_concept) : same as subtract(), but modify
 the set 
\begin_inset Quotes eld
\end_inset

in place
\begin_inset Quotes erd
\end_inset

.
\end_layout

\begin_layout Itemize
Concepts.imply(concepts2) : returns true if all concepts in the set are descendan
ts of at least one of the concept in the set concepts2.
\end_layout

\begin_layout Itemize
Concepts.keep_most_specific() : keeps only the most specific concepts, i.e.
 remove all concepts that are more general that another concept in the set.
\end_layout

\begin_layout Itemize
Concepts.keep_most_generic() : keeps only the most general concepts, i.e.
 remove all concepts that are more specific that another concept in the
 set.
\end_layout

\begin_layout Itemize
Concepts.lowest_common_ancestors() : returns the lowest common ancestors.
\end_layout

\begin_layout Itemize
Concepts.all_subsets() : returns all the subsets included in the set.
\end_layout

\begin_layout Section
Using PyMedTermino without Python
\end_layout

\begin_layout Standard
PyMedTermino can also be used without Python, simply for converting SNOMED
 CT and ICD10 XML data into SQL database.
 The SQLite3 databases created can then be interrogated with most programming
 language, however you won't have access to high level functions proposed
 by PyMedTermino (such as the ancestors() and descendants() functions).
\end_layout

\begin_layout Standard
The definition of the tables of the databases can be found in the scripts/import
_sonmedct.py and scripts/import_icd10.py files.
\end_layout

\end_body
\end_document
