Skip to content

Commit f5a5923

Browse files
* clean-up/restructure
1 parent a0fbd3b commit f5a5923

23 files changed

Lines changed: 406 additions & 163 deletions

DESCRIPTION

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,48 @@ Encoding: UTF-8
4444
Language: en-US
4545
LazyData: true
4646
Roxygen: list(markdown = TRUE, roclets = c("collate", "namespace", "rd"))
47+
Collate:
48+
'aaa-classes.R'
49+
'aaa-generics.R'
50+
'aaa-cms-list.R'
51+
'aaa-cms.R'
52+
'aaa-pdc.R'
53+
'checks.R'
54+
'cli.R'
55+
'combine.R'
56+
'data.R'
57+
'end-affiliation.R'
58+
'end-clia.R'
59+
'end-clinicians.R'
60+
'end-dialysis.R'
61+
'end-facility.R'
62+
'end-hospitals.R'
63+
'end-hospitals2.R'
64+
'end-nppes.R'
65+
'end-opt_out.R'
66+
'end-order_refer.R'
67+
'end-owner.R'
68+
'end-pending.R'
69+
'end-providers.R'
70+
'end-quality.R'
71+
'end-reassignment.R'
72+
'end-revocations.R'
73+
'end-transparency.R'
74+
'end-utilization.R'
75+
'enums.R'
76+
'httr2.R'
77+
'import-standalone-obj-type.R'
78+
'import-standalone-types-check.R'
79+
'modifiers.R'
80+
'offset.R'
81+
'pivot.R'
82+
'polish-core.R'
83+
'polish.R'
84+
'provider-common-params.R'
85+
'provider-package.R'
86+
'query.R'
87+
'query2.R'
88+
'recode.R'
89+
'rename.R'
90+
'utils.R'
91+
'zzz.R'

R/aaa-classes.R

Lines changed: 27 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -86,64 +86,36 @@ EndpointPDC <- S7::new_class(
8686
)
8787

8888
#' @noRd
89-
request_count <- S7::new_generic("request_count", "x")
90-
89+
s3_affiliations <- S7::new_S3_class("affiliations")
9190
#' @noRd
92-
request_preview <- S7::new_generic("request_preview", "x")
93-
91+
s3_clia <- S7::new_S3_class("clia")
9492
#' @noRd
95-
request_single <- S7::new_generic("request_single", "x")
96-
93+
s3_clinicians <- S7::new_S3_class("clinicians")
9794
#' @noRd
98-
request_multi <- S7::new_generic("request_multi", "x")
99-
95+
s3_dialysis <- S7::new_S3_class("dialysis")
10096
#' @noRd
101-
execute <- S7::new_generic("execute", "x")
102-
97+
s3_facility <- S7::new_S3_class("facility")
10398
#' @noRd
104-
S7::method(execute, Endpoint) <- function(x) {
105-
check_online()
106-
107-
if (length(x@query) == 0L) {
108-
switch(
109-
x@action,
110-
count = return(report_total(x)),
111-
set = return(request_multi(x)),
112-
return(request_preview(x))
113-
)
114-
}
115-
116-
if (x@pages == 0L || x@action == "count") {
117-
report_count(x)
118-
return(x@count)
119-
}
120-
121-
if (x@pages == 1L) {
122-
return(request_single(x))
123-
}
124-
request_multi(x)
125-
}
126-
99+
s3_hospitals <- S7::new_S3_class("hospitals")
127100
#' @noRd
128-
S7::method(execute, EndpointCMSList) <- function(x) {
129-
check_online()
130-
131-
if (length(x@query) == 0L) {
132-
switch(
133-
x@action,
134-
count = return(report_total(x)),
135-
set = return(request_multi(x)),
136-
return(request_preview(x))
137-
)
138-
}
139-
140-
if (x@pages == 0L || x@action == "count") {
141-
report_count(x)
142-
return(x@count)
143-
}
144-
145-
if (x@pages <= length(x@url)) {
146-
return(request_single(x))
147-
}
148-
request_multi(x)
149-
}
101+
s3_hospitals2 <- S7::new_S3_class("hospitals2")
102+
#' @noRd
103+
s3_opt_out <- S7::new_S3_class("opt_out")
104+
#' @noRd
105+
s3_order_refer <- S7::new_S3_class("order_refer")
106+
#' @noRd
107+
s3_owner <- S7::new_S3_class("owner")
108+
#' @noRd
109+
s3_pending <- S7::new_S3_class("pending")
110+
#' @noRd
111+
s3_providers <- S7::new_S3_class("providers")
112+
#' @noRd
113+
s3_quality <- S7::new_S3_class("quality")
114+
#' @noRd
115+
s3_reassignments <- S7::new_S3_class("reassignments")
116+
#' @noRd
117+
s3_revocations <- S7::new_S3_class("revocations")
118+
#' @noRd
119+
s3_transparency <- S7::new_S3_class("transparency")
120+
#' @noRd
121+
s3_utilization <- S7::new_S3_class("utilization")

R/aaa-cms-list.R

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,22 @@ cms_list <- function(
8181
action = count_set(count, set)
8282
)
8383

