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

ORQQAL.m

Go to the documentation of this file.
  1. ORQQAL ;SLC/CLA,JFR - FUNCTIONS THAT RETURN PATIENT ADVERSE REACTION DATA ;Oct 14, 2020@10:37:30
  1. ;;3.0;ORDER ENTRY/RESULTS REPORTING;**9,85,162,190,216,232,243,269,377,539**;Dec 17, 1997;Build 41
  1. LIST(ORAY,ORPT) ; RETURN PATIENT'S ALLERGY/ADVERSE REACTION INFO:
  1. ; null:no allergy assessment, 0:no known allergies, 1:pt has allergies
  1. ; if 1 also get: allergen/reactant^reaction/symptom^severity^allergy ien
  1. N I,J,K,GMRARXN,GMRA
  1. S I=1,J=0,K=0
  1. D EN1^GMRAOR1(ORPT,"GMRARXN")
  1. I $G(GMRARXN)="" S ORAY(I)="^No Allergy Assessment"
  1. I $G(GMRARXN)=0 S ORAY(I)="^No Known Allergies"
  1. I $G(GMRARXN)=1 F S J=$O(GMRARXN(J)) Q:J="" S ORAY(I)=$P(GMRARXN(J),"^",3)_"^"_$P(GMRARXN(J),"^")_"^"_$P(GMRARXN(J),"^",2) D SIGNS S I=I+1
  1. S:'$D(ORAY(1)) ORAY(1)="^No allergies found."
  1. Q
  1. SIGNS S K=0,N=0 F S K=$O(GMRARXN(J,"S",K)) Q:K'>0 D
  1. .I N=0 S ORAY(I)=ORAY(I)_"^"_$P(GMRARXN(J,"S",K),";")
  1. .E S ORAY(I)=ORAY(I)_"; "_$P(GMRARXN(J,"S",K),";")
  1. .S N=N+1
  1. Q
  1. LRPT(ORAY,ORPT) ; RETURN PT'S ALLERGY/ADVERSE REACTION INFO IN REPORT FORMAT:
  1. ; null:no allergy assessment, 0:no known allergies, 1:pt has allergies
  1. ; if 1 also get: allergen/reactant^reaction/symptom^severity^allergy ien
  1. N I,J,K,SEVER,CR,GMRAIDT ;216
  1. S CR=$CHAR(13)
  1. S I=1,J=0,K=0,SEVER="",GMRAIDT=1 ;216
  1. D EN1^GMRAOR1(ORPT,"GMRARXN")
  1. I $G(GMRARXN)="" S ORAY(I)="No Allergy Assessment"
  1. I $G(GMRARXN)=0 S ORAY(I)="No Known Allergies"
  1. I $G(GMRARXN)=1 F S J=$O(GMRARXN(J)) Q:J="" D
  1. .S SEVER=$P(GMRARXN(J),U,2)
  1. .S ORAY(I)=$P(GMRARXN(J),U)_" "_$S($L($G(SEVER)):"[Severity: "_SEVER_"]",1:""),I=I+1
  1. .S K=0,N=0 F S K=$O(GMRARXN(J,"S",K)) Q:K'>0 D
  1. ..I N=0 S ORAY(I)=" Signs/symptoms: "_$P(GMRARXN(J,"S",K),";")
  1. ..E S ORAY(I)=" "_$P(GMRARXN(J,"S",K),";")
  1. ..I $P(GMRARXN(J,"S",K),";",2) S ORAY(I)=ORAY(I)_" ("_$$FMTE^XLFDT($P(GMRARXN(J,"S",K),";",2),2)_")" ;216
  1. ..S N=N+1,I=I+1
  1. .S ORAY(I)=" ",I=I+1
  1. S:'$D(ORAY(1)) ORAY(1)="No allergies found."
  1. K GMRARXN
  1. Q
  1. DETAIL(ORAY,DFN,ALLR,ID) ; RETURN DETAILED ALLERGY INFO FOR SPECIFIED ALLERGIC REACTION:
  1. D EN2^GMRAOR2(ALLR,"GMRACT")
  1. N CR,OX,OH S CR=$CHAR(13),I=1
  1. S ORAY(I)=" Causative agent: "_$P(GMRACT,U),I=I+1
  1. S ORAY(I)=" Nature of Reaction: "_$S($P(GMRACT,U,6)="ALLERGY":"Allergy",$P(GMRACT,U,6)="PHARMACOLOGIC":"Adverse Reaction",$P(GMRACT,U,6)="UNKNOWN":"Unknown",1:""),I=I+1 ;216
  1. S ORAY(I)=" ",I=I+1
  1. I $D(GMRACT("S",1)) D SYMP
  1. I $D(GMRACT("V",1)) D CLAS
  1. S ORAY(I)=" Originator: "_$P(GMRACT,U,2)_$S($L($P(GMRACT,U,3)):" ("_$P(GMRACT,U,3)_")",1:""),I=I+1 ;216
  1. S ORAY(I)=" Originated: "_$P(GMRACT,U,10),I=I+1 ;216
  1. I $D(GMRACT("O",1)) D OBS
  1. I $D(GMRACT("H")) D HIST
  1. S ORAY(I)=" Verified: "_$S($P(GMRACT,U,4)="VERIFIED":$P(GMRACT,U,8),1:"No"),I=I+1 ;216
  1. S ORAY(I)="Observed/Historical: "_$S($P(GMRACT,U,5)="OBSERVED":"Observed",$P(GMRACT,U,5)="HISTORICAL":"Historical",1:""),I=I+1
  1. I $D(GMRACT("C",1)) D COM
  1. K GMRACT
  1. Q
  1. SYMP S K=0,N=0 F S K=$O(GMRACT("S",K)) Q:K'>0 D
  1. .I N=0 S ORAY(I)=" Signs/symptoms: "_GMRACT("S",K),I=I+1
  1. .E S ORAY(I)=" "_GMRACT("S",K),I=I+1
  1. .S N=N+1
  1. S ORAY(I)=" ",I=I+1
  1. K N,K
  1. Q
  1. CLAS S K=0,N=0 F S K=$O(GMRACT("V",K)) Q:K'>0 D
  1. .I N=0 S ORAY(I)=" Drug Classes: "_$P(GMRACT("V",K),U,2),I=I+1
  1. .E S ORAY(I)=" "_$P(GMRACT("V",K),U,2),I=I+1
  1. .S N=N+1
  1. S ORAY(I)=" ",I=I+1
  1. K N,K
  1. Q
  1. OBS S K=0,N=0 F S K=$O(GMRACT("O",K)) Q:K'>0 D
  1. .I N=0 D
  1. ..S Y=$P(GMRACT("O",K),U) D DD^%DT
  1. ..S ORAY(I)=" Obs dates/severity: "_Y_" "_$P(GMRACT("O",K),U,2),I=I+1
  1. .E D
  1. ..S Y=$P(GMRACT("O",K),U) D DD^%DT
  1. ..S ORAY(I)=" "_Y_" "_$P(GMRACT("O",K),U,2),I=I+1
  1. .S N=N+1
  1. S ORAY(I)=" ",I=I+1
  1. K N,K,Y
  1. Q
  1. HIST ;Historical Severity and dates
  1. N Y
  1. S Y=$P(GMRACT("H"),U) D DD^%DT
  1. S ORAY(I)=" Hist date/severity: "_$S(Y="":"",1:Y_" ")_$P(GMRACT("H"),U,2),I=I+1
  1. S ORAY(I)=" ",I=I+1
  1. Q
  1. COM S K=0,N=0,ORAY(I)=" ",I=I+1
  1. F S K=$O(GMRACT("C",K)) Q:K'>0 D
  1. .I N=0 S ORAY(I)="Comments:",I=I+1
  1. .S Y=$P(GMRACT("C",K),U) D DD^%DT
  1. .S ORAY(I)=" "_Y_" by "_$P(GMRACT("C",K),U,2),I=I+1
  1. .I $D(GMRACT("C",K,1,0)) S L=0 F S L=$O(GMRACT("C",K,L)) Q:L'>0 D
  1. ..S ORAY(I)=GMRACT("C",K,L,0),I=I+1
  1. .S N=N+1
  1. S ORAY(I)=" ",I=I+1
  1. K N,K,L,Y
  1. Q