diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 3497ac5..9c04dc5 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -31,15 +31,24 @@ jobs: mkdir -p gh-pages touch gh-pages/.nojekyll + function branch_exists { + git show-ref refs/heads/$1 > /dev/null 2>&1 + } + function build_docs { - # The function will checkout a branch and build the Javadoc & documentation - # into provided documentation directory. + # The function will checkout a branch and build the Sphinx docs + # into the provided documentation directory. BRANCH=${1} DOCDIR=${2} - - git checkout ${BRANCH} - git fetch - git pull + + if branch_exists ${BRANCH}; then + git checkout ${BRANCH} + git fetch + git pull + else + echo "Branch ${BRANCH} does not exist. Skipping..." + return + fi ## Init the target folder. # We will put all site documentation there. @@ -57,12 +66,11 @@ jobs: cd .. } - # We store the docs for `main` in `stable` dir + # We store the docs for `main` in `stable` dir, if it exists build_docs main stable - # We store the docs for `development` in `latest` dir + # We store the docs for `develop` in `latest` dir build_docs develop latest - - name: Deploy documentation if: ${{ github.event_name == 'push' }} uses: JamesIves/github-pages-deploy-action@v4.4.1 diff --git a/README.md b/README.md index 6168f47..6a62ac9 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ An ontology-based Rare Disease Common Data Model (RD CDM) to enable international registry use, HL7 FHIR, and GA4GH Phenopackets. -[![Python CI](https://github.com/BIH-CEI/rd-cdm/actions/workflows/python_ci.yml/badge.svg)](https://github.com/{OWNER}/{REPO}/actions/workflows/python_ci.yml) +[![Python CI](https://github.com/BIH-CEI/rd-cdm/actions/workflows/python_ci.yml/badge.svg)](https://github.com/BIH-CEI/rd-cdm/actions/workflows/python_ci.yml) [![Documentation Status](https://readthedocs.org/projects/rd-cdm/badge/?version=latest)](https://rd-cdm.readthedocs.io/en/latest/?badge=latest) diff --git a/docs/resources/resources_file.rst b/docs/resources/resourscs_file.rst similarity index 100% rename from docs/resources/resources_file.rst rename to docs/resources/resourscs_file.rst diff --git a/res/v2_0_0/rd_cdm_codesystems_v2_0_0.json b/res/v2_0_0/rd_cdm_codesystems_v2_0_0.json index 4a52acf..20d294f 100644 --- a/res/v2_0_0/rd_cdm_codesystems_v2_0_0.json +++ b/res/v2_0_0/rd_cdm_codesystems_v2_0_0.json @@ -22,6 +22,28 @@ "url": "http://www.sequenceontology.org/", "synonyms": [] }, + { + "codeSystemName": "International Classification of Diseases, Ninth Revision", + "namespace_prefix": "ICD9", + "version": "unknown", + "url": "https://www.cdc.gov/nchs/icd/icd9.htm", + "synonyms": [ + "ICD-9", + "ICD_9" + ] + }, + { + "codeSystemName": "International Classification of Diseases, Tenth Revision, German Modification", + "namespace_prefix": "ICD10GM", + "version": "unknown", + "url": "https://www.bfarm.de/EN/Code-systems/Classifications/ICD/ICD-10-GM/_node.html", + "synonyms": [ + "ICD10-GM", + "ICD-10-GM", + "ICD10_GM", + "ICD_10_GM" + ] + }, { "codeSystemName": "International Classification of Diseases, Tenth Revision, Clinical Modification", "namespace_prefix": "ICD10CM", @@ -75,7 +97,7 @@ "synonyms": [] }, { - "codeSystemName": "International Classification of Functioning, Disability and Health (ICF)", + "codeSystemName": "International Classification of Functioning, Disability and Health", "namespace_prefix": "ICF", "version": "1.0.2", "url": "https://www.who.int/classifications/icf/en/", diff --git a/res/v2_0_0/rd_cdm_data_elements_v2_0_0.json b/res/v2_0_0/rd_cdm_data_elements_v2_0_0.json index cd24175..70a99b3 100644 --- a/res/v2_0_0/rd_cdm_data_elements_v2_0_0.json +++ b/res/v2_0_0/rd_cdm_data_elements_v2_0_0.json @@ -12,10 +12,10 @@ "n/a" ], "valueSet": null, - "fhirExpression_v4.0.1": "Patient.identifier.value", - "recommendedVS_fhir": null, - "phenopacketSchemaElement_v2.0": "Individual.id", - "recommendedVS_phenopacket": null, + "fhirExpression_v4_0_1": "Patient.identifier.value", + "recommendedDataSpec_fhir": "n/a", + "phenopacketSchemaElement_v2_0": "Individual.id", + "recommendedDataSpec_phenopackets": "string", "description": "The (local) patient-related identification code." }, { @@ -26,14 +26,13 @@ "elementCodeSystem": "SNOMED", "dataType": "Date", "dataSpecification": [ - "YYYY-MM-DD", - "ISO 8601" + "YYYY-MM-DD" ], "valueSet": null, - "fhirExpression_v4.0.1": "Encounter.period.start", - "recommendedVS_fhir": null, - "phenopacketSchemaElement_v2.0": "Individual.time_at_last_encounter", - "recommendedVS_phenopacket": null, + "fhirExpression_v4_0_1": "Encounter.period.start", + "recommendedDataSpec_fhir": "n/a", + "phenopacketSchemaElement_v2_0": "Individual.time_at_last_encounter", + "recommendedDataSpec_phenopackets": "TimeElement", "description": "The date of admission or data capture of the individual." }, { @@ -49,10 +48,10 @@ "YYYY-MM-DD" ], "valueSet": null, - "fhirExpression_v4.0.1": "Patient.birthDate", - "recommendedVS_fhir": null, - "phenopacketSchemaElement_v2.0": "Individual.date_of_birth", - "recommendedVS_phenopacket": null, + "fhirExpression_v4_0_1": "Patient.birthDate", + "recommendedDataSpec_fhir": "n/a", + "phenopacketSchemaElement_v2_0": "Individual.date_of_birth", + "recommendedDataSpec_phenopackets": "TimeElement", "description": "The individual's date of birth." }, { @@ -65,20 +64,235 @@ "dataSpecification": [ "VSe / VSc" ], - "valueSet": { - "valueSetName": "Sex at Birth Value Set v2.0.0", - "valueSetOrigin": "RD CDM v2.0.0", - "valueSetLink": "https://github.com/BIH-CEI/rd-cdm", - "display": "Sex at Birth", - "valueSetCode": "281053000", - "valueSetCodeSystem": "SNOMED", - "valueSetChoices": [] - }, - "fhirExpression_v4.0.1": "Patient.extension:individual-recordedSexOrGender", - "recommendedVS_fhir": "Recorded Sex Or Gender Type", - "phenopacketSchemaElement_v2.0": "Individual.sex", - "recommendedVS_phenopacket": "Sex", + "valueSet": "Sex at Birth Value Set v2.0.0", + "fhirExpression_v4_0_1": "Patient.extension:individual-recordedSexOrGender", + "recommendedDataSpec_fhir": "Recorded Sex Or Gender Type", + "phenopacketSchemaElement_v2_0": "Individual.sex", + "recommendedDataSpec_phenopackets": "Sex", "description": "The individual's sex that was assigned at birth." + }, + { + "ordinal": "2.3", + "section": "2. Personal Information", + "elementName": "Karyotypic Sex", + "elementCode": "1296886006", + "elementCodeSystem": "SNOMED", + "dataType": "Code", + "dataSpecification": [ + "VSc" + ], + "valueSet": "Karyotypic Sex Value Set v2.0.0", + "fhirExpression_v4_0_1": "Observation.value", + "recommendedDataSpec_fhir": "n/a", + "phenopacketSchemaElement_v2_0": "Individual.karyotypic_sex", + "recommendedDataSpec_phenopackets": "Karyotypic Sex", + "description": "The chromosomal sex of an individual." + }, + { + "ordinal": "2.4", + "section": "2. Personal Information", + "elementName": "Gender Identity", + "elementCode": "263495000", + "elementCodeSystem": "SNOMED", + "dataType": "Code", + "dataSpecification": [ + "VSe / VSc" + ], + "valueSet": "Gender Identity Value Set v2.0.0", + "fhirExpression_v4_0_1": "Patient.extension:individual-genderIdentity", + "recommendedDataSpec_fhir": "Gender Identity", + "phenopacketSchemaElement_v2_0": "Individual.gender", + "recommendedDataSpec_phenopackets": "OntologyClass", + "description": "The self-assigned gender of the individual." + }, + { + "ordinal": "2.5", + "section": "2. Personal Information", + "elementName": "Country of Birth", + "elementCode": "370159000", + "elementCodeSystem": "SNOMED", + "dataType": "Code", + "dataSpecification": [ + "VS" + ], + "valueSet": null, + "fhirExpression_v4_0_1": "Patient.extension:patient-birthPlace", + "recommendedDataSpec_fhir": "DataType: Address", + "phenopacketSchemaElement_v2_0": "n/a", + "recommendedDataSpec_phenopackets": "n/a", + "description": "The individual's country of birth." + }, + { + "ordinal": "3.1", + "section": "3. Patient Status", + "elementName": "Vital Status", + "elementCode": "278844005", + "elementCodeSystem": "SNOMED", + "dataType": "Code", + "dataSpecification": [ + "VSe / VSc" + ], + "valueSet": "Vital Status Value Set v2.0.0", + "fhirExpression_v4_0_1": "Patient.deceased.deceasedBoolean|Observation.value", + "recommendedDataSpec_fhir": "Boolean|Code", + "phenopacketSchemaElement_v2_0": "Individual.VitalStatus.status", + "recommendedDataSpec_phenopackets": "Value Set: Status", + "description": "The individual\u2019s general clinical status or vital status." + }, + { + "ordinal": "3.2", + "section": "3. Patient Status", + "elementName": "Time of Death", + "elementCode": "398299004", + "elementCodeSystem": "SNOMED", + "dataType": "Date", + "dataSpecification": [ + "YYYY", + "YYYY-MM", + "YYYY-MM-DD" + ], + "valueSet": null, + "fhirExpression_v4_0_1": "Patient.deceasedDateTime", + "recommendedDataSpec_fhir": "DateTime", + "phenopacketSchemaElement_v2_0": "Individual.VitalStatus.time_of_death", + "recommendedDataSpec_phenopackets": "TimeElement", + "description": "If deceased, the individual\u2019s date of death." + }, + { + "ordinal": "3.3", + "section": "3. Patient Status", + "elementName": "Cause of Death", + "elementCode": "184305005", + "elementCodeSystem": "SNOMED", + "dataType": "Code", + "dataSpecification": [ + "ICD-10CM" + ], + "valueSet": null, + "fhirExpression_v4_0_1": "Observation.value.coding.code", + "recommendedDataSpec_fhir": "Code|CodeableConcept", + "phenopacketSchemaElement_v2_0": "Individual.VitalStatus.cause_of_death", + "recommendedDataSpec_phenopackets": "OntologyClass", + "description": "If deceased, the individual\u2019s primary cause of death." + }, + { + "ordinal": "3.4", + "section": "3. Patient Status", + "elementName": "Age Category", + "elementCode": "105727008", + "elementCodeSystem": "SNOMED", + "dataType": "Code", + "dataSpecification": [ + "VSe" + ], + "valueSet": "Age Category Value Set v2.0.0", + "fhirExpression_v4_0_1": "Observation.value.coding.code", + "recommendedDataSpec_fhir": "CodableConcept", + "phenopacketSchemaElement_v2_0": "Individual.time_at_last_encounter.ontology_class", + "recommendedDataSpec_phenopackets": "TimeElement", + "description": "The individual's age category at the time of data capture." + }, + { + "ordinal": "3.5", + "section": "3. Patient Status", + "elementName": "Length of Gestation at Birth [weeks+days]", + "elementCode": "412726003", + "elementCodeSystem": "SNOMED", + "dataType": "String", + "dataSpecification": [ + "XX+X" + ], + "valueSet": null, + "fhirExpression_v4_0_1": "Observation.component:weeks.valueQuantity|Observation.component:days.valueQuantity", + "recommendedDataSpec_fhir": "Quantity", + "phenopacketSchemaElement_v2_0": "n/a", + "recommendedDataSpec_phenopackets": "n/a", + "description": "The duration of the pregnancy in weeks and days, formatted as XX+X (weeks+days)." + }, + { + "ordinal": "3.6", + "section": "3. Patient Status", + "elementName": "Undiagnosed RD Case", + "elementCode": "723663001", + "elementCodeSystem": "SNOMED", + "dataType": "Code", + "dataSpecification": [ + "VSe" + ], + "valueSet": "Undiagnosed RD Case Value Set v2.0.0", + "fhirExpression_v4_0_1": "(Condition.code)", + "recommendedDataSpec_fhir": "Code(e.g. ORDO:616874 - Rare disorder without a determined diagnosis after full investigation)", + "phenopacketSchemaElement_v2_0": "(Disease.term)", + "recommendedDataSpec_phenopackets": "(OntologyClass (e.g. ORDO:616874 - Rare disorder without a determined diagnosis after full investigation))", + "description": "Identifies cases where an RD diagnosis has not been established." + }, + { + "ordinal": "4.1", + "section": "4. Care Pathway", + "elementName": "Encounter Start", + "elementCode": "encounter.period.start", + "elementCodeSystem": "HL7FHIR", + "dataType": "Date", + "dataSpecification": [ + "YYYY-MM-DD" + ], + "valueSet": null, + "fhirExpression_v4_0_1": "Encounter.period.start", + "recommendedDataSpec_fhir": "DateTime", + "phenopacketSchemaElement_v2_0": "n/a", + "recommendedDataSpec_phenopackets": "n/a", + "description": "The beginning of an encounter of the individual." + }, + { + "ordinal": "4.2", + "section": "4. Care Pathway", + "elementName": "Encounter End", + "elementCode": "encounter.period.end", + "elementCodeSystem": "HL7FHIR", + "dataType": "Date", + "dataSpecification": [ + "YYYY-MM-DD" + ], + "valueSet": null, + "fhirExpression_v4_0_1": "Encounter.period.end", + "recommendedDataSpec_fhir": "DateTime", + "phenopacketSchemaElement_v2_0": "n/a", + "recommendedDataSpec_phenopackets": "n/a", + "description": "The end of an encounter of the individual." + }, + { + "ordinal": "4.3", + "section": "4. Care Pathway", + "elementName": "Encounter Status", + "elementCode": "305058001", + "elementCodeSystem": "SNOMED", + "dataType": "Code", + "dataSpecification": [ + "VSe / VSc" + ], + "valueSet": "Encounter Status Value Set v2.0.0", + "fhirExpression_v4_0_1": "Encounter.status", + "recommendedDataSpec_fhir": "ValueSet: EncounterStatus", + "phenopacketSchemaElement_v2_0": "n/a", + "recommendedDataSpec_phenopackets": "n/a", + "description": "The status of an encounter of the individual at the time of data capture." + }, + { + "ordinal": "4.4", + "section": "4. Care Pathway", + "elementName": "Encounter Class", + "elementCode": "encounter.class", + "elementCodeSystem": "HL7FHIR", + "dataType": "Code", + "dataSpecification": [ + "VSe / VSc" + ], + "valueSet": "Encounter Class Value Set v2.0.0", + "fhirExpression_v4_0_1": "Encounter.class", + "recommendedDataSpec_fhir": "ValueSet: EncounterClass", + "phenopacketSchemaElement_v2_0": "n/a", + "recommendedDataSpec_phenopackets": "n/a", + "description": "The class of an encounter of the individual at the time of data capture." } ] } \ No newline at end of file diff --git a/res/v2_0_0/rd_cdm_v2_0_0.json b/res/v2_0_0/rd_cdm_v2_0_0.json index 45e0fe9..83f1783 100644 --- a/res/v2_0_0/rd_cdm_v2_0_0.json +++ b/res/v2_0_0/rd_cdm_v2_0_0.json @@ -5,7 +5,7 @@ "description": "The ontology-based Rare Disease Common Data Model (RD CDM) to enable international registry use, HL7 FHIR, and GA4GH Phenopackets.", "metadata": { "author": "Author Name", - "creationDate": "2024-01-01" + "creationDate": "2024-09-28" }, "codeSystems": [ { @@ -29,6 +29,28 @@ "url": "http://www.sequenceontology.org/", "synonyms": [] }, + { + "codeSystemName": "International Classification of Diseases, Ninth Revision", + "namespace_prefix": "ICD9", + "version": "unknown", + "url": "https://www.cdc.gov/nchs/icd/icd9.htm", + "synonyms": [ + "ICD-9", + "ICD_9" + ] + }, + { + "codeSystemName": "International Classification of Diseases, Tenth Revision, German Modification", + "namespace_prefix": "ICD10GM", + "version": "unknown", + "url": "https://www.bfarm.de/EN/Code-systems/Classifications/ICD/ICD-10-GM/_node.html", + "synonyms": [ + "ICD10-GM", + "ICD-10-GM", + "ICD10_GM", + "ICD_10_GM" + ] + }, { "codeSystemName": "International Classification of Diseases, Tenth Revision, Clinical Modification", "namespace_prefix": "ICD10CM", @@ -82,7 +104,7 @@ "synonyms": [] }, { - "codeSystemName": "International Classification of Functioning, Disability and Health (ICF)", + "codeSystemName": "International Classification of Functioning, Disability and Health", "namespace_prefix": "ICF", "version": "1.0.2", "url": "https://www.who.int/classifications/icf/en/", @@ -168,10 +190,10 @@ "n/a" ], "valueSet": null, - "fhirExpression_v4.0.1": "Patient.identifier.value", - "recommendedVS_fhir": null, - "phenopacketSchemaElement_v2.0": "Individual.id", - "recommendedVS_phenopacket": null, + "fhirExpression_v4_0_1": "Patient.identifier.value", + "recommendedDataSpec_fhir": "n/a", + "phenopacketSchemaElement_v2_0": "Individual.id", + "recommendedDataSpec_phenopackets": "string", "description": "The (local) patient-related identification code." }, { @@ -182,14 +204,13 @@ "elementCodeSystem": "SNOMED", "dataType": "Date", "dataSpecification": [ - "YYYY-MM-DD", - "ISO 8601" + "YYYY-MM-DD" ], "valueSet": null, - "fhirExpression_v4.0.1": "Encounter.period.start", - "recommendedVS_fhir": null, - "phenopacketSchemaElement_v2.0": "Individual.time_at_last_encounter", - "recommendedVS_phenopacket": null, + "fhirExpression_v4_0_1": "Encounter.period.start", + "recommendedDataSpec_fhir": "n/a", + "phenopacketSchemaElement_v2_0": "Individual.time_at_last_encounter", + "recommendedDataSpec_phenopackets": "TimeElement", "description": "The date of admission or data capture of the individual." }, { @@ -205,10 +226,10 @@ "YYYY-MM-DD" ], "valueSet": null, - "fhirExpression_v4.0.1": "Patient.birthDate", - "recommendedVS_fhir": null, - "phenopacketSchemaElement_v2.0": "Individual.date_of_birth", - "recommendedVS_phenopacket": null, + "fhirExpression_v4_0_1": "Patient.birthDate", + "recommendedDataSpec_fhir": "n/a", + "phenopacketSchemaElement_v2_0": "Individual.date_of_birth", + "recommendedDataSpec_phenopackets": "TimeElement", "description": "The individual's date of birth." }, { @@ -221,20 +242,235 @@ "dataSpecification": [ "VSe / VSc" ], - "valueSet": { - "valueSetName": "Sex at Birth Value Set v2.0.0", - "valueSetOrigin": "RD CDM v2.0.0", - "valueSetLink": "https://github.com/BIH-CEI/rd-cdm", - "display": "Sex at Birth", - "valueSetCode": "281053000", - "valueSetCodeSystem": "SNOMED", - "valueSetChoices": [] - }, - "fhirExpression_v4.0.1": "Patient.extension:individual-recordedSexOrGender", - "recommendedVS_fhir": "Recorded Sex Or Gender Type", - "phenopacketSchemaElement_v2.0": "Individual.sex", - "recommendedVS_phenopacket": "Sex", + "valueSet": "Sex at Birth Value Set v2.0.0", + "fhirExpression_v4_0_1": "Patient.extension:individual-recordedSexOrGender", + "recommendedDataSpec_fhir": "Recorded Sex Or Gender Type", + "phenopacketSchemaElement_v2_0": "Individual.sex", + "recommendedDataSpec_phenopackets": "Sex", "description": "The individual's sex that was assigned at birth." + }, + { + "ordinal": "2.3", + "section": "2. Personal Information", + "elementName": "Karyotypic Sex", + "elementCode": "1296886006", + "elementCodeSystem": "SNOMED", + "dataType": "Code", + "dataSpecification": [ + "VSc" + ], + "valueSet": "Karyotypic Sex Value Set v2.0.0", + "fhirExpression_v4_0_1": "Observation.value", + "recommendedDataSpec_fhir": "n/a", + "phenopacketSchemaElement_v2_0": "Individual.karyotypic_sex", + "recommendedDataSpec_phenopackets": "Karyotypic Sex", + "description": "The chromosomal sex of an individual." + }, + { + "ordinal": "2.4", + "section": "2. Personal Information", + "elementName": "Gender Identity", + "elementCode": "263495000", + "elementCodeSystem": "SNOMED", + "dataType": "Code", + "dataSpecification": [ + "VSe / VSc" + ], + "valueSet": "Gender Identity Value Set v2.0.0", + "fhirExpression_v4_0_1": "Patient.extension:individual-genderIdentity", + "recommendedDataSpec_fhir": "Gender Identity", + "phenopacketSchemaElement_v2_0": "Individual.gender", + "recommendedDataSpec_phenopackets": "OntologyClass", + "description": "The self-assigned gender of the individual." + }, + { + "ordinal": "2.5", + "section": "2. Personal Information", + "elementName": "Country of Birth", + "elementCode": "370159000", + "elementCodeSystem": "SNOMED", + "dataType": "Code", + "dataSpecification": [ + "VS" + ], + "valueSet": null, + "fhirExpression_v4_0_1": "Patient.extension:patient-birthPlace", + "recommendedDataSpec_fhir": "DataType: Address", + "phenopacketSchemaElement_v2_0": "n/a", + "recommendedDataSpec_phenopackets": "n/a", + "description": "The individual's country of birth." + }, + { + "ordinal": "3.1", + "section": "3. Patient Status", + "elementName": "Vital Status", + "elementCode": "278844005", + "elementCodeSystem": "SNOMED", + "dataType": "Code", + "dataSpecification": [ + "VSe / VSc" + ], + "valueSet": "Vital Status Value Set v2.0.0", + "fhirExpression_v4_0_1": "Patient.deceased.deceasedBoolean|Observation.value", + "recommendedDataSpec_fhir": "Boolean|Code", + "phenopacketSchemaElement_v2_0": "Individual.VitalStatus.status", + "recommendedDataSpec_phenopackets": "Value Set: Status", + "description": "The individual\u2019s general clinical status or vital status." + }, + { + "ordinal": "3.2", + "section": "3. Patient Status", + "elementName": "Time of Death", + "elementCode": "398299004", + "elementCodeSystem": "SNOMED", + "dataType": "Date", + "dataSpecification": [ + "YYYY", + "YYYY-MM", + "YYYY-MM-DD" + ], + "valueSet": null, + "fhirExpression_v4_0_1": "Patient.deceasedDateTime", + "recommendedDataSpec_fhir": "DateTime", + "phenopacketSchemaElement_v2_0": "Individual.VitalStatus.time_of_death", + "recommendedDataSpec_phenopackets": "TimeElement", + "description": "If deceased, the individual\u2019s date of death." + }, + { + "ordinal": "3.3", + "section": "3. Patient Status", + "elementName": "Cause of Death", + "elementCode": "184305005", + "elementCodeSystem": "SNOMED", + "dataType": "Code", + "dataSpecification": [ + "ICD-10CM" + ], + "valueSet": null, + "fhirExpression_v4_0_1": "Observation.value.coding.code", + "recommendedDataSpec_fhir": "Code|CodeableConcept", + "phenopacketSchemaElement_v2_0": "Individual.VitalStatus.cause_of_death", + "recommendedDataSpec_phenopackets": "OntologyClass", + "description": "If deceased, the individual\u2019s primary cause of death." + }, + { + "ordinal": "3.4", + "section": "3. Patient Status", + "elementName": "Age Category", + "elementCode": "105727008", + "elementCodeSystem": "SNOMED", + "dataType": "Code", + "dataSpecification": [ + "VSe" + ], + "valueSet": "Age Category Value Set v2.0.0", + "fhirExpression_v4_0_1": "Observation.value.coding.code", + "recommendedDataSpec_fhir": "CodableConcept", + "phenopacketSchemaElement_v2_0": "Individual.time_at_last_encounter.ontology_class", + "recommendedDataSpec_phenopackets": "TimeElement", + "description": "The individual's age category at the time of data capture." + }, + { + "ordinal": "3.5", + "section": "3. Patient Status", + "elementName": "Length of Gestation at Birth [weeks+days]", + "elementCode": "412726003", + "elementCodeSystem": "SNOMED", + "dataType": "String", + "dataSpecification": [ + "XX+X" + ], + "valueSet": null, + "fhirExpression_v4_0_1": "Observation.component:weeks.valueQuantity|Observation.component:days.valueQuantity", + "recommendedDataSpec_fhir": "Quantity", + "phenopacketSchemaElement_v2_0": "n/a", + "recommendedDataSpec_phenopackets": "n/a", + "description": "The duration of the pregnancy in weeks and days, formatted as XX+X (weeks+days)." + }, + { + "ordinal": "3.6", + "section": "3. Patient Status", + "elementName": "Undiagnosed RD Case", + "elementCode": "723663001", + "elementCodeSystem": "SNOMED", + "dataType": "Code", + "dataSpecification": [ + "VSe" + ], + "valueSet": "Undiagnosed RD Case Value Set v2.0.0", + "fhirExpression_v4_0_1": "(Condition.code)", + "recommendedDataSpec_fhir": "Code(e.g. ORDO:616874 - Rare disorder without a determined diagnosis after full investigation)", + "phenopacketSchemaElement_v2_0": "(Disease.term)", + "recommendedDataSpec_phenopackets": "(OntologyClass (e.g. ORDO:616874 - Rare disorder without a determined diagnosis after full investigation))", + "description": "Identifies cases where an RD diagnosis has not been established." + }, + { + "ordinal": "4.1", + "section": "4. Care Pathway", + "elementName": "Encounter Start", + "elementCode": "encounter.period.start", + "elementCodeSystem": "HL7FHIR", + "dataType": "Date", + "dataSpecification": [ + "YYYY-MM-DD" + ], + "valueSet": null, + "fhirExpression_v4_0_1": "Encounter.period.start", + "recommendedDataSpec_fhir": "DateTime", + "phenopacketSchemaElement_v2_0": "n/a", + "recommendedDataSpec_phenopackets": "n/a", + "description": "The beginning of an encounter of the individual." + }, + { + "ordinal": "4.2", + "section": "4. Care Pathway", + "elementName": "Encounter End", + "elementCode": "encounter.period.end", + "elementCodeSystem": "HL7FHIR", + "dataType": "Date", + "dataSpecification": [ + "YYYY-MM-DD" + ], + "valueSet": null, + "fhirExpression_v4_0_1": "Encounter.period.end", + "recommendedDataSpec_fhir": "DateTime", + "phenopacketSchemaElement_v2_0": "n/a", + "recommendedDataSpec_phenopackets": "n/a", + "description": "The end of an encounter of the individual." + }, + { + "ordinal": "4.3", + "section": "4. Care Pathway", + "elementName": "Encounter Status", + "elementCode": "305058001", + "elementCodeSystem": "SNOMED", + "dataType": "Code", + "dataSpecification": [ + "VSe / VSc" + ], + "valueSet": "Encounter Status Value Set v2.0.0", + "fhirExpression_v4_0_1": "Encounter.status", + "recommendedDataSpec_fhir": "ValueSet: EncounterStatus", + "phenopacketSchemaElement_v2_0": "n/a", + "recommendedDataSpec_phenopackets": "n/a", + "description": "The status of an encounter of the individual at the time of data capture." + }, + { + "ordinal": "4.4", + "section": "4. Care Pathway", + "elementName": "Encounter Class", + "elementCode": "encounter.class", + "elementCodeSystem": "HL7FHIR", + "dataType": "Code", + "dataSpecification": [ + "VSe / VSc" + ], + "valueSet": "Encounter Class Value Set v2.0.0", + "fhirExpression_v4_0_1": "Encounter.class", + "recommendedDataSpec_fhir": "ValueSet: EncounterClass", + "phenopacketSchemaElement_v2_0": "n/a", + "recommendedDataSpec_phenopackets": "n/a", + "description": "The class of an encounter of the individual at the time of data capture." } ], "valueSets": [ @@ -244,8 +480,12 @@ "valueSetLink": "https://github.com/your_repo_path/v2.0.0/value_sets_v2.0.0.json", "display": "Sex at Birth", "valueSetCode": "281053000", - "valueSetCodeSystem": "SNOMED", - "valueSetCodeSystemVersion": "2024-09-01", + "valueSetCodeSystem": [ + { + "codeSystem": "SNOMED", + "version": "2024-09-01" + } + ], "valueSetChoices": [ { "choiceDisplay": "Female", @@ -278,6 +518,505 @@ "choiceCodeSystemVersion": "2024-09-01" } ] + }, + { + "valueSetName": "Karyotypic Sex Value Set v2.0.0", + "valueSetOrigin": "RD CDM v2.0.0", + "valueSetLink": "https://github.com/your_repo_path/v2.0.0/value_sets_v2.0.0.json", + "display": "Karyotypic Sex", + "valueSetCode": "1296886006", + "valueSetCodeSystem": [ + { + "codeSystem": "SNOMED", + "version": "2024-09-01" + } + ], + "valueSetChoices": [ + { + "choiceDisplay": "XX", + "choiceCode": "734875008", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "XY", + "choiceCode": "734876009", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "X0", + "choiceCode": "80427008", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "XXY", + "choiceCode": "65162001", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "XXX", + "choiceCode": "35111009", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "XXYY", + "choiceCode": "403760006", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "XXXY", + "choiceCode": "78317008", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "XXXX", + "choiceCode": "10567003", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "XYY", + "choiceCode": "48930007", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Other", + "choiceCode": "74964007", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + } + ] + }, + { + "valueSetName": "Gender Identity Value Set v2.0.0", + "valueSetOrigin": "RD CDM v2.0.0", + "valueSetLink": "https://github.com/your_repo_path/v2.0.0/value_sets_v2.0.0.json", + "display": "Gender Identity", + "valueSetCode": "263495000", + "valueSetCodeSystem": [ + { + "codeSystem": "SNOMED", + "version": "2024-09-01" + } + ], + "valueSetChoices": [ + { + "choiceDisplay": "Female gender identity", + "choiceCode": "446141000124107", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Male gender identity", + "choiceCode": "446151000124109", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Gender unknown", + "choiceCode": "394743007", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Identifies as nonbinary gender", + "choiceCode": "33791000087105", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Not recorded", + "choiceCode": "1220561009", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + } + ] + }, + { + "valueSetName": "Vital Status Value Set v2.0.0", + "valueSetOrigin": "RD CDM v2.0.0", + "valueSetLink": "https://github.com/your_repo_path/v2.0.0/value_sets_v2.0.0.json", + "display": "Vital Status", + "valueSetCode": "278844005", + "valueSetCodeSystem": [ + { + "codeSystem": "SNOMED", + "version": "2024-09-01" + } + ], + "valueSetChoices": [ + { + "choiceDisplay": "Alive", + "choiceCode": "438949009", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Dead", + "choiceCode": "419099009", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Unknown - Lost in follow-up", + "choiceCode": "399307001", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Unknown - Opted-out", + "choiceCode": "185924006", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Unknown - Other Reason", + "choiceCode": "261665006", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + } + ] + }, + { + "valueSetName": "Age Category Value Set v2.0.0", + "valueSetOrigin": "RD CDM v2.0.0", + "valueSetLink": "https://github.com/your_repo_path/v2.0.0/value_sets_v2.0.0.json", + "display": "Age Category", + "valueSetCode": "105727008", + "valueSetCodeSystem": [ + { + "codeSystem": "SNOMED", + "version": "2024-09-01" + } + ], + "valueSetChoices": [ + { + "choiceDisplay": "Infancy", + "choiceCode": "3658006", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Toddler", + "choiceCode": "713153009", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Childhood", + "choiceCode": "255398004", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Adolescence", + "choiceCode": "263659003", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Adulthood", + "choiceCode": "41847000", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Fetal period", + "choiceCode": "303112003", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Dead", + "choiceCode": "419099009", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Unknown", + "choiceCode": "261665006", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + } + ] + }, + { + "valueSetName": "Vital Status Value Set v2.0.0", + "valueSetOrigin": "RD CDM v2.0.0", + "valueSetLink": "https://github.com/your_repo_path/v2.0.0/value_sets_v2.0.0.json", + "display": "Vital Status", + "valueSetCode": "278844005", + "valueSetCodeSystem": [ + { + "codeSystem": "SNOMED", + "version": "2024-09-01" + } + ], + "valueSetChoices": [ + { + "choiceDisplay": "Alive", + "choiceCode": "438949009", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Dead", + "choiceCode": "419099009", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Unknown - Lost in follow-up", + "choiceCode": "399307001", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Unknown - Opted-out", + "choiceCode": "185924006", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Unknown - Other Reason", + "choiceCode": "261665006", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + } + ] + }, + { + "valueSetName": "Age Category Value Set v2.0.0", + "valueSetOrigin": "RD CDM v2.0.0", + "valueSetLink": "https://github.com/your_repo_path/v2.0.0/value_sets_v2.0.0.json", + "display": "Age Category", + "valueSetCode": "105727008", + "valueSetCodeSystem": [ + { + "codeSystem": "SNOMED", + "version": "2024-09-01" + } + ], + "valueSetChoices": [ + { + "choiceDisplay": "Infancy", + "choiceCode": "3658006", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Toddler", + "choiceCode": "713153009", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Childhood", + "choiceCode": "255398004", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Adolescence", + "choiceCode": "263659003", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Adulthood", + "choiceCode": "41847000", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Fetal period", + "choiceCode": "303112003", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Dead", + "choiceCode": "419099009", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Unknown", + "choiceCode": "261665006", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + } + ] + }, + { + "valueSetName": "Undiagnosed RD Case Value Set v2.0.0", + "valueSetOrigin": "RD CDM v2.0.0", + "valueSetLink": "https://github.com/your_repo_path/v2.0.0/value_sets_v2.0.0.json", + "display": "Undiagnosed RD Case", + "valueSetCode": "723663001", + "valueSetCodeSystem": [ + { + "codeSystem": "SNOMED", + "version": "2024-09-01" + } + ], + "valueSetChoices": [ + { + "choiceDisplay": "Yes", + "choiceCode": "373066001", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "No", + "choiceCode": "373067005", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + } + ] + }, + { + "valueSetName": "Encounter Status Value Set v2.0.0", + "valueSetOrigin": "RD CDM v2.0.0", + "valueSetLink": "https://github.com/your_repo_path/v2.0.0/value_sets_v2.0.0.json", + "display": "Encounter Status", + "valueSetCode": "305058001", + "valueSetCodeSystem": [ + { + "codeSystem": "SNOMED", + "version": "2024-09-01" + } + ], + "valueSetChoices": [ + { + "choiceDisplay": "Planned", + "choiceCode": "planned", + "choiceCodeSystem": "HL7FHIR", + "choiceCodeSystemVersion": "v4.0.1" + }, + { + "choiceDisplay": "Arrived", + "choiceCode": "arrived", + "choiceCodeSystem": "HL7FHIR", + "choiceCodeSystemVersion": "v4.0.1" + }, + { + "choiceDisplay": "Triaged", + "choiceCode": "triaged", + "choiceCodeSystem": "HL7FHIR", + "choiceCodeSystemVersion": "v4.0.1" + }, + { + "choiceDisplay": "In Progress", + "choiceCode": "in-progress", + "choiceCodeSystem": "HL7FHIR", + "choiceCodeSystemVersion": "v4.0.1" + }, + { + "choiceDisplay": "On Leave", + "choiceCode": "onleave", + "choiceCodeSystem": "HL7FHIR", + "choiceCodeSystemVersion": "v4.0.1" + }, + { + "choiceDisplay": "Finished", + "choiceCode": "finished", + "choiceCodeSystem": "HL7FHIR", + "choiceCodeSystemVersion": "v4.0.1" + }, + { + "choiceDisplay": "Cancelled", + "choiceCode": "cancelled", + "choiceCodeSystem": "HL7FHIR", + "choiceCodeSystemVersion": "v4.0.1" + }, + { + "choiceDisplay": "Entered in Error", + "choiceCode": "entered-in-error", + "choiceCodeSystem": "HL7FHIR", + "choiceCodeSystemVersion": "v4.0.1" + }, + { + "choiceDisplay": "Unknown", + "choiceCode": "unknown", + "choiceCodeSystem": "HL7FHIR", + "choiceCodeSystemVersion": "v4.0.1" + } + ] + }, + { + "valueSetName": "Encounter Class Value Set v2.0.0", + "valueSetOrigin": "RD CDM v2.0.0", + "valueSetLink": "https://github.com/your_repo_path/v2.0.0/value_sets_v2.0.0.json", + "display": "Encounter Class", + "valueSetCode": "encounter.class", + "valueSetCodeSystem": [ + { + "codeSystem": "HL7FHIR", + "version": "v4.0.1" + }, + { + "codeSystem": "SNOMED", + "version": "2024-09-01" + } + ], + "valueSetChoices": [ + { + "choiceDisplay": "Ambulatory", + "choiceCode": "AMB", + "choiceCodeSystem": "HL7FHIR", + "choiceCodeSystemVersion": "v4.0.1" + }, + { + "choiceDisplay": "Inpatient", + "choiceCode": "IMP", + "choiceCodeSystem": "HL7FHIR", + "choiceCodeSystemVersion": "v4.0.1" + }, + { + "choiceDisplay": "Observation", + "choiceCode": "OBSENC", + "choiceCodeSystem": "HL7FHIR", + "choiceCodeSystemVersion": "v4.0.1" + }, + { + "choiceDisplay": "Emergency", + "choiceCode": "EMER", + "choiceCodeSystem": "HL7FHIR", + "choiceCodeSystemVersion": "v4.0.1" + }, + { + "choiceDisplay": "Virtual", + "choiceCode": "VR", + "choiceCodeSystem": "HL7FHIR", + "choiceCodeSystemVersion": "v4.0.1" + }, + { + "choiceDisplay": "Home Health", + "choiceCode": "HH", + "choiceCodeSystem": "HL7FHIR", + "choiceCodeSystemVersion": "v4.0.1" + }, + { + "choiceDisplay": "RD Specialist Center", + "choiceCode": "RDC", + "choiceCodeSystem": "HL7FHIR", + "choiceCodeSystemVersion": "v4.0.1" + }, + { + "choiceDisplay": "Unknown", + "choiceCode": "261665006", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + } + ] } ] } \ No newline at end of file diff --git a/res/v2_0_0/rd_cdm_value_sets_v2_0_0.json b/res/v2_0_0/rd_cdm_value_sets_v2_0_0.json index e758770..3414d2c 100644 --- a/res/v2_0_0/rd_cdm_value_sets_v2_0_0.json +++ b/res/v2_0_0/rd_cdm_value_sets_v2_0_0.json @@ -8,8 +8,12 @@ "valueSetLink": "https://github.com/your_repo_path/v2.0.0/value_sets_v2.0.0.json", "display": "Sex at Birth", "valueSetCode": "281053000", - "valueSetCodeSystem": "SNOMED", - "valueSetCodeSystemVersion": "2024-09-01", + "valueSetCodeSystem": [ + { + "codeSystem": "SNOMED", + "version": "2024-09-01" + } + ], "valueSetChoices": [ { "choiceDisplay": "Female", @@ -42,6 +46,505 @@ "choiceCodeSystemVersion": "2024-09-01" } ] + }, + { + "valueSetName": "Karyotypic Sex Value Set v2.0.0", + "valueSetOrigin": "RD CDM v2.0.0", + "valueSetLink": "https://github.com/your_repo_path/v2.0.0/value_sets_v2.0.0.json", + "display": "Karyotypic Sex", + "valueSetCode": "1296886006", + "valueSetCodeSystem": [ + { + "codeSystem": "SNOMED", + "version": "2024-09-01" + } + ], + "valueSetChoices": [ + { + "choiceDisplay": "XX", + "choiceCode": "734875008", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "XY", + "choiceCode": "734876009", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "X0", + "choiceCode": "80427008", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "XXY", + "choiceCode": "65162001", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "XXX", + "choiceCode": "35111009", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "XXYY", + "choiceCode": "403760006", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "XXXY", + "choiceCode": "78317008", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "XXXX", + "choiceCode": "10567003", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "XYY", + "choiceCode": "48930007", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Other", + "choiceCode": "74964007", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + } + ] + }, + { + "valueSetName": "Gender Identity Value Set v2.0.0", + "valueSetOrigin": "RD CDM v2.0.0", + "valueSetLink": "https://github.com/your_repo_path/v2.0.0/value_sets_v2.0.0.json", + "display": "Gender Identity", + "valueSetCode": "263495000", + "valueSetCodeSystem": [ + { + "codeSystem": "SNOMED", + "version": "2024-09-01" + } + ], + "valueSetChoices": [ + { + "choiceDisplay": "Female gender identity", + "choiceCode": "446141000124107", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Male gender identity", + "choiceCode": "446151000124109", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Gender unknown", + "choiceCode": "394743007", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Identifies as nonbinary gender", + "choiceCode": "33791000087105", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Not recorded", + "choiceCode": "1220561009", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + } + ] + }, + { + "valueSetName": "Vital Status Value Set v2.0.0", + "valueSetOrigin": "RD CDM v2.0.0", + "valueSetLink": "https://github.com/your_repo_path/v2.0.0/value_sets_v2.0.0.json", + "display": "Vital Status", + "valueSetCode": "278844005", + "valueSetCodeSystem": [ + { + "codeSystem": "SNOMED", + "version": "2024-09-01" + } + ], + "valueSetChoices": [ + { + "choiceDisplay": "Alive", + "choiceCode": "438949009", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Dead", + "choiceCode": "419099009", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Unknown - Lost in follow-up", + "choiceCode": "399307001", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Unknown - Opted-out", + "choiceCode": "185924006", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Unknown - Other Reason", + "choiceCode": "261665006", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + } + ] + }, + { + "valueSetName": "Age Category Value Set v2.0.0", + "valueSetOrigin": "RD CDM v2.0.0", + "valueSetLink": "https://github.com/your_repo_path/v2.0.0/value_sets_v2.0.0.json", + "display": "Age Category", + "valueSetCode": "105727008", + "valueSetCodeSystem": [ + { + "codeSystem": "SNOMED", + "version": "2024-09-01" + } + ], + "valueSetChoices": [ + { + "choiceDisplay": "Infancy", + "choiceCode": "3658006", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Toddler", + "choiceCode": "713153009", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Childhood", + "choiceCode": "255398004", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Adolescence", + "choiceCode": "263659003", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Adulthood", + "choiceCode": "41847000", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Fetal period", + "choiceCode": "303112003", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Dead", + "choiceCode": "419099009", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Unknown", + "choiceCode": "261665006", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + } + ] + }, + { + "valueSetName": "Vital Status Value Set v2.0.0", + "valueSetOrigin": "RD CDM v2.0.0", + "valueSetLink": "https://github.com/your_repo_path/v2.0.0/value_sets_v2.0.0.json", + "display": "Vital Status", + "valueSetCode": "278844005", + "valueSetCodeSystem": [ + { + "codeSystem": "SNOMED", + "version": "2024-09-01" + } + ], + "valueSetChoices": [ + { + "choiceDisplay": "Alive", + "choiceCode": "438949009", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Dead", + "choiceCode": "419099009", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Unknown - Lost in follow-up", + "choiceCode": "399307001", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Unknown - Opted-out", + "choiceCode": "185924006", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Unknown - Other Reason", + "choiceCode": "261665006", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + } + ] + }, + { + "valueSetName": "Age Category Value Set v2.0.0", + "valueSetOrigin": "RD CDM v2.0.0", + "valueSetLink": "https://github.com/your_repo_path/v2.0.0/value_sets_v2.0.0.json", + "display": "Age Category", + "valueSetCode": "105727008", + "valueSetCodeSystem": [ + { + "codeSystem": "SNOMED", + "version": "2024-09-01" + } + ], + "valueSetChoices": [ + { + "choiceDisplay": "Infancy", + "choiceCode": "3658006", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Toddler", + "choiceCode": "713153009", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Childhood", + "choiceCode": "255398004", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Adolescence", + "choiceCode": "263659003", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Adulthood", + "choiceCode": "41847000", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Fetal period", + "choiceCode": "303112003", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Dead", + "choiceCode": "419099009", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "Unknown", + "choiceCode": "261665006", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + } + ] + }, + { + "valueSetName": "Undiagnosed RD Case Value Set v2.0.0", + "valueSetOrigin": "RD CDM v2.0.0", + "valueSetLink": "https://github.com/your_repo_path/v2.0.0/value_sets_v2.0.0.json", + "display": "Undiagnosed RD Case", + "valueSetCode": "723663001", + "valueSetCodeSystem": [ + { + "codeSystem": "SNOMED", + "version": "2024-09-01" + } + ], + "valueSetChoices": [ + { + "choiceDisplay": "Yes", + "choiceCode": "373066001", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + }, + { + "choiceDisplay": "No", + "choiceCode": "373067005", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + } + ] + }, + { + "valueSetName": "Encounter Status Value Set v2.0.0", + "valueSetOrigin": "RD CDM v2.0.0", + "valueSetLink": "https://github.com/your_repo_path/v2.0.0/value_sets_v2.0.0.json", + "display": "Encounter Status", + "valueSetCode": "305058001", + "valueSetCodeSystem": [ + { + "codeSystem": "SNOMED", + "version": "2024-09-01" + } + ], + "valueSetChoices": [ + { + "choiceDisplay": "Planned", + "choiceCode": "planned", + "choiceCodeSystem": "HL7FHIR", + "choiceCodeSystemVersion": "v4.0.1" + }, + { + "choiceDisplay": "Arrived", + "choiceCode": "arrived", + "choiceCodeSystem": "HL7FHIR", + "choiceCodeSystemVersion": "v4.0.1" + }, + { + "choiceDisplay": "Triaged", + "choiceCode": "triaged", + "choiceCodeSystem": "HL7FHIR", + "choiceCodeSystemVersion": "v4.0.1" + }, + { + "choiceDisplay": "In Progress", + "choiceCode": "in-progress", + "choiceCodeSystem": "HL7FHIR", + "choiceCodeSystemVersion": "v4.0.1" + }, + { + "choiceDisplay": "On Leave", + "choiceCode": "onleave", + "choiceCodeSystem": "HL7FHIR", + "choiceCodeSystemVersion": "v4.0.1" + }, + { + "choiceDisplay": "Finished", + "choiceCode": "finished", + "choiceCodeSystem": "HL7FHIR", + "choiceCodeSystemVersion": "v4.0.1" + }, + { + "choiceDisplay": "Cancelled", + "choiceCode": "cancelled", + "choiceCodeSystem": "HL7FHIR", + "choiceCodeSystemVersion": "v4.0.1" + }, + { + "choiceDisplay": "Entered in Error", + "choiceCode": "entered-in-error", + "choiceCodeSystem": "HL7FHIR", + "choiceCodeSystemVersion": "v4.0.1" + }, + { + "choiceDisplay": "Unknown", + "choiceCode": "unknown", + "choiceCodeSystem": "HL7FHIR", + "choiceCodeSystemVersion": "v4.0.1" + } + ] + }, + { + "valueSetName": "Encounter Class Value Set v2.0.0", + "valueSetOrigin": "RD CDM v2.0.0", + "valueSetLink": "https://github.com/your_repo_path/v2.0.0/value_sets_v2.0.0.json", + "display": "Encounter Class", + "valueSetCode": "encounter.class", + "valueSetCodeSystem": [ + { + "codeSystem": "HL7FHIR", + "version": "v4.0.1" + }, + { + "codeSystem": "SNOMED", + "version": "2024-09-01" + } + ], + "valueSetChoices": [ + { + "choiceDisplay": "Ambulatory", + "choiceCode": "AMB", + "choiceCodeSystem": "HL7FHIR", + "choiceCodeSystemVersion": "v4.0.1" + }, + { + "choiceDisplay": "Inpatient", + "choiceCode": "IMP", + "choiceCodeSystem": "HL7FHIR", + "choiceCodeSystemVersion": "v4.0.1" + }, + { + "choiceDisplay": "Observation", + "choiceCode": "OBSENC", + "choiceCodeSystem": "HL7FHIR", + "choiceCodeSystemVersion": "v4.0.1" + }, + { + "choiceDisplay": "Emergency", + "choiceCode": "EMER", + "choiceCodeSystem": "HL7FHIR", + "choiceCodeSystemVersion": "v4.0.1" + }, + { + "choiceDisplay": "Virtual", + "choiceCode": "VR", + "choiceCodeSystem": "HL7FHIR", + "choiceCodeSystemVersion": "v4.0.1" + }, + { + "choiceDisplay": "Home Health", + "choiceCode": "HH", + "choiceCodeSystem": "HL7FHIR", + "choiceCodeSystemVersion": "v4.0.1" + }, + { + "choiceDisplay": "RD Specialist Center", + "choiceCode": "RDC", + "choiceCodeSystem": "HL7FHIR", + "choiceCodeSystemVersion": "v4.0.1" + }, + { + "choiceDisplay": "Unknown", + "choiceCode": "261665006", + "choiceCodeSystem": "SNOMED", + "choiceCodeSystemVersion": "2024-09-01" + } + ] } ] } \ No newline at end of file diff --git a/schemas/rd_cdm_data_elements_schema.json b/schemas/rd_cdm_data_elements_schema.json index 469be72..33dfd51 100644 --- a/schemas/rd_cdm_data_elements_schema.json +++ b/schemas/rd_cdm_data_elements_schema.json @@ -40,8 +40,8 @@ "description": "The data specification (e.g., format)." }, "valueSet": { - "type": ["object", "null"], - "description": "The optional value set associated with the element.", + "type": ["object", "string", "null"], + "description": "The optional value set associated with the element, can also be a string or 'n/a'.", "properties": { "valueSetName": { "type": "string" }, "valueSetOrigin": { "type": "string" }, @@ -63,13 +63,27 @@ } } }, - "fhirExpression_v4.0.1": { "type": "string" }, - "recommendedVS_fhir": { "type": ["string", "null"] }, - "phenopacketSchemaElement_v2.0": { "type": "string" }, - "recommendedVS_phenopacket": { "type": ["string", "null"] }, - "description": { "type": "string" } + "fhirExpression_v4_0_1": { + "type": ["string", "null"], + "description": "FHIR expression associated with the element, can also be 'n/a'." + }, + "recommendedDataSpec_fhir": { + "type": ["string", "null"], + "description": "Recommended FHIR data specification or value set, can also be 'n/a'." + }, + "phenopacketSchemaElement_v2_0": { + "type": ["string", "null"], + "description": "Recommended Phenopacket data specification, can also be 'n/a'." + }, + "recommendedDataSpec_phenopackets": { + "type": ["string", "null"], + "description": "Recommended Phenopacket data specification or value set, can also be 'n/a'." + }, + "description": { + "type": "string" + } }, - "required": ["ordinal", "section", "elementName", "elementCode", "elementCodeSystem", "dataType", "dataSpecification"] + "required": ["ordinal", "section", "elementName", "elementCode", "elementCodeSystem", "dataType", "dataSpecification", "fhirExpression_v4_0_1", "recommendedDataSpec_fhir", "phenopacketSchemaElement_v2_0", "recommendedDataSpec_phenopackets", "description"] } } }, diff --git a/schemas/rd_cdm_v2_0_0_schema.json b/schemas/rd_cdm_v2_0_0_schema.json index a8c21a4..dfa07a7 100644 --- a/schemas/rd_cdm_v2_0_0_schema.json +++ b/schemas/rd_cdm_v2_0_0_schema.json @@ -56,7 +56,21 @@ "valueSetLink": { "type": "string" }, "display": { "type": "string" }, "valueSetCode": { "type": "string" }, - "valueSetCodeSystem": { "type": "string" }, + "valueSetCodeSystem": { + "type": "array", + "items": { + "type": "object", + "properties": { + "codeSystem": { + "type": "string" + }, + "version": { + "type": "string" + } + } + }, + "description": "The code systems associated with the value set." + }, "valueSetChoices": { "type": "array", "items": { diff --git a/schemas/rd_cdm_value_sets_schema.json b/schemas/rd_cdm_value_sets_schema.json index 0700834..c94cb63 100644 --- a/schemas/rd_cdm_value_sets_schema.json +++ b/schemas/rd_cdm_value_sets_schema.json @@ -3,52 +3,62 @@ "title": "RD CDM Value Sets Schema", "type": "object", "properties": { - "valueSets": { - "type": "array", - "items": { - "type": "object", - "properties": { - "valueSetName": { - "type": "string", - "description": "The name of the value set." - }, - "valueSetOrigin": { - "type": "string", - "description": "The origin of the value set." - }, - "valueSetLink": { - "type": "string", - "description": "A URL linking to the value set source." - }, - "display": { - "type": "string", - "description": "The display name for the value set." - }, - "valueSetCode": { - "type": "string", - "description": "The code for the value set." - }, - "valueSetCodeSystem": { - "type": "string", - "description": "The code system associated with the value set." - }, - "valueSetChoices": { - "type": "array", - "items": { + "valueSets": { + "type": "array", + "items": { "type": "object", "properties": { - "choiceDisplay": { "type": "string" }, - "choiceCode": { "type": "string" }, - "choiceCodeSystem": { "type": "string" } + "valueSetName": { + "type": "string", + "description": "The name of the value set." + }, + "valueSetOrigin": { + "type": "string", + "description": "The origin of the value set." + }, + "valueSetLink": { + "type": "string", + "description": "A URL linking to the value set source." + }, + "display": { + "type": "string", + "description": "The display name for the value set." + }, + "valueSetCode": { + "type": "string", + "description": "The code for the value set." + }, + "valueSetCodeSystem": { + "type": "array", + "items": { + "type": "object", + "properties": { + "codeSystem": { + "type": "string" + }, + "version": { + "type": "string" + } + } + }, + "description": "The code systems associated with the value set." + }, + "valueSetChoices": { + "type": "array", + "items": { + "type": "object", + "properties": { + "choiceDisplay": { "type": "string" }, + "choiceCode": { "type": "string" }, + "choiceCodeSystem": { "type": "string" } + }, + "required": ["choiceDisplay", "choiceCode", "choiceCodeSystem"] + } + } }, - "required": ["choiceDisplay", "choiceCode", "choiceCodeSystem"] - } + "required": ["valueSetName", "valueSetOrigin", "valueSetLink", "display", "valueSetCode", "valueSetCodeSystem", "valueSetChoices"] } - }, - "required": ["valueSetName", "valueSetOrigin", "valueSetLink", "display", "valueSetCode", "valueSetCodeSystem", "valueSetChoices"] } - } }, "required": ["valueSets"] - } - \ No newline at end of file +} diff --git a/src/data_model/__init__.py b/src/data_model/__init__.py index b7698cb..61b9ec4 100644 --- a/src/data_model/__init__.py +++ b/src/data_model/__init__.py @@ -1,18 +1,23 @@ """This submodules contains the data model schemas for the application.""" -from .codesystems import create_code_systems -from .base_types import CodeSystem, CodeableConcept, Coding, Date +from .codesystems import CodeSystems +from .base_types import CodeSystem, CodeableConcept, Coding, Date, String, Boolean from .value_set import ValueSet, ValueSetChoice from .data_elements import DataElement, DataElementModel +from .utils import json_serializer + __all__ = [ - 'create_code_systems', + 'CodeSystems', 'CodeSystem', 'CodeableConcept', - 'Coding' + 'Coding', 'ValueSetChoice', 'ValueSet', 'DataElement', 'DataElementModel', - 'Date' + 'Date', + 'String', + 'Boolean', + 'json_serializer' ] diff --git a/src/data_model/base_types.py b/src/data_model/base_types.py index 816ab8c..5cb589b 100644 --- a/src/data_model/base_types.py +++ b/src/data_model/base_types.py @@ -10,7 +10,6 @@ class CodeSystem: data representation in domains like healthcare and bioinformatics. Attributes: - ----------- name : str The full name of the CodeSystem (e.g., "SNOMED CT"). @@ -27,7 +26,6 @@ class CodeSystem: Alternative names or abbreviations for the CodeSystem. Methods: - -------- __eq__(self, other): Checks equality based on `namespace_prefix` or `synonyms`. @@ -134,6 +132,10 @@ class CodeableConcept: def __str__(self): return f"CodeableConcept(codings=[{', '.join(map(str, self.coding))}], text={self.text})" +from dataclasses import dataclass +from datetime import datetime +from typing import Union + @dataclass(frozen=True, slots=True) class Date: """Represents a date in the formats YYYY, YYYY-MM, or YYYY-MM-DD.""" @@ -154,4 +156,64 @@ def is_valid_format(date_str): except ValueError: continue return False - \ No newline at end of file + + def to_json(self): + """Return the date as a string for JSON serialization.""" + return str(self.value) + + +@dataclass(frozen=True, slots=True) +class Code: + """Represents a coded value.""" + system: str + code: str + + def to_json(self): + """Return a dictionary representing this Code.""" + return {"system": self.system, "code": self.code} + +@dataclass(frozen=True, slots=True) +class Address: + """Represents an address.""" + street: str + city: str + zip_code: str + country: str + + def to_json(self): + """Return a dictionary representing this Address.""" + return { + "country" : self.country, + "street": self.street, + "city": self.city, + "zip_code": self.zip_code + } + +@dataclass(frozen=True, slots=True) +class Identifier: + """Represents an identifier.""" + id: str + type: str + + def to_json(self): + """Return a dictionary representing this Identifier.""" + return {"id": self.id, "type": self.type} + + +@dataclass(frozen=True, slots=True) +class String: + """Represents a string data type.""" + value: str + + def __post_init__(self): + if not isinstance(self.value, str): + raise ValueError(f"Invalid value for String: {self.value}. Expected a string.") + +@dataclass(frozen=True, slots=True) +class Boolean: + """Represents a boolean data type.""" + value: bool + + def __post_init__(self): + if not isinstance(self.value, bool): + raise ValueError(f"Invalid value for Boolean: {self.value}. Expected a boolean.") diff --git a/src/data_model/codesystems.py b/src/data_model/codesystems.py index df43597..a5fc86c 100644 --- a/src/data_model/codesystems.py +++ b/src/data_model/codesystems.py @@ -1,134 +1,143 @@ -from dataclasses import dataclass, field - from .base_types import CodeSystem -# Function to create a list of CodeSystem instances without versions -def create_code_systems(versions: dict[str, str]): - """Create a list of CodeSystem instances and filter by defined versions.""" +class CodeSystems: + """Class that holds all predefined CodeSystems as attributes.""" - all_code_systems = [ - CodeSystem( - name="NCBI organismal classification", - namespace_prefix="NCBITaxon", - url="https://www.ncbi.nlm.nih.gov/taxonomy" - ), - CodeSystem( - name="GENO: The Genotype Ontology", - namespace_prefix="GENO", - url="http://www.genoontology.org/" - ), - CodeSystem( - name="Sequence types and features ontology", - namespace_prefix="SO", - url="http://www.sequenceontology.org/" - ), - CodeSystem( - name="International Classification of Diseases, Ninth Revision", - namespace_prefix="ICD9", - url="https://www.cdc.gov/nchs/icd/icd9.htm", - synonyms=["ICD-9", "ICD_9"] - ), - CodeSystem( - name="International Classification of Diseases, Tenth Revision, " - "German Modification", - namespace_prefix="ICD10GM", - url="https://www.bfarm.de/EN/Code-systems/Classifications/ICD/" - "ICD-10-GM/_node.html", - synonyms=["ICD10-GM", "ICD-10-GM", "ICD10_GM", "ICD_10_GM"] - ), - CodeSystem( - name="International Classification of Diseases, Tenth Revision, " - "Clinical Modification", - namespace_prefix="ICD10CM", - url="https://www.cdc.gov/nchs/icd/icd10cm.htm", - synonyms=["ICD10-CM", "ICD10_CM", "ICD-10-CM", "ICD_10_CM"] - ), - CodeSystem( - name="SNOMED", - namespace_prefix="SNOMED", - url="https://www.snomed.org/snomed-ct", - synonyms=["SCT", "SNOMED CT"] - ), - CodeSystem( - name="International Classification of Diseases, Eleventh Revision", - namespace_prefix="ICD11", - url="https://icd.who.int/en", - synonyms=["ICD-11"] - ), - CodeSystem( - name="Health Level 7 Fast Healthcare Interoperability Resources", - namespace_prefix="HL7FHIR", - url="https://www.hl7.org/fhir/" - ), - CodeSystem( - name="Global Alliance for Genomics and Health Phenopacket Schema v2.0", - namespace_prefix="GA4GH", - url="https://www.ga4gh.org/product/phenopackets/" - ), - CodeSystem( - name="ISO 3166-1:2020(en) alpha-2 and alpha-3 country codes", - namespace_prefix="ISO3166", - url="https://www.iso.org/iso-3166-country-codes.html" - ), - CodeSystem( - name="International Classification of Functioning, Disability and " - "Health (ICF)", - namespace_prefix="ICF", - url="https://www.who.int/classifications/icf/en/" - ), - CodeSystem( - name="Monarch Disease Ontology", - namespace_prefix="MONDO", - url="http://purl.obolibrary.org/obo/mondo.owl" - ), - CodeSystem( - name="Orphanet Rare Disease Ontology", - namespace_prefix="ORDO", - url="http://www.orpha.net/", - synonyms=["ORPHA"] - ), - CodeSystem( - name="Online Mendelian Inheritance", - namespace_prefix="OMIM", - url="https://omim.org/" - ), - CodeSystem( - name="Logical Observation Identifiers Names and Codes", - namespace_prefix="LOINC", - url="https://loinc.org/" - ), - CodeSystem( - name="Human Genome Variation Society", - namespace_prefix="HGVS", - url="http://varnomen.hgvs.org/" - ), - CodeSystem( - name="HUGO Gene Nomenclature Committee", - namespace_prefix="HGNC", - url="https://www.genenames.org/" - ), - CodeSystem( - name="Human Phenotype Ontology", - namespace_prefix="HP", - url="http://www.human-phenotype-ontology.org", - iri_prefix="http://purl.obolibrary.org/obo/HP_", - synonyms=["HPO"] - ), - CodeSystem( - name="Units of Measurement Ontology", - namespace_prefix="UO", - url="http://www.ontobee.org/ontology/UO" - ), - CodeSystem( - name="NCI Thesaurus OBO Edition", - namespace_prefix="NCIT", - url="https://ncit.nci.nih.gov/" - ) - ] + NCBITaxon = CodeSystem( + name="NCBI organismal classification", + namespace_prefix="NCBITaxon", + url="https://www.ncbi.nlm.nih.gov/taxonomy" + ) - # Filter code systems to include only those with a defined version - filtered_code_systems = [ - cs for cs in all_code_systems if cs.namespace_prefix in versions - ] + GENO = CodeSystem( + name="GENO: The Genotype Ontology", + namespace_prefix="GENO", + url="http://www.genoontology.org/" + ) + + SO = CodeSystem( + name="Sequence types and features ontology", + namespace_prefix="SO", + url="http://www.sequenceontology.org/" + ) + + ICD9 = CodeSystem( + name="International Classification of Diseases, Ninth Revision", + namespace_prefix="ICD9", + url="https://www.cdc.gov/nchs/icd/icd9.htm", + synonyms=["ICD-9", "ICD_9"] + ) + + ICD10GM = CodeSystem( + name="International Classification of Diseases, Tenth Revision, German Modification", + namespace_prefix="ICD10GM", + url="https://www.bfarm.de/EN/Code-systems/Classifications/ICD/ICD-10-GM/_node.html", + synonyms=["ICD10-GM", "ICD-10-GM", "ICD10_GM", "ICD_10_GM"] + ) + + ICD10CM = CodeSystem( + name="International Classification of Diseases, Tenth Revision, Clinical Modification", + namespace_prefix="ICD10CM", + url="https://www.cdc.gov/nchs/icd/icd10cm.htm", + synonyms=["ICD10-CM", "ICD10_CM", "ICD-10-CM", "ICD_10_CM"] + ) + + SNOMED = CodeSystem( + name="SNOMED", + namespace_prefix="SNOMED", + url="https://www.snomed.org/snomed-ct", + synonyms=["SCT", "SNOMED CT"] + ) + + ICD11 = CodeSystem( + name="International Classification of Diseases, Eleventh Revision", + namespace_prefix="ICD11", + url="https://icd.who.int/en", + synonyms=["ICD-11"] + ) + + HL7FHIR = CodeSystem( + name="Health Level 7 Fast Healthcare Interoperability Resources", + namespace_prefix="HL7FHIR", + url="https://www.hl7.org/fhir/" + ) + + GA4GH = CodeSystem( + name="Global Alliance for Genomics and Health Phenopacket Schema v2.0", + namespace_prefix="GA4GH", + url="https://www.ga4gh.org/product/phenopackets/" + ) + + ISO3166 = CodeSystem( + name="ISO 3166-1:2020(en) alpha-2 and alpha-3 country codes", + namespace_prefix="ISO3166", + url="https://www.iso.org/iso-3166-country-codes.html" + ) + + ICF = CodeSystem( + name="International Classification of Functioning, Disability and Health", + namespace_prefix="ICF", + url="https://www.who.int/classifications/icf/en/" + ) + + MONDO = CodeSystem( + name="Monarch Disease Ontology", + namespace_prefix="MONDO", + url="http://purl.obolibrary.org/obo/mondo.owl" + ) + + ORDO = CodeSystem( + name="Orphanet Rare Disease Ontology", + namespace_prefix="ORDO", + url="http://www.orpha.net/", + synonyms=["ORPHA"] + ) + + OMIM = CodeSystem( + name="Online Mendelian Inheritance", + namespace_prefix="OMIM", + url="https://omim.org/" + ) + + LOINC = CodeSystem( + name="Logical Observation Identifiers Names and Codes", + namespace_prefix="LOINC", + url="https://loinc.org/" + ) + + HGVS = CodeSystem( + name="Human Genome Variation Society", + namespace_prefix="HGVS", + url="http://varnomen.hgvs.org/" + ) + + HGNC = CodeSystem( + name="HUGO Gene Nomenclature Committee", + namespace_prefix="HGNC", + url="https://www.genenames.org/" + ) + + HP = CodeSystem( + name="Human Phenotype Ontology", + namespace_prefix="HP", + url="http://www.human-phenotype-ontology.org", + iri_prefix="http://purl.obolibrary.org/obo/HP_", + synonyms=["HPO"] + ) + + UO = CodeSystem( + name="Units of Measurement Ontology", + namespace_prefix="UO", + url="http://www.ontobee.org/ontology/UO" + ) + + NCIT = CodeSystem( + name="NCI Thesaurus OBO Edition", + namespace_prefix="NCIT", + url="https://ncit.nci.nih.gov/" + ) - return filtered_code_systems \ No newline at end of file + @classmethod + def get_all_code_systems(cls): + """Returns all code systems as a dictionary.""" + return {attr: value for attr, value in cls.__dict__.items() if isinstance(value, CodeSystem)} diff --git a/src/data_model/data_elements.py b/src/data_model/data_elements.py index b4640d9..62af2e5 100644 --- a/src/data_model/data_elements.py +++ b/src/data_model/data_elements.py @@ -13,11 +13,11 @@ class DataElement: elementCodeSystem: CodeSystem dataType: str dataSpecification: List[str] - valueSet: Optional[ValueSet] = None # ValueSet is optional + valueSet: Optional[str] = None # Now it references the ValueSet by name (just a string) fhirExpression_v4_0_1: Optional[str] = None - recommendedVS_fhir: Optional[str] = None + recommendedDataSpec_fhir: Optional[str] = None phenopacketSchemaElement_v2_0: Optional[str] = None - recommendedVS_phenopacket: Optional[str] = None + recommendedDataSpec_phenopackets: Optional[str] = None description: str = "" @dataclass(slots=True, frozen=True) diff --git a/src/data_model/utils.py b/src/data_model/utils.py new file mode 100644 index 0000000..220fbcd --- /dev/null +++ b/src/data_model/utils.py @@ -0,0 +1,33 @@ +from datetime import datetime + +def json_serializer(obj): + """ + Custom JSON serializer for objects not serializable by default. + + This function handles serialization of objects that the default `json` module + cannot serialize, such as custom classes and datetime objects. It covers: + + - **Datetime objects**: Serializes `datetime` instances to ISO 8601 + formatted strings. + - **Class types (e.g., Date, Code)**: Serializes class references by + returning their class name as a string. + - **Objects with a `__dict__` attribute**: Serializes objects by converting + their `__dict__` (attribute dictionary) to a serializable form. + + Args: + obj (Any): The object to serialize. + + Returns: + str or dict: A JSON-serializable representation of the input object. + + Raises: + TypeError: If the object type is not supported for serialization. + """ + if isinstance(obj, (datetime,)): + return obj.isoformat() + elif isinstance(obj, type): # Handles class references like Date, Code, etc. + return obj.__name__ # Return the name of the class + elif hasattr(obj, "__dict__"): + return obj.__dict__ + else: + raise TypeError(f"Object of type {type(obj)} is not JSON serializable") diff --git a/src/data_model/value_set.py b/src/data_model/value_set.py index b0458e2..4a43e0c 100644 --- a/src/data_model/value_set.py +++ b/src/data_model/value_set.py @@ -1,6 +1,6 @@ from dataclasses import dataclass, field from typing import List -from .base_types import CodeSystem, Coding +from .base_types import CodeSystem, Code, Coding @dataclass(slots=True, frozen=True) class ValueSetChoice: diff --git a/src/parsing/create_codesystems_json.py b/src/parsing/create_codesystems_json.py index 6c9950a..d45848d 100644 --- a/src/parsing/create_codesystems_json.py +++ b/src/parsing/create_codesystems_json.py @@ -3,10 +3,11 @@ import os import importlib +# Add src directory to path sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) -from src.data_model.codesystems import create_code_systems - +from data_model.utils import json_serializer +from src.data_model.codesystems import CodeSystems def load_code_system_versions(version): """ @@ -17,28 +18,17 @@ def load_code_system_versions(version): is stored in a class containing a dictionary mapping code system names to their respective version numbers. - The module to be imported should follow a standard structure: - - The module is located in "src//" (e.g., "src/v2_0_0/"). - - It contains a class named "CODESYSTEMS_VERSIONS_" that stores - the code system versions in a dictionary called `versions`. - - Example: - - For version "v2_0_0", the module "rd_cdm_v2_0_0_codesystems_versions.py" - should define a class "CODESYSTEMS_VERSIONS_V2_0_0" containing a `versions` - dictionary with code system mappings. - :param version: A string representing the version of the code systems to load (e.g., "v2_0_0"). :return: A dictionary with the code system versions for the given version, or None if the module or class is not found. """ try: - module = importlib.import_module( - f"src.{version}.rd_cdm_{version}_codesystems_versions" - ) + # Dynamically import the version-specific module + module = importlib.import_module(f"src.{version}.rd_cdm_{version}_codesystems_versions") class_name = f"CODESYSTEMS_VERSIONS_{version.replace('.', '_').upper()}" version_class = getattr(module, class_name) - return version_class.versions + return version_class.versions except (ModuleNotFoundError, AttributeError) as e: print(f"Error loading version module for {version}: {e}") return None @@ -49,46 +39,47 @@ def create_codesystem_json(version): This function generates a JSON file containing the code systems for a given version of the data model. It first loads the code system versions - using `load_code_system_versions()`, then it uses `create_code_systems()` - to build a list of code systems. The result is written as a JSON file in - the "res" folder under the respective version directory. - - Example: - - For version "v2_0_0", the JSON will be created at: - "res/v2_0_0/rd_cdm_codesystems_v2_0_0.json". + using `load_code_system_versions()`, then it uses `CodeSystems` to fetch + all code systems. The result is written as a JSON file in the "res" folder + under the respective version directory. :param version: A string representing the data model version (e.g., "v2_0_0"). """ + # Load code system versions for the specified version versions = load_code_system_versions(version) if versions is None: print(f"Failed to create code system JSON for {version}.") return - code_systems = create_code_systems(versions) + # Access all predefined code systems using the CodeSystems class + code_systems = CodeSystems.get_all_code_systems() - # Create a JSON structure for the code systems + # Generate the JSON structure code_systems_json = { - "version": version, # Adding the version key to the root of the JSON + "version": version, "CodeSystems": [ { "codeSystemName": cs.name, "namespace_prefix": cs.namespace_prefix, - "version": versions[cs.namespace_prefix], + "version": versions.get(cs.namespace_prefix, "unknown"), # Get version from versions dict "url": cs.url, "synonyms": cs.synonyms - } for cs in code_systems if cs.namespace_prefix in versions + } for cs in code_systems.values() # Access values from the dictionary returned by get_all_code_systems ] } + # Ensure the output directory exists + output_directory = f"res/{version}/" + os.makedirs(output_directory, exist_ok=True) + # Write the JSON file to the res folder - output_path = f"res/{version}/rd_cdm_codesystems_{version}.json" + output_path = os.path.join(output_directory, f"rd_cdm_codesystems_{version}.json") with open(output_path, "w") as json_file: - json.dump(code_systems_json, json_file, indent=2) + json.dump(code_systems_json, json_file, default=json_serializer, indent=2) print(f"JSON file created successfully: {output_path}") if __name__ == "__main__": create_codesystem_json("v2_0_0") - diff --git a/src/parsing/create_data_elements_json.py b/src/parsing/create_data_elements_json.py index b08a4d2..afba382 100644 --- a/src/parsing/create_data_elements_json.py +++ b/src/parsing/create_data_elements_json.py @@ -6,6 +6,7 @@ # Add the src directory to the system path sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) +from data_model.utils import json_serializer from src.data_model.data_elements import DataElement, DataElementModel from src.data_model.base_types import CodeSystem, Coding @@ -50,30 +51,15 @@ def create_data_elements_json(version): "ordinal": de.ordinal, "section": de.section, "elementName": de.elementName, - "elementCode": de.elementCode.code, # Assuming Coding object - "elementCodeSystem": de.elementCodeSystem.namespace_prefix, + "elementCode": de.elementCode.code, + "elementCodeSystem": de.elementCodeSystem if isinstance(de.elementCodeSystem, str) else de.elementCodeSystem.namespace_prefix, "dataType": de.dataType, "dataSpecification": de.dataSpecification, - "valueSet": { - "valueSetName": de.valueSet.valueSetName, - "valueSetOrigin": de.valueSet.valueSetOrigin, - "valueSetLink": de.valueSet.valueSetLink, - "display": de.valueSet.display, - "valueSetCode": de.valueSet.valueSetCode.code, - "valueSetCodeSystem": de.valueSet.valueSetCodeSystem.namespace_prefix, - "valueSetChoices": [ - { - "choiceDisplay": choice.choiceDisplay, - "choiceCode": choice.choiceCode.code, - "choiceCodeSystem": choice.choiceCodeSystem.namespace_prefix - } - for choice in de.valueSet.valueSetChoices - ] - } if de.valueSet else None, - "fhirExpression_v4.0.1": de.fhirExpression_v4_0_1, - "recommendedVS_fhir": de.recommendedVS_fhir, - "phenopacketSchemaElement_v2.0": de.phenopacketSchemaElement_v2_0, - "recommendedVS_phenopacket": de.recommendedVS_phenopacket, + "valueSet": de.valueSet if isinstance(de.valueSet, str) else None, # Directly use the string reference + "fhirExpression_v4_0_1": de.fhirExpression_v4_0_1, + "recommendedDataSpec_fhir": de.recommendedDataSpec_fhir, + "phenopacketSchemaElement_v2_0": de.phenopacketSchemaElement_v2_0, + "recommendedDataSpec_phenopackets": de.recommendedDataSpec_phenopackets, "description": de.description } for de in data_elements @@ -83,11 +69,10 @@ def create_data_elements_json(version): # Write the JSON file to the res folder output_path = f"res/{version}/rd_cdm_data_elements_{version}.json" with open(output_path, "w") as json_file: - json.dump(data_elements_json, json_file, indent=2) + json.dump(data_elements_json, json_file, default=json_serializer, indent=2) print(f"JSON file created successfully: {output_path}") # Run the function for the versions you want if __name__ == "__main__": create_data_elements_json("v2_0_0") - #create_data_elements_json("v2_1_0") diff --git a/src/parsing/create_rd_cdm_json.py b/src/parsing/create_rd_cdm_json.py index 890f023..f971555 100644 --- a/src/parsing/create_rd_cdm_json.py +++ b/src/parsing/create_rd_cdm_json.py @@ -1,8 +1,20 @@ import json import os +from datetime import datetime + +from data_model.utils import json_serializer def load_json(file_path): - """Utility function to load a JSON file.""" + """ + Utility function to load a JSON file. + + Args: + file_path (str): The path to the JSON file to be loaded. + + Returns: + dict: The loaded JSON data or None if the file could not be found + or has invalid JSON format. + """ try: with open(file_path, "r") as f: return json.load(f) @@ -14,8 +26,20 @@ def load_json(file_path): return None def create_final_rd_cdm_json(version): - """Combine CodeSystems, DataElements, and ValueSets into one final JSON.""" - + """ + Combine CodeSystems, DataElements, and ValueSets into one final RD CDM JSON file. + + This function combines the contents of separate JSON files for code systems, + data elements, and value sets into a single comprehensive JSON document. It + also adds metadata including the current creation date and author. + + Args: + version (str): The version of the RD CDM (e.g., "v2_0_0"). + + Returns: + dict: The combined RD CDM JSON structure, or None if any components fail + to load. + """ # Define the paths to the individual JSON files base_path = f"res/{version}/" codesystems_file = os.path.join(base_path, f"rd_cdm_codesystems_{version}.json") @@ -32,6 +56,9 @@ def create_final_rd_cdm_json(version): print(f"Failed to load one or more components for version {version}.") return None + # Get the current date in YYYY-MM-DD format + current_date = datetime.now().strftime("%Y-%m-%d") + # Build the final combined RD CDM JSON rd_cdm_json = { "$schema": "https://json-schema.org/draft/2020-12/schema", @@ -40,7 +67,7 @@ def create_final_rd_cdm_json(version): "description": "The ontology-based Rare Disease Common Data Model (RD CDM) to enable international registry use, HL7 FHIR, and GA4GH Phenopackets.", "metadata": { "author": "Author Name", # Replace with your metadata logic - "creationDate": "2024-01-01", # Example date + "creationDate": current_date, # Automatically use today's date }, "codeSystems": code_systems.get("CodeSystems", []), "dataElements": data_elements.get("dataElements", []), @@ -49,15 +76,11 @@ def create_final_rd_cdm_json(version): # Write the final JSON file output_path = os.path.join(base_path, f"rd_cdm_{version}.json") - try: - with open(output_path, "w") as json_file: - json.dump(rd_cdm_json, json_file, indent=2) - print(f"Final RD CDM JSON created successfully: {output_path}") - except IOError as e: - print(f"Failed to write final RD CDM JSON: {e}") + with open(output_path, "w") as json_file: + json.dump(rd_cdm_json, json_file, default=json_serializer, indent=2) + print(f"Final RD CDM JSON created successfully: {output_path}") - return rd_cdm_json # Return the final RD CDM JSON for testing - + return rd_cdm_json # Run the function for the desired version if __name__ == "__main__": create_final_rd_cdm_json("v2_0_0") diff --git a/src/parsing/create_value_sets_json.py b/src/parsing/create_value_sets_json.py index dac6fe2..f820d06 100644 --- a/src/parsing/create_value_sets_json.py +++ b/src/parsing/create_value_sets_json.py @@ -6,7 +6,9 @@ # Add the src directory to the system path sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) +from data_model.utils import json_serializer from src.data_model.value_set import ValueSet, ValueSetChoice +from src.data_model.base_types import Coding, CodeSystem def load_value_set_definitions(version): """Dynamically load the value sets for a given version.""" @@ -22,30 +24,33 @@ def load_value_set_definitions(version): def load_code_system_versions(version): """Dynamically load the code system versions for a given version.""" try: - # Dynamically load the code system version class module = importlib.import_module(f"src.{version}.rd_cdm_{version}_codesystems_versions") class_name = f"CODESYSTEMS_VERSIONS_{version.replace('.', '_').upper()}" version_class = getattr(module, class_name) - - # Ensure we're accessing the 'versions' dictionary directly - return version_class.versions # Access the dictionary directly + return version_class.versions except (ModuleNotFoundError, AttributeError) as e: print(f"Error loading code system version module for {version}: {e}") return {} -# Example usage -code_system_versions = load_code_system_versions("v2_0_0") -print(code_system_versions.get("SNOMED", "unknown")) # Should return '2024-09-01' +import os +import json +from data_model.utils import json_serializer def create_value_set_json(version): + """Create a JSON file for the value sets of a specified version.""" + + # Load value sets for the specified version value_sets = load_value_set_definitions(version) if value_sets is None: print(f"Failed to create value set JSON for {version}.") return + # Load code system versions for the specified version + code_system_versions = load_code_system_versions(version) + # Create a JSON structure for the value sets value_sets_json = { - "version": version, # Add version to comply with schema + "version": version, "dataElements": [], # Add dataElements as required by schema "valueSets": [ { @@ -53,15 +58,38 @@ def create_value_set_json(version): "valueSetOrigin": vs.valueSetOrigin, "valueSetLink": vs.valueSetLink, "display": vs.display, - "valueSetCode": vs.valueSetCode.code, # Assuming Coding object - "valueSetCodeSystem": vs.valueSetCodeSystem.namespace_prefix, - "valueSetCodeSystemVersion": code_system_versions.get(vs.valueSetCodeSystem.namespace_prefix, "unknown"), # Fetch version dynamically + "valueSetCode": vs.valueSetCode.code if isinstance( + vs.valueSetCode, Coding) else None, + + "valueSetCodeSystem": [ + { + "codeSystem": system.namespace_prefix, + "version": code_system_versions.get( + system.namespace_prefix, "unknown") + } + for system in vs.valueSetCodeSystem if isinstance( + vs.valueSetCodeSystem, list) + ] if isinstance(vs.valueSetCodeSystem, list) else [ + { + "codeSystem": vs.valueSetCodeSystem.namespace_prefix, + "version": code_system_versions.get( + vs.valueSetCodeSystem.namespace_prefix, "unknown") + } + ] if isinstance(vs.valueSetCodeSystem, CodeSystem) else None, + "valueSetChoices": [ { "choiceDisplay": choice.choiceDisplay, - "choiceCode": choice.choiceCode.code, - "choiceCodeSystem": choice.choiceCodeSystem.namespace_prefix, - "choiceCodeSystemVersion": code_system_versions.get(choice.choiceCodeSystem.namespace_prefix, "unknown") # Fetch version dynamically + "choiceCode": choice.choiceCode.code if isinstance( + choice.choiceCode, Coding) else None, + "choiceCodeSystem": + choice.choiceCodeSystem.namespace_prefix if + isinstance(choice.choiceCodeSystem, CodeSystem) + else None, + "choiceCodeSystemVersion": code_system_versions.get( + choice.choiceCodeSystem.namespace_prefix, "unknown" + ) if isinstance(choice.choiceCodeSystem, CodeSystem) + else "unknown" } for choice in vs.valueSetChoices ] @@ -70,12 +98,17 @@ def create_value_set_json(version): ] } + # Ensure the output directory exists + output_directory = f"res/{version}/" + os.makedirs(output_directory, exist_ok=True) + # Write the JSON file to the res folder - output_path = f"res/{version}/rd_cdm_value_sets_{version}.json" + output_path = os.path.join(output_directory, f"rd_cdm_value_sets_{version}.json") with open(output_path, "w") as json_file: - json.dump(value_sets_json, json_file, indent=2) + json.dump(value_sets_json, json_file, default=json_serializer, indent=2) print(f"JSON file created successfully: {output_path}") +# Example usage if __name__ == "__main__": create_value_set_json("v2_0_0") diff --git a/src/v2_0_0/rd_cdm_v2_0_0_data_elements.py b/src/v2_0_0/rd_cdm_v2_0_0_data_elements.py index b991c14..47858ef 100644 --- a/src/v2_0_0/rd_cdm_v2_0_0_data_elements.py +++ b/src/v2_0_0/rd_cdm_v2_0_0_data_elements.py @@ -1,8 +1,13 @@ from src.data_model.data_elements import DataElement from src.data_model.value_set import ValueSet -from src.data_model.base_types import CodeSystem, Coding, Date +from src.data_model.base_types import CodeSystem, Coding, Date, Code, String +from src.data_model.codesystems import CodeSystems + +# Define CodeSystems +SNOMED = CodeSystems.SNOMED +HL7FHIR = CodeSystems.HL7FHIR +GA4GH = CodeSystems.GA4GH -SNOMED = CodeSystem(name="SNOMED CT", namespace_prefix="SNOMED", url="https://www.snomed.org/snomed-ct") class DATA_ELEMENTS_VERSIONS_V2_0_0: """Data elements definitions for version 2_0_0.""" @@ -18,7 +23,9 @@ class DATA_ELEMENTS_VERSIONS_V2_0_0: dataSpecification=["n/a"], valueSet=None, fhirExpression_v4_0_1="Patient.identifier.value", + recommendedDataSpec_fhir="n/a", phenopacketSchemaElement_v2_0="Individual.id", + recommendedDataSpec_phenopackets="string", description="The (local) patient-related identification code." ), DataElement( @@ -27,11 +34,13 @@ class DATA_ELEMENTS_VERSIONS_V2_0_0: elementName="Date of Admission", elementCode=Coding(system=SNOMED, code="399423000"), elementCodeSystem=SNOMED, - dataType="Date", - dataSpecification=["YYYY-MM-DD", "ISO 8601"], + dataType=Date, + dataSpecification=["YYYY-MM-DD"], valueSet=None, fhirExpression_v4_0_1="Encounter.period.start", + recommendedDataSpec_fhir="n/a", phenopacketSchemaElement_v2_0="Individual.time_at_last_encounter", + recommendedDataSpec_phenopackets="TimeElement", description="The date of admission or data capture of the individual." ), DataElement( @@ -40,13 +49,13 @@ class DATA_ELEMENTS_VERSIONS_V2_0_0: elementName="Date of Birth", elementCode=Coding(system=SNOMED, code="184099003"), elementCodeSystem=SNOMED, - dataType="Date", + dataType=Date, dataSpecification=["YYYY", "YYYY-MM", "YYYY-MM-DD"], valueSet=None, fhirExpression_v4_0_1="Patient.birthDate", - recommendedVS_fhir=None, + recommendedDataSpec_fhir="n/a", phenopacketSchemaElement_v2_0="Individual.date_of_birth", - recommendedVS_phenopacket=None, + recommendedDataSpec_phenopackets="TimeElement", description="The individual's date of birth." ), DataElement( @@ -55,22 +64,209 @@ class DATA_ELEMENTS_VERSIONS_V2_0_0: elementName="Sex at Birth", elementCode=Coding(system=SNOMED, code="281053000"), elementCodeSystem=SNOMED, - dataType="Code", + dataType=Code, dataSpecification=["VSe / VSc"], - valueSet=ValueSet( - valueSetName="Sex at Birth Value Set v2.0.0", - valueSetOrigin="RD CDM v2.0.0", - valueSetLink="https://github.com/BIH-CEI/rd-cdm", - display="Sex at Birth", - valueSetCode=Coding(system=SNOMED, code="281053000"), - valueSetCodeSystem=SNOMED, - valueSetChoices=[] # Add the choices if required - ), + valueSet="Sex at Birth Value Set v2.0.0", fhirExpression_v4_0_1="Patient.extension:individual-recordedSexOrGender", - recommendedVS_fhir="Recorded Sex Or Gender Type", + recommendedDataSpec_fhir="Recorded Sex Or Gender Type", phenopacketSchemaElement_v2_0="Individual.sex", - recommendedVS_phenopacket="Sex", + recommendedDataSpec_phenopackets="Sex", description="The individual's sex that was assigned at birth." + ), + DataElement( + ordinal="2.3", + section="2. Personal Information", + elementName="Karyotypic Sex", + elementCode=Coding(system=SNOMED, code="1296886006"), + elementCodeSystem=SNOMED, + dataType=Code, + dataSpecification=["VSc"], + valueSet="Karyotypic Sex Value Set v2.0.0", + fhirExpression_v4_0_1="Observation.value", + recommendedDataSpec_fhir="n/a", + phenopacketSchemaElement_v2_0="Individual.karyotypic_sex", + recommendedDataSpec_phenopackets="Karyotypic Sex", + description="The chromosomal sex of an individual." + ), + DataElement( + ordinal="2.4", + section="2. Personal Information", + elementName="Gender Identity", + elementCode=Coding(system=SNOMED, code="263495000"), + elementCodeSystem=SNOMED, + dataType=Code, + dataSpecification=["VSe / VSc"], + valueSet="Gender Identity Value Set v2.0.0", + fhirExpression_v4_0_1="Patient.extension:individual-genderIdentity", + recommendedDataSpec_fhir="Gender Identity", + phenopacketSchemaElement_v2_0="Individual.gender", + recommendedDataSpec_phenopackets="OntologyClass", + description="The self-assigned gender of the individual." + ), + DataElement( + ordinal="2.5", + section="2. Personal Information", + elementName="Country of Birth", + elementCode=Coding(system=SNOMED, code="370159000"), + elementCodeSystem=SNOMED, + dataType=Code, + dataSpecification=["VS"], + valueSet=None, + fhirExpression_v4_0_1="Patient.extension:patient-birthPlace", + recommendedDataSpec_fhir="DataType: Address", + phenopacketSchemaElement_v2_0="n/a", + recommendedDataSpec_phenopackets="n/a", + description="The individual's country of birth." + ), + # Section 3: Patient Status + DataElement( + ordinal="3.1", + section="3. Patient Status", + elementName="Vital Status", + elementCode=Coding(system=SNOMED, code="278844005"), + elementCodeSystem=SNOMED, + dataType=Code, + dataSpecification=["VSe / VSc"], + valueSet="Vital Status Value Set v2.0.0", + fhirExpression_v4_0_1="Patient.deceased.deceasedBoolean|Observation.value", + recommendedDataSpec_fhir="Boolean|Code", + phenopacketSchemaElement_v2_0="Individual.VitalStatus.status", + recommendedDataSpec_phenopackets="Value Set: Status", + description="The individual’s general clinical status or vital status." + ), + DataElement( + ordinal="3.2", + section="3. Patient Status", + elementName="Time of Death", + elementCode=Coding(system=SNOMED, code="398299004"), + elementCodeSystem=SNOMED, + dataType=Date, + dataSpecification=["YYYY", "YYYY-MM", "YYYY-MM-DD"], + valueSet=None, + fhirExpression_v4_0_1="Patient.deceasedDateTime", + recommendedDataSpec_fhir="DateTime", + phenopacketSchemaElement_v2_0="Individual.VitalStatus.time_of_death", + recommendedDataSpec_phenopackets="TimeElement", + description="If deceased, the individual’s date of death." + ), + DataElement( + ordinal="3.3", + section="3. Patient Status", + elementName="Cause of Death", + elementCode=Coding(system=SNOMED, code="184305005"), + elementCodeSystem=SNOMED, + dataType=Code, + dataSpecification=["ICD-10CM"], + valueSet=None, + fhirExpression_v4_0_1="Observation.value.coding.code", + recommendedDataSpec_fhir="Code|CodeableConcept", + phenopacketSchemaElement_v2_0="Individual.VitalStatus.cause_of_death", + recommendedDataSpec_phenopackets="OntologyClass", + description="If deceased, the individual’s primary cause of death." + ), + DataElement( + ordinal="3.4", + section="3. Patient Status", + elementName="Age Category", + elementCode=Coding(system=SNOMED, code="105727008"), + elementCodeSystem=SNOMED, + dataType=Code, + dataSpecification=["VSe"], + valueSet="Age Category Value Set v2.0.0", + fhirExpression_v4_0_1="Observation.value.coding.code", + recommendedDataSpec_fhir="CodableConcept", + phenopacketSchemaElement_v2_0="Individual.time_at_last_encounter.ontology_class", + recommendedDataSpec_phenopackets="TimeElement", + description="The individual's age category at the time of data capture." + ), + DataElement( + ordinal="3.5", + section="3. Patient Status", + elementName="Length of Gestation at Birth [weeks+days]", + elementCode=Coding(system=SNOMED, code="412726003"), + elementCodeSystem=SNOMED, + dataType=String, + dataSpecification=["XX+X"], + valueSet=None, + fhirExpression_v4_0_1="Observation.component:weeks.valueQuantity|Observation.component:days.valueQuantity", + recommendedDataSpec_fhir="Quantity", + phenopacketSchemaElement_v2_0="n/a", + recommendedDataSpec_phenopackets="n/a", + description="The duration of the pregnancy in weeks and days, formatted as XX+X (weeks+days)." + ), + DataElement( + ordinal="3.6", + section="3. Patient Status", + elementName="Undiagnosed RD Case", + elementCode=Coding(system=SNOMED, code="723663001"), + elementCodeSystem=SNOMED, + dataType=Code, + dataSpecification=["VSe"], + valueSet="Undiagnosed RD Case Value Set v2.0.0", + fhirExpression_v4_0_1="(Condition.code)", + recommendedDataSpec_fhir="Code(e.g. ORDO:616874 - Rare disorder without a determined diagnosis after full investigation)", + phenopacketSchemaElement_v2_0="(Disease.term)", + recommendedDataSpec_phenopackets="(OntologyClass (e.g. ORDO:616874 - Rare disorder without a determined diagnosis after full investigation))", + description="Identifies cases where an RD diagnosis has not been established." + ), + DataElement( + ordinal="4.1", + section="4. Care Pathway", + elementName="Encounter Start", + elementCode=Coding(system=HL7FHIR, code="encounter.period.start"), + elementCodeSystem=HL7FHIR, + dataType=Date, + dataSpecification=["YYYY-MM-DD"], + valueSet=None, + fhirExpression_v4_0_1="Encounter.period.start", + recommendedDataSpec_fhir="DateTime", + phenopacketSchemaElement_v2_0="n/a", + recommendedDataSpec_phenopackets="n/a", + description="The beginning of an encounter of the individual." + ), + DataElement( + ordinal="4.2", + section="4. Care Pathway", + elementName="Encounter End", + elementCode=Coding(system=HL7FHIR, code="encounter.period.end"), + elementCodeSystem=HL7FHIR, + dataType=Date, + dataSpecification=["YYYY-MM-DD"], + valueSet=None, + fhirExpression_v4_0_1="Encounter.period.end", + recommendedDataSpec_fhir="DateTime", + phenopacketSchemaElement_v2_0="n/a", + recommendedDataSpec_phenopackets="n/a", + description="The end of an encounter of the individual." + ), + DataElement( + ordinal="4.3", + section="4. Care Pathway", + elementName="Encounter Status", + elementCode=Coding(system=SNOMED, code="305058001"), + elementCodeSystem=SNOMED, + dataType=Code, + dataSpecification=["VSe / VSc"], + valueSet="Encounter Status Value Set v2.0.0", + fhirExpression_v4_0_1="Encounter.status", + recommendedDataSpec_fhir="ValueSet: EncounterStatus", + phenopacketSchemaElement_v2_0="n/a", + recommendedDataSpec_phenopackets="n/a", + description="The status of an encounter of the individual at the time of data capture." + ), + DataElement( + ordinal="4.4", + section="4. Care Pathway", + elementName="Encounter Class", + elementCode=Coding(system=HL7FHIR, code="encounter.class"), + elementCodeSystem=HL7FHIR, + dataType=Code, + dataSpecification=["VSe / VSc"], + valueSet="Encounter Class Value Set v2.0.0", + fhirExpression_v4_0_1="Encounter.class", + recommendedDataSpec_fhir="ValueSet: EncounterClass", + phenopacketSchemaElement_v2_0="n/a", + recommendedDataSpec_phenopackets="n/a", + description="The class of an encounter of the individual at the time of data capture." ) ] - diff --git a/src/v2_0_0/rd_cdm_v2_0_0_value_sets.py b/src/v2_0_0/rd_cdm_v2_0_0_value_sets.py index 967afd6..6bfe2ea 100644 --- a/src/v2_0_0/rd_cdm_v2_0_0_value_sets.py +++ b/src/v2_0_0/rd_cdm_v2_0_0_value_sets.py @@ -1,10 +1,10 @@ from src.data_model.value_set import ValueSet, ValueSetChoice from src.data_model.base_types import CodeSystem, Coding +from src.data_model.codesystems import CodeSystems -# Example CodeSystem definitions -SNOMED = CodeSystem(name="SNOMED CT", namespace_prefix="SNOMED", url="https://www.snomed.org/snomed-ct") +SNOMED = CodeSystems.SNOMED +HL7FHIR = CodeSystems.HL7FHIR -# Define the value sets for v2_0_0 class VALUE_SETS_VERSIONS_V2_0_0: """Value set definitions for version 2_0_0.""" @@ -43,5 +43,397 @@ class VALUE_SETS_VERSIONS_V2_0_0: choiceCodeSystem=SNOMED ) ] - ) + ), + ValueSet( + valueSetName="Karyotypic Sex Value Set v2.0.0", + valueSetOrigin="RD CDM v2.0.0", + valueSetLink="https://github.com/your_repo_path/v2.0.0/value_sets_v2.0.0.json", + display="Karyotypic Sex", + valueSetCode=Coding(system=SNOMED, code="1296886006"), + valueSetCodeSystem=SNOMED, + valueSetChoices=[ + ValueSetChoice( + choiceDisplay="XX", + choiceCode=Coding(system=SNOMED, code="734875008"), + choiceCodeSystem=SNOMED + ), + ValueSetChoice( + choiceDisplay="XY", + choiceCode=Coding(system=SNOMED, code="734876009"), + choiceCodeSystem=SNOMED + ), + ValueSetChoice( + choiceDisplay="X0", + choiceCode=Coding(system=SNOMED, code="80427008"), + choiceCodeSystem=SNOMED + ), + ValueSetChoice( + choiceDisplay="XXY", + choiceCode=Coding(system=SNOMED, code="65162001"), + choiceCodeSystem=SNOMED + ), + ValueSetChoice( + choiceDisplay="XXX", + choiceCode=Coding(system=SNOMED, code="35111009"), + choiceCodeSystem=SNOMED + ), + ValueSetChoice( + choiceDisplay="XXYY", + choiceCode=Coding(system=SNOMED, code="403760006"), + choiceCodeSystem=SNOMED + ), + ValueSetChoice( + choiceDisplay="XXXY", + choiceCode=Coding(system=SNOMED, code="78317008"), + choiceCodeSystem=SNOMED + ), + ValueSetChoice( + choiceDisplay="XXXX", + choiceCode=Coding(system=SNOMED, code="10567003"), + choiceCodeSystem=SNOMED + ), + ValueSetChoice( + choiceDisplay="XYY", + choiceCode=Coding(system=SNOMED, code="48930007"), + choiceCodeSystem=SNOMED + ), + ValueSetChoice( + choiceDisplay="Other", + choiceCode=Coding(system=SNOMED, code="74964007"), + choiceCodeSystem=SNOMED + ) + ] + ), + ValueSet( + valueSetName="Gender Identity Value Set v2.0.0", + valueSetOrigin="RD CDM v2.0.0", + valueSetLink="https://github.com/your_repo_path/v2.0.0/value_sets_v2.0.0.json", + display="Gender Identity", + valueSetCode=Coding(system=SNOMED, code="263495000"), + valueSetCodeSystem=SNOMED, + valueSetChoices=[ + ValueSetChoice( + choiceDisplay="Female gender identity", + choiceCode=Coding(system=SNOMED, code="446141000124107"), + choiceCodeSystem=SNOMED + ), + ValueSetChoice( + choiceDisplay="Male gender identity", + choiceCode=Coding(system=SNOMED, code="446151000124109"), + choiceCodeSystem=SNOMED + ), + ValueSetChoice( + choiceDisplay="Gender unknown", + choiceCode=Coding(system=SNOMED, code="394743007"), + choiceCodeSystem=SNOMED + ), + ValueSetChoice( + choiceDisplay="Identifies as nonbinary gender", + choiceCode=Coding(system=SNOMED, code="33791000087105"), + choiceCodeSystem=SNOMED + ), + ValueSetChoice( + choiceDisplay="Not recorded", + choiceCode=Coding(system=SNOMED, code="1220561009"), + choiceCodeSystem=SNOMED + ) + ] + ), + ValueSet( + valueSetName="Vital Status Value Set v2.0.0", + valueSetOrigin="RD CDM v2.0.0", + valueSetLink="https://github.com/your_repo_path/v2.0.0/value_sets_v2.0.0.json", + display="Vital Status", + valueSetCode=Coding(system=SNOMED, code="278844005"), + valueSetCodeSystem=SNOMED, + valueSetChoices=[ + ValueSetChoice( + choiceDisplay="Alive", + choiceCode=Coding(system=SNOMED, code="438949009"), + choiceCodeSystem=SNOMED + ), + ValueSetChoice( + choiceDisplay="Dead", + choiceCode=Coding(system=SNOMED, code="419099009"), + choiceCodeSystem=SNOMED + ), + ValueSetChoice( + choiceDisplay="Unknown - Lost in follow-up", + choiceCode=Coding(system=SNOMED, code="399307001"), + choiceCodeSystem=SNOMED + ), + ValueSetChoice( + choiceDisplay="Unknown - Opted-out", + choiceCode=Coding(system=SNOMED, code="185924006"), + choiceCodeSystem=SNOMED + ), + ValueSetChoice( + choiceDisplay="Unknown - Other Reason", + choiceCode=Coding(system=SNOMED, code="261665006"), + choiceCodeSystem=SNOMED + ) + ] + ), + ValueSet( + valueSetName="Age Category Value Set v2.0.0", + valueSetOrigin="RD CDM v2.0.0", + valueSetLink="https://github.com/your_repo_path/v2.0.0/value_sets_v2.0.0.json", + display="Age Category", + valueSetCode=Coding(system=SNOMED, code="105727008"), + valueSetCodeSystem=SNOMED, + valueSetChoices=[ + ValueSetChoice( + choiceDisplay="Infancy", + choiceCode=Coding(system=SNOMED, code="3658006"), + choiceCodeSystem=SNOMED + ), + ValueSetChoice( + choiceDisplay="Toddler", + choiceCode=Coding(system=SNOMED, code="713153009"), + choiceCodeSystem=SNOMED + ), + ValueSetChoice( + choiceDisplay="Childhood", + choiceCode=Coding(system=SNOMED, code="255398004"), + choiceCodeSystem=SNOMED + ), + ValueSetChoice( + choiceDisplay="Adolescence", + choiceCode=Coding(system=SNOMED, code="263659003"), + choiceCodeSystem=SNOMED + ), + ValueSetChoice( + choiceDisplay="Adulthood", + choiceCode=Coding(system=SNOMED, code="41847000"), + choiceCodeSystem=SNOMED + ), + ValueSetChoice( + choiceDisplay="Fetal period", + choiceCode=Coding(system=SNOMED, code="303112003"), + choiceCodeSystem=SNOMED + ), + ValueSetChoice( + choiceDisplay="Dead", + choiceCode=Coding(system=SNOMED, code="419099009"), + choiceCodeSystem=SNOMED + ), + ValueSetChoice( + choiceDisplay="Unknown", + choiceCode=Coding(system=SNOMED, code="261665006"), + choiceCodeSystem=SNOMED + ) + ] + ), + ValueSet( + valueSetName="Vital Status Value Set v2.0.0", + valueSetOrigin="RD CDM v2.0.0", + valueSetLink="https://github.com/your_repo_path/v2.0.0/value_sets_v2.0.0.json", + display="Vital Status", + valueSetCode=Coding(system=SNOMED, code="278844005"), + valueSetCodeSystem=SNOMED, + valueSetChoices=[ + ValueSetChoice( + choiceDisplay="Alive", + choiceCode=Coding(system=SNOMED, code="438949009"), + choiceCodeSystem=SNOMED + ), + ValueSetChoice( + choiceDisplay="Dead", + choiceCode=Coding(system=SNOMED, code="419099009"), + choiceCodeSystem=SNOMED + ), + ValueSetChoice( + choiceDisplay="Unknown - Lost in follow-up", + choiceCode=Coding(system=SNOMED, code="399307001"), + choiceCodeSystem=SNOMED + ), + ValueSetChoice( + choiceDisplay="Unknown - Opted-out", + choiceCode=Coding(system=SNOMED, code="185924006"), + choiceCodeSystem=SNOMED + ), + ValueSetChoice( + choiceDisplay="Unknown - Other Reason", + choiceCode=Coding(system=SNOMED, code="261665006"), + choiceCodeSystem=SNOMED + ) + ] + ), + ValueSet( + valueSetName="Age Category Value Set v2.0.0", + valueSetOrigin="RD CDM v2.0.0", + valueSetLink="https://github.com/your_repo_path/v2.0.0/value_sets_v2.0.0.json", + display="Age Category", + valueSetCode=Coding(system=SNOMED, code="105727008"), + valueSetCodeSystem=SNOMED, + valueSetChoices=[ + ValueSetChoice( + choiceDisplay="Infancy", + choiceCode=Coding(system=SNOMED, code="3658006"), + choiceCodeSystem=SNOMED + ), + ValueSetChoice( + choiceDisplay="Toddler", + choiceCode=Coding(system=SNOMED, code="713153009"), + choiceCodeSystem=SNOMED + ), + ValueSetChoice( + choiceDisplay="Childhood", + choiceCode=Coding(system=SNOMED, code="255398004"), + choiceCodeSystem=SNOMED + ), + ValueSetChoice( + choiceDisplay="Adolescence", + choiceCode=Coding(system=SNOMED, code="263659003"), + choiceCodeSystem=SNOMED + ), + ValueSetChoice( + choiceDisplay="Adulthood", + choiceCode=Coding(system=SNOMED, code="41847000"), + choiceCodeSystem=SNOMED + ), + ValueSetChoice( + choiceDisplay="Fetal period", + choiceCode=Coding(system=SNOMED, code="303112003"), + choiceCodeSystem=SNOMED + ), + ValueSetChoice( + choiceDisplay="Dead", + choiceCode=Coding(system=SNOMED, code="419099009"), + choiceCodeSystem=SNOMED + ), + ValueSetChoice( + choiceDisplay="Unknown", + choiceCode=Coding(system=SNOMED, code="261665006"), + choiceCodeSystem=SNOMED + ) + ] + ), + ValueSet( + valueSetName="Undiagnosed RD Case Value Set v2.0.0", + valueSetOrigin="RD CDM v2.0.0", + valueSetLink="https://github.com/your_repo_path/v2.0.0/value_sets_v2.0.0.json", + display="Undiagnosed RD Case", + valueSetCode=Coding(system=SNOMED, code="723663001"), + valueSetCodeSystem=SNOMED, + valueSetChoices=[ + ValueSetChoice( + choiceDisplay="Yes", + choiceCode=Coding(system=SNOMED, code="373066001"), + choiceCodeSystem=SNOMED + ), + ValueSetChoice( + choiceDisplay="No", + choiceCode=Coding(system=SNOMED, code="373067005"), + choiceCodeSystem=SNOMED + ) + ] + ), + # 4. Care Pathway + ValueSet( + valueSetName="Encounter Status Value Set v2.0.0", + valueSetOrigin="RD CDM v2.0.0", + valueSetLink="https://github.com/your_repo_path/v2.0.0/value_sets_v2.0.0.json", + display="Encounter Status", + valueSetCode=Coding(system=SNOMED, code="305058001"), + valueSetCodeSystem=SNOMED, + valueSetChoices=[ + ValueSetChoice( + choiceDisplay="Planned", + choiceCode=Coding(system=HL7FHIR, code="planned"), + choiceCodeSystem=HL7FHIR + ), + ValueSetChoice( + choiceDisplay="Arrived", + choiceCode=Coding(system=HL7FHIR, code="arrived"), + choiceCodeSystem=HL7FHIR + ), + ValueSetChoice( + choiceDisplay="Triaged", + choiceCode=Coding(system=HL7FHIR, code="triaged"), + choiceCodeSystem=HL7FHIR + ), + ValueSetChoice( + choiceDisplay="In Progress", + choiceCode=Coding(system=HL7FHIR, code="in-progress"), + choiceCodeSystem=HL7FHIR + ), + ValueSetChoice( + choiceDisplay="On Leave", + choiceCode=Coding(system=HL7FHIR, code="onleave"), + choiceCodeSystem=HL7FHIR + ), + ValueSetChoice( + choiceDisplay="Finished", + choiceCode=Coding(system=HL7FHIR, code="finished"), + choiceCodeSystem=HL7FHIR + ), + ValueSetChoice( + choiceDisplay="Cancelled", + choiceCode=Coding(system=HL7FHIR, code="cancelled"), + choiceCodeSystem=HL7FHIR + ), + ValueSetChoice( + choiceDisplay="Entered in Error", + choiceCode=Coding(system=HL7FHIR, code="entered-in-error"), + choiceCodeSystem=HL7FHIR + ), + ValueSetChoice( + choiceDisplay="Unknown", + choiceCode=Coding(system=HL7FHIR, code="unknown"), + choiceCodeSystem=HL7FHIR + ) + ] + ), + ValueSet( + valueSetName="Encounter Class Value Set v2.0.0", + valueSetOrigin="RD CDM v2.0.0", + valueSetLink="https://github.com/your_repo_path/v2.0.0/value_sets_v2.0.0.json", + display="Encounter Class", + valueSetCode=Coding(system=HL7FHIR, code="encounter.class"), + valueSetCodeSystem=[HL7FHIR, SNOMED], + valueSetChoices=[ + ValueSetChoice( + choiceDisplay="Ambulatory", + choiceCode=Coding(system=HL7FHIR, code="AMB"), + choiceCodeSystem=HL7FHIR + ), + ValueSetChoice( + choiceDisplay="Inpatient", + choiceCode=Coding(system=HL7FHIR, code="IMP"), + choiceCodeSystem=HL7FHIR + ), + ValueSetChoice( + choiceDisplay="Observation", + choiceCode=Coding(system=HL7FHIR, code="OBSENC"), + choiceCodeSystem=HL7FHIR + ), + ValueSetChoice( + choiceDisplay="Emergency", + choiceCode=Coding(system=HL7FHIR, code="EMER"), + choiceCodeSystem=HL7FHIR + ), + ValueSetChoice( + choiceDisplay="Virtual", + choiceCode=Coding(system=HL7FHIR, code="VR"), + choiceCodeSystem=HL7FHIR + ), + ValueSetChoice( + choiceDisplay="Home Health", + choiceCode=Coding(system=HL7FHIR, code="HH"), + choiceCodeSystem=HL7FHIR + ), + ValueSetChoice( + choiceDisplay="RD Specialist Center", + choiceCode=Coding(system=HL7FHIR, code="RDC"), + choiceCodeSystem=HL7FHIR + ), + ValueSetChoice( + choiceDisplay="Unknown", + choiceCode=Coding(system=SNOMED, code="261665006"), + choiceCodeSystem=SNOMED + ) + ] + ), ] + \ No newline at end of file diff --git a/tests/parsing/test_create_codesystems_json.py b/tests/parsing/test_create_codesystems_json.py index 694cb52..28f9f31 100644 --- a/tests/parsing/test_create_codesystems_json.py +++ b/tests/parsing/test_create_codesystems_json.py @@ -13,17 +13,21 @@ def setUp(self): def test_create_codesystem_json(self): """Test if the code systems JSON file is correctly created.""" + # Call the function that generates the JSON file create_codesystem_json(self.version) + + # Check if the output file was created self.assertTrue(os.path.exists(self.output_file), "Output file not created") + + # Open and read the output file with open(self.output_file, 'r') as f: data = json.load(f) + + # Check that the data is a dictionary and contains "CodeSystems" self.assertIsInstance(data, dict) self.assertIn("CodeSystems", data) - # def tearDown(self): - # """Clean up after tests.""" - # if os.path.exists(self.output_file): - # os.remove(self.output_file) + # Further checks can be added to validate the content if necessary if __name__ == "__main__": unittest.main() diff --git a/tests/parsing/test_create_data_elements_json.py b/tests/parsing/test_create_data_elements_json.py index 2392aca..f22402c 100644 --- a/tests/parsing/test_create_data_elements_json.py +++ b/tests/parsing/test_create_data_elements_json.py @@ -20,10 +20,10 @@ def test_create_data_elements_json(self): self.assertIsInstance(data, dict) self.assertIn("dataElements", data) - # def tearDown(self): - # """Clean up after tests.""" - # if os.path.exists(self.output_file): - # os.remove(self.output_file) + for element in data["dataElements"]: + self.assertIn("dataType", element) + self.assertIsInstance(element["dataType"], str) if __name__ == "__main__": unittest.main() + diff --git a/tests/parsing/test_create_rd_cdm_json.py b/tests/parsing/test_create_rd_cdm_json.py index ef4a913..bf2bc6c 100644 --- a/tests/parsing/test_create_rd_cdm_json.py +++ b/tests/parsing/test_create_rd_cdm_json.py @@ -12,11 +12,15 @@ def setUp(self): self.output_file = f"res/{self.version}/rd_cdm_{self.version}.json" def test_create_final_rd_cdm_json(self): - """Test if the final RD CDM JSON file is correctly created.""" - # Create the final RD CDM JSON + """Test if the final RD CDM JSON file is correctly created. + + This test is a combination of the tests for the individual JSON files + (code systems, data elements, and value sets) that are combined to create + the final RD CDM JSON file. + """ result = create_final_rd_cdm_json(self.version) - # Check if the file was created + self.assertTrue(os.path.exists(self.output_file), "Output file not created") # Check if the function returned the combined JSON @@ -35,11 +39,5 @@ def test_create_final_rd_cdm_json(self): self.assertIn("dataElements", data) self.assertIn("valueSets", data) - - # def tearDown(self): - # """Clean up after tests.""" - # if os.path.exists(self.output_file): - # os.remove(self.output_file) - if __name__ == "__main__": unittest.main() diff --git a/tests/parsing/test_create_value_sets_json.py b/tests/parsing/test_create_value_sets_json.py index 18a4fe5..4c57c45 100644 --- a/tests/parsing/test_create_value_sets_json.py +++ b/tests/parsing/test_create_value_sets_json.py @@ -13,17 +13,24 @@ def setUp(self): def test_create_value_sets_json(self): """Test if the value sets JSON file is correctly created.""" + # Call the function to create the value sets JSON create_value_set_json(self.version) + + # Check if the file was created self.assertTrue(os.path.exists(self.output_file), "Output file not created") + + # Open and load the created JSON file with open(self.output_file, 'r') as f: data = json.load(f) - self.assertIsInstance(data, dict) - self.assertIn("valueSets", data) - - # def tearDown(self): - # """Clean up after tests.""" - # if os.path.exists(self.output_file): - # os.remove(self.output_file) + + # Assert that the data is a dictionary + self.assertIsInstance(data, dict, "Output is not a dictionary") + + # Check if "valueSets" key is present in the JSON + self.assertIn("valueSets", data, "'valueSets' not found in JSON") + + # Optional: Check if the version is correctly set in the JSON + self.assertEqual(data.get("version"), self.version, "Version mismatch in JSON") if __name__ == "__main__": unittest.main() diff --git a/tests/parsing/test_validate_json_schema.py b/tests/parsing/test_validate_json_schema.py index 5305099..52e0bf5 100644 --- a/tests/parsing/test_validate_json_schema.py +++ b/tests/parsing/test_validate_json_schema.py @@ -3,17 +3,13 @@ from jsonschema import validate, ValidationError import os -# Base directory where the res and schema folders are located BASE_DIR = os.path.dirname(os.path.abspath(__file__)) -# List of JSON files to validate with corresponding schemas -# Path to the schema files CODE_SYSTEMS_SCHEMA = "schemas/rd_cdm_code_systems_schema.json" DATA_ELEMENTS_SCHEMA = "schemas/rd_cdm_data_elements_schema.json" VALUE_SETS_SCHEMA = "schemas/rd_cdm_value_sets_schema.json" FULL_MODEL_SCHEMA = "schemas/rd_cdm_v2_0_0_schema.json" -# List of JSON files and their corresponding schema JSON_FILES_AND_SCHEMAS = [ ("res/v2_0_0/rd_cdm_codesystems_v2_0_0.json", CODE_SYSTEMS_SCHEMA), ("res/v2_0_0/rd_cdm_data_elements_v2_0_0.json", DATA_ELEMENTS_SCHEMA), @@ -32,9 +28,16 @@ def test_validate_json_file(json_file, schema_file): data = json.load(jf) validate(instance=data, schema=schema) + except FileNotFoundError: pytest.fail(f"File not found: {json_file}") + except json.JSONDecodeError as e: pytest.fail(f"Invalid JSON format in {json_file}: {e.msg}") + except ValidationError as e: + print(f"Validation failed for {json_file}: {e.message}") + print(f"Error in data element: {e.instance}") # The problematic element + print(f"Error in schema part: {e.schema}") # The part of the schema causing the issue + print(f"Validation path: {e.path}") # The path in the JSON where the error occurred pytest.fail(f"Validation failed for {json_file}: {e.message}")