Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement missing DB fields / custom types #30

Open
5HT2 opened this issue Jan 17, 2023 · 2 comments
Open

Implement missing DB fields / custom types #30

5HT2 opened this issue Jan 17, 2023 · 2 comments
Labels
backend:db Related to database structure / design backend:models Related to the model design bug Something isn't working
Milestone

Comments

@5HT2
Copy link
Contributor

5HT2 commented Jan 17, 2023

Trip Report Data structure and fields
Trip Report
├── ID
├── Creation Date
├── Last Modified Date
├── Source
│   ├── Name
│   ├── ID
│   └── URL
├── []Effect
│   ├── Name
│   ├── ID
│   └── []Matched Text
├── Submitter Info
│   ├── Name
│   ├── Gender
│   ├── Age
│   ├── Height
│   │   ├── Metric
│   │   └── Imperial
│   ├── Weight
│   │   ├── Metric
│   │   └── Imperial
│   ├── []Medication
│   │   ├── Name
│   │   ├── Dosage
│   │   ├── Frequency
│   │   ├── Route of Administration
│   │   └── Prescribed
│   └── Social Media
└── Report
├── Title
├── Date
├── Setting
└── []Report Event
├── Type
│   ├── Note
│   └── Substance
├── Time
│   ├── Absolute
│   └── Relative
└── Section
├── Onset
├── Offset
├── Peak
└── Description
├── Offset
├── Onset
└── Peak
Source text
ID
Creation Date
Last Modified Date
Source
Source/Name
Source/ID
Source/URL
[]Effect
[]Effect/Name
[]Effect/ID
[]Effect/[]Matched Text
Submitter Info
Submitter Info/Name
Submitter Info/Gender
Submitter Info/Age
Submitter Info/Height
Submitter Info/Height/Metric
Submitter Info/Height/Imperial
Submitter Info/Weight
Submitter Info/Weight/Metric
Submitter Info/Weight/Imperial
Submitter Info/[]Medication
Submitter Info/[]Medication/Name
Submitter Info/[]Medication/Dosage
Submitter Info/[]Medication/Frequency
Submitter Info/[]Medication/Route of Administration
Submitter Info/[]Medication/Prescribed
Submitter Info/Social Media
Report
Report/Title
Report/Date
Report/Setting
Report/[]Report Event
Report/[]Report Event/Type
Report/[]Report Event/Type/Note
Report/[]Report Event/Type/Substance
Report/[]Report Event/Time
Report/[]Report Event/Time/Absolute
Report/[]Report Event/Time/Relative
Report/[]Report Event/Section
Report/[]Report Event/Section/Description
Report/[]Report Event/Section/Description/Onset
Report/[]Report Event/Section/Description/Peak
Report/[]Report Event/Section/Description/Offset

See this Go snippet for a scanner impl

// Scan implements the sql.Scanner interface for database deserialization.
func (d *Decimal) Scan(value interface{}) error {
	// first try to see if the data is stored in database as a Numeric datatype
	switch v := value.(type) {

	case float32:
		*d = NewFromFloat(float64(v))
		return nil

	case float64:
		// numeric in sqlite3 sends us float64
		*d = NewFromFloat(v)
		return nil

	case int64:
		// at least in sqlite3 when the value is 0 in db, the data is sent
		// to us as an int64 instead of a float64 ...
		*d = New(v, 0)
		return nil

	default:
		// default is trying to interpret value stored as string
		str, err := unquoteIfQuoted(v)
		if err != nil {
			return err
		}
		*d, err = NewFromString(str)
		return err
	}
}
@5HT2 5HT2 converted this from a draft issue Jan 17, 2023
@5HT2 5HT2 added backend:db Related to database structure / design backend:models Related to the model design labels Jan 17, 2023
@5HT2 5HT2 added this to the 1.0.0 milestone Jan 17, 2023
@5HT2 5HT2 added the bug Something isn't working label Jan 17, 2023
@5HT2 5HT2 moved this from Todo (within 1 month) to Todo (within 1 week) in tripreporter tasks Feb 24, 2023
@5HT2
Copy link
Contributor Author

5HT2 commented Mar 7, 2023

See c74287e...0ce3f57

@5HT2 5HT2 modified the milestones: 1.0.0, 1.1.0 Mar 7, 2023
@5HT2
Copy link
Contributor Author

5HT2 commented Mar 7, 2023

Moving this to 1.1.0 as the important ones are done.

@5HT2 5HT2 moved this from Todo (within 1 week) to In Progress in tripreporter tasks Mar 15, 2023
@settings settings bot removed this from the 1.1.0 milestone Apr 5, 2023
@5HT2 5HT2 added this to the 1.1.0 milestone Apr 5, 2023
5HT2 added a commit that referenced this issue Apr 11, 2023
5HT2 added a commit that referenced this issue Apr 11, 2023
5HT2 added a commit that referenced this issue Apr 11, 2023
…rtion and handling, reduce duplicate code

See #30
See #100
5HT2 added a commit that referenced this issue Apr 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:db Related to database structure / design backend:models Related to the model design bug Something isn't working
Projects
Status: In Progress
Development

No branches or pull requests

1 participant