107 lines
3.1 KiB
Go
107 lines
3.1 KiB
Go
package models
|
|
|
|
// MockUsers represents a mock database of users
|
|
var MockUsers = []User{
|
|
{
|
|
ID: "1",
|
|
Email: "admin",
|
|
Role: "expertise_doctor",
|
|
Name: "Admin User",
|
|
CreatedAt: "2025-01-01T00:00:00Z",
|
|
UpdatedAt: "2025-01-01T00:00:00Z",
|
|
},
|
|
{
|
|
ID: "2",
|
|
Email: "patient",
|
|
Role: "patient",
|
|
Name: "Patient User",
|
|
CreatedAt: "2025-01-01T00:00:00Z",
|
|
UpdatedAt: "2025-01-01T00:00:00Z",
|
|
},
|
|
{
|
|
ID: "3",
|
|
Email: "doctor",
|
|
Role: "ref_doctor",
|
|
Name: "DR. HERWINDO RIDWAN, SP.OT",
|
|
CreatedAt: "2025-01-01T00:00:00Z",
|
|
UpdatedAt: "2025-01-01T00:00:00Z",
|
|
},
|
|
{
|
|
ID: "4",
|
|
Email: "patient2",
|
|
Role: "patient",
|
|
Name: "Patient Two",
|
|
CreatedAt: "2025-01-01T00:00:00Z",
|
|
UpdatedAt: "2025-01-01T00:00:00Z",
|
|
},
|
|
}
|
|
|
|
// PatientData represents additional data for patients
|
|
type PatientData struct {
|
|
PatientID string `json:"patient_id"`
|
|
UserID string `json:"user_id"`
|
|
StudyIUID string `json:"study_iuid,omitempty"` // For backward compatibility
|
|
StudyIUIDs []string `json:"study_iuids,omitempty"` // Multiple study IDs
|
|
AccessionNumber string `json:"accession_number,omitempty"` // For backward compatibility
|
|
AccessionNumbers []string `json:"accession_numbers,omitempty"` // Multiple accession numbers
|
|
PatientName string `json:"patient_name"`
|
|
ReferringPhysician string `json:"referring_physician"`
|
|
}
|
|
|
|
// MockPatients represents a mock database of patient data
|
|
var MockPatients = []PatientData{
|
|
{
|
|
PatientID: "00211622",
|
|
UserID: "2",
|
|
StudyIUIDs: []string{"1.2.826.0.1.3680043.9.7307.1.20180530066", "1.2.826.0.1.3680043.9.7307.1.20180713036"},
|
|
AccessionNumbers: []string{"CR.180530.066", "CR.180713.036"},
|
|
PatientName: "DIDIT SUYATNA^R.10049.18",
|
|
ReferringPhysician: "DR. HERWINDO RIDWAN, SP.OT",
|
|
},
|
|
{
|
|
PatientID: "MR00000359",
|
|
UserID: "4",
|
|
StudyIUID: "1.2.826.0.1.3680043.9.7307.1.202503196393.01",
|
|
AccessionNumber: "CR.250319.6393.01",
|
|
PatientName: "Bobon Santoso",
|
|
ReferringPhysician: "DR. HERWINDO RIDWAN, SP.OT",
|
|
},
|
|
}
|
|
|
|
// FindUserByCredentials finds a user by email and password (mock authentication)
|
|
func FindUserByCredentials(email, password string) *User {
|
|
// In a real implementation, you would hash passwords
|
|
// For the mock, we'll just match email and assume password is the same as email
|
|
if password != email {
|
|
return nil
|
|
}
|
|
|
|
for _, user := range MockUsers {
|
|
if user.Email == email {
|
|
return &user
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// FindPatientDataByUserID finds patient data by user ID
|
|
func FindPatientDataByUserID(userID string) *PatientData {
|
|
for _, patient := range MockPatients {
|
|
if patient.UserID == userID {
|
|
return &patient
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// FindStudiesByReferringPhysician returns all study IUIDs that belong to a referring physician
|
|
func FindStudiesByReferringPhysician(physicianName string) []string {
|
|
var studies []string
|
|
for _, patient := range MockPatients {
|
|
if patient.ReferringPhysician == physicianName {
|
|
studies = append(studies, patient.StudyIUID)
|
|
}
|
|
}
|
|
return studies
|
|
}
|