new file structure & koneksi ke DB
This commit is contained in:
8
internal/api/models/doctor.go
Normal file
8
internal/api/models/doctor.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package models
|
||||
|
||||
// DoctorDetails contains doctor-specific data
|
||||
type DoctorDetails struct {
|
||||
DoctorID string `json:"doctor_id"`
|
||||
DoctorName string `json:"doctor_name"`
|
||||
Type string `json:"type"` // "ref_doctor" or "expertise_doctor"
|
||||
}
|
||||
18
internal/api/models/patient.go
Normal file
18
internal/api/models/patient.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package models
|
||||
|
||||
// PatientDetails contains patient-specific data
|
||||
type PatientDetails struct {
|
||||
PatientID string `json:"patient_id"`
|
||||
PatientName string `json:"patient_name"`
|
||||
StudyInstanceUIDs []string `json:"study_instance_uids,omitempty"`
|
||||
AccessionNumbers []string `json:"accession_numbers,omitempty"`
|
||||
}
|
||||
|
||||
// Study represents a DICOM study associated with a patient
|
||||
type Study struct {
|
||||
StudyInstanceUID string `json:"study_instance_uid"`
|
||||
AccessionNumber string `json:"accession_number,omitempty"`
|
||||
StudyDate string `json:"study_date,omitempty"`
|
||||
StudyDescription string `json:"study_description,omitempty"`
|
||||
Modalities string `json:"modalities,omitempty"`
|
||||
}
|
||||
52
internal/api/models/shortlink.go
Normal file
52
internal/api/models/shortlink.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package models
|
||||
|
||||
// ShortLink represents a short URL token for patient access
|
||||
type ShortLink struct {
|
||||
ID string `db:"id" json:"id"`
|
||||
Token string `db:"token" json:"token"` // The short token used in the URL
|
||||
PatientID string `db:"patient_id" json:"patient_id"`
|
||||
StudyUID string `db:"study_uid" json:"study_uid"` // The StudyInstanceUID this token grants access to
|
||||
HashedDOB string `db:"hashed_dob" json:"-"` // Hashed Date of Birth for verification
|
||||
ExpiresAt string `db:"expires_at" json:"expires_at"`
|
||||
IsRevoked bool `db:"is_revoked" json:"is_revoked"`
|
||||
CreatedAt string `db:"created_at" json:"created_at"`
|
||||
CreatedByID string `db:"created_by_id" json:"created_by_id"` // ID of admin who created this
|
||||
RemainingTries int `db:"remaining_tries" json:"-"` // Number of failed attempts allowed
|
||||
}
|
||||
|
||||
// GenerateShortLinkRequest represents request to create a short URL
|
||||
type GenerateShortLinkRequest struct {
|
||||
PatientID string `json:"patient_id"`
|
||||
StudyUID string `json:"study_uid"`
|
||||
DOB string `json:"dob"` // Date of birth in YYYY-MM-DD format
|
||||
ExpiresIn int `json:"expires_in"` // Expiry in hours (optional, defaults to 72)
|
||||
}
|
||||
|
||||
// GenerateShortLinkResponse is the response for a generated short link
|
||||
type GenerateShortLinkResponse struct {
|
||||
ShortToken string `json:"short_token"`
|
||||
FullURL string `json:"full_url"`
|
||||
ExpiresAt string `json:"expires_at"`
|
||||
}
|
||||
|
||||
// ShortLinkAuthRequest represents the shortlink authentication request
|
||||
type ShortLinkAuthRequest struct {
|
||||
ShortToken string `json:"short_token,omitempty"` // The original field
|
||||
ShortTokenAlt string `json:"shortToken,omitempty"` // Support for camelCase naming from OHIF
|
||||
DOB string `json:"dob"` // Date of birth in YYYY-MM-DD format
|
||||
}
|
||||
|
||||
func (r *ShortLinkAuthRequest) GetToken() string {
|
||||
// Use ShortTokenAlt if ShortToken is empty
|
||||
if r.ShortToken == "" {
|
||||
return r.ShortTokenAlt
|
||||
}
|
||||
return r.ShortToken
|
||||
}
|
||||
|
||||
// ShortLinkAuthResponse is the response for successful shortlink authentication
|
||||
type ShortLinkAuthResponse struct {
|
||||
AccessToken string `json:"access_token"`
|
||||
ExpiresIn int `json:"expires_in"` // Token expiry in seconds
|
||||
RedirectURL string `json:"redirect_url"`
|
||||
}
|
||||
@@ -21,21 +21,6 @@ type RefreshToken struct {
|
||||
CreatedAt string `db:"created_at" json:"created_at"`
|
||||
}
|
||||
|
||||
// PatientDetails contains patient-specific data
|
||||
type PatientDetails struct {
|
||||
PatientID string `json:"patient_id"`
|
||||
PatientName string `json:"patient_name"`
|
||||
StudyInstanceUIDs []string `json:"study_instance_uids,omitempty"`
|
||||
AccessionNumbers []string `json:"accession_numbers,omitempty"`
|
||||
}
|
||||
|
||||
// DoctorDetails contains doctor-specific data
|
||||
type DoctorDetails struct {
|
||||
DoctorID string `json:"doctor_id"`
|
||||
DoctorName string `json:"doctor_name"`
|
||||
Type string `json:"type"` // "ref_doctor" or "expertise_doctor"
|
||||
}
|
||||
|
||||
// LoginRequest represents the login form data
|
||||
type LoginRequest struct {
|
||||
Email string `json:"email"`
|
||||
@@ -59,54 +44,3 @@ type RefreshRequest struct {
|
||||
type RefreshResponse struct {
|
||||
AccessToken string `json:"access_token"`
|
||||
}
|
||||
|
||||
// ShortLink represents a short URL token for patient access
|
||||
type ShortLink struct {
|
||||
ID string `db:"id" json:"id"`
|
||||
Token string `db:"token" json:"token"` // The short token used in the URL
|
||||
PatientID string `db:"patient_id" json:"patient_id"`
|
||||
StudyUID string `db:"study_uid" json:"study_uid"` // The StudyInstanceUID this token grants access to
|
||||
HashedDOB string `db:"hashed_dob" json:"-"` // Hashed Date of Birth for verification
|
||||
ExpiresAt string `db:"expires_at" json:"expires_at"`
|
||||
IsRevoked bool `db:"is_revoked" json:"is_revoked"`
|
||||
CreatedAt string `db:"created_at" json:"created_at"`
|
||||
CreatedByID string `db:"created_by_id" json:"created_by_id"` // ID of admin who created this
|
||||
RemainingTries int `db:"remaining_tries" json:"-"` // Number of failed attempts allowed
|
||||
}
|
||||
|
||||
// GenerateShortLinkRequest represents request to create a short URL
|
||||
type GenerateShortLinkRequest struct {
|
||||
PatientID string `json:"patient_id"`
|
||||
StudyUID string `json:"study_uid"`
|
||||
DOB string `json:"dob"` // Date of birth in YYYY-MM-DD format
|
||||
ExpiresIn int `json:"expires_in"` // Expiry in hours (optional, defaults to 72)
|
||||
}
|
||||
|
||||
// GenerateShortLinkResponse is the response for a generated short link
|
||||
type GenerateShortLinkResponse struct {
|
||||
ShortToken string `json:"short_token"`
|
||||
FullURL string `json:"full_url"`
|
||||
ExpiresAt string `json:"expires_at"`
|
||||
}
|
||||
|
||||
// ShortLinkAuthRequest represents the shortlink authentication request
|
||||
type ShortLinkAuthRequest struct {
|
||||
ShortToken string `json:"short_token,omitempty"` // The original field
|
||||
ShortTokenAlt string `json:"shortToken,omitempty"` // Support for camelCase naming from OHIF
|
||||
DOB string `json:"dob"` // Date of birth in YYYY-MM-DD format
|
||||
}
|
||||
|
||||
func (r *ShortLinkAuthRequest) GetToken() string {
|
||||
// Use ShortTokenAlt if ShortToken is empty
|
||||
if r.ShortToken == "" {
|
||||
return r.ShortTokenAlt
|
||||
}
|
||||
return r.ShortToken
|
||||
}
|
||||
|
||||
// ShortLinkAuthResponse is the response for successful shortlink authentication
|
||||
type ShortLinkAuthResponse struct {
|
||||
AccessToken string `json:"access_token"`
|
||||
ExpiresIn int `json:"expires_in"` // Token expiry in seconds
|
||||
RedirectURL string `json:"redirect_url"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user