phenopackets / phenopacket-schema

Repository for the GA4GH phenopacket schema
https://phenopacket-schema.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
78 stars 30 forks source link

Add AgeElement for age-related fields #275

Closed julesjacobsen closed 3 years ago

julesjacobsen commented 3 years ago

TimeElement might be too broad in cases where we really only want to know an age , and a timestamp would not be appropriate, such as Individual.age_at_encounter

Current temporal types:

message GestationalAge {
    int32 weeks = 1;
    int32 days = 2;
}

// See http://build.fhir.org/datatypes and http://build.fhir.org/condition-definitions.html#Condition.onset_x_
// In FHIR this is represented as a UCUM measurement - http://unitsofmeasure.org/trac/
message Age {
    // The :ref:`ISO 8601<metadata_date_time>` age of this object as ISO8601
    // duration or time intervals. e.g. P40Y10M05D)
    string iso8601duration = 1;
}

message AgeRange {
    Age start = 1;
    Age end = 2;
}

message TimeInterval {
    google.protobuf.Timestamp start = 1;
    google.protobuf.Timestamp end = 2;
}

message TimeElement {
    oneof element {
        GestationalAge gestational_age = 6;
        Age age = 1;
        AgeRange age_range = 2;
        OntologyClass ontology_class = 3;
        google.protobuf.Timestamp timestamp = 4;
        TimeInterval interval = 5;
    }
}

Proposed AgeElement:

message AgeElement {
    oneof element {
        GestationalAge gestational_age = 1;
        Age age = 2;
        AgeRange age_range = 3;
    }
}

and usage

message Individual {
    // An age object describing the age of the individual at the time of encounter. The Age object allows the encoding
    // of the age either as ISO8601 duration or time interval (preferred)
    // See http://build.fhir.org/datatypes
    AgeElement age_at_encounter = 11;
julesjacobsen commented 3 years ago

Alternatively - rename Individual.age_at_encounter to time_at_encounter which could contain some kind of Age or Timestamp