Skip to content

Commit

Permalink
add in lifestyle of socioeconmic
Browse files Browse the repository at this point in the history
  • Loading branch information
calmacx committed Oct 4, 2023
1 parent 13428fe commit 1c774bb
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 9 deletions.
41 changes: 39 additions & 2 deletions hdr_schemata/models/GWDM/1.1/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,28 @@
"lifestyle": {
"anyOf": [
{
"$ref": "#/$defs/LongDescription"
"$ref": "#/$defs/Lifestyles"
},
{
"type": "null"
}
],
"default": null,
"description": "Description of cohort lifestyle habits: Smoking, Physical activity, Dietary habits, Alcohol",
"description": "Cohort lifestyle habits: Smoking, Physical activity, Dietary habits, Alcohol",
"title": "Lifestyle"
},
"socioeconomic": {
"anyOf": [
{
"$ref": "#/$defs/SocioEconomic"
},
{
"type": "null"
}
],
"default": null,
"description": "Description of Occupation, Family circumstances, Housing, Education, Ethnic group, Martial status, Social support",
"title": "Socio-economic"
}
},
"title": "Coverage",
Expand Down Expand Up @@ -614,6 +627,18 @@
"title": "FormatAndStandards",
"type": "object"
},
"Lifestyles": {
"anyOf": [
{
"pattern": "\\b(?:Smoking|Dietary Habits|Physical Activity|Alcohol)(?:,(?:Smoking|Dietary Habits|Physical Activity|Alcohol))*\\b",
"type": "string"
},
{
"type": "null"
}
],
"title": "Lifestyles"
},
"Linkage": {
"additionalProperties": false,
"properties": {
Expand Down Expand Up @@ -1043,6 +1068,18 @@
],
"title": "ShortTitle"
},
"SocioEconomic": {
"anyOf": [
{
"pattern": "\\b(?:Finances|Family Circumstances|Housing|Education|Marital Status|Occupation|Ethnic Group|Social Support)(?:,(?:Finances|Family Circumstances|Housing|Education|Marital Status|Occupation|Ethnic Group|Social Support))*\\b",
"type": "string"
},
{
"type": "null"
}
],
"title": "SocioEconomic"
},
"StatisticalPopulationConstrained": {
"enum": [
"PERSONS",
Expand Down
41 changes: 39 additions & 2 deletions hdr_schemata/models/GWDM/latest/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,28 @@
"lifestyle": {
"anyOf": [
{
"$ref": "#/$defs/LongDescription"
"$ref": "#/$defs/Lifestyles"
},
{
"type": "null"
}
],
"default": null,
"description": "Description of cohort lifestyle habits: Smoking, Physical activity, Dietary habits, Alcohol",
"description": "Cohort lifestyle habits: Smoking, Physical activity, Dietary habits, Alcohol",
"title": "Lifestyle"
},
"socioeconomic": {
"anyOf": [
{
"$ref": "#/$defs/SocioEconomic"
},
{
"type": "null"
}
],
"default": null,
"description": "Description of Occupation, Family circumstances, Housing, Education, Ethnic group, Martial status, Social support",
"title": "Socio-economic"
}
},
"title": "Coverage",
Expand Down Expand Up @@ -614,6 +627,18 @@
"title": "FormatAndStandards",
"type": "object"
},
"Lifestyles": {
"anyOf": [
{
"pattern": "\\b(?:Smoking|Dietary Habits|Physical Activity|Alcohol)(?:,(?:Smoking|Dietary Habits|Physical Activity|Alcohol))*\\b",
"type": "string"
},
{
"type": "null"
}
],
"title": "Lifestyles"
},
"Linkage": {
"additionalProperties": false,
"properties": {
Expand Down Expand Up @@ -1043,6 +1068,18 @@
],
"title": "ShortTitle"
},
"SocioEconomic": {
"anyOf": [
{
"pattern": "\\b(?:Finances|Family Circumstances|Housing|Education|Marital Status|Occupation|Ethnic Group|Social Support)(?:,(?:Finances|Family Circumstances|Housing|Education|Marital Status|Occupation|Ethnic Group|Social Support))*\\b",
"type": "string"
},
{
"type": "null"
}
],
"title": "SocioEconomic"
},
"StatisticalPopulationConstrained": {
"enum": [
"PERSONS",
Expand Down
50 changes: 45 additions & 5 deletions hdr_schemata/models/GWDM/v1_1.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,50 @@
from hdr_schemata.models.GWDM import Gwdm10
from hdr_schemata.models.GWDM.base import Coverage as BaseCoverage
from hdr_schemata.definitions.HDRUK import LongDescription
from hdr_schemata.definitions.HDRUK import LongDescription,CommaSeparatedValues
import re
from typing import Optional,List
from pydantic import Field, BaseModel, RootModel, constr

from typing import Optional
from pydantic import Field
#'Anthropometric': ['waist circumference', 'weight', 'blood pressure', 'hip circumference', 'height'], 'Physical': ['respiratory', 'vision', 'hearing ', 'musculoskeletal', 'cardiovascular', 'reproductive'], 'Psychological': ['cognitive function', 'mental health'], 'Lifestyle': ['Smoking', 'dietary habits', 'physical activity', 'alcohol', 'smoking'], 'Socio-economic': ['finances', 'family circumstances', 'housing', 'education', 'marital status', 'occupation', 'ethnic group', 'social support'], 'Biological samples': ['blood', 'other', 'urine', 'saliva']}

def get_pattern(allowed_phrases):
return r'\b(?:' + '|'.join(allowed_phrases) + r')(?:,(?:' + '|'.join(allowed_phrases) + r'))*\b'

class Lifestyles(RootModel):
root: Optional[constr(pattern=get_pattern(
[
'Smoking',
'Dietary Habits',
'Physical Activity',
'Alcohol'
]))]

class SocioEconomic(RootModel):
root: Optional[constr(pattern=get_pattern(
[
'Finances',
'Family Circumstances',
'Housing',
'Education',
'Marital Status',
'Occupation',
'Ethnic Group',
'Social Support'
]))]


class Coverage(BaseCoverage):
lifestyle: Optional[LongDescription] = Field(
lifestyle: Optional[Lifestyles] = Field(
None,
title='Lifestyle',
description='Description of cohort lifestyle habits: Smoking, Physical activity, Dietary habits, Alcohol'
description='Cohort lifestyle habits: Smoking, Physical activity, Dietary habits, Alcohol'
)


socioeconomic: Optional[SocioEconomic] = Field(
None,
title='Socio-economic',
description='Description of Occupation, Family circumstances, Housing, Education, Ethnic group, Martial status, Social support'
)


Expand All @@ -21,3 +55,9 @@ class Gwdm11(Gwdm10):
description='Spatial and Temporal coverage',
title='Coverage',
)


#data = {'lifestyle':'Smoking, Alcohol ,Dietary Habits'}
#Coverage(**data)


0 comments on commit 1c774bb

Please sign in to comment.