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

PSOSPMU0.m

Go to the documentation of this file.
  1. PSOSPMU0 ;BIRM/MFR - State Prescription Monitoring Program - Load ASAP Definition Utility ;10/07/12
  1. ;;7.0;OUTPATIENT PHARMACY;**451,625**;DEC 1997;Build 42
  1. ;
  1. LOADASAP(VERSION,DEFTYPE,ASARRAY) ; Loads the ASAP definition array for the specific Version
  1. ; Input: (r) VERSION - ASAP Version (3.0, 4.0, 4.1, 4.2)
  1. ; (r) DEFTYPE - ASAP Definition Type (S: Standard Only; C: Customized Only, B: Both)
  1. ;Output: ASARRAY - Array containing the ASAP Hierarchical Segment Structure/ASAP Elements Definition
  1. ;
  1. N ASAPDEF,FILEIEN,VER,VERIEN,SEGIEN,SEGNAM,ELMIEN,ELM0,ELMPOS,STAIEN,I
  1. ;
  1. I $G(VERSION)="" Q
  1. K ASARRAY,SEGINFO
  1. D SEGTREE(VERSION,DEFTYPE,"ASARRAY")
  1. F ASAPDEF="STANDARD ASAP DEFINITION","CUSTOM ASAP DEFINITION" D
  1. . I ASAPDEF="STANDARD ASAP DEFINITION",DEFTYPE="C" Q
  1. . I ASAPDEF="CUSTOM ASAP DEFINITION",DEFTYPE="S" Q
  1. . S FILEIEN=$O(^PS(58.4,"B",ASAPDEF,0))
  1. . F VER="ALL",VERSION D
  1. . . I VER="ALL",VERSION="4.1Z"!(VERSION="4.2Z") Q ;Zero Report doesn't load "ALL"
  1. . . ; - Don't want to load default (ALL) definitions for entirely cloned ASAP versions
  1. . . I ASAPDEF="STANDARD ASAP DEFINITION",'$D(^PS(58.4,FILEIEN,"VER","B",VERSION)) Q
  1. . . S VERIEN=$O(^PS(58.4,FILEIEN,"VER","B",VER,0)) I 'VERIEN Q
  1. . . I VER'="ALL" S ASARRAY=$G(^PS(58.4,FILEIEN,"VER",VERIEN,0))
  1. . . S SEGIEN=0
  1. . . F S SEGIEN=$O(^PS(58.4,FILEIEN,"VER",VERIEN,"SEG",SEGIEN)) Q:'SEGIEN D
  1. . . . S SEGNAM=$P($G(^PS(58.4,FILEIEN,"VER",VERIEN,"SEG",SEGIEN,0)),"^")
  1. . . . S ELMIEN=0
  1. . . . F S ELMIEN=$O(^PS(58.4,FILEIEN,"VER",VERIEN,"SEG",SEGIEN,"DAT",ELMIEN)) Q:'ELMIEN D
  1. . . . . S ELM0=$G(^PS(58.4,FILEIEN,"VER",VERIEN,"SEG",SEGIEN,"DAT",ELMIEN,0))
  1. . . . . S ELMPOS=$P(ELM0,"^",5)
  1. . . . . ; - Retrieving Data Element Definition
  1. . . . . S ASARRAY(SEGNAM,ELMPOS)=ELM0
  1. . . . . ; - Data Element Description
  1. . . . . K ASARRAY(SEGNAM,ELMPOS,"DES")
  1. . . . . F I=1:1 Q:'$D(^PS(58.4,FILEIEN,"VER",VERIEN,"SEG",SEGIEN,"DAT",ELMIEN,"DES",I)) D
  1. . . . . . S ASARRAY(SEGNAM,ELMPOS,"DES",I)=$G(^PS(58.4,FILEIEN,"VER",VERIEN,"SEG",SEGIEN,"DAT",ELMIEN,"DES",I,0))
  1. . . . . ; - Data Element Value - Mumps SET Command Argument
  1. . . . . K ASARRAY(SEGNAM,ELMPOS,"VAL")
  1. . . . . F I=1:1 Q:'$D(^PS(58.4,FILEIEN,"VER",VERIEN,"SEG",SEGIEN,"DAT",ELMIEN,"VAL",I)) D
  1. . . . . . S ASARRAY(SEGNAM,ELMPOS,"VAL",I)=$G(^PS(58.4,FILEIEN,"VER",VERIEN,"SEG",SEGIEN,"DAT",ELMIEN,"VAL",I,0))
  1. . . . . ; - Customized ASAP Data Element Flagging
  1. . . . . I ASAPDEF="CUSTOM ASAP DEFINITION" D
  1. . . . . . S ASARRAY(SEGNAM,ELMPOS,"CUS")=1
  1. Q
  1. ;
  1. SEGTREE(VERSION,DEFTYPE,ARRAY) ; Retrieve Hierarchical (Tree) Segement Positioning Information for each ASAP Version
  1. ; Input: (r) VERSION - ASAP Version (e.g., "3.0", "4.2", etc.)
  1. ; (r) DEFTYPE - ASAP Definition Type (S: Standard Only; C: Customized Only, B: Both)
  1. ;Output: ARRAY - Array containing Segment Hierarchically formatted (tree)
  1. ; Example: ARRAY(1)="TH"
  1. ; ARRAY(1,1)="IS"
  1. ; ARRAY(1,1,1)="PHA"
  1. ; ARRAY(1,1,1,1)="PAT"
  1. ; ARRAY(1,1,1,1,2)="DSP"
  1. ; ...
  1. ; ARRAY(1,1,2)="TP"
  1. ; ARRAY(2)="TT"
  1. N ASAPDEF,FILEIEN,VER,VERIEN,SEGIEN,SEG0,PARSEG,SEGPOS,SEGINFO
  1. ; Retrieving information about each Segment
  1. K @ARRAY
  1. F ASAPDEF="STANDARD ASAP DEFINITION","CUSTOM ASAP DEFINITION" D
  1. . I ASAPDEF="STANDARD ASAP DEFINITION",DEFTYPE="C" Q
  1. . I ASAPDEF="CUSTOM ASAP DEFINITION",DEFTYPE="S" Q
  1. . S FILEIEN=$O(^PS(58.4,"B",ASAPDEF,0))
  1. . F VER="ALL",VERSION D
  1. . . ; - Prevent loading default (ALL) definitions for entirely cloned ASAP versions
  1. . . I ASAPDEF="STANDARD ASAP DEFINITION",'$D(^PS(58.4,FILEIEN,"VER","B",VERSION)) Q
  1. . . S VERIEN=$O(^PS(58.4,FILEIEN,"VER","B",VER,0)) I 'VERIEN Q
  1. . . S SEGIEN=0
  1. . . F S SEGIEN=$O(^PS(58.4,FILEIEN,"VER",VERIEN,"SEG",SEGIEN)) Q:'SEGIEN D
  1. . . . S SEG0=$G(^PS(58.4,FILEIEN,"VER",VERIEN,"SEG",SEGIEN,0))
  1. . . . S PARSEG=$P(SEG0,"^",3)
  1. . . . S SEGPOS=+$P(SEG0,"^",5)
  1. . . . S SEGINFO($P(SEG0,"^"))=PARSEG_"^"_SEGPOS
  1. . . . S @ARRAY@($P(SEG0,"^"))=SEG0
  1. ; Building the Segment Tree
  1. D BLDTREE("",.SEGINFO,ARRAY)
  1. Q
  1. ;
  1. BLDTREE(SEG,SEGINFO,ARRAY) ; Build the ASAP Segment Tree (Recursivity Used)
  1. ; Input: SEG - Initial Segment (Usually "" to build from the top of the tree)
  1. ; SEGINFO - Segment Information Array (Parent & Position)
  1. ;Output: ARRAY - ASAP Segment Tree (See above for format)
  1. N SEGNAM
  1. S SEGNAM=""
  1. F S SEGNAM=$O(SEGINFO(SEGNAM)) Q:SEGNAM="" D
  1. . I $P(SEGINFO(SEGNAM),"^")'=SEG Q
  1. . S @ARRAY@($P(SEGINFO(SEGNAM),"^",2))=SEGNAM
  1. . D BLDTREE(SEGNAM,.SEGINFO,$Q(@ARRAY))
  1. Q
  1. ;
  1. VERLIST(DEFTYPE,REGZERO,ARRAY) ; Return a list of ASAP Versions ;Zero Report adding REGZERO
  1. ; Input: (r) DEFTYPE - ASAP Definition Type (D: Default Only; C: Customized Only, F: Fully Customized Only,
  1. ; A: All. A combination is also allowed, e.g., "CF")
  1. ; (r) REGZERO - Regular or Zero Report or Both ASAP Definitions (R: Regular Only;
  1. ; Z: Zero Report Only; B: Both)
  1. ;Output: ARRAY - ASAP Version List (ARRAY("3.0")="S", ARRAY("4.0")="S", etc...)
  1. N STDIEN,CUSIEN,VERSION
  1. N VER,ZFLG ;adding Zero Report flag
  1. K ARRAY
  1. S STDIEN=$O(^PS(58.4,"B","STANDARD ASAP DEFINITION",0))
  1. S CUSIEN=$O(^PS(58.4,"B","CUSTOM ASAP DEFINITION",0))
  1. I DEFTYPE["A"!(DEFTYPE["S") D
  1. . S VERSION="" F S VERSION=$O(^PS(58.4,STDIEN,"VER","B",VERSION)) Q:VERSION="" D
  1. . . I VERSION="ALL" Q
  1. . . S VER=$O(^PS(58.4,STDIEN,"VER","B",VERSION,0)) S ZFLG=$P($G(^PS(58.4,STDIEN,"VER",VER,0)),"^",5)
  1. . . I REGZERO["Z",'ZFLG Q ;Zero ASAP only
  1. . . I REGZERO["R",ZFLG Q ;ASAP only
  1. . . I REGZERO["B",ZFLG S ARRAY(VERSION_" ")="SZ" Q ;both ASAP and Zero ASAP
  1. . . S ARRAY(VERSION_" ")="S"
  1. I DEFTYPE["A"!(DEFTYPE["C")!(DEFTYPE["F") D
  1. . S VERSION="" F S VERSION=$O(^PS(58.4,CUSIEN,"VER","B",VERSION)) Q:VERSION="" D
  1. . . I $D(ARRAY(VERSION_" ")) Q ;if customized Zero Report
  1. . . S VER=$O(^PS(58.4,CUSIEN,"VER","B",VERSION,0)) S ZFLG=$P($G(^PS(58.4,CUSIEN,"VER",VER,0)),"^",5)
  1. . . I REGZERO["Z",'ZFLG Q ;Zero ASAP only
  1. . . I REGZERO["R",ZFLG Q ;ASAP only
  1. . . I DEFTYPE["A"!(DEFTYPE["C"),$D(^PS(58.4,STDIEN,"VER","B",VERSION)) S ARRAY(VERSION_" ")="C"
  1. . . I DEFTYPE["A"!(DEFTYPE["C"),$D(^PS(58.4,STDIEN,"VER","B",VERSION)),ZFLG S ARRAY(VERSION_" ")="CZ" ;Zero Rpt
  1. . . I DEFTYPE["A"!(DEFTYPE["F"),'$D(^PS(58.4,STDIEN,"VER","B",VERSION)) S ARRAY(VERSION_" ")="F"
  1. . . I DEFTYPE["A"!(DEFTYPE["F"),'$D(^PS(58.4,STDIEN,"VER","B",VERSION)),ZFLG S ARRAY(VERSION_" ")="FZ" ;Zero Rpt
  1. Q
  1. ;
  1. VERDATA(VERSION,DEFTYPE) ; Returns the ASAP Version fields
  1. ; Input: (r) VERSION - ASAP Version (e.g., "3.0", "4.2", etc.)
  1. ; (r) DEFTYPE - ASAP Definition Type (S: Standard Only; C: Customized Only, B: Both)
  1. ;Output: VERDATA - Sub-file #58.4001 0 node: "Version^Data Element Delimiter Char^Segment Terminator Char^..."
  1. N VERDATA,ASAPDEF,ASDEFIEN,VERIEN
  1. S VERDATA=""
  1. F ASAPDEF="STANDARD ASAP DEFINITION","CUSTOM ASAP DEFINITION" D
  1. . I ASAPDEF="STANDARD ASAP DEFINITION",DEFTYPE="C" Q
  1. . I ASAPDEF="CUSTOM ASAP DEFINITION",DEFTYPE="S" Q
  1. . S ASDEFIEN=$O(^PS(58.4,"B",ASAPDEF,0)) I 'ASDEFIEN Q
  1. . S VERIEN=$O(^PS(58.4,ASDEFIEN,"VER","B",VERSION,0)) I 'VERIEN Q
  1. . S VERDATA=$G(^PS(58.4,ASDEFIEN,"VER",VERIEN,0))
  1. Q VERDATA