-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecords.py
More file actions
94 lines (63 loc) · 2.82 KB
/
records.py
File metadata and controls
94 lines (63 loc) · 2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
from __future__ import annotations
from datetime import datetime
from typing import Any, Dict, List
from pydantic import Field, RootModel
from imednet.models.json_base import JsonModel
class Keyword(JsonModel):
"""A keyword or tag associated with a record."""
keyword_name: str = Field("", alias="keywordName")
keyword_key: str = Field("", alias="keywordKey")
keyword_id: int = Field(0, alias="keywordId")
date_added: datetime = Field(default_factory=datetime.now, alias="dateAdded")
pass
class Record(JsonModel):
"""A data record for a subject, form, and visit."""
study_key: str = Field("", alias="studyKey")
interval_id: int = Field(0, alias="intervalId")
form_id: int = Field(0, alias="formId")
form_key: str = Field("", alias="formKey")
site_id: int = Field(0, alias="siteId")
record_id: int = Field(0, alias="recordId")
record_oid: str = Field("", alias="recordOid")
record_type: str = Field("", alias="recordType")
record_status: str = Field("", alias="recordStatus")
deleted: bool = Field(False, alias="deleted")
date_created: datetime = Field(default_factory=datetime.now, alias="dateCreated")
date_modified: datetime = Field(default_factory=datetime.now, alias="dateModified")
subject_id: int = Field(0, alias="subjectId")
subject_oid: str = Field("", alias="subjectOid")
subject_key: str = Field("", alias="subjectKey")
visit_id: int = Field(0, alias="visitId")
parent_record_id: int = Field(0, alias="parentRecordId")
keywords: List[Keyword] = Field(default_factory=list, alias="keywords")
record_data: Dict[str, Any] = Field(default_factory=dict, alias="recordData")
pass
class RecordJobResponse(JsonModel):
"""Response for a record-related job (batch operations, etc)."""
job_id: str = Field("", alias="jobId")
batch_id: str = Field("", alias="batchId")
state: str = Field("", alias="state")
pass
class RecordData(RootModel[Dict[str, Any]]):
"""Arbitrary record data as a dictionary."""
pass
class BaseRecordRequest(JsonModel):
"""Base class for record creation/update requests."""
form_key: str = Field("", alias="formKey")
data: RecordData = Field(default_factory=lambda: RecordData({}), alias="data")
pass
class RegisterSubjectRequest(BaseRecordRequest):
site_name: str = Field(
"", alias="siteName", description="Name of the site where the subject is enrolled"
)
subject_key: str = Field(
"", alias="subjectKey", description="Unique identifier for the subject"
)
pass
class UpdateScheduledRecordRequest(BaseRecordRequest):
subject_key: str = Field("", alias="subjectKey")
interval_name: str = Field("", alias="intervalName")
pass
class CreateNewRecordRequest(BaseRecordRequest):
subject_key: str = Field("", alias="subjectKey")
pass