fhir 1.0.0

Fast Healthcare Interoperability Resources (FHIR) API is a standardized, RESTful interface for exchanging electronic health records.
Documentation
//! GenomicStudy
//!
//! URL: http://hl7.org/fhir/StructureDefinition/GenomicStudy
//!
//! Version: 5.0.0
//!
//! GenomicStudy Resource: A set of analyses performed to analyze and generate genomic data.
//!
//! FHIR: <https://build.fhir.org/>
//!
//! UML: <https://build.fhir.org/uml.html>

// Allow unused crate::r5::types as types;
#![allow(unused_imports)]

use crate::r5::types;
use ::serde::{Deserialize, Serialize};
use fhir_derive_macros::Validate;

/// A set of analyses performed to analyze and generate genomic data.
///
/// A GenomicStudy resource captures a set of one or more genomic analyses
/// performed for a subject, such as a patient, and the data those analyses
/// produce. Each analysis records the methods used, the genomic changes and
/// regions studied, the specimens and devices involved, the performers, and the
/// input and output files. In FHIR R5 it provides a container that ties together
/// the workflow, provenance, and results of genomic testing.
///
/// Clinically and administratively, GenomicStudy is used to track the overall
/// lifecycle of a genomics investigation, from ordering through to the release
/// of findings. It links the request and reason for testing to the resulting
/// sequencing or variant-calling analyses, and it records provenance information
/// such as which protocols, devices, and personnel were involved in producing
/// each set of input and output files. This makes it possible to trace a
/// reported genomic finding back to the specific analysis event, specimen, and
/// method that produced it, which is important for both clinical decision
/// support and laboratory quality assurance.
///
/// # Related resources
///
/// A GenomicStudy is commonly referenced from, or references, other resources
/// such as [`Patient`](crate::r5::resources::patient::Patient) or `Specimen`
/// (via `subject` and the analysis `specimen` field), `ServiceRequest` or
/// `Task` (via `basedOn`), `Practitioner` or `PractitionerRole` (via
/// `referrer`, `interpreter`, and analysis `performer`), `Device` (via analysis
/// `device`), and `DocumentReference` or `Binary` (via analysis `input` and
/// `output` files). Coded values throughout the resource, such as the type of
/// study or the type of genomic change studied, are represented using
/// [`CodeableConcept`](crate::r5::types::CodeableConcept).
///
/// # Examples
///
/// ```
/// use fhir::r5::resources::genomic_study::GenomicStudy;
///
/// let value = GenomicStudy::default();
/// let json = ::serde_json::to_value(&value).unwrap();
/// let back: GenomicStudy = ::serde_json::from_value(json).unwrap();
/// assert_eq!(value, back);
/// ```
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct GenomicStudy {
    /// Logical id of this artifact
    pub id: Option<types::String>,

    /// Metadata about the resource
    pub meta: Option<types::Meta>,

    /// A set of rules under which this content was created
    pub implicit_rules: Option<types::Uri>,
    /// Primitive extension sibling for [`implicit_rules`](Self::implicit_rules) (FHIR `_implicitRules`).
    #[serde(rename = "_implicitRules")]
    pub implicit_rules_ext: Option<types::Element>,

    /// Language of the resource content
    pub language: Option<types::Code>,
    /// Primitive extension sibling for [`language`](Self::language) (FHIR `_language`).
    #[serde(rename = "_language")]
    pub language_ext: Option<types::Element>,

    /// Text summary of the resource, for human interpretation
    pub text: Option<types::Narrative>,

    /// Contained, inline Resources
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub contained: Vec<::serde_json::Value>,

    /// Additional content defined by implementations
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub extension: Vec<types::Extension>,

    /// Extensions that cannot be ignored
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub modifier_extension: Vec<types::Extension>,

    /// Identifiers assigned to this genomic study by the performing lab or ordering system
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub identifier: Vec<types::Identifier>,

    /// The overall workflow status of the study: registered | available | cancelled | entered-in-error | unknown
    pub status: crate::r5::coded::Coded<crate::r5::codes::GenomicstudyStatus>,
    /// Primitive extension sibling for [`status`](Self::status) (FHIR `_status`).
    #[serde(rename = "_status")]
    pub status_ext: Option<types::Element>,

    /// The type of the study (e.g., Familial variant segregation, Functional variation detection, or Gene expression profiling)
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub r#type: Vec<types::CodeableConcept>,

    /// The primary subject of the genomic study, typically a [`Patient`](crate::r5::resources::patient::Patient)
    pub subject: types::Reference,

    /// The healthcare event with which this genomics study is associated
    pub encounter: Option<types::Reference>,

    /// When the genomic study was started
    pub start_date: Option<types::DateTime>,
    /// Primitive extension sibling for [`start_date`](Self::start_date) (FHIR `_startDate`).
    #[serde(rename = "_startDate")]
    pub start_date_ext: Option<types::Element>,

    /// Event resources that the genomic study is based on
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub based_on: Vec<types::Reference>,

    /// Healthcare professional who requested or referred the genomic study
    pub referrer: Option<types::Reference>,

    /// Healthcare professionals who interpreted the genomic study
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub interpreter: Vec<types::Reference>,

    /// Why the genomic study was performed
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub reason: Vec<types::CodeableReference>,

    /// The defined protocol that describes the study
    pub instantiates_canonical: Option<types::Canonical>,
    /// Primitive extension sibling for [`instantiates_canonical`](Self::instantiates_canonical) (FHIR `_instantiatesCanonical`).
    #[serde(rename = "_instantiatesCanonical")]
    pub instantiates_canonical_ext: Option<types::Element>,

    /// The URL pointing to an externally maintained protocol that describes the study
    pub instantiates_uri: Option<types::Uri>,
    /// Primitive extension sibling for [`instantiates_uri`](Self::instantiates_uri) (FHIR `_instantiatesUri`).
    #[serde(rename = "_instantiatesUri")]
    pub instantiates_uri_ext: Option<types::Element>,

    /// Comments related to the genomic study
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub note: Vec<types::Annotation>,

    /// Description of the genomic study
    pub description: Option<types::Markdown>,
    /// Primitive extension sibling for [`description`](Self::description) (FHIR `_description`).
    #[serde(rename = "_description")]
    pub description_ext: Option<types::Element>,

    /// The one or more genomic analysis events that make up this study
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub analysis: Vec<GenomicStudyAnalysis>,
}

