# coding: utf-8

"""
HaploHub API

The HaploHub is a turnkey solution to securely store and interpret biomarkers, genetics, and 'omics data. Our customers use the HaploHub to:  * Store WGS, WES, low-pass, and array data with uniform REST interfaces to access variants  * Interpret genomic variants  * Generate risk scores for an individual  * Run the typical algorithms (phasing, imputation, etc.)  * Calculate 'biological age' or 'organ age' biomarkers  * Generate custom reports  The HaploHub platform is continually updated to remain at the forefront of scientific understanding.

The version of the OpenAPI document: 1.0
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
"""  # noqa: E501

from __future__ import annotations

import json
import pprint
import re  # noqa: F401
from datetime import datetime
from typing import Optional, Union

from pydantic import BaseModel, Field, StrictBool, StrictFloat, StrictInt, StrictStr


class ResultSchema(BaseModel):
    """
    ResultSchema
    """

    name: StrictStr = Field(...)
    slug: StrictStr = Field(...)
    value: Optional[Union[StrictFloat, StrictInt]] = None
    result: Optional[StrictStr] = None
    type: Optional[StrictStr] = None
    unit: Optional[StrictStr] = None
    timestamp: Optional[datetime] = None
    notes: Optional[StrictStr] = None
    min_range_value: Optional[Union[StrictFloat, StrictInt]] = None
    max_range_value: Optional[Union[StrictFloat, StrictInt]] = None
    is_above_max_range: Optional[StrictBool] = None
    is_below_min_range: Optional[StrictBool] = None
    interpretation: Optional[StrictStr] = None
    loinc: Optional[StrictStr] = None
    loinc_slug: Optional[StrictStr] = None
    provider_id: Optional[StrictStr] = None
    __properties = [
        "name",
        "slug",
        "value",
        "result",
        "type",
        "unit",
        "timestamp",
        "notes",
        "min_range_value",
        "max_range_value",
        "is_above_max_range",
        "is_below_min_range",
        "interpretation",
        "loinc",
        "loinc_slug",
        "provider_id",
    ]

    class Config:
        """Pydantic configuration"""

        allow_population_by_field_name = True
        validate_assignment = True

    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.dict(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> ResultSchema:
        """Create an instance of ResultSchema from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self):
        """Returns the dictionary representation of the model using alias"""
        _dict = self.dict(by_alias=True, exclude={}, exclude_none=True)
        # set to None if value (nullable) is None
        # and __fields_set__ contains the field
        if self.value is None and "value" in self.__fields_set__:
            _dict["value"] = None

        # set to None if result (nullable) is None
        # and __fields_set__ contains the field
        if self.result is None and "result" in self.__fields_set__:
            _dict["result"] = None

        # set to None if type (nullable) is None
        # and __fields_set__ contains the field
        if self.type is None and "type" in self.__fields_set__:
            _dict["type"] = None

        # set to None if unit (nullable) is None
        # and __fields_set__ contains the field
        if self.unit is None and "unit" in self.__fields_set__:
            _dict["unit"] = None

        # set to None if timestamp (nullable) is None
        # and __fields_set__ contains the field
        if self.timestamp is None and "timestamp" in self.__fields_set__:
            _dict["timestamp"] = None

        # set to None if notes (nullable) is None
        # and __fields_set__ contains the field
        if self.notes is None and "notes" in self.__fields_set__:
            _dict["notes"] = None

        # set to None if min_range_value (nullable) is None
        # and __fields_set__ contains the field
        if self.min_range_value is None and "min_range_value" in self.__fields_set__:
            _dict["min_range_value"] = None

        # set to None if max_range_value (nullable) is None
        # and __fields_set__ contains the field
        if self.max_range_value is None and "max_range_value" in self.__fields_set__:
            _dict["max_range_value"] = None

        # set to None if is_above_max_range (nullable) is None
        # and __fields_set__ contains the field
        if self.is_above_max_range is None and "is_above_max_range" in self.__fields_set__:
            _dict["is_above_max_range"] = None

        # set to None if is_below_min_range (nullable) is None
        # and __fields_set__ contains the field
        if self.is_below_min_range is None and "is_below_min_range" in self.__fields_set__:
            _dict["is_below_min_range"] = None

        # set to None if interpretation (nullable) is None
        # and __fields_set__ contains the field
        if self.interpretation is None and "interpretation" in self.__fields_set__:
            _dict["interpretation"] = None

        # set to None if loinc (nullable) is None
        # and __fields_set__ contains the field
        if self.loinc is None and "loinc" in self.__fields_set__:
            _dict["loinc"] = None

        # set to None if loinc_slug (nullable) is None
        # and __fields_set__ contains the field
        if self.loinc_slug is None and "loinc_slug" in self.__fields_set__:
            _dict["loinc_slug"] = None

        # set to None if provider_id (nullable) is None
        # and __fields_set__ contains the field
        if self.provider_id is None and "provider_id" in self.__fields_set__:
            _dict["provider_id"] = None

        return _dict

    @classmethod
    def from_dict(cls, obj: dict) -> ResultSchema:
        """Create an instance of ResultSchema from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return ResultSchema.parse_obj(obj)

        _obj = ResultSchema.parse_obj(
            {
                "name": obj.get("name"),
                "slug": obj.get("slug"),
                "value": obj.get("value"),
                "result": obj.get("result"),
                "type": obj.get("type"),
                "unit": obj.get("unit"),
                "timestamp": obj.get("timestamp"),
                "notes": obj.get("notes"),
                "min_range_value": obj.get("min_range_value"),
                "max_range_value": obj.get("max_range_value"),
                "is_above_max_range": obj.get("is_above_max_range"),
                "is_below_min_range": obj.get("is_below_min_range"),
                "interpretation": obj.get("interpretation"),
                "loinc": obj.get("loinc"),
                "loinc_slug": obj.get("loinc_slug"),
                "provider_id": obj.get("provider_id"),
            }
        )
        return _obj
