Skip to content

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
  • 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
  • DependenciesAllSurveys collection

Survey Operations

Survey Creation

  • FunctionbtnHandleModalAction_Click (NEW_SURVEY case)
  • Purpose — Creates a new survey
  • Parameters
    • NewSurveyTitle (string) — The title of the new survey
    • NewSurveyDescription (string) — The description of the new survey
    • NewSurveySiteId (int) — The ID of the site the survey belongs to
  • Behavior
    • Creates new survey record
    • Sets initial metadata
    • Redirects to new survey

Survey Publishing

  • FunctionbtnHandleModalAction_Click (PUBLISH_SURVEY case)
  • 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

  • FunctionbtnHandleModalAction_Click (ARCHIVE_SURVEY case)
  • 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

  • FunctionbtnHandleModalAction_Click (DELETE_SURVEY case)
  • 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

  • FunctionbtnHandleAddSection_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

  • FunctionbtnHandleModalAction_Click (REORDER_SECTIONS case)
  • Purpose — Reorders survey sections
  • Parameters
    • SectionSorting (List<string>) — JSON array of section IDs in the new order
    • IdUnique (guid) — The unique ID of the survey
  • Behavior
    • Updates section order
    • Saves to database
    • Updates UI

Section Deletion

  • FunctionbtnHandleModalAction_Click (DELETE_SECTION case)
  • Purpose — Removes a section from the survey
  • Parameters
    • hdnExtraModalData (string) — Contains the section ID to delete
      • Format: {sectionId}
  • Behavior
    • Removes section from collection
    • Updates UI

Question Management

Adding Questions

  • FunctionbtnHandleModalAction_Click (ADD_PROMPTS case)
  • Purpose — Adds questions to a section
  • Parameters
    • hdnExtraModalData (string) — Contains the section ID to add questions to
      • Format: {sectionId}
    • Checkbox values for selected questions in format: {sectionId}-{questionId}-Checkbox
  • Behavior
    • Adds selected questions to section
    • Handles nested questions
    • Updates UI

Reordering Questions

  • FunctionbtnHandleModalAction_Click (REORDER_PROMPTS case)
  • Purpose — Reorders questions within a section
  • Parameters
    • hdnExtraModalData (string) — Contains the section ID
      • Format: {sectionId}
    • QuestionSorting (List<int>) — JSON array of question IDs in the new order
  • Behavior
    • Updates question order
    • Saves to database
    • Updates UI

Renaming Questions

  • FunctionbtnHandleModalAction_Click (RENAME_PROMPT or RENAME_NESTED_PROMPT case)
  • Purpose — Updates question labels
  • Parameters
    • For RENAME_PROMPT:
      • hdnExtraModalData (string) — Contains section and question IDs
        • Format: {sectionId}|{questionId}
      • 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}
      • NewLabel (string) — The new label for the nested question
  • Behavior
    • Updates question label
    • Handles translations
    • Updates UI

Deleting Questions

  • FunctionbtnHandleModalAction_Click (DELETE_PROMPT case)
  • Purpose — Removes a question from a section
  • Parameters
    • hdnExtraModalData (string) — Contains section and question IDs
      • Format: {sectionId}|{questionId}
  • 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 object
    • CurrentSurveySections (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_STARTED
      • IN_PROGRESS
      • SUBMITTED
      • VIEWER
  • 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

  • FunctionbtnUpdateState_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

  • FunctionSaveResponse
  • Purpose — Saves individual responses
  • Behavior
    • Saves response to database
    • Handles nested questions
    • Associates with providers
  • Dependencies — PRM database context

Response HTML Saving

  • FunctionSaveResponseHtml
  • Purpose — Saves HTML snapshot of response
  • Behavior
    • Captures survey HTML
    • Saves to database
    • Associates with reference ID
  • DependenciesWebScraper helper from PacificSnippets

Provider Data

Doctor

  • FunctionGetDoctors
  • Purpose — Fetches available doctors
  • Behavior
    • Gets doctors from last 30 days
    • Filters by site
    • Adds “Other” option
  • Dependencies — StatSchedule database

Nurse

  • FunctionGetNurses
  • Purpose — Fetches available nurses
  • Behavior
    • Gets nurses by site
    • Handles special cases
    • Adds “Other” option
  • Dependencies — PRM database

Anesthesiologist

  • FunctionGetAnesthesiologists
  • Purpose — Fetches available anesthesiologists
  • Behavior
    • Gets anesthesiologists from last 30 days
    • Adds “Other” option
  • Dependencies — QGenda database

EMS Agency

  • FunctionGetEMSAgencies
  • Purpose — Fetches available EMS agencies
  • Behavior
    • Gets agencies by site
    • Adds “Other” option
  • Dependencies — PRM database

Email Notifications

Email Building

  • FunctionBuildEmail
  • Purpose — Creates email content
  • Behavior
    • Builds HTML email
    • Includes provider information
    • Includes survey responses
    • Adds reference link
  • Dependencies — Survey data

Email Sending

  • FunctionbtnUpdateState_Click (email part in case IN_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
  • DependenciesGraphEmail helper from PacificSnippets

Data Models

Survey (tblOnyxSurveys)

PropertyTypeDescription
ID_UniqueguidUnique identifier for the survey
TitlestringSurvey title
Descriptionstring (JSON)Survey description with translations
ID_SiteintAssociated site ID
ID_OrgintAssociated organization ID
Sectionsstring (JSON)Survey sections data
CreatedAtDateTimeCreation timestamp
CreatedBystringCreator’s identifier
UpdatedAtDateTimeLast update timestamp
UpdatedBystringLast updater’s identifier
IsPublishedboolPublication status
PublishedAtDateTime?Publication timestamp (nullable)
IsArchivedboolArchive status
Distribution_GroupstringEmail distribution group

Published Survey (tblOnyxSurveysPublished)

PropertyTypeDescription
ID_UniqueguidUnique identifier for the published survey
ID_SiteintAssociated site ID
ID_OrgintAssociated organization ID
TitlestringSurvey title
Descriptionstring (JSON)Survey description with translations
Sectionsstring (JSON)Survey sections data
Distribution_GroupstringEmail distribution group

Section

PropertyTypeDescription
IdguidUnique identifier for the section
Titlestring (JSON)Section title with translations
Descriptionstring (JSON)Section description with translations
Questionsstring (Base64)Encoded questions data
OrderintSection order in survey

Question (AKA Prompts)

PropertyTypeDescription
IdintUnique identifier for the question
CustomLabelstring (JSON)Custom label with translations
NestedPromptsstring (JSON)Nested questions data

Response (tblOnyxSurveyResponses)

PropertyTypeDescription
ID_OnyxSurveysPublishedintPublished survey ID
ID_SiteintAssociated site ID
QuestionstringSurvey question
ResponsestringUser’s response
LanguagestringResponse language
TimestampDateTimeResponse timestamp
ID_ReferenceintReference ID for the response set
ID_UniqueguidUnique identifier for the response
ID_Providerint?Associated provider ID (nullable)

Completed Survey (tblOnyxSurveyCompleted)

PropertyTypeDescription
ID_OnyxSurveysPublishedintPublished survey ID
ID_SiteintAssociated site ID
SurveyJSONstringComplete survey response data
SurveyHTMLstringHTML snapshot of the survey
SatisfiedboolSatisfaction status
SurveyDateDateTimeCompletion date
ID_ReferenceintReference ID for the response set
ID_UniqueguidUnique identifier for the completed survey