- Timestamp:
- Feb 4, 2013, 6:26:26 PM (12 years ago)
- Location:
- fmts/trunk/p
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
fmts/trunk/p/C0XGET3.m
r1602 r1604 1 C0XGET3 ; VEN/SMH - Sam's Getters... let's try to make them simple ;2013-0 1-25 4:59PM1 C0XGET3 ; VEN/SMH - Sam's Getters... let's try to make them simple ;2013-02-04 12:00 PM 2 2 ;;1.1;FILEMAN TRIPLE STORE; 3 3 ; 4 4 IEN(N) ; Public $$; Resolved IEN of a stored string such as "rdf:type" in Strings File 5 I +N=N Q N ; We are given the IEN, just return it back 5 6 Q $$IENOF^C0XGET1($$EXT^C0XUTIL(N)) 6 7 ; … … 25 26 QUIT 26 27 GSPO1(G,S,P) ; Public $$; Get Object for A Graph/Subject/Predicate combination 28 ; Supports forward relational navigation for predicates using "." as separator 29 N EP S EP=$P(P,".",2,99) ; Extended Predicate 30 S P=$P(P,".") ; Predicate becomes the first piece 27 31 N O S O=$O(^C0X(101,"GSPO",$$IEN(G),$$IEN(S),$$IEN(P),"")) 28 Q:O="" "" 29 Q ^C0X(201,O,0) 32 Q:O="" "" ; Another end point for recursion 33 Q:$L(EP) $$GSPO1(G,O,EP) ; if we have an extended predicate, recurse 34 Q ^C0X(201,O,0) ; this is the end point of the recursion. -
fmts/trunk/p/C0XPT0.m
r1603 r1604 1 C0XPT0 ; VEN/SMH - Get patient data and do something about it ;2013-0 1-28 4:24PM1 C0XPT0 ; VEN/SMH - Get patient data and do something about it ;2013-02-04 3:41 PM 2 2 ;;1.1;FILEMAN TRIPLE STORE;; 3 3 ; … … 27 27 NEW RETURN 28 28 D ADDPT(.RETURN,.PARAM) 29 ZWRITE RETURN30 29 N DFN S DFN=$P(RETURN(1),U,2) 31 D VITALS(G,DFN) 30 I DFN<1 S $EC=",U1," ; Debug.Assert that patient is added. 31 ; D VITALS(G,DFN) 32 32 D PROBLEMS(G,DFN) 33 D ADR(G,DFN) ; Adverse Drug Reactions 33 34 ; 34 35 QUIT … … 177 178 N S F S=0:0 S S=$O(^TMP($J,"VS",S)) Q:S="" D 178 179 . N ENC S ENC=$$GSPO1^C0XGET3(G,^TMP($J,"VS",S),"sp:encounter") 179 . ZWRITE ENC180 180 ; 181 181 ; D EN1^GMVDCSAV(.RESULT,DATA) … … 267 267 I '$D(DA) S $EC=",U1," ; Fail here if API fails. 268 268 QUIT 269 ; 270 ; 271 ADR(G,DFN) ; Private Proc; Extract Allergies and ADRs from Graph and add to Patient's Record 272 ; Input: G, Patient Graph, DFN, you should know that that is; Both by value. 273 ; 274 ; Try No known allergies first. 275 N NKA S NKA=$$ONETYPE1^C0XGET3(G,"sp:AllergyExclusion") ; Get NKA node 276 ; 277 ; Add allergies to record. 278 ; We don't really care about the return value. If patient already has 279 ; allergies, we just keep them. 280 I $L(NKA) N % S %=$$NKA^C0XPT0(DFN) QUIT ; If it exists, let's try to file it into VISTA 281 ; 282 ; If we are here, it means that the patient has allergies. Fun! 283 ; Process incoming allergies 284 N RETURN ; Local return variable. I don't expect a patient to have more than 50 allergies. 285 D ONETYPE^C0XGET3($NA(RETURN),G,"sp:Allergy") ; Get all allergies for patient 286 ; 287 N S F S=0:0 S S=$O(RETURN(S)) Q:'S D ; For each allergy 288 . ; Get the SNOMED code for the category 289 . N ALLERGYTYPE 290 . N SNOCAT S SNOCAT=$$GSPO1^C0XGET3(G,RETURN(S),"sp:category.sp:code"),SNOCAT=$P(SNOCAT,"/",$L(SNOCAT,"/")) 291 . I SNOCAT=414285001 S ALLERGYTYPE="F" ; Food 292 . E I SNOCAT=416098002 S ALLERGYTYPE="D" ; Drug 293 . I '$D(ALLERGYTYPE) S $EC=",U1," ; Crash if neither of these is true. 294 . ; 295 . N ALLERGEN,ALLERGENI ; Allergen, Internal Allergen 296 . I ALLERGYTYPE="F" D ; Food 297 . . S ALLERGEN=$$UP^XLFSTR($$GSPO1^C0XGET3(G,RETURN(S),"sp:otherAllergen.dcterms:title")) ; uppercase the allergen 298 . . I ALLERGEN="PEANUT" S ALLERGEN="PEANUTS" ; temporary fix 299 . . S ALLERGENI=$$GMRA^C0XPT0(ALLERGEN) ; Get internal representation for GMRA call 300 . ; 301 . ; Otherwise, it's a drug. But we need to find out if it's a class, 302 . ; ingredient, canonical drug, etc. Unfortunately, Smart examples don't 303 . ; show such variety. The only one specified is a drug class. 304 . ; Therefore 305 . ; TODO: Handle other drug items besides drug class 306 . ; 307 . E D ; Drug 308 . . N DC S DC=$$GSPO1^C0XGET3(G,RETURN(S),"sp:drugClassAllergen.sp:code") ; drug class 309 . . I '$L(DC) QUIT ; edit this line out when handling other items 310 . . S ALLERGEN=$P(DC,"/",$L(DC,"/")) ; Get last piece 311 . . ; TODO: Resolve drug class properly. Need all of RxNorm for that. 312 . . I ALLERGEN="N0000175503" 313 QUIT 314 ; 315 NKA(DFN) ; Public $$; Add no known allergies to patient record 316 N ORDFN S ORDFN=DFN ; CPRS API requires this one 317 N ORY ; Return value: 0 - Everything is okay; -1^msg: Patient already has allergies 318 D NKA^GMRAGUI1 ; API 319 QUIT $G(ORY) ; Not always returned 320 ; 321 GMRA(NAME) ; $$ Private - Retrieve GMRAGNT for food allergy from 120.82 322 ; Input: Brand Name, By Value 323 ; Output: Entry Name^IEN;File Root for IEN 324 N C0PIEN S C0PIEN=$$FIND1^DIC(120.82,"","O",NAME,"B") 325 Q:C0PIEN $$GET1^DIQ(120.82,C0PIEN,.01)_"^"_C0PIEN_";GMRD(120.82," 326 QUIT "" ; no match otherwise 327 ; 328 TYPE(GMRAGNT) ; $$ Private - Get allergy Type (Drug, food, or other) 329 ; Input: Allergen, formatted as Allergen^IEN;File Root 330 ; Output: Type (internal)^Type (external) e.g. D^Drug 331 N C0PIEN S C0PIEN=+$P(GMRAGNT,U,2) 332 I GMRAGNT["GMRD(120.82," Q $$GET1^DIQ(120.82,C0PIEN,"ALLERGY TYPE","I")_U_$$GET1^DIQ(120.82,C0PIEN,"ALLERGY TYPE","E") 333 Q "D^Drug" ; otherwise, it's a drug
Note:
See TracChangeset
for help on using the changeset viewer.