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

APCHS3F.m

Go to the documentation of this file.
APCHS3F ; IHS/CMI/LAB - PART 3A OF APCHS -- SUMMARY PRODUCTION COMPONENTS ;
 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
 ;
MRL ; ******************** MOST RECENT LAB * 9000010.09 *******
 I '$D(^AUPNVBB("AA",APCHSPAT)) G MRLX
 W !?3,"See the Lab Package for More Complete Blood Bank Information than ",!,"contained below."
 X APCHSCKP Q:$D(APCHSQIT)
 X:'APCHSNPG APCHSBRK
 ; <SETUP>
 ; <PROCESS>
 D LBLD,LPRT
 D ANTIBOD
 ; <CLEANUP>
MRLX K APCHSLT,APCHSLR,APCHSLTX,APCHSLRT,APCHSLL,APCHSLW,APCHSNMX,APCHSDFN,APCHSIVD,APCHSLTD,APCHSN,Y
 K ^TMP($J,"APCHS"),^TMP($J,"APCHS1")
 Q
 ; <BUILD>
LBLD K ^TMP($J,"APCHS","LAB"),^TMP($J,"APCHS1")
 S APCHSLRT="" F APCHSQ=0:0 S APCHSLRT=$O(^AUPNVBB("AA",APCHSPAT,APCHSLRT)) Q:APCHSLRT=""  D LDATE
 D REORDER
 Q
REORDER ;reorder by accession, parent and child
 S X=0 F  S X=$O(^TMP($J,"APCHS","LAB",X)) Q:X'=+X  D
 .S D=0 F  S D=$O(^TMP($J,"APCHS","LAB",X,D)) Q:D'=+D  D
 ..S Y=$P(^TMP($J,"APCHS","LAB",X,D),U,3)
 ..;S %=$E($P(^AUPNVBB(Y,0),U,6),1,2) S:%="" %="ZZ"
 ..S %=X
 ..S %1=$S($P($G(^AUPNVBB(Y,12)),U,8)]"":$P(^AUPNVBB(Y,12),U,8),1:Y)
 ..S %2=$S($P($G(^AUPNVBB(Y,12)),U,8)="":0,1:Y)
 ..S ^TMP($J,"APCHS1",%,%1,%2,X)=^TMP($J,"APCHS","LAB",X,D)
 .Q
 K ^TMP($J,"APCHS")
 Q
LDATE S APCHSIVD=$O(^AUPNVBB("AA",APCHSPAT,APCHSLRT,0))
 S APCHSDFN=0 F  S APCHSDFN=$O(^AUPNVBB("AA",APCHSPAT,APCHSLRT,APCHSIVD,APCHSDFN)) Q:APCHSDFN'=+APCHSDFN   D:APCHSIVD&(APCHSIVD'>APCHSDLM) LSET
 Q
LSET ;
 S APCHSN=^AUPNVBB(APCHSDFN,0),APCHSLR=$P(APCHSN,U,4)
 I $P($G(^AUPNVBB(APCHSDFN,11)),U,9)="R",APCHSLR="",$$VALI^XBDIQ1(60,$P(APCHSN,U),999999901) Q  ;do not display tests that are resulted, result is null and flag says don't display
 ;I APCHSLR="",$P($G(^TMP($J,"APCHS","LAB",APCHSLRT)),U,2)]"" Q
 ;S P=$P($G(^AUPNVBB(APCHSDFN,12)),U,8) I P="" S P=APCHSDFN
 ;S C=APCHSDFN I $P($G(^AUPNVBB(APCHSDFN,12)),U,8)="" S C=0
 S ^TMP($J,"APCHS","LAB",APCHSLRT,APCHSDFN)=(-APCHSIVD\1+9999999)_U_APCHSLR_U_APCHSDFN S APCHSLTX=$P(^LAB(60,APCHSLRT,0),U,1)
 Q
 ; <PRINT>
