Finished allergies (added reactions); allergies and problems in their own routines now
This commit is contained in:
parent
ac8e3dc555
commit
4976db567f
181
p/C0XPT0.m
181
p/C0XPT0.m
|
@ -1,4 +1,4 @@
|
|||
C0XPT0 ; VEN/SMH - Get patient data and do something about it ;2013-02-06 3:08 PM
|
||||
C0XPT0 ; VEN/SMH - Get patient data and do something about it ;2013-02-19 12:01 PM
|
||||
;;1.1;FILEMAN TRIPLE STORE;;
|
||||
;
|
||||
; Get all graphs
|
||||
|
@ -29,8 +29,8 @@ PROGRAPH(G) ; Process Graph (i.e. Patient)
|
|||
N DFN S DFN=$P(RETURN(1),U,2)
|
||||
I DFN<1 S $EC=",U1," ; Debug.Assert that patient is added.
|
||||
; D VITALS(G,DFN)
|
||||
D PROBLEMS(G,DFN)
|
||||
D ADR(G,DFN) ; Adverse Drug Reactions
|
||||
D PROBLEMS^C0XPT1(G,DFN) ; Extract Problems and File
|
||||
D ADR^C0XPT2(G,DFN) ; Extract Allergies and File
|
||||
;
|
||||
QUIT
|
||||
;
|
||||
|
@ -181,34 +181,6 @@ VITALS(G,DFN) ; Private EP; Process Vitals for a patient graph.
|
|||
; D EN1^GMVDCSAV(.RESULT,DATA)
|
||||
QUIT
|
||||
;
|
||||
PROBLEMS(G,DFN) ; Private EP; Process Problems for a patient graph
|
||||
; Delete existing problems if they are present
|
||||
; PS: This is a risky operation if somebody points to the original data.
|
||||
; PS2: Another idea is just to quit here if Patient has problems already.
|
||||
I $D(^AUPNPROB("AC",DFN)) DO ; Patient already has problems.
|
||||
. N DIK S DIK="^AUPNPROB(" ; Global to kill
|
||||
. N DA F DA=0:0 S DA=$O(^AUPNPROB("AC",DFN,DA)) Q:'DA D ^DIK ; Kill each entry
|
||||
;
|
||||
; Process incoming problems
|
||||
N RETURN ; Local return variable. I don't expect a patient to have more than 50 problems.
|
||||
D ONETYPE^C0XGET3($NA(RETURN),G,"sp:Problem") ; Get all problems for patient
|
||||
N S F S=0:0 S S=$O(RETURN(S)) Q:'S D ; For each problem
|
||||
. N PROBNM S PROBNM=$$GSPO1^C0XGET3(G,RETURN(S),"sp:problemName") ; Snomed-CT coding info
|
||||
. N CODEURL S CODEURL=$$GSPO1^C0XGET3(G,PROBNM,"sp:code") ; Snomed-CT Code URL
|
||||
. N TEXT S TEXT=$$GSPO1^C0XGET3(G,PROBNM,"dcterms:title") ; Snomed-CT Code description
|
||||
. ;
|
||||
. N CODE ; Actual Snomed code rather than URL
|
||||
. S CODE=$P(CODEURL,"/",$L(CODEURL,"/")) ; Get last / piece
|
||||
. N EXPIEN ; IEN in the EXPESSION file
|
||||
. N LEXS ; Return from Lex call
|
||||
. D EN^LEXCODE(CODE) ; Lex API
|
||||
. S EXPIEN=$P(LEXS("SCT",1),U) ; First match on Snomed CT. Crash if isn't present.
|
||||
. ;
|
||||
. N STARTDT S STARTDT=$$GSPO1^C0XGET3(G,RETURN(S),"sp:startDate") ; Start Date
|
||||
. N X,Y,%DT S X=STARTDT D ^%DT S STARTDT=Y ; Convert STARTDT to internal format
|
||||
. D PROBADD(DFN,CODE,TEXT,EXPIEN,STARTDT) ; Add problem to VISTA.
|
||||
QUIT
|
||||
;
|
||||
NP() ; New Person Entry
|
||||
N C0XFDA,C0XIEN,C0XERR
|
||||
S C0XFDA(200,"?+1,",.01)="PROVIDER,UNKNOWN SMART" ; Name
|
||||
|
@ -219,150 +191,3 @@ NP() ; New Person Entry
|
|||
D UPDATE^DIE("E",$NA(C0XFDA),$NA(C0XIEN),$NA(C0XERR)) ; Typical UPDATE
|
||||
Q C0XIEN(1) ;Provider IEN
|
||||
;
|
||||
PROBADD(DFN,CODE,TEXT,EXPIEN,STARTDT) ; Add a problem to a patient's record.
|
||||
; Input
|
||||
; DFN - you know what that is
|
||||
; CODE - SNOMED code; not used alas; for the future.
|
||||
; TEXT - SNOMED Text
|
||||
; EXPIEN - IEN of Snomed CT Expression in the Expressions File (757.01)
|
||||
; STARTDT - Internal Date of when the problem was first noted.
|
||||
;
|
||||
; Output:
|
||||
; NONE
|
||||
; Crash expected if code fails to add a problem.
|
||||
;
|
||||
;
|
||||
;
|
||||
N GMPDFN S GMPDFN=DFN ; patient dfn
|
||||
;
|
||||
; Add unknown provider to database
|
||||
N GMPPROV S GMPPROV=$$NP^C0XPT0() ;Smart Provider IEN
|
||||
;
|
||||
N GMPVAMC S GMPVAMC=$$KSP^XUPARAM("INST") ; Problem Institution. Ideally, the external one. But we are taking a shortcut here.
|
||||
;
|
||||
N GMPFLD ; Input array
|
||||
S GMPFLD(".01")="" ;Code IEN - API will assign 799.9.
|
||||
; .02 field (Patient IEN) not used. Pass variable GMPDFN instead.
|
||||
S GMPFLD(".03")=DT ;Date Last Modified
|
||||
S GMPFLD(".05")="^"_TEXT ;Expression text
|
||||
S GMPFLD(".08")=DT ; today's date (entry?)
|
||||
S GMPFLD(".12")="A" ;Active/Inactive
|
||||
S GMPFLD(".13")=STARTDT ;Onset date
|
||||
S GMPFLD("1.01")=EXPIEN_U_TEXT ;^LEX(757.01 ien,descip
|
||||
S GMPFLD("1.03")=GMPPROV ;Entered by
|
||||
S GMPFLD("1.04")=GMPPROV ;Recording provider
|
||||
S GMPFLD("1.05")=GMPPROV ;Responsible provider
|
||||
S GMPFLD("1.06")="" ; SERVICE FILE - LEAVE BLANK(#49)
|
||||
S GMPFLD("1.07")="" ; Date resolved
|
||||
S GMPFLD("1.08")="" ; Clinic (#44)
|
||||
S GMPFLD("1.09")=DT ;entry date
|
||||
S GMPFLD("1.1")=0 ;Service Connected
|
||||
S GMPFLD("1.11")=0 ;Agent Orange exposure
|
||||
S GMPFLD("1.12")=0 ;Ionizing radiation exposure
|
||||
S GMPFLD("1.13")=0 ;Persian Gulf exposure
|
||||
S GMPFLD("1.14")="C" ;Accute/Chronic (A,C)
|
||||
S GMPFLD("1.15")="" ;Head/neck cancer
|
||||
S GMPFLD("1.16")="" ;Military sexual trauma
|
||||
S GMPFLD("10",0)=0 ; Note. No note.
|
||||
;
|
||||
;
|
||||
N DA ; Return variable
|
||||
D NEW^GMPLSAVE ; API call
|
||||
I '$D(DA) S $EC=",U1," ; Fail here if API fails.
|
||||
QUIT
|
||||
;
|
||||
;
|
||||
ADR(G,DFN) ; Private Proc; Extract Allergies and ADRs from Graph and add to Patient's Record
|
||||
; Input: G, Patient Graph, DFN, you should know that that is; Both by value.
|
||||
;
|
||||
; Try No known allergies first.
|
||||
N NKA S NKA=$$ONETYPE1^C0XGET3(G,"sp:AllergyExclusion") ; Get NKA node
|
||||
;
|
||||
; Add allergies to record.
|
||||
; We don't really care about the return value. If patient already has
|
||||
; allergies, we just keep them.
|
||||
I $L(NKA) N % S %=$$NKA^C0XPT0(DFN) QUIT ; If it exists, let's try to file it into VISTA
|
||||
;
|
||||
; If we are here, it means that the patient has allergies. Fun!
|
||||
; Process incoming allergies
|
||||
N RETURN ; Local return variable. I don't expect a patient to have more than 50 allergies.
|
||||
D ONETYPE^C0XGET3($NA(RETURN),G,"sp:Allergy") ; Get all allergies for patient
|
||||
;
|
||||
N S F S=0:0 S S=$O(RETURN(S)) Q:'S D ; For each allergy
|
||||
. ; Get the SNOMED code for the category
|
||||
. N ALLERGYTYPE
|
||||
. N SNOCAT S SNOCAT=$$GSPO1^C0XGET3(G,RETURN(S),"sp:category.sp:code"),SNOCAT=$P(SNOCAT,"/",$L(SNOCAT,"/"))
|
||||
. I SNOCAT=414285001 S ALLERGYTYPE="F" ; Food
|
||||
. E I SNOCAT=416098002 S ALLERGYTYPE="D" ; Drug
|
||||
. I '$D(ALLERGYTYPE) S $EC=",U1," ; Crash if neither of these is true.
|
||||
. ;
|
||||
. N ALLERGEN,ALLERGENI ; Allergen, Internal Allergen
|
||||
. I ALLERGYTYPE="F" D ; Food
|
||||
. . S ALLERGEN=$$UP^XLFSTR($$GSPO1^C0XGET3(G,RETURN(S),"sp:otherAllergen.dcterms:title")) ; uppercase the allergen
|
||||
. . I ALLERGEN="PEANUT" S ALLERGEN="PEANUTS" ; TODO: temporary fix
|
||||
. . S ALLERGENI=$$GMRA^C0XPT0(ALLERGEN) ; Get internal representation for GMRA call
|
||||
. ;
|
||||
. ; Otherwise, it's a drug. But we need to find out if it's a class,
|
||||
. ; ingredient, canonical drug, etc. Unfortunately, Smart examples don't
|
||||
. ; show such variety. The only one specified is a drug class.
|
||||
. ; Therefore
|
||||
. ; TODO: Handle other drug items besides drug class
|
||||
. ;
|
||||
. E D ; Drug
|
||||
. . N DC S DC=$$GSPO1^C0XGET3(G,RETURN(S),"sp:drugClassAllergen.sp:code") ; drug class
|
||||
. . I '$L(DC) QUIT ; edit this line out when handling other items
|
||||
. . S ALLERGEN=$P(DC,"/",$L(DC,"/")) ; Get last piece
|
||||
. . ; TODO: Resolve drug class properly. Need all of RxNorm for that.
|
||||
. . N STR S STR=$$UP^XLFSTR($$GSPO1^C0XGET3(G,RETURN(S),"sp:drugClassAllergen.dcterms:title"))
|
||||
. . I ALLERGEN="N0000175503" S ALLERGENI=STR_U_"23;PS(50.605," ; hard codeded for sulfonamides
|
||||
. . ;
|
||||
. ; DEBUG.ASSERT THAT allergen Internal isn't empty
|
||||
. I '$L(ALLERGENI) S $EC=",U1,"
|
||||
. ;
|
||||
. ; Get Severity (Mild or Severe) - We get free text rather than SNOMED
|
||||
. N SEVERITY S SEVERITY=$$UP^XLFSTR($$GSPO1^C0XGET3(G,RETURN(S),"sp:severity.dcterms:title"))
|
||||
. I '$L(SEVERITY) S $EC=",U1,"
|
||||
. ;
|
||||
. ; Get Reaction - We get free text rather than SNOMED
|
||||
. N REACTION S REACTION=$$UP^XLFSTR($$GSPO1^C0XGET3(G,RETURN(S),"sp:allergicReaction.dcterms:title"))
|
||||
. I '$L(REACTION) S $EC=",U1,"
|
||||
. ;
|
||||
. ; Now that we have determined the allergy, add it
|
||||
. D FILEADR^C0XPT0(DFN,ALLERGENI,REACTION,SEVERITY,ALLERGYTYPE) ; Internal API
|
||||
QUIT
|
||||
;
|
||||
NKA(DFN) ; Public $$; Add no known allergies to patient record
|
||||
N ORDFN S ORDFN=DFN ; CPRS API requires this one
|
||||
N ORY ; Return value: 0 - Everything is okay; -1^msg: Patient already has allergies
|
||||
D NKA^GMRAGUI1 ; API
|
||||
QUIT $G(ORY) ; Not always returned
|
||||
;
|
||||
GMRA(NAME) ; $$ Private - Retrieve GMRAGNT for food allergy from 120.82
|
||||
; Input: Brand Name, By Value
|
||||
; Output: Entry Name^IEN;File Root for IEN
|
||||
N C0PIEN S C0PIEN=$$FIND1^DIC(120.82,"","O",NAME,"B")
|
||||
Q:C0PIEN $$GET1^DIQ(120.82,C0PIEN,.01)_"^"_C0PIEN_";GMRD(120.82,"
|
||||
QUIT "" ; no match otherwise
|
||||
;
|
||||
TYPE(GMRAGNT) ; $$ Private - Get allergy Type (Drug, food, or other)
|
||||
; Input: Allergen, formatted as Allergen^IEN;File Root
|
||||
; Output: Type (internal)^Type (external) e.g. D^Drug
|
||||
N C0PIEN S C0PIEN=+$P(GMRAGNT,U,2)
|
||||
I GMRAGNT["GMRD(120.82," Q $$GET1^DIQ(120.82,C0PIEN,"ALLERGY TYPE","I")_U_$$GET1^DIQ(120.82,C0PIEN,"ALLERGY TYPE","E")
|
||||
Q "D^Drug" ; otherwise, it's a drug
|
||||
;
|
||||
FILEADR(DFN,AGENT,REACTION,SEVERITY,TYPE) ; Private Proc - File Drug Reaction
|
||||
N C0XRXN
|
||||
S C0XRXN("GMRAGNT")=AGENT ; Agent^Agent in variable pointer format
|
||||
S C0XRXN("GMRATYPE")=TYPE ; F(ood), D(rug), or O(ther) or combination.
|
||||
S C0XRXN("GMRANATR")="U^Unknown" ; Allergic, Pharmacologic, or Unknown
|
||||
S C0XRXN("GMRAORIG")=$$NP^C0XPT0 ; New Person generated for SMART
|
||||
; S C0XRXN("GMRACHT",0)=1 ; Mark Chart as allergy document - commented out b/c depends on Paper Docs
|
||||
; S C0XRXN("GMRACHT",1)=$$NOW^XLFDT ; Chart documentation date - commented out depends on Paper Docs
|
||||
S C0XRXN("GMRAORDT")=$$NOW^XLFDT
|
||||
S C0XRXN("GMRAOBHX")="h^HISTORICAL"
|
||||
S C0XRXN("GMRACMTS",0)=1 ; Comments
|
||||
S C0XRXN("GMRACMTS",1)=SEVERITY ; Store severity in the comments
|
||||
N ORY ; Return value 0: success; -1: failure; discarded.
|
||||
D UPDATE^GMRAGUI1("",DFN,$NA(C0XRXN))
|
||||
QUIT
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
C0XPT1 ; VEN/SMH - Obtain and Store Problems ;2013-02-19 11:55 AM
|
||||
;;1.1;FILEMAN TRIPLE STORE;;
|
||||
;
|
||||
PROBLEMS(G,DFN) ; Private EP; Process Problems for a patient graph
|
||||
; Delete existing problems if they are present
|
||||
; PS: This is a risky operation if somebody points to the original data.
|
||||
; PS2: Another idea is just to quit here if Patient has problems already.
|
||||
I $D(^AUPNPROB("AC",DFN)) DO ; Patient already has problems.
|
||||
. N DIK S DIK="^AUPNPROB(" ; Global to kill
|
||||
. N DA F DA=0:0 S DA=$O(^AUPNPROB("AC",DFN,DA)) Q:'DA D ^DIK ; Kill each entry
|
||||
;
|
||||
; Process incoming problems
|
||||
N RETURN ; Local return variable. I don't expect a patient to have more than 50 problems.
|
||||
D ONETYPE^C0XGET3($NA(RETURN),G,"sp:Problem") ; Get all problems for patient
|
||||
N S F S=0:0 S S=$O(RETURN(S)) Q:'S D ; For each problem
|
||||
. N PROBNM S PROBNM=$$GSPO1^C0XGET3(G,RETURN(S),"sp:problemName") ; Snomed-CT coding info
|
||||
. N CODEURL S CODEURL=$$GSPO1^C0XGET3(G,PROBNM,"sp:code") ; Snomed-CT Code URL
|
||||
. N TEXT S TEXT=$$GSPO1^C0XGET3(G,PROBNM,"dcterms:title") ; Snomed-CT Code description
|
||||
. ;
|
||||
. N CODE ; Actual Snomed code rather than URL
|
||||
. S CODE=$P(CODEURL,"/",$L(CODEURL,"/")) ; Get last / piece
|
||||
. N EXPIEN ; IEN in the EXPESSION file
|
||||
. N LEXS ; Return from Lex call
|
||||
. D EN^LEXCODE(CODE) ; Lex API
|
||||
. S EXPIEN=$P(LEXS("SCT",1),U) ; First match on Snomed CT. Crash if isn't present.
|
||||
. ;
|
||||
. N STARTDT S STARTDT=$$GSPO1^C0XGET3(G,RETURN(S),"sp:startDate") ; Start Date
|
||||
. N X,Y,%DT S X=STARTDT D ^%DT S STARTDT=Y ; Convert STARTDT to internal format
|
||||
. D PROBADD(DFN,CODE,TEXT,EXPIEN,STARTDT) ; Add problem to VISTA.
|
||||
QUIT
|
||||
;
|
||||
PROBADD(DFN,CODE,TEXT,EXPIEN,STARTDT) ; Add a problem to a patient's record.
|
||||
; Input
|
||||
; DFN - you know what that is
|
||||
; CODE - SNOMED code; not used alas; for the future.
|
||||
; TEXT - SNOMED Text
|
||||
; EXPIEN - IEN of Snomed CT Expression in the Expressions File (757.01)
|
||||
; STARTDT - Internal Date of when the problem was first noted.
|
||||
;
|
||||
; Output:
|
||||
; NONE
|
||||
; Crash expected if code fails to add a problem.
|
||||
;
|
||||
;
|
||||
;
|
||||
N GMPDFN S GMPDFN=DFN ; patient dfn
|
||||
;
|
||||
; Add unknown provider to database
|
||||
N GMPPROV S GMPPROV=$$NP^C0XPT0() ;Smart Provider IEN
|
||||
;
|
||||
N GMPVAMC S GMPVAMC=$$KSP^XUPARAM("INST") ; Problem Institution. Ideally, the external one. But we are taking a shortcut here.
|
||||
;
|
||||
N GMPFLD ; Input array
|
||||
S GMPFLD(".01")="" ;Code IEN - API will assign 799.9.
|
||||
; .02 field (Patient IEN) not used. Pass variable GMPDFN instead.
|
||||
S GMPFLD(".03")=DT ;Date Last Modified
|
||||
S GMPFLD(".05")="^"_TEXT ;Expression text
|
||||
S GMPFLD(".08")=DT ; today's date (entry?)
|
||||
S GMPFLD(".12")="A" ;Active/Inactive
|
||||
S GMPFLD(".13")=STARTDT ;Onset date
|
||||
S GMPFLD("1.01")=EXPIEN_U_TEXT ;^LEX(757.01 ien,descip
|
||||
S GMPFLD("1.03")=GMPPROV ;Entered by
|
||||
S GMPFLD("1.04")=GMPPROV ;Recording provider
|
||||
S GMPFLD("1.05")=GMPPROV ;Responsible provider
|
||||
S GMPFLD("1.06")="" ; SERVICE FILE - LEAVE BLANK(#49)
|
||||
S GMPFLD("1.07")="" ; Date resolved
|
||||
S GMPFLD("1.08")="" ; Clinic (#44)
|
||||
S GMPFLD("1.09")=DT ;entry date
|
||||
S GMPFLD("1.1")=0 ;Service Connected
|
||||
S GMPFLD("1.11")=0 ;Agent Orange exposure
|
||||
S GMPFLD("1.12")=0 ;Ionizing radiation exposure
|
||||
S GMPFLD("1.13")=0 ;Persian Gulf exposure
|
||||
S GMPFLD("1.14")="C" ;Accute/Chronic (A,C)
|
||||
S GMPFLD("1.15")="" ;Head/neck cancer
|
||||
S GMPFLD("1.16")="" ;Military sexual trauma
|
||||
S GMPFLD("10",0)=0 ; Note. No note.
|
||||
;
|
||||
;
|
||||
N DA ; Return variable
|
||||
D NEW^GMPLSAVE ; API call
|
||||
I '$D(DA) S $EC=",U1," ; Fail here if API fails.
|
||||
QUIT
|
||||
;
|
||||
;
|
|
@ -0,0 +1,109 @@
|
|||
C0XPT2 ; VEN/SMH - Get and Store Allergies/ADRs ;2013-02-19 12:03 PM
|
||||
;;1.1;FILEMAN TRIPLE STORE;;
|
||||
;
|
||||
ADR(G,DFN) ; Private Proc; Extract Allergies and ADRs from Graph and add to Patient's Record
|
||||
; Input: G, Patient Graph, DFN, you should know that that is; Both by value.
|
||||
;
|
||||
; Try No known allergies first.
|
||||
N NKA S NKA=$$ONETYPE1^C0XGET3(G,"sp:AllergyExclusion") ; Get NKA node
|
||||
;
|
||||
; Add NKA to record.
|
||||
; We don't really care about the return value. If patient already has
|
||||
; allergies, we just keep them.
|
||||
I $L(NKA) N % S %=$$NKA(DFN) QUIT ; If it exists, let's try to file it into VISTA
|
||||
;
|
||||
; If we are here, it means that the patient has allergies. Fun!
|
||||
; Process incoming allergies
|
||||
N RETURN ; Local return variable. I don't expect a patient to have more than 50 allergies.
|
||||
D ONETYPE^C0XGET3($NA(RETURN),G,"sp:Allergy") ; Get all allergies for patient
|
||||
;
|
||||
N S F S=0:0 S S=$O(RETURN(S)) Q:'S D ; For each allergy
|
||||
. ; Get the SNOMED code for the category
|
||||
. N ALLERGYTYPE
|
||||
. N SNOCAT S SNOCAT=$$GSPO1^C0XGET3(G,RETURN(S),"sp:category.sp:code"),SNOCAT=$P(SNOCAT,"/",$L(SNOCAT,"/"))
|
||||
. I SNOCAT=414285001 S ALLERGYTYPE="F" ; Food
|
||||
. E I SNOCAT=416098002 S ALLERGYTYPE="D" ; Drug
|
||||
. I '$D(ALLERGYTYPE) S $EC=",U1," ; Crash if neither of these is true.
|
||||
. ;
|
||||
. N ALLERGEN,ALLERGENI ; Allergen, Internal Allergen
|
||||
. I ALLERGYTYPE="F" D ; Food
|
||||
. . S ALLERGEN=$$UP^XLFSTR($$GSPO1^C0XGET3(G,RETURN(S),"sp:otherAllergen.dcterms:title")) ; uppercase the allergen
|
||||
. . I ALLERGEN="PEANUT" S ALLERGEN="PEANUTS" ; TODO: temporary fix
|
||||
. . S ALLERGENI=$$GMRA(ALLERGEN) ; Get internal representation for GMRA call
|
||||
. ;
|
||||
. ; Otherwise, it's a drug. But we need to find out if it's a class,
|
||||
. ; ingredient, canonical drug, etc. Unfortunately, Smart examples don't
|
||||
. ; show such variety. The only one specified is a drug class.
|
||||
. ; Therefore
|
||||
. ; TODO: Handle other drug items besides drug class
|
||||
. ;
|
||||
. E D ; Drug Class
|
||||
. . N DC S DC=$$GSPO1^C0XGET3(G,RETURN(S),"sp:drugClassAllergen.sp:code") ; drug class
|
||||
. . I '$L(DC) QUIT ; edit this line out when handling other items
|
||||
. . S ALLERGEN=$P(DC,"/",$L(DC,"/")) ; Get last piece
|
||||
. . ; TODO: Resolve drug class properly. Need all of RxNorm for that.
|
||||
. . N STR S STR=$$UP^XLFSTR($$GSPO1^C0XGET3(G,RETURN(S),"sp:drugClassAllergen.dcterms:title"))
|
||||
. . I ALLERGEN="N0000175503" S ALLERGENI=STR_U_"23;PS(50.605," ; hard codeded for sulfonamides
|
||||
. . ;
|
||||
. ; DEBUG.ASSERT THAT allergen Internal isn't empty
|
||||
. I '$L(ALLERGENI) S $EC=",U1,"
|
||||
. ;
|
||||
. ; Get Severity (Mild or Severe) - We get free text rather than SNOMED
|
||||
. N SEVERITY S SEVERITY=$$UP^XLFSTR($$GSPO1^C0XGET3(G,RETURN(S),"sp:severity.dcterms:title"))
|
||||
. I '$L(SEVERITY) S $EC=",U1,"
|
||||
. ;
|
||||
. ; Get Reaction - We get free text rather than SNOMED
|
||||
. N REACTION S REACTION=$$UP^XLFSTR($$GSPO1^C0XGET3(G,RETURN(S),"sp:allergicReaction.dcterms:title"))
|
||||
. I '$L(REACTION) S $EC=",U1,"
|
||||
. ;
|
||||
. ; Now that we have determined the allergy, add it
|
||||
. D FILEADR(DFN,ALLERGENI,REACTION,SEVERITY,ALLERGYTYPE) ; Internal API
|
||||
QUIT
|
||||
;
|
||||
NKA(DFN) ; Public $$; Add no known allergies to patient record
|
||||
N ORDFN S ORDFN=DFN ; CPRS API requires this one
|
||||
N ORY ; Return value: 0 - Everything is okay; -1^msg: Patient already has allergies
|
||||
D NKA^GMRAGUI1 ; API
|
||||
QUIT $G(ORY) ; Not always returned
|
||||
;
|
||||
GMRA(NAME) ; $$ Private - Retrieve GMRAGNT for food allergy from 120.82
|
||||
; Input: Brand Name, By Value
|
||||
; Output: Entry Name^IEN;File Root for IEN
|
||||
N C0PIEN S C0PIEN=$$FIND1^DIC(120.82,"","O",NAME,"B")
|
||||
Q:C0PIEN $$GET1^DIQ(120.82,C0PIEN,.01)_"^"_C0PIEN_";GMRD(120.82,"
|
||||
QUIT "" ; no match otherwise
|
||||
;
|
||||
TYPE(GMRAGNT) ; $$ Private - Get allergy Type (Drug, food, or other)
|
||||
; Input: Allergen, formatted as Allergen^IEN;File Root
|
||||
; Output: Type (internal)^Type (external) e.g. D^Drug
|
||||
N C0PIEN S C0PIEN=+$P(GMRAGNT,U,2)
|
||||
I GMRAGNT["GMRD(120.82," Q $$GET1^DIQ(120.82,C0PIEN,"ALLERGY TYPE","I")_U_$$GET1^DIQ(120.82,C0PIEN,"ALLERGY TYPE","E")
|
||||
Q "D^Drug" ; otherwise, it's a drug
|
||||
;
|
||||
FILEADR(DFN,AGENT,REACTION,SEVERITY,TYPE,DATE) ; Private Proc - File Drug Reaction
|
||||
; This is very messy right now. The more use this gets, the better idea
|
||||
; I will have of how much data resolution this API should expect and how
|
||||
; much it should do itself.
|
||||
;
|
||||
K ^TMP($J,"ADR")
|
||||
S ^TMP($J,"ADR","GMRAGNT")=AGENT ; Agent Free Text^Agent in variable pointer format
|
||||
S ^TMP($J,"ADR","GMRATYPE")=TYPE ; F(ood), D(rug), or O(ther) or combination.
|
||||
S ^TMP($J,"ADR","GMRANATR")="U^Unknown" ; Mechanism: Allergic, Pharmacologic, or Unknown
|
||||
S ^TMP($J,"ADR","GMRAORIG")=$$NP^C0XPT0 ; New Person generated for SMART
|
||||
S ^TMP($J,"ADR","GMRAORDT")=$G(DATE,$$NOW^XLFDT) ; Origination Date; Ideally, would have a date for the allergy.
|
||||
S ^TMP($J,"ADR","GMRACHT",0)=1 ; Mark Chart as allergy document; don't know why; CPRS does that.
|
||||
S ^TMP($J,"ADR","GMRACHT",1)=$$NOW^XLFDT ; Chart documentation date; don't know why; CPRS does that.
|
||||
S ^TMP($J,"ADR","GMRAOBHX")="h^HISTORICAL" ; or o^Observered
|
||||
S ^TMP($J,"ADR","GMRACMTS",0)=1 ; Comments
|
||||
S ^TMP($J,"ADR","GMRACMTS",1)=SEVERITY ; Store severity in the comments (Severity in VISTA only applies to observed allergies)
|
||||
S ^TMP($J,"ADR","GMRASYMP",0)=1 ; One Symptom
|
||||
;
|
||||
; Find IEN of Reaction from S/S file. We say "Q - Don't transform; X - exact match only; Screen on VUID status"
|
||||
N RXN S RXN=$$FIND1^DIC(120.83,,"QX",REACTION,"B^D","I '$$SCREEN^XTID(120.83,.01,Y_"","")") ; Get Reaction IEN
|
||||
I RXN S ^TMP($J,"ADR","GMRASYMP",1)=RXN_U_REACTION ; Coded reaction
|
||||
E S ^TMP($J,"ADR","GMRASYMP",1)="FT"_U_REACTION ; Free Text Reaction
|
||||
;
|
||||
N ORY ; Return value 0: success; -1: failure; discarded.
|
||||
D UPDATE^GMRAGUI1("",DFN,$NA(^TMP($J,"ADR")))
|
||||
K ^TMP($J,"ADR")
|
||||
QUIT
|
Loading…
Reference in New Issue