Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: ONCXDEM

ONCXDEM.m

Go to the documentation of this file.
  1. ONCXDEM ;HCIOFO/SG - HTTP AND WEB SERVICES (DEMO) ; 5/14/04 10:59am
  1. ;;2.2;ONCOLOGY;**1**;Jul 31, 2013;Build 8
  1. ;
  1. Q
  1. ;
  1. ;***** DEMO ENTRY POINT
  1. ;
  1. ; The ^TMP($J,"ONCX") global node is used by the entry point.
  1. ;
  1. DEMO ;
  1. N BODY,DIR,DIRUT,DTOUT,DUOUT,HEADER,RC,URL,X,Y
  1. S BODY=$NA(^TMP($J,"ONCX"))
  1. S URL="http://www.hardhats.org"
  1. ;
  1. S RC=0
  1. F D Q:RC
  1. . K @BODY,HEADER
  1. . ;--- Request a URL from the user
  1. . K DIR S DIR(0)="F"
  1. . S DIR("A")="URL",DIR("B")=URL
  1. . D ^DIR I $D(DIRUT) S RC=1 Q
  1. . S URL=$$TRIM^XLFSTR(Y)
  1. . ;--- Request the resource
  1. . S RC=$$GETURL^ONCX10(URL,,BODY,.HEADER)
  1. . I RC<0 D ERROR(RC) S RC=0 Q
  1. . ;--- Print the data
  1. . D PRINT(BODY,.HEADER)
  1. . S RC=0
  1. ;
  1. ;--- Cleanup
  1. K @BODY
  1. Q
  1. ;
  1. ;***** PRINT THE ERROR MESSAGE
  1. ERROR(ERR) ;
  1. W !!,"ERROR: "_$J(+ERR,3)_" "_$P(ERR,U,2),!
  1. W $J("",12)_$P(ERR,U,3,4),!
  1. Q
  1. ;
  1. ;***** PAUSES THE OUTPUT IN THE END OF PAGE
  1. ;
  1. ; N Number of lines to reserve
  1. ;
  1. ; Return values:
  1. ; 0 Ok (continue)
  1. ; >0 Exit Request or Timeout
  1. ;
  1. PAGE(N) ;
  1. Q:($Y+$G(N))<IOSL 0
  1. N DIR,DIRUT,DTOUT,DUOUT,X,Y
  1. S DIR(0)="E" D ^DIR W !! S $Y=0
  1. Q '$G(Y)
  1. ;
  1. ;***** PRINTS THE RESPONSE
  1. PRINT(ONCX8DAT,HEADER) ;
  1. N I,J
  1. ;---
  1. I $D(HEADER)>0 D Q:$$PAGE(IOSL)
  1. . W @IOF,"----- HTTP HEADER -----",!!
  1. . W $G(HEADER),!
  1. . S I=""
  1. . F S I=$O(HEADER(I)) Q:I="" W I_"="_HEADER(I),!
  1. ;---
  1. D:$D(@ONCX8DAT)>1
  1. . W @IOF,"----- MESSAGE ONCX8DAT -----",!!
  1. . S I=""
  1. . F S I=$O(@ONCX8DAT@(I)) Q:I="" W @ONCX8DAT@(I) D W !
  1. . . S J="" F S J=$O(@ONCX8DAT@(I,J)) Q:J="" W @ONCX8DAT@(I,J)
  1. Q