clinical_encounter

package module
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2026 License: MIT Imports: 9 Imported by: 0

README

clinical_encounter

encuentro

Documentation

Index

Constants

View Source
const (
	StatusCreated    = "created"     // scheduled, not yet at clinic
	StatusArrived    = "arrived"     // patient registered at reception
	StatusTriaged    = "triaged"     // nurse took vitals, waiting for doctor
	StatusInProgress = "in_progress" // doctor started the consultation
	StatusCompleted  = "completed"
	StatusCancelled  = "cancelled"
)

Visit status — FHIR-aligned lifecycle

View Source
const (
	OpCreateVisit         = "create_visit"
	OpGetVisit            = "get_medical_history"
	OpListVisitsByPatient = "list_medical_history"
	OpListRecentPatients  = "list_recent_patients"
)
View Source
const (
	TopicVisitCreated = "clinical_encounter.visit.created"
)

Topics de eventos de dominio — <módulo>.<entidad>.<verbo-en-pasado>, los datos de tenant/id van en el payload, nunca en el nombre del topic (no aplica aquí — ver la nota "no TenantId field" en ARCHITECTURE.md).

Variables

View Source
var (
	ErrNotFound    = fmt.Err("visit not found")
	ErrMissingArgs = fmt.Err("missing required arguments")
)
View Source
var CreateVisitArgsModel = model.Definition{
	Name: "create_visit_args",
	Fields: model.Fields{
		{Name: "patient_id", Type: input.Text(), NotNull: true},
		{Name: "doctor_id", Type: input.Text(), NotNull: true},
		{Name: "attention_at", Type: input.Number(), NotNull: true},
		{Name: "reason", Type: input.Text(), NotNull: true},
		{Name: "patient_name_snapshot", Type: input.Text(), NotNull: true},
		{Name: "patient_rut_snapshot", Type: input.Text(), NotNull: true},
		{Name: "doctor_name_snapshot", Type: input.Text(), NotNull: true},
		{Name: "reservation_id", Type: input.Text()},
		{Name: "diagnostic", Type: input.Textarea()},
		{Name: "prescription", Type: input.Textarea()},
		{Name: "doctor_specialty_snapshot", Type: input.Text()},
	},
}

NotNull refleja exactamente el conjunto de argumentos requeridos que CreateVisit exige (visit.go) — el Definition es el único lugar donde se declara el contrato; las validaciones manuales del servicio son un duplicado de defensa en profundidad del mismo conjunto, nunca uno distinto.

View Source
var GetVisitArgsModel = model.Definition{
	Name: "get_visit_args",
	Fields: model.Fields{
		{Name: "id", Type: model.Text()},
	},
}

GetVisitArgsModel y ListVisitsArgsModel son solo de transporte (Field.DB es nil en todos los campos) — ver ops.go para las operaciones que los consumen.

View Source
var ListRecentPatientsArgsModel = model.Definition{
	Name: "list_recent_patients_args",
	Fields: model.Fields{
		{Name: "limit", Type: model.Int()},
	},
}

ListRecentPatientsArgsModel is transport-only, no DB fields — the picker that lists WHICH patients already have a ficha (see ListRecentPatients in patients.go) takes no filter of its own today; Limit exists so a caller can cap the scan without a schema change once volume calls for it.

