From dab9c2c0d6ca771f58c5544f296aa633135cc67f Mon Sep 17 00:00:00 2001 From: nikita-harripersadh Date: Fri, 21 Nov 2025 09:38:27 +0200 Subject: [PATCH 1/7] [Add: SQL data for healthcare facilities and fixtures] --- sql/14-health.sql | 139 ++++++++++++++++++++++++++++++++++++++++++++++ sql/fixtures.sql | 124 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 263 insertions(+) create mode 100644 sql/14-health.sql diff --git a/sql/14-health.sql b/sql/14-health.sql new file mode 100644 index 0000000..98391f3 --- /dev/null +++ b/sql/14-health.sql @@ -0,0 +1,139 @@ +-- --------------------------------------HEALTHCARE +-- FACILITIES------------------------------------- +-- By: Nikita Harripersadh +-- ---------------------------- HEALTHCARE FACILITIES ---------------------------- + +-- Healthcare Facility Type Lookup Table +CREATE TABLE healthcare_facility_type ( + id SERIAL NOT NULL PRIMARY KEY, + name TEXT UNIQUE NOT NULL, + description TEXT, + last_update TIMESTAMP DEFAULT now() NOT NULL, + last_update_by TEXT NOT NULL, + uuid UUID UNIQUE NOT NULL DEFAULT gen_random_uuid() +); + +COMMENT ON TABLE healthcare_facility_type IS 'Lookup table for the type of healthcare facilities (e.g., hospital, clinic, etc.).'; + +COMMENT ON COLUMN healthcare_facility_type.id IS 'The unique ID for the healthcare facility type. This is the Primary Key.'; + +COMMENT ON COLUMN healthcare_facility_type.name IS 'The name of the healthcare facility type (e.g., hospital, clinic).'; + +COMMENT ON COLUMN healthcare_facility_type.description IS 'A description of the healthcare facility type.'; + +COMMENT ON COLUMN healthcare_facility_type.last_update IS 'The date the record was last updated.'; + +COMMENT ON COLUMN healthcare_facility_type.last_update_by IS 'The user who last updated the record.'; + +COMMENT ON COLUMN healthcare_facility_type.uuid IS 'A globally unique identifier for the healthcare facility type.'; + +-- Building condition Lookup Table +CREATE TABLE building_condition ( + id SERIAL NOT NULL PRIMARY KEY, + condition_type TEXT NOT NULL, + notes TEXT, + last_update TIMESTAMP DEFAULT now() NOT NULL, + last_update_by TEXT NOT NULL, + uuid UUID UNIQUE NOT NULL DEFAULT gen_random_uuid() +); + +COMMENT ON TABLE building_condition IS 'Lookup table for different conditions of the healthcare facility buildings.'; + +COMMENT ON COLUMN building_condition.id IS 'The unique ID for the building condition. This is the Primary Key.'; + +COMMENT ON COLUMN building_condition.condition_type IS 'Type of building condition (e.g., Good, Needs Repair).'; + +COMMENT ON COLUMN building_condition.notes IS 'Additional notes about the building condition.'; + +COMMENT ON COLUMN building_condition.last_update IS 'The date the record was last updated.'; + +COMMENT ON COLUMN building_condition.last_update_by IS 'The user who last updated the record.'; + +COMMENT ON COLUMN building_condition.uuid IS 'A globally unique identifier for the building condition record.'; + +-- Healthcare facility Table +CREATE TABLE healthcare_facility ( + id SERIAL NOT NULL PRIMARY KEY, + name TEXT NOT NULL, + address VARCHAR(255), + contact_number VARCHAR(20), + capacity INTEGER, + emergency_services BOOLEAN, + last_update TIMESTAMP DEFAULT now() NOT NULL, + last_update_by TEXT NOT NULL, + uuid UUID UNIQUE NOT NULL DEFAULT gen_random_uuid(), + healthcare_facility_type_uuid UUID NOT NULL REFERENCES healthcare_facility_type(uuid), + building_condition_uuid UUID NOT NULL REFERENCES building_condition(uuid) +); + +COMMENT ON TABLE healthcare_facility IS 'Table storing healthcare facilities like hospitals, clinics, etc.'; + +COMMENT ON COLUMN healthcare_facility.id IS 'The unique ID for the healthcare facility. This is the Primary Key.'; + +COMMENT ON COLUMN healthcare_facility.name IS 'The name of the healthcare facility.'; + +COMMENT ON COLUMN healthcare_facility.address IS 'The address of the healthcare facility.'; + +COMMENT ON COLUMN healthcare_facility.contact_number IS 'The contact number of the healthcare facility.'; + +COMMENT ON COLUMN healthcare_facility.capacity IS 'The capacity of the healthcare facility (e.g., number of beds).'; + +COMMENT ON COLUMN healthcare_facility.emergency_services IS 'Whether the healthcare facility provides emergency services or not.'; + +COMMENT ON COLUMN healthcare_facility.last_update IS 'The date the record was last updated.'; + +COMMENT ON COLUMN healthcare_facility.last_update_by IS 'The user who last updated the record.'; + +COMMENT ON COLUMN healthcare_facility.uuid IS 'A globally unique identifier for the healthcare facility.'; + +COMMENT ON COLUMN healthcare_facility.healthcare_facility_type_uuid IS 'References the type of healthcare facility (e.g., hospital, clinic).'; + +COMMENT ON COLUMN healthcare_facility.building_condition_uuid IS 'References the building condition of the facility (e.g., Good, Needs Repair).'; + +-- Ownership Type Lookup Table +CREATE TABLE ownership_type ( + id SERIAL NOT NULL PRIMARY KEY, + ownership_type TEXT NOT NULL, + notes TEXT, + last_update TIMESTAMP DEFAULT now() NOT NULL, + last_update_by TEXT NOT NULL, + uuid UUID UNIQUE NOT NULL DEFAULT gen_random_uuid() +); + +COMMENT ON TABLE ownership_type IS 'Lookup table for ownership types of healthcare facilities (e.g., Public, Private).'; + +COMMENT ON COLUMN ownership_type.id IS 'The unique ID for the ownership type. This is the Primary Key.'; + +COMMENT ON COLUMN ownership_type.ownership_type IS 'The type of ownership (e.g., Public, Private).'; + +COMMENT ON COLUMN ownership_type.notes IS 'Additional notes about the ownership type.'; + +COMMENT ON COLUMN ownership_type.last_update IS 'The date the record was last updated.'; + +COMMENT ON COLUMN ownership_type.last_update_by IS 'The user who last updated the record.'; + +COMMENT ON COLUMN ownership_type.uuid IS 'A globally unique identifier for the ownership type record.'; + +-- Healthcare Facility Services Table +CREATE TABLE healthcare_facility_services ( + id SERIAL NOT NULL PRIMARY KEY, + service TEXT NOT NULL, + healthcare_facility_uuid UUID NOT NULL REFERENCES healthcare_facility(uuid), + last_update TIMESTAMP DEFAULT now() NOT NULL, + last_update_by TEXT NOT NULL, + uuid UUID UNIQUE NOT NULL DEFAULT gen_random_uuid() +); + +COMMENT ON TABLE healthcare_facility_services IS 'Table storing services offered by healthcare facilities (e.g., General consultation, Surgery).'; + +COMMENT ON COLUMN healthcare_facility_services.id IS 'The unique ID for the healthcare service. This is the Primary Key.'; + +COMMENT ON COLUMN healthcare_facility_services.service IS 'The service offered by the healthcare facility.'; + +COMMENT ON COLUMN healthcare_facility_services.healthcare_facility_uuid IS 'References the healthcare facility providing the service.'; + +COMMENT ON COLUMN healthcare_facility_services.last_update IS 'The date the record was last updated.'; + +COMMENT ON COLUMN healthcare_facility_services.last_update_by IS 'The user who last updated the record.'; + +COMMENT ON COLUMN healthcare_facility_services.uuid IS 'A globally unique identifier for the healthcare service record.'; \ No newline at end of file diff --git a/sql/fixtures.sql b/sql/fixtures.sql index cd53fed..438a754 100644 --- a/sql/fixtures.sql +++ b/sql/fixtures.sql @@ -439,3 +439,127 @@ INSERT INTO segment_condition ( ) VALUES ( 'Lindie', 'Under Repair', 'Currently under maintenance or construction' ); + + +-- healthcare facilities +-- ownership_type +INSERT INTO ownership_type (last_update_by, ownership_type, notes) VALUES ( + 'Nikita', 'Public', 'Government-owned healthcare facility.' +); +INSERT INTO ownership_type (last_update_by, ownership_type, notes) VALUES ( + 'Nikita', 'Private', 'Privately operated healthcare facility.' +); + +-- building_condition +INSERT INTO building_condition (last_update_by, condition_type, notes) VALUES ( + 'Nikita', 'Good', 'Facility is in good condition.' +); +INSERT INTO building_condition (last_update_by, condition_type, notes) VALUES ( + 'Nikita', 'Needs Repair', 'Some repairs or maintenance required.' +); +INSERT INTO building_condition (last_update_by, condition_type, notes) VALUES ( + 'Nikita', 'Under Renovation', 'Currently being renovated.' +); +INSERT INTO building_condition (last_update_by, condition_type, notes) VALUES ( + 'Nikita', 'Bad', 'Poor building condition, needs major work.' +); + +-- facility_type +INSERT INTO facility_type (last_update_by, type, notes) VALUES ( + 'Nikita', 'Hospital', 'General medical and surgical facility.' +); +INSERT INTO facility_type (last_update_by, type, notes) VALUES ( + 'Nikita', 'Doctors practice', 'General practitioner services.' +); +INSERT INTO facility_type (last_update_by, type, notes) VALUES ( + 'Nikita', 'Pharmacy', 'Dispenses medicine and medical supplies.' +); +INSERT INTO facility_type (last_update_by, type, notes) VALUES ( + 'Nikita', 'Diagnostic Imaging Centers', 'Radiology and imaging services.' +); +INSERT INTO facility_type (last_update_by, type, notes) VALUES ( + 'Nikita', 'Optometrist', 'Eye examinations and vision care.' +); +INSERT INTO facility_type (last_update_by, type, notes) VALUES ( + 'Nikita', 'Dental Office', 'Dentistry and oral care.' +); +INSERT INTO facility_type (last_update_by, type, notes) VALUES ( + 'Nikita', 'Community Healthcare Centres', 'Community-level primary healthcare.' +); +INSERT INTO facility_type (last_update_by, type, notes) VALUES ( + 'Nikita', 'Hospice', 'Pain management.' +); +INSERT INTO facility_type (last_update_by, type, notes) VALUES ( + 'Nikita', 'Womens Health', 'Women-specific healthcare services.' +); +INSERT INTO facility_type (last_update_by, type, notes) VALUES ( + 'Nikita', 'Dialysis Centre', 'Kidney dialysis treatment facility.' +); +INSERT INTO facility_type (last_update_by, type, notes) VALUES ( + 'Nikita', 'Physiotherapist', 'Rehabilitation and physical therapy.' +); +INSERT INTO facility_type (last_update_by, type, notes) VALUES ( + 'Nikita', 'Medical centre', 'General outpatient medical care.' +); +INSERT INTO facility_type (last_update_by, type, notes) VALUES ( + 'Nikita', 'Occupational therapist', 'Functional rehabilitation therapy.' +); +INSERT INTO facility_type (last_update_by, type, notes) VALUES ( + 'Nikita', 'Clinic', 'Primary healthcare clinic.' +); +INSERT INTO facility_type (last_update_by, type, notes) VALUES ( + 'Nikita', 'Optometry', 'Vision care services.' +); +INSERT INTO facility_type (last_update_by, type, notes) VALUES ( + 'Nikita', 'Chiropractor', 'Musculoskeletal adjustments and therapy.' +); + +-- facility_services +INSERT INTO facility_services (last_update_by, service, notes) VALUES ( + 'Nikita', 'General consultation', 'General doctor consultation.' +); +INSERT INTO facility_services (last_update_by, service, notes) VALUES ( + 'Nikita', 'Emergency care', 'Emergency medical response.' +); +INSERT INTO facility_services (last_update_by, service, notes) VALUES ( + 'Nikita', 'Surgery', 'General surgical procedures.' +); +INSERT INTO facility_services (last_update_by, service, notes) VALUES ( + 'Nikita', 'Radiology', 'Medical imaging services.' +); +INSERT INTO facility_services (last_update_by, service, notes) VALUES ( + 'Nikita', 'Physical therapy', 'Rehabilitation therapy.' +); +INSERT INTO facility_services (last_update_by, service, notes) VALUES ( + 'Nikita', 'Orthopedic services', 'Bone and joint treatments.' +); +INSERT INTO facility_services (last_update_by, service, notes) VALUES ( + 'Nikita', 'Pharmacy services', 'Dispensing medication.' +); +INSERT INTO facility_services (last_update_by, service, notes) VALUES ( + 'Nikita', 'Prenatal care', 'Pregnancy-related care.' +); +INSERT INTO facility_services (last_update_by, service, notes) VALUES ( + 'Nikita', 'Dental care', 'Dental treatment services.' +); +INSERT INTO facility_services (last_update_by, service, notes) VALUES ( + 'Nikita', 'Vaccinations', 'Immunization services.' +); +INSERT INTO facility_services (last_update_by, service, notes) VALUES ( + 'Nikita', 'Eye examinations/treatment', 'Optometry and visual health.' +); +INSERT INTO facility_services (last_update_by, service, notes) VALUES ( + 'Nikita', 'Counseling services', 'Mental health support.' +); +INSERT INTO facility_services (last_update_by, service, notes) VALUES ( + 'Nikita', 'Pain management', 'Pain relief and chronic care.' +); +INSERT INTO facility_services (last_update_by, service, notes) VALUES ( + 'Nikita', 'Occupational therapy', 'Functional rehabilitation.' +); +INSERT INTO facility_services (last_update_by, service, notes) VALUES ( + 'Nikita', 'Dialysis treatment', 'Kidney dialysis therapy.' +); +INSERT INTO facility_services (last_update_by, service, notes) VALUES ( + 'Nikita', 'Chiropractic services', 'Spinal and musculoskeletal alignment.' +); From 974592db362b5bd9d9c35d355c65e0e518f5a341 Mon Sep 17 00:00:00 2001 From: nikita-harripersadh Date: Fri, 21 Nov 2025 10:49:13 +0200 Subject: [PATCH 2/7] Add geometry column to healthcare_facility table --- sql/14-health.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/sql/14-health.sql b/sql/14-health.sql index 98391f3..f7bc0a3 100644 --- a/sql/14-health.sql +++ b/sql/14-health.sql @@ -59,6 +59,7 @@ CREATE TABLE healthcare_facility ( contact_number VARCHAR(20), capacity INTEGER, emergency_services BOOLEAN, + location GEOMETRY(POINT, 4326), last_update TIMESTAMP DEFAULT now() NOT NULL, last_update_by TEXT NOT NULL, uuid UUID UNIQUE NOT NULL DEFAULT gen_random_uuid(), From 74e03f7ca6440d3f21ead6dd074871353918142b Mon Sep 17 00:00:00 2001 From: nikita-harripersadh Date: Fri, 21 Nov 2025 14:29:03 +0200 Subject: [PATCH 3/7] Fix geometry ( bracket space. --- sql/14-health.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/14-health.sql b/sql/14-health.sql index f7bc0a3..738cc4c 100644 --- a/sql/14-health.sql +++ b/sql/14-health.sql @@ -59,7 +59,7 @@ CREATE TABLE healthcare_facility ( contact_number VARCHAR(20), capacity INTEGER, emergency_services BOOLEAN, - location GEOMETRY(POINT, 4326), + location GEOMETRY (POINT, 4326), last_update TIMESTAMP DEFAULT now() NOT NULL, last_update_by TEXT NOT NULL, uuid UUID UNIQUE NOT NULL DEFAULT gen_random_uuid(), From 90fc4ee758803e79400463012e2b726a481e7724 Mon Sep 17 00:00:00 2001 From: nikita-harripersadh Date: Mon, 24 Nov 2025 14:10:11 +0200 Subject: [PATCH 4/7] [Fix: SQL data for healthcare facilities and fixtures] --- sql/14-health.sql | 134 +++++++++++++++++++++++++++++----------------- sql/fixtures.sql | 34 ++++++------ 2 files changed, 103 insertions(+), 65 deletions(-) diff --git a/sql/14-health.sql b/sql/14-health.sql index 738cc4c..222006a 100644 --- a/sql/14-health.sql +++ b/sql/14-health.sql @@ -1,14 +1,13 @@ --- --------------------------------------HEALTHCARE --- FACILITIES------------------------------------- +-- -------------------------------------- HEALTHCARE FACILITIES -------------------------------------- -- By: Nikita Harripersadh -- ---------------------------- HEALTHCARE FACILITIES ---------------------------- --- Healthcare Facility Type Lookup Table +-- healthcare Facility Type Lookup Table CREATE TABLE healthcare_facility_type ( - id SERIAL NOT NULL PRIMARY KEY, + id SERIAL PRIMARY KEY, name TEXT UNIQUE NOT NULL, description TEXT, - last_update TIMESTAMP DEFAULT now() NOT NULL, + last_update TIMESTAMP NOT NULL DEFAULT now(), last_update_by TEXT NOT NULL, uuid UUID UNIQUE NOT NULL DEFAULT gen_random_uuid() ); @@ -27,12 +26,13 @@ COMMENT ON COLUMN healthcare_facility_type.last_update_by IS 'The user who last COMMENT ON COLUMN healthcare_facility_type.uuid IS 'A globally unique identifier for the healthcare facility type.'; --- Building condition Lookup Table + +-- Building Condition Lookup Table CREATE TABLE building_condition ( - id SERIAL NOT NULL PRIMARY KEY, + id SERIAL PRIMARY KEY, condition_type TEXT NOT NULL, notes TEXT, - last_update TIMESTAMP DEFAULT now() NOT NULL, + last_update TIMESTAMP NOT NULL DEFAULT now(), last_update_by TEXT NOT NULL, uuid UUID UNIQUE NOT NULL DEFAULT gen_random_uuid() ); @@ -51,20 +51,73 @@ COMMENT ON COLUMN building_condition.last_update_by IS 'The user who last update COMMENT ON COLUMN building_condition.uuid IS 'A globally unique identifier for the building condition record.'; --- Healthcare facility Table + +-- Ownership Type Lookup Table +CREATE TABLE ownership_type ( + id SERIAL PRIMARY KEY, + ownership_type TEXT NOT NULL, + notes TEXT, + last_update TIMESTAMP NOT NULL DEFAULT now(), + last_update_by TEXT NOT NULL, + uuid UUID UNIQUE NOT NULL DEFAULT gen_random_uuid() +); + +COMMENT ON TABLE ownership_type IS 'Lookup table for ownership types of healthcare facilities (e.g., Public, Private).'; + +COMMENT ON COLUMN ownership_type.id IS 'The unique ID for the ownership type. This is the Primary Key.'; + +COMMENT ON COLUMN ownership_type.ownership_type IS 'The type of ownership (e.g., Public, Private).'; + +COMMENT ON COLUMN ownership_type.notes IS 'Additional notes about the ownership type.'; + +COMMENT ON COLUMN ownership_type.last_update IS 'The date the record was last updated.'; + +COMMENT ON COLUMN ownership_type.last_update_by IS 'The user who last updated the record.'; + +COMMENT ON COLUMN ownership_type.uuid IS 'A globally unique identifier for the ownership type record.'; + + +-- Service Type Lookup Table (list of possible services) +CREATE TABLE facility_services ( + id SERIAL PRIMARY KEY, + service TEXT UNIQUE NOT NULL, + notes TEXT, + last_update TIMESTAMP NOT NULL DEFAULT now(), + last_update_by TEXT NOT NULL, + uuid UUID UNIQUE NOT NULL DEFAULT gen_random_uuid() +); + +COMMENT ON TABLE facility_services IS 'Lookup table for types of services that healthcare facilities can offer.'; + +COMMENT ON COLUMN facility_services.id IS 'The unique ID for the service type. This is the Primary Key.'; + +COMMENT ON COLUMN facility_services.service IS 'The name of the service (e.g., General consultation, Surgery).'; + +COMMENT ON COLUMN facility_services.notes IS 'Additional notes about the service.'; + +COMMENT ON COLUMN facility_services.last_update IS 'The date the record was last updated.'; + +COMMENT ON COLUMN facility_services.last_update_by IS 'The user who last updated the record.'; + +COMMENT ON COLUMN facility_services.uuid IS 'A globally unique identifier for the service type record.'; + + +-- Healthcare Facility Table CREATE TABLE healthcare_facility ( - id SERIAL NOT NULL PRIMARY KEY, + id SERIAL PRIMARY KEY, name TEXT NOT NULL, address VARCHAR(255), + geometry GEOMETRY(Point, 4326), contact_number VARCHAR(20), capacity INTEGER, emergency_services BOOLEAN, - location GEOMETRY (POINT, 4326), - last_update TIMESTAMP DEFAULT now() NOT NULL, + last_update TIMESTAMP NOT NULL DEFAULT now(), last_update_by TEXT NOT NULL, uuid UUID UNIQUE NOT NULL DEFAULT gen_random_uuid(), - healthcare_facility_type_uuid UUID NOT NULL REFERENCES healthcare_facility_type(uuid), - building_condition_uuid UUID NOT NULL REFERENCES building_condition(uuid) + + healthcare_facility_type_id INTEGER NOT NULL REFERENCES healthcare_facility_type(id), + ownership_type_id INTEGER NOT NULL REFERENCES ownership_type(id), + building_condition_id INTEGER NOT NULL REFERENCES building_condition(id) ); COMMENT ON TABLE healthcare_facility IS 'Table storing healthcare facilities like hospitals, clinics, etc.'; @@ -75,6 +128,8 @@ COMMENT ON COLUMN healthcare_facility.name IS 'The name of the healthcare facili COMMENT ON COLUMN healthcare_facility.address IS 'The address of the healthcare facility.'; +COMMENT ON COLUMN healthcare_facility.geometry IS 'The geographic location of the facility as a point (WGS84).'; + COMMENT ON COLUMN healthcare_facility.contact_number IS 'The contact number of the healthcare facility.'; COMMENT ON COLUMN healthcare_facility.capacity IS 'The capacity of the healthcare facility (e.g., number of beds).'; @@ -87,54 +142,37 @@ COMMENT ON COLUMN healthcare_facility.last_update_by IS 'The user who last updat COMMENT ON COLUMN healthcare_facility.uuid IS 'A globally unique identifier for the healthcare facility.'; -COMMENT ON COLUMN healthcare_facility.healthcare_facility_type_uuid IS 'References the type of healthcare facility (e.g., hospital, clinic).'; +COMMENT ON COLUMN healthcare_facility.healthcare_facility_type_id IS 'References the type of healthcare facility (e.g., hospital, clinic).'; -COMMENT ON COLUMN healthcare_facility.building_condition_uuid IS 'References the building condition of the facility (e.g., Good, Needs Repair).'; +COMMENT ON COLUMN healthcare_facility.ownership_type_id IS 'References the ownership type of the facility (e.g., Public, Private).'; --- Ownership Type Lookup Table -CREATE TABLE ownership_type ( - id SERIAL NOT NULL PRIMARY KEY, - ownership_type TEXT NOT NULL, - notes TEXT, - last_update TIMESTAMP DEFAULT now() NOT NULL, - last_update_by TEXT NOT NULL, - uuid UUID UNIQUE NOT NULL DEFAULT gen_random_uuid() -); +COMMENT ON COLUMN healthcare_facility.building_condition_id IS 'References the building condition of the facility (e.g., Good, Needs Repair).'; -COMMENT ON TABLE ownership_type IS 'Lookup table for ownership types of healthcare facilities (e.g., Public, Private).'; -COMMENT ON COLUMN ownership_type.id IS 'The unique ID for the ownership type. This is the Primary Key.'; - -COMMENT ON COLUMN ownership_type.ownership_type IS 'The type of ownership (e.g., Public, Private).'; - -COMMENT ON COLUMN ownership_type.notes IS 'Additional notes about the ownership type.'; - -COMMENT ON COLUMN ownership_type.last_update IS 'The date the record was last updated.'; - -COMMENT ON COLUMN ownership_type.last_update_by IS 'The user who last updated the record.'; +-- Join Table: Healthcare Facility <-> Service (many-to-many) +CREATE TABLE healthcare_facility_services ( + id SERIAL PRIMARY KEY, -COMMENT ON COLUMN ownership_type.uuid IS 'A globally unique identifier for the ownership type record.'; + healthcare_facility_id INTEGER NOT NULL REFERENCES healthcare_facility(id), + facility_services_id INTEGER NOT NULL REFERENCES facility_services(id), --- Healthcare Facility Services Table -CREATE TABLE healthcare_facility_services ( - id SERIAL NOT NULL PRIMARY KEY, - service TEXT NOT NULL, - healthcare_facility_uuid UUID NOT NULL REFERENCES healthcare_facility(uuid), - last_update TIMESTAMP DEFAULT now() NOT NULL, + last_update TIMESTAMP NOT NULL DEFAULT now(), last_update_by TEXT NOT NULL, - uuid UUID UNIQUE NOT NULL DEFAULT gen_random_uuid() + uuid UUID UNIQUE NOT NULL DEFAULT gen_random_uuid(), + + UNIQUE (healthcare_facility_id, facility_services_id) ); -COMMENT ON TABLE healthcare_facility_services IS 'Table storing services offered by healthcare facilities (e.g., General consultation, Surgery).'; +COMMENT ON TABLE healthcare_facility_services IS 'Join table storing which services are offered by which healthcare facilities.'; -COMMENT ON COLUMN healthcare_facility_services.id IS 'The unique ID for the healthcare service. This is the Primary Key.'; +COMMENT ON COLUMN healthcare_facility_services.id IS 'The unique ID for the facility-service relationship. This is the Primary Key.'; -COMMENT ON COLUMN healthcare_facility_services.service IS 'The service offered by the healthcare facility.'; +COMMENT ON COLUMN healthcare_facility_services.healthcare_facility_id IS 'References the healthcare facility providing the service.'; -COMMENT ON COLUMN healthcare_facility_services.healthcare_facility_uuid IS 'References the healthcare facility providing the service.'; +COMMENT ON COLUMN healthcare_facility_services.facility_services_id IS 'References the type of service being offered.'; COMMENT ON COLUMN healthcare_facility_services.last_update IS 'The date the record was last updated.'; COMMENT ON COLUMN healthcare_facility_services.last_update_by IS 'The user who last updated the record.'; -COMMENT ON COLUMN healthcare_facility_services.uuid IS 'A globally unique identifier for the healthcare service record.'; \ No newline at end of file +COMMENT ON COLUMN healthcare_facility_services.uuid IS 'A globally unique identifier for the facility-service relationship record.'; diff --git a/sql/fixtures.sql b/sql/fixtures.sql index 438a754..4fe88db 100644 --- a/sql/fixtures.sql +++ b/sql/fixtures.sql @@ -464,53 +464,53 @@ INSERT INTO building_condition (last_update_by, condition_type, notes) VALUES ( 'Nikita', 'Bad', 'Poor building condition, needs major work.' ); --- facility_type -INSERT INTO facility_type (last_update_by, type, notes) VALUES ( +-- healthcare_facility_type +INSERT INTO healthcare_facility_type (last_update_by, type, notes) VALUES ( 'Nikita', 'Hospital', 'General medical and surgical facility.' ); -INSERT INTO facility_type (last_update_by, type, notes) VALUES ( +INSERT INTO healthcare_facility_type (last_update_by, type, notes) VALUES ( 'Nikita', 'Doctors practice', 'General practitioner services.' ); -INSERT INTO facility_type (last_update_by, type, notes) VALUES ( +INSERT INTO healthcare_facility_type (last_update_by, type, notes) VALUES ( 'Nikita', 'Pharmacy', 'Dispenses medicine and medical supplies.' ); -INSERT INTO facility_type (last_update_by, type, notes) VALUES ( +INSERT INTO healthcare_facility_type (last_update_by, type, notes) VALUES ( 'Nikita', 'Diagnostic Imaging Centers', 'Radiology and imaging services.' ); -INSERT INTO facility_type (last_update_by, type, notes) VALUES ( +INSERT INTO healthcare_facility_type (last_update_by, type, notes) VALUES ( 'Nikita', 'Optometrist', 'Eye examinations and vision care.' ); -INSERT INTO facility_type (last_update_by, type, notes) VALUES ( +INSERT INTO healthcare_facility_type (last_update_by, type, notes) VALUES ( 'Nikita', 'Dental Office', 'Dentistry and oral care.' ); -INSERT INTO facility_type (last_update_by, type, notes) VALUES ( +INSERT INTO healthcare_facility_type (last_update_by, type, notes) VALUES ( 'Nikita', 'Community Healthcare Centres', 'Community-level primary healthcare.' ); -INSERT INTO facility_type (last_update_by, type, notes) VALUES ( +INSERT INTO healthcare_facility_type (last_update_by, type, notes) VALUES ( 'Nikita', 'Hospice', 'Pain management.' ); -INSERT INTO facility_type (last_update_by, type, notes) VALUES ( +INSERT INTO healthcare_facility_type (last_update_by, type, notes) VALUES ( 'Nikita', 'Womens Health', 'Women-specific healthcare services.' ); -INSERT INTO facility_type (last_update_by, type, notes) VALUES ( +INSERT INTO healthcare_facility_type (last_update_by, type, notes) VALUES ( 'Nikita', 'Dialysis Centre', 'Kidney dialysis treatment facility.' ); -INSERT INTO facility_type (last_update_by, type, notes) VALUES ( +INSERT INTO healthcare_facility_type (last_update_by, type, notes) VALUES ( 'Nikita', 'Physiotherapist', 'Rehabilitation and physical therapy.' ); -INSERT INTO facility_type (last_update_by, type, notes) VALUES ( +INSERT INTO healthcare_facility_type (last_update_by, type, notes) VALUES ( 'Nikita', 'Medical centre', 'General outpatient medical care.' ); -INSERT INTO facility_type (last_update_by, type, notes) VALUES ( +INSERT INTO healthcare_facility_type (last_update_by, type, notes) VALUES ( 'Nikita', 'Occupational therapist', 'Functional rehabilitation therapy.' ); -INSERT INTO facility_type (last_update_by, type, notes) VALUES ( +INSERT INTO healthcare_facility_type (last_update_by, type, notes) VALUES ( 'Nikita', 'Clinic', 'Primary healthcare clinic.' ); -INSERT INTO facility_type (last_update_by, type, notes) VALUES ( +INSERT INTO healthcare_facility_type (last_update_by, type, notes) VALUES ( 'Nikita', 'Optometry', 'Vision care services.' ); -INSERT INTO facility_type (last_update_by, type, notes) VALUES ( +INSERT INTO healthcare_facility_type (last_update_by, type, notes) VALUES ( 'Nikita', 'Chiropractor', 'Musculoskeletal adjustments and therapy.' ); From 451ef59c495c0f67a0d603118f489a9e71baa94b Mon Sep 17 00:00:00 2001 From: nikita-harripersadh Date: Tue, 25 Nov 2025 12:27:04 +0200 Subject: [PATCH 5/7] [Fix] Update healthcare SQL tables --- sql/14-health.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sql/14-health.sql b/sql/14-health.sql index 222006a..6e570a1 100644 --- a/sql/14-health.sql +++ b/sql/14-health.sql @@ -5,7 +5,7 @@ -- healthcare Facility Type Lookup Table CREATE TABLE healthcare_facility_type ( id SERIAL PRIMARY KEY, - name TEXT UNIQUE NOT NULL, + name VARCHAR UNIQUE NOT NULL, description TEXT, last_update TIMESTAMP NOT NULL DEFAULT now(), last_update_by TEXT NOT NULL, @@ -30,7 +30,7 @@ COMMENT ON COLUMN healthcare_facility_type.uuid IS 'A globally unique identifier -- Building Condition Lookup Table CREATE TABLE building_condition ( id SERIAL PRIMARY KEY, - condition_type TEXT NOT NULL, + condition_type VARCHAR NOT NULL, notes TEXT, last_update TIMESTAMP NOT NULL DEFAULT now(), last_update_by TEXT NOT NULL, @@ -55,7 +55,7 @@ COMMENT ON COLUMN building_condition.uuid IS 'A globally unique identifier for t -- Ownership Type Lookup Table CREATE TABLE ownership_type ( id SERIAL PRIMARY KEY, - ownership_type TEXT NOT NULL, + ownership_type VARCHAR NOT NULL, notes TEXT, last_update TIMESTAMP NOT NULL DEFAULT now(), last_update_by TEXT NOT NULL, @@ -80,7 +80,7 @@ COMMENT ON COLUMN ownership_type.uuid IS 'A globally unique identifier for the o -- Service Type Lookup Table (list of possible services) CREATE TABLE facility_services ( id SERIAL PRIMARY KEY, - service TEXT UNIQUE NOT NULL, + service VARCHAR UNIQUE NOT NULL, notes TEXT, last_update TIMESTAMP NOT NULL DEFAULT now(), last_update_by TEXT NOT NULL, From 7a0b772e4f448450d40e73fdf7422a9cbc46e5b5 Mon Sep 17 00:00:00 2001 From: nikita-harripersadh Date: Wed, 26 Nov 2025 09:25:41 +0200 Subject: [PATCH 6/7] Update: health facilities SQL file --- sql/14-health.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/sql/14-health.sql b/sql/14-health.sql index 6e570a1..5a7c15b 100644 --- a/sql/14-health.sql +++ b/sql/14-health.sql @@ -118,6 +118,7 @@ CREATE TABLE healthcare_facility ( healthcare_facility_type_id INTEGER NOT NULL REFERENCES healthcare_facility_type(id), ownership_type_id INTEGER NOT NULL REFERENCES ownership_type(id), building_condition_id INTEGER NOT NULL REFERENCES building_condition(id) + facility_services_id INTEGER NOT NULL REFERENCES facility_services(id), ); COMMENT ON TABLE healthcare_facility IS 'Table storing healthcare facilities like hospitals, clinics, etc.'; From a500437172548a690c2daab604f54ac1fbd6e3bb Mon Sep 17 00:00:00 2001 From: nikita-harripersadh Date: Wed, 26 Nov 2025 09:33:34 +0200 Subject: [PATCH 7/7] Update: Health Facilities SQL --- sql/14-health.sql | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sql/14-health.sql b/sql/14-health.sql index 5a7c15b..fc15b64 100644 --- a/sql/14-health.sql +++ b/sql/14-health.sql @@ -117,8 +117,7 @@ CREATE TABLE healthcare_facility ( healthcare_facility_type_id INTEGER NOT NULL REFERENCES healthcare_facility_type(id), ownership_type_id INTEGER NOT NULL REFERENCES ownership_type(id), - building_condition_id INTEGER NOT NULL REFERENCES building_condition(id) - facility_services_id INTEGER NOT NULL REFERENCES facility_services(id), + building_condition_id INTEGER NOT NULL REFERENCES building_condition(id), ); COMMENT ON TABLE healthcare_facility IS 'Table storing healthcare facilities like hospitals, clinics, etc.';