arieldiamond / trans-passports-api

An app that smoothes the path to getting a correctly-gendered passport for transgender Americans.
1 stars 1 forks source link

Create data structure for flowcharts #3

Open approximatelylinear opened 8 years ago

approximatelylinear commented 8 years ago

Situation

We will be storing questions and answers in a database. What should be the representation?

Target

Database and table designs for:

Proposal

See subsequent comments for current design.

Initial pass at data types:

Flowchart resources

Flowchart presentation

Design the flowchart as a linked graph of cells.

Flowchart

Cell

approximatelylinear commented 8 years ago

Google doc with questions / answers

approximatelylinear commented 7 years ago

Updated Flowchart Datastructure

(See the "Talkshow Export Hack" sheet in the above Google doc)

Data is stored as a series of states, each represented as a database row with the following information:

Name Type Description Format Example
id text Unique identifier of the state section:type-abbreviation:label, where types are {d(escription), q(uestion), a(nswer), r(ecommendation)}, eligibility:a:is_citizen
text text Text of the record
next json Next items in the conversation immediately following this node (See schema below in json-schema format) [{"key": "eligibility:a:is_citizen"}, {"key": "eligibility:a:is_non-citizen-national"}, {"key": "eligibility:a:is_non-citizen"}]
type text Type of the node One of {description, question, answer, recommendation} description
backlink json Custom link to a previous part of the conversation in cases where it is not apparent from the graph structure (See schema below in json-schema format) {"key": "eligibility:a:is_citizen"}
next_on_complete json Custom link to a subsequent part of the conversation in cases where it is not apparent from the graph structure (See schema below in json-schema format) {"key": "eligibility:a:is_citizen"}
section text Section of the graph this node should appear in One of {intro, eligibility, trans, passport, location, summary} intro
result json Effect this node has on the current user's state (See schema below in json-schema format) {"eligible": true}
depends_on json Values of the current user's state required to display this node (See schema below in json-schema format) {"eligible": true}
child_display json
approximatelylinear commented 7 years ago

Schemas

next field

{
    "title": "Schema for `next` field",
    "type": "array",
    "items": {
        "title": "Next item",
        "type": "object",
        "properties": {
            "key": {
                            "description": "Lookup key of item in the data store",
                "type": "string"
            },
            "label": {
                            "description": "Optional label for this element when displayed. Defaults to the element's text if it is present in the data store. (This is required for resource elements, since they lack a child element in the data store.)",
                "type": "string"
            },
            "resource": {
                "description": "Link to external resource",
                "type": "string"
            },
            "use_child_text": {
                "description": "Whether to replace the text for the current state with the text for this child. Primarily makes sense in cases where there is a single following state.",
                "type": "boolean"
            }
        },
        "required": []
    }
}

backlink field

{
    "title": "Backlink",
    "type": "object",
    "properties": {
        "key": {
            "description": "Lookup key of item in the data store",
            "type": "string"
        },
        "label": {
                        "description": "Optional label for this element when displayed. Defaults to the element's text if it is present in the data store. (This is required for resource elements, since they lack a child element in the data store.)",
            "type": "string"
        },
        "resource": {
            "description": "Link to external resource",
            "type": "string"
        },
        "use_child_text": {
            "description": "Whether to replace the text for the current state with the text for this child. Primarily makes sense in cases where there is a single following state.",
            "type": "boolean"
        }
    },
    "required": []
}

next_on_complete field

Identical to the schema for the backlink field

{
    "title": "Next-on-complete",
    "type": "object",
    "properties": {
        "key": {
            "description": "Lookup key of item in the data store",
            "type": "string"
        },
        "label": {
                        "description": "Optional label for this element when displayed. Defaults to the element's text if it is present in the data store. (This is required for resource elements, since they lack a child element in the data store.)",
            "type": "string"
        },
        "resource": {
            "description": "Link to external resource",
            "type": "string"
        },
        "use_child_text": {
            "description": "Whether to replace the text for the current state with the text for this child. Primarily makes sense in cases where there is a single following state.",
            "type": "boolean"
        }
    },
    "required": []
}

result field

{
    "title": "Schema for `result` field",
    "type": "object",
    "properties": {
        "eligible": {
                        "description": "Whether the user is eligible for a passport",
            "type": "boolean"
        },
        "is_trans": {
                        "description": "Whether the user identifies as trans",
            "type": "boolean"
        },
        "has_limited_passport": {
            "description": "Whether the user has a limited 'currently transitioning' passport",
            "type": "boolean"
        },
        "is_parent": {
            "description": "Whether the user is a parent or guardian applying on behalf of a minor",
            "type": "boolean"
        },
        "location_help": {
            "description": "Whether the user requested help finding a location",
            "type": "boolean"
        },
        "name_change_help": {
            "description": "Whether the user requested help understanding the name change requirement",
            "type": "boolean"
        },
        "cert_help": {
            "description": "Whether the user requested help understanding the certification letter requirement",
            "type": "boolean"
        },
    },
    "required": []
}

depends_on field

Identical to the schema for the result field

{
    "title": "Schema for `depends_on` field",
    "type": "object",
    "properties": {
        "eligible": {
                        "description": "Whether the user is eligible for a passport",
            "type": "boolean"
        },
        "is_trans": {
                        "description": "Whether the user identifies as trans",
            "type": "boolean"
        },
        "has_limited_passport": {
            "description": "Whether the user has a limited 'currently transitioning' passport",
            "type": "boolean"
        },
        "is_parent": {
            "description": "Whether the user is a parent or guardian applying on behalf of a minor",
            "type": "boolean"
        },
        "location_help": {
            "description": "Whether the user requested help finding a location",
            "type": "boolean"
        },
        "name_change_help": {
            "description": "Whether the user requested help understanding the name change requirement",
            "type": "boolean"
        },
        "cert_help": {
            "description": "Whether the user requested help understanding the certification letter requirement",
            "type": "boolean"
        },
    },
    "required": []
}
arieldiamond commented 7 years ago

Will you add all of this to the trans-passports-react repo?