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

VENPCC1N.m

Go to the documentation of this file.
VENPCC1N ; IHS/OIT/GIS - DISPLAY LAB TEST RESULTS ;
 ;;2.6;PCC+;**1,3**;APR 03, 2012;Build 24
 ;
LAB(DFN,DEFEF) ; EP-GET LAB INFO
 N STG,TMP,NAME,POC,GBL,LNAME,LIEN,SFIEN,%,AFLAG,ORD,MAX,POC,POCFLAG,TOT,MAXL
 I '$D(^DPT(+$G(DFN),0)) Q  ; MUST BE A VALID PATIENT
 I '$D(^VEN(7.41,+$G(DEFEF),0)) Q  ; MUST BE A VALID TEMPLATE
 ; 
INIT ; EP - INITIALIZE VARIABLES
 S AFLAG=$P($G(^VEN(7.41,DEFEF,5)),U,23) ; DIPLAY SORT: 1=ALPHABETICAL,0=ORDINAL
 S TMP=$NA(^TMP("VEN PRNT",$J)) ; MAIL MERGE GLOBAL
 S GBL=$NA(^TMP("VEN LAB ORDER",$J)) K @GBL ; ORDER GLOBAL
 S MAXL=58
 S %=$P($G(^VEN(7.41,DEFEF,1)),U,7) I % S MAXL=% ; MAX # LAB RESULTS ALLOWED ON THE FORM
 ; 
ORD ; EP - PUT TEST NAMES IN ORDER
 S SFIEN=0
 F  S SFIEN=$O(^VEN(7.41,DEFEF,7,SFIEN)) Q:'SFIEN  D  ; LOOP THRU LAB TESTS
 . S POC=+$P(^VEN(7.41,DEFEF,7,SFIEN,0),U,6) ; POINT OF CARE TEST
 . S LNAME=$P(^VEN(7.41,DEFEF,7,SFIEN,0),U,3) ; GET DISPLAY NAME IF IT EXISTS
 . I '$L(LNAME) D  ; IF NOT DISPLAY NAME, USE DEFAULT NAME FROM LAB TEST FILE
 .. S LIEN=+^VEN(7.41,DEFEF,7,SFIEN,0) I 'LIEN Q
 .. S LNAME=$P($G(^LAB(60,LIEN,0)),U) ; PATCHED BY GIS/OIT 10/17/05 ; PCC+ 2.5 PATCH 1
 .. Q
 . I '$L(LNAME) Q
 . I AFLAG,POC S @GBL@("POC",LNAME)=SFIEN_U_LNAME Q  ; POC/ALPHABETICAL ORDER
 . I AFLAG S @GBL@(LNAME)=SFIEN_U_LNAME Q  ; ALPHABETICAL ORDER
 . S ORD=$P(^VEN(7.41,DEFEF,7,SFIEN,0),U,4)
 . I 'ORD S ORD=SFIEN+999999 ; THIS FORCES ITEMS WITH UNSPECIFIED ORDER TO THE END OF THE LIST - IN IEN ORDER
 . I POC S @GBL@("POC",ORD)=SFIEN_U_LNAME Q  ; POC/ORDINAL ORDER
 . S @GBL@(ORD)=SFIEN_U_LNAME ; ORDINAL ORDER
 . Q
LABX ; EP - GET LAB RESULTS
 S TOT=0
 S ORD="" F  S ORD=$O(@GBL@(ORD)) Q:ORD=""  I ORD'="POC" D PASS(@GBL@(ORD),.TOT,MAXL) I TOT=60 Q  ; 1ST PASS - NON POC TESTS
 I '$D(@GBL@("POC")) Q  ; NO POINT OF CARE TESTS
 I TOT>MAXL Q  ; NO MORE ROOM
 S TOT=TOT+1
 S @TMP@(1,"lt"_TOT)="***  POINT OF CARE TESTS  ***" ; ADD DIVIDER LINE
 S ORD="" F  S ORD=$O(@GBL@("POC",ORD)) Q:ORD=""  D PASS(@GBL@("POC",ORD),.TOT,MAXL) I TOT>MAXL Q  ; 2ND PASS -  POC TESTS
 K @GBL
 Q
 ; 
