Skip to content

Match attains wqp water types#939

Open
hillarymarler wants to merge 28 commits into
developfrom
match_attains_wqp_water_types
Open

Match attains wqp water types#939
hillarymarler wants to merge 28 commits into
developfrom
match_attains_wqp_water_types

Conversation

@hillarymarler
Copy link
Copy Markdown
Collaborator

@hillarymarler hillarymarler commented May 15, 2026

Pull Request Checklist (convert PR to draft if in progress)

Adds a new function to add/crosswalk ATTAINS.WaterType to a TADA df based on TADA.MonitoringLocationTypeName.. This function will help facilitate the creation of AUs from WQP Monitoring Locations for new ATTAINS tribes.

I will add this function to a mod 2 vignette when additional functions to support this workflow are developed.

Required

  • Update your branch from the latest develop and resolve any merge conflicts

  • Run devtools::test(), devtools::check(), and devtools::document() locally; ensure tests pass and fix any errors, warnings, or notes. Add new dependencies to DESCRIPTION and document appropriately

  • Add/update vignettes for corresponding changes in functionality, list these under articles in _pkgdown.yml, and ensure added/updated vignettes run and build with proper formatting locally

  • Request review from at least one developer team member (convert PR to ready for review if it was designated as in progress)

Best practices

  • Include a summary of the changes made and relevant context/motivation

  • Link issues to auto-close on merge (use Development sidebar or include "Closes #" in the PR)

  • Refresh inline/block comments for clarity

  • Update roxygen docs and include examples; review help pages

  • Add/update tests in tests/testthat; review the bot's coverage report from test-coverage and confirm all changes are covered

Conditional

  • If there is a bot spelling comment, run spelling::spell_check_package() locally and fix any misspellings; add approved project terms to WORDLIST with spelling::update_wordlist()

  • If tests fail suggesting internal reference files need a refresh, run .TADA_UpdateRefFiles() and .TADA_UpdateExampleData() locally via MaintenanceScheduled.R or trigger the Component File Update GitHub Action

  • If new example data files were added, document them in ExampleData.R and include them in MaintenanceScheduled.R for regular refresh

  • If columns were added/updated, update RequiredCols.R

  • If changes affect other package or the shiny app functions, update those impacted functions accordingly

@github-actions
Copy link
Copy Markdown
Contributor

Spelling check failed. Details:

Spelling check failed. Found 2 potential misspelling(s). Note: Run spelling::spell_check_package() locally and fix any misspellings; add approved project terms to WORDLIST with spelling::update_wordlist().

  WORD                   FOUND IN
ATTAINSWaterTypeFlag   TADA_CrosswalkATTAINSWaterTypes.Rd:27,32
crosswalking           TADA_CrosswalkATTAINSWaterTypes.Rd:31

1 similar comment
@github-actions
Copy link
Copy Markdown
Contributor

Spelling check failed. Details:

Spelling check failed. Found 2 potential misspelling(s). Note: Run spelling::spell_check_package() locally and fix any misspellings; add approved project terms to WORDLIST with spelling::update_wordlist().

  WORD                   FOUND IN
ATTAINSWaterTypeFlag   TADA_CrosswalkATTAINSWaterTypes.Rd:27,32
crosswalking           TADA_CrosswalkATTAINSWaterTypes.Rd:31

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 18, 2026

wokenny13 and others added 2 commits May 19, 2026 12:25
…walk as an option

add arg inputs to TADA_CrosswalkWaterTypes to return additional columns to match the needed columns for the crosswalk arg inputs in TADA_UpdateATTAINSAUMLCrosswalk.

In TADA_UpdateATTAINSAUMLCrosswalk also handle the crosswalk input by selecting appropriate columns and distinct values from it.
@wokenny13
Copy link
Copy Markdown
Collaborator

Not sure if this updated workflow makes sense, if a user wants to now use ML as the AU, they can proceed with creating the AUML ref table as follows:

#' # filter to Blackfeet
#' Tribal_modified2 <- Tribal_modified |>
#' dplyr::filter(OrganizationIdentifier == "BLCKFEET")
#'
#' # append additional columns to the data frame to allow for creating the AUML crosswalk
#' Tribal_reviewUpdate2 <- TADA_CrosswalkATTAINSWaterTypes(Tribal_modified2,
#' org_id = "BLCKFEET",
#' review_all = TRUE,
#' review_action = "update",
#' create_AUMLRef = TRUE)
#'
#' Tribal_AUMLRef <- TADA_UpdateATTAINSAUMLCrosswalk(
#' org_id = "BLCKFEET",
#' crosswalk = Tribal_reviewUpdate2,
#' api_key = .setEQKey())

@hillarymarler
Copy link
Copy Markdown
Collaborator Author

Not sure if this updated workflow makes sense, if a user wants to now use ML as the AU, they can proceed with creating the AUML ref table as follows:

