ORWGAPIW ; SLC/STAFF - Graph API Utilities, Generic ;8/19/06 15:20
;;3.0;ORDER ENTRY/RESULTS REPORTING;**243**;Dec 17, 1997;Build 242
;
DATA(ARRAY) ; $$(application results) -> single string of results
N NUM,RESULT,SUB
S OUT=""
S SUB=""
F S SUB=$O(ARRAY(SUB)) Q:SUB="" D
. I $D(ARRAY(SUB,0)) D Q
.. S OUT=OUT_SUB_"["
.. S NUM=0
.. F S NUM=$O(ARRAY(SUB,NUM)) Q:NUM<1 D
... S RESULT=$G(ARRAY(SUB,NUM,0))
... S OUT=OUT_RESULT_";"
.. S OUT=OUT_"]"
. S RESULT=$G(ARRAY(SUB))
. S OUT=OUT_SUB_"["_RESULT_"]"
S OUT=$TR(OUT,U,"~")
Q OUT
;
DATETFM(DATETIME) ; $$(external date/time) -> fm date/time else 0
N DATE,DAY,FMDT,HOUR,MIN,SEC,TIME,YEAR
S DATE=$P(DATETIME,"@"),TIME=$P(DATETIME,"@",2)
S YEAR=$P(DATE,",",2) I $L(YEAR)'=4 Q 0
S YEAR=YEAR-1700 I YEAR<270 Q 0
S MONTH=$P(DATE," ")
S MONTH=$$MTN(MONTH) I MONTH<1 Q 0
I MONTH<10 S MONTH="0"_MONTH
S DAY=$P(DATE," ",2),DAY=$P(DAY,",")
I DAY<1 Q 0
I DAY<10 S DAY="0"_DAY
S HOUR=$P(TIME,":")
S MIN=$P(TIME,":",2)
S SEC=$P(TIME,":",3)
S TIME=HOUR_MIN_SEC
S FMDT=YEAR_MONTH_DAY
I '$L(TIME) Q FMDT
Q FMDT_"."_TIME
;
GENERIC(VAL,FROM,DIR,FILE,REF,XREF,SCREEN) ; Return a set of entries from xref in REF
; from ORWGAPI
; .VAL=returned list, FROM=text to $O from, DIR=$O direction,
N CNT,IEN,NAME,NEXTNAME,NUM,OK,ROOT,ZERO S NUM=0,CNT=44 K VAL
I FILE=405 Q
S ROOT=""
S FROM=$$UP^ORWGAPIX(FROM)
I $E(REF,$L(REF))="," S ROOT=$E(REF,1,$L(REF)-1)_")"
I $E(REF,$L(REF))="(" S ROOT=$P(REF,"(")
I '$L(ROOT) Q
S REF=REF_""""_XREF_""")"
F Q:NUM'<CNT S FROM=$O(@REF@(FROM),DIR) Q:FROM="" D
. S IEN="" F S IEN=$O(@REF@(FROM,IEN),DIR) Q:'IEN D
.. I FILE=100,$O(@REF@(FROM,IEN,""))>0 Q
.. S ZERO=$G(@ROOT@(IEN,0)) I '$L(ZERO) Q
.. X SCREEN I '$T Q
.. S NUM=NUM+1
.. I FILE="45DX"!(FILE=9000010.07)!(FILE=9000011)!(FILE="63AP;I") D Q
... S VAL(NUM)=FILE_U_IEN_U_$$ICD9^ORWGAPIA(IEN) Q
.. I FILE="45OP" S VAL(NUM)=FILE_U_IEN_U_$$ICD0^ORWGAPIA(IEN) Q
.. I FILE=53.79 S VAL(NUM)=FILE_U_IEN_U_$$POINAME^ORWGAPIC(IEN) Q
.. I FILE="55NVA" S VAL(NUM)=FILE_U_IEN_U_$$POINAME^ORWGAPIC(IEN) Q
.. I FILE=9000010.18 S VAL(NUM)=FILE_U_IEN_U_$$ICPT^ORWGAPIA(IEN) Q
.. I FILE=130 S VAL(NUM)=FILE_U_IEN_U_$$ICPT^ORWGAPIA(IEN) Q
.. S VAL(NUM)=FILE_U_IEN_U_FROM
I FILE=120.5 D
. S (NUM,OK)=0
. F S NUM=$O(VAL(NUM)) Q:NUM<1 D Q:OK
.. S NAME=$P(VAL(NUM),U,3)
.. S NEXTNAME=$P($G(VAL(NUM+1)),U,3)
.. I "BODY MASS INDEX"]NAME,NEXTNAME]"BODY MASS INDEX" D
... S OK=1
... S VAL(NUM+.5)="120.5^99999^BODY MASS INDEX"
Q
;
MTN(MONTH) ; $$(external month) -> month number
N MONTHS,NUM
I $L(MONTH)'=3 Q 0
S MONTHS="JAN^FEB^MAR^APR^MAY^JUN^JUL^AUG^SEP^OCT^NOV^DEC"
F NUM=1:1:13 I $P(MONTHS,U,NUM)=MONTH Q
I NUM=13 Q 0
Q NUM
;
OGROUP(OITEM) ; $$(orderable item) -> ien display group^display group - from ORWGAPIR
N IEN
S IEN=+$P($G(^ORD(101.43,+$G(OITEM),0)),U,5)
Q IEN_U_"order - "_$P($G(^ORD(100.98,IEN,0)),U)
;
RETURN(TMP,ITEMS) ; return TMP (0 use local, 1 use ^TMP(ITEMS,$J, where ITEMS is a namespaced string)
; from ORWGAPI, ORWGAPIP, ORWGAPIX
N NMSP
S NMSP=$G(ITEMS) K ITEMS S ITEMS=""
S TMP=NMSP?1U1UN1.14UNP
I TMP S ITEMS=NMSP
Q
;
SETUP(DATA,RESULT,TMP,CNT) ; from ORWGAPI1, ORWGAPI2, ORWGAPI3, ORWGAPI4, ORWGAPIP, ORWGAPIR, ORWGAPIX
S CNT=CNT+1
I TMP=2 S ^TMP(DATA,$J,$P(RESULT,U,1,2))=RESULT Q
I TMP S ^TMP(DATA,$J,CNT)=RESULT
I 'TMP S DATA(CNT)=RESULT
Q
;
ORWGAPIW ; SLC/STAFF - Graph API Utilities, Generic ;8/19/06 15:20
+1 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**243**;Dec 17, 1997;Build 242
+2 ;
DATA(ARRAY) ; $$(application results) -> single string of results
+1 NEW NUM,RESULT,SUB
+2 SET OUT=""
+3 SET SUB=""
+4 FOR
SET SUB=$ORDER(ARRAY(SUB))
IF SUB=""
QUIT
Begin DoDot:1
+5 IF $DATA(ARRAY(SUB,0))
Begin DoDot:2
+6 SET OUT=OUT_SUB_"["
+7 SET NUM=0
+8 FOR
SET NUM=$ORDER(ARRAY(SUB,NUM))
IF NUM<1
QUIT
Begin DoDot:3
+9 SET RESULT=$GET(ARRAY(SUB,NUM,0))
+10 SET OUT=OUT_RESULT_";"
End DoDot:3
+11 SET OUT=OUT_"]"
End DoDot:2
QUIT
+12 SET RESULT=$GET(ARRAY(SUB))
+13 SET OUT=OUT_SUB_"["_RESULT_"]"
End DoDot:1
+14 SET OUT=$TRANSLATE(OUT,U,"~")
+15 QUIT OUT
+16 ;
DATETFM(DATETIME) ; $$(external date/time) -> fm date/time else 0
+1 NEW DATE,DAY,FMDT,HOUR,MIN,SEC,TIME,YEAR
+2 SET DATE=$PIECE(DATETIME,"@")
SET TIME=$PIECE(DATETIME,"@",2)
+3 SET YEAR=$PIECE(DATE,",",2)
IF $LENGTH(YEAR)'=4
QUIT 0
+4 SET YEAR=YEAR-1700
IF YEAR<270
QUIT 0
+5 SET MONTH=$PIECE(DATE," ")
+6 SET MONTH=$$MTN(MONTH)
IF MONTH<1
QUIT 0
+7 IF MONTH<10
SET MONTH="0"_MONTH
+8 SET DAY=$PIECE(DATE," ",2)
SET DAY=$PIECE(DAY,",")
+9 IF DAY<1
QUIT 0
+10 IF DAY<10
SET DAY="0"_DAY
+11 SET HOUR=$PIECE(TIME,":")
+12 SET MIN=$PIECE(TIME,":",2)
+13 SET SEC=$PIECE(TIME,":",3)
+14 SET TIME=HOUR_MIN_SEC
+15 SET FMDT=YEAR_MONTH_DAY
+16 IF '$LENGTH(TIME)
QUIT FMDT
+17 QUIT FMDT_"."_TIME
+18 ;
GENERIC(VAL,FROM,DIR,FILE,REF,XREF,SCREEN) ; Return a set of entries from xref in REF
+1 ; from ORWGAPI
+2 ; .VAL=returned list, FROM=text to $O from, DIR=$O direction,
+3 NEW CNT,IEN,NAME,NEXTNAME,NUM,OK,ROOT,ZERO
SET NUM=0
SET CNT=44
KILL VAL
+4 IF FILE=405
QUIT
+5 SET ROOT=""
+6 SET FROM=$$UP^ORWGAPIX(FROM)
+7 IF $EXTRACT(REF,$LENGTH(REF))=","
SET ROOT=$EXTRACT(REF,1,$LENGTH(REF)-1)_")"
+8 IF $EXTRACT(REF,$LENGTH(REF))="("
SET ROOT=$PIECE(REF,"(")
+9 IF '$LENGTH(ROOT)
QUIT
+10 SET REF=REF_""""_XREF_""")"
+11 FOR
IF NUM'<CNT
QUIT
SET FROM=$ORDER(@REF@(FROM),DIR)
IF FROM=""
QUIT
Begin DoDot:1
+12 SET IEN=""
FOR
SET IEN=$ORDER(@REF@(FROM,IEN),DIR)
IF 'IEN
QUIT
Begin DoDot:2
+13 IF FILE=100
IF $ORDER(@REF@(FROM,IEN,""))>0
QUIT
+14 SET ZERO=$GET(@ROOT@(IEN,0))
IF '$LENGTH(ZERO)
QUIT
+15 XECUTE SCREEN
IF '$TEST
QUIT
+16 SET NUM=NUM+1
+17 IF FILE="45DX"!(FILE=9000010.07)!(FILE=9000011)!(FILE="63AP;I")
Begin DoDot:3
+18 SET VAL(NUM)=FILE_U_IEN_U_$$ICD9^ORWGAPIA(IEN)
QUIT
End DoDot:3
QUIT
+19 IF FILE="45OP"
SET VAL(NUM)=FILE_U_IEN_U_$$ICD0^ORWGAPIA(IEN)
QUIT
+20 IF FILE=53.79
SET VAL(NUM)=FILE_U_IEN_U_$$POINAME^ORWGAPIC(IEN)
QUIT
+21 IF FILE="55NVA"
SET VAL(NUM)=FILE_U_IEN_U_$$POINAME^ORWGAPIC(IEN)
QUIT
+22 IF FILE=9000010.18
SET VAL(NUM)=FILE_U_IEN_U_$$ICPT^ORWGAPIA(IEN)
QUIT
+23 IF FILE=130
SET VAL(NUM)=FILE_U_IEN_U_$$ICPT^ORWGAPIA(IEN)
QUIT
+24 SET VAL(NUM)=FILE_U_IEN_U_FROM
End DoDot:2
End DoDot:1
+25 IF FILE=120.5
Begin DoDot:1
+26 SET (NUM,OK)=0
+27 FOR
SET NUM=$ORDER(VAL(NUM))
IF NUM<1
QUIT
Begin DoDot:2
+28 SET NAME=$PIECE(VAL(NUM),U,3)
+29 SET NEXTNAME=$PIECE($GET(VAL(NUM+1)),U,3)
+30 IF "BODY MASS INDEX"]NAME
IF NEXTNAME]"BODY MASS INDEX"
Begin DoDot:3
+31 SET OK=1
+32 SET VAL(NUM+.5)="120.5^99999^BODY MASS INDEX"
End DoDot:3
End DoDot:2
IF OK
QUIT
End DoDot:1
+33 QUIT
+34 ;
MTN(MONTH) ; $$(external month) -> month number
+1 NEW MONTHS,NUM
+2 IF $LENGTH(MONTH)'=3
QUIT 0
+3 SET MONTHS="JAN^FEB^MAR^APR^MAY^JUN^JUL^AUG^SEP^OCT^NOV^DEC"
+4 FOR NUM=1:1:13
IF $PIECE(MONTHS,U,NUM)=MONTH
QUIT
+5 IF NUM=13
QUIT 0
+6 QUIT NUM
+7 ;
OGROUP(OITEM) ; $$(orderable item) -> ien display group^display group - from ORWGAPIR
+1 NEW IEN
+2 SET IEN=+$PIECE($GET(^ORD(101.43,+$GET(OITEM),0)),U,5)
+3 QUIT IEN_U_"order - "_$PIECE($GET(^ORD(100.98,IEN,0)),U)
+4 ;
RETURN(TMP,ITEMS) ; return TMP (0 use local, 1 use ^TMP(ITEMS,$J, where ITEMS is a namespaced string)
+1 ; from ORWGAPI, ORWGAPIP, ORWGAPIX
+2 NEW NMSP
+3 SET NMSP=$GET(ITEMS)
KILL ITEMS
SET ITEMS=""
+4 SET TMP=NMSP?1U1UN1.14UNP
+5 IF TMP
SET ITEMS=NMSP
+6 QUIT
+7 ;
SETUP(DATA,RESULT,TMP,CNT) ; from ORWGAPI1, ORWGAPI2, ORWGAPI3, ORWGAPI4, ORWGAPIP, ORWGAPIR, ORWGAPIX
+1 SET CNT=CNT+1
+2 IF TMP=2
SET ^TMP(DATA,$JOB,$PIECE(RESULT,U,1,2))=RESULT
QUIT
+3 IF TMP
SET ^TMP(DATA,$JOB,CNT)=RESULT
+4 IF 'TMP
SET DATA(CNT)=RESULT
+5 QUIT
+6 ;