cdisc-org / cdisc-org/cdisc-rules-engine
substring operation (on dates) and datediff (not "FDA-math")
- Dominant language
- Python
- Stars
- 113
- Forks
- 43
- Avg merge
- 14h 51m
- Merged PRs (30d)
- 14
Description
### Standard
CDISC SEND
### Reference Rule ID(s)
SEND406
### Conformance Rule ID(s) (if published in CORE)
CORE-
### JIRA Ticket
https://jira.cdisc.org/projects/CORERULES/issues/CORERULES-
### Proposed Rule YAML
```YAML
see https://rule-editor.cdisc.org/ rule SEND406
which is just a first start ... (I got stuck)
```
### Attach any sample test data file(s)
For SEND-(DART-)406, I need to take the earliest date from SJ.SJSTDTC, so I use "min_date", but then I may only use the date part (first 10 characters), and then subtract 2 such dates from each other. I can however not use the "dy" method, as that is specific for DM-RFSTDTC which excludes "0". So I need to have the "real" (not-FDA-method) difference.
I did sofar not find any operators for this.
How do I get the first 10 characters? Is there something like a "substring" operation? We urgently need such a (simple) operator.
What we also need is an operation like "datediff" that provides the "real" (not-FDA-method) difference between dates, i.e. allows "0" as the result.
The rule is: "'RPPLENDY should be populated using the planned repro phase day of observation end algorithm."
and "RPPLENDY=planned event date- (date portion of SJSTDTC) + RPRFDY"
[SENDIG_406_positive.xlsx](https://github.com/user-attachments/files/29451886/SENDIG_406_positive.xlsx)
[SENDIG_406_positive_SJSTDTC_date_only.xlsx](https://github.com/user-attachments/files/29451885/SENDIG_406_positive_SJSTDTC_date_only.xlsx)
### Expected output
correct implementation of "substring" (Python: slicing, see e.g. https://stackoverflow.com/questions/509211/how-slicing-in-python-works)
correct implementation of "datediff" (Python: see e.g. Answer 1 of: https://stackoverflow.com/questions/8419564/difference-between-two-dates-in-python)
### Any Additional Information
_No response_
Contributor guide
Research direction
Start with rule SEND406 in the linked rule editor and compare its expected calculations with the attached SENDIG_406_positive.xlsx files. Investigate how the engine represents date expressions and operators; done means substring returns the requested date portion and datediff produces the expected real date difference, including 0.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100