MED-137: add doctor other jobs view (#55)

* add doctor jobs view

* change translation

* another translation change

* clean up

* add analaysis detail view to paths config

* translation

* merge fix

* fix path

* move components to shared

* refactor

* imports

* clean up
This commit is contained in:
Helena
2025-08-25 11:12:57 +03:00
committed by GitHub
parent ee86bb8829
commit 195af1db3d
156 changed files with 2823 additions and 364 deletions

View File

@@ -0,0 +1,95 @@
create policy "doctor_select"
on "medreport"."analysis_responses"
as PERMISSIVE
for SELECT
to authenticated
using (medreport.is_doctor());
create policy "doctor_select"
on "medreport"."analysis_response_elements"
as PERMISSIVE
for SELECT
to authenticated
using (medreport.is_doctor());
create policy "doctor_select"
on "medreport"."accounts"
as PERMISSIVE
for SELECT
to authenticated
using (medreport.is_doctor());
create type medreport.analysis_feedback_status as enum ('STARTED', 'DRAFT', 'COMPLETED');
CREATE TABLE medreport.doctor_analysis_feedback (
id BIGINT GENERATED BY DEFAULT as IDENTITY NOT NULL,
analysis_order_id BIGINT NOT NULL REFERENCES medreport.analysis_orders(id),
doctor_user_id UUID NULL REFERENCES auth.users(id),
user_id UUID NOT NULL REFERENCES auth.users(id),
value TEXT,
status medreport.analysis_feedback_status DEFAULT 'STARTED' NOT NULL,
created_at TIMESTAMPTZ DEFAULT NOW() NOT NULL,
updated_at TIMESTAMPTZ DEFAULT NOW(),
created_by UUID DEFAULT auth.uid() REFERENCES auth.users(id) NOT NULL,
updated_by UUID DEFAULT auth.uid() REFERENCES auth.users(id),
PRIMARY KEY (id)
);
CREATE UNIQUE INDEX doctor_analysis_feedback_analysis_order_id_key ON medreport.doctor_analysis_feedback USING btree (analysis_order_id);
CREATE OR REPLACE FUNCTION medreport.update_doctor_analysis_feedback_updated_fields()
RETURNS TRIGGER AS $$
BEGIN
NEW.updated_at = NOW();
NEW.updated_by = auth.uid();
RETURN NEW;
END;
$$ LANGUAGE plpgsql SECURITY DEFINER;
CREATE TRIGGER trigger_update_doctor_analysis_feedback_updated_fields
AFTER UPDATE ON medreport.doctor_analysis_feedback
FOR EACH ROW
EXECUTE FUNCTION medreport.update_doctor_analysis_feedback_updated_fields();
CREATE OR REPLACE FUNCTION medreport.set_doctor_analysis_feedback_created_fields()
RETURNS TRIGGER AS $$
BEGIN
NEW.created_at = NOW();
NEW.created_by = auth.uid();
RETURN NEW;
END;
$$ LANGUAGE plpgsql SECURITY DEFINER;
CREATE TRIGGER trigger_insert_doctor_analysis_feedback_created_fields
AFTER INSERT ON medreport.doctor_analysis_feedback
FOR EACH ROW
EXECUTE FUNCTION medreport.set_doctor_analysis_feedback_created_fields();
CREATE INDEX idx_doctor_analysis_feedback_analysis_order_id ON medreport.doctor_analysis_feedback(analysis_order_id);
CREATE INDEX idx_doctor_analysis_feedback_doctor_user_id ON medreport.doctor_analysis_feedback(doctor_user_id);
grant select,insert, update, delete on table medreport.doctor_analysis_feedback to authenticated;
ALTER TABLE medreport.doctor_analysis_feedback ENABLE ROW LEVEL SECURITY;
create policy "user_select"
on "medreport"."doctor_analysis_feedback"
as PERMISSIVE
for SELECT
to authenticated
using (auth.uid() = user_id);
create policy "doctor_all"
on "medreport"."doctor_analysis_feedback"
as PERMISSIVE
for ALL
to authenticated
using (medreport.is_doctor());
create policy "doctor_select"
on "medreport"."account_params"
as PERMISSIVE
for SELECT
to authenticated
using (medreport.is_doctor());