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

SCMCWS1.m

Go to the documentation of this file.
SCMCWS1 ;ALB/ART - PCMM Web-Call Patient Summary Web Service ;02/06/2015
 ;;5.3;Scheduling;**603**;Aug 13, 1993;Build 79
 ;
 QUIT
 ;
 ;Public, Supported ICRs
 ; #2053 - Data Base Server API: Editing Utilities (DIE)
 ; #2056 - Data Base Server API: Data Retriever Utilities (DIQ)
 ; #4440 - DBIA4440 (XUPROD)
 ; #5421 - XOBWLIB - Public APIs for HWSC
 ; #10035 - PATIENT FILE
 ; #10060 - NEW PERSON FILE
 ; #10103 - XLFDT - Supported APIs for date & time
 ; #10112 - VASITE - Supported APIs for site info
 ;
PCDETAIL(SCDISPLY,SCDFN) ;Call PCMM/R Web Service
 ;Inputs: SCDISPLY - Array for team assignment info - passed by reference
 ;        SCDFN    - Patient DFN
 ;Output: populated SCDISPLY
 ; ICR #6027 - SCMC PCMM/R GET PRIMARY CARE DETAILS
 ;
 NEW SCSERVER,SCSERVC,SCLIST,SCSRVRKY,SCRC
 NEW SCSTAT,SCEOF,SCREADR,SCCNT,SCARRAY,SCVALUE,SCNODE,SCROW
 NEW SCREST,SCGETRC,SCERR
 NEW SCTEAMS,SCINPAT,SCNVA,SCBLOCK,SCTMLVL,SCPCLVL,SCNVALVL,SCMHLVL,SCOELVL,SCSPLVL,SCSPTYPE,SCSPMBR
 NEW SCDATA,SCX,SCY
 ;
 IF $$PROD^XUPROD DO
 . SET SCDATA("serverNameKey")="PCMMR SERVER"
 ELSE  DO
 . SET SCDATA("serverNameKey")="PCMMR TEST SERVER"
 SET SCDATA("webServiceName")="PCMM-R GET PC INFO REST"
 ;
 ; Web service setup
 SET SCRC=+$$SETUP^SCMCWSUT(.SCDATA)
 IF SCRC=0 DO  QUIT
 . SET SCDISPLY(1)=$PIECE(SCRC,U,2)
 ;
 ; Get client REST request object
 SET SCDATA("restObject")=$$GETREST^XOBWLIB(SCDATA("webServiceName"),SCDATA("serverName"))
 ;
 ; Get Local Site ID
 ;Institution file pointer^Institution name^station number with suffix
 SET SCDATA("site")=$PIECE($$SITE^VASITE(),U,3)
 ;
 ; Set PCMM/R web service parameters
 SET SCDATA("webServiceParameters")="/"_SCDATA("site")_"/"_SCDFN_".xml"
 ;
 ; Retrieve the resource; execute HTTP GET method
 SET SCGETRC=$$GET^XOBWLIB(SCDATA("restObject"),SCDATA("webServiceParameters"),.SCERR,0)
 IF 'SCGETRC DO  QUIT
 . SET SCRC=$$GET1^DIQ(404.41,SCDFN_",",.07,"","SCDISPLY")
 . IF $GET(SCDISPLY(1))="" DO
 . . SET SCDISPLY(1)="PCMM is unavailable."
 ;
 ; Parse the XML stream
 SET SCSTAT=##class(%XML.TextReader).ParseStream(SCDATA("restObject").HttpResponse.Data,.SCREADR)
 ;
 ; Check XML parse error
 IF 'SCSTAT DO  QUIT
 . SET SCDISPLY(1)=">>> ERROR reading XML <<<"
 . SET SCDISPLY(2)="    Invalid XML Format"
 ;
 ; Process XML
 SET SCTMLVL=0
 SET SCPCLVL=0
 SET SCNVALVL=0
 SET SCMHLVL=0
 SET SCOELVL=0
 SET SCSPLVL=0
 SET SCSPTYPE=0
 SET SCSPMBR=0
 SET SCCNT=0
 SET SCBLOCK=0
 SET SCEOF=0
 FOR  QUIT:SCEOF!SCREADR.EOF!'SCREADR.Read()  DO
 . ; Get element value
 . IF (SCREADR.NodeType="chars") DO
 . . SET SCNODE=SCREADR.Path
 . . SET SCVALUE=SCREADR.Value
 . . DO PARSEXML^SCMCWS1A(SCNODE,SCVALUE,.SCTEAMS,.SCNVA,.SCTMLVL,.SCPCLVL,.SCNVALVL,.SCMHLVL,.SCOELVL,.SCSPLVL,.SCSPTYPE,.SCSPMBR,.SCBLOCK,.SCEOF)
 . ; Check for last closing tag
 . IF (SCREADR.NodeType="endelement")&(SCREADR.LocalName="PatientSummary") DO
 . . SET SCEOF=1
 ;
 ; Get Ipatient Data
 DO GETINPAT(SCDFN,.SCINPAT)
 ;
 ; Build Display Array
 IF 'SCBLOCK DO
 . DO BLDISPLY(.SCTEAMS,.SCINPAT,.SCNVA,.SCDISPLY,SCDATA("site"))
 ELSE  DO
 . DO BLDBLOCK(.SCTEAMS,.SCINPAT,.SCDISPLY)
 ;
 ;Save display array in OutPatient Profile
 SET SCDISPLY(1)="ATTENTION: PCMM is unavailable, data is current as of: "_$$FMTE^XLFDT($$NOW^XLFDT(),2)
 DO WP^DIE(404.41,SCDFN_",",.07,"K","SCDISPLY")
 SET SCDISPLY(1)=""
 ;
 QUIT
 ;
 ;
