Skip to content
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
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ python = ["dep:pyo3"]

[dependencies]
chrono = { version = "0.4.38", features = ["serde"] }
pyo3 = { version = "0.22.6", optional = true }
pyo3 = { version = "0.23.1", optional = true }
serde = { version = "1.0.215", features = ["derive"] }
serde-xml-rs = "0.6.0"
serde_json = "1.0.132"
Expand Down
26 changes: 13 additions & 13 deletions src/native/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl Value {
}

pub fn to_dict<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyDict>> {
let dict = PyDict::new_bound(py);
let dict = PyDict::new(py);
dict.set_item("by", &self.by)?;
dict.set_item("by_unique_id", &self.by_unique_id)?;
dict.set_item("role", &self.role)?;
Expand Down Expand Up @@ -160,7 +160,7 @@ impl Reason {
}

pub fn to_dict<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyDict>> {
let dict = PyDict::new_bound(py);
let dict = PyDict::new(py);
dict.set_item("by", &self.by)?;
dict.set_item("by_unique_id", &self.by_unique_id)?;
dict.set_item("role", &self.role)?;
Expand Down Expand Up @@ -211,7 +211,7 @@ impl Entry {
}

pub fn to_dict<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyDict>> {
let dict = PyDict::new_bound(py);
let dict = PyDict::new(py);
dict.set_item("entry_id", &self.entry_id)?;
if let Some(value) = &self.value {
dict.set_item("value", value.to_dict(py)?)?;
Expand Down Expand Up @@ -261,7 +261,7 @@ impl Comment {
}

pub fn to_dict<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyDict>> {
let dict = PyDict::new_bound(py);
let dict = PyDict::new(py);
dict.set_item("comment_id", &self.comment_id)?;
if let Some(value) = &self.value {
dict.set_item("value", value.to_dict(py)?)?;
Expand Down Expand Up @@ -369,7 +369,7 @@ impl Field {
}

pub fn to_dict<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyDict>> {
let dict = PyDict::new_bound(py);
let dict = PyDict::new(py);
dict.set_item("name", &self.name)?;
dict.set_item("field_type", &self.field_type)?;
dict.set_item("data_type", &self.data_type)?;
Expand All @@ -381,7 +381,7 @@ impl Field {
if let Some(entries) = &self.entries {
for entry in entries {
let entry_dict = entry.to_dict(py)?;
entry_dicts.push(entry_dict.to_object(py));
entry_dicts.push(entry_dict);
}
dict.set_item("entries", entry_dicts)?;
} else {
Expand All @@ -392,7 +392,7 @@ impl Field {
if let Some(comments) = &self.comments {
for comment in comments {
let comment_dict = comment.to_dict(py)?;
comment_dicts.push(comment_dict.to_object(py));
comment_dicts.push(comment_dict);
}
dict.set_item("comments", comment_dicts)?;
} else {
Expand Down Expand Up @@ -458,7 +458,7 @@ impl Category {
}

pub fn to_dict<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyDict>> {
let dict = PyDict::new_bound(py);
let dict = PyDict::new(py);
dict.set_item("name", &self.name)?;
dict.set_item("category_type", &self.category_type)?;
dict.set_item("highest_index", self.highest_index)?;
Expand All @@ -467,7 +467,7 @@ impl Category {
if let Some(fields) = &self.fields {
for field in fields {
let field_dict = field.to_dict(py)?;
field_dicts.push(field_dict.to_object(py));
field_dicts.push(field_dict);
}
dict.set_item("fields", field_dicts)?;
} else {
Expand Down Expand Up @@ -533,7 +533,7 @@ impl State {
}

pub fn to_dict<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyDict>> {
let dict = PyDict::new_bound(py);
let dict = PyDict::new(py);
dict.set_item("value", &self.value)?;
dict.set_item("signer", &self.signer)?;
dict.set_item("signer_unique_id", &self.signer_unique_id)?;
Expand Down Expand Up @@ -746,7 +746,7 @@ impl Form {
}

pub fn to_dict<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyDict>> {
let dict = PyDict::new_bound(py);
let dict = PyDict::new(py);
dict.set_item("name", &self.name)?;
dict.set_item(
"last_modified",
Expand All @@ -772,7 +772,7 @@ impl Form {
if let Some(states) = &self.states {
for state in states {
let state_dict = state.to_dict(py)?;
state_dicts.push(state_dict.to_object(py));
state_dicts.push(state_dict);
}
dict.set_item("states", state_dicts)?;
} else {
Expand All @@ -783,7 +783,7 @@ impl Form {
let mut category_dicts = Vec::new();
for category in categories {
let category_dict = category.to_dict(py)?;
category_dicts.push(category_dict.to_object(py));
category_dicts.push(category_dict);
}
dict.set_item("categories", category_dicts)?;
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/native/deserializers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub fn to_py_datetime<'py>(
py: Python<'py>,
date_time: &DateTime<Utc>,
) -> PyResult<Bound<'py, PyDateTime>> {
let py_datetime = PyDateTime::new_bound(
let py_datetime = PyDateTime::new(
py,
date_time.year(),
date_time.month() as u8,
Expand All @@ -80,7 +80,7 @@ pub fn to_py_datetime_option<'py>(
date_time: &Option<DateTime<Utc>>,
) -> PyResult<Option<Bound<'py, PyDateTime>>> {
if let Some(d) = date_time {
let py_datetime = Some(PyDateTime::new_bound(
let py_datetime = Some(PyDateTime::new(
py,
d.year(),
d.month() as u8,
Expand Down
8 changes: 4 additions & 4 deletions src/native/site_native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl Site {
}

pub fn to_dict<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyDict>> {
let dict = PyDict::new_bound(py);
let dict = PyDict::new(py);
dict.set_item("name", &self.name)?;
dict.set_item("unique_id", &self.unique_id)?;
dict.set_item("number_of_patients", self.number_of_patients)?;
Expand All @@ -112,7 +112,7 @@ impl Site {
if let Some(forms) = &self.forms {
for form in forms {
let form_dict = form.to_dict(py)?;
form_dicts.push(form_dict.to_object(py));
form_dicts.push(form_dict);
}
dict.set_item("forms", form_dicts)?;
} else {
Expand Down Expand Up @@ -153,11 +153,11 @@ impl SiteNative {

/// Convert the class instance to a dictionary
fn to_dict<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyDict>> {
let dict = PyDict::new_bound(py);
let dict = PyDict::new(py);
let mut site_dicts = Vec::new();
for site in &self.sites {
let site_dict = site.to_dict(py)?;
site_dicts.push(site_dict.to_object(py));
site_dicts.push(site_dict);
}
dict.set_item("sites", site_dicts)?;
Ok(dict)
Expand Down
8 changes: 4 additions & 4 deletions src/native/subject_native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ impl Patient {
}

pub fn to_dict<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyDict>> {
let dict = PyDict::new_bound(py);
let dict = PyDict::new(py);
dict.set_item("patient_id", &self.patient_id)?;
dict.set_item("unique_id", &self.unique_id)?;
dict.set_item("when_created", to_py_datetime(py, &self.when_created)?)?;
Expand All @@ -129,7 +129,7 @@ impl Patient {
if let Some(forms) = &self.forms {
for form in forms {
let form_dict = form.to_dict(py)?;
form_dicts.push(form_dict.to_object(py));
form_dicts.push(form_dict);
}
dict.set_item("forms", form_dicts)?;
} else {
Expand Down Expand Up @@ -169,11 +169,11 @@ impl SubjectNative {

/// Convert the class instance to a dictionary
fn to_dict<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyDict>> {
let dict = PyDict::new_bound(py);
let dict = PyDict::new(py);
let mut patient_dicts = Vec::new();
for patient in &self.patients {
let patient_dict = patient.to_dict(py)?;
patient_dicts.push(patient_dict.to_object(py));
patient_dicts.push(patient_dict);
}
dict.set_item("patients", patient_dicts)?;
Ok(dict)
Expand Down
8 changes: 4 additions & 4 deletions src/native/user_native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl User {
}

pub fn to_dict<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyDict>> {
let dict = PyDict::new_bound(py);
let dict = PyDict::new(py);
dict.set_item("unique_id", &self.unique_id)?;
dict.set_item("last_language", &self.last_language)?;
dict.set_item("creator", &self.creator)?;
Expand All @@ -82,7 +82,7 @@ impl User {
if let Some(forms) = &self.forms {
for form in forms {
let form_dict = form.to_dict(py)?;
form_dicts.push(form_dict.to_object(py));
form_dicts.push(form_dict);
}
dict.set_item("forms", form_dicts)?;
} else {
Expand Down Expand Up @@ -122,11 +122,11 @@ impl UserNative {

/// Convert the class instance to a dictionary
fn to_dict<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyDict>> {
let dict = PyDict::new_bound(py);
let dict = PyDict::new(py);
let mut user_dicts = Vec::new();
for user in &self.users {
let user_dict = user.to_dict(py)?;
user_dicts.push(user_dict.to_object(py));
user_dicts.push(user_dict);
}
dict.set_item("users", user_dicts)?;
Ok(dict)
Expand Down