use serde::{Deserialize, Serialize};
use utoipa::ToSchema;
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct OdsRoleReference {
pub role_id: String,
pub role_name: String,
pub is_primary_role_type: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct OdsRelationshipReference {
pub relationship_id: String,
pub relationship_name: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct OdsRecordClassReference {
pub code: String,
pub name: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct OdsRecordUseTypeReference {
pub code: String,
pub name: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct PractitionerRoleReference {
pub role_code: String,
pub role_name: String,
pub role_category: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct GeographyNameReference {
pub ons_code: String,
pub name: String,
pub geography_type: String,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_ods_role_reference() {
let role = OdsRoleReference {
role_id: "RO197".to_string(),
role_name: "NHS Trust".to_string(),
is_primary_role_type: true,
};
assert!(role.is_primary_role_type);
}
#[test]
fn test_ods_relationship_reference() {
let rel = OdsRelationshipReference {
relationship_id: "RE4".to_string(),
relationship_name: "IS COMMISSIONED BY".to_string(),
};
assert_eq!(rel.relationship_id, "RE4");
}
#[test]
fn test_practitioner_role_reference() {
let role = PractitionerRoleReference {
role_code: "PGP".to_string(),
role_name: "General Practitioner".to_string(),
role_category: Some("Prescriber".to_string()),
};
assert_eq!(role.role_code, "PGP");
}
#[test]
fn test_geography_name_reference() {
let geo = GeographyNameReference {
ons_code: "E09000033".to_string(),
name: "Westminster".to_string(),
geography_type: "Local Authority".to_string(),
};
assert_eq!(geo.geography_type, "Local Authority");
}
#[test]
fn test_ods_record_class_reference() {
let rc = OdsRecordClassReference {
code: "RC1".to_string(),
name: "Organisation".to_string(),
};
assert_eq!(rc.code, "RC1");
}
#[test]
fn test_ods_role_reference_serialization() {
let role = OdsRoleReference {
role_id: "RO76".to_string(),
role_name: "GP Practice".to_string(),
is_primary_role_type: true,
};
let json = serde_json::to_string(&role).unwrap();
let deser: OdsRoleReference = serde_json::from_str(&json).unwrap();
assert_eq!(deser.role_id, "RO76");
assert!(deser.is_primary_role_type);
}
}