@@ -307,13 +307,22 @@ def _validate_identifier_mappings_collection(
307307 of a same-system primary. It is also invalid to add two ``rms -> smda``
308308 mappings for the same ``source_id``.
309309
310- - A cross-system ``target_id`` can be used only once per target system.
310+ - A cross-system ``target_id`` can be used only once per target system, except
311+ for RMS to SMDA wellbore mappings. Different RMS wellbore names can map to
312+ the same SMDA wellbore.
311313 Example valid mappings::
312314
313315 rms -> rms, primary, source_id="TopVolantis", target_id="TopVolantis"
314316 rms -> rms, alias, source_id="TOP_VOLANTIS", target_id="TopVolantis"
315317 rms -> smda, primary, source_id="TopVolantis", target_id="VOLANTIS GP. Top"
316318
319+ Example valid RMS to SMDA wellbore mappings::
320+
321+ rms -> rms, primary, source_id="RFT_30_9-B-21_C", target_id="RFT_30_9-B-21_C"
322+ rms -> rms, primary, source_id="MLW_30_9-B-21_C", target_id="MLW_30_9-B-21_C"
323+ rms -> smda, primary, source_id="RFT_30_9-B-21_C", target_id="NO 30/9-B-21 C"
324+ rms -> smda, primary, source_id="MLW_30_9-B-21_C", target_id="NO 30/9-B-21 C"
325+
317326 Example invalid mappings::
318327
319328 rms -> rms, primary, source_id="TopVolantis", target_id="TopVolantis"
@@ -322,7 +331,9 @@ def _validate_identifier_mappings_collection(
322331 rms -> smda, primary, source_id="Volon", target_id="VOLANTIS GP. Top"
323332
324333 The second cross-system mapping is invalid because one cross-system
325- ``target_id`` cannot be mapped to more than one same-system primary.
334+ ``target_id`` cannot be mapped to more than one same-system primary. The
335+ exception permits this relationship only for ``wellbore`` mappings from
336+ ``rms`` to ``smda``.
326337 """
327338 same_system_source_keys : set [tuple [DataSystem , MappingType , str ]] = set ()
328339 same_system_primary_source_keys : set [tuple [DataSystem , MappingType , str ]] = set ()
@@ -368,8 +379,14 @@ def _validate_identifier_mappings_collection(
368379 )
369380 cross_system_source_keys .add (cross_system_source_key )
370381
371- # A cross-system target_id can only belong to one same-system primary.
372- if mapping .target_id is not None :
382+ # RMS wellbore names can share an SMDA wellbore target. Other
383+ # cross-system target_ids can only belong to one same-system primary.
384+ allows_reused_target_id = (
385+ mapping .mapping_type == MappingType .wellbore
386+ and mapping .source_system == DataSystem .rms
387+ and mapping .target_system == DataSystem .smda
388+ )
389+ if mapping .target_id is not None and not allows_reused_target_id :
373390 cross_system_target_key = (
374391 mapping .mapping_type ,
375392 mapping .source_system ,
0 commit comments