Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update origin fields to be enum lists only #34

Merged
merged 2 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 69 additions & 69 deletions docs/HDRUK/2.2.1.md

Large diffs are not rendered by default.

67 changes: 29 additions & 38 deletions docs/HDRUK/2.2.1.structure.json
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@
"examples": null,
"type": [
"EmailAddress[{'anyOf': [{'format': 'email', 'type': 'string'}, {'type': 'null'}]}]",
"typing.List[typing.Optional[hdr_schemata.definitions.HDRUK.EmailAddress.EmailAddress]]",
"List",
"null"
],
"is_list": false,
Expand Down Expand Up @@ -267,7 +267,7 @@
],
"type": [
"CommaSeparatedValues[{'anyOf': [{'pattern': '([^,]+)', 'type': 'string'}, {'type': 'null'}]}]",
"typing.List[hdr_schemata.definitions.HDRUK.OneHundredFiftyCharacters.OneHundredFiftyCharacters]",
"List",
"null"
],
"is_list": false,
Expand All @@ -282,7 +282,7 @@
"examples": null,
"type": [
"CommaSeparatedValues[{'anyOf': [{'pattern': '([^,]+)', 'type': 'string'}, {'type': 'null'}]}]",
"typing.List[typing.Optional[hdr_schemata.definitions.HDRUK.ShortDescription.ShortDescription]]",
"List",
"null"
],
"is_list": false,
Expand Down Expand Up @@ -385,7 +385,7 @@
],
"type": [
"CommaSeparatedValues[{'anyOf': [{'pattern': '([^,]+)', 'type': 'string'}, {'type': 'null'}]}]",
"typing.List[typing.Optional[hdr_schemata.definitions.HDRUK.Url.Url]]",
"List",
"null"
],
"is_list": false,
Expand All @@ -402,7 +402,7 @@
],
"type": [
"CommaSeparatedValues[{'anyOf': [{'pattern': '([^,]+)', 'type': 'string'}, {'type': 'null'}]}]",
"typing.List[typing.Union[hdr_schemata.definitions.HDRUK.Url.Url, NoneType, hdr_schemata.definitions.HDRUK.OneHundredFiftyCharacters.OneHundredFiftyCharacters, hdr_schemata.definitions.HDRUK.IsPartOfEnum.IsPartOfEnum]]",
"List",
"null"
],
"is_list": false,
Expand Down Expand Up @@ -434,7 +434,7 @@
],
"type": [
"CommaSeparatedValues[{'anyOf': [{'pattern': '([^,]+)', 'type': 'string'}, {'type': 'null'}]}]",
"typing.List[typing.Optional[hdr_schemata.definitions.HDRUK.Url.Url]]",
"List",
"null"
],
"is_list": false,
Expand Down Expand Up @@ -601,13 +601,10 @@
"description": "Please indicate the purpose(s) that the dataset was collected.",
"examples": null,
"type": [
"CommaSeparatedValues[{'anyOf': [{'pattern': '([^,]+)', 'type': 'string'}, {'type': 'null'}]}]",
"typing.List[hdr_schemata.definitions.HDRUK.Purpose.Purpose]",
"null"
"Purpose['STUDY','DISEASE REGISTRY','TRIAL','CARE','AUDIT','ADMINISTRATIVE','FINANCIAL','STATUTORY','OTHER',null]"
],
"is_list": false,
"is_optional": true,
"subItems": []
"is_list": true,
"is_optional": true
},
{
"name": "source",
Expand All @@ -616,13 +613,10 @@
"description": "Please indicate the source of the data extraction",
"examples": null,
"type": [
"CommaSeparatedValues[{'anyOf': [{'pattern': '([^,]+)', 'type': 'string'}, {'type': 'null'}]}]",
"typing.List[hdr_schemata.definitions.HDRUK.Source.Source]",
"null"
"Source['EPR','ELECTRONIC SURVEY','LIMS','OTHER INFORMATION SYSTEM','PAPER BASED','FREETEXT NLP','MACHINE GENERATED','OTHER']"
],
"is_list": false,
"is_optional": true,
"subItems": []
"is_list": true,
"is_optional": true
},
{
"name": "collectionSituation",
Expand All @@ -631,13 +625,10 @@
"description": "Please indicate the setting(s) where data was collected. Multiple settings may be provided",
"examples": null,
"type": [
"CommaSeparatedValues[{'anyOf': [{'pattern': '([^,]+)', 'type': 'string'}, {'type': 'null'}]}]",
"typing.List[hdr_schemata.definitions.HDRUK.Setting.Setting]",
"null"
"Setting['CLINIC','PRIMARY CARE','ACCIDENT AND EMERGENCY','OUTPATIENTS','IN-PATIENTS','SERVICES','COMMUNITY','HOME','PRIVATE','PHARMACY','SOCIAL CARE','LOCAL AUTHORITY','NATIONAL GOVERNMENT','OTHER']"
],
"is_list": false,
"is_optional": true,
"subItems": []
"is_list": true,
"is_optional": true
}
]
},
Expand Down Expand Up @@ -758,7 +749,7 @@
"examples": null,
"type": [
"CommaSeparatedValues[{'anyOf': [{'pattern': '([^,]+)', 'type': 'string'}, {'type': 'null'}]}]",
"typing.List[hdr_schemata.definitions.HDRUK.DataUseLimitation.DataUseLimitation]",
"List",
"null"
],
"is_list": false,
Expand All @@ -773,7 +764,7 @@
"examples": null,
"type": [
"CommaSeparatedValues[{'anyOf': [{'pattern': '([^,]+)', 'type': 'string'}, {'type': 'null'}]}]",
"typing.List[hdr_schemata.definitions.HDRUK.DataUseRequirements.DataUseRequirements]",
"List",
"null"
],
"is_list": false,
Expand All @@ -788,7 +779,7 @@
"examples": null,
"type": [
"ShortDescription[{'anyOf': [{'maxLength': 1000, 'minLength': 2, 'type': 'string'}, {'type': 'null'}]}]",
"typing.List[typing.Optional[hdr_schemata.definitions.HDRUK.ShortDescription.ShortDescription]]",
"List",
"null"
],
"is_list": false,
Expand All @@ -803,7 +794,7 @@
"examples": null,
"type": [
"CommaSeparatedValues[{'anyOf': [{'pattern': '([^,]+)', 'type': 'string'}, {'type': 'null'}]}]",
"typing.List[typing.Optional[hdr_schemata.definitions.HDRUK.Url.Url]]",
"List",
"null"
],
"is_list": false,
Expand All @@ -819,7 +810,7 @@
"type": [
"Doi[{'anyOf': [{'pattern': '^10.\\\\d{4,9}/[-._;()/:a-zA-Z0-9]+$', 'type': 'string'}, {'type': 'null'}]}]",
"str",
"typing.List[typing.Optional[hdr_schemata.definitions.HDRUK.Doi.Doi]]",
"List",
"null"
],
"is_list": false,
Expand Down Expand Up @@ -878,7 +869,7 @@
"examples": null,
"type": [
"LongDescription[{'anyOf': [{'maxLength': 50000, 'minLength': 2, 'type': 'string'}, {'type': 'null'}]}]",
"typing.List[typing.Optional[hdr_schemata.definitions.HDRUK.Url.Url]]",
"List",
"null"
],
"is_list": false,
Expand Down Expand Up @@ -906,7 +897,7 @@
"examples": null,
"type": [
"CommaSeparatedValues[{'anyOf': [{'pattern': '([^,]+)', 'type': 'string'}, {'type': 'null'}]}]",
"typing.List[hdr_schemata.definitions.HDRUK.Isocountrycode.Isocountrycode]",
"List",
"null"
],
"is_list": false,
Expand Down Expand Up @@ -978,7 +969,7 @@
"examples": null,
"type": [
"CommaSeparatedValues[{'anyOf': [{'pattern': '([^,]+)', 'type': 'string'}, {'type': 'null'}]}]",
"typing.List[hdr_schemata.definitions.HDRUK.ControlledVocabulary.ControlledVocabulary]",
"List",
"null"
],
"is_list": false,
Expand All @@ -993,7 +984,7 @@
"examples": null,
"type": [
"CommaSeparatedValues[{'anyOf': [{'pattern': '([^,]+)', 'type': 'string'}, {'type': 'null'}]}]",
"typing.List[hdr_schemata.definitions.HDRUK.StandardisedDataModels.StandardisedDataModels]",
"List",
"null"
],
"is_list": false,
Expand All @@ -1008,7 +999,7 @@
"examples": null,
"type": [
"CommaSeparatedValues[{'anyOf': [{'pattern': '([^,]+)', 'type': 'string'}, {'type': 'null'}]}]",
"typing.List[hdr_schemata.definitions.HDRUK.Language.Language]",
"List",
"null"
],
"is_list": false,
Expand All @@ -1023,7 +1014,7 @@
"examples": null,
"type": [
"CommaSeparatedValues[{'anyOf': [{'pattern': '([^,]+)', 'type': 'string'}, {'type': 'null'}]}]",
"typing.List[hdr_schemata.definitions.HDRUK.Format.Format]",
"List",
"null"
],
"is_list": false,
Expand Down Expand Up @@ -1055,7 +1046,7 @@
"examples": null,
"type": [
"CommaSeparatedValues[{'anyOf': [{'pattern': '([^,]+)', 'type': 'string'}, {'type': 'null'}]}]",
"typing.List[typing.Union[hdr_schemata.definitions.HDRUK.Url.Url, NoneType, hdr_schemata.definitions.HDRUK.OneHundredFiftyCharacters.OneHundredFiftyCharacters]]",
"List",
"null"
],
"is_list": false,
Expand All @@ -1070,7 +1061,7 @@
"examples": null,
"type": [
"CommaSeparatedValues[{'anyOf': [{'pattern': '([^,]+)', 'type': 'string'}, {'type': 'null'}]}]",
"typing.List[typing.Optional[hdr_schemata.definitions.HDRUK.AbstractText.AbstractText]]",
"List",
"null"
],
"is_list": false,
Expand All @@ -1085,7 +1076,7 @@
"examples": null,
"type": [
"CommaSeparatedValues[{'anyOf': [{'pattern': '([^,]+)', 'type': 'string'}, {'type': 'null'}]}]",
"typing.List[typing.Optional[hdr_schemata.definitions.HDRUK.Url.Url]]",
"List",
"null"
],
"is_list": false,
Expand Down
9 changes: 0 additions & 9 deletions hdr_schemata/models/HDRUK/2.2.1/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1455,9 +1455,6 @@
"properties": {
"purpose": {
"anyOf": [
{
"$ref": "#/$defs/CommaSeparatedValues"
},
{
"items": {
"$ref": "#/$defs/Purpose"
Expand All @@ -1474,9 +1471,6 @@
},
"source": {
"anyOf": [
{
"$ref": "#/$defs/CommaSeparatedValues"
},
{
"items": {
"$ref": "#/$defs/Source"
Expand All @@ -1493,9 +1487,6 @@
},
"collectionSituation": {
"anyOf": [
{
"$ref": "#/$defs/CommaSeparatedValues"
},
{
"items": {
"$ref": "#/$defs/Setting"
Expand Down
18 changes: 18 additions & 0 deletions hdr_schemata/models/HDRUK/v2_2_1/Origin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from typing import Optional, List, Union
from pydantic import BaseModel, Field
from hdr_schemata.definitions.HDRUK import *

from .annotations import annotations

an = annotations.provenance.origin


class Origin(BaseModel):
class Config:
extra = "forbid"

purpose: Optional[List[Purpose]] = Field(None, **an.purpose.__dict__)
source: Optional[List[Source]] = Field(None, **an.source.__dict__)
collectionSituation: Optional[
List[Setting]
] = Field(None, **an.collectionSituation.__dict__)
15 changes: 15 additions & 0 deletions hdr_schemata/models/HDRUK/v2_2_1/Provenance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from hdr_schemata.models.HDRUK.v2_2_0 import Provenance as BaseProvenance
from pydantic import Field
from typing import Optional
from .Origin import Origin

from .annotations import annotations

an = annotations.provenance


class Provenance(BaseProvenance):

origin: Optional[Origin] = Field(
None, description=an.origin.description, title=an.origin.title
)
7 changes: 7 additions & 0 deletions hdr_schemata/models/HDRUK/v2_2_1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

from .EnrichmentAndLinkage import EnrichmentAndLinkage
from .Accessibility import Accessibility
from .Provenance import Provenance

from .annotations import annotations as an


class Hdruk221(Hdruk220):
Expand All @@ -21,6 +24,10 @@ class Hdruk221(Hdruk220):
title="Accessibility",
)

provenance: Optional[Provenance] = Field(
None, description=an.provenance.description, title=an.provenance.title
)

@classmethod
def save_schema(cls, location="./2.2.1/schema.json"):
with open(location, "w") as f:
Expand Down
Loading