csrlite 0.3.0__py3-none-any.whl → 0.3.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
csrlite/ae/ae_utils.py CHANGED
@@ -1,62 +1,62 @@
1
- from typing import Any
2
-
3
-
4
- def get_ae_parameter_title(param: Any, prefix: str = "Participants With") -> str:
5
- """
6
- Extract title from parameter for ae_* title generation.
7
-
8
- Args:
9
- param: Parameter object with terms attribute
10
- prefix: Prefix for the title (e.g. "Participants With", "Listing of Participants With")
11
-
12
- Returns:
13
- Title string for the analysis
14
- """
15
- default_suffix = "Adverse Events"
16
-
17
- if not param:
18
- return f"{prefix} {default_suffix}"
19
-
20
- # Check for terms attribute
21
- if hasattr(param, "terms") and param.terms and isinstance(param.terms, dict):
22
- terms = param.terms
23
-
24
- # Preprocess to empty strings (avoiding None)
25
- before = terms.get("before", "").title()
26
- after = terms.get("after", "").title()
27
-
28
- # Build title and clean up extra spaces
29
- title = f"{prefix} {before} {default_suffix} {after}"
30
- return " ".join(title.split()) # Remove extra spaces
31
-
32
- # Fallback to default
33
- return f"{prefix} {default_suffix}"
34
-
35
-
36
- def get_ae_parameter_row_labels(param: Any) -> tuple[str, str]:
37
- """
38
- Generate n_with and n_without row labels based on parameter terms.
39
-
40
- Returns:
41
- Tuple of (n_with_label, n_without_label)
42
- """
43
- # Default labels
44
- default_with = " with one or more adverse events"
45
- default_without = " with no adverse events"
46
-
47
- if not param or not hasattr(param, "terms") or not param.terms:
48
- return (default_with, default_without)
49
-
50
- terms = param.terms
51
- before = terms.get("before", "").lower()
52
- after = terms.get("after", "").lower()
53
-
54
- # Build dynamic labels with leading indentation
55
- with_label = f"with one or more {before} adverse events {after}"
56
- without_label = f"with no {before} adverse events {after}"
57
-
58
- # Clean up extra spaces and add back the 4-space indentation
59
- with_label = " " + " ".join(with_label.split())
60
- without_label = " " + " ".join(without_label.split())
61
-
62
- return (with_label, without_label)
1
+ from typing import Any
2
+
3
+
4
+ def get_ae_parameter_title(param: Any, prefix: str = "Participants With") -> str:
5
+ """
6
+ Extract title from parameter for ae_* title generation.
7
+
8
+ Args:
9
+ param: Parameter object with terms attribute
10
+ prefix: Prefix for the title (e.g. "Participants With", "Listing of Participants With")
11
+
12
+ Returns:
13
+ Title string for the analysis
14
+ """
15
+ default_suffix = "Adverse Events"
16
+
17
+ if not param:
18
+ return f"{prefix} {default_suffix}"
19
+
20
+ # Check for terms attribute
21
+ if hasattr(param, "terms") and param.terms and isinstance(param.terms, dict):
22
+ terms = param.terms
23
+
24
+ # Preprocess to empty strings (avoiding None)
25
+ before = terms.get("before", "").title()
26
+ after = terms.get("after", "").title()
27
+
28
+ # Build title and clean up extra spaces
29
+ title = f"{prefix} {before} {default_suffix} {after}"
30
+ return " ".join(title.split()) # Remove extra spaces
31
+
32
+ # Fallback to default
33
+ return f"{prefix} {default_suffix}"
34
+
35
+
36
+ def get_ae_parameter_row_labels(param: Any) -> tuple[str, str]:
37
+ """
38
+ Generate n_with and n_without row labels based on parameter terms.
39
+
40
+ Returns:
41
+ Tuple of (n_with_label, n_without_label)
42
+ """
43
+ # Default labels
44
+ default_with = " with one or more adverse events"
45
+ default_without = " with no adverse events"
46
+
47
+ if not param or not hasattr(param, "terms") or not param.terms:
48
+ return (default_with, default_without)
49
+
50
+ terms = param.terms
51
+ before = terms.get("before", "").lower()
52
+ after = terms.get("after", "").lower()
53
+
54
+ # Build dynamic labels with leading indentation
55
+ with_label = f"with one or more {before} adverse events {after}"
56
+ without_label = f"with no {before} adverse events {after}"
57
+
58
+ # Clean up extra spaces and add back the 4-space indentation
59
+ with_label = " " + " ".join(with_label.split())
60
+ without_label = " " + " ".join(without_label.split())
61
+
62
+ return (with_label, without_label)