pepfar-datim / datapackr

Creative Commons Zero v1.0 Universal
9 stars 7 forks source link

create packForPAW function and tests #794

Closed flopez-bao closed 9 months ago

flopez-bao commented 9 months ago
flopez-bao commented 9 months ago

@JordanBalesBAO , I added a createPAWExport as a potential route option - I think it may be the most straightforward after more testing, you can run the COP24 Cameroon datapack to see the differences in the final object, the PAW export should have the extra key pop indicators:

library(datapackr)
library(magrittr)

# Point to DATIM login secrets ####
secrets <- Sys.getenv("SECRETS_FOLDER") %>% paste0(., "datim.json")

datimutils::loginToDATIM(secrets)

output_folder <- Sys.getenv("OUTPUT_FOLDER") %>% paste0(., "COP24 Data Packs/")
model_data_path <- Sys.getenv("MODEL_DATA_PATH")
snuxim_model_data_path <- Sys.getenv("SNUXIM_MODEL_DATA_PATH")

# Unpack Submitted Data Pack ####
d <- datapackr::unPackToolSet(file.choose()) 

paw_ex <- createPAWExport(d)
datim_ex <- createDATIMExport(d)
> nrow(paw_ex)
[1] 5562
> nrow(datim_ex)
[1] 5132

pop_data <- c("KssDaTsGWnS", "lJtpR5byqps", "nF19GOjcnoD", "P2XNbiNnIqV")
datim_ex %>% dplyr::filter(dataElement %in% pop_data)
# A tibble: 0 × 6
# ℹ 6 variables: dataElement <chr>, period <chr>, orgUnit <chr>, categoryOptionCombo <chr>, attributeOptionCombo <chr>, value <chr>

paw_ex %>% dplyr::filter(dataElement %in% pop_data) %>% head(2)
# A tibble: 2 × 6
  dataElement period  orgUnit     categoryOptionCombo attributeOptionCombo value 
  <chr>       <chr>   <chr>       <chr>               <chr>                <chr> 
1 KssDaTsGWnS 2023Oct HxXMyMSODnm C8E2J67vSKJ         HllvX50cXC0          34781 
2 KssDaTsGWnS 2023Oct HxXMyMSODnm DWZgJTKGiia         HllvX50cXC0          307495
JordanBalesBAO commented 9 months ago

NOTE for myself, HAVE TO do in an ifelse in the app send to paw button based upon cop year. This will go away after this year

JordanBalesBAO commented 9 months ago

NOTE for myself, HAVE TO do in an ifelse in the app send to paw button based upon cop year. This will go away after this year

Won't be necessary the way pack for paw was coded.