working on Gorm Serialization of structs.

This commit is contained in:
Jason Kulatunga 2022-08-30 19:35:01 -07:00
parent c8441086c8
commit 4c0d3c831d
4 changed files with 10 additions and 54 deletions

View File

@ -9,6 +9,8 @@ type DatabaseRepository interface {
Close() error
GetCurrentUser() models.User
CreateProviderCredentials(ctx context.Context, providerCreds *models.ProviderCredential) error
GetProviderCredentials(ctx context.Context) ([]models.ProviderCredential, error)
UpsertProfile(ctx context.Context, profile models.Profile) error
CreateSource(ctx context.Context, providerCreds *models.Source) error
GetSources(ctx context.Context) ([]models.Source, error)
}

View File

@ -10,12 +10,12 @@ import (
)
type FHIR430Client struct {
BaseClient
*BaseClient
}
func NewFHIR430Client(appConfig config.Interface, globalLogger logrus.FieldLogger, credentials models.ProviderCredential, testHttpClient ...*http.Client) (FHIR430Client, error) {
return FHIR430Client{
NewBaseClient(appConfig, globalLogger, credentials, testHttpClient...),
func NewFHIR430Client(appConfig config.Interface, globalLogger logrus.FieldLogger, source models.Source, testHttpClient ...*http.Client) (*FHIR430Client, error) {
return &FHIR430Client{
NewBaseClient(appConfig, globalLogger, source, testHttpClient...),
}, nil
}

View File

@ -48,8 +48,8 @@ func (c CignaClient) SyncAll(db database.DatabaseRepository) error {
//patientProfile. = c.Source.ID
c.Logger.Infof("CREATING PATIENT PROFILES: %v", patientProfiles)
for _, patient := range patientProfiles {
err = db.UpsertSourceResource(context.Background(), patient)
for _, profile := range patientProfiles {
err = db.UpsertProfile(context.Background(), profile)
if err != nil {
return err
}

View File

@ -1,46 +0,0 @@
package models
import "gorm.io/gorm"
//demographics Object (optional) (See demographics)
//alcohol Object (optional) The users alcohol usage. See alcohol object.
//smoking Object (optional) The users smoking habits. See smoking object.
type PatientProfile struct {
gorm.Model
User User `json:"user,omitempty"`
UserID uint `json:"user_id" gorm:"uniqueIndex:idx_user_provider_patient"`
ProviderId string `json:"provider_id" gorm:"uniqueIndex:idx_user_provider_patient"`
PatientId string `json:"patient_id" gorm:"uniqueIndex:idx_user_provider_patient"`
//embedded structs
Demographics `json:"demographics,omitempty"`
}
type Demographics struct {
Address Address `json:"address"` // Object (See address object)
Dob string `json:"dob"` //String (optional) The users date of birth e.g. "04/21/1965"
Ethnicity string `json:"ethnicity"` // String (optional) The ethnicity of the user e.g. "Not Hispanic of Latino"
Gender string `json:"gender"` // String (optional) The users gender e.g. "male"
Language string `json:"language"` //String (optional) The users primary language e.g. "eng"
MaritalStatus string `json:"maritalStatus"` // String (optional) The users marital status (eg: “married”, “single”)
Name Name `json:"name"` // Object (optional) (See name object)
Race string `json:"race"` // String (optional) The users race e.g. "White"
EthnicityCodes string `json:"ethnicityCodes"` // ethnicityCodes Array[Object] (optional) CDC Race & Ethnicity and SNOMED CT Ethnicity codes: See codes
MaritalStatusCodes string `json:"maritalStatusCodes"` // String (optional) SNOMED CT Marital status codes: see codes object
GenderCodes string `json:"genderCodes"` //String (optional) SNOMED CT Gender codes: See codes
}
type Address struct {
City string `json:"city"` // (optional) City of address e.g. "SAN FRANCISCO"
Country string `json:"country"` // (optional) Country of address e.g. "US"
State string `json:"state"` // (optional) State of address e.g. "CA"
Street []string `json:"street"` // Array[String] (optional) Street of address e.g. ["156 22ND AVE NW"]
Zip string `json:"zip"` // (optional) Zip of address e.g. "94123"
}
type Name struct {
Prefix string `json:"prefix"` // String (optional) The title of the provider e.g. "MD"
Given []string `json:"given"` // Array[String] Name values associated with the provider e.g. ["Travis", "R"]
Family string `json:"family"` // String (optional) Family name of the provider e.g. "Liddell"
}