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

ORWLRAP2.m

Go to the documentation of this file.
ORWLRAP2 ;SLC/JNM - ANATOMIC PATHOLOGY DIALOG SUPPORT ROUTINES ;Jul 13, 2022@08:14:55
 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**569**;Dec 17, 1997;Build 23
 Q
GETDLGIEN() ; Returns the 101.45 IEN for the current quick order
 N IEN,APIDX,OI
 S IEN=0,APIDX=$P($G(ORDIALOG("B","ANATOMIC PATHOLOGY TEST")),U,2)
 I APIDX S OI=$P($G(ORDIALOG(APIDX,1)),U) I OI S IEN=$O(^ORD(101.45,"C",OI,0))
 Q IEN
 ;
ASKPROMPT(PROMPTID) ; Allow prompt selection in quick order
 ; PROMPTID:
 ;   OPURG:URGENCY
 ;   OPCDT:COLLECTION DATE/TIME
 ;   OPSSB:SPECIMEN SUBMITTED BY
 ;   OPCTY:COLLECTION TYPE
 ;   OPHOF:HOW OFTEN
 ;   OPSPH:SURGEON/PROVIDER
 ;   OPODC:ORDER COMMENT
 N OK,IEN,PIDX
 I "^OPURG^OPCDT^OPSSB^OPCTY^OPHOF^OPSPH^OPODC^"'[(U_$G(PROMPTID)_U) Q 0
 S OK=1,IEN=$$GETDLGIEN
 I 'IEN S OK=0
 E  D
 . S PIDX=$O(^ORD(101.45,IEN,1,"B",PROMPTID,0))
 . I PIDX,$P($G(^ORD(101.45,IEN,1,PIDX,0)),U,2) S OK=0
 Q OK
 ;
GETPAGECODES(CODE) ;
 S CODE(1)="Clinical History^CLINHX"
 S CODE(2)="Pre-Operative Diagnosis^PREOPDX"
 S CODE(3)="Operative Findings^OPFIND"
 S CODE(4)="Post-Operative Findings^POSTOPDX"
 Q
 ;
ASKPAGE(PAGEID) ; Allow page selection in quick order
 N OK,IEN,IDX,PAGE,CODE,FOUND
 D GETPAGECODES(.CODE)
 S (IDX,FOUND)=0 F  S IDX=$O(CODE(IDX)) Q:'IDX  D  Q:FOUND
 . I PAGEID=$P(CODE(IDX),U,2) S FOUND=1
 I 'FOUND Q 0
 S OK=0,IEN=$$GETDLGIEN I IEN D
 . S IDX=0 F  S IDX=$O(^ORD(101.45,IEN,2,IDX))  Q:'IDX  D  Q:OK
 . . S PAGE=$G(^ORD(101.45,IEN,2,IDX,0))
 . . I $P(PAGE,U,5)=PAGEID,'$P(PAGE,U,3) S OK=1
 Q OK
 ;
ALLOWSPEC(SPEC) ; Allow specimens
 N IEN,OK
 S OK=0,IEN=$$GETDLGIEN
 I IEN D
 . I $P($G(^ORD(101.45,IEN,0)),U,2) S OK=1
 . E  I +$O(^ORD(101.45,IEN,3,"B",SPEC,0)) S OK=1
 Q OK
 ;
GETCOUNT(IDX) ; Get the count of the spcific prompt
 N COUNT,I
 S (COUNT,I)=0
 F  S I=$O(ORDIALOG(IDX,I)) Q:'I  S COUNT=COUNT+1
 Q COUNT
 ;
SHOWCOUNT(COUNT,DESC) ; Show count line
 N SS,ZMSG S SS=$S(COUNT=1:"",1:"s"),ZMSG=""
 I COUNT<1 S COUNT="No",ZMSG=" (must have at lease one)"
 W " ***      "_COUNT_" "_DESC_SS_" found"_ZMSG_".",?SIZE,"***",!
 Q
 ;
