0% found this document useful (0 votes)
4 views2 pages

834 Initial Query

The document contains a SQL query that constructs a JSON object with various details about a group, including sender and receiver information, transaction details, and member demographics. It retrieves data from 'Groups', 'Member', and 'Enrollment' tables, aggregating member information into a structured JSON format. The query is limited to a specific group identified by 'GRP54321'.

Uploaded by

Dharm Pal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

834 Initial Query

The document contains a SQL query that constructs a JSON object with various details about a group, including sender and receiver information, transaction details, and member demographics. It retrieves data from 'Groups', 'Member', and 'Enrollment' tables, aggregating member information into a structured JSON format. The query is limited to a specific group identified by 'GRP54321'.

Uploaded by

Dharm Pal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

SELECT json_build_object(

'isa', json_build_object(
'control_number', '000000905',
'sender_id', 'SENDERID123',
'receiver_id', 'RECEIVERID456',
'date', TO_CHAR(CURRENT_DATE, 'YYYYMMDD'),
'time', TO_CHAR(CURRENT_TIMESTAMP, 'HH24MI'),
'usage_indicator', 'T'
),
'gs', json_build_object(
'group_control_number', '123456789',
'transaction_set_count', 1
),
'st', json_build_object(
'control_number', '0001',
'segment_count', 50
),
'bgn', json_build_object(
'reference_number', 'REF123456'
),
'sponsor', json_build_object(
'name', 'SPONSOR_NAME_NOT_AVAILABLE_IN_DB',
'tax_id', 'SPONSOR_TAX_ID_NOT_AVAILABLE'
),
'payer', json_build_object(
'name', 'PAYER_NAME_NOT_AVAILABLE_IN_DB',
'tax_id', 'PAYER_TAX_ID_NOT_AVAILABLE'
),
'members', (
SELECT json_agg(
json_build_object(
'yes_no_condition', 'Y',
'relationship_code', m."Relationship",
'maintenance_type_code', '001',
'benefit_status_code', 'AC',
'subscriber_number', m."Subscriber_ID",
'family_number', m."Member_Seq",
'group_id', e."Group_ID",
'member_id_qualifier', 'MI',
'member_id_number', m."Subscriber_ID" || '-' || m."Member_Seq",
'dates', json_build_object(
'eligibility_begin', TO_CHAR(e."Effective_Date", 'YYYYMMDD'),
'eligibility_end', TO_CHAR(e."Term_Date", 'YYYYMMDD')
),
'personal', json_build_object(
'last_name', m."Last_Name",
'first_name', m."First_Name",
'middle_name', m."Middle_Name",
'prefix', m."Salutation",
'suffix', NULL,
'ssn', m."SSN"
),
'contact', json_build_object(
'name', CONCAT_WS(' ', m."First_Name", m."Last_Name"),
'phone', NULL
),
'address', json_build_object(
'line1', NULL,
'line2', NULL,
'city', NULL,
'state', NULL,
'postal', NULL,
'country', COALESCE(m."Home_Country_Code", m."Work_Country_Code",
m."Cell_Country_Code")
),
'demographics', json_build_object(
'dob', TO_CHAR(m."Date_Of_Birth", 'YYYYMMDD'),
'gender', m."Gender",
'marital', m."Marital_Status"
),
'coverage', json_build_object(
'maintenance_type', '001',
'insurance_line', NULL,
'plan_description', NULL,
'coverage_level', e."Tier",
'benefit_begin', TO_CHAR(e."Effective_Date", 'YYYYMMDD'),
'benefit_end', TO_CHAR(e."Term_Date", 'YYYYMMDD'),
'policy_number', e."Plan_ID"
)
)
)
FROM "Member" m
JOIN "Enrollment" e
ON m."Subscriber_ID" = e."Subscriber_ID"
AND m."Member_Seq" = e."Member_Seq"
WHERE e."Group_ID" = g."Group_ID"
)
)
FROM "Groups" g
WHERE g."Group_ID" = 'GRP54321'
LIMIT 1;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy