ORCDFHO ;SLC/MKB-Utility functions for Outpt FH dialogs ;8/27/03 15:28 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**215**;Dec 17, 1997 ; EN ; -- entry action I $$INPT^ORCD W $C(7),!!,"This patient is not an outpatient!" S ORQUIT=1 H 2 Q I '$L($T(EN2^FHWOR8))!'$L($T(DIETLST^FHOMAPI)) W $C(7),!!,"Dietetics v5.5 must be installed to place outpatient diet orders!" S ORQUIT=1 H 2 Q N X S X=$S($G(OREVENT):$$LOC^OREVNTX(OREVENT),1:$G(ORL)) Q:X<1 D EN1^FHWOR8(X,.ORPARAM) S ORCAT="O" I $G(ORPARAM(3))'["B" S ORPARAM(3)=$G(ORPARAM(3))_"B" ;bagged meal I $G(OREWRITE) D ;remove addl diets . N I,P1,P2 S P1=$$PTR("ADDL DIETS"),P2=$$PTR("MEAL DATE") . S I=0 F S I=$O(ORDIALOG(P1,I)) Q:I<1 K ORDIALOG(P1,I),ORDIALOG(P2,I) Q ; EX ; -- exit action K ORPARAM,ORNPO,ORTRAIL,ORDAY,ORDT,ORCAT Q ; PTR(X) ; -- Returns ptr value of prompt OR GTX X in Dialog file Q +$O(^ORD(101.41,"AB",$E("OR GTX "_X,1,63),0)) ; OPDIETS ; -- Get list of diets ok for outpatients Q:$G(ORDIALOG(PROMPT,"LIST")) N FHDIET,I,X,Y,CNT D DIETLST^FHOMAPI S CNT=0 S I=0 F S I=$O(FHDIET(I)) Q:I<1 D . S Y=FHDIET(I),X=+Y,Y=$P(Y,U,2) . S X=+$O(^ORD(101.43,"ID",X_";99FHD",0)) . I X S CNT=CNT+1,ORDIALOG(PROMPT,"LIST",CNT)=X_U_Y,ORDIALOG(PROMPT,"LIST","B",Y)=X S:CNT ORDIALOG(PROMPT,"LIST")=CNT_"^1" Q ; ONETIME() ; -- Condition for SCHEDULE N X,Y S Y=$$FTDCOMP^ORCD("END DATE","START DATE",">") S X=$G(ORDIALOG(PROMPT,INST)) S:'Y ORDIALOG(PROMPT,INST)="ONCE" I Y,X="ONCE" K ORDIALOG(PROMPT,INST) Q 'Y ; TIMES ; -- get existing outpatient meal times Q:$G(ORDIALOG(PROMPT,"LIST")) D EN2^FHWOR8(+$G(ORVP),"",.ORDT) N I,CNT,X,Y,M S (I,CNT)=0 F S I=$O(ORDT(I)) Q:I<1 D . S X=ORDT(I),Y=$$FMTE^XLFDT(+X),M=$P(X,U,2) . S Y=Y_" "_$S(M="B":"Breakfast",M="N":"Noon",M="E":"Evening",1:"") . S X=$TR(X,"^",";"),CNT=CNT+1 . S ORDIALOG(PROMPT,"LIST",I)=X_U_Y,ORDIALOG(PROMPT,"LIST","B",Y)=X S:CNT ORDIALOG(PROMPT,"LIST")=CNT_"^1" Q ; ENDT ; -- setup START ;S $P(ORDIALOG(PROMPT,0),":",3)="ETX" ;allow time D TIMES I FIRST,$G(ORDIALOG(PROMPT,"LIST")) D LIST^ORCD Q ; EXDT(X) ; -- populate E/L T values from START Q:X'[";" N DATE,MEAL S DATE=+X,MEAL=$P(X,";",2) S ORDIALOG(PROMPT,INST)=DATE,ORDIALOG($$PTR("STOP DATE"),1)=DATE S ORDIALOG($$PTR("MEAL"),1)=MEAL Q ; MEALTIME(IFN) ; -- gets meal time for order IFN [from STARTDT^ORCSAVE2] N ORPARAM,ORLOC,X,Y S IFN=+$G(IFN) S ORLOC=$S($G(ORL):ORL,1:$P($G(^OR(100,IFN,0)),U,10)) D EN1^FHWOR8(ORLOC,.ORPARAM) S X=$$VALUE^ORCSAVE2(IFN,"MEAL") S:'$D(ORPARAM(2)) ORPARAM(2)="^^^^^^6:00A^12:00P^6:00P" S Y=$S(X="B":$P(ORPARAM(2),U,7),X="N":$P(ORPARAM(2),U,8),X="E":$P(ORPARAM(2),U,9),1:"") Q Y ; CKMEAL(Y,DAY,MEAL,LOC) ; -- Returns Y if valid mealtime or not ; Y = 0^msg if invalid ; 1 if valid ; 2 if valid, but latetray will be needed ; RPC = ORCDFHO CKMEAL ; N TIMES,NOW,BEGIN,LATE S Y=1 Q:$G(ORTYPE)="Z" S DAY=$$FMDATE($G(DAY)) I DAY<0 S Y="0^Invalid date." Q Q:DAY>DT I DAY