Phase 2: Leaf Position Database Query

Back to Database Queries

Refer to the Leaf Position user guide for background information.

Currently there are are  over 2 million rows in this table, so the quantity of data in a single query should be restricted by adding WHERE clauses. The following query limits by leafIndex, leafPositionIndex, and machine.

         
        SELECT
          "institution"."name" as "Institution",          -- anonymized name of institution
          "machine"."id" as "Machine",                    -- anonymized name of machine
          "machineType"."model",                          -- type of machine
          "multileafCollimator"."model" as "Collimator",  -- HD or Millenium
          "output"."dataDate",                            -- time and date that data was collected
       -- "output"."analysisDate",                        -- time and date that data was analyzed
          "leafPosition"."beamName",                      -- name of beam in RTPLAN
          "leafPosition"."leafIndex",                     -- leaf number starting at 1
          "leafPosition"."leafPositionIndex",             -- leaf position number as it moves across the field.  This will be a number from 1 to 10.
          "leafPosition"."offset_mm",                     -- difference from expected location in mm: measuredEndPosition_mm - expectedEndPosition_mm
          "leafPosition"."measuredEndPosition_mm",        -- measured position of leaf end in mm
          "leafPosition"."expectedEndPosition_mm",        -- expected position of leaf end in mm
          "leafPosition"."measuredLowSide_mm",            -- measured position of top side of leaf in mm
          "leafPosition"."measuredHighSide_mm"            -- measured position of bottom side of leaf in mm
		FROM
          public."leafPosition",
          public."institution",
          public."machine",
          public."machineType",
          public."multileafCollimator",
          public."output"
        WHERE
              ("leafPosition"."outputPK" = "output"."outputPK")
          AND ("output"."machinePK" = "machine"."machinePK")
          AND ("machine"."institutionPK" = "institution"."institutionPK")
          AND ("machine"."machineTypePK" = "machineType"."machineTypePK")
          AND ("machine"."multileafCollimatorPK" = "multileafCollimator"."multileafCollimatorPK")
          AND ("leafPosition"."leafIndex" = 5)           -- restrict search to a given leaf
          AND ("leafPosition"."leafPositionIndex" = 2)   -- restrict search to a given leaf position
          AND ("machine"."id" = 'MACH_2')                -- restrict search to a given machine
        ORDER BY
          "institution"."name",
          "machine"."id",
          "output"."dataDate",
          "leafPosition"."leafIndex",
          "leafPosition"."leafPositionIndex"
        ASC LIMIT 10;  -- limit to first 10 entries