GETINPAT(SCDFN,SCINPAT) ;Build an array of local attending and inpatient providers
 ;Inputs: SCDFN    - patient DFN
 ;        SCINPAT  - inpatient provider array - by reference
 ;Output: Populated inpatient provider array
 ;
 NEW SCATT,SCPROV
 ;If patient is assigned to a ward
 IF $$GET1^DIQ(2,SCDFN_",",.1)'="" DO
 . SET SCATT=$$GET1^DIQ(2,SCDFN_",",.1041,"I")
 . SET SCPROV=$$GET1^DIQ(2,SCDFN_",",.104,"I")
 . ;populate array from New Person File
 . IF +SCATT DO
 . . SET SCINPAT("ATT NAME")=$$GET1^DIQ(200,+SCATT_",",.01)
 . . SET SCINPAT("ATT PHONE")=$$GET1^DIQ(200,+SCATT_",",.132)
 . . SET SCINPAT("ATT PAGER")=$$GET1^DIQ(200,+SCATT_",",.138)
 . IF +SCPROV DO
 . . SET SCINPAT("PROV NAME")=$$GET1^DIQ(200,+SCPROV_",",.01)
 . . SET SCINPAT("PROV PHONE")=$$GET1^DIQ(200,+SCPROV_",",.132)
 . . SET SCINPAT("PROV PAGER")=$$GET1^DIQ(200,+SCPROV_",",.138)
 QUIT
 ;
BLDBLOCK(SCTEAMS,SCINPAT,SCDISPLY) ; Build the Display Array
 ;Inputs: SCTEAMS  - Teams array - by reference
 ;        SCINPAT  - inpatient array - by reference
 ;        SCDISPLY - Display array - by reference
 ;Output: Populated Display Array
 ;
 NEW SCDISP,SCSKIP,SCI
 ;
 SET SCDISP=1
 SET SCSKIP=0
 SET SCDISPLY(SCDISP)=""
 ;Inpatient providers
 IF $GET(SCINPAT("ATT NAME"))'="" DO
 . SET SCDISP=SCDISP+1
 . SET SCSKIP=1
 . SET SCDISPLY(SCDISP)="  Inpatient Attending: "_$GET(SCINPAT("ATT NAME"))_$$FMTPHPG("I","ATT",0)
 IF $GET(SCINPAT("PROV NAME"))'="" DO
 . SET SCDISP=SCDISP+1
 . SET SCSKIP=1
 . SET SCDISPLY(SCDISP)="  Inpatient Provider:  "_$GET(SCINPAT("PROV NAME"))_$$FMTPHPG("I","PROV",0)
 IF SCSKIP DO
 . SET SCDISP=SCDISP+1
 . SET SCDISPLY(SCDISP)=""
 ;
 FOR SCI=1:1 QUIT:'$DATA(SCTEAMS(SCI))  DO
 . SET SCDISP=SCDISP+1
 . SET SCDISPLY(SCDISP)=SCTEAMS(SCI)
 ;
 QUIT
 ;