LPRT ;
 W ?34,"COLL DATE",?45,"RESULTS",?60,"ANTIBODY",!
 S APCHSACC="" F  S APCHSACC=$O(^TMP($J,"APCHS1",APCHSACC)) Q:APCHSACC=""!($D(APCHSQIT))  D
 .S APCHSPAR=0 F  S APCHSPAR=$O(^TMP($J,"APCHS1",APCHSACC,APCHSPAR)) Q:APCHSPAR'=+APCHSPAR!($D(APCHSQIT))  D
 ..S APCHCHIL="" F  S APCHCHIL=$O(^TMP($J,"APCHS1",APCHSACC,APCHSPAR,APCHCHIL)) Q:APCHCHIL=""  D
 ...S APCHSLT=$O(^TMP($J,"APCHS1",APCHSACC,APCHSPAR,APCHCHIL,0))
 ...S APCHSDFN=$P(^TMP($J,"APCHS1",APCHSACC,APCHSPAR,APCHCHIL,APCHSLT),U,3)
 ...S Y=$P(^TMP($J,"APCHS1",APCHSACC,APCHSPAR,APCHCHIL,APCHSLT),U,1),APCHSLR=$P(^TMP($J,"APCHS1",APCHSACC,APCHSPAR,APCHCHIL,APCHSLT),U,2) X APCHSCVD S APCHSLTD=Y
 ...D LPRT2
 K APCHCHIL,APCHSPAR,APCHSACC,APCHSLT
 Q
LPRT2 ;
 S APCHSLTX=$S($P($G(^AUPNVBB(APCHSDFN,0)),U,7)]"":$P(^AUPNVBB(APCHSDFN,0),U,7),1:$P(^LAB(60,APCHSLT,0),U))
 X APCHSCKP Q:$D(APCHSQIT)  I APCHSNPG W ?34,"COLL DATE",?45,"RESULTS",?60,"ANTIBODY",!
 W:APCHCHIL "  " W:'APCHCHIL ! W APCHSLTX,$S(APCHCHIL:"",1:":"),?35,APCHSLTD,?45,APCHSLR
 W ?60,$$VAL^XBDIQ1(9000010.31,APCHSDFN,.05)
 ;W ?78," ",$P($G(^AUPNVBB(APCHSDFN,11)),U,9)
 W !
 Q
 ;
ANTIBOD ; - antibody display
 ;gather up all v blood bank entries with an antibody and display
 Q:'$D(^AUPNVBB("AC",APCHSPAT))
 K ^TMP($J,"APCHS")
 S X=0 F  S X=$O(^AUPNVBB("AC",APCHSPAT,X)) Q:X'=+X  D
 .Q:'$D(^AUPNVBB(X,0))
 .S A=$P(^AUPNVBB(X,0),U,5) Q:A=""
 .S Y="",V=$P(^AUPNVBB(X,0),U,3) I V,$D(^AUPNVSIT(V,0)) S Y=$P($P(^AUPNVSIT(V,0),U),".")=$P
 .S D=$P($P($G(^AUPNVBB(X,12)),U),".")
 .S D=$S(D]"":D,1:Y),D=9999999-D
 .S ^TMP($J,"APCHS",A,D,X)=""
 .Q
PRTANTI ;
 G:'$D(^TMP($J,"APCHS")) ANTIBODX
 X APCHSCKP G:$D(APCHSQIT) ANTIBODX
 W !!?2,"ANTIBODIES",!
 S APCHSA=0 F  S APCHSA=$O(^TMP($J,"APCHS",APCHSA)) Q:APCHSA'=+APCHSA!($D(APCHSQIT))  D
 .S APCHSD=$O(^TMP($J,"APCHS",APCHSA,0))
 .X APCHSCKP Q:$D(APCHSQIT)  I APCHSNPG W !!?2,"ANTIBODIES",!
 .S Y=9999999-APCHSD X APCHSCVD
 .W ?3,Y,?13,$P($G(^LAB(61.3,APCHSA,0)),U),!
ANTIBODX ;
 K V,X,Y,D,APCHSX,APCHSD
 K ^TMP($J,"APCHS")
 Q
 ;
 ;