View Source
var ListVisitsArgsModel = model.Definition{
	Name: "list_visits_args",
	Fields: model.Fields{
		{Name: "patient_id", Type: model.Text()},
	},
}
View Source
var MedicalHistoryModel = model.Definition{
	Name: "medical_history",
	Fields: model.Fields{
		{Name: "id", Type: model.Text(), DB: &model.FieldDB{PK: true}},
		{Name: "patient_id", Type: model.Text(), NotNull: true},
		{Name: "doctor_id", Type: model.Text(), NotNull: true},
		{Name: "reservation_id", Type: model.Text()},

		{Name: "status", Type: model.Text(), NotNull: true},
		{Name: "attention_at", Type: model.Int(), NotNull: true},
		{Name: "reason", Type: model.Text(), NotNull: true},
		{Name: "diagnostic", Type: model.Text()},
		{Name: "prescription", Type: model.Text()},
		{Name: "cie10_code", Type: model.Text()},
		{Name: "started_at", Type: model.Int()},
		{Name: "finished_at", Type: model.Int()},
		{Name: "patient_name_snapshot", Type: model.Text(), NotNull: true},
		{Name: "patient_rut_snapshot", Type: model.Text(), NotNull: true},
		{Name: "doctor_name_snapshot", Type: model.Text(), NotNull: true},
		{Name: "doctor_specialty_snapshot", Type: model.Text()},
		{Name: "updated_at", Type: model.Int(), NotNull: true},
	},
}
View Source
var MedicalHistory_ = struct {
	Id                      string
	PatientId               string
	DoctorId                string
	ReservationId           string
	Status                  string
	AttentionAt             string
	Reason                  string
	Diagnostic              string
	Prescription            string
	Cie10Code               string
	StartedAt               string
	FinishedAt              string
	PatientNameSnapshot     string
	PatientRutSnapshot      string
	DoctorNameSnapshot      string
	DoctorSpecialtySnapshot string
	UpdatedAt               string
}{
	Id:                      "id",
	PatientId:               "patient_id",
	DoctorId:                "doctor_id",
	ReservationId:           "reservation_id",
	Status:                  "status",
	AttentionAt:             "attention_at",
	Reason:                  "reason",
	Diagnostic:              "diagnostic",
	Prescription:            "prescription",
	Cie10Code:               "cie10_code",
	StartedAt:               "started_at",
	FinishedAt:              "finished_at",
	PatientNameSnapshot:     "patient_name_snapshot",
	PatientRutSnapshot:      "patient_rut_snapshot",
	DoctorNameSnapshot:      "doctor_name_snapshot",
	DoctorSpecialtySnapshot: "doctor_specialty_snapshot",
	UpdatedAt:               "updated_at",
}

Functions

func NewView

func NewView(caller router.Caller) view.Presenter

NewView construye el Presenter del historial médico — el motor agnóstico de tecnología que envuelve un renderer (rightpanel, o cualquier otro). Este módulo lo construye (view + model + router); la app decide qué renderer lo dibuja.

Types

type CreateVisitArgs

type CreateVisitArgs struct {
	PatientId               string
	DoctorId                string
	AttentionAt             int64
	Reason                  string
	PatientNameSnapshot     string
	PatientRutSnapshot      string
	DoctorNameSnapshot      string
	ReservationId           string
	Diagnostic              string
	Prescription            string
	DoctorSpecialtySnapshot string
}

func (*CreateVisitArgs) DecodeFields

func (m *CreateVisitArgs) DecodeFields(r model.FieldReader)

func (*CreateVisitArgs) EncodeFields

func (m *CreateVisitArgs) EncodeFields(w model.FieldWriter)

func (*CreateVisitArgs) IsNil

func (m *CreateVisitArgs) IsNil() bool

func (*CreateVisitArgs) ModelName

func (m *CreateVisitArgs) ModelName() string

func (*CreateVisitArgs) Pointers

func (m *CreateVisitArgs) Pointers() []any

func (*CreateVisitArgs) Schema

func (m *CreateVisitArgs) Schema() []model.Field

func (*CreateVisitArgs) Validate

func (m *CreateVisitArgs) Validate(action byte) error

type CreateVisitArgsList

type CreateVisitArgsList []*CreateVisitArgs

func (*CreateVisitArgsList) Append

func (s *CreateVisitArgsList) Append() model.Fielder

func (*CreateVisitArgsList) At

func (*CreateVisitArgsList) DecodeFields

func (s *CreateVisitArgsList) DecodeFields(_ model.FieldReader)

func (*CreateVisitArgsList) EncodeFields

func (s *CreateVisitArgsList) EncodeFields(_ model.FieldWriter)

func (*CreateVisitArgsList) IsNil

func (s *CreateVisitArgsList) IsNil() bool

func (*CreateVisitArgsList) Len

func (s *CreateVisitArgsList) Len() int

func (*CreateVisitArgsList) Pointers

func (s *CreateVisitArgsList) Pointers() []any

func (*CreateVisitArgsList) Schema

func (s *CreateVisitArgsList) Schema() []model.Field

type Deps

type Deps struct {
	IDs       model.IDGenerator // requerido — el módulo nunca lo construye por sí mismo
	Publisher events.Publisher  // opcional — nil deshabilita la publicación silenciosamente
}

Deps son los puertos de infraestructura del módulo — nunca una implementación concreta.

type GetVisitArgs

type GetVisitArgs struct {
	Id string
}

func (*GetVisitArgs) DecodeFields

func (m *GetVisitArgs) DecodeFields(r model.FieldReader)

func (*GetVisitArgs) EncodeFields

func (m *GetVisitArgs) EncodeFields(w model.FieldWriter)

func (*GetVisitArgs) IsNil

func (m *GetVisitArgs) IsNil() bool

func (*GetVisitArgs) ModelName

func (m *GetVisitArgs) ModelName() string

func (*GetVisitArgs) Pointers

func (m *GetVisitArgs) Pointers() []any