BLDISPLY(SCTEAMS,SCINPAT,SCNVA,SCDISPLY,SCSITE) ; Build the Display Array
 ;Inputs: SCTEAMS  - Teams array - by reference
 ;        SCINPAT  - inpatient array - by reference
 ;        SCNVA    - nonVA array - by reference
 ;        SCDISPLY - Display array - by reference
 ;        SCSITE   - Site Number
 ;Output: Populated Display Array
 ;
 NEW SCDISP,SCX,SCY,SCZ,SCLEVEL,SCLEVEL2,SCSTAT,SCXSITE,SCLOCAL,SCTMCNT,SCDISPSV,SCTYPE,SCSKIP,SCOTHTM
 SET SCDISP=0
 SET SCTMCNT=0
 SET SCDISPSV=0
 SET SCSKIP=0
 SET SCOTHTM=0
 ;Teams from web service call
 SET SCLEVEL=""
 FOR  SET SCLEVEL=$ORDER(SCTEAMS(SCLEVEL)) QUIT:SCLEVEL=""  DO
 . SET SCDISP=SCDISP+1
 . SET SCDISPLY(SCDISP)=""
 . ;Check for local site
 . SET SCXSITE=$TR($PIECE($GET(SCTEAMS(SCLEVEL,"STATION")),"(",2),"#)","")
 . SET SCLOCAL=$SELECT(SCSITE=SCXSITE:1,1:0)
 . IF SCLOCAL DO
 . . SET SCDISP=SCDISP+1
 . . SET SCDISPLY(SCDISP)="LOCAL - "_$GET(SCTEAMS(SCLEVEL,"STATION"))
 . . ;Inpatient providers
 . . IF $GET(SCINPAT("ATT NAME"))'="" DO
 . . . SET SCDISP=SCDISP+1
 . . . SET SCSKIP=1
 . . . SET SCDISPLY(SCDISP)="  Inpatient Attending: "_$GET(SCINPAT("ATT NAME"))_$$FMTPHPG("I","ATT",0)
 . . IF $GET(SCINPAT("PROV NAME"))'="" DO
 . . . SET SCDISP=SCDISP+1
 . . . SET SCSKIP=1
 . . . SET SCDISPLY(SCDISP)="  Inpatient Provider:  "_$GET(SCINPAT("PROV NAME"))_$$FMTPHPG("I","PROV",0)
 . ELSE  DO
 . . SET SCDISP=SCDISP+1
 . . SET SCDISPLY(SCDISP)="REMOTE - "_$GET(SCTEAMS(SCLEVEL,"STATION"))
 . IF SCLOCAL,SCSKIP DO
 . . SET SCDISP=SCDISP+1
 . . SET SCDISPLY(SCDISP)=""
 . ;
 . ;PACT
 . IF '$DATA(SCTEAMS(SCLEVEL,2)) DO
 . . IF SCLOCAL DO
 . . . SET SCDISP=SCDISP+1
 . . . SET SCDISPSV=SCDISP
 . . . SET SCDISPLY(SCDISP)="  PACT: No Local PACT Assigned."
 . SET SCY=""
 . FOR  SET SCY=$ORDER(SCTEAMS(SCLEVEL,2,SCY)) QUIT:SCY=""  DO
 . . IF $GET(SCTEAMS(SCLEVEL,2,SCY,"PACT"))'="" DO
 . . . SET SCTMCNT=SCTMCNT+1
 . . . SET SCSTAT=$GET(SCTEAMS(SCLEVEL,2,SCY,"STATUS"))
 . . . SET SCSTAT=$SELECT(SCSTAT="Pending":"PENDING: ",1:"")
 . . . SET SCDISP=SCDISP+1
 . . . SET SCDISPLY(SCDISP)="  PACT: "_SCSTAT_$GET(SCTEAMS(SCLEVEL,2,SCY,"PACT"))
 . . . SET SCDISP=SCDISP+1
 . . . IF $GET(SCTEAMS(SCLEVEL,2,SCY,"PCP NAME"))'="" DO
 . . . . SET SCDISPLY(SCDISP)="    Primary Care Provider: "_$GET(SCTEAMS(SCLEVEL,2,SCY,"PCP NAME"))_$$FMTPHPG("P","PCP",2)
 . . . ELSE  DO
 . . . . SET SCDISPLY(SCDISP)="    Primary Care Provider: Vacant"
 . . . IF $GET(SCTEAMS(SCLEVEL,2,SCY,"ASSOC NAME"))'="" DO
 . . . . SET SCDISP=SCDISP+1
 . . . . SET SCDISPLY(SCDISP)="    Associate Provider:    "_$GET(SCTEAMS(SCLEVEL,2,SCY,"ASSOC NAME"))_$$FMTPHPG("P","ASSOC",2)
 . . . SET SCDISP=SCDISP+1
 . . . IF $GET(SCTEAMS(SCLEVEL,2,SCY,"APOC NAME"))'="" DO
 . . . . SET SCDISPLY(SCDISP)="    Administrative POC:    "_$GET(SCTEAMS(SCLEVEL,2,SCY,"APOC ROLE"))_" || "_$GET(SCTEAMS(SCLEVEL,2,SCY,"APOC NAME"))_$$FMTPHPG("P","APOC",2)
 . . . ELSE  DO
 . . . . SET SCDISPLY(SCDISP)="    Administrative POC:    Vacant"
 . . . SET SCDISP=SCDISP+1
 . . . IF $GET(SCTEAMS(SCLEVEL,2,SCY,"CPOC NAME"))'="" DO
 . . . . SET SCDISPLY(SCDISP)="    Clinical POC:          "_$GET(SCTEAMS(SCLEVEL,2,SCY,"CPOC ROLE"))_" || "_$GET(SCTEAMS(SCLEVEL,2,SCY,"CPOC NAME"))_$$FMTPHPG("P","CPOC",2)
 . . . ELSE  DO
 . . . . SET SCDISPLY(SCDISP)="    Clinical POC:          Vacant"
 . . ELSE  DO  ;No Local PACT Assigned
 . . . IF SCLOCAL DO
 . . . . SET SCDISP=SCDISP+1
 . . . . SET SCDISPSV=SCDISP
 . . . . SET SCDISPLY(SCDISP)="  PACT: No Local PACT Assigned."
 . ;
 . ; Mental Health
 . SET SCY=""
 . FOR  SET SCY=$ORDER(SCTEAMS(SCLEVEL,4,SCY)) QUIT:SCY=""  DO
 . . IF $GET(SCTEAMS(SCLEVEL,4,SCY,"SP TEAM"))'="" DO
 . . . SET SCDISP=SCDISP+1
 . . . SET SCDISPLY(SCDISP)=""
 . . . SET SCDISP=SCDISP+1
 . . . SET SCDISPLY(SCDISP)="  MH: "_$GET(SCTEAMS(SCLEVEL,4,SCY,"SP TEAM"))
 . . . SET SCZ=0
 . . . FOR  SET SCZ=$ORDER(SCTEAMS(SCLEVEL,4,SCY,SCZ)) QUIT:'SCZ  DO
 . . . . SET SCDISP=SCDISP+1
 . . . . SET SCDISPLY(SCDISP)="    "_$GET(SCTEAMS(SCLEVEL,4,SCY,SCZ,"SP ROLE"))_" || "_$GET(SCTEAMS(SCLEVEL,4,SCY,SCZ,"SP NAME"))_$$FMTPHPG("S","SP",4)
 . . . SET:SCLOCAL SCOTHTM=1
 . ;
 . ; OEF/OIF/OND
 . SET SCY=""
 . FOR  SET SCY=$ORDER(SCTEAMS(SCLEVEL,"OEF",SCY)) QUIT:SCY=""  DO
 . . IF ($GET(SCTEAMS(SCLEVEL,"OEF",SCY,"OEF TEAM"))'="")!($GET(SCTEAMS(SCLEVEL,"OEF",SCY,"OEF MGR"))'="") DO
 . . . SET SCDISP=SCDISP+1
 . . . SET SCDISPLY(SCDISP)=""
 . . . SET SCDISP=SCDISP+1
 . . . SET SCDISPLY(SCDISP)="  OEF/OIF/OND: "_$GET(SCTEAMS(SCLEVEL,"OEF",SCY,"OEF TEAM"))
 . . . SET SCDISP=SCDISP+1
 . . . SET SCDISPLY(SCDISP)="    LEAD COORDINATOR: "_$GET(SCTEAMS(SCLEVEL,"OEF",SCY,"OEF MGR"))_$$FMTPHPG("O","OEF","OEF")
 . . . SET:SCLOCAL SCOTHTM=1
 . ;
 . ; Specialty
 . SET SCX=""
 . FOR  SET SCX=$ORDER(SCTEAMS(SCLEVEL,SCX)) QUIT:'+SCX  DO
 . . QUIT:SCX=4  ;MH
 . . QUIT:SCX=2  ;PC
 . . QUIT:SCX=10  ;OEF
 . . SET SCY=0
 . . FOR  SET SCY=$ORDER(SCTEAMS(SCLEVEL,SCX,SCY)) QUIT:'+SCY  DO
 . . . IF ($GET(SCTEAMS(SCLEVEL,SCX,SCY,"SP TEAM"))'="")!($GET(SCTEAMS(SCLEVEL,SCX,SCY,"SP ROLE"))'="") DO
 . . . . SET SCDISP=SCDISP+1
 . . . . SET SCDISPLY(SCDISP)=""
 . . . . SET SCDISP=SCDISP+1
 . . . SET SCDISPLY(SCDISP)="  SP: "_$GET(SCTEAMS(SCLEVEL,SCX,SCY,"SP TEAM"))
 . . . SET SCZ=0
 . . . FOR  SET SCZ=$ORDER(SCTEAMS(SCLEVEL,SCX,SCY,SCZ)) QUIT:'SCZ  DO
 . . . . SET SCDISP=SCDISP+1
 . . . . SET SCDISPLY(SCDISP)="    "_$GET(SCTEAMS(SCLEVEL,SCX,SCY,SCZ,"SP ROLE"))_" || "_$GET(SCTEAMS(SCLEVEL,SCX,SCY,SCZ,"SP NAME"))_$$FMTPHPG("S","SP",SCX)
 . . . SET:SCLOCAL SCOTHTM=1
 ;Check if PACTs assigned
 IF 'SCTMCNT,SCDISPSV DO
 . SET:'SCOTHTM SCDISPLY(SCDISPSV-1)=""
 . SET SCDISPLY(SCDISPSV)="  No PACT assigned at any VA location."
 IF '$DATA(SCTEAMS) DO
 . SET SCDISP=SCDISP+1
 . SET SCDISPLY(SCDISP)=""
 . SET SCDISP=SCDISP+1
 . SET SCDISPLY(SCDISP)="  No PACT assigned at any VA location."
 ; Non-VA Providers
 QUIT:'$DATA(SCNVA)
 SET SCDISP=SCDISP+1
 SET SCDISPLY(SCDISP)=""
 SET SCLEVEL=""
 FOR  SET SCLEVEL=$ORDER(SCNVA(SCLEVEL)) QUIT:SCLEVEL=""  DO
 . SET SCDISP=SCDISP+1
 . SET SCDISPLY(SCDISP)="Non-VA: "_$GET(SCNVA(SCLEVEL,"ROLE"))_" || "_$GET(SCNVA(SCLEVEL,"NAME"))_$$FMTPHPG("N","N",0)
 ;
 QUIT
 ;
