clinical_encounter

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 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"
)
View Source
const (
	TopicVisitCreated = "clinical_encounter.visit.created"
)

Domain event topics — <module>.<entity>.<past-tense-verb>, tenant/id data goes in the payload, never in the topic name (n/a here — see "no TenantId field" note in 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 mirrors exactly the required-argument set CreateVisit enforces (visit.go) — the Definition is the single place the contract is declared; the service's manual checks are a defense-in-depth duplicate of the same set, never a different one.

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

GetVisitArgsModel and ListVisitsArgsModel are transport-only (Field.DB is nil throughout) — see Stage 3 for the ops that consume them.

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 builds the medical-history Presenter — the tech-agnostic engine a renderer (tinywasm/layout/rightpanel, or any other) wraps. This module builds it (view+model+router only); the app decides which renderer draws it.

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 // required — the module never builds its own
	Publisher events.Publisher  // optional — nil disables publishing silently
}

Deps are the module's infrastructure ports — never a concrete implementation.

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 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 implements view.Itemizer — the ONLY view-specific code this record carries. The Presenter indexes rows by ID from this during Reload; there is no manual byID/WithFill lookup.

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) ListVisitsByPatient

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

func (*Module) ModelName

func (m *Module) ModelName() string

func (*Module) MountOps

func (m *Module) MountOps(reg router.OpRegistry)

Jump to

Keyboard shortcuts

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