PASS(LAB,TOT,MAXL) ; EP-FOR THIS PASS, GET LAB TESTS IN ORDER
 N SFIEN,LNAME,STG,LIEN,CPT,DISPLAY,DATA,EP,%
 S SFIEN=+LAB I 'SFIEN Q  ; GET SUBFILE IEN FOR THIS LAB TEST
 S LNAME=$P(LAB,U,2) I '$L(LNAME) Q  ; GET NAME FOR THIS LAB TEST
 S STG=$G(^VEN(7.41,DEFEF,7,SFIEN,0)) I '$L(STG) Q  ; GET DATA STRING FOR THIS LAB TEST
 S LIEN=+STG I 'LIEN Q
 S CPT=$P(STG,U,2) I '$L(CPT) S CPT=$$CPT(LIEN) ; IF CPT NOT SPECIFIED, TRY CPT LOOKUP
 I $P(STG,U,7) D  Q  ; DONT PRINT RESULT (USED FOR "ORDER ENTRY" ONLY)
 . S TOT=TOT+1
 . S @TMP@("lt"_TOT)=LNAME
 . S @TMP@("lt"_TOT_"a")=CPT
 . Q
 S EP=$G(^VEN(7.41,DEFEF,7,SFIEN,1))
 I '$L(EP) D LAB1(DFN,STG,LNAME,CPT,.TOT,MAXL) Q  ; GET RESULTS FROM V LAB
 D LAB2(DFN,STG,EP,LNAME,CPT,.TOT) ; SPECIAL CODE FOR OBTAINING RESULTS
 ; PATCHED BY GIS/OIT 08/17/06 ; PCC+ 2.5 PATCH 6
 Q
 ; 
LAB1(DFN,DATA,LNAME,CPT,TOT,MAXL) ; EP-RETRUN TEST NAME, CPT CODE AND RESULTS
 ; PATCHED BY GIS/OIT 10/15/05 ; PCC+ 2.5 PATCH 1
 N IDT,DATE,RES,NAME,VLIEN,%,MAX,MAXM,MAXIDT,STOP,RES,VAL,CNT
 I $G(DATA)="" Q ""
 S MAX=$P(DATA,U,8) I 'MAX S MAX=1
 S MAXM=$P(DATA,U,9) I 'MAXM S MAXM=12
 S MAXIDT=$$MAXIDT(MAXM)
 S STOP=0,IDT=0,CNT=0 ; PATCHED BY GIS/OIT 01/10/06 ; PCC+ 2.5 PATCH 2
 F  S IDT=$O(^AUPNVLAB("AA",DFN,LIEN,IDT)) Q:'IDT  D  I STOP Q  ; MAIN LAB LOOP
 . I IDT>MAXIDT S STOP=1 Q  ; RESULT MUST BE WITHIN SPECIFIED DATE RANGE
 . S VLIEN=999999999
 . F  S VLIEN=$O(^AUPNVLAB("AA",DFN,LIEN,IDT,VLIEN),-1) Q:'VLIEN  D  I STOP Q  ; NO RESULT
 .. S %=9999999-(IDT\1),DATE=$$FMTE^XLFDT(%,"2D")
 .. S VAL=$P($G(^AUPNVLAB(VLIEN,0)),U,4) I '$L(VAL) Q
 .. S RES=LNAME_": "_VAL_" ("_DATE_")"
 .. S TOT=TOT+1 I TOT=MAXL S STOP=1 ; = MAX # OF RESULTS FOR ALL TESTS
 .. S CNT=CNT+1 I CNT=MAX S STOP=1 ; = MAX # OF RESULTS FOR THIS TEST
 .. S @TMP@(1,"lt"_TOT)=RES ; SAVE RESULT
 .. S @TMP@(1,"lt"_TOT_"a")=$G(CPT) ; SAVE CPT
 .. Q
 . Q
 Q
 ;
MAXIDT(MAXM) ; EP - GET LIMITING IDT
 N MAXIDT,DATE,IDT,%
 I MAXM=12 Q (9999999-(DT-10000))
 S %=(30.5*MAXM)\1 S %=-%
 S DATE=$$FMADD^XLFDT(DT,%,0,0,0)
 S MAXIDT=9999999-DATE
 Q MAXIDT
 ; 
