Skip to content
3 changes: 2 additions & 1 deletion cdisc_rules_engine/services/reporting/json_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ def get_export(
json_export[self._get_property_name(sheet_name)] = data_sheet
if raw_report:
json_export["results_data"] = [
rule_result.to_representation() for rule_result in self._results
rule_result.to_representation()
for rule_result in self._report_standard._results
]
return json_export

Expand Down
63 changes: 63 additions & 0 deletions tests/QARegressionTests/test_Issues/test_CoreIssue1501.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import os
import subprocess
import unittest

import pytest
import json
from conftest import get_python_executable


@pytest.mark.regression
class TestCoreIssue1501(unittest.TestCase):
def test_raw_report(self):
# Run the command in the terminal
command = [
f"{get_python_executable()}",
"-m",
"core",
"validate",
"-s",
"send",
"-v",
"1-0",
"-dp",
os.path.join(
"tests",
"resources",
"CoreIssue1501",
"unit-test-coreid-SENDIG282-negative.json",
),
"-lr",
os.path.join("tests", "resources", "CoreIssue1501", "Rule.yml"),
"-ps",
"1",
"-of",
"json",
"-rr",
]
subprocess.run(command, check=True)

# Get the latest created Excel file
files = os.listdir()
json_files = [
file
for file in files
if file.startswith("CORE-Report-") and file.endswith(".json")
]
json_report_path = sorted(json_files)[-1]
# Open the JSON report file
json_report = json.load(open(json_report_path))
assert {
"Conformance_Details",
"Dataset_Details",
"Issue_Summary",
"Issue_Details",
"Rules_Report",
}.issubset(json_report.keys())

if "results_data" not in json_report.keys():
assert (
False
), "'results_data' key not found in report. Expected while using -rr, --raw_report flag"
if os.path.exists(json_report_path):
os.remove(json_report_path)
132 changes: 132 additions & 0 deletions tests/resources/CoreIssue1501/Rule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
Authorities:
- Organization: CDISC
Standards:
- Name: SENDIG
References:
- Citations:
- Cited Guidance:
"Defines the type of specimen used for a measurement. Examples:
SERUM, PLASMA, URINE. If multiple specimen types are used for
a calculation (e.g., serum and urine for creatinine
clearance), then refer to Section 4.3.6.2 for guidance on how
to populate."
Document: IG v3.1
Item: PPSPEC CDISC Notes
Section: 6.3.12
Origin: SEND Conformance Rules
Rule Identifier:
Id: "SEND282"
Version: "1"
Version: "5.0"
Version: "3.1"
- Name: SENDIG
References:
- Citations:
- Cited Guidance:
"Defines the type of specimen used for a measurement. Examples:
SERUM, PLASMA, URINE. If multiple specimen types are used for
a calculation (e.g., serum and urine for creatinine
clearance), then refer to Section 4.3.6.2 for guidance on how
to populate."
Document: IG v3.1.1
Item: PPSPEC CDISC Notes
Section: 6.3.12
Origin: SEND Conformance Rules
Rule Identifier:
Id: "SEND282"
Version: "1"
Version: "5.0"
Version: "3.1.1"
- Name: SENDIG-DART
References:
- Citations:
- Cited Guidance:
"Defines the type of specimen used for a measurement. Examples:
SERUM, PLASMA, URINE. If multiple specimen types are used for
a calculation (e.g., serum and urine for creatinine
clearance), then refer to Section 4.3.6.2 for guidance on how
to populate."
Document: IG v3.1
Item: PPSPEC CDISC Notes
Section: 6.3.12
Origin: SEND Conformance Rules
Rule Identifier:
Id: "SEND282"
Version: "1"
Version: "5.0"
Version: "1.1"
- Name: SENDIG-DART
References:
- Citations:
- Cited Guidance:
"Defines the type of specimen used for a measurement. Examples:
SERUM, PLASMA, URINE. If multiple specimen types are used for
a calculation (e.g., serum and urine for creatinine
clearance), then refer to Section 4.3.6.2 for guidance on how
to populate."
Document: IG v3.1.1
Item: PPSPEC CDISC Notes
Section: 6.3.12
Origin: SEND Conformance Rules
Rule Identifier:
Id: "SEND282"
Version: "1"
Version: "5.0"
Version: "1.2"
- Name: SENDIG-GENETOX
References:
- Citations:
- Cited Guidance:
"Defines the type of specimen used for a measurement. Examples:
SERUM, PLASMA, URINE. If multiple specimen types are used for
a calculation (e.g., serum and urine for creatinine
clearance), then refer to Section 4.3.6.2 for guidance on how
to populate."
Document: IG v3.1.1
Item: PPSPEC CDISC Notes
Section: 6.3.12
Origin: SEND Conformance Rules
Rule Identifier:
Id: "SEND282"
Version: "1"
Version: "5.0"
Version: "1.0"
Check:
all:
- name: $spec_codelist
operator: not_contains_all
value: $ppspec_value
Core:
Id: CDISC.SENDIG.SEND282
Status: Draft
Version: "1"
Operations:
- codelists:
- SPEC
level: term
id: $spec_codelist
operator: codelist_terms
returntype: value
- name: PPSPEC
delimiter: ;
id: $ppspec_value
operator: split_by
Description: If multiple specimen types are used for a calculation (e.g., serum
and urine for creatinine clearance), then this field should be populated with
values from the (SPEC) Controlled Terminology codelist delimited by a
semicolon.
Executability: Fully Executable
Outcome:
Message: The multiple specimens are not correctly separated by a semicolon
Output Variables:
- $ppspec_value
- $spec_codelist
Rule Type: Record Data
Scope:
Classes:
Include:
- ALL
Domains:
Include:
- ALL
Sensitivity: Record
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"datasets": [
{
"filename": "pp.xpt",
"label": "Pharmacokinetics Parameters",
"domain": "PP",
"variables": [
{
"name": "STUDYID",
"label": "Study Identifier",
"type": "Char",
"length": 12
},
{
"name": "DOMAIN",
"label": "Domain Abbreviation",
"type": "Char",
"length": 2
},
{
"name": "USUBJID",
"label": "Unique Subject Identifier",
"type": "Char",
"length": 20
},
{
"name": "PPSEQ",
"label": "Sequence Number",
"type": "Num",
"length": 20
},
{
"name": "PPTESTCD",
"label": "Parameter Short Name",
"type": "Char",
"length": 20
},
{
"name": "PPTEST",
"label": "Parameter Name",
"type": "Char",
"length": 20
},
{
"name": "PPSPEC",
"label": "Specimen Material Type",
"type": "Char",
"length": 20
}
],
"records": {
"STUDYID": [
"CDISCPILOT01",
"CDISCPILOT01",
"CDISCPILOT01",
"CDISCPILOT01"
],
"DOMAIN": ["PP", "PP", "PP", "PP"],
"USUBJID": ["CDISC001", "CDISC001", "CDISC001", "CDISC001"],
"PPSEQ": [1, 2, 3, 4],
"PPTESTCD": ["TMAX", "TMAX", "TMAX", "TMAX"],
"PPTEST": [
"Time of CMAX ",
"Time of CMAX ",
"Time of CMAX ",
"Time of CMAX "
],
"PPSPEC": [
"ABDOMINAL WALL",
"ADIPOSE TISSUE, BROWN",
"ABDOMINAL WALL|ADIPOSE TISSUE, BROWN",
"ABDOMINAL WALL;ADIPOSE TISSUE, BROWN&AIR SAC"
]
}
}
],
"standard": {
"product": "sendig",
"version": "3-1"
},
"codelists": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"datasets": [
{
"filename": "pp.xpt",
"label": "Pharmacokinetics Parameters",
"domain": "PP",
"variables": [
{
"name": "STUDYID",
"label": "Study Identifier",
"type": "Char",
"length": 12
},
{
"name": "DOMAIN",
"label": "Domain Abbreviation",
"type": "Char",
"length": 2
},
{
"name": "USUBJID",
"label": "Unique Subject Identifier",
"type": "Char",
"length": 20
},
{
"name": "PPSEQ",
"label": "Sequence Number",
"type": "Num",
"length": 20
},
{
"name": "PPTESTCD",
"label": "Parameter Short Name",
"type": "Char",
"length": 20
},
{
"name": "PPTEST",
"label": "Parameter Name",
"type": "Char",
"length": 20
},
{
"name": "PPSPEC",
"label": "Specimen Material Type",
"type": "Char",
"length": 20
}
],
"records": {
"STUDYID": [
"CDISCPILOT01",
"CDISCPILOT01",
"CDISCPILOT01",
"CDISCPILOT01"
],
"DOMAIN": ["PP", "PP", "PP", "PP"],
"USUBJID": ["CDISC001", "CDISC001", "CDISC001", "CDISC001"],
"PPSEQ": [1, 2, 3, 4],
"PPTESTCD": ["TMAX", "TMAX", "TMAX", "TMAX"],
"PPTEST": [
"Time of CMAX ",
"Time of CMAX ",
"Time of CMAX ",
"Time of CMAX "
],
"PPSPEC": [
"ABDOMINAL WALL",
"ADIPOSE TISSUE, BROWN",
"ABDOMINAL WALL;ADIPOSE TISSUE, BROWN",
"ABDOMINAL WALL;ADIPOSE TISSUE, BROWN;AIR SAC"
]
}
}
],
"standard": {
"product": "sendig",
"version": "3-1"
},
"codelists": []
}
Loading
Loading