func (*GetVisitArgs) Schema

func (m *GetVisitArgs) Schema() []model.Field

func (*GetVisitArgs) Validate

func (m *GetVisitArgs) Validate(action byte) error

type GetVisitArgsList

type GetVisitArgsList []*GetVisitArgs

func (*GetVisitArgsList) Append

func (s *GetVisitArgsList) Append() model.Fielder

func (*GetVisitArgsList) At

func (s *GetVisitArgsList) At(i int) model.Fielder

func (*GetVisitArgsList) DecodeFields

func (s *GetVisitArgsList) DecodeFields(_ model.FieldReader)

func (*GetVisitArgsList) EncodeFields

func (s *GetVisitArgsList) EncodeFields(_ model.FieldWriter)

func (*GetVisitArgsList) IsNil

func (s *GetVisitArgsList) IsNil() bool

func (*GetVisitArgsList) Len

func (s *GetVisitArgsList) Len() int

func (*GetVisitArgsList) Pointers

func (s *GetVisitArgsList) Pointers() []any

func (*GetVisitArgsList) Schema

func (s *GetVisitArgsList) Schema() []model.Field

type ListRecentPatientsArgs added in v0.1.2

type ListRecentPatientsArgs struct {
	Limit int64
}

func (*ListRecentPatientsArgs) DecodeFields added in v0.1.2

func (m *ListRecentPatientsArgs) DecodeFields(r model.FieldReader)

func (*ListRecentPatientsArgs) EncodeFields added in v0.1.2

func (m *ListRecentPatientsArgs) EncodeFields(w model.FieldWriter)

func (*ListRecentPatientsArgs) IsNil added in v0.1.2

func (m *ListRecentPatientsArgs) IsNil() bool

func (*ListRecentPatientsArgs) ModelName added in v0.1.2

func (m *ListRecentPatientsArgs) ModelName() string

func (*ListRecentPatientsArgs) Pointers added in v0.1.2

func (m *ListRecentPatientsArgs) Pointers() []any

func (*ListRecentPatientsArgs) Schema added in v0.1.2

func (m *ListRecentPatientsArgs) Schema() []model.Field

func (*ListRecentPatientsArgs) Validate added in v0.1.2

func (m *ListRecentPatientsArgs) Validate(action byte) error

type ListRecentPatientsArgsList added in v0.1.2

type ListRecentPatientsArgsList []*ListRecentPatientsArgs

func (*ListRecentPatientsArgsList) Append added in v0.1.2

func (*ListRecentPatientsArgsList) At added in v0.1.2

func (*ListRecentPatientsArgsList) DecodeFields added in v0.1.2

func (s *ListRecentPatientsArgsList) DecodeFields(_ model.FieldReader)

func (*ListRecentPatientsArgsList) EncodeFields added in v0.1.2

func (s *ListRecentPatientsArgsList) EncodeFields(_ model.FieldWriter)

func (*ListRecentPatientsArgsList) IsNil added in v0.1.2

func (s *ListRecentPatientsArgsList) IsNil() bool

func (*ListRecentPatientsArgsList) Len added in v0.1.2

func (*ListRecentPatientsArgsList) Pointers added in v0.1.2

func (s *ListRecentPatientsArgsList) Pointers() []any

func (*ListRecentPatientsArgsList) Schema added in v0.1.2

func (s *ListRecentPatientsArgsList) Schema() []model.Field

type ListVisitsArgs

type ListVisitsArgs struct {
	PatientId string
}

func (*ListVisitsArgs) DecodeFields

func (m *ListVisitsArgs) DecodeFields(r model.FieldReader)

func (*ListVisitsArgs) EncodeFields

func (m *ListVisitsArgs) EncodeFields(w model.FieldWriter)

func (*ListVisitsArgs) IsNil

func (m *ListVisitsArgs) IsNil() bool

func (*ListVisitsArgs) ModelName

func (m *ListVisitsArgs) ModelName() string

func (*ListVisitsArgs) Pointers

func (m *ListVisitsArgs) Pointers() []any

func (*ListVisitsArgs) Schema

func (m *ListVisitsArgs) Schema() []model.Field

func (*ListVisitsArgs) Validate

func (m *ListVisitsArgs) Validate(action byte) error

type ListVisitsArgsList

type ListVisitsArgsList []*ListVisitsArgs

func (*ListVisitsArgsList) Append

func (s *ListVisitsArgsList) Append() model.Fielder

func (*ListVisitsArgsList) At

func (*ListVisitsArgsList) DecodeFields

func (s *ListVisitsArgsList) DecodeFields(_ model.FieldReader)

func (*ListVisitsArgsList) EncodeFields

