@@ -268,17 +268,21 @@ def parse_snomed_complex_map_tsv(
268
268
file_path : str ,
269
269
prefix_map : Dict [str , str ] = None ,
270
270
meta : Dict [str , str ] = None ,
271
+ filter_by_confident_mappings = True
271
272
) -> MappingSetDataFrame :
272
273
"""Parse special SNOMED ICD10CM mapping file and translates it into a MappingSetDataFrame.
273
274
274
- :param file_path: The path to the obographs file
275
+ :param file_path: The path to the source file
275
276
:param prefix_map: an optional prefix map
276
277
:param meta: an optional dictionary of metadata elements
278
+ :param filter_by_confident_mappings: Will only include mapping rows where the `mapAdvice` field includes an 'ALWAYS
279
+ <code>' pattern.
277
280
:return: A SSSOM MappingSetDataFrame
278
281
"""
279
282
raise_for_bad_path (file_path )
280
283
df = read_pandas (file_path )
281
- df2 = from_snomed_complex_map_tsv (df , prefix_map = prefix_map , meta = meta )
284
+ df2 = from_snomed_complex_map_tsv (
285
+ df , prefix_map = prefix_map , meta = meta , filter_by_confident_mappings = filter_by_confident_mappings )
282
286
return df2
283
287
284
288
@@ -691,12 +695,15 @@ def from_snomed_complex_map_tsv(
691
695
df : pd .DataFrame ,
692
696
prefix_map : Optional [PrefixMap ] = None ,
693
697
meta : Optional [MetadataType ] = None ,
698
+ filter_by_confident_mappings = True
694
699
) -> MappingSetDataFrame :
695
700
"""Convert a snomed_icd10cm_map dataframe to a MappingSetDataFrame.
696
701
697
702
:param df: A mappings dataframe
698
703
:param prefix_map: A prefix map
699
704
:param meta: A metadata dictionary
705
+ :param filter_by_confident_mappings: Will only include mapping rows where the `mapAdvice` field includes an 'ALWAYS
706
+ <code>' pattern.
700
707
:return: MappingSetDataFrame
701
708
702
709
# Field descriptions
@@ -730,11 +737,23 @@ def from_snomed_complex_map_tsv(
730
737
- mapCategoryId,SctId,Identifies the SNOMED CT concept in the metadata hierarchy which is the MapCategory for the
731
738
associated map record. This is a subtype of 447634004 |ICD-10 Map Category value|.,
732
739
"""
740
+ # Local variables
733
741
# https://www.findacode.com/snomed/447561005--snomed-ct-source-code-to-target-map-correlation-not-specified.html
734
742
match_type_snomed_unspecified_id = 447561005
743
+ # - Note: joeflack4: I used this info as a reference for this pattern.
744
+ # https://www.medicalbillingandcoding.org/icd-10-cm/#:~:text=ICD%2D10%2DCM%20is%20a,decimal%20point%20and%20the%20subcategory.
745
+ always_confidence_pattern = 'ALWAYS [A-Z]{1}[0-9]{1,2}\.[0-9A-Z]{1,4}'
746
+ always_confidence_antipattern = always_confidence_pattern + '\?'
735
747
prefix_map = _ensure_prefix_map (prefix_map )
736
748
ms = _init_mapping_set (meta )
737
749
750
+ # Filtering
751
+ if filter_by_confident_mappings :
752
+ df = df [
753
+ (df ['mapAdvice' ].str .contains (always_confidence_pattern , regex = True , na = False )) &
754
+ (~ df ['mapAdvice' ].str .contains (always_confidence_antipattern , regex = True , na = False ))]
755
+
756
+ # Map mappings
738
757
mlist : List [Mapping ] = []
739
758
for _ , row in df .iterrows ():
740
759
mdict = {
0 commit comments