ONCSAPI ;Hines OIFO/SG - ONCOLOGY WEB-SERVICE  ; 12/7/06 10:37am
 ;;2.2;ONCOLOGY;**1**;Jul 31, 2013;Build 8
 ;
 ; ONCSAPI ------------- API DESCRIPTOR
 ;
 ; ONCSAPI(
 ;
 ;   "DEBUG")            Debug mode
 ;                         0  Disabled
 ;                         1  Enabled
 ;
 ;   "MSG",              ""
 ;     IEN,
 ;       0)              Error Descriptor
 ;                         ^01: Error Code   (see MSGLIST^ONCSAPIE)
 ;                         ^02: Error Message
 ;                         ^03: Label+Offset (optional)
 ;                         ^04: Routine      (optional)
 ;       1,i)            Error details (text)
 ;     "E",
 ;       Error Code,
 ;         IEN)    ""
 ;
 ; ^XTMP("ONCSAPI") ---- LOCAL CACHE FOR WEB-SERVICE DATA
 ;
 ; ^XTMP("ONCSAPI",
 ;
 ;   0)                  Node descriptor
 ;                         ^01: Purge date  (FileMan)
 ;                         ^02: Create date (FileMan)
 ;                         ^03: Description
 ;
 ;   "EDITS",            Metafile Version
 ;     IEN,
 ;       0)              Edit Descriptor
 ;                         ^01: Index in the edit set
 ;                         ^02: Name
 ;       "D",i)          Description
 ;       "H",i)          Help
 ;     "ES",
 ;       EditSetName,
 ;         EditIndex)    IEN
 ;
 ;   "SCHEMAS",
 ;     Schema#,
 ;       0)              Schema name
 ;
 ;     "N",
 ;       Name)           Schema#
 ;
 ;     "SH",
 ;       Site,Hist)      Schema#
 ;
 ;   "TABLES",           DLL Version
 ;
 ;     IEN,
 ;       0)              Table descriptor
 ;                         ^01: Number of rows
 ;                         ^02: Schema number
 ;                         ^03: Table number
 ;                         ^04: Table pattern
 ;                         ^05: Table title
 ;                         ^06: Table subtitle
 ;       Row#,
 ;         1)            Codes
 ;                         ^01: Row code
 ;                         ^02: Additional code #1
 ;                         ^03: Additional code #2
 ;                         ^04: ...
 ;         3,i)          Description (text)
 ;
 ;       "C",
 ;         RowCode)      Descriptor
 ;                         ^01: Row#
 ;                         ^02: Upper boundary (for intervals)
 ;
 ;       "FN",
 ;         Note#,i)      Footnote (text)
 ;       "TN",
 ;         Note#,i)      Note (text)
 ;
 ;     "ST",
 ;       Schema#,
 ;         Table#)       IEN
 ;
 ; CS TABLE NUMBER ----- TABLE DESCRIPTION
 ;
 ;               1       CS Tumor Size
 ;               2       CS Extension
 ;               3       CS Size/Ext Eval
 ;               4       CS Lymph Nodes
 ;               5       CS Reg Nodes Eval
 ;               6       Regional Nodes Positive
 ;               7       Regional Nodes Examined
 ;               8       CS Mets at DX
 ;               9       CS Mets Eval
 ;              10       CS Site-Specific Factor 1
 ;              11       CS Site-Specific Factor 2
 ;              12       CS Site-Specific Factor 3
 ;              13       CS Site-Specific Factor 4
 ;              14       CS Site-Specific Factor 5
 ;              15       CS Site-Specific Factor 6 
 ;              16       CS Site-Specific Factor 7 
 ;              17       CS Site-Specific Factor 8
 ;              18       CS Site-Specific Factor 9
 ;              19       CS Site-Specific Factor 10
 ;              20       CS Site-Specific Factor 11
 ;              21       CS Site-Specific Factor 12
 ;              22       CS Site-Specific Factor 13
 ;              23       CS Site-Specific Factor 14
 ;              24       CS Site-Specific Factor 15
 ;              25       CS Site-Specific Factor 16
 ;              26       CS Site-Specific Factor 17
 ;              27       CS Site-Specific Factor 18
 ;              28       CS Site-Specific Factor 19
 ;              29       CS Site-Specific Factor 20
 ;              30       CS Site-Specific Factor 21
 ;              31       CS Site-Specific Factor 22
 ;              32       CS Site-Specific Factor 23
 ;              33       CS Site-Specific Factor 24
 ;              34       CS Site-Specific Factor 25
 ;              35       Histologies
 ;
 ; CS ENTRY POINT ------ DESCRIPTION
 ;
 ;       HELP^ONCSAPI1   Displays the field's valid codes
 ;      INPUT^ONCSAPI1   Checks if the code is valid
 ;
 ;     $$CALC^ONCSAPI3   Calculates the staging values
 ;
 ;   $$SCHEMA^ONCSAPIS   Returns schema number
 ;
 ; $$CODEDESC^ONCSAPIT   Loads the CS code description
 ; $$GETCSTBL^ONCSAPIT   Returns table IEN (loads table if necessary)
 ;
 ; EDITS ENTRY POINT --- DESCRIPTION
 ;
 ;  $$RBQEXEC^ONCSED01   Executes the 'Run Batch' EDITS request
 ;  $$RBQPREP^ONCSED01   Starts preparation of the 'Run Batch' request
 ;
 ;   $$REPORT^ONCSED01   Prints EDITS report generated by the
 ;                       $$RBQEXEC^ONCSED01
 ;
 ; $$GETEDESC^ONCSED04   Returns the edit description node
 ; $$GETEDHLP^ONCSED04   Returns the edit help text node
 ;
 ; UTILITY ------------- DESCRIPTION
 ;
 ;       DEMO^ONCSAPI    Demonstration entry point
 ;
 ;      CLEAR^ONCSAPIE   Initializes the error stack
 ;      $$DBS^ONCSAPIE   Cehcks for FileMan DBS errors
 ;    $$ERROR^ONCSAPIE   Generates an error message
 ;      $$MSG^ONCSAPIE   Returns the text and type of the message
 ;    PRTERRS^ONCSAPIE   Displays the error messages
 ;      STORE^ONCSAPIE   Stores the message into the error stack
 ;
 ;   $$CHKERR^ONCSAPIR   Checks for parsing and web-service errors
 ;     HEADER^ONCSAPIR   Generates the request header
 ;   $$PARAMS^ONCSAPIR   Converts input parameters into XML format
 ;        PUT^ONCSAPIR   Adds element/text to the destination buffer
 ;  $$REQUEST^ONCSAPIR   Sends the request and gets the response
 ;    TRAILER^ONCSAPIR   Generates the request trailer
 ;
 ; $$GETCSURL^ONCSAPIU   Returns the Oncology web-service URL
 ;     $$PAGE^ONCSAPIU   Pauses the output at page end
 ; $$UPDCSURL^ONCSAPIU   Updates the Oncology web-service URL
 ;         WW^ONCSAPIU   Wraps the string and prints it
 ;         ZW^ONCSAPIU   Emulates and extends the ZWRITE command
 ;
 ;   $$CHKVER^ONCSAPIV   Checks version of the local cache
 ;  $$VERSION^ONCSAPIV   Returns versions of web-service components
 ;
 ;      BEGIN^ONCSNACR   Starts the NAACCR record output
 ;        END^ONCSNACR   Finishes the NAACCR record output
 ;      WRITE^ONCSNACR   Outputs the piece of the NAACCR record
 ;
 ; INITIALS ------------ DEVELOPER
 ;
 ; SG                    Sergey Gavrilov
 ;
 Q
 ;
 ;***** DEMO ENTRY POINT