/// Genomic Analysis Event
///
/// A single genomic analysis performed as part of the study, capturing the
/// methods, genomic changes, regions, specimens, devices, performers, and the
/// input and output files associated with that analysis.
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct GenomicStudyAnalysis {
    /// Unique id for inter-element referencing
    pub id: Option<types::String>,

    /// Additional content defined by implementations
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub extension: Vec<types::Extension>,

    /// Extensions that cannot be ignored even if unrecognized
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub modifier_extension: Vec<types::Extension>,

    /// Identifiers for the analysis event
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub identifier: Vec<types::Identifier>,

    /// Type of the methods used in the analysis (e.g., FISH, Karyotyping, MSI)
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub method_type: Vec<types::CodeableConcept>,

    /// Type of the genomic changes studied in the analysis (e.g., DNA, RNA, or AA change)
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub change_type: Vec<types::CodeableConcept>,

    /// Genome build that is used in this analysis
    pub genome_build: Option<types::CodeableConcept>,

    /// The defined protocol that describes the analysis
    pub instantiates_canonical: Option<types::Canonical>,
    /// Primitive extension sibling for [`instantiates_canonical`](Self::instantiates_canonical) (FHIR `_instantiatesCanonical`).
    #[serde(rename = "_instantiatesCanonical")]
    pub instantiates_canonical_ext: Option<types::Element>,

    /// The URL pointing to an externally maintained protocol that describes the analysis
    pub instantiates_uri: Option<types::Uri>,
    /// Primitive extension sibling for [`instantiates_uri`](Self::instantiates_uri) (FHIR `_instantiatesUri`).
    #[serde(rename = "_instantiatesUri")]
    pub instantiates_uri_ext: Option<types::Element>,

    /// Name of the analysis event (human friendly)
    pub title: Option<types::String>,
    /// Primitive extension sibling for [`title`](Self::title) (FHIR `_title`).
    #[serde(rename = "_title")]
    pub title_ext: Option<types::Element>,

    /// What the genomic analysis is about, when it is not about the subject of record
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub focus: Vec<types::Reference>,

    /// The specimen used in the analysis event
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub specimen: Vec<types::Reference>,

    /// The date of the analysis event
    pub date: Option<types::DateTime>,
    /// Primitive extension sibling for [`date`](Self::date) (FHIR `_date`).
    #[serde(rename = "_date")]
    pub date_ext: Option<types::Element>,

    /// Any notes capture with the analysis event
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub note: Vec<types::Annotation>,

    /// The protocol that was performed for the analysis event
    pub protocol_performed: Option<types::Reference>,

    /// The genomic regions to be studied in the analysis (BED file)
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub regions_studied: Vec<types::Reference>,

    /// Genomic regions actually called in the analysis event (BED file)
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub regions_called: Vec<types::Reference>,

    /// Inputs for the analysis event
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub input: Vec<GenomicStudyAnalysisInput>,

    /// Outputs for the analysis event
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub output: Vec<GenomicStudyAnalysisOutput>,

    /// Performer for the analysis event
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub performer: Vec<GenomicStudyAnalysisPerformer>,

    /// Devices used for the analysis (e.g., instruments, software), with settings and parameters
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub device: Vec<GenomicStudyAnalysisDevice>,
}