#' # filter to Blackfeet #' Tribal_modified2 <- Tribal_modified |> #' dplyr::filter(OrganizationIdentifier == "BLCKFEET") #' #' # append additional columns to the data frame to allow for creating the AUML crosswalk #' Tribal_reviewUpdate2 <- TADA_CrosswalkATTAINSWaterTypes(Tribal_modified2, #' org_id = "BLCKFEET", #' review_all = TRUE, #' review_action = "update", #' create_AUMLRef = TRUE) #' #' Tribal_AUMLRef <- TADA_UpdateATTAINSAUMLCrosswalk( #' org_id = "BLCKFEET", #' crosswalk = Tribal_reviewUpdate2, #' api_key = .setEQKey())

What piece of it needs to be modified do you think?

I believe Jesse has a naming convention established for the point AUs based on MLs, so I would like to get that logic from him and create another function which would generate the AU identifiers. Then from there would create the batch upload file with the new AU Ids, Water types, and MLs.

@wokenny13
Copy link
Copy Markdown
Collaborator

wokenny13 commented May 19, 2026

I made some push with updates on how I envisioned the workflow might work (though very open to modifying it). Handling of the ATTAINS batch upload vs TADA workflow might need to be considered as well as how we handle assignment of org_id if there exists multiple orgs like in the Tribal example data frame. I have an open issue #932 that could potentially address the org_id crosswalk.

@wokenny13 wokenny13 linked an issue May 19, 2026 that may be closed by this pull request
@wokenny13
Copy link
Copy Markdown
Collaborator

wokenny13 commented May 19, 2026

Example Workflow to get AUMLRef and UsesAURef:

MT_ExData <- Data_MT_AUMLRef$TADA_with_ATTAINS |>
sf::st_drop_geometry()

# add ATTAINS.WaterType only for rows without values in that column
MT_addMissing <- TADA_CrosswalkATTAINSWaterTypes(MT_ExData)

# add ATTAINS.WaterType for all rows (replace existing matches)
MT_replaceAll <- TADA_CrosswalkATTAINSWaterTypes(MT_ExData, replace_all = TRUE)

# add ATTAINS.WaterType to TADA df without ATTAINS.WaterType column
Tribal_addAll <- TADA_CrosswalkATTAINSWaterTypes(Data_TribalNations_Harmonized)

# modify tribal example data to include an ATTAINS.WaterType not allowed by ATTAINS
Tribal_modified <- Tribal_addAll |>
dplyr::mutate(ATTAINS.WaterType =
ifelse(TADA.MonitoringLocationIdentifier %in%
 c("REDLAKE_WQX-GREE-REDLAKE",
   "UTEMTN-COTTONWOOD WASH SPRING",
   "BLCKFEET-00000054",
   "BLCKFEET-00000056"
 ), "INVALID WATER TYPE",
 ATTAINS.WaterType))

 # add ATTAINS.WaterType for any rows where it is missing, review all ATTAINS.WaterType
 # values and update any that are not allowed
 Tribal_reviewUpdate <- TADA_CrosswalkATTAINSWaterTypes(Tribal_modified,
 review_all = TRUE,
 review_action = "update")

 # filter to Blackfeet
 Tribal_modified2 <- Tribal_modified |>
 dplyr::filter(OrganizationIdentifier == "BLCKFEET")

 # append additional columns to the data frame to allow for creating the AUML crosswalk
 Tribal_reviewUpdate2 <- TADA_CrosswalkATTAINSWaterTypes(Tribal_modified2,
 org_id = "BLCKFEET",
 review_all = TRUE,
 review_action = "update",
 create_AUMLRef = TRUE)

 Tribal_AUMLRef <- TADA_UpdateATTAINSAUMLCrosswalk(
 org_id = "BLCKFEET",
 crosswalk = Tribal_reviewUpdate2,
 api_key = .setEQKey())

# First creates the uses water type using org_id = NULL, next determine which of these uses are appropriate
# Note: can we decide and assign which epa304a recommended uses may be applicable from ATTAINS here?
usesWater_filtered <- TADA_AssignUsesToWaterType(
Tribal_reviewUpdate2, org_id = NULL, AUMLRef = Tribal_AUMLRef) |> dplyr::filter(ATTAINS.UseName %in% c("Aquatic Life Support", "Primary Human Contact", "Secondary Human Contact", "Primary Contact Recreation")) |> dplyr::mutate(ATTAINS.OrganizationIdentifier = "BLCKFEET"

# from the waterUseRef, we will assign all unique uses to each ML/AU
usesAU_BLCKFEET <- TADA_AssignUsesToAU(Tribal_reviewUpdate2, org_id = "BLCKFEET", AUMLRef = Tribal_AUMLRef, waterUseRef = usesWater_filtered)
)```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TADA_AssignUsesToAU does not run when org_id = NULL

2 participants