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

PXVRPC3.m

Go to the documentation of this file.
PXVRPC3 ;MSC/DKA - VIMM 2.0 RPC code to return list of Immunizations ;10/27/2015 13:36
 ;;1.0;PCE PATIENT CARE ENCOUNTER;**215**;Aug 12, 1996;Build 10
 ;
 Q
IMMDATA(PXVRET,PXVFLTR,SUBFILES) ; Return array of entries from IMMUNIZATION, File #9999999.14
 ; PXVFLTR can have one of these values:
 ;   R:XXX - Return entry with IEN XXX.
 ;   S:A   - List of Active Immunizations (default)
 ;   S:H   - List of [Selectable for] Historic Immunizations
 ;   S:*   - All records (Including Inactive Immunizations)
 ; SUBFILES is 1 or Y to include the subfiles when returning the data
 ; If SUBFILES is 0 or N (or not specified) then return just this subset of fields:
 ; IEN, NAME, SHORT NAME, CVX CODE, MAX # IN SERIES, INACTIVE FLAG,
 ; MNEMONIC, ACRONYM, SELECTABLE FOR HISTORIC)
 N PXVFILE,PXVIEN,PXVIENS,PXVCNT,PXVGBL,PXVDATA,PXVSTR,PXVREF,PXVERR,PXVSUB,PXVSUBC,PXVDELIM,PXVSBSCR
 N PXVBRIEF,PXVACTIV,PXVHISTR,PXVINCLU,PXVTEMP,PXVDLM1,PXVDLM2,PXVDLM3,PXVVALID,PXVERMSG,PXVTYPE
 N PXVSDATA,PXVSERR,PXVFMT,PXVSUB2,PXVSUB2C,PXVSVSC2
 S SUBFILES=+$TR($E($G(SUBFILES,0)),"YyNn","1100")
 S PXVFLTR=$G(PXVFLTR,"S:A") S:PXVFLTR="" PXVFLTR="S:A"
 S PXVGBL=$NA(^AUTTIMM)
 K PXVRET S PXVRET=$NA(^TMP("PXVRPC3",$J)) K @PXVRET
 S PXVVALID=1 ; Assume the parameters are valid until proven otherwise
 I $E(PXVFLTR,1,2)="R:" D
 . S PXVFMT="R",PXVIEN=$E(PXVFLTR,3,$L(PXVFLTR)),PXVTYPE="*"
 . S:PXVIEN'=+PXVIEN!(PXVIEN<1) PXVVALID=0,PXVERMSG="Invalid IEN specified for R: format in PXVFLTR parameter"
 . Q:PXVIEN=""
 . S:'$D(@PXVGBL@(PXVIEN)) PXVVALID=0,PXVERMSG="Entry not found for the specified IEN"
 E  I $E(PXVFLTR,1,2)="S:" D
 . S PXVFMT="S",PXVTYPE=$E(PXVFLTR,3)
 . S:PXVTYPE'="A"&(PXVTYPE'="H")&(PXVTYPE'="*") PXVVALID=0,PXVERMSG="Invalid type specified for S: format in PXVFLTR parameter"
 . S ACTONLY=PXVTYPE'="H" ; ActiveOnly is any type (A or *) except H
 . S SELHIST=PXVTYPE'="A" ; Selectable for Historic is any type (H or *) except A
 E  S PXVVALID=0,PXVERMSG="Invalid Parameter(s)"
 I 'PXVVALID S @PXVRET@(0)=-1_U_PXVERMSG Q
 S PXVBRIEF=".01;.02;.03;.05;.07;8801;8802;8803"
 S PXVCNT=0
 S PXVFILE=9999999.14
 I PXVFMT="R" D
 . D GETFLDS
 E  I PXVFMT="S" D
 . S PXVIEN=0
 . F  S PXVIEN=$O(@PXVGBL@(PXVIEN)) Q:'PXVIEN  D GETFLDS
 S @PXVRET@(0)=PXVCNT ; Put the number of returned records in the first node of the array
 Q
GETFLDS ; Get fields for one IEN
 S PXVIENS=PXVIEN_","
 K PXVDATA,PXVERR
 I 'SUBFILES D GETS^DIQ(PXVFILE,PXVIENS,PXVBRIEF,"I","PXVDATA","PXVERR")
 I SUBFILES D GETS^DIQ(PXVFILE,PXVIENS,"**","IE","PXVDATA","PXVERR")
 S PXVREF=$NA(PXVDATA(PXVFILE,PXVIENS))
 S PXVSTR=""
 S $P(PXVSTR,U,1)=PXVIEN
 ; NAME
 S $P(PXVSTR,U,2)=@PXVREF@(.01,"I")
 S $P(PXVSTR,U,3)=@PXVREF@(.02,"I")
 S $P(PXVSTR,U,4)=@PXVREF@(.03,"I")
 S $P(PXVSTR,U,5)=@PXVREF@(.05,"I")
 ; INACTIVE FLAG - Return 0 or 1 instead of "" or 1
 S (PXVTEMP,$P(PXVSTR,U,6))=+@PXVREF@(.07,"I")
 S PXVACTIV='PXVTEMP
 S $P(PXVSTR,U,7)=@PXVREF@(8801,"I")
 S $P(PXVSTR,U,8)=@PXVREF@(8802,"I")
 S (PXVTEMP,$P(PXVSTR,U,9))=@PXVREF@(8803,"I")
 S PXVHISTR=PXVTEMP="Y"
 S PXVINCLU=1 ; Assume the record is to be included until proven otherwise
 I PXVFMT'="R",PXVTYPE'="*" D
 . I ACTONLY,'PXVACTIV S PXVINCLU=0
 . E  I SELHIST,'PXVHISTR S PXVINCLU=0
 Q:'PXVINCLU
 D:SUBFILES SUBFILES
 S PXVCNT=PXVCNT+1
 S @PXVRET@(PXVCNT)=PXVSTR
 Q
SUBFILES ; Add the subfile multiples to the array
 ; Subfiles:
 S PXVDLM1="|",PXVDLM2="~",PXVDLM3=";;"
 ; Field 2 - CDC FULL VACCINE NAME
 ; There's only one entry in Field 2 for each Immunization, but that may change
 S PXVSUB="",PXVSUBC=0
 F  S PXVSUBC=PXVSUBC+1 Q:'$D(@PXVREF@(2,PXVSUBC))  D
 . S $P(PXVSUB,PXVDLM1,PXVSUBC)=@PXVREF@(2,PXVSUBC)
 S $P(PXVSTR,U,10)=PXVSUB
 ; Field 3 - CODING SYSTEM
 S PXVREF=$NA(PXVDATA(PXVFILE_"3"))
 S PXVSBSCR="",PXVSUB="",PXVSUBC=0
 F  S PXVSBSCR=$O(@PXVREF@(PXVSBSCR)) Q:PXVSBSCR=""  D
 . S PXVSUBC=PXVSUBC+1
 . K PXVSDATA,PXVSERR
 . D GETS^DIQ(PXVFILE_"3",PXVSBSCR,"**","","PXVSDATA","PXVSERR")
 . S PXVSVSC2="",PXVSUB2C=0,PXVSUB2=""
 . F  S PXVSVSC2=$O(PXVSDATA(PXVFILE_"31",PXVSVSC2)) Q:PXVSVSC2=""  D
 . . S PXVSUB2C=PXVSUB2C+1
 . . S $P(PXVSUB2,PXVDLM3,PXVSUB2C)=PXVSDATA(PXVFILE_"31",PXVSVSC2,.01)
 . S $P(PXVSUB,PXVDLM1,PXVSUBC)=@PXVREF@(PXVSBSCR,.01,"I")_PXVDLM2_PXVSUB2
 S $P(PXVSTR,U,11)=PXVSUB
 ; Field 4 - VACCINE INFORMATION STATEMENT
 S PXVREF=$NA(PXVDATA(PXVFILE_"4"))
 S PXVSBSCR="",PXVSUB="",PXVSUBC=0
 F  S PXVSBSCR=$O(@PXVREF@(PXVSBSCR)) Q:PXVSBSCR=""  D
 . S PXVSUBC=PXVSUBC+1
 . S $P(PXVSUB,PXVDLM1,PXVSUBC)=@PXVREF@(PXVSBSCR,.01,"I")_PXVDLM2_@PXVREF@(PXVSBSCR,.01,"E")
 S $P(PXVSTR,U,12)=PXVSUB
 ; Field 5 - CDC PRODUCT NAME
 S PXVREF=$NA(PXVDATA(PXVFILE_"5"))
 S PXVSBSCR="",PXVSUB="",PXVSUBC=0
 F  S PXVSBSCR=$O(@PXVREF@(PXVSBSCR)) Q:PXVSBSCR=""  D
 . S PXVSUBC=PXVSUBC+1
 . S $P(PXVSUB,PXVDLM1,PXVSUBC)=@PXVREF@(PXVSBSCR,.01,"I")
 S $P(PXVSTR,U,13)=PXVSUB
 ; Field 7 - VACCINE GROUP NAME
 S PXVREF=$NA(PXVDATA(PXVFILE_"7"))
 S PXVSBSCR="",PXVSUB="",PXVSUBC=0
 F  S PXVSBSCR=$O(@PXVREF@(PXVSBSCR)) Q:PXVSBSCR=""  D
 . S PXVSUBC=PXVSUBC+1
 . S $P(PXVSUB,PXVDLM1,PXVSUBC)=@PXVREF@(PXVSBSCR,.01,"I")
 S $P(PXVSTR,U,14)=PXVSUB
 ; Field 10 - SYNONYM
 S PXVREF=$NA(PXVDATA(PXVFILE_"1"))
 S PXVSBSCR="",PXVSUB="",PXVSUBC=0
 F  S PXVSBSCR=$O(@PXVREF@(PXVSBSCR)) Q:PXVSBSCR=""  D
 . S PXVSUBC=PXVSUBC+1
 . S $P(PXVSUB,PXVDLM1,PXVSUBC)=@PXVREF@(PXVSBSCR,.01,"I")
 S $P(PXVSTR,U,15)=PXVSUB
 ; Field 99.991 - EFFECTIVE DATE/TIME
 S PXVREF=$NA(PXVDATA(PXVFILE_"99"))
 S PXVSBSCR="",PXVSUB="",PXVSUBC=0
 F  S PXVSBSCR=$O(@PXVREF@(PXVSBSCR)) Q:PXVSBSCR=""  D
 . S PXVSUBC=PXVSUBC+1
 . S $P(PXVSUB,PXVDLM1,PXVSUBC)=@PXVREF@(PXVSBSCR,.01,"I")_PXVDLM2_@PXVREF@(PXVSBSCR,.02,"I")
 S $P(PXVSTR,U,16)=PXVSUB
 Q