Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7640997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:48:41+00:00 2026-05-31T08:48:41+00:00

I have a test I have to use regularly in queries to see if

  • 0

I have a test I have to use regularly in queries to see if a CPT billing code is a billable encounter. In the SQL query, the test looks like this:

where (pvp.code between '99201' and '99215'
    or pvp.code between '99221' and '99239')

plus a whole bunch more ranges.

I tried to create a function by just plugging this in to the function, but I got an “incorrect syntax” error — not a huge surprise, really.

CREATE FUNCTION IsEncounter 
(
    @code varchar(20)
)
RETURNS bit
AS
BEGIN
    DECLARE @Result bit;

    SELECT @Result = @code between '99201' and '99215'
            or @code between '99221' and '99239';

    -- Return the result of the function
    RETURN @Result;

END

I suppose I can do something like

if (@code >= '99201' and @code <= '99215')
        or (@code >= '99221' and @code <= '99239')
    select @Result = 1
else
    select @Result = 0;

but I’d like to know the cleanest way to do this. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T08:48:43+00:00Added an answer on May 31, 2026 at 8:48 am

    Something like this should work:

    CREATE FUNCTION IsEncounter 
    (
       @code varchar(20)
    )
    RETURNS bit
    AS
    BEGIN
        DECLARE @Result bit
    
        SET @Result = CASE WHEN (@code between '99201' and '99215') or (@code between '99221' and '99239') THEN 1 ELSE 0 END
    
        RETURN @Result
    END
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following test code use Data::Dumper; my $hash = { foo =>
I use an sql server regularly and have recently been getting frustrated by the
I have a test project in Visual Studio. I use Microsoft.VisualStudio.TestTools.UnitTesting . I add
I have this script: #!/var/home/cherry/opt/perl use Test::More; use DBI; use Test::mysqld; use Data::Dumper; my
For our test fixtures we use NHibernate to generate a database schema. We have
I have a Selenium IDE (version 1.7.2) test that I use to test the
I have been suggested to use should:rise in my test case to test for
I have created total 50 test scripts. All these scripts use almost same objects
So I want to use funkload to stress test an API. I have a
You have a Python class which needs an equals test. Python should use duck-typing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.