<commit_before>from sqlalchemy import Column, Integer, String, ForeignKey, DateTime, Index
from sqlalchemy.orm import relationship
from sqlalchemy.dialects import postgresql

from radar.database import db
from radar.models.common import MetaModelMixin, uuid_pk_column, patient_id_column, patient_relationship

OBSERVATION_TYPE_INTEGER = 'INTEGER'
OBSERVATION_TYPE_REAL = 'REAL'
OBSERVATION_TYPE_LOOKUP = 'LOOKUP'
OBSERVATION_TYPE_STRING = 'STRING'


class Observation(db.Model):
    __tablename__ = 'observations'

    id = Column(Integer, primary_key=True)
    type = Column(String, nullable=False)
    name = Column(String, nullable=False)
    short_name = Column(String, nullable=False)
    system_id = Column(Integer, ForeignKey('observation_systems.id'), nullable=False)
    system = relationship('ObservationSystem')
    options = Column(postgresql.JSONB, nullable=False)


class ObservationSystem(db.Model):
    __tablename__ = 'observation_systems'

    id = Column(Integer, primary_key=True)
    name = Column(String, nullable=False)


class Result(db.Model, MetaModelMixin):
    __tablename__ = 'results'

    id = uuid_pk_column()

    patient_id = patient_id_column()
    patient = patient_relationship('results')

    source_group_id = Column(Integer, ForeignKey('groups.id'), nullable=False)
    source_group = relationship('Group')
    source_type_id = Column(String, ForeignKey('source_types.id'), nullable=False)
    source_type = relationship('SourceType')

    observation_id = Column(Integer, ForeignKey('observations.id'), nullable=False)
    observation = relationship('Observation')

    date = Column(DateTime(timezone=False), nullable=False)
    _value = Column('value', String, nullable=False)

    @property
    def value(self):
        x = self._value

        if x is not None and self.observation is not None:<commit_msg>Change system_id type to String<commit_after>from sqlalchemy import Column, Integer, String, ForeignKey, DateTime, Index
from sqlalchemy.orm import relationship
from sqlalchemy.dialects import postgresql

from radar.database import db
from radar.models.common import MetaModelMixin, uuid_pk_column, patient_id_column, patient_relationship

OBSERVATION_TYPE_INTEGER = 'INTEGER'
OBSERVATION_TYPE_REAL = 'REAL'
OBSERVATION_TYPE_LOOKUP = 'LOOKUP'
OBSERVATION_TYPE_STRING = 'STRING'


class Observation(db.Model):
    __tablename__ = 'observations'

    id = Column(Integer, primary_key=True)
    type = Column(String, nullable=False)
    name = Column(String, nullable=False)
    short_name = Column(String, nullable=False)
    system_id = Column(String, ForeignKey('observation_systems.id'), nullable=False)
    system = relationship('ObservationSystem')
    options = Column(postgresql.JSONB, nullable=False)


class ObservationSystem(db.Model):
    __tablename__ = 'observation_systems'

    id = Column(String, primary_key=True)
    name = Column(String, nullable=False)


class Result(db.Model, MetaModelMixin):
    __tablename__ = 'results'

    id = uuid_pk_column()

    patient_id = patient_id_column()
    patient = patient_relationship('results')

    source_group_id = Column(Integer, ForeignKey('groups.id'), nullable=False)
    source_group = relationship('Group')
    source_type_id = Column(String, ForeignKey('source_types.id'), nullable=False)
    source_type = relationship('SourceType')

    observation_id = Column(Integer, ForeignKey('observations.id'), nullable=False)
    observation = relationship('Observation')

    date = Column(DateTime(timezone=False), nullable=False)
    _value = Column('value', String, nullable=False)

    @property
    def value(self):
        x = self._value

        if x is not None and self.observation is not None:
{'fraction_non_alphanumeric': 0.09951586874663798, 'fraction_numerical': 0.0, 'mean_word_length': 5.208681135225375, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1658705', 'n_tokens_mistral': 1155, 'n_tokens_neox': 1122, 'n_words': 247}