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

GMRAOR0.m

Go to the documentation of this file.
GMRAOR0 ;HIRMFO/WAA,FPT - OERR HL7 UTILITY;10/29/2015  08:25
 ;;4.0;Adverse Reaction Tracking;**4,46**;Mar 29, 1996;Build 62
DUPCHK(DFN,GMRALL) ;CHECK FOR DUPS
 ;Input variable:
 ;         DFN = Patient DFN
 ;      GMRALL = Free text of allergy
 ;
 ;return variable:
 ;     GMRAFLG = (0,1,-1)
 ;               0   Patient has no matching reactions on file
 ;               1   Patient has a matching reaction.
 ;              -1   Patient has a matching reaction but is E/E
 ;
 ;********************************************************************
 N GMRAFLG,GMRAPA
 S GMRAFLG=0,GMRAPA=0
 ;Loop through all the patient's reaction and look for matches
 F  S GMRAPA=$O(^GMR(120.8,"B",DFN,GMRAPA)) Q:GMRAPA<1  D  Q:GMRAFLG=1
 .Q:GMRALL'=$P($G(^GMR(120.8,GMRAPA,0)),U,2)  ;Not a match
 .I +$G(^GMR(120.8,GMRAPA,"ER")) S GMRAFLG=-1 Q  ;E/E
 .S GMRAFLG=1 ;Matching allergy.
 .Q
 Q GMRAFLG
 ;********************************************************************
 ;CONTINUATION FROM GMRAOR