FMTPHPG(SCTYPE,SCPREFIX,SCTEAMID) ;Format Phone and Pager #
 ;Inputs: SCTYPE   - Team Type - I=Inpatient, P=Primary Care, O=OEF/OIF, S=Specialty & MH, N=Non-VA
 ;        SCPREFIX - Value of Prefix
 ;        SCTEAMID - Value of team ID
 ;Returns: Phone and Pager string
 ;
 QUIT:$GET(SCTYPE)="" -1
 QUIT:$GET(SCPREFIX)="" -2
 QUIT:$GET(SCTEAMID)="" -3
 NEW SCPPSTR
 SET SCPPSTR=""
 ; Inpatient
 IF SCTYPE="I" DO
 . SET SCPPSTR=$SELECT($GET(SCINPAT(SCPREFIX_" PHONE"))="":"",1:" || PHONE:"_SCINPAT(SCPREFIX_" PHONE"))
 . SET SCPPSTR=SCPPSTR_$S($GET(SCINPAT(SCPREFIX_" PAGER"))="":"",1:" || PAGER:"_SCINPAT(SCPREFIX_" PAGER"))
 ; Primary Care
 IF SCTYPE="P" DO
 . SET SCPPSTR=$SELECT($GET(SCTEAMS(SCLEVEL,SCTEAMID,SCY,SCPREFIX_" PHONE"))="":"",1:" || PHONE:"_SCTEAMS(SCLEVEL,SCTEAMID,SCY,SCPREFIX_" PHONE"))
 . SET SCPPSTR=SCPPSTR_$SELECT($GET(SCTEAMS(SCLEVEL,SCTEAMID,SCY,SCPREFIX_" PAGER"))="":"",1:" || PAGER:"_SCTEAMS(SCLEVEL,SCTEAMID,SCY,SCPREFIX_" PAGER"))
 ; Specialty & MH
 IF SCTYPE="S" DO
 . SET SCPPSTR=$SELECT($GET(SCTEAMS(SCLEVEL,SCTEAMID,SCY,SCZ,SCPREFIX_" PHONE"))="":"",1:" || PHONE:"_SCTEAMS(SCLEVEL,SCTEAMID,SCY,SCZ,SCPREFIX_" PHONE"))
 . SET SCPPSTR=SCPPSTR_$S($GET(SCTEAMS(SCLEVEL,SCTEAMID,SCY,SCZ,SCPREFIX_" PAGER"))="":"",1:" || PAGER:"_SCTEAMS(SCLEVEL,SCTEAMID,SCY,SCZ,SCPREFIX_" PAGER"))
 ; OEF/OIF
 IF SCTYPE="O" DO
 . SET SCPPSTR=$SELECT($GET(SCTEAMS(SCLEVEL,SCTEAMID,SCY,SCPREFIX_" PHONE"))="":"",1:" || PHONE:"_SCTEAMS(SCLEVEL,SCPREFIX,SCY,SCPREFIX_" PHONE"))
 . SET SCPPSTR=SCPPSTR_$S($GET(SCTEAMS(SCLEVEL,SCTEAMID,SCY,SCPREFIX_" PAGER"))="":"",1:" || PAGER:"_SCTEAMS(SCLEVEL,SCPREFIX,SCY,SCPREFIX_" PAGER"))
 ; Non-VA
 IF SCTYPE="N" DO
 . SET SCPPSTR=$SELECT($GET(SCNVA(SCLEVEL,"PHONE"))="":"",1:" || PHONE:"_SCNVA(SCLEVEL,"PHONE"))
 . SET SCPPSTR=SCPPSTR_$SELECT($GET(SCNVA(SCLEVEL,"CITY"))="":"",1:" || CITY: "_SCNVA(SCLEVEL,"CITY"))
 . SET SCPPSTR=SCPPSTR_$SELECT($GET(SCNVA(SCLEVEL,"STATE"))="":"",1:" || STATE: "_SCNVA(SCLEVEL,"STATE"))
 ;
 QUIT SCPPSTR
 ;