84-
x@count <- request_count(x)
84+
x <- request_count(x)
8585

8686
return(x)
8787
}
8888

89+
#' @include aaa-generics.R
8990
#' @noRd
9091
S7::method(request_count, EndpointCMSList) <- function(x) {
9192
if (length(x@query) > 0L || x@action == "count") {
92-
u <- flatten_cms(x@url, x@query, "/stats?")
93-
x <- multi_count(u, x@url, "found_rows")
94-
return(x)
93+
x@count <- multi_count(
94+
flatten_cms(x@url, x@query, "/stats?"),
95+
x@url,
96+
"found_rows"
97+
)
9598
}
96-
return(0L)
99+
return(x)
97100
}
98101

99102
#' @noRd

R/aaa-cms.R

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ url_cms <- function(x) {
2323
)
2424
}
2525

26+
#' @include aaa-classes.R
2627
#' @noRd
2728
param_cms <- function(...) {
2829
x <- ParamCMS(params(...))
@@ -53,7 +54,7 @@ cms <- function(
5354
action = count_set(count, set)
5455
)
5556

56-
x@count <- request_count(x)
57+
x <- request_count(x)
5758

5859
return(x)
5960
}
@@ -67,14 +68,16 @@ flatten_cms <- function(url, query = NULL, append = "?", ...) {
6768
)
6869
}
6970

71+
#' @include aaa-generics.R
7072
#' @noRd
7173
S7::method(request_count, EndpointCMS) <- function(x) {
7274
if (length(x@query) > 0L || x@action == "count") {
73-
x <- flatten_cms(x@url, x@query, "/stats?")
74-
x <- base_request(x, "found_rows")
75-
return(x)
75+
x@count <- base_request(
76+
flatten_cms(x@url, x@query, "/stats?"),
77+
"found_rows"
78+
)
7679
}
77-
return(0L)
80+
return(x)
7881
}
7982

8083
#' @noRd

R/aaa-generics.R

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#' @noRd
2+
request_count <- S7::new_generic("request_count", "x")
3+
4+
#' @noRd
5+
request_preview <- S7::new_generic("request_preview", "x")
6+
7+
#' @noRd
8+
request_single <- S7::new_generic("request_single", "x")
9+
10+
#' @noRd
11+
request_multi <- S7::new_generic("request_multi", "x")
12+
13+
#' @noRd
14+
build <- S7::new_generic("build", "x")
15+
16+
#' @noRd
17+
combine <- S7::new_generic("combine", c("x", "y"))
18+
19+
#' @noRd
20+
polish <- S7::new_generic("polish", "x")
21+
22+
#' @noRd
23+
execute <- S7::new_generic("execute", "x")
24+
25+
#' @noRd
26+
S7::method(execute, Endpoint) <- function(x) {
27+
check_online()
28+
29+
if (length(x@query) == 0L) {
30+
switch(
31+
x@action,
32+
count = return(report_total(x)),
33+
set = return(request_multi(x)),
34+
return(request_preview(x))
35+
)
36+
}
37+
38+
if (x@pages == 0L || x@action == "count") {
39+
report_count(x)
40+
return(x@count)
41+
}
42+
43+
if (x@pages == 1L) {
44+
return(request_single(x))
45+
}
46+
request_multi(x)
47+
}
48+
49+
#' @noRd
50+
S7::method(execute, EndpointCMSList) <- function(x) {
51+
check_online()
52+
53+
if (length(x@query) == 0L) {
54+
switch(
55+
x@action,
56+
count = return(report_total(x)),
57+
set = return(request_multi(x)),
58+
return(request_preview(x))
59+
)
60+
}
61+
62+
if (x@pages == 0L || x@action == "count") {
63+
report_count(x)
64+
return(x@count)
65+
}
66+
67+
if (x@pages <= length(x@url)) {
68+
return(request_single(x))
69+
}
70+
request_multi(x)
71+
}

R/aaa-pdc.R

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ url_pdc <- function(x) {
5353
)
5454
}
5555

56+
#' @include aaa-classes.R
5657
#' @noRd
5758
param_pdc <- function(...) {
5859
x <- ParamPDC(params(...))
@@ -85,7 +86,7 @@ pdc <- function(
8586
action = count_set(count, set)
8687
)
8788

88-
x@count <- request_count(x)
89+
x <- request_count(x)
8990

9091
return(x)
9192
}
@@ -99,14 +100,16 @@ flatten_pdc <- function(url, query = NULL, ...) {
99100
)
100101
}
101102

103+
#' @include aaa-generics.R
102104
#' @noRd
103105
S7::method(request_count, EndpointPDC) <- function(x) {
104106
if (length(x@query) > 0L || x@action == "count") {
105-
x <- flatten_pdc(x@url, x@query, results = "false")
106-
x <- base_request(x, "count")
107-
return(x)
107+
x@count <- base_request(
108+
flatten_pdc(x@url, x@query, results = "false"),
109+
"count"
110+
)
108111
}
109-
return(0L)
112+
return(x)
110113
}
111114

112115
#' @noRd

0 commit comments

Comments
 (0)