From 0368ef1755189aa6aaa05827ff4ffd5bf97905b2 Mon Sep 17 00:00:00 2001 From: Tom Gebhardt Date: Wed, 25 Oct 2023 15:57:04 +0200 Subject: [PATCH] towards task autmation for CSH --- app/csh_schemas/v3.0.json | 9 - app/main.py | 2 - app/metrics/assessments_lifespan.py | 14 +- app/metrics/metrics.csv | 2 + app/models/csh.py | 58 ----- app/models/session.py | 5 + app/routers/router.py | 1 - tests/local_request.py | 328 +++++++++++++++++++++++++++- 8 files changed, 343 insertions(+), 76 deletions(-) delete mode 100644 app/csh_schemas/v3.0.json delete mode 100644 app/models/csh.py diff --git a/app/csh_schemas/v3.0.json b/app/csh_schemas/v3.0.json deleted file mode 100644 index 776d342..0000000 --- a/app/csh_schemas/v3.0.json +++ /dev/null @@ -1,9 +0,0 @@ - { - "link": [ - {"value": null, "score": -1} - ], - "resource": [ - {"value": "collection", "score": 1} - - ] - } \ No newline at end of file diff --git a/app/main.py b/app/main.py index c4f1680..4d69ad8 100644 --- a/app/main.py +++ b/app/main.py @@ -3,7 +3,6 @@ from fastapi.middleware.cors import CORSMiddleware from app.routers.router import base_router -from app.routers.csh_router import csh_router from app.metrics.assessments_lifespan import get_tasks_definitions from app.dependencies.settings import get_settings @@ -50,7 +49,6 @@ lifespan=get_tasks_definitions, ) app.include_router(base_router) -app.include_router(csh_router) config = get_settings() origins = config.allowed_origins diff --git a/app/metrics/assessments_lifespan.py b/app/metrics/assessments_lifespan.py index 4ae17f3..80be3ae 100644 --- a/app/metrics/assessments_lifespan.py +++ b/app/metrics/assessments_lifespan.py @@ -24,7 +24,10 @@ async def get_tasks_definitions(app: FastAPI): config = get_settings() def parse_line(line): - sub_group = regex_csh.search(line["TaskName"]).groups()[0] + sub_group = regex_csh.search(line["TaskName"]) + if sub_group is None: + return + sub_group = sub_group.groups()[0] task_group = sub_group[0] return { line["TaskName"]: models.Indicator( @@ -39,8 +42,13 @@ def parse_line(line): } # Get the list of tasks and their definitions from internal file - with open(config.csh_indicators_path, "r") as file_handler: + with open(config.indicators_path, "r") as file_handler: csv_reader = DictReader(file_handler, dialect="unix") - [fair_indicators.update(parse_line(line)) for line in csv_reader] + for line in csv_reader: + parsed_line = parse_line(line) + if parsed_line is not None: + print(parsed_line) + fair_indicators.update(parsed_line) + #[fair_indicators.update(parse_line(line)) for line in csv_reader] yield diff --git a/app/metrics/metrics.csv b/app/metrics/metrics.csv index 30a17d7..e9cc8bb 100644 --- a/app/metrics/metrics.csv +++ b/app/metrics/metrics.csv @@ -83,3 +83,5 @@ "CA-RDA-R1.3-02MM","Essential","Metadata of model is expressed in compliance with a machine-understandable community standard","This indicator requires that the model metadata follows a community standard that has a machine-understandable expression","This indicator can be evaluated by verifying that the community standard used f or the metadata has a machine-understandable expression" "CA-RDA-R1.3-03MA","Important","Metadata of archive is expressed in compliance with a machine-understandable cross-community standard","This indicator requires that the archive metadata follows a cross-community standard that has a machine-understandable expression","This indicator can be evaluated by verifying that the cross-community standard used f or the metadata has a machine-understandable expression" "CA-RDA-R1.3-03MM","Important","Metadata of model is expressed in compliance with a machine-understandable cross-community standard","This indicator requires that the model metadata follows a cross-community standard that has a machine-understandable expression","This indicator can be evaluated by verifying that the cross-community standard used f or the metadata has a machine-understandable expression" +"CSH-RDA-F1-01","Important","Is a unique identifier assigned to the study","This indicator is the inital test indicator for evaluating elemts from the CSH","And some more details","??" +"CSH-RDA-F2-01","Essential","Something else","And some more details","??" \ No newline at end of file diff --git a/app/models/csh.py b/app/models/csh.py deleted file mode 100644 index 18f590e..0000000 --- a/app/models/csh.py +++ /dev/null @@ -1,58 +0,0 @@ -import re -from pydantic import BaseModel - -class Score(BaseModel): - overall: int =0 - F: int = 0 - A: int = 0 - I: int = 0 - R: int = 0 - -class study_evaluation: - def __init__(self, json_data, schema): - print("+++++++++++ INSIDE study_evaluation") - self.schema = schema - self.metadata = json_data - self.score = Score() - - - - - def evaluate(self): - print("the schema is: ") - print(self.schema) - if(self.schema == "3.1"): - ###### here will be the list of assessments for schema 3.1 - #check identifier - # - identifier = self.check_route(["resource", "resource_identifier"]) - self.score.F += self.check_identifier(identifier) - - ###### - print(self.score) - return self.score - - def check_route(self, route_keys): - current_position = self.metadata - - for key in route_keys: - if key in current_position: - current_position = current_position[key] - else: - #if a key is missing return false - return False - #if the route exists return the value - return current_position - - # function to check the identifier for uniqueness and persistancy - def check_identifier(self, identifier): - if(self.is_doi(identifier)): - return 1 - elif(identifier.startswith("DRKS")): - return 1 - - @staticmethod - def is_doi(doi): - doi_pattern = r'^10\.\d{4,9}/[-._;()/:A-Z0-9]+$' - # Use the re.match function to check if the string matches the pattern - return bool(re.match(doi_pattern, doi)) \ No newline at end of file diff --git a/app/models/session.py b/app/models/session.py index 90571f0..6b09708 100644 --- a/app/models/session.py +++ b/app/models/session.py @@ -477,6 +477,10 @@ def _get_default_task_status(self, indicator: str) -> tuple[TaskStatus, bool]: if indicator in config.pmr_indicator_status and self.user_input.is_pmr: return TaskStatus(config.pmr_assessment_status[indicator]), True + + if indicator in config.csh_metadata_status: + print("+++++++HUHU++++++") + return TaskStatus(config.csh_metadata_status[indicator]), True if indicator in config.assessment_dependencies: dependency_dict = config.assessment_dependencies[indicator] @@ -577,6 +581,7 @@ def start_automated_tasks(self): """Starts the assessment of automated tasks""" for task_id in self.indicator_tasks.values(): task = self.session_model.get_task(task_id) + print(task) if isinstance(task, AutomatedTask): task.do_evaluate(self.assessed_data.dict()) diff --git a/app/routers/router.py b/app/routers/router.py index e9c655c..61639bb 100644 --- a/app/routers/router.py +++ b/app/routers/router.py @@ -22,7 +22,6 @@ base_router = APIRouter() -print("TESTSTSTS") @base_router.post("/session", tags=["Sessions"]) def create_session( subject: SessionSubjectIn = Depends(SessionSubjectIn.as_form), diff --git a/tests/local_request.py b/tests/local_request.py index 1bd8346..9e7514f 100644 --- a/tests/local_request.py +++ b/tests/local_request.py @@ -8,8 +8,330 @@ # Define the data you want to send in the POST request (as a dictionary) metadata = { - "k1": "v1", - "k2": "v2" + "link": None, + "resource": { + "collection": [ + "COVID-19", + "coverCHILD study platform" + ], + "ids": [ + { + "identifier": "https://www.thieme-connect.com/products/ejournals/abstract/10.1055/a-1638-6053", + "relation_type": "A is described by B", + "resource_type_general": "Other", + "type": "Other" + } + ], + "ids_alternative": [ + { + "identifier": "DRKS00027974", + "type": "DRKS" + } + ], + "provenance": { + "data_source": "Automatically uploaded: DRKS" + }, + "resource_acronyms": [ + { + "language": "EN (English)", + "text": "KICK-COVID" + } + ], + "resource_classification": { + "resource_type": "Study", + "resource_type_general": "Other" + }, + "resource_description_english": { + "language": "EN (English)", + "text": "In a prospective study, the long-term effects of the COVID-19 pandemic on medical and psychosocial characteristics in children and adolescents with chronic conditions will be investigated using a holistic approach. The included diseases are obesity, diabetes, and rheumatic diseases; both the affected individuals themselves and their parents will be interviewed.\nInterdisciplinary collaboration between pediatricians of various specialties, psychologists, and epidemiologists will allow a comprehensive evaluation of the effects of COVID-19 on health care and the physical and mental health of children and adolescents with chronic conditions and their families, as well as the complex interplay between health status and health care as well as environmental and personal contextual factors.\nFor this, questions for the children and adolescents and their parents will be implemented as part of the standard survey in the Diabetes-Patienten-Verlaufsdokumentation (DPV), the Adipositas-Patienten-Verlaufsdokumentation (APV) and the Kerndokumentation rheumakranker Kinder und Jugendlicher (KRhOKo). In addition, all participants are invited to participate in a further online survey on the psychosocial situation and available resources. After one year, a follow-up takes place for both surveys. The prospective design allows both the detection of short- and long-term effects of the COVID-19 pandemic on well-being and the analysis of mediator and moderator effects. The aim is to find approaches to help those families with children and adolescents affected by a chronic condition." + }, + "resource_identifier": "DRKS00027974", + "resource_keywords": [ + { + "resource_keywords_label": "family" + }, + { + "resource_keywords_label": "Coronavirus Disease 2019 (COVID-19)" + }, + { + "resource_keywords_label": "mental health" + }, + { + "resource_keywords_label": "longitudinal study" + }, + { + "resource_keywords_label": "obesity" + }, + { + "resource_keywords_label": "rheumatic diseases" + }, + { + "resource_keywords_label": "health care" + }, + { + "resource_keywords_label": "medical care" + }, + { + "resource_keywords_label": "disease management" + }, + { + "resource_keywords_label": "children and adolescents" + }, + { + "resource_keywords_label": "chronic conditions" + }, + { + "resource_keywords_label": "well-being" + }, + { + "resource_keywords_label": "diabetes" + }, + { + "resource_keywords_label": "psychosocial strain" + } + ], + "resource_titles": [ + { + "language": "EN (English)", + "text": "A prospective analysis of the long-term impact of the COVID-19 pandemic on well-being and health care among children with a high-risk chronic condition and their families" + } + ], + "resource_web_page": "https://www.kick-covid.de", + "roles": [ + { + "role_affiliations": [ + { + "role_affiliation_address": "Kennedyallee 40, 53175 Bonn, Germany", + "role_affiliation_name": "Deutsche Forschungsgemeinschaft", + "role_affiliation_web_page": "https://www.dfg.de" + } + ], + "role_name_organisational_group": { + "role_name_organisational_group_name": "Deutsche Forschungsgemeinschaft", + "role_name_organisational_group_type": "Funder (public)" + }, + "role_name_type": "Organisational" + }, + { + "role_affiliations": [ + { + "role_affiliation_address": "Karl-Liebknecht-Str. 24/25, 14476 Potsdam OT Golm, Germany", + "role_affiliation_name": "Lehrstuhl für Beratungspsychologie\nDepartment Psychologie\nUniversität Potsdam" + } + ], + "role_email": "warschb@uni-potsdam.de", + "role_name_personal": { + "role_name_personal_family_name": "Warschburger", + "role_name_personal_given_name": "Petra", + "role_name_personal_title": "Prof. Dr.", + "role_name_personal_type": "Sponsor (primary)" + }, + "role_name_type": "Personal", + "role_phone": "0331/ 977-2988" + }, + { + "role_affiliations": [ + { + "role_affiliation_address": "Karl-Liebknecht-Str. 24/25, 14476 Potsdam OT Golm, Germany", + "role_affiliation_name": "Lehrstuhl für Beratungspsychologie\nDepartment Psychologie\nUniversität Potsdam", + "role_affiliation_web_page": "http://www.psych.uni-potsdam.de/counseling/index-d.html" + } + ], + "role_email": "warschb@uni-potsdam.de", + "role_name_personal": { + "role_name_personal_family_name": "Warschburger", + "role_name_personal_given_name": "Petra", + "role_name_personal_title": "Prof. Dr.", + "role_name_personal_type": "Contact" + }, + "role_name_type": "Personal", + "role_phone": "0331/ 977-2988" + }, + { + "role_affiliations": [ + { + "role_affiliation_address": "Karl-Liebknecht-Str. 24-25, 14476 Potsdamm, Germany", + "role_affiliation_name": "Lehrstuhl für BeratungspsychologieDepartment PsychologieUniversität Potsdam" + } + ], + "role_email": "goeldel@uni-potsdam.de", + "role_name_personal": { + "role_name_personal_family_name": "Göldel", + "role_name_personal_given_name": "Julia", + "role_name_personal_title": "Ms.", + "role_name_personal_type": "Contact" + }, + "role_name_type": "Personal", + "role_phone": "0049 331 977 5387" + } + ], + "study_design": { + "study_arms_groups": [ + { + "study_arm_group_description": "Children and adolescents with chronic conditions as well as their parents/ guardians are taking part in a questionnaire-based survey at two measurement points one year apart.\nThe first step of the survey takes place as part of the routine health check-ups in specialist care. Interruptions in consultations (self-construction), the therapeutic intensity (self-construction) and the child's mental health (PHQ-9, GAD-7) are recorded. In addition, the child's media consumption (Lampert, Sygusch & Schlack, 2007), the effects of the corona pandemic on family and everyday life (self-construction), the experience of stress (self-construction), risk perception (self-construction) and well-being (WHO-5 Well-being Index). For children under the age of 12, parents/guardians are asked to provide their child's assessment.\nThe children and adolescents from the age of 9 and the parent/guardian are then invited to a further online study.\nThe questionnaire for parents includes the following constructs: corona-specific burden (according to Calvano et al. 2021, modified), well-being (WHO-5; SAM; De Jong-Gierveld loneliness scale) together with the quality of life (SF-8; SF-36 fatigue scale; CHQ; FLQ), psychosocial adjustment (PHQ-4; ADNM8; PSS-4), also referred to ones role as parent (CGSQ-SF11; BPBS), resources (ASKU; IE-4; RS-11; OSLO), parental coping with the child's illness (CHIP-D), parenting behavior (APQ-9; according to Clemens et al.), child’s problem behavior (SDQ), its resources (self-construction) and its corona-specific coping (according to COSMO). In addition, social desirability (SEA-K), socioeconomic status (MacArthur scale; Winkler index) and some demographic information are recorded.\nThe questionnaire for children and adolescents includes the corona-specific burden (based on Calvano et al., 2021), well-being (SAM; KIDCSREEN-27; De-Jong-Gierveld Loneliness Scale), the parent-child relationship (EBF-KJ), resources (FRKJ-8-16; Benefit-finding-Scale), coping (CODI), problem behavior (SDQ) and social integration.", + "study_arm_group_label": "Arm 1" + } + ], + "study_centers": "Multicentric", + "study_centers_number": 1, + "study_conditions": [ + { + "study_conditions_classification": "ICD-10", + "study_conditions_label": "Type 1 diabetes mellitus" + }, + { + "study_conditions_classification": "ICD-10", + "study_conditions_label": "Type 2 diabetes mellitus" + }, + { + "study_conditions_classification": "ICD-10", + "study_conditions_label": "Malnutrition-related diabetes mellitus" + }, + { + "study_conditions_classification": "ICD-10", + "study_conditions_label": "Other specified diabetes mellitus" + }, + { + "study_conditions_classification": "ICD-10", + "study_conditions_label": "Unspecified diabetes mellitus" + }, + { + "study_conditions_classification": "ICD-10", + "study_conditions_label": "Obesity" + }, + { + "study_conditions_classification": "ICD-10", + "study_conditions_label": "Direct infections of joint in infectious and parasitic diseases classified elsewhere" + }, + { + "study_conditions_classification": "ICD-10", + "study_conditions_label": "Postinfective and reactive arthropathies in diseases classified elsewhere" + }, + { + "study_conditions_classification": "ICD-10", + "study_conditions_label": "Juvenile arthritis" + }, + { + "study_conditions_classification": "ICD-10", + "study_conditions_label": "Juvenile arthritis in diseases classified elsewhere" + }, + { + "study_conditions_classification": "ICD-10", + "study_conditions_label": "Other specific arthropathies" + }, + { + "study_conditions_classification": "ICD-10", + "study_conditions_label": "Polyarteritis nodosa and related conditions" + }, + { + "study_conditions_classification": "ICD-10", + "study_conditions_label": "Other necrotizing vasculopathies" + }, + { + "study_conditions_classification": "ICD-10", + "study_conditions_label": "Systemic lupus erythematosus" + }, + { + "study_conditions_classification": "ICD-10", + "study_conditions_label": "Dermatopolymyositis" + }, + { + "study_conditions_classification": "ICD-10", + "study_conditions_label": "Systemic sclerosis" + }, + { + "study_conditions_classification": "ICD-10", + "study_conditions_label": "Other systemic involvement of connective tissue" + }, + { + "study_conditions_classification": "ICD-10", + "study_conditions_label": "Enthesopathies of lower limb, excluding foot" + }, + { + "study_conditions_classification": "ICD-10", + "study_conditions_label": "Other soft tissue disorders, not elsewhere classified" + }, + { + "study_conditions_classification": "ICD-10", + "study_conditions_label": "Osteomyelitis" + }, + { + "study_conditions_classification": "ICD-10", + "study_conditions_label": "Other localized connective tissue disorders" + }, + { + "study_conditions_classification": "ICD-10", + "study_conditions_label": "Purpura and other haemorrhagic conditions" + }, + { + "study_conditions_classification": "ICD-10", + "study_conditions_label": "Sarcoidosis" + }, + { + "study_conditions_classification": "ICD-10", + "study_conditions_label": "Amyloidosis" + } + ], + "study_countries": [ + "Germany" + ], + "study_data_sharing_plan": { + "study_data_sharing_plan_description": "The following documents will be provided:\n• Study protocol\n• Scale manual\n\nPeriod:\n• Fully anonymized data will be made available after a moratorium of five years.\n\nProcedure:\n• A reasonable request must be made.\n", + "study_data_sharing_plan_generally": "Yes, there is a plan to make data available" + }, + "study_design_non_interventional": {}, + "study_eligibility_criteria": { + "study_eligibility_age_max": { + "number": 18, + "time_unit": "Years" + }, + "study_eligibility_age_min": { + "number": 9, + "time_unit": "Years" + }, + "study_eligibility_exclusion_criteria": "insufficient knowledge of the German language (written and spoken)", + "study_eligibility_genders": [ + "Male", + "Female", + "Diverse" + ], + "study_eligibility_inclusion_criteria": "Subjects, who have already consented to participate in one of the three patient registries (obesity, rheumatic diseases, diabetes) and to the processing of these data, and their parents/guardians." + }, + "study_ethics_committee_approval": "Request for approval submitted, approval granted", + "study_groups_of_diseases": { + "study_groups_of_diseases_generally": [ + "Unknown" + ] + }, + "study_outcomes": [ + { + "study_outcome_description": "Children’s physical and mental well-being (WHO-5; KIDCREEN; SAM), parents’ and children’s corona-specific burden (Calvano et al.)\n- T1 and T2", + "study_outcome_title": "Primary Outcome", + "study_outcome_type": "Primary" + }, + { + "study_outcome_description": "- Children’s mental well-being (PHQ-9; GAD-7; De-Jong-Gierveld-Einsamkeitsskala)\n- Parents‘ satisfaction with life (SF-8, CHQ, FLQ) and mental well-being (PHQ-4; ADNM8, PSS-4; CGSQ-SF11; BPBS)\n-T1 and T2", + "study_outcome_title": "Secondary Outcome", + "study_outcome_type": "Secondary" + } + ], + "study_primary_design": "Non-interventional", + "study_primary_purpose": "Supportive care", + "study_region": "International", + "study_start_date": "2022-02-01", + "study_status": "At the planning stage", + "study_subject": "Person", + "study_target_sample_size": 300, + "study_type": { + "study_type_non_interventional": [ + "Other" + ] + } + } + }, + "versions": [ + "1.0" + ] } body = { @@ -24,7 +346,7 @@ # Check the response if response.status_code == 200: print("Request was successful.") - print("Response:", response.json()) + print("Response:", response.json()['tasks']) else: print("Request failed with status code:", response.status_code) print(response.text)