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

ORDEA01A.m

Go to the documentation of this file.
  1. ORDEA01A ;ISP/RFR - DEA REPORTS 01;10/15/2014 08:03
  1. ;;3.0;ORDER ENTRY/RESULTS REPORTING;**218,350,499**;Dec 17, 1997;Build 165
  1. Q
  1. DUPVA ;DUPLICATE VA#'S REPORT
  1. ;REP IS HANDLED BY REPORTS^ORDEA01
  1. N DISINC,DIV,SAVE
  1. W !!,"This report identifies all users with similar VA numbers. To identify",!
  1. W "similar numbers, the software builds a temporary index. First, it removes all",!
  1. W "non-alphanumeric characters (such as punctuation and spaces) from the user's",!
  1. W "VA number, then changes all letters to uppercase, and finally adds the VA",!
  1. W "number to the temporary index. It then uses that index to build a list of",!
  1. W "similar or duplicate numbers. For example, kc123, KC 123, and KC-123 are",!
  1. W "considered similar.",!
  1. S DISINC=$$DISPRMPT^ORDEA01()
  1. Q:DISINC=U
  1. S SAVE("DISINC")=""
  1. D DEVICE^ORUTL($P(REP(REP),";",3),"OR "_$$UP^XLFSTR($P(REP(REP),";")),"Q",.SAVE)
  1. Q
  1. DUPVAQ ;TASKMAN ENTRY POINT
  1. ;CBUFFER IS HANDLED BY DEVICE^ORUTL OR TASKMAN
  1. N DOCS,ERROR,KEY,INDEX,NUMBER,DUPL,PGNUM,COL,STOP,OUTPUT
  1. ;RETRIEVE ALL USERS WITH A VA #
  1. S DOCS=$NA(^TMP($J,"ORDUPVA")),DUPL=$NA(^TMP($J,"ORDUPVA","DUPL"))
  1. K @DOCS
  1. D LIST^DIC(200,,"@;.01;53.3","PQ",,,,"PS2",,,DOCS,"ERROR")
  1. I $D(ERROR) D Q
  1. .D FMERROR^ORUTL(.ERROR)
  1. .S:$D(ZTQUEUED) ZTREQ="@"
  1. ;ORDER THE RETURNED LIST BY VA #
  1. S INDEX=0 F S INDEX=$O(@DOCS@("DILIST",INDEX)) Q:+$G(INDEX)=0 D
  1. .S NUMBER=$P(@DOCS@("DILIST",INDEX,0),U,3),KEY=$$UP^XLFSTR(NUMBER)
  1. .S KEY=$$STRIP(KEY)
  1. .Q:$G(KEY)=""
  1. .N ACCOUNT S ACCOUNT=$$ACTIVE^XUSER($P(@DOCS@("DILIST",INDEX,0),U))
  1. .I 'DISINC,(+ACCOUNT<1),($P(ACCOUNT,U,2)'="") Q
  1. .S ACCOUNT("TEXT")=$S($P(ACCOUNT,U,2)'="":$P(ACCOUNT,U,2),ACCOUNT=0:"CANNOT SIGN ON",1:"UNKNOWN")
  1. .S @DUPL@(KEY)=+$G(@DUPL@(KEY))+1
  1. .S @DUPL@(KEY,@DUPL@(KEY),NUMBER)=$$LJ^XLFSTR($P(@DOCS@("DILIST",INDEX,0),U,2),37," ")_ACCOUNT("TEXT")
  1. ;OUTPUT THE DUPLICATES
  1. S COL(1)=$$LJ^XLFSTR("VA#",12," ")_$$LJ^XLFSTR("NAME",37," ")_"ACCOUNT STATUS"
  1. S KEY="" F S KEY=$O(@DUPL@(KEY)) Q:$G(KEY)=""!($G(STOP)) D
  1. .I @DUPL@(KEY)>1 D
  1. ..S OUTPUT=1
  1. ..I (@DUPL@(KEY)+$Y+CBUFFER)>IOSL!($Y=0) S STOP=$$HEADER^ORUTL("NON-UNIQUE VA NUMBERS REPORT",.PGNUM,.COL)
  1. ..Q:$G(STOP)
  1. ..S INDEX=0 F S INDEX=$O(@DUPL@(KEY,INDEX)) Q:+$G(INDEX)=0 D
  1. ...S NUMBER=$O(@DUPL@(KEY,INDEX,""))
  1. ...W $$LJ^XLFSTR(NUMBER,12," ")_@DUPL@(KEY,INDEX,NUMBER)
  1. ...I ($Y+1)<IOSL W !
  1. ..W $$REPEAT^XLFSTR("=",60)
  1. ..I ($Y+1)<IOSL W !
  1. I '$G(STOP) D
  1. .I '$G(OUTPUT) D Q:$G(STOP)
  1. ..S STOP=$$HEADER^ORUTL("NON-UNIQUE VA NUMBERS REPORT",.PGNUM,.COL)
  1. ..Q:STOP
  1. ..W !,$$CJ^XLFSTR("All VA Numbers are unique.",$S(+$G(IOM)>0:(IOM-1),1:79)," "),!
  1. .I ($Y+2)>IOSL S STOP=$$HEADER^ORUTL("NON-UNIQUE VA NUMBERS REPORT",.PGNUM,.COL)
  1. .Q:$G(STOP)
  1. .W !,$$CJ^XLFSTR("[END OF REPORT]",$S(+$G(IOM)>0:(IOM-1),1:79)," ")
  1. S:$D(ZTQUEUED) ZTREQ="@"
  1. Q
  1. STRIP(TEXT) ;REMOVE PUNCTUATION CHARACTERS AND SPACES
  1. N %
  1. F %=1:1:$L(TEXT) N CHR S CHR=$A($E(TEXT,%)) I CHR<48!(CHR>57&(CHR<65))!(CHR>90&(CHR<97))!(CHR>122) S TEXT=$TR(TEXT,$E(TEXT,%))
  1. Q TEXT
  1. INCOMPL ;INCOMPLETE PROVIDER SETUP REPORT
  1. ;REP IS HANDLED BY REPORTS^ORDEA01
  1. W !!,"This report identifies all active providers who are unable to sign controlled",!
  1. W "substance orders. For the purposes of this report, a provider is a user who",!
  1. W "holds the ORES security key.",!
  1. W !,"By default, the report lists the prescribable schedules for each provider",!
  1. W "(including those providers that are properly configured).",!
  1. N INCLUDE,DISINC,DIV,DIR,X,Y,DTOUT,DUOUT,DIRUT,DIROUT,SAVE,ORCSV
  1. S DIR(0)="Y"_U,DIR("A")="Do you want to include prescribable schedules in the output"
  1. S DIR("B")="NO"
  1. S DIR("?",1)="By answering YES, the report will list the schedules each provider is able to"
  1. S DIR("?",2)="prescribe and will include those providers who are able to sign controlled"
  1. S DIR("?",3)="substance orders."
  1. S DIR("?",4)="By answering NO, the report will not list the prescribable schedules and will"
  1. S DIR("?",5)="only include those providers who are unable to sign controlled substance"
  1. S DIR("?")="orders."
  1. D ^DIR
  1. Q:$D(DIRUT)
  1. S INCLUDE=Y
  1. K X,Y,DTOUT,DUOUT,DIRUT,DIROUT
  1. W !
  1. S DISINC=$$DISPRMPT^ORDEA01()
  1. Q:DISINC=U
  1. W !
  1. S X=$$DIVPRMPT^ORUTL(.DIV)
  1. Q:X<1
  1. K X,Y,DIR,DTOUT,DUOUT,DIRUT,DIROUT
  1. S DIR(0)="Y"_U,DIR("A",1)="Do you want to generate the report in a delimited format suitable for import"
  1. S DIR("A")="into third-party applications"
  1. S DIR("?",1)="By answering YES, the report is generated in a comma-separated values (CSV)"
  1. S DIR("?",2)="format."
  1. S DIR("?")="By answering NO, the report is generated in a non-delimited format."
  1. W !
  1. D ^DIR
  1. Q:$D(DIRUT)
  1. S ORCSV=Y
  1. I ORCSV D
  1. .W !!,"To create a file on your computer for use in third-party applications, perform"
  1. .W !,"the following:",!
  1. .W !," 1. To queue the report, at the DEVICE: prompt, enter the letter Q."
  1. .W !," 2. At the DEVICE: prompt, select the appropriate spooler device."
  1. .W !," 3. Once the spooled document is ready, use option Download a Spool file entry"
  1. .W !," [XT-KERMIT SPOOL DL] to download the report to your computer."
  1. .W !," Note: Refer to your terminal emulator's documentation for instructions on"
  1. .W !," receiving files via the KERMIT protocol.",!
  1. S SAVE("INCLUDE")="",SAVE("DISINC")="",SAVE("DIV(")="",SAVE("ORCSV")=""
  1. D DEVICE^ORUTL($P(REP(REP),";",3),"OR "_$$UP^XLFSTR($P(REP(REP),";")),"Q",.SAVE)
  1. Q
  1. INCOMPLQ ;TASKMAN ENTRY POINT
  1. ;CBUFFER IS HANDLED BY DEVICE^ORUTL OR TASKMAN
  1. N DATA,Y,INDENT,STOP,COUNT
  1. S DATA=$NA(^TMP($J,"ORDATA"))
  1. K @DATA
  1. S INDENT(0)=$$REPEAT^XLFSTR(" ",37),INDENT(1)=$$REPEAT^XLFSTR("-",34)
  1. ;IA #10076
  1. S Y=0 F S Y=$O(^XUSEC("ORES",Y)) Q:+$G(Y)=0!($G(STOP)) D
  1. .N DIVISION S DIVISION=$$HASDIV^ORUTL(Y,.DIV)
  1. .Q:$G(DIVISION)=""
  1. .N ACCOUNT S ACCOUNT=$$ACTIVE^XUSER(Y)
  1. .I 'DISINC,(+ACCOUNT<1),($P(ACCOUNT,U,2)'="") Q
  1. .;INCLUDE USERS WHO CANNOT SIGN-ON IN ACTIVE LISTING
  1. .S ACCOUNT=$S(ACCOUNT=0:1,ACCOUNT="":-1,1:ACCOUNT)
  1. .N RETURN,STATUS
  1. .S STATUS=$$VDEA^XUSER(.RETURN,Y),COUNT=1+$G(COUNT)
  1. .S STATUS=$$CHKSWIT^ORDEA01(.RETURN,Y,STATUS)
  1. .I $D(RETURN)>9 D
  1. ..N REASON,NAME,INDEX
  1. ..S NAME=$$GET1^DIQ(200,Y_",",.01)
  1. ..I NAME="",ACCOUNT=-1 S NAME="ACCOUNT #"_Y
  1. ..S @DATA@(DIVISION,STATUS,+ACCOUNT,NAME)=$$GET1^DIQ(200,Y_",",8)
  1. ..S REASON="" F S REASON=$O(RETURN(REASON)) Q:$G(REASON)="" D
  1. ...N TEXT
  1. ...I '$G(INCLUDE),(REASON["Is permitted") Q
  1. ...I STATUS=1,(REASON'["Is permitted") D
  1. ....S TEXT=$$LOW^XLFSTR($E(REASON,1,1))_$E(REASON,2,$L(REASON))
  1. ....S TEXT="Can sign controlled substance orders, however, the provider "_TEXT
  1. ...S INDEX=1+$G(INDEX),@DATA@(DIVISION,STATUS,+ACCOUNT,NAME,INDEX)=$S($G(TEXT)'="":$G(TEXT),1:REASON)
  1. .I 'COUNT#100 S STOP=$$STOPTASK^ORUTL()
  1. I 'ORCSV D IREPORT
  1. I ORCSV D IEXPORT
  1. K @DATA
  1. S:$D(ZTQUEUED) ZTREQ="@"
  1. Q
  1. IREPORT ;CREATE NON-CSV FORMAT
  1. N DIVISION,NAME,LINE,STATUS,TEXT,OUTPUT,ACCOUNT,COL,PGNUM
  1. S DIVISION="" F S DIVISION=$O(@DATA@(DIVISION)) Q:$G(DIVISION)=""!($G(STOP)) D
  1. .S COL(1)="DIVISION: "_DIVISION
  1. .F STATUS=0:1:1 D Q:$G(STOP)
  1. ..I STATUS=1,('$G(INCLUDE)) Q
  1. ..Q:$D(@DATA@(DIVISION,STATUS))<10
  1. ..S TEXT=$S(STATUS=0:"un",1:"")_"able"
  1. ..S COL(2)=$$LJ^XLFSTR("PROVIDER NAME",37," ")
  1. ..S COL(3)=$$LJ^XLFSTR(" TITLE",37," ")_$S(TEXT="unable":"DEFICIENCY",1:"")
  1. ..S COL(3)=COL(3)_$S(TEXT="unable"&INCLUDE=1:"/",1:"")_$S(INCLUDE=1:"PRESCRIBABLE SCHEDULES",1:"")
  1. ..S STOP=$$HEADER^ORUTL("PROVIDER INCOMPLETE CONFIGURATION REPORT",.PGNUM,.COL)
  1. ..Q:$G(STOP)
  1. ..F ACCOUNT=1:-1:-1 D Q:$G(STOP)
  1. ...Q:$D(@DATA@(DIVISION,STATUS,ACCOUNT))<10
  1. ...N BUFFER S BUFFER=@DATA@(DIVISION,STATUS,ACCOUNT,$O(@DATA@(DIVISION,STATUS,ACCOUNT,"")))
  1. ...S BUFFER=BUFFER+$S(ACCOUNT=0&($Y>4):3,ACCOUNT=0:2,1:0)
  1. ...I (BUFFER+$Y+CBUFFER)>IOSL!($Y=0) D Q:$G(STOP)
  1. ....S STOP=$$HEADER^ORUTL("PROVIDER INCOMPLETE CONFIGURATION REPORT",.PGNUM,.COL)
  1. ...I ACCOUNT=0 D
  1. ....W:$Y>4 !
  1. ....W $$CJ^XLFSTR("*** DISUSERED/TERMINATED USERS ***",$S(+$G(IOM)>0:(IOM-1),1:79)," "),!
  1. ....W $$CJ^XLFSTR(INDENT(1),$S(+$G(IOM)>0:(IOM-1),1:79)," "),!
  1. ...S NAME="" F S NAME=$O(@DATA@(DIVISION,STATUS,ACCOUNT,NAME)) Q:$G(NAME)=""!($G(STOP)) D
  1. ....N BODY
  1. ....S INDEX=0 F S INDEX=$O(@DATA@(DIVISION,STATUS,ACCOUNT,NAME,INDEX)) Q:'INDEX D
  1. .....D WRAP^ORUTL(INDENT(0)_@DATA@(DIVISION,STATUS,ACCOUNT,NAME,INDEX),"BODY")
  1. ....S BODY(1)=$$LJ^XLFSTR(NAME,37," ")_$E($G(BODY(1)),38,$S(+$G(IOM)>0:IOM,1:80))
  1. ....S BODY(2)=$$LJ^XLFSTR(" "_@DATA@(DIVISION,STATUS,ACCOUNT,NAME),37," ")_$E($G(BODY(2)),38,$S(+$G(IOM)>0:IOM,1:80))
  1. ....S:BODY<2 BODY=2
  1. ....I (BODY+$Y+CBUFFER)>IOSL D Q:$G(STOP)
  1. .....S STOP=$$HEADER^ORUTL("PROVIDER INCOMPLETE CONFIGURATION REPORT",.PGNUM,.COL)
  1. ....F LINE=1:1:BODY D
  1. .....W BODY(LINE)
  1. .....I ($Y+1)<IOSL W !
  1. .....S OUTPUT=1
  1. ....I LINE>0,(($Y+1)<IOSL) W !
  1. I '$G(STOP) D
  1. .I '$G(OUTPUT) D Q:$G(STOP)
  1. ..S STOP=$$HEADER^ORUTL("PROVIDER INCOMPLETE CONFIGURATION REPORT",.PGNUM,.COL)
  1. ..Q:STOP
  1. ..N TEXT,BODY
  1. ..S TEXT="All providers are able to sign controlled substance orders"
  1. ..I $D(DIV) D
  1. ...N IDX,STATIONS
  1. ...S IDX="" F S IDX=$O(DIV(IDX)) Q:$G(IDX)="" D
  1. ....N DELIMIT
  1. ....S DELIMIT=$S($O(DIV(IDX))'="":", ",1:" and ")
  1. ....S STATIONS=$S($G(STATIONS)'="":STATIONS_DELIMIT,1:"")_DIV(IDX)
  1. ...S TEXT=TEXT_" in "_STATIONS
  1. ..D WRAP^ORUTL(TEXT_".","BODY")
  1. ..S BODY=0 F S BODY=$O(BODY(BODY)) Q:'BODY W BODY(BODY),!
  1. .I ($Y+2)>IOSL S STOP=$$HEADER^ORUTL("PROVIDER INCOMPLETE CONFIGURATION REPORT",.PGNUM,.COL)
  1. .Q:$G(STOP)
  1. .W !,$$CJ^XLFSTR("[END OF REPORT]",$S(+$G(IOM)>0:(IOM-1),1:79)," ")
  1. Q
  1. IEXPORT ;CREATE CSV FORMAT
  1. N DIVISION,STATUS,ACCOUNT,NAME,Q,QCQ,LINE,XTKDIC,XTKMODE,XTKFILE
  1. S Q=$C(34),QCQ=Q_","_Q
  1. W Q_"DIVISION"_QCQ_"PROVIDER NAME"_QCQ_"TITLE"_QCQ_"DEFICIENCY"
  1. W $S(INCLUDE=1:"/PRESCRIBABLE SCHEDULES",1:"")_Q,!
  1. S DIVISION="" F S DIVISION=$O(@DATA@(DIVISION)) Q:$G(DIVISION)="" D
  1. .F STATUS=0:1:1 D
  1. ..I STATUS=1,('$G(INCLUDE)) Q
  1. ..F ACCOUNT=1:-1:0 D
  1. ...S NAME="" F S NAME=$O(@DATA@(DIVISION,STATUS,ACCOUNT,NAME)) Q:$G(NAME)="" D
  1. ....S INDEX=0 F S INDEX=$O(@DATA@(DIVISION,STATUS,ACCOUNT,NAME,INDEX)) Q:$G(INDEX)="" D
  1. .....W Q_DIVISION_QCQ_NAME_QCQ_@DATA@(DIVISION,STATUS,ACCOUNT,NAME)_QCQ
  1. .....W @DATA@(DIVISION,STATUS,ACCOUNT,NAME,INDEX)_Q,!
  1. Q
  1. DETOX ;DETOX/MAINTENANCE ID Report
  1. ;REP IS HANDLED BY REPORTS^ORDEA01
  1. N DISINC
  1. W !!,"This report identifies all users who have a DETOX/MAINTENANCE ID number",!
  1. W "in the NEW PERSON FILE (#200).",!
  1. S DISINC=$$DISPRMPT^ORDEA01()
  1. Q:DISINC=U
  1. S SAVE("DISINC")=""
  1. D DEVICE^ORUTL($P(REP(REP),";",3),"OR "_$$UP^XLFSTR($P(REP(REP),";")),"Q",.SAVE)
  1. Q
  1. DETOXQ ;TASKMAN ENTRY POINT
  1. ;CBUFFER IS HANDLED BY DEVICE^ORUTL OR TASKMAN
  1. N DOCS,DATA,ERROR,INDEX,PGNUM,COL,STOP,ACCOUNT,OUTPUT
  1. ;RETRIEVE ALL USERS WITH A DETOX/MAINTENANCE ID NUMBER
  1. S DOCS=$NA(^TMP($J,"ORDETOX")),DATA=$NA(^TMP($J,"ORDETOXDATA"))
  1. K @DOCS,@DATA
  1. S COL(1)=" DETOX/MAINTENANCE"
  1. S COL(2)="NAME ID NUMBER ACCOUNT STATUS"
  1. ;*499
  1. D LIST^DIC(200,,"@;.01;9001","PQ",,,,,"I ($L($$DETOX^XUSER(Y)))",,DOCS,"ERROR")
  1. I $D(ERROR) D Q
  1. .D FMERROR^ORUTL(.ERROR)
  1. .S:$D(ZTQUEUED) ZTREQ="@"
  1. .K @DOCS
  1. S INDEX=0 F S INDEX=$O(@DOCS@("DILIST",INDEX)) Q:+$G(INDEX)=0 D
  1. .N ACCOUNT S ACCOUNT=$$ACTIVE^XUSER($P(@DOCS@("DILIST",INDEX,0),U))
  1. .I 'DISINC,(+ACCOUNT<1),($P(ACCOUNT,U,2)'="") Q
  1. .S ACCOUNT("TEXT")=$S($P(ACCOUNT,U,2)'="":$P(ACCOUNT,U,2),ACCOUNT=0:"CANNOT SIGN ON",1:"UNKNOWN")
  1. .;INCLUDE USERS WHO CANNOT SIGN-ON IN ACTIVE LISTING
  1. .I ACCOUNT=0 S ACCOUNT=1
  1. .S @DATA@(+ACCOUNT,$P(@DOCS@("DILIST",INDEX,0),U,2))=$$LJ^XLFSTR($P(@DOCS@("DILIST",INDEX,0),U,3),19," ")_ACCOUNT("TEXT")
  1. F ACCOUNT=1:-1:0 D Q:$G(STOP)
  1. .Q:'$D(@DATA@(ACCOUNT))
  1. .I ACCOUNT=0 D
  1. ..I ($Y+CBUFFER+4)>IOSL!($Y=0) D Q:$G(STOP)
  1. ...S STOP=$$HEADER^ORUTL("PROVIDERS WITH A DETOX/MAINTENANCE ID",.PGNUM,.COL)
  1. ..W !,$$CJ^XLFSTR("*** DISUSERED/TERMINATED USERS ***",$S(+$G(IOM)>0:(IOM-1),1:79)," "),!
  1. ..W $$CJ^XLFSTR($$REPEAT^XLFSTR("-",34),$S(+$G(IOM)>0:IOM,1:80)," "),!
  1. .S NAME="" F S NAME=$O(@DATA@(ACCOUNT,NAME)) Q:NAME=""!($G(STOP)) D
  1. ..I ($Y+CBUFFER)>IOSL!($Y=0) D Q:$G(STOP)
  1. ...S STOP=$$HEADER^ORUTL("PROVIDERS WITH A DETOX/MAINTENANCE ID",.PGNUM,.COL)
  1. ..W $$LJ^XLFSTR(NAME,37," ")_@DATA@(ACCOUNT,NAME)
  1. ..I ($Y+1)<IOSL W !
  1. ..S OUTPUT=1
  1. I '$G(STOP) D
  1. .I '$G(OUTPUT) D Q:$G(STOP)
  1. ..S STOP=$$HEADER^ORUTL("PROVIDERS WITH A DETOX/MAINTENANCE ID",.PGNUM,.COL)
  1. ..Q:STOP
  1. ..W !,$$CJ^XLFSTR("0 PROVIDERS FOUND",$S(+$G(IOM)>0:(IOM-1),1:79)," "),!
  1. .I ($Y+2)>IOSL S STOP=$$HEADER^ORUTL("PROVIDERS WITH A DETOX/MAINTENANCE ID",.PGNUM,.COL)
  1. .Q:$G(STOP)
  1. .W !,$$CJ^XLFSTR("[END OF REPORT]",$S(+$G(IOM)>0:(IOM-1),1:79)," ")
  1. K @DOCS,@DATA
  1. S:$D(ZTQUEUED) ZTREQ="@"
  1. Q