AddLecture
Oleg Zech این صفحه 3 سال پیش را ویرایش کرده است
-- This function creates a new lecture and associates it with the specified classes.
-- The function accepts a list of class IDs, a subject name, a start date and time,
-- and optional parameters for a visitor name, notes, and extra data stored as JSON.

/*

end_dt is auto caluclated from start_dt + lecture duration and CANNOT BE provided
Duration comes from the MoH and cannot be edited

SUBJECT format is: <subject><level> i.e.

<ILOVEMYHEART4> is a lecture ILOVEMYHEART at the edu level 4 (4th grade of primary)
<ILOVEMYHEART7> is a lecture ILOVEMYHEART at the edu level 7 (1th grade of gymnasium)

*/

create or replace function api."AddLecture"
    (
          _classes             uuid[]          -- List of class IDs to associate with the lecture
        , _subject             capitaltext     -- ID ('BODYCARE1') of the subject for the lecture
        , _start_dt            timestamptz     -- Start date and time for the lecture
        , _visitor             name default current_user -- Name of the visitor giving the lecture
        , _notes               text default null -- Optional notes for the lecture
        , _data                jsonb default null -- Optional extra data to store with the lecture
        , _substitute_end_date date default null -- If substitute visitor, till when?
        , out _lecture         lectures.lectures -- Output parameter for the created lecture record
    )
    language plpgsql as
$$