REMOTE(DFN) ;OBTAIN DATA STORED REMOTELY
 ;PARAMTER: DFN => IEN IN THE PATIENT (#2) FILE
 Q:$$HDRDATA^GMRAHDR()<1
 N J
 S J=0 F  S J=$O(^XTMP("ORRDI","ART",DFN,J)) Q:'+J  D
 .N SEVERE,SYMPTOM,AGENT,CLASSES,INGS,DATE,IN,DC,GL,IEN,DD,INDEX,DATA,REACT,IN,OBSHIS
 .N VUID,FILE,GMRARAY,DC,GMRAING,GMRADC,K,INGLST,I,PRIM
 .S GL=$NA(^XTMP("ORRDI","ART",DFN,J)),DATE=""
 .I +$G(@GL@("ORIGINATION DATE/TIME",0))'=0 S DATE=$$HL7TFM^XLFDT(@GL@("ORIGINATION DATE/TIME",0))
 .S DATA=$P($G(@GL@("FACILITY",0)),U)_U_"R"_U_DATE
 .S REACT=$G(@GL@("GMRALLERGY",0))
 .I REACT'="" D
 ..S VUID=$P(REACT,U,1)
 ..S FILE=$P($P(REACT,U,3),"99VA",2)
 ..D GETIREF^XTID(FILE,,VUID,"GMRARAY")
 ..D FILE^DID(FILE,,"GLOBAL NAME","DD")
 ..S IEN=0 F  S IEN=$O(GMRARAY(FILE,.01,IEN)) Q:+$G(IEN)=0  D
 ...S AGENT=+IEN_";"_$P(DD("GLOBAL NAME"),U,2)
 ..K VUID,FILE,GMRARAY,IEN
 .I $D(@GL@("SEVERITY"))>9 D
 ..S SEVERE="|"_$P(@GL@("SEVERITY",0),U)
 .I $D(@GL@("SIGNS/SYMPTOMS"))>9 D
 ..S INDEX=0 F  S INDEX=$O(@GL@("SIGNS/SYMPTOMS",INDEX)) Q:+$G(INDEX)=0  D
 ...I $P($G(@GL@("SIGNS/SYMPTOMS",INDEX)),U,3)="L" D
 ....S SYMPTOM=$S($G(SYMPTOM)'="":SYMPTOM_"~",1:"")_GMRAOTH_"-"_$P($G(@GL@("SIGNS/SYMPTOMS",INDEX)),U,2)
 ...I $P($G(@GL@("SIGNS/SYMPTOMS",INDEX)),U,3)'="L" D
 ....S VUID=$P(@GL@("SIGNS/SYMPTOMS",INDEX),U,1)
 ....S FILE=$P($P(@GL@("SIGNS/SYMPTOMS",INDEX),U,3),"99VA",2)
 ....D GETIREF^XTID(FILE,,VUID,"GMRARAY")
 ....S IEN=0 F  S IEN=$O(GMRARAY(FILE,.01,IEN)) Q:+$G(IEN)=0  S SYMPTOM=$S($G(SYMPTOM)'="":SYMPTOM_"~",1:"")_+IEN
 ....K VUID,FILE,GMRARAY,IEN
 .I $D(@GL@("OBS/HISTORICAL"))>9 D
 ..D GETIREF^XTID(120.8,,$P($G(@GL@("OBS/HISTORICAL",0)),U,1),"GMRARAY")
 ..S OBSHIS=$O(GMRARAY(120.8,6,""))
 ..K GMRARAY
 .S DATA=DATA_U_$G(SEVERE)_U_$G(SYMPTOM)_U_$G(@GL@("REACTANT",0))_U_$G(AGENT)_U_$G(OBSHIS)
 .I $D(^XTMP("ORRDI","ART",DFN,J,"DRUG INGREDIENTS")) D
 ..S IN=0 F  S IN=$O(^XTMP("ORRDI","ART",DFN,J,"DRUG INGREDIENTS",IN)) Q:'+IN  D
 ...S VUID=$P(@GL@("DRUG INGREDIENTS",IN),U),FILE=$P(^(IN),U,3)
 ...S FILE=$P(FILE,"99VA",2)
 ...D GETIREF^XTID(FILE,,VUID,"GMRARAY")
 ...S IEN=0 F  S IEN=$O(GMRARAY(FILE,.01,IEN)) Q:'+IEN  D
 ....;*BD
 ....S ^TMP("GMRAOC",$J,"API",+IEN)=$$SETNODE^GMRAOR1($G(^TMP("GMRAOC",$J,"API",+IEN)),"REMOTE SITE(S)")
 ....;*ED
 ....S:'$D(INGS(+IEN)) INGS(+IEN)=""
 ...K VUID,FILE,GMRARAY,IEN
 .I $D(@GL@("DRUG CLASSES")) D
 ..S DC=0 F  S DC=$O(@GL@("DRUG CLASSES",DC)) Q:'+DC  D
 ...;*BD
 ...N DCLASS
 ...S DCLASS=$P(@GL@("DRUG CLASSES",DC),U,4)
 ...S ^TMP("GMRAOC",$J,"APC",DCLASS)=$$SETNODE^GMRAOR1($G(^TMP("GMRAOC",$J,"APC",DCLASS)),"REMOTE SITE(S)")
 ...;*ED
 ...S VUID=$P(@GL@("DRUG CLASSES",DC),U,1),FILE=$P($P(^(DC),U,3),"99VA",2)
 ...D GETIREF^XTID(FILE,,VUID,"GMRARAY")
 ...S IEN=0 F  S IEN=$O(GMRARAY(FILE,.01,IEN)) Q:'+IEN  D
 ....S:'$D(CLASSES(+IEN)) CLASSES(+IEN)=$P(@GL@("DRUG CLASSES",DC),U,4)
 ...K GMRARAY
 .D FIND(REACT,.GMRAING,.GMRADC) I $D(GMRAING)!($D(GMRADC)) D
 ..S K=0 F  S K=$O(GMRAING(K)) Q:'+K  D
 ...;*BD
 ...S ^TMP("GMRAOC",$J,"API",K)=$$SETNODE^GMRAOR1($G(^TMP("GMRAOC",$J,"API",K)),"REMOTE SITE(S)")
 ...;*ED
 ...S:'$D(INGS(K)) INGS(K)=""
 ..S K="" F  S K=$O(GMRADC(K)) Q:K=""  D
 ...;*BD
 ...S ^TMP("GMRAOC",$J,"APC",GMRADC(K))=$$SETNODE^GMRAOR1($G(^TMP("GMRAOC",$J,"APC",GMRADC(K))),"REMOTE SITE(S)")
 ...;*ED
 ...S:'$D(CLASSES(K)) CLASSES(K)=GMRADC(K)
 .S $P(DATA,U,9)="V"
 .S IN="" F  S IN=$O(INGS(IN)) Q:IN=""  S ^TMP("GMRAOC",$J,"API",IN,"R"_J)=$G(DATA)
 .S DC="" F  S DC=$O(CLASSES(DC)) Q:DC=""  S ^TMP("GMRAOC",$J,"APC",CLASSES(DC),"R"_J)=$G(DATA)
 I $D(^TMP("GMRAOC",$J,"API")) D
 .N I,INGLST
 .S I=0 F  S I=$O(^TMP("GMRAOC",$J,"API",I)) Q:'I  D
 ..N PRIM
 ..S PRIM=$$PRIMARY(I)
 ..I PRIM M INGLST(PRIM)=^TMP("GMRAOC",$J,"API",I) K ^TMP("GMRAOC",$J,"API",I)
 .S I=0 F  S I=$O(INGLST(I)) Q:'I  M ^TMP("GMRAOC",$J,"API",I)=INGLST(I)
 Q
FIND(REACT,ING,DC) ;DETERMINE DRUG INGREDIENTS AND CLASSES FOR REACTANT USING LOCAL DATA
 ;PARAMETERS: REACT => REACTANT TO RETURN DRUG INGREDIENTS AND CLASSES FOR
 ;                     FORMAT: VUID^NAME^FILE, WHERE VUID IS UNIQUE ID FOR REACTANT,
 ;                             NAME IS THE NAME OF THE REACTANT, AND FILE IS THE FILE
 ;                             CONTAINING THE REACTANT, IN THE FORMAT 99VA#
 ;                             EX.: 4637287^EGGS^99VA120.82
 ;            ING => ARRAY REFERENCE TO RETURN DRUG INGREDIENTS IN
 ;            DC => ARRAY REFERENCE TO RETRUN DRUG CLASSES IN
 Q:$G(REACT)=""
 N VUID,FILE,PSNDA,GMRAIEN,LIST,GMRAI,GMRALIST,GMRARAY,J,SUB
 S VUID=$P(REACT,U)
 S FILE=$P(REACT,U,3)
 S FILE=$P(FILE,"99VA",2)
 D GETIREF^XTID(,,VUID,"GMRARAY")
 S FILE="" F  S FILE=$O(GMRARAY(FILE)) Q:FILE=""  D
 .S GMRAIEN=0 F  S GMRAIEN=$O(GMRARAY(FILE,.01,GMRAIEN)) Q:'+GMRAIEN  D
 ..I FILE=50.6 D
 ...K ^TMP("PSN",$J) S PSNDA=+GMRAIEN D ^PSNNGR
 ...S GMRAI=0 F  S GMRAI=$O(^TMP("PSN",$J,GMRAI)) Q:GMRAI<1  S ING(GMRAI)=""
 ...K ^TMP("PSN",$J),GMRARAY
 ...S PSNDA=+GMRAIEN,GMRALIST=$$CLIST^PSNAPIS(PSNDA,.GMRALIST) Q:'$G(GMRALIST)
 ...S GMRALIST=0 F  S GMRALIST=$O(GMRALIST(GMRALIST)) Q:'GMRALIST  S DC(GMRALIST)=$P(GMRALIST(GMRALIST),U,2)
 ..I FILE=120.82 D
 ...S SUB=0 F  S SUB=$O(^GMRD(120.82,+GMRAIEN,"ING",SUB)) Q:'+SUB  S ING(+$P($G(^GMRD(120.82,+GMRAIEN,"ING",SUB,0)),U))=""
 ...S SUB=0 F  S SUB=$O(^GMRD(120.82,+GMRAIEN,"CLASS",SUB)) Q:'+SUB  S DC(+$P($G(^GMRD(120.82,+GMRAIEN,"CLASS",SUB,0)),U))=$P($$CLASS2^PSNAPIS(+$P($G(^GMRD(120.82,+GMRAIEN,"CLASS",SUB,0)),U)),U)
 ..I FILE=50.605 D
 ...S DC(+GMRAIEN)=$P($$CLASS2^PSNAPIS(+GMRAIEN),U)
 ..I FILE=50.416 D
 ...S ING(+GMRAIEN)=""
 Q
PRIMARY(INGIEN) ;DETERMINE IF AN INGREDIENT IS A PRIMARY INGREDIENT
 ;PARAMTER: INGIEN => IEN IN THE DRUG INGREDIENTS FILE (#50.416)
 ;RETURN: 0 => INGIEN IS PRIMARY
 ;        # => IEN IN THE DRUG INGREDIENTS FILE OF INGIEN'S PRIMARY INGREDIENT
 N RETURN
 K ^TMP($J,"GMRALIST")
 D ZERO^PSN50P41(INGIEN,,,"GMRALIST")
 S RETURN=+$G(^TMP($J,"GMRALIST",INGIEN,2))
 K ^TMP($J,"GMRALIST")
 Q RETURN