Skip to main content


A Python package named pathling is available from PyPI.

View the generated API documentation


The Python library features a set of encoders for converting FHIR data into Spark dataframes.

See the Encoders page for more details.

Value set membership

The member_of function can be used to test the membership of a code within a FHIR value set. In this example, we take a list of SNOMED CT diagnosis codes and create a new column which shows which are viral infections.

# << 64572001|Disease| : (
# << 370135005|Pathological process| = << 441862004|Infectious process|,
# << 246075003|Causative agent| = << 49872002|Virus|
# )
result = pc.member_of(csv, to_coding(csv.CODE, ''),

Results in:

65363002Otitis mediafalse
16114001Fracture of anklefalse
444814009Viral sinusitistrue
444814009Viral sinusitistrue
43878008Streptococcal sore throatfalse

Concept translation

The translate function can be used to translate codes from one code system to another using maps that are known to the terminology server. In this example, we translate our SNOMED CT diagnosis codes into Read CTV3.

result = pc.translate(csv, to_coding(csv.CODE, ''),
result = result.withColumn('READ_CODE', result.READ_CODE.code)'CODE', 'DESCRIPTION', 'READ_CODE').show()

Results in:

65363002Otitis mediaX00ik
16114001Fracture of ankleS34..
444814009Viral sinusitisXUjp0
444814009Viral sinusitisXUjp0
43878008Streptococcal sore throatA340.

Subsumption testing

The subsumes function allows us to perform subsumption testing on codes within our data. In hierarchical code systems, a subsumption test determines whether a code is a subtype of another code, e.g. an "ankle fracture" is subsumed by " fracture".

In this example, we first take our codes, cross-join them and then test whether they subsume each other. Then we do another subsumption test against the "ear, nose and throat disorder" concept.

# 232208008 |Ear, nose and throat disorder|
left_coding = Coding('', '232208008')
right_coding_column = to_coding(csv.CODE, '')

result = pc.subsumes(csv, 'SUBSUMES',
right_coding_column=right_coding_column)'CODE', 'DESCRIPTION', 'IS_ENT').show()

Results in:

65363002Otitis mediatrue
16114001Fracture of anklefalse
444814009Viral sinusitistrue