ISINVALID() ; Validate AP Dialog quick order before saving
 N INVALID,IDX,SIZE,SAMPIDX,SPECIDX,DESCIDX,SAMPCOUNT,SPECCOUNT,DESCCOUNT
 S INVALID=1 D
 . S SAMPIDX=$P($G(ORDIALOG("B","COLLECTION SAMPLE")),U,2) Q:'SAMPIDX
 . S SPECIDX=$P($G(ORDIALOG("B","SPECIMEN")),U,2) Q:'SPECIDX
 . S DESCIDX=$P($G(ORDIALOG("B","SPECIMEN DESCRIPTION")),U,2) Q:'DESCIDX
 . S INVALID=0
 I 'INVALID D
 . S SAMPCOUNT=$$GETCOUNT(SAMPIDX)
 . S SPECCOUNT=$$GETCOUNT(SPECIDX)
 . S DESCCOUNT=$$GETCOUNT(DESCIDX)
 . I (SAMPCOUNT<1)!(SAMPCOUNT'=SPECCOUNT)!(SAMPCOUNT'=DESCCOUNT) D
 . . S INVALID=1,SIZE=69
 . . W !,$C(7)," "_$$REPEAT^XLFSTR("*",SIZE+2),!
 . . W " ***   Anatomic Pathology Quick Order is not valid!",?SIZE,"***",!
 . . W " ***",?SIZE,"***",!
 . . D SHOWCOUNT(SAMPCOUNT,"Collection Sample")
 . . D SHOWCOUNT(SPECCOUNT,"Specimen")
 . . D SHOWCOUNT(DESCCOUNT,"Specimen Description")
 . . W " ***",?SIZE,"***",!
 . . W " ***   The same number of Collection Samples, Specimens",?SIZE,"***",!
 . . W " ***   and Specimen Descriptions are required!",?SIZE,"***",!
 . . W " "_$$REPEAT^XLFSTR("*",SIZE+2),!
 Q INVALID
 ;
