phenopacket_mapper.data_standards.code module

class phenopacket_mapper.data_standards.code.Coding(system: str | CodeSystem, code: str, display: str = '', text: str = '')[source]

Bases: object

Data class for Coding

A Coding is a representation of a concept defined by a code and a code system. It is used in the CodeableConcept data class.

Variables:
  • system – The code system that defines the code

  • code – The code that represents the concept

  • display – The human readable representation of the concept

  • text – A human readable description or other additional text of the concept

system: str | CodeSystem
code: str
display: str
text: str
static parse_coding(coding_str: str, resources: List[CodeSystem], compliance: Literal['lenient', 'strict'] = 'lenient') Coding[source]

Parsed a string representing a coding to a Coding object

Expected format: <namespace_prefix>:<code>

E.g.: >>> Coding.parse_coding(“SNOMED:404684003”, [code_system.SNOMED_CT]) Coding(system=CodeSystem(name=SNOMED CT, name space prefix=SNOMED, version=0.0.0), code=’404684003’, display=’’, text=’’)

Intended to be called with a list of all resources used.

Can only recognize the name space prefixes that belong to code systems provided in the resources list. If a name space is not found in the resources, it will return a Coding object with the system as the name space prefix and the code as the code.

E.g.: >>> Coding.parse_coding(“SNOMED:404684003”, []) Warning: Code system with namespace prefix ‘SNOMED’ not found in resources. Warning: Returning Coding object with system as namespace prefix and code as ‘404684003’ Coding(system=’SNOMED’, code=’404684003’, display=’’, text=’’)

Parameters:
  • coding_str – a string representing a coding

  • resources – a list of all resources used

  • compliance – whether to throw a ValueError or just a warning if a name space prefix is not found in the resources

Returns:

a Coding object as specified in the coding string

class phenopacket_mapper.data_standards.code.CodeableConcept(coding: List[Coding], text: str = '')[source]

Bases: object

Data class for CodeableConcept

A CodeableConcept represents a concept that is defined by a set of codes. The concept may additionally have a text representation.

Variables:
  • coding – A list of codings that define the concept

  • text – A text representation of the concept

coding: List[Coding]
text: str