Core Functions
Survey Builder (Default.aspx)
Page Lifecycle
Page_Load
- Purpose — Initial page load handler
- Behavior — Calls
BuildPage()on first load (non-postback)
BuildPage
- Purpose — Interface initialization
- Behavior
- Sets page title
- Fetches required data
- Builds admin data
- Builds navigation
- Builds current survey
- Builds language dropdown
- Builds modal content
- Dependencies
GetData()BuildAdminData()BuildNavigation()BuildCurrentSurvey()BuildLanguageDropdown()BuildModalContent()
Data Management
GetData
- Purpose — Fetches all required data for the page
- Behavior
- Concurrently fetches
- Admin data
- Sites
- All surveys
- All questions
- Survey deletability status
- Distribution groups
- Concurrently fetches
- Dependencies — Various database contexts
GetCurrentSurvey
- Purpose — Loads the currently selected survey
- Behavior
- Finds survey by ID in
AllSurveys - Loads survey sections and questions if found
- Finds survey by ID in
- Dependencies —
AllSurveyscollection
Survey Operations
Survey Creation
- Function —
btnHandleModalAction_Click(NEW_SURVEYcase) - Purpose — Creates a new survey
- Parameters
NewSurveyTitle(string) — The title of the new surveyNewSurveyDescription(string) — The description of the new surveyNewSurveySiteId(int) — The ID of the site the survey belongs to
- Behavior
- Creates new survey record
- Sets initial metadata
- Redirects to new survey
Survey Publishing
- Function —
btnHandleModalAction_Click(PUBLISH_SURVEYcase) - Purpose — Publishes/unpublishes a survey
- Parameters
IdUnique(guid) — The unique ID of the survey to publish
- Behavior
- Creates published survey record
- Updates survey’s publish status
- Handles republishing if published version does not match current
- Handles unpublishing if published version already exists
Survey Archiving
- Function —
btnHandleModalAction_Click(ARCHIVE_SURVEYcase) - Purpose — Archives/unarchives a survey
- Parameters
IdUnique(guid) — The unique ID of the survey to archive
- Behavior
- Toggles archive status
- Unpublishes survey if published
- Updates database
- Sets all fields in UI to read-only
Survey Deletion
- Function —
btnHandleModalAction_Click(DELETE_SURVEYcase) - Purpose — Deletes a survey
- Parameters
IdUnique(guid) — The unique ID of the survey to delete
- Behavior
- Removes draft and published versions of the survey
- Redirects to empty page state
Section Management
Section Creation
- Function —
btnHandleAddSection_Click - Purpose — Adds a new section to the survey
- Parameters
CurrentSurveySections(List<Section>) — The current sections of the survey
- Behavior
- Creates new section with empty title/description
- Adds to current survey sections
- Updates UI
Section Reordering
- Function —
btnHandleModalAction_Click(REORDER_SECTIONScase) - Purpose — Reorders survey sections
- Parameters
SectionSorting(List<string>) — JSON array of section IDs in the new orderIdUnique(guid) — The unique ID of the survey
- Behavior
- Updates section order
- Saves to database
- Updates UI
Section Deletion
- Function —
btnHandleModalAction_Click(DELETE_SECTIONcase) - Purpose — Removes a section from the survey
- Parameters
hdnExtraModalData(string) — Contains the section ID to delete- Format:
{sectionId}
- Format:
- Behavior
- Removes section from collection
- Updates UI
Question Management
Adding Questions
- Function —
btnHandleModalAction_Click(ADD_PROMPTScase) - Purpose — Adds questions to a section
- Parameters
hdnExtraModalData(string) — Contains the section ID to add questions to- Format:
{sectionId}
- Format:
- Checkbox values for selected questions in format:
{sectionId}-{questionId}-Checkbox
- Behavior
- Adds selected questions to section
- Handles nested questions
- Updates UI
Reordering Questions
- Function —
btnHandleModalAction_Click(REORDER_PROMPTScase) - Purpose — Reorders questions within a section
- Parameters
hdnExtraModalData(string) — Contains the section ID- Format:
{sectionId}
- Format:
QuestionSorting(List<int>) — JSON array of question IDs in the new order
- Behavior
- Updates question order
- Saves to database
- Updates UI
Renaming Questions
- Function —
btnHandleModalAction_Click(RENAME_PROMPTorRENAME_NESTED_PROMPTcase) - Purpose — Updates question labels
- Parameters
- For
RENAME_PROMPT:hdnExtraModalData(string) — Contains section and question IDs- Format:
{sectionId}|{questionId}
- Format:
NewLabel(string) — The new label for the question
- For
RENAME_NESTED_PROMPT:hdnExtraModalData(string) — Contains section, question, and nested question IDs- Format:
{sectionId}|{questionId}|{nestedId}
- Format:
NewLabel(string) — The new label for the nested question
- For
- Behavior
- Updates question label
- Handles translations
- Updates UI
Deleting Questions
- Function —
btnHandleModalAction_Click(DELETE_PROMPTcase) - Purpose — Removes a question from a section
- Parameters
hdnExtraModalData(string) — Contains section and question IDs- Format:
{sectionId}|{questionId}
- Format:
- Behavior
- Removes question from section
- Updates UI
Autosave
btnHandleAutosave_Click
- Purpose — Handles autosaving of survey changes (invoked by the client)
- Parameters
CurrentSurvey(tblOnyxSurveys) — The current survey objectCurrentSurveySections(List<Section>) — The current sections of the survey- Various form fields for survey details, sections, and questions
- Behavior
- Saves survey title
- Saves survey description
- Saves site assignment
- Saves distribution group
- Saves all section changes
- Updates timestamps
- Dependencies — Current survey state
Survey Response (Survey.aspx)
Page Lifecycle
Page_Load
- Purpose — Initial page load handler
- Behavior
- Sets viewer state if reference ID exists
- Calls
BuildPage()on first load
BuildPage
- Purpose — Main page initialization
- Behavior
- Fetches required data
- Builds survey content based on state
- Handles admin mode
- Handles dev mode
- Builds survey sections and questions
- Manages different page states
NOT_STARTEDIN_PROGRESSSUBMITTEDVIEWER
- Dependencies
GetData()BuildCurrentSurveySections()BuildSurveySectionQuestions()
Data Management
GetData
- Purpose — Fetches all required data for the page
- Behavior — Concurrently fetches:
- All questions
- Current survey
- Dependencies — PRM database context
GetCurrentSurvey
- Purpose — Loads the published survey
- Behavior
- Finds published survey by ID
- Loads survey data
- Dependencies — PRM database context
Response Operations
Response Submission
- Function —
btnUpdateState_Click - Purpose — Handles survey submission
- Behavior
- Generates unique reference ID
- Saves all responses
- Saves HTML snapshot
- Sends email notifications
- Updates page state
- Dependencies
GenerateIdReference()SaveResponse()SaveResponseHtml()BuildEmail()
Response Saving
- Function —
SaveResponse - Purpose — Saves individual responses
- Behavior
- Saves response to database
- Handles nested questions
- Associates with providers
- Dependencies — PRM database context
Response HTML Saving
- Function —
SaveResponseHtml - Purpose — Saves HTML snapshot of response
- Behavior
- Captures survey HTML
- Saves to database
- Associates with reference ID
- Dependencies —
WebScraperhelper from PacificSnippets
Provider Data
Doctor
- Function —
GetDoctors - Purpose — Fetches available doctors
- Behavior
- Gets doctors from last 30 days
- Filters by site
- Adds “Other” option
- Dependencies — StatSchedule database
Nurse
- Function —
GetNurses - Purpose — Fetches available nurses
- Behavior
- Gets nurses by site
- Handles special cases
- Adds “Other” option
- Dependencies — PRM database
Anesthesiologist
- Function —
GetAnesthesiologists - Purpose — Fetches available anesthesiologists
- Behavior
- Gets anesthesiologists from last 30 days
- Adds “Other” option
- Dependencies — QGenda database
EMS Agency
- Function —
GetEMSAgencies - Purpose — Fetches available EMS agencies
- Behavior
- Gets agencies by site
- Adds “Other” option
- Dependencies — PRM database
Email Notifications
Email Building
- Function —
BuildEmail - Purpose — Creates email content
- Behavior
- Builds HTML email
- Includes provider information
- Includes survey responses
- Adds reference link
- Dependencies — Survey data
Email Sending
- Function —
btnUpdateState_Click(email part in caseIN_PROGRESS) - Purpose — Sends email notifications
- Behavior
- Sends to appropriate recipients based on satisfaction state
- Handles dev/admin modes
- Sets email importance
- Includes BCC recipients
- For dissatisfied responses —
recoverdissatisfiedforms@pacifichealthworks.com - For satisfied responses —
recoversurveyforms@pacifichealthworks.com - In dev/admin mode — Bart and Mike’s email addresses
- For dissatisfied responses —
- Dependencies —
GraphEmailhelper from PacificSnippets
Data Models
Survey (tblOnyxSurveys)
| Property | Type | Description |
|---|---|---|
| ID_Unique | guid | Unique identifier for the survey |
| Title | string | Survey title |
| Description | string (JSON) | Survey description with translations |
| ID_Site | int | Associated site ID |
| ID_Org | int | Associated organization ID |
| Sections | string (JSON) | Survey sections data |
| CreatedAt | DateTime | Creation timestamp |
| CreatedBy | string | Creator’s identifier |
| UpdatedAt | DateTime | Last update timestamp |
| UpdatedBy | string | Last updater’s identifier |
| IsPublished | bool | Publication status |
| PublishedAt | DateTime? | Publication timestamp (nullable) |
| IsArchived | bool | Archive status |
| Distribution_Group | string | Email distribution group |
Published Survey (tblOnyxSurveysPublished)
| Property | Type | Description |
|---|---|---|
| ID_Unique | guid | Unique identifier for the published survey |
| ID_Site | int | Associated site ID |
| ID_Org | int | Associated organization ID |
| Title | string | Survey title |
| Description | string (JSON) | Survey description with translations |
| Sections | string (JSON) | Survey sections data |
| Distribution_Group | string | Email distribution group |
Section
| Property | Type | Description |
|---|---|---|
| Id | guid | Unique identifier for the section |
| Title | string (JSON) | Section title with translations |
| Description | string (JSON) | Section description with translations |
| Questions | string (Base64) | Encoded questions data |
| Order | int | Section order in survey |
Question (AKA Prompts)
| Property | Type | Description |
|---|---|---|
| Id | int | Unique identifier for the question |
| CustomLabel | string (JSON) | Custom label with translations |
| NestedPrompts | string (JSON) | Nested questions data |
Response (tblOnyxSurveyResponses)
| Property | Type | Description |
|---|---|---|
| ID_OnyxSurveysPublished | int | Published survey ID |
| ID_Site | int | Associated site ID |
| Question | string | Survey question |
| Response | string | User’s response |
| Language | string | Response language |
| Timestamp | DateTime | Response timestamp |
| ID_Reference | int | Reference ID for the response set |
| ID_Unique | guid | Unique identifier for the response |
| ID_Provider | int? | Associated provider ID (nullable) |
Completed Survey (tblOnyxSurveyCompleted)
| Property | Type | Description |
|---|---|---|
| ID_OnyxSurveysPublished | int | Published survey ID |
| ID_Site | int | Associated site ID |
| SurveyJSON | string | Complete survey response data |
| SurveyHTML | string | HTML snapshot of the survey |
| Satisfied | bool | Satisfaction status |
| SurveyDate | DateTime | Completion date |
| ID_Reference | int | Reference ID for the response set |
| ID_Unique | guid | Unique identifier for the completed survey |