PROMPTINFO(TYPE) ; Returns item info from the LR OTHER LAB AP TESTS order dialog
 ; Return Data = AP Dlg IEN^Item Multiple IEN^Child Dlg IEN
 N ASKCODE,APDLG,DATA,IDX,X0,DONE,ITEM
 Q:$G(TYPE)="" ""
 S ASKCODE="$$ASKPROMPT^ORWLRAP2("""_TYPE_""")"
 S DATA="",APDLG=$O(^ORD(101.41,"B","LR OTHER LAB AP TESTS",0)) Q:'APDLG ""
 S (DONE,IDX)=0 F  S IDX=$O(^ORD(101.41,APDLG,10,IDX)) Q:DONE!('IDX)  D
 . I $G(^ORD(101.41,APDLG,10,IDX,3))[ASKCODE D  S DONE=1
 . . S X0=$G(^ORD(101.41,APDLG,10,IDX,0)),ITEM=$P(X0,U,2)
 . . S DATA=APDLG_U_IDX_U_ITEM
 Q DATA
 ;
ISTEXT(LABIEN,PROMPTIEN) ;
 N TYPE,ITEM
 S TYPE=$P($G(^ORD(101.45,LABIEN,1,PROMPTIEN,0)),U)
 S ITEM=$P($$PROMPTINFO(TYPE),U,3)
 I +ITEM,"^S^P^R^"'[(U_$P($G(^ORD(101.41,ITEM,1)),U)_U) Q 1
 Q 0
 ;
OK2DELETE(DEFAULT) ;
 N OK
 S OK=0
 I DEFAULT'="" D
 . N DIR,DA,X,Y,DIRUT
 . S DIR(0)="YAO",DIR("A")="   SURE YOU WANT TO DELETE? "
 . D ^DIR
 . I Y=1 S OK=1
 . E  W "  <NOTHING DELETED>"
 Q OK
 ;
GETDEFAULT(LABIEN,PROMPTIEN) ; Used by Input Template OR AP DIALOG EDIT TEMPLATE
 N REC,TYPE,DEFAULT,INFO,APDLG,IDX,ITEM,X1,PRTYPE,HELP
 N DIR,DA,X,Y,DIRUT,DONE
 S REC=$G(^ORD(101.45,LABIEN,1,PROMPTIEN,0))
 S TYPE=$P(REC,U),DEFAULT=$P(REC,U,4) Q:TYPE="" DEFAULT
 S INFO=$$PROMPTINFO(TYPE) Q:INFO="" DEFAULT
 S APDLG=$P(INFO,U,1),IDX=$P(INFO,U,2),ITEM=$P(INFO,U,3)
 S X1=$G(^ORD(101.41,ITEM,1)),PRTYPE=$P(X1,U,1),HELP=$P($G(^ORD(101.41,APDLG,10,IDX,1)),U,1)
 S DIR("A")="  DEFAULT: "
 I HELP'="" S DIR("?")=HELP
 I PRTYPE="P" D  I 1 ; Pointer Type
 . N FILE,VAL
 . S FILE=+$P(X1,U,2),DIR(0)="PAOr^"_FILE_":AEQM"
 . I +DEFAULT D EXTNAME^ORWU(.VAL,+DEFAULT,FILE) S:VAL'="" DIR("B")=VAL
 . F  S DONE=1 D  Q:DONE
 . . D ^DIR I $G(X)="@" D  I 1
 . . . S DONE=$$OK2DELETE(DEFAULT)
 . . . I DONE S DEFAULT="@"
 . . E  I '$D(DIRUT),+Y>0 S DEFAULT=+Y
 E  I PRTYPE="S" D  I 1 ; Set of Codes
 . N CODES,P1,P2
 . S CODES=$P(X1,U,2),DIR(0)="SAO^"_CODES
 . I DEFAULT'="" D
 . . S P1=$F(CODES,DEFAULT_":")
 . . I P1 D  I 1
 . . . S P2=$F(CODES,";",P1) I 'P2 S P2=$L(CODES)+2
 . . . S DIR("B")=$E(CODES,P1,P2-2)
 . . E  S DEFAULT="@" ; Code not found
 . F  S DONE=1 D  Q:DONE
 . . D ^DIR I $G(X)="@" D  I 1
 . . . S DONE=$$OK2DELETE(DEFAULT)
 . . . I DONE S DEFAULT="@"
 . . E  I '$D(DIRUT),Y'="" S DEFAULT=Y
 E  I PRTYPE="R" D  I 1 ; Free Text Date/Time
 . S DIR(0)="DAO^::ET"
 . I DEFAULT'="" S DIR("B")=DEFAULT
 . F  S DONE=1 D  Q:DONE
 . . D ^DIR I $G(X)="@" D  I 1
 . . . S DONE=$$OK2DELETE(DEFAULT)
 . . . I DONE S DEFAULT="@"
 . . E  I '$D(DIRUT),Y>0 S DEFAULT=X
 Q DEFAULT
 ;
GETPAGEID(LABIEN,PAGEIEN) ; Used by Input Template OR AP DIALOG EDIT TEMPLATE
 N REC,NAME,TYPE,DEFAULT,DIR,DA,X,Y,DIRUT,DONE,CODE,IDX,IEN,USEDTYPE,FIRST
 S REC=$G(^ORD(101.45,LABIEN,2,PAGEIEN,0))
 S NAME=$P(REC,U,2),TYPE=$P(REC,U,5)
 D GETPAGECODES(.CODE)
 S IEN=0 F  S IEN=$O(^ORD(101.45,LABIEN,2,IEN)) Q:'IEN  D:IEN'=PAGEIEN
 . S USEDTYPE=$P($G(^ORD(101.45,LABIEN,2,IEN,0)),U,5)
 . I USEDTYPE'="" D
 . . S (DONE,IDX)=0 F  S IDX=$O(CODE(IDX)) Q:'IDX  D  Q:DONE
 . . . I USEDTYPE=$P(CODE(IDX),U,2) K CODE(IDX) S DONE=1
 S DIR(0)="SA^",DIR("A")="  PAGE TYPE: ",DEFAULT=""
 S DIR("?")="Enter the type of page (types already used have been removed)."
 S IDX=0,FIRST=1 F  S IDX=$O(CODE(IDX)) Q:'IDX  D
 . S DIR(0)=DIR(0)_$S(FIRST:"",1:";")_IDX_":"_$P(CODE(IDX),U),FIRST=0
 I TYPE'="" D
 . S (IDX,DONE)=0 F  S IDX=$O(CODE(IDX)) Q:'IDX  D  Q:DONE
 . . I TYPE=$P(CODE(IDX),U,2) S DIR("B")=$P(CODE(IDX),U),DEFAULT=TYPE,DONE=1
 D ^DIR
 I '$D(DIRUT),+Y>0 S DEFAULT=$P($G(CODE(+Y)),U,2)
 Q DEFAULT
 ;
GETPAGENAME(LABIEN,PAGEIEN,TYPE) ; Used by Input Template OR AP DIALOG EDIT TEMPLATE
 N NAME,CODE,IDX,DONE
 S NAME=$P($G(^ORD(101.45,LABIEN,2,PAGEIEN,0)),U,2)
 I NAME="",TYPE'="" D
 . D GETPAGECODES(.CODE)
 . S (IDX,DONE)=0 F  S IDX=$O(CODE(IDX)) Q:'IDX  D  Q:DONE
 . . I TYPE=$P(CODE(IDX),U,2) S NAME=$P(CODE(IDX),U),DONE=1
 Q NAME
 ;