source: WorldVistAEHR/trunk/r/ICR_IMMUNOLOGY_CASE_REGISTRY-IMR/IMRLABSV.m@ 1270

Last change on this file since 1270 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 4.0 KB
Line 
1IMRLABSV ; HCIOFO-FAI/ STORE CURRENT LAB VALUES; 06/02/00 04:45
2 ;;2.1;IMMUNOLOGY CASE REGISTRY;**5**;Feb 09, 1998
3START I $G(IMRTSTLR)="" W !!,?13,"** SORRY NO LABORATORY REFERENCE IN PLACE **" Q
4 I '$D(^IMR(158.9,1,3,0)) W !!,?13,"SORRY, HIV COORDINATOR HAS NOT SET UP LAB LINKS" Q
5 D KILL
6 S (IMRTSTI,IMRTSTII)="",ILR=IMRTSTLR
7 S LGN="" F S LGN=$O(^IMR(158.95,"B",LGN)),LIG="" Q:LGN="" S LIG=$O(^IMR(158.95,"B",LGN,LIG)) Q:LIG="" D LOCAL,LOCAL2
8 Q
9LOCAL Q:LGN'="CD4"
10 S IMRCD="" F S IMRCD=$O(^IMR(158.9,1,3,"B",LIG,IMRCD)),IMS="" Q:IMRCD="" F S IMS=$O(^IMR(158.9,1,3,IMRCD,1,"B",IMS)),IMLM="" Q:IMS="" F S IMLM=$O(^IMR(158.9,1,3,IMRCD,1,"B",IMS,IMLM)) Q:IMLM="" D LLT
11 Q
12LOCAL2 Q:LGN'="VIRAL LOAD"
13 S IMRCD="" F S IMRCD=$O(^IMR(158.9,1,3,"B",LIG,IMRCD)),IMS="" Q:IMRCD="" F S IMS=$O(^IMR(158.9,1,3,IMRCD,1,"B",IMS)),IMLM="" Q:IMS="" F S IMLM=$O(^IMR(158.9,1,3,IMRCD,1,"B",IMS,IMLM)) Q:IMLM="" D LLT
14 Q
15LLT S IMLO="" F S IMLO=$O(^IMR(158.9,1,3,IMRCD,1,IMLM,1,"B",IMLO)),TNN="" Q:IMLO="" F S TNN=$O(^IMR(158.9,1,3,IMRCD,1,IMLM,1,"B",IMLO,TNN)) Q:TNN="" D LWK
16 Q
17LWK S IMWK=$P($G(^IMR(158.9,1,3,IMRCD,1,IMLM,1,TNN,0)),U,2),LNM=$P($G(^LAB(60,IMLO,0)),U,1),LLOC=$P($G(^LAB(60,IMLO,0)),U,5)
18 I LLOC'="" S UNN=$P($G(^LAB(60,IMLO,1,0)),U,3),LDAT=$P(LLOC,";",2) S:UNN'="" UNS=$P($G(^LAB(60,IMLO,1,UNN,0)),U,7) D CHEMS Q
19 I LLOC="" D PANEL Q
20 Q
21PANEL F PN=0:0 S PN=$O(^LAB(60,IMLO,2,PN)) Q:PN'>0 S LPN=$P($G(^LAB(60,IMLO,2,PN,0)),U,1),LNM=$P($G(^LAB(60,LPN,0)),U,1),LLOC=$P($G(^LAB(60,LPN,0)),U,5) D PAN2
22 Q
23PAN2 S UNN=$P($G(^LAB(60,LPN,1,0)),U,3)
24 S:UNN'="" UNS=$P($G(^LAB(60,LPN,1,UNN,0)),U,7)
25 S:LLOC'="" LDAT=$P(LLOC,";",2)
26 D CHEMS
27 Q
28CHEMS S LDT="" F S LDT=$O(^LR(ILR,"CH",LDT)),DNAM="" Q:LDT="" F S DNAM=$O(^LR(ILR,"CH",LDT,DNAM)),(LRES,DTRC)="" Q:DNAM="" S LRES=$P($G(^LR(ILR,"CH",LDT,LDAT)),U,1),DTRC=$P($G(^LR(ILR,"CH",LDT,0)),U,1),Y=DTRC D DD^%DT S DTAA=Y D PLBS
29 Q
30PLBS S DTR1=$E(DTAA,1,3),DTR2=$E(DTAA,9,12),DTRD=DTR1_","_DTR2
31 S LDO=$E(LDT,1,7)
32 I LGN="CD4" Q:DNAM'=LDAT D:UNS'["%" CHRG
33 I LGN="CD4" Q:DNAM'=LDAT D:UNS["%" CHPR
34 I LGN="VIRAL LOAD" Q:DNAM'=LDAT D STORE
35 Q
36CHRG ; Update CD4 Actual Levels. Called from IMREDIT
37 Q:(LRES["CANC")!(LRES["canc")
38 Q:(DTRC["CANC")!(DTRC["canc")
39 S LCDD=$P($G(^IMR(158,IMRFN,102)),U,2)
40 S:DTRC>LCDD $P(^IMR(158,IMRFN,102),U,2)=DTRC,$P(^IMR(158,IMRFN,102),U,1)=LRES
41 ;last CD4 value and date ABOVE
42 S PLOW=$P($G(^IMR(158,IMRFN,102)),U,5) ;get lowest CD4 value in File 158 for comparison
43 S:LRES<PLOW $P(^IMR(158,IMRFN,102),U,5)=LRES,$P(^IMR(158,IMRFN,102),U,6)=DTRC
44 D KILL
45 Q
46CHPR ; Update CD4 Percentage. Called from IMREDIT
47 Q:(LRES["CANC")!(LRES["canc")
48 Q:(DTRC["CANC")!(DTRC["canc")
49 S LOWP=$P($G(^IMR(158,IMRFN,112)),U,9)
50 Q:LRES<LOWP
51 S $P(^IMR(158,IMRFN,112),U,9)=LRES,$P(^IMR(158,IMRFN,112),U,10)=DTRC
52 D KILL
53 Q
54STORE ; Store viral load data in 113 nodes
55 Q:(LRES["CANC")!(LRES["canc")
56 Q:(DTRC["CANC")!(DTRC["canc")
57 Q:$G(IMLO)="" S IMRLTEST=IMLO
58 I '$D(^IMR(158,IMRFN,113,"B",IMRLTEST)) D ;add viral test results if that test not in field 113
59 .K DA,DD,DO
60 .S:'$D(^IMR(158,IMRFN,113,0)) DIC("P")=$P(^DD(158,122,0),U,2)
61 .S X=IMRLTEST,DA(1)=IMRFN,DIC="^IMR(158,IMRFN,113,",DIC(0)="L"
62 .D FILE^DICN
63 .K DD,DO
64 .Q:Y'>0
65 .S DA=+Y
66 .S DA(1)=IMRFN,DIE="^IMR(158,IMRFN,113,",DR="1////"_LRES_";2////"_DTRC_";3////"_LRES_";4////"_DTRC
67 .D ^DIE
68 .Q
69 S IMRVLIEN=$O(^IMR(158,IMRFN,113,"B",IMRLTEST,0)) Q:'IMRVLIEN
70 S IMRLNODE=$G(^IMR(158,IMRFN,113,IMRVLIEN,0)) Q:IMRLNODE=""
71 I LRES>$P(IMRLNODE,U,2) S $P(IMRLNODE,U,2)=LRES,$P(IMRLNODE,U,3)=DTRC ;save the highest score and its date/time
72 I DTRC>$P(IMRLNODE,U,5) S $P(IMRLNODE,U,4)=LRES,$P(IMRLNODE,U,5)=DTRC ;save most recent date/time and its value
73 S ^IMR(158,IMRFN,113,IMRVLIEN,0)=IMRLNODE ;update global node
74 D KILL
75 Q
76KILL ; kill variables
77 K CDAR,CDP,D,D(0),D0,DA,D1,DN,HVR,ILR,IMDATE,IMRANS,IMRCD,IMRCD4,IMRCD4D,IMRCD4E,IMRCD4X,IMRCDX,IMRCDXD,IMRDFN,IMREDIT,IMRESULT,IMRLOOP,IMRPN,X,Y
78 K IMRLNODE,IMRLTEST,IMRP103,IMRSTN,IMRTSTI,IMRTSTII,IMRVLIEN,IMRXCAT,IMS,IMWK,LCDD,LDO,LDT,LIG,LLOC,LNM,MDT,PLOW,RC,TNN,UNN,UNS
79 Q
Note: See TracBrowser for help on using the repository browser.