func (s *ListVisitsArgsList) EncodeFields(_ model.FieldWriter)

func (*ListVisitsArgsList) IsNil

func (s *ListVisitsArgsList) IsNil() bool

func (*ListVisitsArgsList) Len

func (s *ListVisitsArgsList) Len() int

func (*ListVisitsArgsList) Pointers

func (s *ListVisitsArgsList) Pointers() []any

func (*ListVisitsArgsList) Schema

func (s *ListVisitsArgsList) Schema() []model.Field

type MedicalHistory

type MedicalHistory struct {
	Id                      string
	PatientId               string
	DoctorId                string
	ReservationId           string
	Status                  string
	AttentionAt             int64
	Reason                  string
	Diagnostic              string
	Prescription            string
	Cie10Code               string
	StartedAt               int64
	FinishedAt              int64
	PatientNameSnapshot     string
	PatientRutSnapshot      string
	DoctorNameSnapshot      string
	DoctorSpecialtySnapshot string
	UpdatedAt               int64
}

func ReadOneMedicalHistory

func ReadOneMedicalHistory(qb *orm.QB, model *MedicalHistory) (*MedicalHistory, error)

func (*MedicalHistory) DecodeFields

func (m *MedicalHistory) DecodeFields(r model.FieldReader)

func (*MedicalHistory) EncodeFields

func (m *MedicalHistory) EncodeFields(w model.FieldWriter)

func (*MedicalHistory) IsNil

func (m *MedicalHistory) IsNil() bool

func (*MedicalHistory) Item

func (it *MedicalHistory) Item() view.Item

Item implementa view.Itemizer — el ÚNICO código específico de view que carga este registro. El Presenter indexa las filas por ID a partir de esto durante Reload; no hay lookup manual byID/WithFill. El badge lateral lleva la fecha (leadFromUnix); Label el motivo, Description el estado — el nombre del doctor no aparece aquí porque, a diferencia de la demo, el consumidor decide qué snapshot mostrar (ver modules/clinical_encounter/view.go de mjosefa-cms, que sí conoce DoctorNameSnapshot).

func (*MedicalHistory) ModelName

func (m *MedicalHistory) ModelName() string

func (*MedicalHistory) Pointers

func (m *MedicalHistory) Pointers() []any

func (*MedicalHistory) Schema

func (m *MedicalHistory) Schema() []model.Field

func (*MedicalHistory) Validate

func (m *MedicalHistory) Validate(action byte) error

type MedicalHistoryList

type MedicalHistoryList []*MedicalHistory

func ReadAllMedicalHistory

func ReadAllMedicalHistory(qb *orm.QB) (MedicalHistoryList, error)

func (*MedicalHistoryList) Append

func (s *MedicalHistoryList) Append() model.Fielder

func (*MedicalHistoryList) At

func (*MedicalHistoryList) DecodeFields

func (s *MedicalHistoryList) DecodeFields(_ model.FieldReader)

func (*MedicalHistoryList) EncodeFields

func (s *MedicalHistoryList) EncodeFields(_ model.FieldWriter)

func (*MedicalHistoryList) IsNil

func (s *MedicalHistoryList) IsNil() bool

func (*MedicalHistoryList) Len

func (s *MedicalHistoryList) Len() int

func (*MedicalHistoryList) Pointers

func (s *MedicalHistoryList) Pointers() []any

func (*MedicalHistoryList) Schema

func (s *MedicalHistoryList) Schema() []model.Field

type Module

type Module struct {
	// contains filtered or unexported fields
}

func New

func New(db *orm.DB, deps Deps) (*Module, error)

func (*Module) CreateVisit

func (m *Module) CreateVisit(args CreateVisitArgs) (*MedicalHistory, error)

func (*Module) GetVisit

func (m *Module) GetVisit(id string) (*MedicalHistory, error)

func (*Module) ListRecentPatients added in v0.1.2

func (m *Module) ListRecentPatients(limit int) ([]*MedicalHistory, error)

ListRecentPatients returns the most recently attended patients, one row per patient_id (deduped, most recent attention_at wins), for a picker that searches "which patient has an existing ficha" rather than looking one up by an ID nobody has memorized. Sourced entirely from this module's own data — no cross-module dependency on a patient/client directory, which does not exist yet (see ARCHITECTURE.md).

func (*Module) ListVisitsByPatient

func (m *Module) ListVisitsByPatient(patientId string) ([]*MedicalHistory, error)

func (*Module) ModelName

func (m *Module) ModelName() string

func (*Module) MountOperations added in v0.1.4

func (m *Module) MountOperations(reg router.OperationRegistry)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL