Skip to content

public ​

go
import "github.com/prescriptoo/prescriptoo-api/services/prescription/public"

Package public exposes prescription-owned clinical contracts.

Index ​

Variables ​

Suggestion errors distinguish validation, missing entries, duplicates and unavailable storage.

go
var (
    ErrInvalidSuggestion      = errors.New("invalid prescription suggestion input")
    ErrSuggestionNotFound     = errors.New("prescription suggestion not found")
    ErrSuggestionConflict     = errors.New("a suggestion with this label already exists")
    ErrSuggestionsUnavailable = errors.New("prescription suggestion storage is unavailable")
)

ErrNotImplemented identifies documentation-first prescription operations.

go
var ErrNotImplemented = errors.New("prescription operation is not implemented")

type AdviceItem ​

AdviceItem preserves advice text and an optional reusable phrase reference.

go
type AdviceItem struct {
    ID       string `json:"id" minLength:"1" pattern:"\\S"`
    PhraseID string `json:"phrase_id,omitempty"`
    Text     string `json:"text" minLength:"1" pattern:"\\S"`
}

type Association ​

Association preserves the presence or absence of an associated complaint.

go
type Association struct {
    ConceptID string `json:"concept_id,omitempty"`
    Label     string `json:"label" minLength:"1" pattern:"\\S"`
    Polarity  string `json:"polarity" enum:"present,absent"`
    RawText   string `json:"raw_text,omitempty"`
}

type CancelPrescriptionInput ​

CancelPrescriptionInput retains the record while marking it canceled.

go
type CancelPrescriptionInput struct {
    Authorization, PrescriptionID string
    Params                        CancelPrescriptionParams
}

type CancelPrescriptionParams ​

CancelPrescriptionParams requires an auditable reason and a current version.

go
type CancelPrescriptionParams struct {
    ExpectedVersion int64  `json:"expected_version" minimum:"1" example:"1"`
    Reason          string `json:"reason" minLength:"1" maxLength:"2000" pattern:"\\S" example:"Created in error; replacement follows."`
}

type ClinicalContent ​

ClinicalContent preserves the workspace sections in their supplied order.

go
type ClinicalContent struct {
    Complaints     []Complaint          `json:"complaints,omitempty" nullable:"false"`
    History        []HistoryItem        `json:"history,omitempty" nullable:"false"`
    Observations   []Observation        `json:"observations,omitempty" nullable:"false"`
    Investigations []InvestigationOrder `json:"investigations,omitempty" nullable:"false"`
    Diagnoses      []Diagnosis          `json:"diagnoses,omitempty" nullable:"false"`
    Medications    []MedicationOrder    `json:"medications,omitempty" nullable:"false"`
    Advice         []AdviceItem         `json:"advice,omitempty" nullable:"false"`
    FollowUp       *FollowUp            `json:"follow_up,omitempty"`
}

type Complaint ​

Complaint is an ordered, locally identified clinical entry.

go
type Complaint struct {
    ID        string            `json:"id" minLength:"1" pattern:"\\S"`
    ConceptID string            `json:"concept_id,omitempty"`
    Label     string            `json:"label" minLength:"1" pattern:"\\S"`
    Duration  *Duration         `json:"duration,omitempty"`
    Details   *ComplaintDetails `json:"details,omitempty"`
}

type ComplaintDetails ​

ComplaintDetails preserves qualifiers entered in the complaint workspace.

go
type ComplaintDetails struct {
    Onset              string                 `json:"onset,omitempty"`
    Course             string                 `json:"course,omitempty"`
    Severity           string                 `json:"severity,omitempty"`
    Location           string                 `json:"location,omitempty"`
    Laterality         string                 `json:"laterality,omitempty" enum:"left,right,bilateral"`
    Character          string                 `json:"character,omitempty"`
    Radiation          string                 `json:"radiation,omitempty"`
    Pattern            string                 `json:"pattern,omitempty"`
    AggravatingFactors []string               `json:"aggravating_factors,omitempty" nullable:"false"`
    RelievingFactors   []string               `json:"relieving_factors,omitempty" nullable:"false"`
    Associated         []Association          `json:"associated,omitempty" nullable:"false"`
    CustomDetails      []CustomClinicalDetail `json:"custom_details,omitempty" nullable:"false"`
}

type CreatePrescriptionInput ​

CreatePrescriptionInput carries credentials separately from client-owned fields.

go
type CreatePrescriptionInput struct {
    Authorization string
    Params        CreatePrescriptionParams
}

type CreatePrescriptionParams ​

CreatePrescriptionParams allows a patient-ID-only draft; organization and author are derived.

go
type CreatePrescriptionParams struct {
    PatientID string `json:"patient_id" minLength:"1" pattern:"\\S" example:"patient_123"`
    ClinicalContent
    EncounterDate string `json:"encounter_date,omitempty" format:"date" doc:"Defaults to the server's current date."`
    VisitReason   string `json:"visit_reason,omitempty" maxLength:"2000"`
    SpecialtyID   string `json:"specialty_id,omitempty"`
    Notes         string `json:"notes,omitempty" maxLength:"10000"`
}

type CustomClinicalDetail ​

CustomClinicalDetail retains custom clarification answers and their interpretation.

go
type CustomClinicalDetail struct {
    ID               string   `json:"id" minLength:"1" pattern:"\\S"`
    RawText          string   `json:"raw_text" minLength:"1" pattern:"\\S"`
    NormalizedValue  string   `json:"normalized_value,omitempty"`
    Attribute        string   `json:"attribute,omitempty"`
    ConceptID        string   `json:"concept_id,omitempty"`
    Confidence       *float64 `json:"confidence,omitempty" minimum:"0" maximum:"1"`
    Source           string   `json:"source" enum:"clarification-custom"`
    Status           string   `json:"status" enum:"structured,new-complaint,unstructured"`
    SourceQuestionID string   `json:"source_question_id,omitempty"`
    WasCustomAnswer  *bool    `json:"was_custom_answer,omitempty"`
    IncludeInPaper   *bool    `json:"include_in_paper,omitempty"`
}

type Diagnosis ​

Diagnosis retains an optional reference independently of its display label.

go
type Diagnosis struct {
    ID        string `json:"id" minLength:"1" pattern:"\\S"`
    ConceptID string `json:"concept_id,omitempty"`
    Label     string `json:"label" minLength:"1" pattern:"\\S"`
}

type DoctorSnapshot ​

DoctorSnapshot preserves the issuing doctor's display details independently of profile edits.

go
type DoctorSnapshot struct {
    ID             string `json:"id"`
    Name           string `json:"name"`
    LicenseNumber  string `json:"license_number"`
    Specialization string `json:"specialization"`
}

type Duration ​

Duration represents a positive clinical interval.

go
type Duration struct {
    Value int    `json:"value" minimum:"1"`
    Unit  string `json:"unit" enum:"hour,day,week,month,year"`
}

type FollowUp ​

FollowUp contains a relative interval or an exact date plus its display label.

go
type FollowUp struct {
    Label         string `json:"label" minLength:"1" pattern:"\\S"`
    Value         *int   `json:"value,omitempty" minimum:"1"`
    Unit          string `json:"unit,omitempty" enum:"hour,day,week,month,year"`
    ExactDate     string `json:"exact_date,omitempty" format:"date"`
    FormattedDate string `json:"formatted_date,omitempty" doc:"Optional display text; exact_date remains authoritative."`
}

type GetPatientHistoryInput ​

GetPatientHistoryInput retrieves prescription-derived history for an authorized patient.

go
type GetPatientHistoryInput struct {
    Authorization, PatientID, Cursor string
    Limit                            int
}

type GetPrescriptionInput ​

GetPrescriptionInput identifies a prescription within the actor's permitted context.

go
type GetPrescriptionInput struct{ Authorization, PrescriptionID string }

type HistoryItem ​

HistoryItem records positive or negative clinical history.

go
type HistoryItem struct {
    ID        string    `json:"id" minLength:"1" pattern:"\\S"`
    ConceptID string    `json:"concept_id,omitempty"`
    Label     string    `json:"label" minLength:"1" pattern:"\\S"`
    Polarity  string    `json:"polarity,omitempty" enum:"present,absent"`
    Duration  *Duration `json:"duration,omitempty"`
    Value     string    `json:"value,omitempty"`
    Emphasis  string    `json:"emphasis,omitempty" enum:"allergy"`
}

type InvestigationOrder ​

InvestigationOrder records an investigation without claiming completion tracking.

go
type InvestigationOrder struct {
    ID    string `json:"id" minLength:"1" pattern:"\\S"`
    Code  string `json:"code,omitempty"`
    Label string `json:"label" minLength:"1" pattern:"\\S"`
}

type IssuePrescriptionInput ​

IssuePrescriptionInput transitions the author's draft to immutable issued content.

go
type IssuePrescriptionInput struct {
    Authorization, PrescriptionID string
    Params                        IssuePrescriptionParams
}

type IssuePrescriptionParams ​

IssuePrescriptionParams protects issuance from stale autosaves.

go
type IssuePrescriptionParams struct {
    ExpectedVersion int64 `json:"expected_version" minimum:"1" example:"1"`
}

type ListPrescriptionsInput ​

ListPrescriptionsInput scopes a newest-first list to one authorized organization.

go
type ListPrescriptionsInput struct {
    Authorization, OrganizationID, PatientID, DoctorID, Status, Cursor string
    Limit                                                              int
}

type ListSuggestionsInput ​

ListSuggestionsInput selects a searchable, cursor-paginated catalog page.

go
type ListSuggestionsInput struct {
    Q, Cursor string
    Limit     int
}

type MedicationDuration ​

MedicationDuration allows incomplete draft instructions or an ongoing course.

go
type MedicationDuration struct {
    Value   *int   `json:"value,omitempty" minimum:"1"`
    Unit    string `json:"unit,omitempty" enum:"hour,day,week,month,year"`
    Ongoing bool   `json:"ongoing,omitempty"`
}

type MedicationOrder ​

MedicationOrder accepts a display name even without a catalog reference.

go
type MedicationOrder struct {
    ID           string `json:"id" minLength:"1" pattern:"\\S"`
    MedicationID string `json:"medication_id,omitempty"`
    DisplayName  string `json:"display_name" minLength:"1" pattern:"\\S"`
    Form         string `json:"form,omitempty"`
    Strength     string `json:"strength,omitempty"`
    SIG          SIG    `json:"sig"`
}

type Observation ​

Observation retains textual values, including compound blood-pressure readings.

go
type Observation struct {
    ID    string `json:"id" minLength:"1" pattern:"\\S"`
    Type  string `json:"type" minLength:"1" pattern:"\\S"`
    Label string `json:"label" minLength:"1" pattern:"\\S"`
    Value string `json:"value" minLength:"1" pattern:"\\S"`
    Unit  string `json:"unit,omitempty"`
}

type Page ​

Page contains a newest-first, cursor-paginated result.

go
type Page[T any] struct {
    Items      []T    `json:"items" nullable:"false"`
    NextCursor string `json:"next_cursor,omitempty"`
}

type PatchPrescriptionInput ​

PatchPrescriptionInput updates the author's draft using optimistic concurrency.

go
type PatchPrescriptionInput struct {
    Authorization, PrescriptionID string
    Params                        PatchPrescriptionParams
}

type PatchPrescriptionParams ​

PatchPrescriptionParams replaces supplied sections and preserves omissions.

go
type PatchPrescriptionParams struct {
    ExpectedVersion int64                 `json:"expected_version" minimum:"1" doc:"Must match the current version; stale writes return 409."`
    Complaints      *[]Complaint          `json:"complaints,omitempty" nullable:"false"`
    History         *[]HistoryItem        `json:"history,omitempty" nullable:"false"`
    Observations    *[]Observation        `json:"observations,omitempty" nullable:"false"`
    Investigations  *[]InvestigationOrder `json:"investigations,omitempty" nullable:"false"`
    Diagnoses       *[]Diagnosis          `json:"diagnoses,omitempty" nullable:"false"`
    Medications     *[]MedicationOrder    `json:"medications,omitempty" nullable:"false"`
    Advice          *[]AdviceItem         `json:"advice,omitempty" nullable:"false"`
    FollowUp        *FollowUp             `json:"follow_up,omitempty"`
    EncounterDate   *string               `json:"encounter_date,omitempty" nullable:"false" format:"date"`
    VisitReason     *string               `json:"visit_reason,omitempty" nullable:"true" maxLength:"2000"`
    SpecialtyID     *string               `json:"specialty_id,omitempty" nullable:"true"`
    Notes           *string               `json:"notes,omitempty" nullable:"true" maxLength:"10000"`
    Supplied        map[string]bool       `json:"-"`
}

func (PatchPrescriptionParams) TransformSchema ​

go
func (PatchPrescriptionParams) TransformSchema(_ huma.Registry, schema *huma.Schema) *huma.Schema

TransformSchema describes clearing the optional object explicitly with null. Huma's nullable tag supports scalars only, so referenced objects use anyOf.

func (*PatchPrescriptionParams) UnmarshalJSON ​

go
func (p *PatchPrescriptionParams) UnmarshalJSON(data []byte) error

UnmarshalJSON records explicit null separately from omitted fields.

type PatientPrescriptionHistory ​

PatientPrescriptionHistory contains only prescription-derived clinical history.

go
type PatientPrescriptionHistory struct {
    PatientID          string        `json:"patient_id"`
    Visits             Page[Summary] `json:"visits" doc:"Issued and canceled records, newest first; cancellations remain visible."`
    RecentObservations []Observation `json:"recent_observations" nullable:"false" doc:"Derived from issued records only, not external lab results."`
}

type Prescription ​

Prescription is doctor-owned, organization-contextual clinical content.

go
type Prescription struct {
    Summary
    ClinicalContent
    SpecialtyID        string                  `json:"specialty_id,omitempty"`
    Notes              string                  `json:"notes,omitempty"`
    PatientSnapshot    *patientpublic.Snapshot `json:"patient_snapshot,omitempty" doc:"Frozen at issuance; patient profile edits never rewrite issued content."`
    DoctorSnapshot     *DoctorSnapshot         `json:"doctor_snapshot,omitempty" doc:"Frozen at issuance."`
    CanceledByUserID   string                  `json:"canceled_by_user_id,omitempty"`
    CancellationReason string                  `json:"cancellation_reason,omitempty"`
}

type SIG ​

SIG contains structured medication directions; drafts may be incomplete.

go
type SIG struct {
    Frequency    string              `json:"frequency,omitempty"`
    Duration     *MedicationDuration `json:"duration,omitempty"`
    MealRelation string              `json:"meal_relation,omitempty" enum:"before,after,none"`
    Timing       []string            `json:"timing,omitempty" nullable:"false"`
    Instruction  string              `json:"instruction,omitempty"`
}

type SuggestionAdvice ​

SuggestionAdvice is a globally shared advice phrase for prescription generation.

go
type SuggestionAdvice struct {
    ID    string `json:"id"`
    Label string `json:"label"`
}

type SuggestionAdviceParams ​

SuggestionAdviceParams supplies the editable advice suggestion label.

go
type SuggestionAdviceParams struct {
    Label string `json:"label" minLength:"1" maxLength:"500" pattern:"\\S" example:"Example advice suggestion"`
}

type SuggestionDiagnosis ​

SuggestionDiagnosis is a globally shared diagnosis phrase for prescription generation.

go
type SuggestionDiagnosis struct {
    ID    string `json:"id"`
    Label string `json:"label"`
}

type SuggestionDiagnosisParams ​

SuggestionDiagnosisParams supplies the editable diagnosis suggestion label.

go
type SuggestionDiagnosisParams struct {
    Label string `json:"label" minLength:"1" maxLength:"500" pattern:"\\S" example:"Example diagnosis suggestion"`
}

type SuggestionInvestigation ​

SuggestionInvestigation is a globally shared investigation phrase for prescription generation.

go
type SuggestionInvestigation struct {
    ID    string `json:"id"`
    Label string `json:"label"`
}

type SuggestionInvestigationParams ​

SuggestionInvestigationParams supplies the editable investigation suggestion label.

go
type SuggestionInvestigationParams struct {
    Label string `json:"label" minLength:"1" maxLength:"500" pattern:"\\S" example:"Example investigation suggestion"`
}

type Summary ​

Summary is a lightweight prescription list item, not the complete clinical payload.

go
type Summary struct {
    ID              string     `json:"id"`
    PatientID       string     `json:"patient_id"`
    DoctorID        string     `json:"doctor_id"`
    OrganizationID  string     `json:"organization_id"`
    PatientName     string     `json:"patient_name"`
    DoctorName      string     `json:"doctor_name"`
    Status          string     `json:"status" enum:"draft,issued,canceled"`
    Version         int64      `json:"version" minimum:"1"`
    EncounterDate   string     `json:"encounter_date" format:"date"`
    VisitReason     string     `json:"visit_reason,omitempty"`
    ClinicalSummary string     `json:"clinical_summary,omitempty"`
    IssuedAt        *time.Time `json:"issued_at,omitempty"`
    CanceledAt      *time.Time `json:"canceled_at,omitempty"`
    CreatedAt       time.Time  `json:"created_at"`
    UpdatedAt       time.Time  `json:"updated_at"`
}

type UpdateSuggestionAdviceInput ​

UpdateSuggestionAdviceInput updates one advice suggestion without changing its ID.

go
type UpdateSuggestionAdviceInput struct {
    ID  string
    SuggestionAdviceParams
}

type UpdateSuggestionDiagnosisInput ​

UpdateSuggestionDiagnosisInput updates one diagnosis suggestion without changing its ID.

go
type UpdateSuggestionDiagnosisInput struct {
    ID  string
    SuggestionDiagnosisParams
}

type UpdateSuggestionInvestigationInput ​

UpdateSuggestionInvestigationInput updates one investigation suggestion without changing its ID.

go
type UpdateSuggestionInvestigationInput struct {
    ID  string
    SuggestionInvestigationParams
}

Generated by gomarkdoc

Documentation follows the source. Planned contracts are marked explicitly.