/// Inputs for the analysis event
///
/// An input file consumed by the analysis event, along with its data type and
/// the analysis event or GenomicStudy that generated it.
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct GenomicStudyAnalysisInput {
    /// Unique id for inter-element referencing
    pub id: Option<types::String>,

    /// Additional content defined by implementations
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub extension: Vec<types::Extension>,

    /// Extensions that cannot be ignored even if unrecognized
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub modifier_extension: Vec<types::Extension>,

    /// File containing input data
    pub file: Option<types::Reference>,

    /// Type of input data (e.g., BAM, CRAM, or FASTA)
    pub r#type: Option<types::CodeableConcept>,

    /// The `GenomicStudy.analysis.input.generatedBy[x]` choice element (0..1); see [`GenomicStudyAnalysisInputGeneratedBy`].
    #[serde(flatten)]
    pub generated_by: Option<GenomicStudyAnalysisInputGeneratedBy>,
}

/// Outputs for the analysis event
///
/// An output file produced by the analysis event, along with its data type.
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct GenomicStudyAnalysisOutput {
    /// Unique id for inter-element referencing
    pub id: Option<types::String>,

    /// Additional content defined by implementations
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub extension: Vec<types::Extension>,

    /// Extensions that cannot be ignored even if unrecognized
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub modifier_extension: Vec<types::Extension>,

    /// File containing output data
    pub file: Option<types::Reference>,

    /// Type of output data (e.g., VCF, MAF, or BAM)
    pub r#type: Option<types::CodeableConcept>,
}

/// Performer for the analysis event
///
/// A participant in performing the analysis event, described by the actor and
/// the role that actor played.
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct GenomicStudyAnalysisPerformer {
    /// Unique id for inter-element referencing
    pub id: Option<types::String>,

    /// Additional content defined by implementations
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub extension: Vec<types::Extension>,

    /// Extensions that cannot be ignored even if unrecognized
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub modifier_extension: Vec<types::Extension>,

    /// The organization, healthcare professional, or others who participated in performing this analysis
    pub actor: Option<types::Reference>,

    /// Role of the actor for this analysis
    pub role: Option<types::CodeableConcept>,
}

/// Devices used for the analysis
///
/// A device (such as an instrument or software) used for the analysis event,
/// together with the specific function it performed.
#[serde_with::skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Validate)]
#[serde(rename_all = "camelCase")]
pub struct GenomicStudyAnalysisDevice {
    /// Unique id for inter-element referencing
    pub id: Option<types::String>,

    /// Additional content defined by implementations
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub extension: Vec<types::Extension>,

    /// Extensions that cannot be ignored even if unrecognized
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub modifier_extension: Vec<types::Extension>,

    /// Device used for the analysis
    pub device: Option<types::Reference>,

    /// Specific function for the device used for the analysis
    pub function: Option<types::CodeableConcept>,
}

#[cfg(test)]
mod tests {
    use super::*;
    type T = GenomicStudy;

    #[test]
    fn test_default() {
        let _ = T::default();
    }

    #[test]
    fn test_serde_round_trip() {
        let value = T::default();
        let json = ::serde_json::to_value(&value).expect("to_value");
        let back: T = ::serde_json::from_value(json).expect("from_value");
        assert_eq!(value, back);
    }
}
/// The `GenomicStudy.analysis.input.generatedBy[x]` choice element (see spec/11-choice-types.md).
#[derive(Debug, Clone, PartialEq, Eq, fhir_derive_macros::FhirChoice, Validate)]
#[allow(clippy::large_enum_variant)]
pub enum GenomicStudyAnalysisInputGeneratedBy {
    /// `generatedByIdentifier` variant.
    #[fhir("generatedByIdentifier")]
    Identifier(Box<types::Identifier>),
    /// `generatedByReference` variant.
    #[fhir("generatedByReference")]
    Reference(Box<types::Reference>),
}