LAB2(DFN,DATA,EP,LNAME,CPT,TOT) ; EP-SPECIAL DISPLAY CODE
 ; SPECIAL TESTS WILL ONLY WORK IF TEST NAMES APPEAR IN THE LAB(60) FILE
 N CODE,TXT,%
 I '$L($G(EP)) Q  ; EP MUST EXIST
 X "I $L($T("_EP_"))" E  Q  ; EP MUST BE VALID
 S CODE="D "_EP_"(DFN,DATA,LNAME,CPT,.TOT)"
 X CODE
 Q
 ; 
CPT(LIEN) ; EP-GIVEN A LAB IEN RETURN THE CPT CODE
 N CPTIEN,CPT,%,CIEN
 I '$D(^LAB(60,+$G(LIEN),0)) Q "" ; INVALID/MISSING LAB TEST
 I '$D(^BLRCPT("C")) Q "" ; IHS LAB CPT CODE FILE MISSING
 S CPTIEN=$O(^BLRCPT("C",LIEN,0)) I 'CPTIEN Q "" ; PANEL/TEST INDEX ("C")
 I $P($G(^BLRCPT(CPTIEN,1)),U,2) Q "" ; CODE FOR THIS TEST IS INACTIVE
 S %=$O(^BLRCPT(CPTIEN,11,0)) I '% Q "" ; GET FIRST MULTIPLE IEN
 S CIEN=+$P(^BLRCPT(CPTIEN,11,%,0),U) I 'CIEN Q "" ; GET FIRST CPT CODE IEN
 S CPT=$P($G(^ICPT(CIEN,0)),U) ; LOOKUP THE CPT CODE IN THE ICPT FILE
 Q CPT ; RETURN THE CPT CODE
 ;
COPY ; EP-COPY LAB TESTS FROM ONE TEMPLATE TO ANOTHER
 N DIC,X,Y,FROM,TO,TOT
 W !,?5,"*****  COPY LAB TEST LIST FROM ONE TEMPLATE TO ANOTHER  *****",!!
 S DIC("A")="Template that is the source of lab tests: "
 S DIC(0)="AEQM",DIC="^VEN(7.41,"
 D ^DIC I Y=-1 G CX
 S FROM=+Y
 S TOT=+$P($G(^VEN(7.41,+Y,7,0)),U,3)
 W !,"There are ",TOT," tests associated with this template..."
 I 'TOT W !,"Request terminated..." G CX
 S DIC("A")="Copy these lab test to which template: "
 D ^DIC I Y=-1 G CX
 S TO=+Y,TOT=+$P($G(^VEN(7.41,+Y,7,0)),U,3)
 I TOT W !,"Template ",$P(Y,U,2)," already has ",TOT," lab tests.",!,"These will be overwritten!"
 W !!,"Sure you want to copy ",TOT," lab tests to ",$P(Y,U,2)
 S %=1 D YN^DICN I %'=1 G CX
 K ^VEN(7.41,TO,7) M ^VEN(7.41,TO,7)=^VEN(7.41,FROM,7)
 W !,"All lab tests have been successfully copied!"
CX D ^XBFMK
 Q
 ;
DEL ; EP-DELETE ALL LAB TESTS FROM A TEMPLATE
 N DIC,X,Y,TOT
 W !,?10,"*****  REMOVE ALL LAB TESTS FROM A TEMPLATE  *****",!!
 S DIC("A")="Remove all tests from which template: "
 S DIC(0)="AEQM",DIC="^VEN(7.41,"
 D ^DIC I Y=-1 G DX
 S TOT=+$P($G(^VEN(7.41,+Y,7,0)),U,3)
 W !,"There are ",TOT," tests associated with this template..."
 I 'TOT W !,"Request terminated..." G DX
 W !!,"Sure you want to remove all lab tests from ",$P(Y,U,2)
 S %=1 D YN^DICN I %'=1 G DX
 K ^VEN(7.41,+Y,7)
 W !,"All lab tests have been successfully removed from the template!"
DX D ^XBFMK
 Q
 ;