Surgery Flags Software for Services and Procedures

Surgery Flags for Services and Procedures are part of the family of databases and software tools developed as part of the Healthcare Cost and Utilization Project (HCUP), a Federal-State-Industry partnership sponsored by the Agency for Healthcare Research and Quality. HCUP databases, tools, and software inform decision making at the national, State, and community levels.

The Surgery Flags Software for Services and Procedures is being made available for users who would like to identify surgical procedures and encounters using Current Procedural Terminology (CPT®) procedure coded data. AHRQ looks forward to your comments and suggestions for changes and improvements.

The Surgery Flags Software was first released in September 2014. The software was updated annually to reflect changes in ICD-9-CM and CPT codes. The initial release was valid for ICD-9-CM codes through September 2013 and CPT codes through December 2013. A second version was released in June 2015. This version not only brought the Surgery Flags software up to date for ICD-9-CM and CPT codes through 2015, but the software assignments were also validated by certified coding specialists. A third version, focusing on CPT only, was released in August 2019. This version brought the Surgery Flag software up to date for CPT codes January 2019. The software assignments were also validated by certified coding specialists. The ICD-9-CM and CPT portions of the Surgery Flags Software were separated to create two Surgery Flags tools in August 2019 -- the Surgery Flags for ICD-9-CM and the Surgery Flags for Services and Procedures.


U.S. Government Rights
This product includes CPT which is commercial technical data, which was developed exclusively at private expense by the American Medical Association, 330 North Wabash Avenue, Chicago, Illinois 60611. The American Medical Association does not agree to license CPT to the Federal Government based on the license in FAR 52.227-14 (Data Rights - General) and DFARS 252.227-7015 (Technical Data - Commercial Items) or any other license provision. The American Medical Association reserves all rights to approve any license with any Federal agency.

The five-character codes included in the Surgery Flag Software for Services and Procedures are obtained from the Current Procedural Terminology (CPT®), copyright 2019 by the American Medical Association (AMA). CPT is developed by the AMA as a listing of descriptive terms and five–character identifying codes and modifiers for reporting medical services and procedures.

The responsibility for the content of Surgery Flag Software for Services and Procedures is with the U.S. Department of Health and Human Services, Agency for Healthcare Research and Quality (AHRQ) and no endorsement by the AMA is intended or should be implied. The AMA disclaims responsibility for any consequences or liability attributable or related to any use, nonuse or interpretation of information contained in Surgery Flag Software for Services and Procedures. Fee schedules, relative value units, conversion factors and/or related components are not assigned by the AMA, are not part of CPT, and the AMA is not recommending their use. The AMA does not directly or indirectly practice medicine or dispense medical services. The AMA assumes no liability for data contained or not contained herein. Any use of CPT outside the Surgery Flag Software for Services and Procedures should refer to the most current Current Procedural Terminology which contains the complete and most current listing of CPT codes and descriptive terms.

CPT is a registered trademark of the American Medical Association.

The Surgery Flags Software for Services and Procedures provides a method for identifying surgical procedures and encounters using CPT-based data.

CPT is a proprietary coding system developed by the American Medical Association (AMA) for coding services provided by health care professionals. CPT is also referred to as HCPCS Level I. The Surgery Flags Software for Services and Procedures is current as of 2019 and can be used with any data that include CPT procedure information.

Approximately 4,700 CPT surgical procedure codes (a subset of the 9,707 CPT procedure codes) are classified as a narrowly defined therapeutic invasive surgery (NARROW) or a more broadly defined surgery that includes diagnostic invasive procedures (BROAD).

Return to Contents

The Surgery Flag software identifies surgical procedures and encounters based on the Current Procedural Terminology (CPT®) maintained by the American Medical Association. CPT procedure coding is used for physician claims and outpatient procedures.

This software includes CPT five-character codes. Descriptive terms for individual Current Procedural Terminology (CPT®) codes are not included because CPT codes are proprietary.

Values for the Surgery Flags Software for Services and Procedures

A procedure that is classified as a surgery based on a narrow, targeted, and restrictive definition (surgery flag value = NARROW) includes invasive surgical procedures:

An invasive therapeutic surgical procedure involving incision, excision, manipulation, or suturing of tissue that penetrates or breaks the skin; typically requires use of an operating room; and also requires regional anesthesia, general anesthesia, or sedation to control pain.

Guiding Key Terms:

  • Invasive (does not go through an existing orifice)
  • Therapeutic
  • Pacemakers
  • Robotic-assisted procedures
  • Laparoscopy
  • Layer closure
  • Complex repair
  • Extensive, complicated
  • Penetrating wound
  • Deep
  • Complicated
  • Tissue transfer

A procedure that is classified as a surgery based on a broad definition (surgery flag value = BROAD) includes surgical procedures that may not fit the more strict definition of surgery applied for the narrow flag, but are often performed in surgical settings. This definition includes diagnostic surgical procedures:

An invasive therapeutic or diagnostic surgical procedure involving incision, excision, manipulation, or suturing of tissue that penetrates or breaks the skin or enters a body cavity through an existing orifice; typically requires use of an operating room; and also typically requires regional anesthesia, general anesthesia, or sedation to control pain. This includes percutaneous procedures, endoscopic procedures, and all "open" surgical procedures, regardless of therapeutic or diagnostic purpose. By definition, the BROAD flag includes all narrowly defined surgical procedures as well as a broader group of diagnostic and less invasive therapeutic surgeries.

Guiding Key Terms:

  • Therapeutic and diagnostic surgeries that go through an existing orifice and require an sterile field
  • Episiotomy
  • Lacerations
  • Endoscopies in conjunction with therapeutic intervention (e.g., incision, removal of polyp, destruction of lesion)
  • Simple repair
  • Subcutaneous
  • Drainage
  • Exploratory (diagnostic)
  • Percutaneous

Examples of procedures that are classified as neither NARROW nor BROAD (surgery flag value = NEITHER) include:

  • Lithotripsy
  • Radiosurgery
  • Closed reduction
  • Colonoscopy without biopsy or removal of tissue (with exceptions noted above)
  • Use of endoscopes for diagnostic purposes only and for which nothing was removed
  • Shaving
  • Identified paired codes (see example below)

Process of Assigning CPT Procedure Codes to Surgery Flags

Following completion of ICD-9-CM code assignments to the Surgery Flags, CPT codes were assigned. Because the Procedure Classes software is an ICD-9-CM based tool and there is no equivalent tool for CPTs, another approach had to be used to efficiently assign CPTs to Surgical Flag values. The surgical CPT code mapping and assignments utilized the Optum and Truven Health Analytics ICD-9-CM to CPT crosswalks for 2013, as well as the ICD-9-CM Backbone file. The crosswalks were used to link CPT codes to equivalent ICD-9-CM codes with a surgical assignment of BROAD or NARROW; ICD-9-CM codes assigned NEITHER were not included in this mapping. Once this was done, a surgery flag assignment was obtained using the ICD-9-CM backbone file. The surgical CPT range was limited to the American Medical Association specified surgical CPT range of 10021-69990.

CPT codes whose crosswalk assignments to ICD-9-CM codes were the same in both crosswalks did not require additional review, although a 1 percent sample was reviewed to gauge consistency and face validity of this approach.

A certified clinical coding specialist, a general surgeon, an analyst, and AHRQ staff systematically reviewed and assigned CPT surgical procedure codes that had an inconsistent assignment in the crosswalks (n=447 CPT codes) or were not included in the crosswalk (n=203 CPT codes).

The following iterative process was used to review 447 CPT codes:

  • Each CPT code was reviewed by a coder and categorized based on the definitions and key terms provided above. A coder rationale was provided for each questionable code. It was made clear that "operations" does not necessarily mean that a surgical procedure.
  • If there was not one best category or if there was lack of clarity about what the procedure involved, the general surgeon reviewed the code and categorized it based on the definitions above. A surgeon rationale was provided for each questionable code.
  • AHRQ staff reviewed the codes and the rationale. Additional key terms, unique to the CPT coding system, were identified.
  • Codes were reviewed for consistency of assignments based on key terms, and consistency of treatment of paired codes (identified paired codes were assigned a value of NEITHER since the qualifying surgical code should be assigned a BROAD or NARROW value and be on the same record).
  • Assignments were reviewed for consistency and accuracy.
  • CPT code assignments were re-reviewed and discussed and reassignments were made based on consensus.
  • A final review was conducted by AHRQ staff.
  • A final version of the CPT file ("CPT Backbone file") was created and CPT codes were grouped into ranges to meet the AMA licensing agreement.
  • The final surgical CPT code software file was created from the CPT Backbone containing select fields and CPT codes grouped into ranges .

It should be noted that only surgical CPT codes were analyzed; while some medicine or professional CPT codes may code similar procedures, non-surgical codes were not included. For example, angioplasty under surgical CPT codes has a BROAD assignment while angioplasty under medicine CPT codes are considered NEITHER. This applies to CPT codes but is not an issue with ICD-9-CM procedure codes. ICD-9-CM procedure codes are not medical-discipline specific; CPT coding is medical-discipline (medicine versus surgery versus radiology) specific.

Guidelines for Assigning Procedure Codes to Surgery Flags

In the course of assigning CPT codes as a NARROW or BROAD surgery or no surgery (NEITHER), a series of guidelines were developed to ensure consistent code assignments:

  • If the code indicated that it may include an invasive process, the code was considered more narrowly defined and were assigned as NARROW.

    • 54550 - Exploration for undescended testis (inguinal or scrotal area) - NARROW
    • 63275 - Laminectomy for biopsy/excision of intraspinal neoplasm; extradural, cervical - NARROW

  • If the code indicated an "oscopy" in conjunction with any other therapeutic intervention, the code was assigned as BROAD.

    • 43200 - Esophagoscopy, rigid or flexible; diagnostic, with or without collection of specimen(s) by brushing or washing (separate procedure) - BROAD
    • 47555 - Biliary endoscopy, percutaneous via T-tube or other tract; with dilation of biliary duct stricture(s) without stent - BROAD

  • If the code indicated a procedure that went through an existing orifice and required a sterile field, it was coded as BROAD.

    • 69205 - Removal foreign body from external auditory canal; with general anesthesia - BROAD
    • 67938 - Removal of embedded foreign body, eyelid - BROAD

  • If the code was for a laparoscopic procedure that by definition requires an incision, the code could be categorized as NARROW or BROAD, depending in part on whether the procedure was intended to be therapeutic (rather than diagnostic) in nature. Procedures that were intended to be therapeutic were classified as NARROW, and procedures that were diagnostic were classified as BROAD. When the intent of the procedure could not be determined, the procedure was generally classified as BROAD.

    • 38120 - Laparoscopy, surgical, splenectomy – NARROW
    • 38571 - Laparoscopy, surgical; with bilateral total pelvic lymphadenectomy - NARROW
    • 38570 - Laparoscopy, surgical; with retroperitoneal lymph node sampling (biopsy), single or multiple - BROAD
    • 43605 - Biopsy of stomach, by laparotomy - BROAD

  • If the code indicated that it was to be used only with another surgery code (i.e., paired code), the code was assigned as not being a surgery (NEITHER).

    Example: CPT Codes for Cervical Laminectomy/Discectomy
    • 22100 - Partial excision, posterior vertebral component, single segment - NARROW
    • 22013 - Partial excision, posterior vertebral component, each additional segment (which cannot stand alone and must be used with another surgery code) - NEITHER
Return to Contents

Surgery Flags Software for Services and Procedures

The Surgery Flags Software for Services and Procedures consists of a SAS program and CSV file that includes information about the classification of procedures into the broad and narrow definitions of surgeries. The surgical flag has value of '0' (NEITHER), '1' (BROAD) or '2' (NARROW). Any code with a value of '2' always has a value of '1' as well; that is '2' NARROW is a subset of '1' BROAD. The CSV file name is:


This file can be used to assign the surgery flags to data with CPT procedures (as defined by the AMA). The Surgery Flags Software file contains flag assignments for all surgical CPT codes (broadly or narrowly defined).

CSV File

The CSV files included with the Surgical Flag for Services and Procedures tool can be loaded into almost any kind of database or statistical package. The first two rows of each file contain the field headers and also list the values for the surgical flag:

  • The first column of the CSV file contains a range of CPT codes. Individual codes and labels are not listed in this file per agreement with the AMA. In the second column users will find the surgical flag that corresponds to the range of codes.

Sample SAS Load Program

Researchers have the option of creating record-level flags for procedure-level flags. Optional code is included in the top comments section of the program that would create binary BROAD and NARROW surgery flags for each record.

The software includes a sample SAS program ("CPT_SURGERY_FLAGS_LOAD_PROGRAM.SAS") that reads in the CPT software file and creates flags to identify surgical procedures based on a BROAD or NARROW definition of surgery.

This SAS program assumes the use of discharge-level data where a single discharge record contains all of the procedure codes on a single line. The SAS load program creates surgery flags for each procedure on a discharge record. Values of '1'=BROAD or '2'=NARROW will be in each flag. Any codes that are not in the software files are assigned a surgery flag of 0.

The program is intended for data with CPT procedure codes. By default, the program assumes up to 5 CPT procedures are present on each record, although these can be adjusted by changing the following parameter in the SAS file:


Please note that in order to build a list of all discharges with "BROAD" surgeries, analysts will need to capture codes with surgery flag=1 (BROAD) as well as codes that have surgery flag=2 (NARROW) because the NARROW codes are also BROAD by definition.

Program Structure

There are two general sections to the SAS load program:

  1. In the first phase, the program loads the CSV files into SAS then creates a temporary SAS format to be used later.
  2. In the second phase, the format created above are applied to the researcher's SAS dataset in order to create the surgery flags. The default action is to create CPT surgery flags for each record on a dataset. These are procedure-level flags, and the number of flags depends on the number of procedures on each record as specified by the user.

Optional Flags

Users may wish to create a record-level flag (as opposed to procedure-level flag) to identify the entire discharge as surgical or not. In order to do this, analysts should scan the CPT surgery flags created by the program below. If any surgery flag on a record contains the values '1' or '2', a record-level surgery flag would be created with a possible value of 'surgical'. Otherwise, the record-level flag would have a value of 'not surgical'.

An example of SAS code to do this which could be added at the end of the program follows:

%if &NUMCPTPRS > 0 %then %do;
        IF CPTSFLAGS(I) IN('1','2') THEN

Step-by-Step Guide

To apply Surgical Flag assignments to your SAS dataset, follow these steps:

  • Save the CSV files and SAS program to a directory of your choosing.
  • Identify the location of the SAS dataset you wish to augment.
  • Edit the SAS load program so that:
    • The correct directory path for the CSV files and your SAS dataset is specified.
    • The maximum number of CPT codes found on each record is indicated.
    • Your SAS dataset name is provided.
    • The names of the CPT and procedure codes match those on your SAS file.
  • Run the SAS program and examine the output to make sure the surgery flags were created correctly. A partial printing of 10 records is executed by the load program.
Return to Contents

Prior to downloading the Surgery Flags Software for Services and Procedures, users must agree to a license agreement with the AMA for using CPT codes.

Click here to access the Surgery Flags Software for Services and Procedures license agreement.

Return to Contents

Publications prior to the Surgery Flags Software split into separate Surgery Flags tools for ICD-9-CM and CPT codes in May 2019 are listed here. Some publications listed here may not use the Services and Procedures version of the Surgery Flags Software.

Henke RM, Karaca, Z, Moore B, Cutler E, Liu H, Marder WD, Wong HS. Impact of Health System Affiliation on Hospital Resource Use Intensity and Quality of Care. Health Services Research. 2018 Feb;53(1):63-86.

Wu RT, Shultz BN, Gabrick KS, Abraham PF, Cabrejo R, Persing JA, Alperovich M. National Longitudinal Comparison of Patients Undergoing Surgical Management of Craniosynostosis. The Journal of Craniofacial Surgery. 2018 Oct;29(7):1755-1759.

Mull HJ, Rivard PE, Legler A, Pizer SD, Hawn MT, Itani KMF, Rosen AK. Comparing definitions of outpatient surgery: Implications for quality measurement. American Journal of Surgery. 2017 Aug;214(2):186-192.

Gavigan T, Rozario N, Matthews B, Reinke C. Trends in parastomal hernia repair in the United States: a 14-y review. The Journal of Surgical Research. 2017 Oct;218:78-85.

Reinke CE, Thomason M, Paton L, Schiffern L, Rozario N, Matthews BD. Emergency general surgery transfers in the United States: a 10-year analysis. The Journal of Surgical Research. 2017 Nov;219:128-135.

Soleimani T, Sasor SE, Spera L, Eppley BE, Socas J, Chu MW, Tholpady SS. Pediatric pyoderma gangrenosum: is it just big wounds on little adults? The Journal of Surgical Research. 2016 Nov;206(1):113-117.

Return to Contents

Questions regarding the Surgery Flags Software for Services and Procedures may be directed to HCUP User Support through the following channels:

Return to Contents

CPT only copyright 2019 American Medical Association. All rights reserved.

Internet Citation: Surgery Flag Software for Services and Procedures. Healthcare Cost and Utilization Project (HCUP). August 2019. Agency for Healthcare Research and Quality, Rockville, MD.
Are you having problems viewing or printing pages on this Website?
If you have comments, suggestions, and/or questions, please contact
Privacy Notice, Viewers & Players
Last modified 8/9/19