@@ -146,17 +146,21 @@ def read_snomed_complex_map_tsv(
146
146
file_path : str ,
147
147
prefix_map : Dict [str , str ] = None ,
148
148
meta : Dict [str , str ] = None ,
149
+ filter_by_confident_mappings = True
149
150
) -> MappingSetDataFrame :
150
151
"""Parse special SNOMED ICD10CM mapping file and translates it into a MappingSetDataFrame.
151
152
152
- :param file_path: The path to the obographs file
153
+ :param file_path: The path to the source file
153
154
:param prefix_map: an optional prefix map
154
155
:param meta: an optional dictionary of metadata elements
156
+ :param filter_by_confident_mappings: Will only include mapping rows where the `mapAdvice` field includes an 'ALWAYS
157
+ <code>' pattern.
155
158
:return: A SSSOM MappingSetDataFrame
156
159
"""
157
160
raise_for_bad_path (file_path )
158
161
df = read_pandas (file_path )
159
- df2 = from_snomed_complex_map_tsv (df , prefix_map = prefix_map , meta = meta )
162
+ df2 = from_snomed_complex_map_tsv (
163
+ df , prefix_map = prefix_map , meta = meta , filter_by_confident_mappings = filter_by_confident_mappings )
160
164
return df2
161
165
162
166
@@ -524,12 +528,15 @@ def from_snomed_complex_map_tsv(
524
528
df : pd .DataFrame ,
525
529
prefix_map : Optional [PrefixMap ] = None ,
526
530
meta : Optional [MetadataType ] = None ,
531
+ filter_by_confident_mappings = True
527
532
) -> MappingSetDataFrame :
528
533
"""Convert a snomed_icd10cm_map dataframe to a MappingSetDataFrame.
529
534
530
535
:param df: A mappings dataframe
531
536
:param prefix_map: A prefix map
532
537
:param meta: A metadata dictionary
538
+ :param filter_by_confident_mappings: Will only include mapping rows where the `mapAdvice` field includes an 'ALWAYS
539
+ <code>' pattern.
533
540
:return: MappingSetDataFrame
534
541
535
542
# Field descriptions
@@ -563,11 +570,23 @@ def from_snomed_complex_map_tsv(
563
570
- mapCategoryId,SctId,Identifies the SNOMED CT concept in the metadata hierarchy which is the MapCategory for the
564
571
associated map record. This is a subtype of 447634004 |ICD-10 Map Category value|.,
565
572
"""
573
+ # Local variables
566
574
# https://www.findacode.com/snomed/447561005--snomed-ct-source-code-to-target-map-correlation-not-specified.html
567
575
match_type_snomed_unspecified_id = 447561005
576
+ # - Note: joeflack4: I used this info as a reference for this pattern.
577
+ # https://www.medicalbillingandcoding.org/icd-10-cm/#:~:text=ICD%2D10%2DCM%20is%20a,decimal%20point%20and%20the%20subcategory.
578
+ always_confidence_pattern = 'ALWAYS [A-Z]{1}[0-9]{1,2}\.[0-9A-Z]{1,4}'
579
+ always_confidence_antipattern = always_confidence_pattern + '\?'
568
580
prefix_map = _ensure_prefix_map (prefix_map )
569
581
ms = _init_mapping_set (meta )
570
582
583
+ # Filtering
584
+ if filter_by_confident_mappings :
585
+ df = df [
586
+ (df ['mapAdvice' ].str .contains (always_confidence_pattern , regex = True , na = False )) &
587
+ (~ df ['mapAdvice' ].str .contains (always_confidence_antipattern , regex = True , na = False ))]
588
+
589
+ # Map mappings
571
590
mlist : List [Mapping ] = []
572
591
for _ , row in df .iterrows ():
573
592
mdict = {
0 commit comments