DEMO ;
 N DA,DIR,DIRUT,DTOUT,DUOUT,ONCSAPI,X,Y
 ;
 ;--- Debug mode?
 K DIR  S DIR(0)="Y"
 S DIR("A")="Run in debug mode"
 S DIR("B")="NO"
 D ^DIR  Q:$D(DIRUT)
 S:Y ONCSAPI("DEBUG")=1
 ;
 ;--- Select and run a demo
DEMOSEL K DIR  S DIR(0)="SO^C:Collaborative Staging;E:EDITS"
 S DIR("A")="Select a demo"
 D ^DIR  Q:$D(DIRUT)
 D  G DEMOSEL
 . I Y="C"  D DEMO^ONCSAPID(.ONCSAPI)  Q  ; Collaborative Staging
 . I Y="E"  D DEMO^ONCSEDEM(.ONCSAPI)  Q  ; EDITS
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HONCSAPI   7191     printed  Sep 23, 2025@20:03:48                                                                                                                                                                                                     Page 2
ONCSAPI   ;Hines OIFO/SG - ONCOLOGY WEB-SERVICE  ; 12/7/06 10:37am
 +1       ;;2.2;ONCOLOGY;**1**;Jul 31, 2013;Build 8
 +2       ;
 +3       ; ONCSAPI ------------- API DESCRIPTOR
 +4       ;
 +5       ; ONCSAPI(
 +6       ;
 +7       ;   "DEBUG")            Debug mode
 +8       ;                         0  Disabled
 +9       ;                         1  Enabled
 +10      ;
 +11      ;   "MSG",              ""
 +12      ;     IEN,
 +13      ;       0)              Error Descriptor
 +14      ;                         ^01: Error Code   (see MSGLIST^ONCSAPIE)
 +15      ;                         ^02: Error Message
 +16      ;                         ^03: Label+Offset (optional)
 +17      ;                         ^04: Routine      (optional)
 +18      ;       1,i)            Error details (text)
 +19      ;     "E",
 +20      ;       Error Code,
 +21      ;         IEN)    ""
 +22      ;
 +23      ; ^XTMP("ONCSAPI") ---- LOCAL CACHE FOR WEB-SERVICE DATA
 +24      ;
 +25      ; ^XTMP("ONCSAPI",
 +26      ;
 +27      ;   0)                  Node descriptor
 +28      ;                         ^01: Purge date  (FileMan)
 +29      ;                         ^02: Create date (FileMan)
 +30      ;                         ^03: Description
 +31      ;
 +32      ;   "EDITS",            Metafile Version
 +33      ;     IEN,
 +34      ;       0)              Edit Descriptor
 +35      ;                         ^01: Index in the edit set
 +36      ;                         ^02: Name
 +37      ;       "D",i)          Description
 +38      ;       "H",i)          Help
 +39      ;     "ES",
 +40      ;       EditSetName,
 +41      ;         EditIndex)    IEN
 +42      ;
 +43      ;   "SCHEMAS",
 +44      ;     Schema#,
 +45      ;       0)              Schema name
 +46      ;
 +47      ;     "N",
 +48      ;       Name)           Schema#
 +49      ;
 +50      ;     "SH",
 +51      ;       Site,Hist)      Schema#
 +52      ;
 +53      ;   "TABLES",           DLL Version
 +54      ;
 +55      ;     IEN,
 +56      ;       0)              Table descriptor
 +57      ;                         ^01: Number of rows
 +58      ;                         ^02: Schema number
 +59      ;                         ^03: Table number
 +60      ;                         ^04: Table pattern
 +61      ;                         ^05: Table title
 +62      ;                         ^06: Table subtitle
 +63      ;       Row#,
 +64      ;         1)            Codes
 +65      ;                         ^01: Row code
 +66      ;                         ^02: Additional code #1
 +67      ;                         ^03: Additional code #2
 +68      ;                         ^04: ...
 +69      ;         3,i)          Description (text)
 +70      ;
 +71      ;       "C",
 +72      ;         RowCode)      Descriptor
 +73      ;                         ^01: Row#
 +74      ;                         ^02: Upper boundary (for intervals)
 +75      ;
 +76      ;       "FN",
 +77      ;         Note#,i)      Footnote (text)
 +78      ;       "TN",
 +79      ;         Note#,i)      Note (text)
 +80      ;
 +81      ;     "ST",
 +82      ;       Schema#,
 +83      ;         Table#)       IEN
 +84      ;
 +85      ; CS TABLE NUMBER ----- TABLE DESCRIPTION
 +86      ;
 +87      ;               1       CS Tumor Size
 +88      ;               2       CS Extension
 +89      ;               3       CS Size/Ext Eval
 +90      ;               4       CS Lymph Nodes
 +91      ;               5       CS Reg Nodes Eval
 +92      ;               6       Regional Nodes Positive
 +93      ;               7       Regional Nodes Examined
 +94      ;               8       CS Mets at DX
 +95      ;               9       CS Mets Eval
 +96      ;              10       CS Site-Specific Factor 1
 +97      ;              11       CS Site-Specific Factor 2
 +98      ;              12       CS Site-Specific Factor 3
 +99      ;              13       CS Site-Specific Factor 4
 +100     ;              14       CS Site-Specific Factor 5
 +101     ;              15       CS Site-Specific Factor 6 
 +102     ;              16       CS Site-Specific Factor 7 
 +103     ;              17       CS Site-Specific Factor 8
 +104     ;              18       CS Site-Specific Factor 9
 +105     ;              19       CS Site-Specific Factor 10
 +106     ;              20       CS Site-Specific Factor 11
 +107     ;              21       CS Site-Specific Factor 12
 +108     ;              22       CS Site-Specific Factor 13
 +109     ;              23       CS Site-Specific Factor 14
 +110     ;              24       CS Site-Specific Factor 15
 +111     ;              25       CS Site-Specific Factor 16
 +112     ;              26       CS Site-Specific Factor 17
 +113     ;              27       CS Site-Specific Factor 18
 +114     ;              28       CS Site-Specific Factor 19
 +115     ;              29       CS Site-Specific Factor 20
 +116     ;              30       CS Site-Specific Factor 21
 +117     ;              31       CS Site-Specific Factor 22
 +118     ;              32       CS Site-Specific Factor 23
 +119     ;              33       CS Site-Specific Factor 24
 +120     ;              34       CS Site-Specific Factor 25
 +121     ;              35       Histologies
 +122     ;
 +123     ; CS ENTRY POINT ------ DESCRIPTION
 +124     ;
 +125     ;       HELP^ONCSAPI1   Displays the field's valid codes
 +126     ;      INPUT^ONCSAPI1   Checks if the code is valid
 +127     ;
 +128     ;     $$CALC^ONCSAPI3   Calculates the staging values
 +129     ;
 +130     ;   $$SCHEMA^ONCSAPIS   Returns schema number
 +131     ;
 +132     ; $$CODEDESC^ONCSAPIT   Loads the CS code description
 +133     ; $$GETCSTBL^ONCSAPIT   Returns table IEN (loads table if necessary)
 +134     ;
 +135     ; EDITS ENTRY POINT --- DESCRIPTION
 +136     ;
 +137     ;  $$RBQEXEC^ONCSED01   Executes the 'Run Batch' EDITS request
 +138     ;  $$RBQPREP^ONCSED01   Starts preparation of the 'Run Batch' request
 +139     ;
 +140     ;   $$REPORT^ONCSED01   Prints EDITS report generated by the
 +141     ;                       $$RBQEXEC^ONCSED01
 +142     ;
 +143     ; $$GETEDESC^ONCSED04   Returns the edit description node
 +144     ; $$GETEDHLP^ONCSED04   Returns the edit help text node
 +145     ;
 +146     ; UTILITY ------------- DESCRIPTION
 +147     ;
 +148     ;       DEMO^ONCSAPI    Demonstration entry point
 +149     ;
 +150     ;      CLEAR^ONCSAPIE   Initializes the error stack
 +151     ;      $$DBS^ONCSAPIE   Cehcks for FileMan DBS errors
 +152     ;    $$ERROR^ONCSAPIE   Generates an error message
 +153     ;      $$MSG^ONCSAPIE   Returns the text and type of the message
 +154     ;    PRTERRS^ONCSAPIE   Displays the error messages
 +155     ;      STORE^ONCSAPIE   Stores the message into the error stack
 +156     ;
 +157     ;   $$CHKERR^ONCSAPIR   Checks for parsing and web-service errors
 +158     ;     HEADER^ONCSAPIR   Generates the request header
 +159     ;   $$PARAMS^ONCSAPIR   Converts input parameters into XML format
 +160     ;        PUT^ONCSAPIR   Adds element/text to the destination buffer
 +161     ;  $$REQUEST^ONCSAPIR   Sends the request and gets the response
 +162     ;    TRAILER^ONCSAPIR   Generates the request trailer
 +163     ;
 +164     ; $$GETCSURL^ONCSAPIU   Returns the Oncology web-service URL
 +165     ;     $$PAGE^ONCSAPIU   Pauses the output at page end
 +166     ; $$UPDCSURL^ONCSAPIU   Updates the Oncology web-service URL
 +167     ;         WW^ONCSAPIU   Wraps the string and prints it
 +168     ;         ZW^ONCSAPIU   Emulates and extends the ZWRITE command
 +169     ;
 +170     ;   $$CHKVER^ONCSAPIV   Checks version of the local cache
 +171     ;  $$VERSION^ONCSAPIV   Returns versions of web-service components
 +172     ;
 +173     ;      BEGIN^ONCSNACR   Starts the NAACCR record output
 +174     ;        END^ONCSNACR   Finishes the NAACCR record output
 +175     ;      WRITE^ONCSNACR   Outputs the piece of the NAACCR record
 +176     ;
 +177     ; INITIALS ------------ DEVELOPER
 +178     ;
 +179     ; SG                    Sergey Gavrilov
 +180     ;
 +181      QUIT 
 +182     ;
 +183     ;***** DEMO ENTRY POINT
DEMO      ;
 +1        NEW DA,DIR,DIRUT,DTOUT,DUOUT,ONCSAPI,X,Y
 +2       ;
 +3       ;--- Debug mode?
 +4        KILL DIR
           SET DIR(0)="Y"
 +5        SET DIR("A")="Run in debug mode"
 +6        SET DIR("B")="NO"
 +7        DO ^DIR
           if $DATA(DIRUT)
               QUIT 
 +8        if Y
               SET ONCSAPI("DEBUG")=1
 +9       ;
 +10      ;--- Select and run a demo
DEMOSEL    KILL DIR
           SET DIR(0)="SO^C:Collaborative Staging;E:EDITS"
 +1        SET DIR("A")="Select a demo"
 +2        DO ^DIR
           if $DATA(DIRUT)
               QUIT 
 +3        Begin DoDot:1
 +4       ; Collaborative Staging
               IF Y="C"
                   DO DEMO^ONCSAPID(.ONCSAPI)
                   QUIT 
 +5       ; EDITS
               IF Y="E"
                   DO DEMO^ONCSEDEM(.ONCSAPI)
                   QUIT 
           End DoDot:1
           GOTO DEMOSEL