Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. determine last patient temprature

determine last patient temprature

Scheduled Pinned Locked Moved Database
question
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jassim Rahma
    wrote on last edited by
    #1

    I am using this code to determine last patient pulse in my vital_signs table.

    -- determine pusle;
    SET @pulse = (SELECT TOP 1 pulse FROM vital_signs WHERE file_no = @file_no AND visit_id = @visit_id AND pulse IS NOT NULL ORDER BY vital_id DESC)

    IF (@is_child = 'True' AND (@pulse < (SELECT CONVERT(int, system_param_value) FROM system_parameters WHERE system_param_name = 'VITAL_SIGNS_PULSE_ADULT_CHILD_MIN') OR @pulse > (SELECT CONVERT(int, system_param_value) FROM system_parameters WHERE system_param_name = 'VITAL_SIGNS_PULSE_ADULT_CHILD_MAX')))
    BEGIN
    SET @normal_pulse = 'False'
    END
    ELSE IF (@patient_gender = 'M' AND (@pulse < (SELECT CONVERT(int, system_param_value) FROM system_parameters WHERE system_param_name = 'VITAL_SIGNS_PULSE_ADULT_MALE_MIN') OR @pulse > (SELECT CONVERT(int, system_param_value) FROM system_parameters WHERE system_param_name = 'VITAL_SIGNS_PULSE_ADULT_MALE_MAX')))
    BEGIN
    SET @normal_pulse = 'False'
    END
    ELSE IF (@patient_gender = 'F' AND (@pulse < (SELECT CONVERT(int, system_param_value) FROM system_parameters WHERE system_param_name = 'VITAL_SIGNS_PULSE_ADULT_FEMALE_MIN') OR @pulse > (SELECT CONVERT(int, system_param_value) FROM system_parameters WHERE system_param_name = 'VITAL_SIGNS_PULSE_ADULT_FEMALE_MAX')))
    BEGIN
    SET @normal_pulse = 'False'
    END

    It was so easy as you can see :) now I want to do the same for the temprature but the temperature is more than one field unlike the pulse.. I have the following fields: temperature_oral temperature_axillary temperature_rectal temperature_tympanic temperature_skin How can I do the same code above to check the last temp taken from any field. Only one temp will be taken at at time so i need to get that value and the will compare using the above code...

    P D 2 Replies Last reply
    0
    • J Jassim Rahma

      I am using this code to determine last patient pulse in my vital_signs table.

      -- determine pusle;
      SET @pulse = (SELECT TOP 1 pulse FROM vital_signs WHERE file_no = @file_no AND visit_id = @visit_id AND pulse IS NOT NULL ORDER BY vital_id DESC)

      IF (@is_child = 'True' AND (@pulse < (SELECT CONVERT(int, system_param_value) FROM system_parameters WHERE system_param_name = 'VITAL_SIGNS_PULSE_ADULT_CHILD_MIN') OR @pulse > (SELECT CONVERT(int, system_param_value) FROM system_parameters WHERE system_param_name = 'VITAL_SIGNS_PULSE_ADULT_CHILD_MAX')))
      BEGIN
      SET @normal_pulse = 'False'
      END
      ELSE IF (@patient_gender = 'M' AND (@pulse < (SELECT CONVERT(int, system_param_value) FROM system_parameters WHERE system_param_name = 'VITAL_SIGNS_PULSE_ADULT_MALE_MIN') OR @pulse > (SELECT CONVERT(int, system_param_value) FROM system_parameters WHERE system_param_name = 'VITAL_SIGNS_PULSE_ADULT_MALE_MAX')))
      BEGIN
      SET @normal_pulse = 'False'
      END
      ELSE IF (@patient_gender = 'F' AND (@pulse < (SELECT CONVERT(int, system_param_value) FROM system_parameters WHERE system_param_name = 'VITAL_SIGNS_PULSE_ADULT_FEMALE_MIN') OR @pulse > (SELECT CONVERT(int, system_param_value) FROM system_parameters WHERE system_param_name = 'VITAL_SIGNS_PULSE_ADULT_FEMALE_MAX')))
      BEGIN
      SET @normal_pulse = 'False'
      END

      It was so easy as you can see :) now I want to do the same for the temprature but the temperature is more than one field unlike the pulse.. I have the following fields: temperature_oral temperature_axillary temperature_rectal temperature_tympanic temperature_skin How can I do the same code above to check the last temp taken from any field. Only one temp will be taken at at time so i need to get that value and the will compare using the above code...

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #2

      The schema you have will lead to trouble. Have the temperature table as a "transaction" sort of table. Then just query for the most recent. Do the same for the pulse, blood pressure, etc. In fact, probably have one table for all the vital signs, one record per value: ID, PatientID, TakerID, TimeStamp, ReadingType, Value

      J 1 Reply Last reply
      0
      • P PIEBALDconsult

        The schema you have will lead to trouble. Have the temperature table as a "transaction" sort of table. Then just query for the most recent. Do the same for the pulse, blood pressure, etc. In fact, probably have one table for all the vital signs, one record per value: ID, PatientID, TakerID, TimeStamp, ReadingType, Value

        J Offline
        J Offline
        Jassim Rahma
        wrote on last edited by
        #3

        but changing the table structure now is a major work! any solution with the current structure?

        P M 2 Replies Last reply
        0
        • J Jassim Rahma

          I am using this code to determine last patient pulse in my vital_signs table.

          -- determine pusle;
          SET @pulse = (SELECT TOP 1 pulse FROM vital_signs WHERE file_no = @file_no AND visit_id = @visit_id AND pulse IS NOT NULL ORDER BY vital_id DESC)

          IF (@is_child = 'True' AND (@pulse < (SELECT CONVERT(int, system_param_value) FROM system_parameters WHERE system_param_name = 'VITAL_SIGNS_PULSE_ADULT_CHILD_MIN') OR @pulse > (SELECT CONVERT(int, system_param_value) FROM system_parameters WHERE system_param_name = 'VITAL_SIGNS_PULSE_ADULT_CHILD_MAX')))
          BEGIN
          SET @normal_pulse = 'False'
          END
          ELSE IF (@patient_gender = 'M' AND (@pulse < (SELECT CONVERT(int, system_param_value) FROM system_parameters WHERE system_param_name = 'VITAL_SIGNS_PULSE_ADULT_MALE_MIN') OR @pulse > (SELECT CONVERT(int, system_param_value) FROM system_parameters WHERE system_param_name = 'VITAL_SIGNS_PULSE_ADULT_MALE_MAX')))
          BEGIN
          SET @normal_pulse = 'False'
          END
          ELSE IF (@patient_gender = 'F' AND (@pulse < (SELECT CONVERT(int, system_param_value) FROM system_parameters WHERE system_param_name = 'VITAL_SIGNS_PULSE_ADULT_FEMALE_MIN') OR @pulse > (SELECT CONVERT(int, system_param_value) FROM system_parameters WHERE system_param_name = 'VITAL_SIGNS_PULSE_ADULT_FEMALE_MAX')))
          BEGIN
          SET @normal_pulse = 'False'
          END

          It was so easy as you can see :) now I want to do the same for the temprature but the temperature is more than one field unlike the pulse.. I have the following fields: temperature_oral temperature_axillary temperature_rectal temperature_tympanic temperature_skin How can I do the same code above to check the last temp taken from any field. Only one temp will be taken at at time so i need to get that value and the will compare using the above code...

          D Offline
          D Offline
          David Mujica
          wrote on last edited by
          #4

          I'm a bit confused. Is there a timestamp field in your table ? If yes, then you want to find the MAX(timestamp) record and find the value of the temperature. Maybe something with a case statement. (Concept only, syntax is close but not correct) SELECT TempTaken = CASE Temperature_oral WHEN >0 THEN Temperature_Oral Else case Temperature_auxillary When > 0 Then Temperature_Auxillary End End FROM Vital_signs Repeat the series of case statements for each of the temperature methods. Good luck. :thumbsup:

          1 Reply Last reply
          0
          • J Jassim Rahma

            but changing the table structure now is a major work! any solution with the current structure?

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #5

            No, fix it now before it becomes really difficult. You can always create views to mimic the current schema.

            1 Reply Last reply
            0
            • J Jassim Rahma

              but changing the table structure now is a major work! any solution with the current structure?

              M Offline
              M Offline
              Mycroft Holmes
              wrote on last edited by
              #6

              You are now starting to live with the consequences of lousy data design. This query would be dead simple with a correct data structure.

              jrahma wrote:

              but changing the table structure now is a major work

              If you think it will get any better or take less effort in the future you are insane. The work arounds to service rotten design will mount the longer you leave it, then you need layer more crap on the workarounds, shortly you have a completely unworkable database.

              Never underestimate the power of human stupidity RAH

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups