initial release of the VistA Smart Container demo
This commit is contained in:
parent
32bf8c6698
commit
0bcbc4394f
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,289 @@
|
|||
C0SDEM ; GPL - Smart Demographics Processing ;2/22/12 17:05
|
||||
;;0.1;C0S;nopatch;noreleasedate;Build 2
|
||||
;Copyright 2012 George Lilly. Licensed under the terms of the GNU
|
||||
;General Public License See attached copy of the License.
|
||||
;
|
||||
;This program is free software; you can redistribute it and/or modify
|
||||
;it under the terms of the GNU General Public License as published by
|
||||
;the Free Software Foundation; either version 2 of the License, or
|
||||
;(at your option) any later version.
|
||||
;
|
||||
;This program is distributed in the hope that it will be useful,
|
||||
;but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;GNU General Public License for more details.
|
||||
;
|
||||
;You should have received a copy of the GNU General Public License along
|
||||
;with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
;
|
||||
Q
|
||||
;
|
||||
;<?xml version="1.0" encoding="utf-8"?>
|
||||
;<rdf:RDF
|
||||
; xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
; xmlns:sp="http://smartplatforms.org/terms#"
|
||||
; xmlns:dcterms="http://purl.org/dc/terms/"
|
||||
; xmlns:v="http://www.w3.org/2006/vcard/ns#"
|
||||
; xmlns:foaf="http://xmlns.com/foaf/0.1/">
|
||||
; <sp:Demographics>
|
||||
;
|
||||
; <v:n>
|
||||
; <v:Name>
|
||||
; <v:given-name>Bob</v:given-name>
|
||||
; <v:additional-name>J</v:additional-name>
|
||||
; <v:family-name>Odenkirk</v:family-name>
|
||||
; </v:Name>
|
||||
; </v:n>
|
||||
;
|
||||
; <v:adr>
|
||||
; <v:Address>
|
||||
; <rdf:type rdf:resource="http://www.w3.org/2006/vcard/ns#Home" />
|
||||
; <rdf:type rdf:resource="http://www.w3.org/2006/vcard/ns#Pref" />
|
||||
;
|
||||
; <v:street-address>15 Main St</v:street-address>
|
||||
; <v:extended-address>Apt 2</v:extended-address>
|
||||
; <v:locality>Wonderland</v:locality>
|
||||
; <v:region>OZ</v:region>
|
||||
; <v:postal-code>54321</v:postal-code>
|
||||
; <v:country>USA</v:country>
|
||||
; </v:Address>
|
||||
; </v:adr>
|
||||
;
|
||||
; <v:tel>
|
||||
; <v:Tel>
|
||||
; <rdf:type rdf:resource="http://www.w3.org/2006/vcard/ns#Home" />
|
||||
; <rdf:type rdf:resource="http://www.w3.org/2006/vcard/ns#Pref" />
|
||||
; <rdf:value>800-555-1212</rdf:value>
|
||||
; </v:Tel>
|
||||
; </v:tel>
|
||||
;
|
||||
; <v:tel>
|
||||
; <v:Tel>
|
||||
; <rdf:type rdf:resource="http://www.w3.org/2006/vcard/ns#Cell" />
|
||||
; <rdf:value>800-555-1515</rdf:value>
|
||||
; </v:Tel>
|
||||
; </v:tel>
|
||||
;
|
||||
; <foaf:gender>male</foaf:gender>
|
||||
; <v:bday>1959-12-25</v:bday>
|
||||
; <v:email>bob.odenkirk@example.com</v:email>
|
||||
;
|
||||
; <sp:medicalRecordNumber>
|
||||
; <sp:Code>
|
||||
; <dcterms:title>My Hospital Record 2304575</dcterms:title>
|
||||
; <dcterms:identifier>2304575</dcterms:identifier>
|
||||
; <sp:system>My Hospital Record</sp:system>
|
||||
; </sp:Code>
|
||||
; </sp:medicalRecordNumber>
|
||||
;
|
||||
; </sp:Demographics>
|
||||
;</rdf:RDF><?xml version="1.0" encoding="utf-8"?>
|
||||
;<rdf:RDF
|
||||
; xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
; xmlns:sp="http://smartplatforms.org/terms#"
|
||||
; xmlns:dcterms="http://purl.org/dc/terms/"
|
||||
; xmlns:v="http://www.w3.org/2006/vcard/ns#"
|
||||
; xmlns:foaf="http://xmlns.com/foaf/0.1/">
|
||||
; <sp:Demographics>
|
||||
;
|
||||
; <v:n>
|
||||
; <v:Name>
|
||||
; <v:given-name>Bob</v:given-name>
|
||||
; <v:additional-name>J</v:additional-name>
|
||||
; <v:family-name>Odenkirk</v:family-name>
|
||||
; </v:Name>
|
||||
; </v:n>
|
||||
;
|
||||
; <v:adr>
|
||||
; <v:Address>
|
||||
; <rdf:type rdf:resource="http://www.w3.org/2006/vcard/ns#Home" />
|
||||
; <rdf:type rdf:resource="http://www.w3.org/2006/vcard/ns#Pref" />
|
||||
;
|
||||
; <v:street-address>15 Main St</v:street-address>
|
||||
; <v:extended-address>Apt 2</v:extended-address>
|
||||
; <v:locality>Wonderland</v:locality>
|
||||
; <v:region>OZ</v:region>
|
||||
; <v:postal-code>54321</v:postal-code>
|
||||
; <v:country>USA</v:country>
|
||||
; </v:Address>
|
||||
; </v:adr>
|
||||
;
|
||||
; <v:tel>
|
||||
; <v:Tel>
|
||||
; <rdf:type rdf:resource="http://www.w3.org/2006/vcard/ns#Home" />
|
||||
; <rdf:type rdf:resource="http://www.w3.org/2006/vcard/ns#Pref" />
|
||||
; <rdf:value>800-555-1212</rdf:value>
|
||||
; </v:Tel>
|
||||
; </v:tel>
|
||||
;
|
||||
; <v:tel>
|
||||
; <v:Tel>
|
||||
; <rdf:type rdf:resource="http://www.w3.org/2006/vcard/ns#Cell" />
|
||||
; <rdf:value>800-555-1515</rdf:value>
|
||||
; </v:Tel>
|
||||
; </v:tel>
|
||||
;
|
||||
; <foaf:gender>male</foaf:gender>
|
||||
; <v:bday>1959-12-25</v:bday>
|
||||
; <v:email>bob.odenkirk@example.com</v:email>
|
||||
;
|
||||
; <sp:medicalRecordNumber>
|
||||
; <sp:Code>
|
||||
; <dcterms:title>My Hospital Record 2304575</dcterms:title>
|
||||
; <dcterms:identifier>2304575</dcterms:identifier>
|
||||
; <sp:system>My Hospital Record</sp:system>
|
||||
; </sp:Code>
|
||||
; </sp:medicalRecordNumber>
|
||||
;
|
||||
; </sp:Demographics>
|
||||
;</rdf:RDF>
|
||||
;G(1)="nodeID:25591^rdf:type^v:Home"
|
||||
;G(2)="nodeID:25591^rdf:type^v:Pref"
|
||||
;G(3)="nodeID:25591^rdf:type^v:Tel"
|
||||
;G(4)="nodeID:25591^rdf:value^800-369-6403"
|
||||
;G(5)="nodeID:25611^rdf:type^v:Name"
|
||||
;G(6)="nodeID:25611^v:additional-name^N"
|
||||
;G(7)="nodeID:25611^v:family-name^Brooks"
|
||||
;G(8)="nodeID:25611^v:given-name^Brian"
|
||||
;G(9)="nodeID:25622^dcterms:identifier^981968"
|
||||
;G(10)="nodeID:25622^dcterms:title^My Hospital Record 981968"
|
||||
;G(11)="nodeID:25622^rdf:type^sp:Code"
|
||||
;G(12)="nodeID:25622^sp:system^My Hospital Record"
|
||||
;G(13)="nodeID:25623^rdf:type^v:Address"
|
||||
;G(14)="nodeID:25623^rdf:type^v:Home"
|
||||
;G(15)="nodeID:25623^rdf:type^v:Pref"
|
||||
;G(16)="nodeID:25623^v:locality^Bixby"
|
||||
;G(17)="nodeID:25623^v:postal-code^74008"
|
||||
;G(18)="nodeID:25623^v:region^OK"
|
||||
;G(19)="nodeID:25623^v:street-address^82 Lake St"
|
||||
;G(20)="smart:981968/demographics^foaf:gender^male"
|
||||
;G(21)="smart:981968/demographics^rdf:type^sp:Demographics"
|
||||
;G(22)="smart:981968/demographics^sp:belongsTo^smart:981968"
|
||||
;G(23)="smart:981968/demographics^sp:medicalRecordNumber^nodeID:25622"
|
||||
;G(24)="smart:981968/demographics^v:adr^nodeID:25623"
|
||||
;G(25)="smart:981968/demographics^v:bday^1956-03-23"
|
||||
;G(26)="smart:981968/demographics^v:email^brian.brooks@example.com"
|
||||
;G(27)="smart:981968/demographics^v:n^nodeID:25611"
|
||||
;G(28)="smart:981968/demographics^v:tel^nodeID:25591"
|
||||
Q
|
||||
;
|
||||
PATIENT(GRTN,C0SARY) ; GRTN, passed by reference,
|
||||
; is the return name of the graph created. "" if none
|
||||
; C0SARY is passed in by reference and is the NHIN array of patient
|
||||
;
|
||||
I $O(C0SARY("patient",""))="" D Q ;
|
||||
. I $D(DEBUG) W !,"No Patient array"
|
||||
. S GRTN=""
|
||||
S GRTN="" ; default to no patient
|
||||
N C0SGRF
|
||||
S C0SGRF="vistaSmart:"_ZPATID_"/patient"
|
||||
S ZPAT=C0SGRF ; subject is the same as the graph name
|
||||
I $D(DEBUG) W !,"Processing ",C0SGRF
|
||||
D DELGRAPH^C0XF2N(C0SGRF) ; delete the old graph
|
||||
D INITFARY^C0XF2N("C0XFARY") ; which triple store to use
|
||||
N FARY S FARY="C0XFARY"
|
||||
D USEFARY^C0XF2N(FARY)
|
||||
D VOCINIT^C0XUTIL
|
||||
;
|
||||
N ZPN,ZR
|
||||
D STARTADD^C0XF2N
|
||||
;
|
||||
; First do the base demographic graph
|
||||
;
|
||||
S ZPN=$NA(C0SARY("patient",1)) ; name of predicate array for this patient
|
||||
N SEX S SEX=$G(@ZPN@("gender@value"))
|
||||
I SEX="M" S SEX="male"
|
||||
I SEX="F" S SEX="female"
|
||||
S ZR("foaf:gender")=SEX
|
||||
S ZR("rdf:type")="sp:Demographics"
|
||||
S ZR("sp:belongsTo")=ZPAT
|
||||
N PATIENT
|
||||
S PATIENT=$P(ZPAT,"#",2)
|
||||
I $D(DEBUG) W !,"PROCESSING PATIENT ",PATIENT
|
||||
N NMREC S NMREC=$$ANONS^C0XF2N ; new anonomous subject for med rec graph
|
||||
S ZR("sp:medicalRecordNumber")=NMREC
|
||||
N NVADR S NVADR=$$ANONS^C0XF2N ; for address
|
||||
S ZR("v:adr")=NVADR
|
||||
N NNAME S NNAME=$$ANONS^C0XF2N ; for name
|
||||
S ZR("v:n")=NNAME
|
||||
N NTEL S NTEL=$$ANONS^C0XF2N ; for telephone
|
||||
I $D(@ZPN@("telecomList.telecom@value")) S ZR("v:tel")=NTEL ; only if exists
|
||||
N BDATE
|
||||
S ZX=""
|
||||
S ZX=$G(@ZPN@("dob@value")) ; date of birth in fileman format
|
||||
S BDATE=$$FMTE^XLFDT(ZX,"7D") ; ordered date
|
||||
S BDATE=$TR(BDATE,"/","-") ; change slashes to hyphens
|
||||
I BDATE="" S BDATE="UNKNOWN"
|
||||
N Z2,Z3
|
||||
S Z2=$P(BDATE,"-",2)
|
||||
S Z3=$P(BDATE,"-",3)
|
||||
I $L(Z2)=1 S $P(BDATE,"-",2)="0"_Z2
|
||||
I $L(Z3)=1 S $P(BDATE,"-",3)="0"_Z3
|
||||
S ZR("v:bday")=BDATE
|
||||
I $D(C0SVISTA) D ;
|
||||
. S ZR("vista:SSN")=$G(@ZPN@("ssn@value")) ; SSN
|
||||
. S ZR("vista:DFN")=$G(@ZPN@("id@value")) ; DFN
|
||||
D ADDINN^C0XF2N(C0SGRF,ZPAT,.ZR) ; create base graph
|
||||
K ZR
|
||||
;
|
||||
; create address sub-graph
|
||||
;
|
||||
S ZR("rdf:type")="v:Address"
|
||||
S ZR("rdf:type")="v:Home"
|
||||
S ZR("v:locality")=$G(@ZPN@("address@city"))
|
||||
S ZR("v:postal-code")=$G(@ZPN@("address@postalCode"))
|
||||
S ZR("v:region")=$G(@ZPN@("address@stateProvince"))
|
||||
S ZR("v:street-address")=$G(@ZPN@("address@streetLine1"))
|
||||
D ADDINN^C0XF2N(C0SGRF,NVADR,.ZR) ; create the vcard address
|
||||
K ZR
|
||||
;
|
||||
; create medical record subgraph
|
||||
;
|
||||
S ZR("dcterms:identifier")=$G(@ZPN@("id@value"))
|
||||
S ZR("dcterms:title")="VistA Patient Record "_ZR("dcterms:identifier")
|
||||
S ZR("rdf:type")="sp:Code"
|
||||
S ZR("sp:system")="VistA Patient Record"
|
||||
D ADDINN^C0XF2N(C0SGRF,NMREC,.ZR) ; create medical record graph
|
||||
K ZR
|
||||
;
|
||||
; create name subgraph
|
||||
;
|
||||
N ZNF,ZNL,ZNM,ZNAM
|
||||
S ZR("rdf:type")="v:Name"
|
||||
S ZX=$G(@ZPN@("givenNames@value")) ; first name and middle names
|
||||
S ZNF=$P(ZX," ",1) ; first name is first piece
|
||||
S ZNM=$P(ZX," ",2) ; middle names are the rest
|
||||
S ZR("v:additional-name")=ZNM
|
||||
S ZR("v:family-name")=$G(@ZPN@("familyName@value"))
|
||||
S ZR("v:given-name")=ZNF
|
||||
D ADDINN^C0XF2N(C0SGRF,NNAME,.ZR) ; insert name graph
|
||||
K ZR
|
||||
;
|
||||
; create telephone subgraph
|
||||
;
|
||||
D ;
|
||||
. S ZR("rdf:value")=$G(@ZPN@("telecomList.telecom@value"))
|
||||
. I ZR("rdf:value")="" Q ; telephone number missing, no subgraph
|
||||
. S ZR("rdf:type")="v:Tel"
|
||||
. D ADDINN^C0XF2N(C0SGRF,NTEL,.ZR)
|
||||
K ZR
|
||||
;
|
||||
; load the demographics graph and all sub graphs to the triple store
|
||||
;
|
||||
D BULKLOAD^C0XF2N(.C0XFDA)
|
||||
S GRTN=C0SGRF
|
||||
Q
|
||||
;
|
||||
AGES ; LIST ALL PATIENTS AND THEIR AGES
|
||||
N ZI S ZI=0
|
||||
F S ZI=$O(^DPT(ZI)) Q:+ZI=0 D ; FOR EVERY PATIENT
|
||||
. N ZDOB
|
||||
. S ZDOB=$$GET1^DIQ(2,ZI_",","DOB","I") ; FILEMAN DOB
|
||||
. N ZNAME
|
||||
. S ZNAME=$P(^DPT(ZI,0),U)
|
||||
. N ZSEX
|
||||
. S ZSEX=$$GET1^DIQ(2,ZI_",","SEX")
|
||||
. W !,"DFN:",ZI," ",ZNAME," AGE: ",+$$BRIEF^VWTIME(ZDOB)," YEAR OLD ",ZSEX
|
||||
Q
|
||||
;
|
|
@ -0,0 +1,320 @@
|
|||
C0SDOM ; GPL - Smart Container - DOM PROCESSING ROUTINES ;6/6/11 17:05
|
||||
;;0.1;C0S;nopatch;noreleasedate;Build 2
|
||||
;Copyright 2011,2012 George Lilly. Licensed under the terms of the GNU
|
||||
;General Public License See attached copy of the License.
|
||||
;
|
||||
;This program is free software; you can redistribute it and/or modify
|
||||
;it under the terms of the GNU General Public License as published by
|
||||
;the Free Software Foundation; either version 2 of the License, or
|
||||
;(at your option) any later version.
|
||||
;
|
||||
|
||||
;This program is distributed in the hope that it will be useful,
|
||||
;but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;GNU General Public License for more details.
|
||||
;
|
||||
;You should have received a copy of the GNU General Public License along
|
||||
;with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
;
|
||||
Q
|
||||
;
|
||||
DOMO(ZOID,ZPATH,ZNARY,ZXIDX,ZXPARY,ZNUM,ZREDUX) ; RECURSIVE ROUTINE TO POPULATE
|
||||
; THE XPATH INDEX ZXIDX, PASSED BY NAME
|
||||
; THE XPATH ARRAY XPARY, PASSED BY NAME
|
||||
; ZOID IS THE STARTING OID
|
||||
; ZPATH IS THE STARTING XPATH, USUALLY "/"
|
||||
; ZNUM IS THE MULTIPLE NUMBER [x], USUALLY NULL WHEN ON THE TOP NODE
|
||||
; ZREDUX IS THE XPATH REDUCTION STRING, TAKEN OUT OF EACH XPATH IF PRESENT
|
||||
I $G(ZREDUX)="" S ZREDUX=""
|
||||
N NEWPATH,NARY ; NEWPATH IS AN XPATH NARY IS AN NHIN MUMPS ARRAY
|
||||
N NEWNUM S NEWNUM=""
|
||||
I $G(ZNUM)>0 S NEWNUM="["_ZNUM_"]"
|
||||
S NEWPATH=ZPATH_"/"_$$TAG(ZOID)_NEWNUM ; CREATE THE XPATH FOR THIS NODE
|
||||
I $G(ZREDUX)'="" D ; REDUX PROVIDED?
|
||||
. N GT S GT=$P(NEWPATH,ZREDUX,2)
|
||||
. I GT'="" S NEWPATH=GT
|
||||
S @ZXIDX@(NEWPATH)=ZOID ; ADD THE XPATH FOR THIS NODE TO THE XPATH INDEX
|
||||
N GA D ATT("GA",ZOID) ; GET ATTRIBUTES FOR THIS NODE
|
||||
I $D(GA) D ; PROCESS THE ATTRIBUTES
|
||||
. N ZI S ZI=""
|
||||
. F S ZI=$O(GA(ZI)) Q:ZI="" D ; FOR EACH ATTRIBUTE
|
||||
. . N ZP S ZP=NEWPATH_"@"_ZI ; PATH FOR ATTRIBUTE
|
||||
. . S @ZXPARY@(ZP)=GA(ZI) ; ADD THE ATTRIBUTE XPATH TO THE XP ARRAY
|
||||
. . I GA(ZI)'="" D ADDNARY(ZP,GA(ZI)) ; ADD THE NHIN ARRAY VALUE
|
||||
N GD D DATA("GD",ZOID) ; SEE IF THERE IS DATA FOR THIS NODE
|
||||
I $D(GD(2)) D ;
|
||||
. M @ZXPARY@(NEWPATH)=GD ; IF MULITPLE DATA MERGE TO THE ARRAY
|
||||
E I $D(GD(1)) D ;
|
||||
. S @ZXPARY@(NEWPATH)=GD(1) ; IF SINGLE VALUE, ADD TO ARRAY
|
||||
. I GD(1)'="" D ADDNARY(NEWPATH,GD(1)) ; ADD TO NHIN ARRAY
|
||||
N ZFRST S ZFRST=$$FIRST(ZOID) ; SET FIRST CHILD
|
||||
I ZFRST'=0 D ; THERE IS A CHILD
|
||||
. N ZNUM
|
||||
. N ZMULT S ZMULT=$$ISMULT(ZFRST) ; IS FIRST CHILD A MULTIPLE
|
||||
. D DOMO(ZFRST,NEWPATH,ZNARY,ZXIDX,ZXPARY,$S(ZMULT:1,1:""),ZREDUX) ; THE CHILD
|
||||
N GNXT S GNXT=$$NXTSIB(ZOID)
|
||||
I $$TAG(GNXT)'=$$TAG(ZOID) S ZNUM="" ; RESET COUNTING AFTER MULTIPLES
|
||||
I GNXT'=0 D ;
|
||||
. N ZMULT S ZMULT=$$ISMULT(GNXT) ; IS THE SIBLING A MULTIPLE?
|
||||
. I (ZNUM="")&(ZMULT) D ; SIBLING IS FIRST OF MULTIPLES
|
||||
. . N ZNUM S ZNUM=1 ;
|
||||
. . D DOMO(GNXT,ZPATH,ZNARY,ZXIDX,ZXPARY,ZNUM,ZREDUX) ; DO NEXT SIB
|
||||
. E D DOMO(GNXT,ZPATH,ZNARY,ZXIDX,ZXPARY,$S(ZNUM>0:ZNUM+1,1:""),ZREDUX) ; SIB
|
||||
Q
|
||||
;
|
||||
ADDNARY(ZXP,ZVALUE) ; ADD AN NHIN ARRAY VALUE TO ZNARY
|
||||
;
|
||||
; IF ZATT=1 THE ARRAY IS ADDED AS ATTRIBUTES
|
||||
;
|
||||
N ZZI,ZZJ,ZZN
|
||||
S ZZI=$P(ZXP,"/",1) ; FIRST PIECE OF XPATH ARRAY
|
||||
I ZZI="" Q ; DON'T ADD THIS ONE .. PROBABLY THE //results NODE
|
||||
S ZZJ=$P(ZXP,ZZI_"/",2) ; REST OF XPATH ARRAY
|
||||
S ZZJ=$TR(ZZJ,"/",".") ; REPLACE / WITH .
|
||||
I ZZI'["]" D ; A SINGLETON
|
||||
. S ZZN=1
|
||||
E D ; THERE IS AN [x] OCCURANCE
|
||||
. S ZZN=$P($P(ZZI,"[",2),"]",1) ; PULL OUT THE OCCURANCE
|
||||
. S ZZI=$P(ZZI,"[",1) ; TAKE OUT THE [X]
|
||||
I ZZJ'="" D ; TIME TO ADD THE VALUE
|
||||
. S @ZNARY@(ZZI,ZZN,ZZJ)=ZVALUE
|
||||
Q
|
||||
;
|
||||
PARSE(INXML,INDOC) ;CALL THE MXML PARSER ON INXML, PASSED BY NAME
|
||||
; INDOC IS PASSED AS THE DOCUMENT NAME - DON'T KNOW WHERE TO STORE THIS NOW
|
||||
; EXTRINSIC WHICH RETURNS THE DOCID ASSIGNED BY MXML
|
||||
;Q $$EN^MXMLDOM(INXML)
|
||||
Q $$EN^MXMLDOM(INXML,"W")
|
||||
;
|
||||
ISMULT(ZOID) ; RETURN TRUE IF ZOID IS ONE OF A MULTIPLE
|
||||
N ZN
|
||||
;I $$TAG(ZOID)["entry" B
|
||||
S ZN=$$NXTSIB(ZOID)
|
||||
I ZN'="" Q $$TAG(ZOID)=$$TAG(ZN) ; IF TAG IS THE SAME AS NEXT SIB TAG
|
||||
Q 0
|
||||
;
|
||||
FIRST(ZOID) ;RETURNS THE OID OF THE FIRST CHILD OF ZOID
|
||||
Q $$CHILD^MXMLDOM(C0SDOCID,ZOID)
|
||||
;
|
||||
PARENT(ZOID) ;RETURNS THE OID OF THE PARENT OF ZOID
|
||||
Q $$PARENT^MXMLDOM(C0SDOCID,ZOID)
|
||||
;
|
||||
ATT(RTN,NODE) ;GET ATTRIBUTES FOR ZOID
|
||||
S HANDLE=C0SDOCID
|
||||
K @RTN
|
||||
D GETTXT^MXMLDOM("A")
|
||||
Q
|
||||
;
|
||||
TAG(ZOID) ; RETURNS THE XML TAG FOR THE NODE
|
||||
;I ZOID=149 B ;GPLTEST
|
||||
N X,Y
|
||||
S Y=""
|
||||
S X=$G(C0SCBK("TAG")) ;IS THERE A CALLBACK FOR THIS ROUTINE
|
||||
I X'="" X X ; EXECUTE THE CALLBACK, SHOULD SET Y
|
||||
I Y="" S Y=$$NAME^MXMLDOM(C0SDOCID,ZOID)
|
||||
Q Y
|
||||
;
|
||||
NXTSIB(ZOID) ; RETURNS THE NEXT SIBLING
|
||||
Q $$SIBLING^MXMLDOM(C0SDOCID,ZOID)
|
||||
;
|
||||
DATA(ZT,ZOID) ; RETURNS DATA FOR THE NODE
|
||||
;N ZT,ZN S ZT=""
|
||||
;S C0SDOM=$NA(^TMP("MXMLDOM",$J,C0SDOCID))
|
||||
;Q $G(@C0SDOM@(ZOID,"T",1))
|
||||
S ZN=$$TEXT^MXMLDOM(C0SDOCID,ZOID,ZT)
|
||||
Q
|
||||
;
|
||||
OUTXML(ZRTN,INID,NO1ST) ; USES C0SMXMLB (MXMLBLD) TO OUTPUT XML FROM AN MXMLDOM
|
||||
;
|
||||
S C0SDOCID=INID
|
||||
I '$D(NO1ST) S NO1ST=0 ; DO NOT SURPRESS THE <?xml tag generation
|
||||
D START^C0SMXMLB($$TAG(1),,"G",NO1ST)
|
||||
D NDOUT($$FIRST(1))
|
||||
D END^C0SMXMLB ;END THE DOCUMENT
|
||||
M @ZRTN=^TMP("MXMLBLD",$J)
|
||||
K ^TMP("MXMLBLD",$J)
|
||||
Q
|
||||
;
|
||||
NDOUT(ZOID) ;CALLBACK ROUTINE - IT IS RECURSIVE
|
||||
N ZI S ZI=$$FIRST(ZOID)
|
||||
I ZI'=0 D ; THERE IS A CHILD
|
||||
. N ZATT D ATT("ZATT",ZOID) ; THESE ARE THE ATTRIBUTES MOVED TO ZATT
|
||||
. D MULTI^C0SMXMLB("",$$TAG(ZOID),.ZATT,"NDOUT^C0SMXML(ZI)") ;HAVE CHILDREN
|
||||
E D ; NO CHILD - IF NO CHILDREN, A NODE HAS DATA, IS AN ENDPOINT
|
||||
. ;W "DOING",ZOID,!
|
||||
. N ZD D DATA("ZD",ZOID) ;NODES WITHOUT CHILDREN HAVE DATA
|
||||
. N ZATT D ATT("ZATT",ZOID) ;ATTRIBUTES
|
||||
. D ITEM^C0SMXMLB("",$$TAG(ZOID),.ZATT,$G(ZD(1))) ;NO CHILDREN
|
||||
I $$NXTSIB(ZOID)'=0 D ; THERE IS A SIBLING
|
||||
. D NDOUT($$NXTSIB(ZOID)) ;RECURSE FOR SIBLINGS
|
||||
Q
|
||||
;
|
||||
WNHIN(ZDFN) ; WRITES THE XML OUTPUT OF GET^NHINV TO AN XML FILE
|
||||
;
|
||||
N GN,GN2
|
||||
D GET^NHINV(.GN,ZDFN) ; EXTRACT THE XML
|
||||
S GN2=$NA(@GN@(1))
|
||||
W $$OUTPUT^C0SXPATH(GN2,"nhin_"_ZDFN_".xml","/home/wvehr3-09/")
|
||||
Q
|
||||
;
|
||||
NARY2XML(ZGOUT,ZGIN) ; CREATE XML FROM AN NHIN ARRAY
|
||||
; ZGOUT AND ZGIN ARE PASSED BY NAME
|
||||
N C0SDOCID
|
||||
W !,ZGOUT," ",ZGIN
|
||||
S C0SDOCID=$$DOMI(ZGIN) ; PUT IT INTO THE DOM
|
||||
D OUTXML(ZGOUT,C0SDOCID)
|
||||
Q
|
||||
;
|
||||
; EXAMPLE OF NHIN ARRAY FORMAT - THIS IS AN OUTPUT OF DOMO ABOVE WHEN RUN
|
||||
; AGAINST THE OUTPUT OF THE GET^NHINV ROUTINE. (THIS IS NOT REAL PATIENT DATA)
|
||||
;
|
||||
;GNARY("med",1,"doses.dose@dose")=10
|
||||
;GNARY("med",1,"doses.dose@noun")="TABLET"
|
||||
;GNARY("med",1,"doses.dose@route")="PO"
|
||||
;GNARY("med",1,"doses.dose@schedule")="QD"
|
||||
;GNARY("med",1,"doses.dose@units")="MG"
|
||||
;GNARY("med",1,"doses.dose@unitsPerDose")=1
|
||||
;GNARY("med",1,"facility@code")=100
|
||||
;GNARY("med",1,"facility@name")="VOE OFFICE INSTITUTION"
|
||||
;GNARY("med",1,"form@value")="TAB"
|
||||
;GNARY("med",1,"id@value")="1N;O"
|
||||
;GNARY("med",1,"location@code")=5
|
||||
;GNARY("med",1,"location@name")="3 WEST"
|
||||
;GNARY("med",1,"name@value")="LISINOPRIL TAB"
|
||||
;GNARY("med",1,"orderID@value")=294
|
||||
;GNARY("med",1,"ordered@value")=3110531.001233
|
||||
;GNARY("med",1,"orderingProvider@code")=63
|
||||
;GNARY("med",1,"orderingProvider@name")="KING,MATTHEW MICHAEL"
|
||||
;GNARY("med",1,"products.product.class@code")="ACE INHIBITORS"
|
||||
;GNARY("med",1,"products.product.vaGeneric@code")=1990
|
||||
;GNARY("med",1,"products.product.vaGeneric@name")="LISINOPRIL"
|
||||
;GNARY("med",1,"products.product.vaGeneric@vuid")=4019380
|
||||
;GNARY("med",1,"products.product.vaProduct@code")=8118
|
||||
;GNARY("med",1,"products.product.vaProduct@name")="LISINOPRIL 10MG TAB"
|
||||
;GNARY("med",1,"products.product.vaProduct@vuid")=4008593
|
||||
;GNARY("med",1,"products.product@code")=6174
|
||||
;GNARY("med",1,"products.product@name")="LISINOPRIL 10MG U/D"
|
||||
;GNARY("med",1,"products.product@role")="D"
|
||||
;GNARY("med",1,"sig")="10MG BY MOUTH EVERY DAY"
|
||||
;GNARY("med",1,"sig@xml:space")="preserve"
|
||||
;GNARY("med",1,"status@value")="active"
|
||||
;GNARY("med",1,"type@value")="OTC"
|
||||
;GNARY("med",1,"vaType@value")="N"
|
||||
;
|
||||
; DOMI is an extrinsic to insert NHIN ARRAY FORMAT arrays into the DOM
|
||||
; it returns 0 or 1 based on success.
|
||||
;
|
||||
; INARY is passed by name and has the format shown above
|
||||
; HANDLE is the document number in the DOM (both MXML and EWD DOMs will
|
||||
; be supported eventually - initial implementation is for MXML
|
||||
;
|
||||
; PARENT is the node id or tag of the parent under which the DOM will
|
||||
; be populated. If it is numeric, it is a node. If it is a string, the DOM
|
||||
; will be searched to find the tag. If not found and there is no root,
|
||||
; it will be inserted as the root. If not found and there is a root, it
|
||||
; will be inserted under the root.
|
||||
;
|
||||
; For the above example the call would be OK=$$DOMI("GNARY",0,"results")
|
||||
; because "results" is the root tag. Use OUTXML to render the xml from
|
||||
; the DOM.
|
||||
;
|
||||
DOMI(INARY,HANDLE,PARENT) ; EXTRINSIC TO INSERT NHIN ARRAYS TO A DOM
|
||||
;
|
||||
N ZPARNODE
|
||||
S (SUCCESS,LEVEL,LEVEL(0),NODE)=0
|
||||
I '$D(INARY) Q 0 ; NO ARRAY PASSED
|
||||
I '$D(HANDLE) S HANDLE=$$NEWDOM() ; MAKE A NEW DOM
|
||||
;I PARENT="" S PARENT="root"
|
||||
I +$G(PARENT)>0 S ZPARNODE=PARENT ; WE HAVE BEEN PASSED A PARENT NODE ID
|
||||
E I $L($G(PARENT))>0 D ; TBD FIND THE PARENT IN THE DOM AND SET LEVEL
|
||||
. D STARTELE^MXMLDOM(PARENT) ; INSERT THE PARENT NODE
|
||||
. S ZPARNODE=1 ;
|
||||
; WE NOW HAVE A HANDLE AND A PARENT NODE AND LEVEL HAS BEEN SET
|
||||
N ZEXARY
|
||||
D EXPAND("ZEXARY",INARY) ; EXPAND THE NHIN ARRAY
|
||||
D MAJOR("ZEXARY") ; PROCESS ALL THE NODES TO BE ADDED
|
||||
I $L($G(PARENT))>0 D ENDELE^MXMLDOM(PARENT) ; CLOSE OUT THE PARENT NODE
|
||||
Q HANDLE ; SUCCESS
|
||||
;
|
||||
MAJOR(ZARY) ; RECURSIVE ROUTINE FOR INTERMEDIATE NODES
|
||||
N ZI S ZI=""
|
||||
N ZTAG
|
||||
F S ZI=$O(@ZARY@(ZI)) Q:ZI="" D ; FOR EACH SECTION
|
||||
. N ZELEADD S ZELEADD=0
|
||||
. I ZI["@" D ; END NODE HAS NO VALUE, ONLY ATTRIBUTES
|
||||
. . S ZTAG=$P(ZI,"@",1) ; PULL OUT THE TAG
|
||||
. . K ZATT ; CLEAR OUT LAST ONE
|
||||
. . M ZATT=@ZARY@(ZI,1) ; GET ATTRIBUTE ARRAY
|
||||
. . D STARTELE^MXMLDOM(ZTAG,.ZATT) ; ADD THE NODE
|
||||
. . S ZELEADD=1 ; FLAG TO NOT ADD THE ELEMENT TWICE
|
||||
. I $O(@ZARY@(ZI,""))="" D ;END NODE
|
||||
. . S ZTAG=ZI ; USE ZI FOR THE TAG
|
||||
. . I 'ZELEADD D STARTELE^MXMLDOM(ZTAG) ; ADD ELEMENT IF NOT THERE
|
||||
. . S ZELEADD=1 ; ADDED AN ELEMENT
|
||||
. . D CHAR^MXMLDOM($G(@ZARY@(ZI))) ; INSERT THE VALUE
|
||||
. I ZELEADD D Q ; NO MORE TO DO ON THIS LEVEL
|
||||
. . D ENDELE^MXMLDOM(ZTAG) ; CLOSE THE ELEMENT BEFORE LEAVING
|
||||
. N NEWARY ; INDENTED ARRAY
|
||||
. N ZN S ZN=0
|
||||
. F S ZN=$O(@ZARY@(ZI,ZN)) Q:ZN="" D ; FOR EACH MULTIPLE
|
||||
. . D STARTELE^MXMLDOM(ZI) ; ADD THE INTERMEDIATE TAG
|
||||
. . S NEWARY=$NA(@ZARY@(ZI,ZN)) ; INDENT THE ARRAY
|
||||
. . D MAJOR(NEWARY) ; RECURSE FOR INDENTED ARRAY
|
||||
. . D ENDELE^MXMLDOM(ZI) ; END THE INTERMEDIATE TAG
|
||||
Q
|
||||
;
|
||||
EXPAND(ZZOUT,ZZIN) ; EXPANDS NHIN ARRAY FORMAT TO AN EXPANDED
|
||||
; CONSISTENT FORMAT
|
||||
; GNARY("patient",1,"facilities[2].facility@code")="050"
|
||||
; becomes G2ARY("patient",1,"facilities",2,"facility@",1,"code")="050"
|
||||
; for easier processing (this is fileman format genius)
|
||||
; basically removes the dot notation from the strings
|
||||
;
|
||||
N ZZI
|
||||
S ZZI=""
|
||||
F S ZZI=$O(@ZZIN@(ZZI)) Q:ZZI="" D ;
|
||||
. N ZZN S ZZN=0
|
||||
. F S ZZN=$O(@ZZIN@(ZZI,ZZN)) Q:ZZN="" D ;
|
||||
. . N ZZS S ZZS=""
|
||||
. . N GA ;PUSH STACK
|
||||
. . F S ZZS=$O(@ZZIN@(ZZI,ZZN,ZZS)) Q:ZZS="" D ;
|
||||
. . . K GA ; NEW STACK
|
||||
. . . D PUSH^C0SXPATH("GA",ZZI_"^"_ZZN) ; PUSH PARENT
|
||||
. . . N ZZV ; PLACE TO STASH THE VALUE
|
||||
. . . S ZZV=@ZZIN@(ZZI,ZZN,ZZS) ; VALUE
|
||||
. . . W !,"VALUE:",ZZV
|
||||
. . . N GK ; COUNTER
|
||||
. . . F GK=1:1:$L(ZZS,".") D ; FOR EACH INTERMEDIATE NODE
|
||||
. . . . N ZZN2 S ZZN2=1 ; DEFAULT IF NO [X]
|
||||
. . . . N GM S GM=$P(ZZS,".",GK) ; TAG
|
||||
. . . . I GM["[" D ; IT'S A MULTIPLE
|
||||
. . . . . S ZZN2=$P($P(GM,"[",2),"]",1) ; PULL OUT THE NUMBER
|
||||
. . . . . S GM=$P(GM,"[",1) ; PULL OUT THE TAG
|
||||
. . . . I GM["@" D ; IT'S GOT ATTRIBUTES
|
||||
. . . . . N GM2 S GM2=$P(GM,"@",2) ; PULLOUT THE ATTRIBUTE NAME
|
||||
. . . . . D PUSH^C0SXPATH("GA",$P(GM,"@",1)_"@"_"^"_ZZN2) ; PUSH THE TAG
|
||||
. . . . . D PUSH^C0SXPATH("GA",GM2_"^"_ZZN2)
|
||||
. . . . E D PUSH^C0SXPATH("GA",GM_"^"_ZZN2) ;
|
||||
. . . S GA(GA(0))=$P(GA(GA(0)),"^",1)_"^" ; GET RID OF THE LAST "1"
|
||||
. . . N GZI S GZI="" ; STRING FOR THE INDEX
|
||||
. . . F GK=1:1:GA(0) D ; TIME TO REVERSE POP THE TAGS
|
||||
. . . . S GM=$P(GA(GK),"^",1) ; THE TAG
|
||||
. . . . S ZZN2=$P(GA(GK),"^",2) ; THE NUMBER IF ANY
|
||||
. . . . I ZZN2="" S GZI=GZI_""""_GM_"""" ; FOR THE LAST ONE
|
||||
. . . . E S GZI=GZI_""""_GM_""""_","_ZZN2_"," ; FOR THE REST
|
||||
. . . S GZI2=ZZOUT_"("_GZI_")" ; INCLUDE THE ARRAY NAME
|
||||
. . . W !,GZI
|
||||
. . . S @GZI2=ZZV ; REMEMBER THE VALUE?
|
||||
Q
|
||||
;
|
||||
NEWDOM() ; extrinsic which creates a new DOM and returns the HANDLE
|
||||
N CBK,SUCCESS,LEVEL,NODE,HANDLE
|
||||
K ^TMP("MXMLERR",$J)
|
||||
L +^TMP("MXMLDOM",$J):5
|
||||
E Q 0
|
||||
S HANDLE=$O(^TMP("MXMLDOM",$J,""),-1)+1,^(HANDLE)=""
|
||||
L -^TMP("MXMLDOM",$J)
|
||||
Q HANDLE
|
||||
;
|
|
@ -0,0 +1,275 @@
|
|||
C0SLAB ; GPL - Smart Lab Processing ;4/15/12 17:05
|
||||
;;0.1;C0S;nopatch;noreleasedate;Build 2
|
||||
;Copyright 2012 George Lilly. Licensed under the terms of the GNU
|
||||
;General Public License See attached copy of the License.
|
||||
;
|
||||
;This program is free software; you can redistribute it and/or modify
|
||||
;it under the terms of the GNU General Public License as published by
|
||||
;the Free Software Foundation; either version 2 of the License, or
|
||||
;(at your option) any later version.
|
||||
;
|
||||
;This program is distributed in the hope that it will be useful,
|
||||
;but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;GNU General Public License for more details.
|
||||
;
|
||||
;You should have received a copy of the GNU General Public License along
|
||||
;with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
;
|
||||
Q
|
||||
;
|
||||
; sample VistA NHIN lab result
|
||||
;
|
||||
;^TMP("C0STBL",32,"lab",8,"collected@value")=3110626.16
|
||||
;^TMP("C0STBL",32,"lab",8,"comment")="Report Released Date/Time: Jun 26, 2011@19:00"
|
||||
;^TMP("C0STBL",32,"lab",8,"comment@xml:space")="preserve"
|
||||
;^TMP("C0STBL",32,"lab",8,"facility@code")=100
|
||||
;^TMP("C0STBL",32,"lab",8,"facility@name")="VOE OFFICE INSTITUTION"
|
||||
;^TMP("C0STBL",32,"lab",8,"groupName@value")="CH 0626 47"
|
||||
;^TMP("C0STBL",32,"lab",8,"high@value")=" 101"
|
||||
;^TMP("C0STBL",32,"lab",8,"id@value")="CH;6889372.84;67003"
|
||||
;^TMP("C0STBL",32,"lab",8,"interpretation@value")="H"
|
||||
;^TMP("C0STBL",32,"lab",8,"labOrderID@value")=336
|
||||
;^TMP("C0STBL",32,"lab",8,"localName@value")="FBLDGLU"
|
||||
;^TMP("C0STBL",32,"lab",8,"loinc@value")="14771-0"
|
||||
;^TMP("C0STBL",32,"lab",8,"low@value")="69 "
|
||||
;^TMP("C0STBL",32,"lab",8,"orderID@value")=807
|
||||
;^TMP("C0STBL",32,"lab",8,"result@value")=178
|
||||
;^TMP("C0STBL",32,"lab",8,"resulted@value")=3110626.190006
|
||||
;^TMP("C0STBL",32,"lab",8,"sample@value")="SERUM"
|
||||
;^TMP("C0STBL",32,"lab",8,"specimen@code")="0X500"
|
||||
;^TMP("C0STBL",32,"lab",8,"specimen@name")="SERUM"
|
||||
;^TMP("C0STBL",32,"lab",8,"status@value")="completed"
|
||||
;^TMP("C0STBL",32,"lab",8,"test@value")="FASTING BLOOD GLUCOSE"
|
||||
;^TMP("C0STBL",32,"lab",8,"type@value")="CH"
|
||||
;^TMP("C0STBL",32,"lab",8,"units@value")="MG/DL"
|
||||
;^TMP("C0STBL",32,"lab",8,"vuid@value")=4656342
|
||||
;
|
||||
; sample Smart lab result triples
|
||||
;
|
||||
;G("loinc:29571-7","dcterms:identifier")="29571-7"
|
||||
;G("loinc:29571-7","dcterms:title")="Phe DBS Ql"
|
||||
;G("loinc:29571-7","rdf:type")="sp:Code"
|
||||
;G("loinc:29571-7","sp:system")="http://loinc.org/codes/"
|
||||
;G("loinc:38478-4","dcterms:identifier")="38478-4"
|
||||
;G("loinc:38478-4","dcterms:title")="Biotinidase DBS Ql"
|
||||
;G("loinc:38478-4","rdf:type")="sp:Code"
|
||||
;G("loinc:38478-4","sp:system")="http://loinc.org/codes/"
|
||||
;G("qqWZZIew993","rdf:type")="sp:Attribution"
|
||||
;G("qqWZZIew993","sp:startDate")="2007-04-21"
|
||||
;G("qqWZZIew994","rdf:type")="sp:NarrativeResult"
|
||||
;G("qqWZZIew994","sp:value")="Normal"
|
||||
;G("qqWZZIew995","dcterms:title")="Biotinidase DBS Ql"
|
||||
;G("qqWZZIew995","rdf:type")="sp:CodedValue"
|
||||
;G("qqWZZIew995","sp:code")="loinc:38478-4"
|
||||
;G("qqWZZIew997","rdf:type")="sp:Attribution"
|
||||
;G("qqWZZIew997","sp:startDate")="2007-09-08"
|
||||
;G("qqWZZIew998","rdf:type")="sp:NarrativeResult"
|
||||
;G("qqWZZIew998","sp:value")="Normal"
|
||||
;G("qqWZZIew999","dcterms:title")="Phe DBS Ql"
|
||||
;G("qqWZZIew999","rdf:type")="sp:CodedValue"
|
||||
;G("qqWZZIew999","sp:code")="loinc:29571-7"
|
||||
;G("smart:99912345/lab_results/3d9b39249193","rdf:type")="sp:LabResult"
|
||||
;G("smart:99912345/lab_results/3d9b39249193","sp:belongsTo")="smart:99912345"
|
||||
;G("smart:99912345/lab_results/3d9b39249193","sp:labName")="qqWZZIew995"
|
||||
;G("smart:99912345/lab_results/3d9b39249193","sp:narrativeResult")="qqWZZIew994"
|
||||
;G("smart:99912345/lab_results/3d9b39249193","sp:specimenCollected")="qqWZZIew993"
|
||||
;G("smart:99912345/lab_results/426c7adc4f54","rdf:type")="sp:LabResult"
|
||||
;G("smart:99912345/lab_results/426c7adc4f54","sp:belongsTo")="smart:99912345"
|
||||
;G("smart:99912345/lab_results/426c7adc4f54","sp:labName")="qqWZZIew999"
|
||||
;G("smart:99912345/lab_results/426c7adc4f54","sp:narrativeResult")="qqWZZIew998"
|
||||
;G("smart:99912345/lab_results/426c7adc4f54","sp:specimenCollected")="qqWZZIew997"
|
||||
;
|
||||
;
|
||||
; another Smart example, this one with sp:quantitativeResult
|
||||
;
|
||||
;G("loinc:786-4","dcterms:identifier")="786-4"
|
||||
;G("loinc:786-4","dcterms:title")="MCHC RBC Auto-mCnc"
|
||||
;G("loinc:786-4","rdf:type")="sp:Code"
|
||||
;G("loinc:786-4","sp:system")="http://loinc.org/codes/"
|
||||
;G("nodeID:4439","rdf:type")="sp:ValueAndUnit"
|
||||
;G("nodeID:4439","sp:unit")="g/dL"
|
||||
;G("nodeID:4439","sp:value")=36.6
|
||||
;G("nodeID:4613","rdf:type")="sp:ValueAndUnit"
|
||||
;G("nodeID:4613","sp:unit")="g/dL"
|
||||
;G("nodeID:4613","sp:value")=32
|
||||
;G("nodeID:4672","rdf:type")="sp:Attribution"
|
||||
;G("nodeID:4672","sp:startDate")="2005-03-10"
|
||||
;G("nodeID:4866","rdf:type")="sp:ValueAndUnit"
|
||||
;G("nodeID:4866","sp:unit")="g/dL"
|
||||
;G("nodeID:4866","sp:value")=36
|
||||
;G("nodeID:4871","dcterms:title")="MCHC RBC Auto-mCnc"
|
||||
;G("nodeID:4871","rdf:type")="sp:CodedValue"
|
||||
;G("nodeID:4871","sp:code")="loinc:786-4"
|
||||
;G("nodeID:5221","rdf:type")="sp:QuantitativeResult"
|
||||
;G("nodeID:5221","sp:normalRange")="nodeID:5282"
|
||||
;G("nodeID:5221","sp:valueAndUnit")="nodeID:4439"
|
||||
;G("nodeID:5282","rdf:type")="sp:ValueRange"
|
||||
;G("nodeID:5282","sp:maximum")="nodeID:4866"
|
||||
;G("nodeID:5282","sp:minimum")="nodeID:4613"
|
||||
;G("smart:1540505/lab_results/2fc100850766","rdf:type")="sp:LabResult"
|
||||
;G("smart:1540505/lab_results/2fc100850766","sp:belongsTo")="smart:1540505"
|
||||
;G("smart:1540505/lab_results/2fc100850766","sp:labName")="nodeID:4871"
|
||||
;G("smart:1540505/lab_results/2fc100850766","sp:quantitativeResult")="nodeID:5221"
|
||||
;G("smart:1540505/lab_results/2fc100850766","sp:specimenCollected")="nodeID:4672"
|
||||
;
|
||||
LAB(GRTN,C0SARY) ; GRTN, passed by reference,
|
||||
; is the return name of the graph created. "" if none
|
||||
; C0SARY is passed in by reference and is the NHIN array of lab
|
||||
;
|
||||
I $O(C0SARY("lab",""))="" D Q ;
|
||||
. I $D(DEBUG) W !,"No Labs"
|
||||
S GRTN="" ; default to no labs
|
||||
N C0SGRF
|
||||
S C0SGRF="vistaSmart:"_ZPATID_"/lab_results"
|
||||
I $D(DEBUG) W !,"Processing ",C0SGRF
|
||||
D DELGRAPH^C0XF2N(C0SGRF) ; delete the old graph
|
||||
D INITFARY^C0XF2N("C0XFARY") ; which triple store to use
|
||||
N FARY S FARY="C0XFARY"
|
||||
D USEFARY^C0XF2N(FARY)
|
||||
D VOCINIT^C0XUTIL
|
||||
;
|
||||
D STARTADD^C0XF2N ; initialize to create triples
|
||||
;
|
||||
N ZI S ZI=""
|
||||
F S ZI=$O(C0SARY("lab",ZI)) Q:ZI="" D ;
|
||||
. N LRN,ZR ; ZR is the local array for building the new triples
|
||||
. S LRN=$NA(C0SARY("lab",ZI)) ; base for values in this lab result
|
||||
. ;
|
||||
. N RSLTID ; unique Id for this lab result
|
||||
. S RSLTID=C0SGRF_"/"_$$LKY17^C0XF2N ; use a random number
|
||||
. ;
|
||||
. ; i don't like this because the same labs result gets a
|
||||
. ; different ID every time it's reported. Can't trace it back to VistA
|
||||
. ; I'd rather be using id@value ie "id@value")="CH;6889372.84;67003"
|
||||
. ; .. either that or store an OID with the lab result - but that
|
||||
. ; will have to wait for the redesign of file 60.. - gpl 4/16/2012
|
||||
. ;
|
||||
. N LOINC S LOINC=$G(@LRN@("loinc@value"))
|
||||
. I LOINC="" D Q ;
|
||||
. . I $D(DEBUG) W !,"NO LOINC VALUE, SKIPPING"
|
||||
. N LABTST S LABTST=$G(@LRN@("test@value"))
|
||||
. I $D(DEBUG) D ;
|
||||
. . W !,"Processing Lab Result ",RSLTID
|
||||
. . W !,"test: ",LABTST
|
||||
. . W !,"loinc: ",LOINC
|
||||
. ;
|
||||
. ; first do the base result graph
|
||||
. ;
|
||||
. S ZR("rdf:type")="sp:LabResult"
|
||||
. S ZR("sp:belongsTo")=C0SGRF ; the subject for this patient's lab results
|
||||
. ; ie /vista/smart/99912345/lab_results
|
||||
. ;
|
||||
. N LABNAME S LABNAME=$$ANONS^C0XF2N ; new node for lab name
|
||||
. S ZR("sp:labName")=LABNAME
|
||||
. ;
|
||||
. N NARRSLT S NARRSLT=$$ANONS^C0XF2N ; new node for narrative result
|
||||
. S ZR("sp:narrativeResult")=NARRSLT
|
||||
. ;
|
||||
. N QNTRSLT S QNTRSLT=$$ANONS^C0XF2N ; new node for narrative result
|
||||
. S ZR("sp:quantitativeResult")=QNTRSLT
|
||||
. ;
|
||||
. N SPECCOLL S SPECCOLL=$$ANONS^C0XF2N ; new node for specimen collected
|
||||
. S ZR("sp:specimenCollected")=SPECCOLL
|
||||
. ;
|
||||
. D ADDINN^C0XF2N(C0SGRF,RSLTID,.ZR) ; addIfNotNull the triples
|
||||
. K ZR ; clean up
|
||||
. ;
|
||||
. ; create the narrative result graph
|
||||
. ;
|
||||
. N IVAL S IVAL=$G(@LRN@("interpretation@value"))'="" D ; H OR L
|
||||
. I IVAL'=""
|
||||
. . S ZR("rdf:type")="sp:NarrativeResult"
|
||||
. . S ZR("sp:value")=$G(@LRN@("interpretation@value")) ; H or L
|
||||
. . I ZR("sp:value")="L" S ZR("sp:value")="abnormal"
|
||||
. . I ZR("sp:value")="H" S ZR("sp:value")="abnormal"
|
||||
. . I ZR("sp:value")="HH" S ZR("sp:value")="critical"
|
||||
. . I ZR("sp:value")="LL" S ZR("sp:value")="critical"
|
||||
. . D ADDINN^C0XF2N(C0SGRF,NARRSLT,.ZR)
|
||||
. . K ZR
|
||||
. ;
|
||||
. ; create the quantitative result graph
|
||||
. ;
|
||||
. S ZR("rdf:type")="sp:QuantitativeResult"
|
||||
. N NORMNM S NORMNM=$$ANONS^C0XF2N ; new node for normal range graph
|
||||
. N VUNM S VUNM=$$ANONS^C0XF2N ; new node for value and unit graph
|
||||
. N HASNORMAL S HASNORMAL=0
|
||||
. I $G(@LRN@("high@value"))'="" S HASNORMAL=1
|
||||
. I HASNORMAL S ZR("sp:normalRange")=NORMNM
|
||||
. S ZR("sp:valueAndUnit")=VUNM
|
||||
. D ADDINN^C0XF2N(C0SGRF,QNTRSLT,.ZR)
|
||||
. K ZR
|
||||
. ;
|
||||
. ; create the normal range graph
|
||||
. ;
|
||||
. I HASNORMAL D ;
|
||||
. . S ZR("rdf:type")="sp:ValueRange"
|
||||
. . N MAXNM S MAXNM=$$ANONS^C0XF2N ; new node for maximum graph
|
||||
. . N MINNM S MINNM=$$ANONS^C0XF2N ; new node for minimum graph
|
||||
. . S ZR("sp:maximum")=MAXNM
|
||||
. . S ZR("sp:minimum")=MINNM
|
||||
. . D ADDINN^C0XF2N(C0SGRF,NORMNM,.ZR)
|
||||
. . K ZR
|
||||
. . ;
|
||||
. . ; create the maximum graph
|
||||
. . ;
|
||||
. . S ZR("rdf:type")="sp:ValueAndUnit"
|
||||
. . S ZR("sp:unit")=$G(@LRN@("units@value"))
|
||||
. . S ZR("sp:value")=$G(@LRN@("high@value"))
|
||||
. . D ADDINN^C0XF2N(C0SGRF,MAXNM,.ZR)
|
||||
. . K ZR
|
||||
. . ;
|
||||
. . ; create the minimum graph
|
||||
. . ;
|
||||
. . S ZR("rdf:type")="sp:ValueAndUnit"
|
||||
. . S ZR("sp:unit")=$G(@LRN@("units@value"))
|
||||
. . S ZR("sp:value")=$G(@LRN@("low@value"))
|
||||
. . D ADDINN^C0XF2N(C0SGRF,MINNM,.ZR)
|
||||
. . K ZR
|
||||
. ;
|
||||
. ; create the value and unit graph
|
||||
. ;
|
||||
. S ZR("rdf:type")="sp:ValueAndUnit"
|
||||
. S ZR("sp:unit")=$G(@LRN@("units@value"))
|
||||
. I ZR("sp:unit")="" S ZR("sp:unit")=$G(@LRN@("test@value"))
|
||||
. S ZR("sp:value")=$G(@LRN@("result@value"))
|
||||
. D ADDINN^C0XF2N(C0SGRF,VUNM,.ZR)
|
||||
. K ZR
|
||||
. ;
|
||||
. ; create specimen collected graph
|
||||
. ;
|
||||
. S ZR("rdf:type")="sp:Attribution"
|
||||
. S ZR("sp:startDate")=$$SPDATE^C0SUTIL($G(@LRN@("collected@value")))
|
||||
. D ADDINN^C0XF2N(C0SGRF,SPECCOLL,.ZR)
|
||||
. K ZR
|
||||
. ;
|
||||
. ; create lab name graph - this contains the test name and code
|
||||
. ;
|
||||
. I LOINC'="" D ;
|
||||
. . S ZR("rdf:type")="sp:CodedValue"
|
||||
. . S ZR("dcterms:title")=LABTST
|
||||
. . N LOINCNM S LOINCNM="loinc:"_LOINC
|
||||
. . S ZR("sp:code")="loinc:"_LOINC
|
||||
. . D ADDINN^C0XF2N(C0SGRF,LABNAME,.ZR)
|
||||
. . K ZR
|
||||
. . S ZR("dcterms:identifier")=LOINC
|
||||
. . S ZR("dcterms:title")=LABTST
|
||||
. . S ZR("rdf:type")="sp:Code"
|
||||
. . S ZR("sp:system")="http://loinc.org/codes/"
|
||||
. . D ADDINN^C0XF2N(C0SGRF,LOINCNM,.ZR)
|
||||
. . K ZR
|
||||
. ;
|
||||
. ; that's all for now folks (there is more to do like reference ranges
|
||||
. ; and result values)
|
||||
. ;
|
||||
D BULKLOAD^C0XF2N(.C0XFDA)
|
||||
S GRTN=C0SGRF
|
||||
Q
|
||||
;
|
||||
SAMPLE ; import sample lab tests to the triplestore
|
||||
N GN
|
||||
S GN=$NA(^rdf("lab_results"))
|
||||
D INSRDF^C0XF2N(GN,"/smart/lab/samples")
|
||||
Q
|
||||
;
|
|
@ -0,0 +1,56 @@
|
|||
C0SMART ; GPL - Smart Container Entry Points;2/22/12 17:05
|
||||
;;0.1;C0S;nopatch;noreleasedate;Build 2
|
||||
;Copyright 2012 George Lilly. Licensed under the terms of the GNU
|
||||
;General Public License See attached copy of the License.
|
||||
;
|
||||
;This program is free software; you can redistribute it and/or modify
|
||||
;it under the terms of the GNU General Public License as published by
|
||||
;the Free Software Foundation; either version 2 of the License, or
|
||||
;(at your option) any later version.
|
||||
;
|
||||
;This program is distributed in the hope that it will be useful,
|
||||
;but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;GNU General Public License for more details.
|
||||
;
|
||||
;You should have received a copy of the GNU General Public License along
|
||||
;with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
;
|
||||
Q
|
||||
EN(ZRTN,ZPATID,ZTYP,ZFORM,DEBUG) ; return a Smart RDF file section ZTYP
|
||||
; for patient ZPATID; ZFORM defaults to rdf
|
||||
; ZRTN is passed by reference
|
||||
; For now, ZPATID is the DFN
|
||||
;
|
||||
I '$D(ZFORM) S ZFORM="rdf"
|
||||
K ZRTN ; CLEAN RETURN
|
||||
N C0SARY
|
||||
I ZTYP="patient" D EN^C0SNHIN(.C0SARY,ZPATID,"patient")
|
||||
E D EN^C0SNHIN(.C0SARY,ZPATID,"patient;"_ZTYP)
|
||||
I $G(C0SARY("patient",1,"id@value"))'=ZPATID D Q ;
|
||||
. W !,"Error Retreiving Patient Record"
|
||||
;
|
||||
K C0XFDA
|
||||
;
|
||||
N C0SGR ; graph
|
||||
;
|
||||
; processing table
|
||||
;
|
||||
N C0SCTRL
|
||||
S C0SCTRL("med")="D MED^C0SMED(.C0SGR,.C0SARY)"
|
||||
S C0SCTRL("patient")="D PATIENT^C0SDEM(.C0SGR,.C0SARY)"
|
||||
S C0SCTRL("lab")="D LAB^C0SLAB(.C0SGR,.C0SARY)"
|
||||
S C0SCTRL("problem")="D PROB^C0SPROB(.C0SGR,.C0SARY)"
|
||||
;
|
||||
I '$D(C0SCTRL(ZTYP)) W !,ZTYP," ","Not Supported" Q ;
|
||||
N ZX
|
||||
S ZX=C0SCTRL(ZTYP)
|
||||
X ZX ;
|
||||
;
|
||||
I '$D(C0SGR) Q ;
|
||||
;
|
||||
D getGraph^C0XGET1(.ZRTN,C0SGR,ZFORM)
|
||||
;
|
||||
Q
|
||||
;
|
|
@ -0,0 +1,157 @@
|
|||
C0SMED ; GPL - Smart Meds Processing ;2/22/12 17:05
|
||||
;;0.1;C0S;nopatch;noreleasedate;Build 2
|
||||
;Copyright 2012 George Lilly. Licensed under the terms of the GNU
|
||||
;General Public License See attached copy of the License.
|
||||
;
|
||||
;This program is free software; you can redistribute it and/or modify
|
||||
;it under the terms of the GNU General Public License as published by
|
||||
;the Free Software Foundation; either version 2 of the License, or
|
||||
;(at your option) any later version.
|
||||
;
|
||||
;This program is distributed in the hope that it will be useful,
|
||||
;but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;GNU General Public License for more details.
|
||||
;
|
||||
;You should have received a copy of the GNU General Public License along
|
||||
;with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
;
|
||||
Q
|
||||
;
|
||||
MED(GRTN,C0SARY) ; GRTN, passed by reference,
|
||||
; is the return name of the graph created. "" if none
|
||||
; C0SARY is passed in by reference and is the NHIN array of meds
|
||||
;
|
||||
I $O(C0SARY("med",""))="" D Q ;
|
||||
. I $D(DEBUG) W !,"No Meds"
|
||||
S GRTN="" ; default to no meds
|
||||
N C0SGRF
|
||||
S C0SGRF="vistaSmart:"_ZPATID_"/"_ZTYP
|
||||
I $D(DEBUG) W !,"Processing ",C0SGRF
|
||||
D DELGRAPH^C0XF2N(C0SGRF) ; delete the old graph
|
||||
N MEDTRP ; MEDS TRIPLES
|
||||
D INITFARY^C0XF2N("C0XFARY") ; which triple store to use
|
||||
N FARY S FARY="C0XFARY"
|
||||
D USEFARY^C0XF2N(FARY)
|
||||
D VOCINIT^C0XUTIL
|
||||
;
|
||||
N DUPCHK S DUPCHK="" ; check for no duplicates
|
||||
N ZI S ZI=""
|
||||
F S ZI=$O(C0SARY("med",ZI)) Q:ZI="" D ;
|
||||
. N SDATE,SDTMP
|
||||
. I $G(C0SARY("med",ZI,"vaStatus@value"))="EXPIRED" D Q ;
|
||||
. . I $D(DEBUG) W !,"Expired Mediation, Skipping"
|
||||
. I $G(COSARY("med",ZI,"vaType@value"))="I" D Q ;
|
||||
. . I $D(DEBUG) W !,"Inpatient Med, skipping"
|
||||
. I $G(COSARY("med",ZI,"vaType@value"))="V" D Q ;
|
||||
. . I $D(DEBUG) W !,"IV Inpatient Med, skipping"
|
||||
. ;
|
||||
. S SDTMP=$G(C0SARY("med",ZI,"ordered@value"))
|
||||
. I SDTMP="" D ;
|
||||
. . S SDTMP=$G(C0SARY("med",ZI,"start@value"))
|
||||
. S SDATE=$$FMTE^XLFDT(SDTMP,"7D") ; ordered date
|
||||
. S SDATE=$TR(SDATE,"/","-") ; change slashes to hyphens
|
||||
. I SDATE="" S SDATE="UNKNOWN"
|
||||
. N DNAME,VUID,DCODE,RXNORM,SIG
|
||||
. S DNAME=$G(C0SARY("med",ZI,"name@value"))
|
||||
. I DNAME="" D ;
|
||||
. . S DNAME=$G(C0SARY("med",ZI,"products.product@name"))
|
||||
. S VUID=$G(C0SARY("med",ZI,"products.product.vaProduct@vuid"))
|
||||
. S DCODE=$G(C0SARY("med",ZI,"products.product.vaProduct@code"))
|
||||
. I DCODE="" S DCODE=$G(C0SARY("med",ZI,"id@value"))
|
||||
. S RXNORM=$$RXCUI(VUID) ; look up RxNorm code
|
||||
. I $P(RXNORM,"^",2)="RXNORM" D ;
|
||||
. . S RXVER=$P(RXNORM,"^",3)
|
||||
. . S RXNORM=$P(RXNORM,"^",1)
|
||||
. E D Q ;
|
||||
. . I $D(DEBUG) W !,"NO RXNORM NUMBER AVAILABLE"
|
||||
. . I $D(DEBUG) W !,RXNORM
|
||||
. I DNAME="" D Q ;
|
||||
. . I $D(DEBUG) W !,"Error No Drug Name"
|
||||
. S MEDGRF=C0SGRF_"/"_DCODE_"-"_$G(SDTMP)
|
||||
. I +$D(DUPCHK(MEDGRF)) D Q ; NO DUPS ALLOWED
|
||||
. . I $D(DEBUG) W !,"Found Duplicate Medication ",MEDGRF
|
||||
. S DUPCHK(MEDGRF)=""
|
||||
. I $D(DEBUG) D ;
|
||||
. . W !,"Processing Medication ",MEDGRF
|
||||
. . W !,DNAME
|
||||
. . W !,RXNORM
|
||||
. S SIG=$G(C0SARY("med",ZI,"sig"))
|
||||
. I SIG["|" D ;
|
||||
. . N SIGTMP
|
||||
. . S SIGTMP=SIG
|
||||
. . S SIG=$P(SIGTMP,"|",2) ; remove the drug name from the sig
|
||||
. . I DNAME["FREE TXT" D ; eRx free text drug, get drug name from sig
|
||||
. . . S DNAME=$P(SIGTMP,"|",1) ; eRx Drug name is stored as the first piece of the sig
|
||||
. K C0XFARY
|
||||
. D ADD^C0XF2N(C0SGRF,MEDGRF,"rdf:type","sp:Medication",FARY)
|
||||
. D ADD^C0XF2N(C0SGRF,MEDGRF,"sp:belongsTo",C0SGRF,FARY)
|
||||
. N DSUBJ S DSUBJ=$$ANONS^C0XF2N ; anonomous subject
|
||||
. D ADD^C0XF2N(C0SGRF,MEDGRF,"sp:drugName",DSUBJ,FARY)
|
||||
. I SIG'="" D ADD^C0XF2N(C0SGRF,MEDGRF,"sp:instructions",SIG,FARY)
|
||||
. N NQTY,NQTY2,NFREQ,NFREQ2
|
||||
. S NQTY=$$ANONS^C0XF2N ; anonomous subject
|
||||
. D ADD^C0XF2N(C0SGRF,MEDGRF,"sp:quantity",NQTY,FARY)
|
||||
. S NQTY2=$$ANONS^C0XF2N ; anonomous subject
|
||||
. D ADD^C0XF2N(C0SGRF,NQTY,"sp:ValueAndUnit",NQTY2,FARY)
|
||||
. N DOSE S DOSE=$G(C0SARY("med",ZI,"doses.dose@dose"))
|
||||
. I DOSE="" S DOSE="UNKNOWN"
|
||||
. N UNIT S UNIT=$G(C0SARY("med",ZI,"doses.dose@units"))
|
||||
. I UNIT="" S UNIT="UNKNOWN"
|
||||
. D ADD^C0XF2N(C0SGRF,NQTY2,"sp:value",DOSE,FARY)
|
||||
. D ADD^C0XF2N(C0SGRF,NQTY2,"sp:unit",UNIT,FARY)
|
||||
. S NFREQ=$$ANONS^C0XF2N ; anonomous subject
|
||||
. S NFREQ2=$$ANONS^C0XF2N ; anonomous subject
|
||||
. D ADD^C0XF2N(C0SGRF,MEDGRF,"sp:frequency",NFREQ,FARY)
|
||||
. D ADD^C0XF2N(C0SGRF,NFREQ,"sp:ValueAndUnit",NFREQ2,FARY)
|
||||
. N SCHED S SCHED=$G(C0SARY("med",ZI,"doses.dose@schedule"))
|
||||
. I SCHED="" S SCHED="UNKNOWN"
|
||||
. N SCHUNIT S SCHUNIT=$G(C0SARY("med",ZI,"doses.dose@route"))
|
||||
. I SCHUNIT="" S SCHUNIT="UNKNOWN"
|
||||
. D ADD^C0XF2N(C0SGRF,NFREQ2,"sp:value",SCHED,FARY)
|
||||
. D ADD^C0XF2N(C0SGRF,NFREQ2,"sp:unit",SCHUNIT,FARY)
|
||||
. D ADD^C0XF2N(C0SGRF,DSUBJ,"rdf:type","sp:CodedValue",FARY)
|
||||
. D ADD^C0XF2N(C0SGRF,DSUBJ,"sp:code","rxnorm:"_RXNORM,FARY)
|
||||
. D ADD^C0XF2N(C0SGRF,"rxnorm:"_RXNORM,"rdf:type","sp:Code",FARY)
|
||||
. D ADD^C0XF2N(C0SGRF,"rxnorm:"_RXNORM,"dcterms:title",DNAME,FARY)
|
||||
. D ADD^C0XF2N(C0SGRF,"rxnorm:"_RXNORM,"sp:system","rxnorm:",FARY)
|
||||
. D ADD^C0XF2N(C0SGRF,"rxnorm:"_RXNORM,"dcterms:identifier",RXNORM,FARY)
|
||||
. D ADD^C0XF2N(C0SGRF,DSUBJ,"dcterms:title",DNAME,FARY)
|
||||
. D ADD^C0XF2N(C0SGRF,MEDGRF,"sp:startDate",SDATE,FARY)
|
||||
. D ADD^C0XF2N(C0SGRF,"rxnorm:"_RXNORM,"rdf:type","http://smartplatforms.org/terms/codes/RxNorm_Semantic",FARY)
|
||||
. D BULKLOAD^C0XF2N(.C0XFDA)
|
||||
. K C0XFDA
|
||||
S GRTN=C0SGRF
|
||||
q
|
||||
;
|
||||
RXNFN() Q 1130590011.001 ; RxNorm Concepts file number
|
||||
;
|
||||
RXCUI(ZVUID) ; EXTRINSIC WHICH RETURNS THE RXNORM CODE IF KNOWN OF
|
||||
; THE VUID - RETURNS CODE^SYSTEM^VERSION TO USE IN THE CCR
|
||||
N ZRSLT S ZRSLT=ZVUID_"^"_"VUID"_"^" ; DEFAULT
|
||||
I $G(ZVUID)="" Q ""
|
||||
I '$D(^C0P("RXN")) Q ZRSLT ; ERX NOT INSTALLED
|
||||
N C0PIEN ; S C0PIEN=$$FIND1^DIC($$RXNFN,"","QX",ZVUID,"VUID")
|
||||
S C0PIEN=$O(^C0P("RXN","VUID",ZVUID,"")) ;GPL FIX FOR MULTIPLES
|
||||
N ZRXN S ZRXN=$$GET1^DIQ($$RXNFN,C0PIEN,.01)
|
||||
S ZRXN=$$NISTMAP(ZRXN) ; CHANGE THE CODE IF NEEDED
|
||||
I ZRXN'="" S ZRSLT=ZRXN_"^RXNORM^08AB_081201F"
|
||||
Q ZRSLT
|
||||
;
|
||||
NISTMAP(ZRXN) ; EXTRINSIC WHICH MAPS SOME RXNORM NUMBERS TO
|
||||
; CONFORM TO NIST REQUIREMENTS
|
||||
;INPATIENT CERTIFICATION
|
||||
I ZRXN=309362 S ZRXN=213169
|
||||
I ZRXN=855318 S ZRXN=855320
|
||||
I ZRXN=197361 S ZRXN=212549
|
||||
;OUTPATIENT CERTIFICATION
|
||||
I ZRXN=310534 S ZRXN=205875
|
||||
I ZRXN=617312 S ZRXN=617314
|
||||
I ZRXN=310429 S ZRXN=200801
|
||||
I ZRXN=628953 S ZRXN=628958
|
||||
I ZRXN=745679 S ZRXN=630208
|
||||
I ZRXN=311564 S ZRXN=979334
|
||||
I ZRXN=836343 S ZRXN=836370
|
||||
Q ZRXN
|
||||
;
|
|
@ -0,0 +1,106 @@
|
|||
MXMLBLD ;;ISF/RWF - Tool to build XML ;07/09/09 16:55 - Smart Container Ver.
|
||||
;;8.0;KERNEL;;;Build 2
|
||||
QUIT
|
||||
;
|
||||
;DOC - The top level tag
|
||||
;DOCTYPE - Want to include a DOCTYPE node
|
||||
;FLAG - Set to 'G' to store the output in the global ^TMP("MXMLBLD",$J,
|
||||
START(DOC,DOCTYPE,FLAG,NO1ST) ;Call this once at the begining.
|
||||
K ^TMP("MXMLBLD",$J)
|
||||
S ^TMP("MXMLBLD",$J,"DOC")=DOC,^TMP("MXMLBLD",$J,"STK")=0
|
||||
I $G(FLAG)["G" S ^TMP("MXMLBLD",$J,"CNT")=1
|
||||
I $G(NO1ST)'=1 D OUTPUT($$XMLHDR)
|
||||
D:$L($G(DOCTYPE)) OUTPUT("<!DOCTYPE "_DOCTYPE_">") D OUTPUT("<"_DOC_">")
|
||||
Q
|
||||
;
|
||||
END ;Call this once to close out the document
|
||||
D OUTPUT("</"_$G(^TMP("MXMLBLD",$J,"DOC"))_">")
|
||||
I '$G(^TMP("MXMLBLD",$J,"CNT")) K ^TMP("MXMLBLD",$J)
|
||||
K ^TMP("MXMLBLD",$J,"DOC"),^("CNT"),^("STK")
|
||||
Q
|
||||
;
|
||||
ITEM(INDENT,TAG,ATT,VALUE) ;Output a Item
|
||||
N I,X
|
||||
S ATT=$G(ATT)
|
||||
I '$D(VALUE) D OUTPUT($$BLS($G(INDENT))_"<"_TAG_$$ATT(.ATT)_" />") Q
|
||||
D OUTPUT($$BLS($G(INDENT))_"<"_TAG_$$ATT(.ATT)_">"_$$CHARCHK(VALUE)_"</"_TAG_">")
|
||||
Q
|
||||
;DOITEM is a callback to output the lower level.
|
||||
MULTI(INDENT,TAG,ATT,DOITEM) ;Output a Multipule
|
||||
N I,X,S
|
||||
S ATT=$G(ATT)
|
||||
D PUSH($G(INDENT),TAG,.ATT)
|
||||
D @DOITEM
|
||||
D POP
|
||||
Q
|
||||
;
|
||||
ATT(ATT) ;Output a string of attributes
|
||||
I $D(ATT)<9 Q ""
|
||||
N I,S,V
|
||||
S S="",I=""
|
||||
F S I=$O(ATT(I)) Q:I="" S S=S_" "_I_"="_$$Q(ATT(I))
|
||||
Q S
|
||||
;
|
||||
Q(X) ;Add Quotes - Changed by gpl to use single instead of double quotes 6/11
|
||||
;I X'[$C(34) Q $C(34)_X_$C(34)
|
||||
I X'[$C(39) Q $C(39)_X_$C(39)
|
||||
;N Q,Y,I,Z S Q=$C(34),(Y,Z)=""
|
||||
N Q,Y,I,Z S Q=$C(39),(Y,Z)=""
|
||||
F I=1:1:$L(X,Q)-1 S Y=Y_$P(X,Q,I)_Q_Q
|
||||
S Y=Y_$P(X,Q,$L(X,Q))
|
||||
;Q $C(34)_Y_$C(34)
|
||||
Q $C(39)_Y_$C(39)
|
||||
;
|
||||
XMLHDR() ; -- provides current XML standard header
|
||||
Q "<?xml version=""1.0"" encoding=""utf-8"" ?>"
|
||||
;
|
||||
OUTPUT(S) ;Output
|
||||
N C S C=$G(^TMP("MXMLBLD",$J,"CNT"))
|
||||
I C S ^TMP("MXMLBLD",$J,C)=S,^TMP("MXMLBLD",$J,"CNT")=C+1 Q
|
||||
W S,!
|
||||
Q
|
||||
;
|
||||
CHARCHK(STR) ; -- replace xml character limits with entities
|
||||
N A,I,X,Y,Z,NEWSTR
|
||||
S (Y,Z)=""
|
||||
;IF STR["&" SET NEWSTR=STR DO SET STR=Y_Z
|
||||
;. FOR X=1:1 SET Y=Y_$PIECE(NEWSTR,"&",X)_"&",Z=$PIECE(STR,"&",X+1,999) QUIT:Z'["&"
|
||||
I STR["&" F I=1:1:$L(STR,"&")-1 S STR=$P(STR,"&",1,I)_"&"_$P(STR,"&",I+1,999)
|
||||
I STR["<" F S STR=$PIECE(STR,"<",1)_"<"_$PIECE(STR,"<",2,99) Q:STR'["<"
|
||||
I STR[">" F S STR=$PIECE(STR,">",1)_">"_$PIECE(STR,">",2,99) Q:STR'[">"
|
||||
I STR["'" F S STR=$PIECE(STR,"'",1)_"'"_$PIECE(STR,"'",2,99) Q:STR'["'"
|
||||
I STR["""" F S STR=$PIECE(STR,"""",1)_"""_$PIECE(STR,"""",2,99) Q:STR'[""""
|
||||
;
|
||||
S STR=$TR(STR,$C(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31))
|
||||
QUIT STR
|
||||
;
|
||||
COMMENT(VAL) ;Add Comments
|
||||
N I,L
|
||||
;I $D($G(VAL))=1 D OUTPUT("<!-- "_ATT_" -->") Q
|
||||
I $D(VAL) D OUTPUT("<!-- "_ATT_" -->") Q ;CHANGED BY GPL FOR GTM
|
||||
S I="",L="<!--"
|
||||
F S I=$O(ATT(I)) Q:I="" D OUTPUT(L_ATT(I)) S L=""
|
||||
D OUTPUT("-->")
|
||||
Q
|
||||
;
|
||||
PUSH(INDENT,TAG,ATT) ;Write a TAG and save.
|
||||
N CNT
|
||||
S ATT=$G(ATT)
|
||||
D OUTPUT($$BLS($G(INDENT))_"<"_TAG_$$ATT(.ATT)_">")
|
||||
S CNT=$G(^TMP("MXMLBLD",$J,"STK"))+1,^TMP("MXMLBLD",$J,"STK")=CNT,^TMP("MXMLBLD",$J,"STK",CNT)=INDENT_"^"_TAG
|
||||
Q
|
||||
;
|
||||
POP ;Write last pushed tag and pop
|
||||
N CNT,TAG,INDENT,X
|
||||
S CNT=$G(^TMP("MXMLBLD",$J,"STK")),X=^TMP("MXMLBLD",$J,"STK",CNT),^TMP("MXMLBLD",$J,"STK")=CNT-1
|
||||
S INDENT=+X,TAG=$P(X,"^",2)
|
||||
D OUTPUT($$BLS(INDENT)_"</"_TAG_">")
|
||||
Q
|
||||
;
|
||||
BLS(I) ;Return INDENT string
|
||||
N S
|
||||
S S="",I=$G(I) S:I>0 $P(S," ",I)=" "
|
||||
Q S
|
||||
;
|
||||
INDENT() ;Renturn indent level
|
||||
Q +$G(^TMP("MXMLBLD",$J,"STK"))
|
|
@ -0,0 +1,324 @@
|
|||
C0SNHIN ; GPL - Smart Container - OUTPUT OF NHINV ROUTINES;6/3/11 17:05
|
||||
;;0.1;C0S;nopatch;noreleasedate;Build 2
|
||||
;Copyright 2011-2012 George Lilly. Licensed under the terms of the GNU
|
||||
;General Public License See attached copy of the License.
|
||||
;
|
||||
;This program is free software; you can redistribute it and/or modify
|
||||
;it under the terms of the GNU General Public License as published by
|
||||
;the Free Software Foundation; either version 2 of the License, or
|
||||
;(at your option) any later version.
|
||||
;
|
||||
;This program is distributed in the hope that it will be useful,
|
||||
;but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;GNU General Public License for more details.
|
||||
;
|
||||
;You should have received a copy of the GNU General Public License along
|
||||
;with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
;
|
||||
Q
|
||||
EN(ZRTN,ZDFN,ZPART,KEEP) ; GENERATE AN NHIN ARRAY FOR A PATIENT
|
||||
;
|
||||
K GARY,GNARY,GIDX,C0SDOCID
|
||||
K ZRTN
|
||||
N GN
|
||||
K ^TMP("NHINV",$J) ; CLEAN UP FROM LAST CALL
|
||||
K ^TMP("MXMLDOM",$J) ; CLEAN UP DOM
|
||||
K ^TMP("MXMLERR",$J) ; CLEAN UP MXML ERRORS
|
||||
D GET^C0SNHINV(.GN,ZDFN,ZPART) ; CALL NHINV ROUTINES TO PULL XML
|
||||
S GN=$P(GN,")",1)_")" ; CUT OFF THE REST OF LINE PROTOCOL
|
||||
S C0SDOCID=$$PARSE(GN,"NHINARRAY") ; PARSE WITH MXML
|
||||
D DOMO^C0SDOM(C0SDOCID,"/","ZRTN","GIDX","GARY",,"/results/") ; BLD ARRAYS
|
||||
I '$G(KEEP) K GIDX,GARY ; GET RID OF THE ARRAYS UNLESS KEEP=1
|
||||
;D PROCESS("ZRTN",GN,"/result/",$G(KEEP))
|
||||
Q
|
||||
;
|
||||
PQRI(ZOUT,KEEP) ; RETURN THE NHIN ARRAY FOR THE PQRI XML TEMPLATE
|
||||
;
|
||||
N ZG
|
||||
S ZG=$NA(^TMP("PQRIXML",$J))
|
||||
K @ZG
|
||||
D GETXML^C0SMXP(ZG,"PQRIXML") ; GET THE XML FROM C0S MISC XML
|
||||
N C0SDOCID
|
||||
S C0SDOCID=$$PARSE^C0SDOM(ZG,"PQRIXML") ; PARSE THE XML
|
||||
D DOMO^C0SDOM(C0SDOCID,"/","ZOUT","GIDX","GARY",,"//submission") ; BLD ARRAYS
|
||||
I '$G(KEEP) K GIDX,GARY ; GET RID OF THE ARRAYS UNLESS KEEP=1
|
||||
Q
|
||||
;
|
||||
PQRI2(ZRTN) ; RETURN THE NHIN ARRAY FOR PQRI ONE MEASURE
|
||||
;
|
||||
;N GG
|
||||
D GETXML^C0SMXP("GG","PQRI ONE MEASURE")
|
||||
D PROCESS(ZRTN,"GG","root",1)
|
||||
Q
|
||||
;
|
||||
PROCESS(ZRSLT,ZXML,ZREDUCE,KEEP) ; PARSE AND RUN DOMO ON XML
|
||||
; ZRTN IS PASSED BY REFERENCE
|
||||
; ZXML IS PASSED BY NAME
|
||||
; IF KEEP IS 1, GARY AND GIDX ARE NOT KILLED
|
||||
;
|
||||
N GN
|
||||
S GN=$NA(^TMP("C0SPROCESS",$J))
|
||||
K @GN
|
||||
M @GN=@ZXML
|
||||
S C0SDOCID=$$PARSE(GN,"NHINARRAY") ; PARSE WITH MXML
|
||||
K @GN
|
||||
D DOMO^C0SDOM(C0SDOCID,"/","ZRSLT","GIDX","GARY",,$G(ZREDUCE)) ; BLD ARRAYS
|
||||
I '$G(KEEP) K GIDX,GARY ; GET RID OF THE ARRAYS UNLESS KEEP=1
|
||||
Q
|
||||
;
|
||||
LOADSMRT ;
|
||||
;
|
||||
K ^GPL("SMART")
|
||||
S GN=$NA(^GPL("SMART",1))
|
||||
I $$FTG^%ZISH("/home/george/","alex-lewis2.xml",GN,2) W !,"SMART FILE LOADED"
|
||||
Q
|
||||
;
|
||||
SMART ; TRY IT WITH SMART
|
||||
;
|
||||
S GN=$NA(^GPL("SMART"))
|
||||
;K ^TMP("MXMLDOM",$J)
|
||||
K ^TMP("MXMLERR",$J)
|
||||
S C0SDOCID=$$PARSE(GN,"SMART")
|
||||
D DOMO^C0SDOM(C0SDOCID,"/","GNARY","GIDX","GARY",,"//rdf:RDF/")
|
||||
;K ^TMP("MXMLDOM",$J) ;CLEAN UP... IT'S BIG
|
||||
Q
|
||||
;
|
||||
CCR ; TRY IT WITH A CCR
|
||||
;
|
||||
S GN=$NA(^GPL("CCR"))
|
||||
;K ^TMP("MXMLDOM",$J)
|
||||
K ^TMP("MXMLERR",$J)
|
||||
S C0SDOCID=$$PARSE(GN,"CCR")
|
||||
D DOMO^C0SDOM(C0SDOCID,"/","GNARY","GIDX","GARY",,"//ContinuityOfCareRecord/Body/")
|
||||
;K ^TMP("MXMLDOM",$J) ;CLEAN UP... IT'S BIG
|
||||
Q
|
||||
;
|
||||
MED ; TRY IT WITH A CCR MED SECTION
|
||||
;
|
||||
S GN=$NA(^GPL("MED"))
|
||||
K ^TMP("MXMLDOM",$J)
|
||||
K ^TMP("MXMLERR",$J)
|
||||
S C0SDOCID=$$PARSE(GN,"MED")
|
||||
D DOMO^C0SDOM(C0SDOCID,"/","GNARY","GIDX","GARY",,"//Medications/")
|
||||
;K ^TMP("MXMLDOM",$J) ;CLEAN UP... IT'S BIG
|
||||
Q
|
||||
;
|
||||
CCD ; TRY IT WITH A CCD
|
||||
;
|
||||
S GN=$NA(^GPL("CCD"))
|
||||
;K ^TMP("MXMLDOM",$J)
|
||||
K ^TMP("MXMLERR",$J)
|
||||
S C0SDOCID=$$PARSE(GN,"CCD")
|
||||
D DOMO^C0SDOM(C0SDOCID,"/","GNARY","GIDX","GARY",,"//ClinicalDocument/component/structuredBody/")
|
||||
;K ^TMP("MXMLDOM",$J) ;CLEAN UP... IT'S BIG
|
||||
Q
|
||||
;
|
||||
TEST1 ; TEST NHINV OUTPUT IN ^GPL("NIHIN")
|
||||
; PARSED WITH MXML
|
||||
; RUN THROUGH XPATH
|
||||
K GARY,GIDX,C0SDOCID
|
||||
S GN=$NA(^GPL("NHIN"))
|
||||
;S GN=$NA(^GPL("DOMI"))
|
||||
S C0SDOCID=$$PARSE(GN,"GPLTEST")
|
||||
D DOMO^C0SDOM(C0SDOCID,"/","GNARY","GIDX","GARY",,"/results/")
|
||||
K ^GPL("GNARY")
|
||||
M ^GPL("GNARY")=GNARY
|
||||
Q
|
||||
;
|
||||
TEST2 ; PUT GNARY THROUGH DOMI AND STORE XML IN ^GPL("DOMI")
|
||||
;
|
||||
S GN=$NA(^GPL("GNARY"))
|
||||
S C0SDOCID=$$DOMI^C0SDOM(GN,,"results")
|
||||
D OUTXML^C0SDOM("G",C0SDOCID)
|
||||
K ^GPL("DOMI")
|
||||
M ^GPL("DOMI")=G
|
||||
Q
|
||||
;
|
||||
TEST3 ; TEST NHINV OUTPUT IN ^GPL("NIHIN")
|
||||
; PARSED WITH MXML
|
||||
; RUN THROUGH XPATH
|
||||
K GARY,GIDX,C0SDOCID
|
||||
;S GN=$NA(^GPL("NHIN"))
|
||||
S GN=$NA(^GPL("DOMI"))
|
||||
S C0SDOCID=$$PARSE(GN,"GPLTEST")
|
||||
D DOMO^C0SDOM(C0SDOCID,"/","GNARY","GIDX","GARY",,"/results/")
|
||||
Q
|
||||
;
|
||||
DOMO(ZOID,ZPATH,ZNARY,ZXIDX,ZXPARY,ZNUM,ZREDUX) ; RECURSIVE ROUTINE TO POPULATE
|
||||
; THE XPATH INDEX ZXIDX, PASSED BY NAME
|
||||
; THE XPATH ARRAY XPARY, PASSED BY NAME
|
||||
; ZOID IS THE STARTING OID
|
||||
; ZPATH IS THE STARTING XPATH, USUALLY "/"
|
||||
; ZNUM IS THE MULTIPLE NUMBER [x], USUALLY NULL WHEN ON THE TOP NODE
|
||||
; ZREDUX IS THE XPATH REDUCTION STRING, TAKEN OUT OF EACH XPATH IF PRESENT
|
||||
I $G(ZREDUX)="" S ZREDUX=""
|
||||
N NEWPATH,NARY ; NEWPATH IS AN XPATH NARY IS AN NHIN MUMPS ARRAY
|
||||
N NEWNUM S NEWNUM=""
|
||||
I $G(ZNUM)>0 S NEWNUM="["_ZNUM_"]"
|
||||
S NEWPATH=ZPATH_"/"_$$TAG(ZOID)_NEWNUM ; CREATE THE XPATH FOR THIS NODE
|
||||
I $G(ZREDUX)'="" D ; REDUX PROVIDED?
|
||||
. N GT S GT=$P(NEWPATH,ZREDUX,2)
|
||||
. I GT'="" S NEWPATH=GT
|
||||
S @ZXIDX@(NEWPATH)=ZOID ; ADD THE XPATH FOR THIS NODE TO THE XPATH INDEX
|
||||
N GA D ATT("GA",ZOID) ; GET ATTRIBUTES FOR THIS NODE
|
||||
I $D(GA) D ; PROCESS THE ATTRIBUTES
|
||||
. N ZI S ZI=""
|
||||
. F S ZI=$O(GA(ZI)) Q:ZI="" D ; FOR EACH ATTRIBUTE
|
||||
. . N ZP S ZP=NEWPATH_"/"_ZI ; PATH FOR ATTRIBUTE
|
||||
. . S @ZXPARY@(ZP)=GA(ZI) ; ADD THE ATTRIBUTE XPATH TO THE XP ARRAY
|
||||
. . I GA(ZI)'="" D ADDNARY(ZP,GA(ZI)) ; ADD THE NHIN ARRAY VALUE
|
||||
N GD D DATA("GD",ZOID) ; SEE IF THERE IS DATA FOR THIS NODE
|
||||
I $D(GD(2)) D ;
|
||||
. M @ZXPARY@(NEWPATH)=GD ; IF MULITPLE DATA MERGE TO THE ARRAY
|
||||
E I $D(GD(1)) D ;
|
||||
. S @ZXPARY@(NEWPATH)=GD(1) ; IF SINGLE VALUE, ADD TO ARRAY
|
||||
. I GD(1)'="" D ADDNARY(NEWPATH,GD(1)) ; ADD TO NHIN ARRAY
|
||||
N ZFRST S ZFRST=$$FIRST(ZOID) ; SET FIRST CHILD
|
||||
I ZFRST'=0 D ; THERE IS A CHILD
|
||||
. N ZNUM
|
||||
. N ZMULT S ZMULT=$$ISMULT(ZFRST) ; IS FIRST CHILD A MULTIPLE
|
||||
. D DOMO(ZFRST,NEWPATH,ZNARY,ZXIDX,ZXPARY,$S(ZMULT:1,1:""),ZREDUX) ; THE CHILD
|
||||
N GNXT S GNXT=$$NXTSIB(ZOID)
|
||||
I $$TAG(GNXT)'=$$TAG(ZOID) S ZNUM="" ; RESET COUNTING AFTER MULTIPLES
|
||||
I GNXT'=0 D ;
|
||||
. N ZMULT S ZMULT=$$ISMULT(GNXT) ; IS THE SIBLING A MULTIPLE?
|
||||
. I (ZNUM="")&(ZMULT) D ; SIBLING IS FIRST OF MULTIPLES
|
||||
. . N ZNUM S ZNUM=1 ;
|
||||
. . D DOMO(GNXT,ZPATH,ZNARY,ZXIDX,ZXPARY,ZNUM,ZREDUX) ; DO NEXT SIB
|
||||
. E D DOMO(GNXT,ZPATH,ZNARY,ZXIDX,ZXPARY,$S(ZNUM>0:ZNUM+1,1:""),ZREDUX) ; SIB
|
||||
Q
|
||||
;
|
||||
ADDNARY(ZXP,ZVALUE) ; ADD AN NHIN ARRAY VALUE TO ZNARY
|
||||
;
|
||||
N ZZI,ZZJ,ZZN
|
||||
S ZZI=$P(ZXP,"/",1) ; FIRST PIECE OF XPATH ARRAY
|
||||
I ZZI="" Q ; DON'T ADD THIS ONE .. PROBABLY THE //results NODE
|
||||
S ZZJ=$P(ZXP,ZZI_"/",2) ; REST OF XPATH ARRAY
|
||||
S ZZJ=$TR(ZZJ,"/",".") ; REPLACE / WITH .
|
||||
I ZZI'["]" D ; A SINGLETON
|
||||
. S ZZN=1
|
||||
E D ; THERE IS AN [x] OCCURANCE
|
||||
. S ZZN=$P($P(ZZI,"[",2),"]",1) ; PULL OUT THE OCCURANCE
|
||||
. S ZZI=$P(ZZI,"[",1) ; TAKE OUT THE [X]
|
||||
I ZZJ'="" S @ZNARY@(ZZI,ZZN,ZZJ)=ZVALUE
|
||||
Q
|
||||
;
|
||||
PARSE(INXML,INDOC) ;CALL THE MXML PARSER ON INXML, PASSED BY NAME
|
||||
; INDOC IS PASSED AS THE DOCUMENT NAME - DON'T KNOW WHERE TO STORE THIS NOW
|
||||
; EXTRINSIC WHICH RETURNS THE DOCID ASSIGNED BY MXML
|
||||
;Q $$EN^MXMLDOM(INXML)
|
||||
Q $$EN^MXMLDOM(INXML,"W")
|
||||
;
|
||||
ISMULT(ZOID) ; RETURN TRUE IF ZOID IS ONE OF A MULTIPLE
|
||||
N ZN
|
||||
;I $$TAG(ZOID)["entry" B
|
||||
S ZN=$$NXTSIB(ZOID)
|
||||
I ZN'="" Q $$TAG(ZOID)=$$TAG(ZN) ; IF TAG IS THE SAME AS NEXT SIB TAG
|
||||
Q 0
|
||||
;
|
||||
FIRST(ZOID) ;RETURNS THE OID OF THE FIRST CHILD OF ZOID
|
||||
Q $$CHILD^MXMLDOM(C0SDOCID,ZOID)
|
||||
;
|
||||
PARENT(ZOID) ;RETURNS THE OID OF THE PARENT OF ZOID
|
||||
Q $$PARENT^MXMLDOM(C0SDOCID,ZOID)
|
||||
;
|
||||
ATT(RTN,NODE) ;GET ATTRIBUTES FOR ZOID
|
||||
S HANDLE=C0SDOCID
|
||||
K @RTN
|
||||
D GETTXT^MXMLDOM("A")
|
||||
Q
|
||||
;
|
||||
TAG(ZOID) ; RETURNS THE XML TAG FOR THE NODE
|
||||
;I ZOID=149 B ;GPLTEST
|
||||
N X,Y
|
||||
S Y=""
|
||||
S X=$G(C0SCBK("TAG")) ;IS THERE A CALLBACK FOR THIS ROUTINE
|
||||
I X'="" X X ; EXECUTE THE CALLBACK, SHOULD SET Y
|
||||
I Y="" S Y=$$NAME^MXMLDOM(C0SDOCID,ZOID)
|
||||
Q Y
|
||||
;
|
||||
NXTSIB(ZOID) ; RETURNS THE NEXT SIBLING
|
||||
Q $$SIBLING^MXMLDOM(C0SDOCID,ZOID)
|
||||
;
|
||||
DATA(ZT,ZOID) ; RETURNS DATA FOR THE NODE
|
||||
;N ZT,ZN S ZT=""
|
||||
;S C0SDOM=$NA(^TMP("MXMLDOM",$J,C0SDOCID))
|
||||
;Q $G(@C0SDOM@(ZOID,"T",1))
|
||||
S ZN=$$TEXT^MXMLDOM(C0SDOCID,ZOID,ZT)
|
||||
Q
|
||||
;
|
||||
OUTXML(ZRTN,INID) ; USES C0SMXMLB (MXMLBLD) TO OUTPUT XML FROM AN MXMLDOM
|
||||
;
|
||||
S C0SDOCID=INID
|
||||
D START^C0SMXMLB($$TAG(1),,"G")
|
||||
D NDOUT($$FIRST(1))
|
||||
D END^C0SMXMLB ;END THE DOCUMENT
|
||||
M @ZRTN=^TMP("MXMLBLD",$J)
|
||||
K ^TMP("MXMLBLD",$J)
|
||||
Q
|
||||
;
|
||||
NDOUT(ZOID) ;CALLBACK ROUTINE - IT IS RECURSIVE
|
||||
N ZI S ZI=$$FIRST(ZOID)
|
||||
I ZI'=0 D ; THERE IS A CHILD
|
||||
. N ZATT D ATT("ZATT",ZOID) ; THESE ARE THE ATTRIBUTES MOVED TO ZATT
|
||||
. D MULTI^C0SMXMLB("",$$TAG(ZOID),.ZATT,"NDOUT^C0SMXML(ZI)") ;HAVE CHILDREN
|
||||
E D ; NO CHILD - IF NO CHILDREN, A NODE HAS DATA, IS AN ENDPOINT
|
||||
. ;W "DOING",ZOID,!
|
||||
. N ZD D DATA("ZD",ZOID) ;NODES WITHOUT CHILDREN HAVE DATA
|
||||
. N ZATT D ATT("ZATT",ZOID) ;ATTRIBUTES
|
||||
. D ITEM^C0SMXMLB("",$$TAG(ZOID),.ZATT,$G(ZD(1))) ;NO CHILDREN
|
||||
I $$NXTSIB(ZOID)'=0 D ; THERE IS A SIBLING
|
||||
. D NDOUT($$NXTSIB(ZOID)) ;RECURSE FOR SIBLINGS
|
||||
Q
|
||||
;
|
||||
WNHIN(ZDFN) ; WRITES THE XML OUTPUT OF GET^NHINV TO AN XML FILE
|
||||
;
|
||||
N GN,GN2
|
||||
D GET^NHINV(.GN,ZDFN) ; EXTRACT THE XML
|
||||
S GN2=$NA(@GN@(1))
|
||||
W $$OUTPUT^C0SXPATH(GN2,"nhin_"_ZDFN_".xml","/home/wvehr3-09/")
|
||||
Q
|
||||
;
|
||||
TESTNARY ; TEST MAKING A NHIN ARRAY
|
||||
N ZI S ZI=""
|
||||
N ZH ; DOM HANDLE
|
||||
D TEST1 ; PARSE AN NHIN RESULT INTO THE DOM
|
||||
S ZH=C0SDOCID ; SET THE HANDLE
|
||||
N ZD S ZD=$NA(^TMP("MXMLDOM",$J,ZH))
|
||||
F S ZI=$O(@ZD@(ZI)) Q:ZI="" D ; FOR EACH NODE
|
||||
. N ZATT
|
||||
. D MNARY(.ZATT,ZH,ZI)
|
||||
. N ZPRE,ZN
|
||||
. S ZPRE=$$PRE(ZI)
|
||||
. S ZN=$P(ZPRE,",",2)
|
||||
. S ZPRE=$P(ZPRE,",",1)
|
||||
. ;I $D(ZATT) ZWR ZATT
|
||||
. N ZJ S ZJ=""
|
||||
. F S ZJ=$O(ZATT(ZJ)) Q:ZJ="" D ; FOR EACH ATTRIBUTE
|
||||
. . W ZPRE_"["_ZN_"]"_$$TAG(ZI)_"."_ZJ_"="_ZATT(ZJ),!
|
||||
. . S GOUT(ZPRE,ZN,$$TAG(ZI)_"."_ZJ)=ZATT(ZJ)
|
||||
Q
|
||||
;
|
||||
PRE(ZNODE) ; EXTRINSIC WHICH RETURNS THE PREFIX FOR A NODE
|
||||
;
|
||||
N GI,GI2,GPT,GJ,GN
|
||||
S GI=$$PARENT(ZNODE) ; PARENT NODE
|
||||
I GI=0 Q "" ; NO PARENT
|
||||
S GPT=$$TAG(GI) ; TAG OF PARENT
|
||||
S GI2=$$PARENT(GI) ; PARENT OF PARENT
|
||||
I (GI2'=0)&($$TAG(GI2)'="results") S GPT=$$TAG(GI2)_"."_GPT
|
||||
S GJ=$$FIRST(GI) ; NODE OF FIRST SIB
|
||||
I GJ=ZNODE Q:$$TAG(GI)_",1"
|
||||
F GN=2:1 Q:GJ=ZNODE D ;
|
||||
. S GJ=$$NXTSIB(GJ) ; NEXT SIBLING
|
||||
Q GPT_","_GN
|
||||
;
|
||||
MNARY(ZRTN,ZHANDLE,ZOID) ; MAKE A NHIN ARRAY FROM A DOM NODE
|
||||
; RETURNED IN ZRTN, PASSED BY REFERENCE
|
||||
; ZHANDLE IS THE DOM DOCUMENT ID
|
||||
; ZOID IS THE DOM NODE
|
||||
D ATT("ZRTN",ZOID)
|
||||
Q
|
||||
;
|
|
@ -0,0 +1,118 @@
|
|||
C0SNHINV ;SLC/MKB - Serve VistA data as XML via RPC - Smart Container Version
|
||||
;;1.0;C0S;**1**;Oct 25, 2010;Build 11
|
||||
;
|
||||
; External References DBIA#
|
||||
; ------------------- -----
|
||||
; ^DPT 10035
|
||||
; ^SC 10040
|
||||
; DIQ 2056
|
||||
; MPIF001 2701
|
||||
; VASITE 10112
|
||||
; XLFDT 10103
|
||||
; XLFSTR 10104
|
||||
; XUAF4 2171
|
||||
;
|
||||
GET(NHIN,DFN,TYPE,START,STOP,MAX,ID) ; -- Return search results as XML in @NHIN@(n)
|
||||
; RPC = NHIN GET VISTA DATA
|
||||
N ICN,NHINI,NHINTOTL
|
||||
S NHIN=$NA(^TMP("NHINV",$J)) K @NHIN
|
||||
;
|
||||
; parse & validate input parameters
|
||||
S ICN=+$P(DFN,";",2),DFN=+$G(DFN)
|
||||
I 'DFN S DFN=+$$GETDFN^MPIF001(ICN)
|
||||
I DFN<1!'$D(^DPT(DFN)) D ERR(1,DFN) G GTQ
|
||||
S TYPE=$G(TYPE) I TYPE="" S TYPE=$$ALL
|
||||
S:'$G(START) START=1410101 S:'$G(STOP) STOP=9999998 S:'$G(MAX) MAX=9999
|
||||
I START,STOP,STOP<START N X S X=START,START=STOP,STOP=X ;switch
|
||||
I STOP,$L(STOP,".")<2 S STOP=STOP_".24"
|
||||
S ID=$G(ID)
|
||||
;
|
||||
; extract data
|
||||
N NHINTYPE,NHINP,RTN
|
||||
S NHINTYPE=TYPE D ADD("<results>")
|
||||
F NHINP=1:1:$L(NHINTYPE,";") S TYPE=$P(NHINTYPE,";",NHINP) I $L(TYPE) D
|
||||
. S RTN="EN^"_$$RTN(TYPE) Q:'$L($T(@RTN)) ;D ERR(2) Q
|
||||
. D @(RTN_"(DFN,START,STOP,MAX,ID)")
|
||||
D ADD("</results>")
|
||||
;
|
||||
I $G(NHINTOTL),$G(@NHIN@(1))="<results>" S @NHIN@(1)="<results total='"_NHINTOTL_"' >"
|
||||
;
|
||||
GTQ ; end
|
||||
Q
|
||||
;
|
||||
RTN(X) ; -- Return name of NHINVxxx routine for clinical domain X
|
||||
S X=$$UP^XLFSTR(X),Y="NHINV"
|
||||
I X="ACCESSION" S Y="NHINVLRA"
|
||||
I X="ALLERGY" S Y="NHINVART"
|
||||
I X="APPOINTMENT" S Y="NHINVAPT"
|
||||
; X="CONSULT" S Y="NHINVCON"
|
||||
I X="DOCUMENT" S Y="NHINVTIU"
|
||||
I X="IMMUNIZATION" S Y="NHINVIMM"
|
||||
I X="LAB" S Y="NHINVLR"
|
||||
I X="PANEL" S Y="NHINVLRO"
|
||||
I X="MED" S Y="NHINVPS"
|
||||
I X="RX" S Y="NHINVPSO"
|
||||
; X="ORDER" S Y="NHINVOR"
|
||||
I X="PATIENT" S Y="NHINVPT"
|
||||
I X="PROBLEM" S Y="NHINVPL"
|
||||
I X="PROCEDURE" S Y="NHINVPRC"
|
||||
I X="SURGERY" S Y="NHINVSR"
|
||||
I X="VISIT" S Y="NHINVSIT"
|
||||
I X="VITAL" S Y="NHINVIT"
|
||||
I X="RADIOLOGY" S Y="NHINVRA"
|
||||
I X="NEW" S Y="NHINVPR"
|
||||
Q Y
|
||||
;
|
||||
ALL() ; -- return string for all types of data
|
||||
;Q "patient;allergy;problem;vital;lab;med;immunization;visit;appointment;document;procedure"
|
||||
Q "patient;allergy;problem;vital;lab;med;immunization;visit;appointment;procedure"
|
||||
;
|
||||
ERR(X,VAL) ; -- return error message
|
||||
N MSG S MSG="Error"
|
||||
I X=1 S MSG="Patient with dfn '"_$G(VAL)_"' not found"
|
||||
I X=2 S MSG="Requested domain type '"_$G(VAL)_"' not recognized"
|
||||
I X=99 S MSG="Unknown request"
|
||||
;
|
||||
D ADD("<error>")
|
||||
D ADD("<message>"_MSG_"</message>")
|
||||
D ADD("</error>")
|
||||
Q
|
||||
;
|
||||
ESC(X) ; -- escape outgoing XML
|
||||
; Q $ZCONVERT(X,"O","HTML") ; uncomment for fastest performance on Cache
|
||||
;
|
||||
N I,Y,QOT S QOT=""""
|
||||
S Y=$P(X,"&") F I=2:1:$L(X,"&") S Y=Y_"&"_$P(X,"&",I)
|
||||
S X=Y,Y=$P(X,"<") F I=2:1:$L(X,"<") S Y=Y_"<"_$P(X,"<",I)
|
||||
S X=Y,Y=$P(X,">") F I=2:1:$L(X,">") S Y=Y_">"_$P(X,">",I)
|
||||
S X=Y,Y=$P(X,"'") F I=2:1:$L(X,"'") S Y=Y_"'"_$P(X,"'",I)
|
||||
S X=Y,Y=$P(X,QOT) F I=2:1:$L(X,QOT) S Y=Y_"""_$P(X,QOT,I)
|
||||
Q Y
|
||||
;
|
||||
ADD(X) ; Add a line @NHIN@(n)=X
|
||||
S NHINI=$G(NHINI)+1
|
||||
S @NHIN@(NHINI)=X
|
||||
Q
|
||||
;
|
||||
STRING(ARRAY) ; -- Return text in ARRAY(n) or ARRAY(n,0) as a string
|
||||
N I,X,Y S Y=""
|
||||
S I=+$O(ARRAY("")) I I=0 S I=+$O(ARRAY(0))
|
||||
S Y=$S($D(ARRAY(I,0)):ARRAY(I,0),1:$G(ARRAY(I)))
|
||||
F S I=$O(ARRAY(I)) Q:I<1 D
|
||||
. S X=$S($D(ARRAY(I,0)):ARRAY(I,0),1:ARRAY(I))
|
||||
. I $E(X)=" " S Y=Y_$C(13,10)_X Q
|
||||
. S Y=Y_$S($E(Y,$L(Y))=" ":"",1:" ")_X
|
||||
Q Y
|
||||
;
|
||||
FAC(X) ; -- return Institution file station# for location X
|
||||
N HLOC,FAC,Y0,Y S Y=""
|
||||
S HLOC=$G(^SC(+$G(X),0)),FAC=$P(HLOC,U,4) ;Institution ien
|
||||
; Get P:4 via Med Ctr Div, if not directly linked
|
||||
I 'FAC,$P(HLOC,U,15) S FAC=$$GET1^DIQ(40.8,+$P(HLOC,U,15)_",",.07,"I")
|
||||
S Y0=$S(FAC:$$NS^XUAF4(FAC),1:$P($$SITE^VASITE,U,2,3)) ;name^stn#
|
||||
S:$L(Y0) Y=$P(Y0,U,2)_U_$P(Y0,U) ;switch to stn#^name
|
||||
I $L(Y),'Y S $P(Y,U)=FAC
|
||||
Q Y
|
||||
;
|
||||
VUID(IEN,FILE) ; -- Return VUID for item
|
||||
Q $$GET1^DIQ(FILE,IEN_",",99.99)
|
|
@ -0,0 +1,323 @@
|
|||
C0SPROB ; GPL - Smart Problem Processing ;5/01/12 17:05
|
||||
;;0.1;C0S;nopatch;noreleasedate;Build 2
|
||||
;Copyright 2012 George Lilly. Licensed under the terms of the GNU
|
||||
;General Public License See attached copy of the License.
|
||||
;
|
||||
;This program is free software; you can redistribute it and/or modify
|
||||
;it under the terms of the GNU General Public License as published by
|
||||
;the Free Software Foundation; either version 2 of the License, or
|
||||
;(at your option) any later version.
|
||||
;
|
||||
;This program is distributed in the hope that it will be useful,
|
||||
;but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;GNU General Public License for more details.
|
||||
;
|
||||
;You should have received a copy of the GNU General Public License along
|
||||
;with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
;
|
||||
Q
|
||||
;
|
||||
; sample VistA NHIN problem list
|
||||
;
|
||||
;^TMP("C0STBL",91,"problem",1,"acuity@value")="C"
|
||||
;^TMP("C0STBL",91,"problem",1,"entered@value")=3110531
|
||||
;^TMP("C0STBL",91,"problem",1,"facility@code")=100
|
||||
;^TMP("C0STBL",91,"problem",1,"facility@name")="VOE OFFICE INSTITUTION"
|
||||
;^TMP("C0STBL",91,"problem",1,"icd@value")=414.9
|
||||
;^TMP("C0STBL",91,"problem",1,"id@value")=100
|
||||
;^TMP("C0STBL",91,"problem",1,"location@value")="DR OFFICE"
|
||||
;^TMP("C0STBL",91,"problem",1,"name@value")="Coronary Artery Disease"
|
||||
;^TMP("C0STBL",91,"problem",1,"onset@value")=3100201
|
||||
;^TMP("C0STBL",91,"problem",1,"provider@code")=63
|
||||
;^TMP("C0STBL",91,"problem",1,"provider@name")="KING,MATTHEW MICHAEL"
|
||||
;^TMP("C0STBL",91,"problem",1,"removed@value")=0
|
||||
;^TMP("C0STBL",91,"problem",1,"sc@value")=0
|
||||
;^TMP("C0STBL",91,"problem",1,"status@value")="A"
|
||||
;^TMP("C0STBL",91,"problem",1,"unverified@value")=0
|
||||
;^TMP("C0STBL",91,"problem",1,"updated@value")=3110531
|
||||
;^TMP("C0STBL",91,"problem",2,"acuity@value")="C"
|
||||
;^TMP("C0STBL",91,"problem",2,"entered@value")=3110602
|
||||
;^TMP("C0STBL",91,"problem",2,"facility@code")=100
|
||||
;^TMP("C0STBL",91,"problem",2,"facility@name")="VOE OFFICE INSTITUTION"
|
||||
;^TMP("C0STBL",91,"problem",2,"icd@value")=780.2
|
||||
;^TMP("C0STBL",91,"problem",2,"id@value")=108
|
||||
;^TMP("C0STBL",91,"problem",2,"name@value")="Syncope and collapse"
|
||||
;^TMP("C0STBL",91,"problem",2,"onset@value")=3110102
|
||||
;^TMP("C0STBL",91,"problem",2,"provider@code")=63
|
||||
;^TMP("C0STBL",91,"problem",2,"provider@name")="KING,MATTHEW MICHAEL"
|
||||
;^TMP("C0STBL",91,"problem",2,"removed@value")=0
|
||||
;^TMP("C0STBL",91,"problem",2,"sc@value")=0
|
||||
;^TMP("C0STBL",91,"problem",2,"status@value")="A"
|
||||
;^TMP("C0STBL",91,"problem",2,"unverified@value")=0
|
||||
;^TMP("C0STBL",91,"problem",2,"updated@value")=3110602
|
||||
;^TMP("C0STBL",91,"problem",3,"acuity@value")="C"
|
||||
;^TMP("C0STBL",91,"problem",3,"entered@value")=3110602
|
||||
;^TMP("C0STBL",91,"problem",3,"facility@code")=100
|
||||
;^TMP("C0STBL",91,"problem",3,"facility@name")="VOE OFFICE INSTITUTION"
|
||||
;^TMP("C0STBL",91,"problem",3,"icd@value")=433.91
|
||||
;^TMP("C0STBL",91,"problem",3,"id@value")=109
|
||||
;^TMP("C0STBL",91,"problem",3,"name@value")="Occlusion and Stenosis of Unspecifid Precerebral Artery with Cerebral Infarctio"
|
||||
;^TMP("C0STBL",91,"problem",3,"onset@value")=3100101
|
||||
;^TMP("C0STBL",91,"problem",3,"provider@code")=63
|
||||
;^TMP("C0STBL",91,"problem",3,"provider@name")="KING,MATTHEW MICHAEL"
|
||||
;^TMP("C0STBL",91,"problem",3,"removed@value")=0
|
||||
;^TMP("C0STBL",91,"problem",3,"sc@value")=0
|
||||
;^TMP("C0STBL",91,"problem",3,"status@value")="A"
|
||||
;^TMP("C0STBL",91,"problem",3,"unverified@value")=0
|
||||
;^TMP("C0STBL",91,"problem",3,"updated@value")=3110602
|
||||
;^TMP("C0STBL",91,"problem",4,"entered@value")=3110603
|
||||
;^TMP("C0STBL",91,"problem",4,"facility@code")=100
|
||||
;^TMP("C0STBL",91,"problem",4,"facility@name")="VOE OFFICE INSTITUTION"
|
||||
;^TMP("C0STBL",91,"problem",4,"icd@value")="00.66"
|
||||
;^TMP("C0STBL",91,"problem",4,"id@value")=115
|
||||
;^TMP("C0STBL",91,"problem",4,"location@value")="DR OFFICE"
|
||||
;^TMP("C0STBL",91,"problem",4,"name@value")="00.66"
|
||||
;^TMP("C0STBL",91,"problem",4,"provider@code")=63
|
||||
;^TMP("C0STBL",91,"problem",4,"provider@name")="KING,MATTHEW MICHAEL"
|
||||
;^TMP("C0STBL",91,"problem",4,"removed@value")=0
|
||||
;^TMP("C0STBL",91,"problem",4,"status@value")="A"
|
||||
;^TMP("C0STBL",91,"problem",4,"unverified@value")=0
|
||||
;^TMP("C0STBL",91,"problem",4,"updated@value")=3110603
|
||||
;^TMP("C0STBL",91,"problem",5,"entered@value")=3110603
|
||||
;^TMP("C0STBL",91,"problem",5,"facility@code")=100
|
||||
;^TMP("C0STBL",91,"problem",5,"facility@name")="VOE OFFICE INSTITUTION"
|
||||
;^TMP("C0STBL",91,"problem",5,"icd@value")=37.21
|
||||
;^TMP("C0STBL",91,"problem",5,"id@value")=116
|
||||
;^TMP("C0STBL",91,"problem",5,"location@value")="DR OFFICE"
|
||||
;^TMP("C0STBL",91,"problem",5,"name@value")=37.21
|
||||
;^TMP("C0STBL",91,"problem",5,"provider@code")=63
|
||||
;^TMP("C0STBL",91,"problem",5,"provider@name")="KING,MATTHEW MICHAEL"
|
||||
;^TMP("C0STBL",91,"problem",5,"removed@value")=0
|
||||
;^TMP("C0STBL",91,"problem",5,"status@value")="A"
|
||||
;^TMP("C0STBL",91,"problem",5,"unverified@value")=0
|
||||
;^TMP("C0STBL",91,"problem",5,"updated@value")=3110603
|
||||
;^TMP("C0STBL",91,"problem",6,"entered@value")=3110603
|
||||
;^TMP("C0STBL",91,"problem",6,"facility@code")=100
|
||||
;^TMP("C0STBL",91,"problem",6,"facility@name")="VOE OFFICE INSTITUTION"
|
||||
;^TMP("C0STBL",91,"problem",6,"icd@value")=81.51
|
||||
;^TMP("C0STBL",91,"problem",6,"id@value")=117
|
||||
;^TMP("C0STBL",91,"problem",6,"location@value")="DR OFFICE"
|
||||
;^TMP("C0STBL",91,"problem",6,"name@value")=81.51
|
||||
;^TMP("C0STBL",91,"problem",6,"provider@code")=63
|
||||
;^TMP("C0STBL",91,"problem",6,"provider@name")="KING,MATTHEW MICHAEL"
|
||||
;^TMP("C0STBL",91,"problem",6,"removed@value")=0
|
||||
;^TMP("C0STBL",91,"problem",6,"status@value")="A"
|
||||
;^TMP("C0STBL",91,"problem",6,"unverified@value")=0
|
||||
;^TMP("C0STBL",91,"problem",6,"updated@value")=3110603
|
||||
;^TMP("C0STBL",91,"problem",7,"entered@value")=3110603
|
||||
;^TMP("C0STBL",91,"problem",7,"facility@code")=100
|
||||
;^TMP("C0STBL",91,"problem",7,"facility@name")="VOE OFFICE INSTITUTION"
|
||||
;^TMP("C0STBL",91,"problem",7,"icd@value")=47.09
|
||||
;^TMP("C0STBL",91,"problem",7,"id@value")=118
|
||||
;^TMP("C0STBL",91,"problem",7,"location@value")="DR OFFICE"
|
||||
;^TMP("C0STBL",91,"problem",7,"name@value")=47.09
|
||||
;^TMP("C0STBL",91,"problem",7,"provider@code")=63
|
||||
;^TMP("C0STBL",91,"problem",7,"provider@name")="KING,MATTHEW MICHAEL"
|
||||
;^TMP("C0STBL",91,"problem",7,"removed@value")=0
|
||||
;^TMP("C0STBL",91,"problem",7,"status@value")="A"
|
||||
;^TMP("C0STBL",91,"problem",7,"unverified@value")=0
|
||||
;^TMP("C0STBL",91,"problem",7,"updated@value")=3110603
|
||||
;^TMP("C0STBL",91,"problem",8,"entered@value")=3110603
|
||||
;^TMP("C0STBL",91,"problem",8,"facility@code")=100
|
||||
;^TMP("C0STBL",91,"problem",8,"facility@name")="VOE OFFICE INSTITUTION"
|
||||
;^TMP("C0STBL",91,"problem",8,"icd@value")="250.00"
|
||||
;^TMP("C0STBL",91,"problem",8,"id@value")=119
|
||||
;^TMP("C0STBL",91,"problem",8,"location@value")="DR OFFICE"
|
||||
;^TMP("C0STBL",91,"problem",8,"name@value")="Diabetes Mellitus without mentionof Complication, type II or unspecified type,"
|
||||
;^TMP("C0STBL",91,"problem",8,"provider@code")=63
|
||||
;^TMP("C0STBL",91,"problem",8,"provider@name")="KING,MATTHEW MICHAEL"
|
||||
;^TMP("C0STBL",91,"problem",8,"removed@value")=0
|
||||
;^TMP("C0STBL",91,"problem",8,"status@value")="A"
|
||||
;^TMP("C0STBL",91,"problem",8,"unverified@value")=0
|
||||
;^TMP("C0STBL",91,"problem",8,"updated@value")=3110603
|
||||
;
|
||||
; sample Smart lab result triples
|
||||
;
|
||||
;G("node16rk1fgdvx10882","code")="snomed:40930008"
|
||||
;G("node16rk1fgdvx10882","dcterms:title")="Hypothyroidism"
|
||||
;G("node16rk1fgdvx10882","rdf:type")="sp:CodedValue"
|
||||
;G("node16rk1fgdvx11051","code")="snomed:188155002"
|
||||
;G("node16rk1fgdvx11051","dcterms:title")="Primary malignant neoplasm of lower outer quadrant of female breast"
|
||||
;G("node16rk1fgdvx11051","rdf:type")="sp:CodedValue"
|
||||
;G("node16rk1fgdvx11073","code")="snomed:353295004"
|
||||
;G("node16rk1fgdvx11073","dcterms:title")="Toxic diffuse goiter"
|
||||
;G("node16rk1fgdvx11073","rdf:type")="sp:CodedValue"
|
||||
;G("node16rk1fgdvx11089","code")="snomed:54302000"
|
||||
;G("node16rk1fgdvx11089","dcterms:title")="Disorder of breast"
|
||||
;G("node16rk1fgdvx11089","rdf:type")="sp:CodedValue"
|
||||
;G("node16rk1fgdvx11351","code")="snomed:38341003"
|
||||
;G("node16rk1fgdvx11351","dcterms:title")="Essential hypertension"
|
||||
;G("node16rk1fgdvx11351","rdf:type")="sp:CodedValue"
|
||||
;G("node16rk1fgdvx11390","code")="snomed:44054006"
|
||||
;G("node16rk1fgdvx11390","dcterms:title")="Diabetes mellitus type 2"
|
||||
;G("node16rk1fgdvx11390","rdf:type")="sp:CodedValue"
|
||||
;G("node16rk1fgdvx11558","code")="snomed:195967001"
|
||||
;G("node16rk1fgdvx11558","dcterms:title")="Asthma"
|
||||
;G("node16rk1fgdvx11558","rdf:type")="sp:CodedValue"
|
||||
;G("node16rk1fgdvx11578","code")="snomed:254837009"
|
||||
;G("node16rk1fgdvx11578","dcterms:title")="Primary malignant neoplasm of female breast"
|
||||
;G("node16rk1fgdvx11578","rdf:type")="sp:CodedValue"
|
||||
;G("node16rk1fgdvx11687","code")="snomed:8517006"
|
||||
;G("node16rk1fgdvx11687","dcterms:title")="History of tobacco use"
|
||||
;G("node16rk1fgdvx11687","rdf:type")="sp:CodedValue"
|
||||
;G("node16rk1fgdvx11716","code")="snomed:55822004"
|
||||
;G("node16rk1fgdvx11716","dcterms:title")="Hyperlipidemia"
|
||||
;G("node16rk1fgdvx11716","rdf:type")="sp:CodedValue"
|
||||
;G("smart:1577780/problems/69560e4721e1","belongsTo")="smart:1577780"
|
||||
;G("smart:1577780/problems/69560e4721e1","problemName")="node16rk1fgdvx11089"
|
||||
;G("smart:1577780/problems/69560e4721e1","rdf:type")="sp:Problem"
|
||||
;G("smart:1577780/problems/69560e4721e1","startDate")="2005-08-02"
|
||||
;G("smart:1577780/problems/06ef10c4e92c","belongsTo")="smart:1577780"
|
||||
;G("smart:1577780/problems/06ef10c4e92c","problemName")="node16rk1fgdvx11051"
|
||||
;G("smart:1577780/problems/06ef10c4e92c","rdf:type")="sp:Problem"
|
||||
;G("smart:1577780/problems/06ef10c4e92c","startDate")="2006-02-20"
|
||||
;G("smart:1577780/problems/9894ba9dfe5a","belongsTo")="smart:1577780"
|
||||
;G("smart:1577780/problems/9894ba9dfe5a","problemName")="node16rk1fgdvx11578"
|
||||
;G("smart:1577780/problems/9894ba9dfe5a","rdf:type")="sp:Problem"
|
||||
;G("smart:1577780/problems/9894ba9dfe5a","startDate")="2005-08-22"
|
||||
;G("smart:1577780/problems/c109aa7a0675","belongsTo")="smart:1577780"
|
||||
;G("smart:1577780/problems/c109aa7a0675","problemName")="node16rk1fgdvx11558"
|
||||
;G("smart:1577780/problems/c109aa7a0675","rdf:type")="sp:Problem"
|
||||
;G("smart:1577780/problems/c109aa7a0675","startDate")="2005-09-22"
|
||||
;G("smart:1577780/problems/1c50100614a2","belongsTo")="smart:1577780"
|
||||
;G("smart:1577780/problems/1c50100614a2","problemName")="node16rk1fgdvx11073"
|
||||
;G("smart:1577780/problems/1c50100614a2","rdf:type")="sp:Problem"
|
||||
;G("smart:1577780/problems/1c50100614a2","startDate")="2007-02-21"
|
||||
;G("smart:1577780/problems/083dffb2c4a0","belongsTo")="smart:1577780"
|
||||
;G("smart:1577780/problems/083dffb2c4a0","problemName")="node16rk1fgdvx11390"
|
||||
;G("smart:1577780/problems/083dffb2c4a0","rdf:type")="sp:Problem"
|
||||
;G("smart:1577780/problems/083dffb2c4a0","startDate")="2007-01-07"
|
||||
;G("smart:1577780/problems/762b5639a2d1","belongsTo")="smart:1577780"
|
||||
;G("smart:1577780/problems/762b5639a2d1","problemName")="node16rk1fgdvx11687"
|
||||
;G("smart:1577780/problems/762b5639a2d1","rdf:type")="sp:Problem"
|
||||
;G("smart:1577780/problems/762b5639a2d1","startDate")="2006-02-20"
|
||||
;G("smart:1577780/problems/9dc9053dd6f4","belongsTo")="smart:1577780"
|
||||
;G("smart:1577780/problems/9dc9053dd6f4","problemName")="node16rk1fgdvx11716"
|
||||
;G("smart:1577780/problems/9dc9053dd6f4","rdf:type")="sp:Problem"
|
||||
;G("smart:1577780/problems/9dc9053dd6f4","startDate")="2008-04-08"
|
||||
;G("smart:1577780/problems/e3fe9b7ee552","belongsTo")="smart:1577780"
|
||||
;G("smart:1577780/problems/e3fe9b7ee552","problemName")="node16rk1fgdvx10882"
|
||||
;G("smart:1577780/problems/e3fe9b7ee552","rdf:type")="sp:Problem"
|
||||
;G("smart:1577780/problems/e3fe9b7ee552","startDate")="2005-10-27"
|
||||
;G("smart:1577780/problems/9933307e8f95","belongsTo")="smart:1577780"
|
||||
;G("smart:1577780/problems/9933307e8f95","problemName")="node16rk1fgdvx11351"
|
||||
;G("smart:1577780/problems/9933307e8f95","rdf:type")="sp:Problem"
|
||||
;G("smart:1577780/problems/9933307e8f95","startDate")="2005-08-22"
|
||||
;G("snomed:188155002","dcterms:identifier")=188155002
|
||||
;G("snomed:188155002","dcterms:title")="Primary malignant neoplasm of lower outer quadrant of female breast"
|
||||
;G("snomed:188155002","rdf:type")="sp:Code"
|
||||
;G("snomed:188155002","system")="http://purl.bioontology.org/ontology/SNOMEDCT"
|
||||
;G("snomed:195967001","dcterms:identifier")=195967001
|
||||
;G("snomed:195967001","dcterms:title")="Asthma"
|
||||
;G("snomed:195967001","rdf:type")="sp:Code"
|
||||
;G("snomed:195967001","system")="http://purl.bioontology.org/ontology/SNOMEDCT"
|
||||
;G("snomed:254837009","dcterms:identifier")=254837009
|
||||
;G("snomed:254837009","dcterms:title")="Primary malignant neoplasm of female breast"
|
||||
;G("snomed:254837009","rdf:type")="sp:Code"
|
||||
;G("snomed:254837009","system")="http://purl.bioontology.org/ontology/SNOMEDCT"
|
||||
;G("snomed:353295004","dcterms:identifier")=353295004
|
||||
;G("snomed:353295004","dcterms:title")="Toxic diffuse goiter"
|
||||
;G("snomed:353295004","rdf:type")="sp:Code"
|
||||
;G("snomed:353295004","system")="http://purl.bioontology.org/ontology/SNOMEDCT"
|
||||
;G("snomed:38341003","dcterms:identifier")=38341003
|
||||
;G("snomed:38341003","dcterms:title")="Essential hypertension"
|
||||
;G("snomed:38341003","rdf:type")="sp:Code"
|
||||
;G("snomed:38341003","system")="http://purl.bioontology.org/ontology/SNOMEDCT"
|
||||
;G("snomed:40930008","dcterms:identifier")=40930008
|
||||
;G("snomed:40930008","dcterms:title")="Hypothyroidism"
|
||||
;G("snomed:40930008","rdf:type")="sp:Code"
|
||||
;G("snomed:40930008","system")="http://purl.bioontology.org/ontology/SNOMEDCT"
|
||||
;G("snomed:44054006","dcterms:identifier")=44054006
|
||||
;G("snomed:44054006","dcterms:title")="Diabetes mellitus type 2"
|
||||
;G("snomed:44054006","rdf:type")="sp:Code"
|
||||
;G("snomed:44054006","system")="http://purl.bioontology.org/ontology/SNOMEDCT"
|
||||
;G("snomed:54302000","dcterms:identifier")=54302000
|
||||
;G("snomed:54302000","dcterms:title")="Disorder of breast"
|
||||
;G("snomed:54302000","rdf:type")="sp:Code"
|
||||
;G("snomed:54302000","system")="http://purl.bioontology.org/ontology/SNOMEDCT"
|
||||
;G("snomed:55822004","dcterms:identifier")=55822004
|
||||
;G("snomed:55822004","dcterms:title")="Hyperlipidemia"
|
||||
;G("snomed:55822004","rdf:type")="sp:Code"
|
||||
;G("snomed:55822004","system")="http://purl.bioontology.org/ontology/SNOMEDCT"
|
||||
;G("snomed:8517006","dcterms:identifier")=8517006
|
||||
;G("snomed:8517006","dcterms:title")="History of tobacco use"
|
||||
;G("snomed:8517006","rdf:type")="sp:Code"
|
||||
;G("snomed:8517006","system")="http://purl.bioontology.org/ontology/SNOMEDCT/"
|
||||
|
||||
;
|
||||
PROB(GRTN,C0SARY) ; GRTN, passed by reference,
|
||||
; is the return name of the graph created. "" if none
|
||||
; C0SARY is passed in by reference and is the NHIN array of problems
|
||||
;
|
||||
I $O(C0SARY("problem",""))="" D Q ;
|
||||
. I $D(DEBUG) W !,"No Problems"
|
||||
S GRTN="" ; default to no problems
|
||||
N C0SGRF
|
||||
S C0SGRF="vistaSmart:"_ZPATID_"/problems"
|
||||
I $D(DEBUG) W !,"Processing ",C0SGRF
|
||||
D DELGRAPH^C0XF2N(C0SGRF) ; delete the old graph
|
||||
D INITFARY^C0XF2N("C0XFARY") ; which triple store to use
|
||||
N FARY S FARY="C0XFARY"
|
||||
D USEFARY^C0XF2N(FARY)
|
||||
D VOCINIT^C0XUTIL
|
||||
;
|
||||
D STARTADD^C0XF2N ; initialize to create triples
|
||||
;
|
||||
N ZI S ZI=""
|
||||
F S ZI=$O(C0SARY("problem",ZI)) Q:ZI="" D ;
|
||||
. N LRN,ZR ; ZR is the local array for building the new triples
|
||||
. S LRN=$NA(C0SARY("problem",ZI)) ; base for values in this lab result
|
||||
. ;
|
||||
. N PROBID ; unique Id for this problem
|
||||
. S PROBID=C0SGRF_"/"_$$LKY17^C0XF2N ; use a random number
|
||||
. ;
|
||||
. ; i don't like this because the same problems gets a
|
||||
. ; different ID every time it's reported. Can't trace it back to VistA
|
||||
. ; I'd rather be using id@value ie "id@value")="118"
|
||||
. ;
|
||||
. N SNOMED S SNOMED=$G(@LRN@("icd@value"))
|
||||
. N SNOGRF S SNOGRF="snomed:"_SNOMED
|
||||
. N SNOTIT S SNOTIT=$G(@LRN@("name@value"))
|
||||
. I $D(DEBUG) D ;
|
||||
. . W !,"Processing Problem List ",PROBID
|
||||
. . W !,"problem: ",SNOTIT
|
||||
. . W !,"code: ",SNOMED
|
||||
. ;
|
||||
. ; first do the base result graph
|
||||
. ;
|
||||
. S ZR("rdf:type")="sp:Problem"
|
||||
. S ZR("sp:belongsTo")=C0SGRF ; the subject for this patient's problems
|
||||
. ; ie /vista/smart/99912345/problems
|
||||
. ;
|
||||
. N PROBNAME S PROBNAME=$$ANONS^C0XF2N ; new node for problem name
|
||||
. S ZR("sp:problemName")=PROBNAME
|
||||
. ;
|
||||
. N STARTDT S STARTDT=$$SPDATE^C0SUTIL($G(@LRN@("entered@value")))
|
||||
. S ZR("sp:startDate")=STARTDT
|
||||
. ;
|
||||
. D ADDINN^C0XF2N(C0SGRF,PROBID,.ZR) ; addIfNotNull the triples
|
||||
. K ZR ; clean up
|
||||
. ;
|
||||
. ; create the problemName graph
|
||||
. ;
|
||||
. S ZR("rdf:type")="sp:CodedValue"
|
||||
. S ZR("sp:code")="snomed:"_SNOMED
|
||||
. S ZR("dcterms:title")=$G(@LRN@("name@value"))
|
||||
. D ADDINN^C0XF2N(C0SGRF,PROBNAME,.ZR)
|
||||
. K ZR
|
||||
. ;
|
||||
. ; create snomed graph
|
||||
. ;
|
||||
. S ZR("rdf:type")="sp:Code"
|
||||
. S ZR("sp:system")="http://purl.bioontology.org/ontology/SNOMEDCT"
|
||||
. S ZR("dcterms:identifier")=SNOMED
|
||||
. S ZR("dcterms:title")=SNOTIT
|
||||
. D ADDINN^C0XF2N(C0SGRF,SNOGRF,.ZR)
|
||||
. K ZR
|
||||
. ;
|
||||
D BULKLOAD^C0XF2N(.C0XFDA)
|
||||
S GRTN=C0SGRF
|
||||
Q
|
||||
;
|
|
@ -0,0 +1,340 @@
|
|||
C0SPROB ; GPL - Smart Problem Processing ;5/01/12 17:05
|
||||
;;0.1;C0S;nopatch;noreleasedate;Build 2
|
||||
;Copyright 2012 George Lilly. Licensed under the terms of the GNU
|
||||
;General Public License See attached copy of the License.
|
||||
;
|
||||
;This program is free software; you can redistribute it and/or modify
|
||||
;it under the terms of the GNU General Public License as published by
|
||||
;the Free Software Foundation; either version 2 of the License, or
|
||||
;(at your option) any later version.
|
||||
;
|
||||
;This program is distributed in the hope that it will be useful,
|
||||
;but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;GNU General Public License for more details.
|
||||
;
|
||||
;You should have received a copy of the GNU General Public License along
|
||||
;with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
;
|
||||
Q
|
||||
;
|
||||
; sample VistA NHIN problem list
|
||||
;
|
||||
;^TMP("C0STBL",91,"problem",1,"acuity@value")="C"
|
||||
;^TMP("C0STBL",91,"problem",1,"entered@value")=3110531
|
||||
;^TMP("C0STBL",91,"problem",1,"facility@code")=100
|
||||
;^TMP("C0STBL",91,"problem",1,"facility@name")="VOE OFFICE INSTITUTION"
|
||||
;^TMP("C0STBL",91,"problem",1,"icd@value")=414.9
|
||||
;^TMP("C0STBL",91,"problem",1,"id@value")=100
|
||||
;^TMP("C0STBL",91,"problem",1,"location@value")="DR OFFICE"
|
||||
;^TMP("C0STBL",91,"problem",1,"name@value")="Coronary Artery Disease"
|
||||
;^TMP("C0STBL",91,"problem",1,"onset@value")=3100201
|
||||
;^TMP("C0STBL",91,"problem",1,"provider@code")=63
|
||||
;^TMP("C0STBL",91,"problem",1,"provider@name")="KING,MATTHEW MICHAEL"
|
||||
;^TMP("C0STBL",91,"problem",1,"removed@value")=0
|
||||
;^TMP("C0STBL",91,"problem",1,"sc@value")=0
|
||||
;^TMP("C0STBL",91,"problem",1,"status@value")="A"
|
||||
;^TMP("C0STBL",91,"problem",1,"unverified@value")=0
|
||||
;^TMP("C0STBL",91,"problem",1,"updated@value")=3110531
|
||||
;^TMP("C0STBL",91,"problem",2,"acuity@value")="C"
|
||||
;^TMP("C0STBL",91,"problem",2,"entered@value")=3110602
|
||||
;^TMP("C0STBL",91,"problem",2,"facility@code")=100
|
||||
;^TMP("C0STBL",91,"problem",2,"facility@name")="VOE OFFICE INSTITUTION"
|
||||
;^TMP("C0STBL",91,"problem",2,"icd@value")=780.2
|
||||
;^TMP("C0STBL",91,"problem",2,"id@value")=108
|
||||
;^TMP("C0STBL",91,"problem",2,"name@value")="Syncope and collapse"
|
||||
;^TMP("C0STBL",91,"problem",2,"onset@value")=3110102
|
||||
;^TMP("C0STBL",91,"problem",2,"provider@code")=63
|
||||
;^TMP("C0STBL",91,"problem",2,"provider@name")="KING,MATTHEW MICHAEL"
|
||||
;^TMP("C0STBL",91,"problem",2,"removed@value")=0
|
||||
;^TMP("C0STBL",91,"problem",2,"sc@value")=0
|
||||
;^TMP("C0STBL",91,"problem",2,"status@value")="A"
|
||||
;^TMP("C0STBL",91,"problem",2,"unverified@value")=0
|
||||
;^TMP("C0STBL",91,"problem",2,"updated@value")=3110602
|
||||
;^TMP("C0STBL",91,"problem",3,"acuity@value")="C"
|
||||
;^TMP("C0STBL",91,"problem",3,"entered@value")=3110602
|
||||
;^TMP("C0STBL",91,"problem",3,"facility@code")=100
|
||||
;^TMP("C0STBL",91,"problem",3,"facility@name")="VOE OFFICE INSTITUTION"
|
||||
;^TMP("C0STBL",91,"problem",3,"icd@value")=433.91
|
||||
;^TMP("C0STBL",91,"problem",3,"id@value")=109
|
||||
;^TMP("C0STBL",91,"problem",3,"name@value")="Occlusion and Stenosis of Unspecifid Precerebral Artery with Cerebral Infarctio"
|
||||
;^TMP("C0STBL",91,"problem",3,"onset@value")=3100101
|
||||
;^TMP("C0STBL",91,"problem",3,"provider@code")=63
|
||||
;^TMP("C0STBL",91,"problem",3,"provider@name")="KING,MATTHEW MICHAEL"
|
||||
;^TMP("C0STBL",91,"problem",3,"removed@value")=0
|
||||
;^TMP("C0STBL",91,"problem",3,"sc@value")=0
|
||||
;^TMP("C0STBL",91,"problem",3,"status@value")="A"
|
||||
;^TMP("C0STBL",91,"problem",3,"unverified@value")=0
|
||||
;^TMP("C0STBL",91,"problem",3,"updated@value")=3110602
|
||||
;^TMP("C0STBL",91,"problem",4,"entered@value")=3110603
|
||||
;^TMP("C0STBL",91,"problem",4,"facility@code")=100
|
||||
;^TMP("C0STBL",91,"problem",4,"facility@name")="VOE OFFICE INSTITUTION"
|
||||
;^TMP("C0STBL",91,"problem",4,"icd@value")="00.66"
|
||||
;^TMP("C0STBL",91,"problem",4,"id@value")=115
|
||||
;^TMP("C0STBL",91,"problem",4,"location@value")="DR OFFICE"
|
||||
;^TMP("C0STBL",91,"problem",4,"name@value")="00.66"
|
||||
;^TMP("C0STBL",91,"problem",4,"provider@code")=63
|
||||
;^TMP("C0STBL",91,"problem",4,"provider@name")="KING,MATTHEW MICHAEL"
|
||||
;^TMP("C0STBL",91,"problem",4,"removed@value")=0
|
||||
;^TMP("C0STBL",91,"problem",4,"status@value")="A"
|
||||
;^TMP("C0STBL",91,"problem",4,"unverified@value")=0
|
||||
;^TMP("C0STBL",91,"problem",4,"updated@value")=3110603
|
||||
;^TMP("C0STBL",91,"problem",5,"entered@value")=3110603
|
||||
;^TMP("C0STBL",91,"problem",5,"facility@code")=100
|
||||
;^TMP("C0STBL",91,"problem",5,"facility@name")="VOE OFFICE INSTITUTION"
|
||||
;^TMP("C0STBL",91,"problem",5,"icd@value")=37.21
|
||||
;^TMP("C0STBL",91,"problem",5,"id@value")=116
|
||||
;^TMP("C0STBL",91,"problem",5,"location@value")="DR OFFICE"
|
||||
;^TMP("C0STBL",91,"problem",5,"name@value")=37.21
|
||||
;^TMP("C0STBL",91,"problem",5,"provider@code")=63
|
||||
;^TMP("C0STBL",91,"problem",5,"provider@name")="KING,MATTHEW MICHAEL"
|
||||
;^TMP("C0STBL",91,"problem",5,"removed@value")=0
|
||||
;^TMP("C0STBL",91,"problem",5,"status@value")="A"
|
||||
;^TMP("C0STBL",91,"problem",5,"unverified@value")=0
|
||||
;^TMP("C0STBL",91,"problem",5,"updated@value")=3110603
|
||||
;^TMP("C0STBL",91,"problem",6,"entered@value")=3110603
|
||||
;^TMP("C0STBL",91,"problem",6,"facility@code")=100
|
||||
;^TMP("C0STBL",91,"problem",6,"facility@name")="VOE OFFICE INSTITUTION"
|
||||
;^TMP("C0STBL",91,"problem",6,"icd@value")=81.51
|
||||
;^TMP("C0STBL",91,"problem",6,"id@value")=117
|
||||
;^TMP("C0STBL",91,"problem",6,"location@value")="DR OFFICE"
|
||||
;^TMP("C0STBL",91,"problem",6,"name@value")=81.51
|
||||
;^TMP("C0STBL",91,"problem",6,"provider@code")=63
|
||||
;^TMP("C0STBL",91,"problem",6,"provider@name")="KING,MATTHEW MICHAEL"
|
||||
;^TMP("C0STBL",91,"problem",6,"removed@value")=0
|
||||
;^TMP("C0STBL",91,"problem",6,"status@value")="A"
|
||||
;^TMP("C0STBL",91,"problem",6,"unverified@value")=0
|
||||
;^TMP("C0STBL",91,"problem",6,"updated@value")=3110603
|
||||
;^TMP("C0STBL",91,"problem",7,"entered@value")=3110603
|
||||
;^TMP("C0STBL",91,"problem",7,"facility@code")=100
|
||||
;^TMP("C0STBL",91,"problem",7,"facility@name")="VOE OFFICE INSTITUTION"
|
||||
;^TMP("C0STBL",91,"problem",7,"icd@value")=47.09
|
||||
;^TMP("C0STBL",91,"problem",7,"id@value")=118
|
||||
;^TMP("C0STBL",91,"problem",7,"location@value")="DR OFFICE"
|
||||
;^TMP("C0STBL",91,"problem",7,"name@value")=47.09
|
||||
;^TMP("C0STBL",91,"problem",7,"provider@code")=63
|
||||
;^TMP("C0STBL",91,"problem",7,"provider@name")="KING,MATTHEW MICHAEL"
|
||||
;^TMP("C0STBL",91,"problem",7,"removed@value")=0
|
||||
;^TMP("C0STBL",91,"problem",7,"status@value")="A"
|
||||
;^TMP("C0STBL",91,"problem",7,"unverified@value")=0
|
||||
;^TMP("C0STBL",91,"problem",7,"updated@value")=3110603
|
||||
;^TMP("C0STBL",91,"problem",8,"entered@value")=3110603
|
||||
;^TMP("C0STBL",91,"problem",8,"facility@code")=100
|
||||
;^TMP("C0STBL",91,"problem",8,"facility@name")="VOE OFFICE INSTITUTION"
|
||||
;^TMP("C0STBL",91,"problem",8,"icd@value")="250.00"
|
||||
;^TMP("C0STBL",91,"problem",8,"id@value")=119
|
||||
;^TMP("C0STBL",91,"problem",8,"location@value")="DR OFFICE"
|
||||
;^TMP("C0STBL",91,"problem",8,"name@value")="Diabetes Mellitus without mentionof Complication, type II or unspecified type,"
|
||||
;^TMP("C0STBL",91,"problem",8,"provider@code")=63
|
||||
;^TMP("C0STBL",91,"problem",8,"provider@name")="KING,MATTHEW MICHAEL"
|
||||
;^TMP("C0STBL",91,"problem",8,"removed@value")=0
|
||||
;^TMP("C0STBL",91,"problem",8,"status@value")="A"
|
||||
;^TMP("C0STBL",91,"problem",8,"unverified@value")=0
|
||||
;^TMP("C0STBL",91,"problem",8,"updated@value")=3110603
|
||||
;
|
||||
; sample Smart lab result triples
|
||||
;
|
||||
;G("node16rk1fgdvx10882","code")="snomed:40930008"
|
||||
;G("node16rk1fgdvx10882","dcterms:title")="Hypothyroidism"
|
||||
;G("node16rk1fgdvx10882","rdf:type")="sp:CodedValue"
|
||||
;G("node16rk1fgdvx11051","code")="snomed:188155002"
|
||||
;G("node16rk1fgdvx11051","dcterms:title")="Primary malignant neoplasm of lower outer quadrant of female breast"
|
||||
;G("node16rk1fgdvx11051","rdf:type")="sp:CodedValue"
|
||||
;G("node16rk1fgdvx11073","code")="snomed:353295004"
|
||||
;G("node16rk1fgdvx11073","dcterms:title")="Toxic diffuse goiter"
|
||||
;G("node16rk1fgdvx11073","rdf:type")="sp:CodedValue"
|
||||
;G("node16rk1fgdvx11089","code")="snomed:54302000"
|
||||
;G("node16rk1fgdvx11089","dcterms:title")="Disorder of breast"
|
||||
;G("node16rk1fgdvx11089","rdf:type")="sp:CodedValue"
|
||||
;G("node16rk1fgdvx11351","code")="snomed:38341003"
|
||||
;G("node16rk1fgdvx11351","dcterms:title")="Essential hypertension"
|
||||
;G("node16rk1fgdvx11351","rdf:type")="sp:CodedValue"
|
||||
;G("node16rk1fgdvx11390","code")="snomed:44054006"
|
||||
;G("node16rk1fgdvx11390","dcterms:title")="Diabetes mellitus type 2"
|
||||
;G("node16rk1fgdvx11390","rdf:type")="sp:CodedValue"
|
||||
;G("node16rk1fgdvx11558","code")="snomed:195967001"
|
||||
;G("node16rk1fgdvx11558","dcterms:title")="Asthma"
|
||||
;G("node16rk1fgdvx11558","rdf:type")="sp:CodedValue"
|
||||
;G("node16rk1fgdvx11578","code")="snomed:254837009"
|
||||
;G("node16rk1fgdvx11578","dcterms:title")="Primary malignant neoplasm of female breast"
|
||||
;G("node16rk1fgdvx11578","rdf:type")="sp:CodedValue"
|
||||
;G("node16rk1fgdvx11687","code")="snomed:8517006"
|
||||
;G("node16rk1fgdvx11687","dcterms:title")="History of tobacco use"
|
||||
;G("node16rk1fgdvx11687","rdf:type")="sp:CodedValue"
|
||||
;G("node16rk1fgdvx11716","code")="snomed:55822004"
|
||||
;G("node16rk1fgdvx11716","dcterms:title")="Hyperlipidemia"
|
||||
;G("node16rk1fgdvx11716","rdf:type")="sp:CodedValue"
|
||||
;G("smart:1577780/problems/69560e4721e1","belongsTo")="smart:1577780"
|
||||
;G("smart:1577780/problems/69560e4721e1","problemName")="node16rk1fgdvx11089"
|
||||
;G("smart:1577780/problems/69560e4721e1","rdf:type")="sp:Problem"
|
||||
;G("smart:1577780/problems/69560e4721e1","startDate")="2005-08-02"
|
||||
;G("smart:1577780/problems/06ef10c4e92c","belongsTo")="smart:1577780"
|
||||
;G("smart:1577780/problems/06ef10c4e92c","problemName")="node16rk1fgdvx11051"
|
||||
;G("smart:1577780/problems/06ef10c4e92c","rdf:type")="sp:Problem"
|
||||
;G("smart:1577780/problems/06ef10c4e92c","startDate")="2006-02-20"
|
||||
;G("smart:1577780/problems/9894ba9dfe5a","belongsTo")="smart:1577780"
|
||||
;G("smart:1577780/problems/9894ba9dfe5a","problemName")="node16rk1fgdvx11578"
|
||||
;G("smart:1577780/problems/9894ba9dfe5a","rdf:type")="sp:Problem"
|
||||
;G("smart:1577780/problems/9894ba9dfe5a","startDate")="2005-08-22"
|
||||
;G("smart:1577780/problems/c109aa7a0675","belongsTo")="smart:1577780"
|
||||
;G("smart:1577780/problems/c109aa7a0675","problemName")="node16rk1fgdvx11558"
|
||||
;G("smart:1577780/problems/c109aa7a0675","rdf:type")="sp:Problem"
|
||||
;G("smart:1577780/problems/c109aa7a0675","startDate")="2005-09-22"
|
||||
;G("smart:1577780/problems/1c50100614a2","belongsTo")="smart:1577780"
|
||||
;G("smart:1577780/problems/1c50100614a2","problemName")="node16rk1fgdvx11073"
|
||||
;G("smart:1577780/problems/1c50100614a2","rdf:type")="sp:Problem"
|
||||
;G("smart:1577780/problems/1c50100614a2","startDate")="2007-02-21"
|
||||
;G("smart:1577780/problems/083dffb2c4a0","belongsTo")="smart:1577780"
|
||||
;G("smart:1577780/problems/083dffb2c4a0","problemName")="node16rk1fgdvx11390"
|
||||
;G("smart:1577780/problems/083dffb2c4a0","rdf:type")="sp:Problem"
|
||||
;G("smart:1577780/problems/083dffb2c4a0","startDate")="2007-01-07"
|
||||
;G("smart:1577780/problems/762b5639a2d1","belongsTo")="smart:1577780"
|
||||
;G("smart:1577780/problems/762b5639a2d1","problemName")="node16rk1fgdvx11687"
|
||||
;G("smart:1577780/problems/762b5639a2d1","rdf:type")="sp:Problem"
|
||||
;G("smart:1577780/problems/762b5639a2d1","startDate")="2006-02-20"
|
||||
;G("smart:1577780/problems/9dc9053dd6f4","belongsTo")="smart:1577780"
|
||||
;G("smart:1577780/problems/9dc9053dd6f4","problemName")="node16rk1fgdvx11716"
|
||||
;G("smart:1577780/problems/9dc9053dd6f4","rdf:type")="sp:Problem"
|
||||
;G("smart:1577780/problems/9dc9053dd6f4","startDate")="2008-04-08"
|
||||
;G("smart:1577780/problems/e3fe9b7ee552","belongsTo")="smart:1577780"
|
||||
;G("smart:1577780/problems/e3fe9b7ee552","problemName")="node16rk1fgdvx10882"
|
||||
;G("smart:1577780/problems/e3fe9b7ee552","rdf:type")="sp:Problem"
|
||||
;G("smart:1577780/problems/e3fe9b7ee552","startDate")="2005-10-27"
|
||||
;G("smart:1577780/problems/9933307e8f95","belongsTo")="smart:1577780"
|
||||
;G("smart:1577780/problems/9933307e8f95","problemName")="node16rk1fgdvx11351"
|
||||
;G("smart:1577780/problems/9933307e8f95","rdf:type")="sp:Problem"
|
||||
;G("smart:1577780/problems/9933307e8f95","startDate")="2005-08-22"
|
||||
;G("snomed:188155002","dcterms:identifier")=188155002
|
||||
;G("snomed:188155002","dcterms:title")="Primary malignant neoplasm of lower outer quadrant of female breast"
|
||||
;G("snomed:188155002","rdf:type")="sp:Code"
|
||||
;G("snomed:188155002","system")="http://purl.bioontology.org/ontology/SNOMEDCT"
|
||||
;G("snomed:195967001","dcterms:identifier")=195967001
|
||||
;G("snomed:195967001","dcterms:title")="Asthma"
|
||||
;G("snomed:195967001","rdf:type")="sp:Code"
|
||||
;G("snomed:195967001","system")="http://purl.bioontology.org/ontology/SNOMEDCT"
|
||||
;G("snomed:254837009","dcterms:identifier")=254837009
|
||||
;G("snomed:254837009","dcterms:title")="Primary malignant neoplasm of female breast"
|
||||
;G("snomed:254837009","rdf:type")="sp:Code"
|
||||
;G("snomed:254837009","system")="http://purl.bioontology.org/ontology/SNOMEDCT"
|
||||
;G("snomed:353295004","dcterms:identifier")=353295004
|
||||
;G("snomed:353295004","dcterms:title")="Toxic diffuse goiter"
|
||||
;G("snomed:353295004","rdf:type")="sp:Code"
|
||||
;G("snomed:353295004","system")="http://purl.bioontology.org/ontology/SNOMEDCT"
|
||||
;G("snomed:38341003","dcterms:identifier")=38341003
|
||||
;G("snomed:38341003","dcterms:title")="Essential hypertension"
|
||||
;G("snomed:38341003","rdf:type")="sp:Code"
|
||||
;G("snomed:38341003","system")="http://purl.bioontology.org/ontology/SNOMEDCT"
|
||||
;G("snomed:40930008","dcterms:identifier")=40930008
|
||||
;G("snomed:40930008","dcterms:title")="Hypothyroidism"
|
||||
;G("snomed:40930008","rdf:type")="sp:Code"
|
||||
;G("snomed:40930008","system")="http://purl.bioontology.org/ontology/SNOMEDCT"
|
||||
;G("snomed:44054006","dcterms:identifier")=44054006
|
||||
;G("snomed:44054006","dcterms:title")="Diabetes mellitus type 2"
|
||||
;G("snomed:44054006","rdf:type")="sp:Code"
|
||||
;G("snomed:44054006","system")="http://purl.bioontology.org/ontology/SNOMEDCT"
|
||||
;G("snomed:54302000","dcterms:identifier")=54302000
|
||||
;G("snomed:54302000","dcterms:title")="Disorder of breast"
|
||||
;G("snomed:54302000","rdf:type")="sp:Code"
|
||||
;G("snomed:54302000","system")="http://purl.bioontology.org/ontology/SNOMEDCT"
|
||||
;G("snomed:55822004","dcterms:identifier")=55822004
|
||||
;G("snomed:55822004","dcterms:title")="Hyperlipidemia"
|
||||
;G("snomed:55822004","rdf:type")="sp:Code"
|
||||
;G("snomed:55822004","system")="http://purl.bioontology.org/ontology/SNOMEDCT"
|
||||
;G("snomed:8517006","dcterms:identifier")=8517006
|
||||
;G("snomed:8517006","dcterms:title")="History of tobacco use"
|
||||
;G("snomed:8517006","rdf:type")="sp:Code"
|
||||
;G("snomed:8517006","system")="http://purl.bioontology.org/ontology/SNOMEDCT/"
|
||||
|
||||
;
|
||||
PROB(GRTN,C0SARY) ; GRTN, passed by reference,
|
||||
; is the return name of the graph created. "" if none
|
||||
; C0SARY is passed in by reference and is the NHIN array of problems
|
||||
;
|
||||
I $O(C0SARY("problem",""))="" D Q ;
|
||||
. I $D(DEBUG) W !,"No Problems"
|
||||
S GRTN="" ; default to no problems
|
||||
N C0SGRF
|
||||
S C0SGRF="/vista/smart/"_ZPATID_"/problems"
|
||||
I $D(DEBUG) W !,"Processing ",C0SGRF
|
||||
D DELGRAPH^C0XF2N(C0SGRF) ; delete the old graph
|
||||
D INITFARY^C0XF2N("C0XFARY") ; which triple store to use
|
||||
N FARY S FARY="C0XFARY"
|
||||
D USEFARY^C0XF2N(FARY)
|
||||
D VOCINIT^C0XUTIL
|
||||
;
|
||||
D STARTADD^C0XF2N ; initialize to create triples
|
||||
;
|
||||
N ZI S ZI=""
|
||||
F S ZI=$O(C0SARY("problem",ZI)) Q:ZI="" D ;
|
||||
. N LRN,ZR ; ZR is the local array for building the new triples
|
||||
. S LRN=$NA(C0SARY("problem",ZI)) ; base for values in this lab result
|
||||
. ;
|
||||
. N PROBID ; unique Id for this problem
|
||||
. S PROBID=C0SGRF_"/"_$$LKY17^C0XF2N ; use a random number
|
||||
. ;
|
||||
. ; i don't like this because the same problems gets a
|
||||
. ; different ID every time it's reported. Can't trace it back to VistA
|
||||
. ; I'd rather be using id@value ie "id@value")="118"
|
||||
. ;
|
||||
. N SNOMED,ICD S ICD=$G(@LRN@("icd@value"))
|
||||
. S SNOMED=$$SNOMED(ICD) ; look up the snomed code in the map
|
||||
. N SNOGRF ; graph for SNOMED code
|
||||
. I SNOMED="" D ;
|
||||
. . S SNOMED=ICD ; if not found, return the ICD code
|
||||
. . S SNOGRF="icd9:"_SNOMED
|
||||
. E S SNOGRF="snomed:"_SNOMED
|
||||
. N SNOTIT S SNOTIT=$G(@LRN@("name@value"))
|
||||
. I $D(DEBUG) D ;
|
||||
. . W !,"Processing Problem List ",PROBID
|
||||
. . W !,"problem: ",SNOTIT
|
||||
. . W !,"code: ",SNOMED
|
||||
. ;
|
||||
. ; first do the base result graph
|
||||
. ;
|
||||
. S ZR("rdf:type")="sp:Problem"
|
||||
. S ZR("sp:belongsTo")=C0SGRF ; the subject for this patient's problems
|
||||
. ; ie /vista/smart/99912345/problems
|
||||
. ;
|
||||
. N PROBNAME S PROBNAME=$$ANONS^C0XF2N ; new node for problem name
|
||||
. S ZR("sp:problemName")=PROBNAME
|
||||
. ;
|
||||
. N STARTDT S STARTDT=$$SPDATE^C0SUTIL($G(@LRN@("entered@value")))
|
||||
. S ZR("sp:startDate")=STARTDT
|
||||
. ;
|
||||
. D ADDINN^C0XF2N(C0SGRF,PROBID,.ZR) ; addIfNotNull the triples
|
||||
. K ZR ; clean up
|
||||
. ;
|
||||
. ; create the problemName graph
|
||||
. ;
|
||||
. S ZR("rdf:type")="sp:CodedValue"
|
||||
. ;S ZR("sp:code")="snomed:"_SNOMED
|
||||
. S ZR("sp:code")=SNOGRF
|
||||
. S ZR("dcterms:title")=$G(@LRN@("name@value"))
|
||||
. D ADDINN^C0XF2N(C0SGRF,PROBNAME,.ZR)
|
||||
. K ZR
|
||||
. ;
|
||||
. ; create snomed graph
|
||||
. ;
|
||||
. S ZR("rdf:type")="sp:Code"
|
||||
. S ZR("sp:system")="http://purl.bioontology.org/ontology/SNOMEDCT"
|
||||
. I ZR("sp:system")["icd9" S ZR("sp:system")="http://purl.bioontology.org/ontology/ICD9"
|
||||
. S ZR("dcterms:identifier")=SNOMED
|
||||
. S ZR("dcterms:title")=SNOTIT
|
||||
. D ADDINN^C0XF2N(C0SGRF,SNOGRF,.ZR)
|
||||
. K ZR
|
||||
. ;
|
||||
D BULKLOAD^C0XF2N(.C0XFDA)
|
||||
S GRTN=C0SGRF
|
||||
Q
|
||||
;
|
||||
SNOMED(ZICD) ; extrinsic which returns SNOMED code given an ICD9 code
|
||||
; requires the mapping table installed in the triplestore
|
||||
;
|
||||
N ZSN,ZARY,ZSUB
|
||||
S ZSUB=$$subject^C0XGET1(,ZICD) ; subject of the ICD9 code
|
||||
D objects^C0XGET1(.ZARY,ZSUB,"cg:ontology#toCode")
|
||||
S ZSN=$O(ZARY(""))
|
||||
I $D(DEBUG) W !,ZSN," ",$$object^C0XGET1(ZSUB,"rdfs:label")
|
||||
Q ZSN
|
||||
;
|
|
@ -0,0 +1,54 @@
|
|||
C0STBL ; GPL - Smart Container CREATE A TABLE OF NHINV VALUES;2/22/12 17:05
|
||||
;;0.1;C0S;nopatch;noreleasedate;Build 2
|
||||
;Copyright 2012 George Lilly. Licensed under the terms of the GNU
|
||||
;General Public License See attached copy of the License.
|
||||
;
|
||||
;This program is free software; you can redistribute it and/or modify
|
||||
;it under the terms of the GNU General Public License as published by
|
||||
;the Free Software Foundation; either version 2 of the License, or
|
||||
;(at your option) any later version.
|
||||
;
|
||||
;This program is distributed in the hope that it will be useful,
|
||||
;but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;GNU General Public License for more details.
|
||||
;
|
||||
;You should have received a copy of the GNU General Public License along
|
||||
;with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
;
|
||||
Q
|
||||
EN(BEGDFN,DFNCNT,ZPART) ; START IS A DFN
|
||||
I '$D(BEGDFN) S BDGDFN=""
|
||||
I '$D(DFNCNT) S DFNCNT=150
|
||||
I '$D(ZPART) S ZPART=""
|
||||
N ZTBL S ZTBL=$NA(^TMP("C0STBL"))
|
||||
N ZI,ZCNT,ZG
|
||||
S ZI=BEGDFN
|
||||
S ZCNT=0
|
||||
F S ZI=$O(^DPT(ZI)) Q:(+ZI="")!(ZCNT>DFNCNT) D ;
|
||||
. S ZCNT=ZCNT+1
|
||||
. W ZI," "
|
||||
. K ZG
|
||||
. D EN^C0SNHIN(.ZG,ZI,ZPART)
|
||||
. M @ZTBL@(ZI)=ZG
|
||||
. K G
|
||||
. ;D EN^C0SMART(.G,ZI,"med")
|
||||
. ;I $D(G) W !,$$output^C0XGET1("G")
|
||||
. ;k G
|
||||
. ;D EN^C0SMART(.G,ZI,"patient")
|
||||
. ;I $D(G) W !,$$output^C0XGET1("G")
|
||||
. ;K G
|
||||
. ;D EN^C0SMART(.G,ZI,"lab")
|
||||
. ;I $D(G) W !,$$output^C0XGET1("G")
|
||||
. ;K G
|
||||
. D EN^C0SMART(.G,ZI,"problem")
|
||||
. I $D(G) W !,$$output^C0XGET1("G")
|
||||
Q
|
||||
;
|
||||
LOADHACK ;
|
||||
N ZI
|
||||
F ZI=2:1:374 D ;
|
||||
. D IMPORT^C0XF2N("hack"_ZI_".xml","/home/vista/hack/")
|
||||
Q
|
||||
;
|
|
@ -0,0 +1,34 @@
|
|||
C0SUTIL ; GPL - Smart Processing Utilities ;2/22/12 17:05
|
||||
;;0.1;C0S;nopatch;noreleasedate;Build 2
|
||||
;Copyright 2012 George Lilly. Licensed under the terms of the GNU
|
||||
;General Public License See attached copy of the License.
|
||||
;
|
||||
;This program is free software; you can redistribute it and/or modify
|
||||
;it under the terms of the GNU General Public License as published by
|
||||
;the Free Software Foundation; either version 2 of the License, or
|
||||
;(at your option) any later version.
|
||||
;
|
||||
;This program is distributed in the hope that it will be useful,
|
||||
;but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;GNU General Public License for more details.
|
||||
;
|
||||
;You should have received a copy of the GNU General Public License along
|
||||
;with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
;
|
||||
Q
|
||||
;
|
||||
SPDATE(ZDATE) ; extrinsic which returns the Smart date format yyyy-mm-dd
|
||||
; ZDATE is a fileman format date
|
||||
N TMPDT
|
||||
S TMPDT=$$FMTE^XLFDT(ZDATE,"7D") ; ordered date
|
||||
S TMPDT=$TR(TMPDT,"/","-") ; change slashes to hyphens
|
||||
I TMPDT="" S TMPDT="UNKNOWN"
|
||||
N Z2,Z3
|
||||
S Z2=$P(TMPDT,"-",2)
|
||||
S Z3=$P(TMPDT,"-",3)
|
||||
I $L(Z2)=1 S $P(TMPDT,"-",2)="0"_Z2
|
||||
I $L(Z3)=1 S $P(TMPDT,"-",3)="0"_Z3
|
||||
Q TMPDT
|
||||
;
|
|
@ -0,0 +1,118 @@
|
|||
C0SPROB ; GPL - Smart Problem Processing ;5/01/12 17:05
|
||||
;;0.1;C0S;nopatch;noreleasedate;Build 2
|
||||
;Copyright 2012 George Lilly. Licensed under the terms of the GNU
|
||||
;General Public License See attached copy of the License.
|
||||
;
|
||||
;This program is free software; you can redistribute it and/or modify
|
||||
;it under the terms of the GNU General Public License as published by
|
||||
;the Free Software Foundation; either version 2 of the License, or
|
||||
;(at your option) any later version.
|
||||
;
|
||||
;This program is distributed in the hope that it will be useful,
|
||||
;but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;GNU General Public License for more details.
|
||||
;
|
||||
;You should have received a copy of the GNU General Public License along
|
||||
;with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
;
|
||||
Q
|
||||
;
|
||||
; sample VistA NHIN problem list
|
||||
;
|
||||
G("node16rk1fgdvx276397","code")="loinc:8480-6"
|
||||
G("node16rk1fgdvx276397","dcterms:title")="systolic blood pressure"
|
||||
G("node16rk1fgdvx276397","rdf:type")="sp:CodedValue"
|
||||
G("node16rk1fgdvx276398","rdf:type")="sp:VitalSign"
|
||||
G("node16rk1fgdvx276398","unit")="mm[Hg]"
|
||||
G("node16rk1fgdvx276398","value")="113.0"
|
||||
G("node16rk1fgdvx276398","vitalName")="node16rk1fgdvx276397"
|
||||
|
||||
;
|
||||
VITALS(GRTN,C0SARY) ; GRTN, passed by reference,
|
||||
; is the return name of the graph created. "" if none
|
||||
; C0SARY is passed in by reference and is the NHIN array of problems
|
||||
;
|
||||
I $O(C0SARY("vital",""))="" D Q ;
|
||||
. I $D(DEBUG) W !,"No Vital Signs"
|
||||
S GRTN="" ; default to no vital signs
|
||||
N C0SGRF
|
||||
S C0SGRF="/vista/smart/"_ZPATID_"/vitals"
|
||||
I $D(DEBUG) W !,"Processing ",C0SGRF
|
||||
D DELGRAPH^C0XF2N(C0SGRF) ; delete the old graph
|
||||
D INITFARY^C0XF2N("C0XFARY") ; which triple store to use
|
||||
N FARY S FARY="C0XFARY"
|
||||
D USEFARY^C0XF2N(FARY)
|
||||
D VOCINIT^C0XUTIL
|
||||
;
|
||||
D STARTADD^C0XF2N ; initialize to create triples
|
||||
;
|
||||
N ZI S ZI=""
|
||||
F S ZI=$O(C0SARY("vital",ZI)) Q:ZI="" D ;
|
||||
. N LRN,ZR ; ZR is the local array for building the new triples
|
||||
. S LRN=$NA(C0SARY("problem",ZI)) ; base for values in this lab result
|
||||
. ;
|
||||
. N PROBID ; unique Id for this problem
|
||||
. S PROBID=C0SGRF_"/"_$$LKY17^C0XF2N ; use a random number
|
||||
. ;
|
||||
. ; i don't like this because the same problems gets a
|
||||
. ; different ID every time it's reported. Can't trace it back to VistA
|
||||
. ; I'd rather be using id@value ie "id@value")="118"
|
||||
. ;
|
||||
. N SNOMED,ICD S ICD=$G(@LRN@("icd@value"))
|
||||
. S SNOMED=$$SNOMED(ICD) ; look up the snomed code in the map
|
||||
. I SNOMED="" S SNOMED=ICD ; if not found, return the ICD code
|
||||
. N SNOGRF S SNOGRF="snomed:"_SNOMED
|
||||
. N SNOTIT S SNOTIT=$G(@LRN@("name@value"))
|
||||
. I $D(DEBUG) D ;
|
||||
. . W !,"Processing Problem List ",PROBID
|
||||
. . W !,"problem: ",SNOTIT
|
||||
. . W !,"code: ",SNOMED
|
||||
. ;
|
||||
. ; first do the base result graph
|
||||
. ;
|
||||
. S ZR("rdf:type")="sp:Problem"
|
||||
. S ZR("sp:belongsTo")=C0SGRF ; the subject for this patient's problems
|
||||
. ; ie /vista/smart/99912345/problems
|
||||
. ;
|
||||
. N PROBNAME S PROBNAME=$$ANONS^C0XF2N ; new node for problem name
|
||||
. S ZR("sp:problemName")=PROBNAME
|
||||
. ;
|
||||
. N STARTDT S STARTDT=$$SPDATE^C0SUTIL($G(@LRN@("entered@value")))
|
||||
. S ZR("sp:startDate")=STARTDT
|
||||
. ;
|
||||
. D ADDINN^C0XF2N(C0SGRF,PROBID,.ZR) ; addIfNotNull the triples
|
||||
. K ZR ; clean up
|
||||
. ;
|
||||
. ; create the problemName graph
|
||||
. ;
|
||||
. S ZR("rdf:type")="sp:CodedValue"
|
||||
. S ZR("sp:code")="snomed:"_SNOMED
|
||||
. S ZR("dcterms:title")=$G(@LRN@("name@value"))
|
||||
. D ADDINN^C0XF2N(C0SGRF,PROBNAME,.ZR)
|
||||
. K ZR
|
||||
. ;
|
||||
. ; create snomed graph
|
||||
. ;
|
||||
. S ZR("rdf:type")="sp:Code"
|
||||
. S ZR("sp:system")="http://purl.bioontology.org/ontology/SNOMEDCT"
|
||||
. S ZR("dcterms:identifier")=SNOMED
|
||||
. S ZR("dcterms:title")=SNOTIT
|
||||
. D ADDINN^C0XF2N(C0SGRF,SNOGRF,.ZR)
|
||||
. K ZR
|
||||
. ;
|
||||
D BULKLOAD^C0XF2N(.C0XFDA)
|
||||
S GRTN=C0SGRF
|
||||
Q
|
||||
;
|
||||
SNOMED(ZICD) ; extrinsic which returns SNOMED code given an ICD9 code
|
||||
; requires the mapping table installed in the triplestore
|
||||
;
|
||||
N ZSN,ZARY,ZSUB
|
||||
S ZSUB=$$subject^C0XGET1(,ZICD) ; subject of the ICD9 code
|
||||
D objects^C0XGET1(.ZARY,ZSUB,"cg:ontology#toCode")
|
||||
S ZSN=$O(ZARY(""))
|
||||
I $D(DEBUG) W !,ZSN," ",$$object^C0XGET1(ZSUB,"rdfs:label")
|
||||
Q ZSN
|
||||
;
|
|
@ -0,0 +1,726 @@
|
|||
C0SXPATH ; CCDCCR/GPL - XPATH XML manipulation utilities; 6/1/08
|
||||
;;1.0;C0S;;May 19, 2009;Build 2
|
||||
;Copyright 2008-2012 George Lilly. Licensed under the terms of the GNU
|
||||
;General Public License See attached copy of the License.
|
||||
;
|
||||
;This program is free software; you can redistribute it and/or modify
|
||||
;it under the terms of the GNU General Public License as published by
|
||||
;the Free Software Foundation; either version 2 of the License, or
|
||||
;(at your option) any later version.
|
||||
;
|
||||
;This program is distributed in the hope that it will be useful,
|
||||
;but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;GNU General Public License for more details.
|
||||
;
|
||||
;You should have received a copy of the GNU General Public License along
|
||||
;with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
;
|
||||
W "This is an XML XPATH utility library",!
|
||||
W !
|
||||
Q
|
||||
;
|
||||
OUTPUT(OUTARY,OUTNAME,OUTDIR) ; WRITE AN ARRAY TO A FILE
|
||||
;
|
||||
N Y
|
||||
S Y=$$GTF^%ZISH(OUTARY,$QL(OUTARY),OUTDIR,OUTNAME)
|
||||
I Y Q 1_U_"WROTE FILE: "_OUTNAME_" TO "_OUTDIR
|
||||
I 'Y Q 0_U_"ERROR WRITING FILE"_OUTNAME_" TO "_OUTDIR
|
||||
Q
|
||||
;
|
||||
PUSH(STK,VAL) ; pushs VAL onto STK and updates STK(0)
|
||||
; VAL IS A STRING AND STK IS PASSED BY NAME
|
||||
;
|
||||
I '$D(@STK@(0)) S @STK@(0)=0 ; IF THE ARRAY IS EMPTY, INITIALIZE
|
||||
S @STK@(0)=@STK@(0)+1 ; INCREMENT ARRAY DEPTH
|
||||
S @STK@(@STK@(0))=VAL ; PUT VAL A THE END OF THE ARRAY
|
||||
Q
|
||||
;
|
||||
POP(STK,VAL) ; POPS THE LAST VALUE OFF THE STK AND RETURNS IT IN VAL
|
||||
; VAL AND STK ARE PASSED BY REFERENCE
|
||||
;
|
||||
I @STK@(0)<1 D ; IF ARRAY IS EMPTY
|
||||
. S VAL=""
|
||||
. S @STK@(0)=0
|
||||
I @STK@(0)>0 D ;
|
||||
. S VAL=@STK@(@STK@(0))
|
||||
. K @STK@(@STK@(0))
|
||||
. S @STK@(0)=@STK@(0)-1 ; NEW DEPTH OF THE ARRAY
|
||||
Q
|
||||
;
|
||||
PUSHA(ADEST,ASRC) ; PUSH ASRC ONTO ADEST, BOTH PASSED BY NAME
|
||||
;
|
||||
N ZGI
|
||||
F ZGI=1:1:@ASRC@(0) D ; FOR ALL OF THE SOURCE ARRAY
|
||||
. D PUSH(ADEST,@ASRC@(ZGI)) ; PUSH ONE ELEMENT
|
||||
Q
|
||||
;
|
||||
MKMDX(STK,RTN,INREDUX) ; MAKES A MUMPS INDEX FROM THE ARRAY STK
|
||||
; RTN IS SET TO //FIRST/SECOND/THIRD FOR THREE ARRAY ELEMENTS
|
||||
; REDUX IS A STRING TO REMOVE FROM THE RESULT
|
||||
S RTN=""
|
||||
N I
|
||||
; W "STK= ",STK,!
|
||||
I @STK@(0)>0 D ; IF THE ARRAY IS NOT EMPTY
|
||||
. S RTN="//"_@STK@(1) ; FIRST ELEMENT NEEDS NO SEMICOLON
|
||||
. I @STK@(0)>1 D ; SUBSEQUENT ELEMENTS NEED A SEMICOLON
|
||||
. . F I=2:1:@STK@(0) S RTN=RTN_"/"_@STK@(I)
|
||||
I $G(INREDUX)'="" S RTN=$P(RTN,INREDUX,1)_$P(RTN,INREDUX,2)
|
||||
Q
|
||||
;
|
||||
XNAME(ISTR) ; FUNCTION TO EXTRACT A NAME FROM AN XML FRAG
|
||||
; </NAME> AND <NAME ID=XNAME> WILL RETURN NAME
|
||||
; ISTR IS PASSED BY VALUE
|
||||
N CUR,TMP
|
||||
I ISTR?.E1"<".E D ; STRIP OFF LEFT BRACKET
|
||||
. S TMP=$P(ISTR,"<",2)
|
||||
I TMP?1"/".E D ; ALSO STRIP OFF SLASH IF PRESENT IE </NAME>
|
||||
. S TMP=$P(TMP,"/",2)
|
||||
S CUR=$P(TMP,">",1) ; EXTRACT THE NAME
|
||||
; W "CUR= ",CUR,!
|
||||
I CUR?.1"_"1.A1" ".E D ; CONTAINS A BLANK IE NAME ID=TEST>
|
||||
. S CUR=$P(CUR," ",1) ; STRIP OUT BLANK AND AFTER
|
||||
; W "CUR2= ",CUR,!
|
||||
Q CUR
|
||||
;
|
||||
XVAL(ISTR) ; EXTRACTS THE VALUE FROM A FRAGMENT OF XML
|
||||
; <NAME>VALUE</NAME> WILL RETURN VALUE
|
||||
N G
|
||||
S G=$P(ISTR,">",2) ;STRIP OFF <NAME>
|
||||
Q $P(G,"<",1) ; STRIP OFF </NAME> LEAVING VALUE
|
||||
;
|
||||
VDX2VDV(OUTVDV,INVDX) ; CONVERT AN VDX ARRAY TO VDV
|
||||
; VDX: @INVDX@(XPATH)=VALUE
|
||||
; VDV: @OUTVDV@(X1X2X3X4)=VALUE
|
||||
; THE VDV DATANAMES MIGHT BE MORE CONVENIENT FOR USE IN CODE
|
||||
; AN INDEX IS PROVIDED TO GO BACK TO VDX FOR CONVERSIONS
|
||||
; @VDV@("XPATH",X1X2X3X4)="XPATH"
|
||||
N ZA,ZI,ZW
|
||||
S ZI=""
|
||||
F S ZI=$O(@INVDX@(ZI)) Q:ZI="" D ;
|
||||
. S ZW=$TR(ZI,"/","") ; ELIMINATE ALL SLASHES - CAMEL CASE VARIABLE NAME
|
||||
. W ZW,!
|
||||
. S @OUTVDV@(ZW)=@INVDX@(ZI)
|
||||
. S @OUTVDV@("XPATH",ZW)=ZI
|
||||
Q
|
||||
;
|
||||
VDX2XPG(OUTXPG,INVDX) ; CONVERT AN VDX ARRAY TO XPG
|
||||
; VDX: @VDX@(XPATH)=VALUE
|
||||
; XPG: @(VDX(X1,X2,X3,X4))@=VALUE
|
||||
; THIS IS A STEP TOWARD GENERATING XML FROM A VDX
|
||||
N ZA,ZI,ZW
|
||||
S ZI=""
|
||||
F S ZI=$O(@INVDX@(ZI)) Q:ZI="" D ;
|
||||
. S ZW=$E(ZI,3,$L(ZI)) ; STRIP OFF INITIAL //
|
||||
. S ZW2=$P(ZW,"/",1)
|
||||
. F ZK=1:1:$L(ZW,"/") D PUSH("ZA",$P(ZW,"/",ZK))
|
||||
. ;ZWR ZA
|
||||
. S ZW2=ZA(1)
|
||||
. F ZK=2:1:ZA(0) D ;
|
||||
. . S ZW2=ZW2_""","""_ZA(ZK)
|
||||
. K ZA
|
||||
. S ZW2=""""_ZW2_""""
|
||||
. W ZW2,!
|
||||
. S ZN=OUTXPG_"("_ZW2_")"
|
||||
. S @ZN=@INVDX@(ZI)
|
||||
Q
|
||||
;
|
||||
XML2XPG(OUTXPG,INXML) ; CONVERT AN XML ARRAY, PASSED BY NAME TO AN XPG ARRAY
|
||||
; XPG MEANS XPATH GLOBAL AND HAS THE FORM @OUTXPG@("X1","X2","X3")=VALUE
|
||||
;
|
||||
;N G1
|
||||
D INDEX(INXML,"G1",1) ; PRODUCES A VDX ARRAY IN G1, NO INDEX IS PRODUCED
|
||||
D VDX2XPG(OUTXPG,"G1") ; CONVERTS THE VDX ARRAY TO XPG FORM
|
||||
Q
|
||||
;
|
||||
DO
|
||||
D XPG2XML("^GPL2B","^GPL2A")
|
||||
Q
|
||||
;
|
||||
T1 ; TEST OUT THESE ROUTINES
|
||||
D XML2XPG("G2","^GPL")
|
||||
D XPG2XML("G3","G2")
|
||||
K ^GPLOUT
|
||||
M ^GPLOUT=G3
|
||||
W $$OUTPUT^C0CXPATH("^GPLOUT(1)","GPLTEST.xml","/home/vademo2/EHR/p")
|
||||
Q
|
||||
;
|
||||
XPG2XML(OUTXML,INXPG) ;
|
||||
N C0CN,FWD,ZA,G,GA,ZQ
|
||||
S ZQ=0 ; QUIT FLAG
|
||||
F Q:ZQ=1 D ; LOOP THROUGH EVERYTHING
|
||||
. I '$D(C0CN) D ; FIRST TIME THROUGH
|
||||
. . K @OUTXML ; MAKE SURE OUTPUT ARRAY IS CLEAR
|
||||
. . S FWD=1 ; START OUT GOING FORWARD THROUGH SUBSCRIPTS
|
||||
. . S G=$Q(@INXPG) ; THIS ONE
|
||||
. . S GN=$Q(@G) ; NEXT ONE
|
||||
. . S C0CN=1 ; SUBSCRIPT COUNT
|
||||
. . S ZQ=0 ; QUIT FLAG
|
||||
. . D ZXO("?xml version=""1.0"" encoding=""UTF-8""?") ;MAKE IT REAL XML
|
||||
. . I $QS(G,1)="ContinuityOfCareRecord" D ;
|
||||
. . . D ZXO("?xml-stylesheet type=""text/xsl"" href=""ccr.xsl""?") ; HACK TO MAKE THE CCR STYLESHEET WORK
|
||||
. I FWD D ; GOING FORWARDS
|
||||
. . I C0CN<$QL(G) D ; NOT A DATA NODE
|
||||
. . . S ZA=$QS(G,C0CN) ; PULL OUT THE SUBSCRIPT
|
||||
. . . D ZXO(ZA) ; AND OPEN AN XML ELEMENT
|
||||
. . . I @OUTXML@(@OUTXML@(0))="<ContinuityOfCareRecord>" D ;
|
||||
. . . . S @OUTXML@(@OUTXML@(0))="<ContinuityOfCareRecord xmlns=""urn:astm-org:CCR"">"
|
||||
. . . S C0CN=C0CN+1 ; MOVE TO THE NEXT ONE
|
||||
. . E D ; AT THE DATA NODE
|
||||
. . . S ZA=$QS(G,C0CN) ; PULL OUT THE SUBSCRIPT
|
||||
. . . D ZXVAL(ZA,@G) ; OUTPUT <X>VAL</X> FOR DATA NODE
|
||||
. . . S FWD=0 ; GO BACKWARDS
|
||||
. I 'FWD D ;GOING BACKWARDS
|
||||
. . S GN=$Q(@G) ;NEXT XPATH
|
||||
. . ;W "NEXT!",GN,!
|
||||
. . S C0CN=C0CN-1 ; PREVIOUS SUBSCRIPT
|
||||
. . I GN'="" D ;
|
||||
. . . I $QS(G,C0CN)'=$QS(GN,C0CN) D ; NEED TO CLOSE OFF ELEMENT
|
||||
. . . . D ZXC($QS(G,C0CN)) ;
|
||||
. . . E I GN'="" D ; MORE ELEMENTS AT THIS LEVEL
|
||||
. . . . S G=$Q(@G) ; ADVANCE TO NEW XPATH
|
||||
. . . . S C0CN=C0CN+1 ; GET READY TO PROCESS NEXT SUBSCRIPT
|
||||
. . . . S FWD=1 ; GOING FORWARD NOW
|
||||
. I (GN="")&(C0CN=1) D Q ; WHEN WE ARE ALL DONE
|
||||
. . D ZXC($QS(G,C0CN)) ; LAST ONE
|
||||
. . S ZQ=1 ; QUIT NOW
|
||||
Q
|
||||
;
|
||||
ZXO(WHAT)
|
||||
D PUSH("GA",WHAT)
|
||||
D PUSH(OUTXML,"<"_WHAT_">")
|
||||
Q
|
||||
;
|
||||
ZXC(WHAT)
|
||||
D POP("GA",.TMP)
|
||||
D PUSH(OUTXML,"</"_WHAT_">")
|
||||
Q
|
||||
;
|
||||
ZXVAL(WHAT,VAL)
|
||||
D PUSH(OUTXML,"<"_WHAT_">"_VAL_"</"_WHAT_">")
|
||||
Q
|
||||
;
|
||||
INDEX(IZXML,VDX,NOINX,TEMPLATE,REDUX) ; parse XML in IZXML and produce
|
||||
; an XPATH index; REDUX is a string to be removed from each xpath
|
||||
; GPL 7/14/09 OPTIONALLY GENERATE AN XML TEMPLATE IF PASSED BY NAME
|
||||
; TEMPLATE IS IDENTICAL TO THE PARSED XML LINE BY LINE
|
||||
; EXCEPT THAT DATA VALUES ARE REPLACED WITH @@XPATH@@ FOR THE XPATH OF THE TAG
|
||||
; GPL 5/24/09 AND OPTIONALLY PRODUCE THE VDX ARRAY PASSED BY NAME
|
||||
; @VDX@("XPATH")=VALUE
|
||||
; ex. @IZXML@("XPATH")=FIRSTLINE^LASTLINE
|
||||
; WHERE FIRSTLINE AND LASTLINE ARE THE BEGINNING AND ENDING OF THE
|
||||
; XML SECTION
|
||||
; IZXML IS PASSED BY NAME
|
||||
; IF NOINX IS SET TO 1, NO INDEX WILL BE GENERATED, BUT THE VDX WILL BE
|
||||
N I,LINE,FIRST,LAST,CUR,TMP,MDX,FOUND,CURVAL,DVDX,LCNT
|
||||
N C0CSTK ; LEAVE OUT FOR DEBUGGING
|
||||
I '$D(REDUX) S REDUX=""
|
||||
I '$D(NOINX) S NOINX=0 ; IF NOT PASSED, GENERATE AN INDEX
|
||||
N ZXML
|
||||
I NOINX S ZXML=$NA(^TMP("C0CINDEX",$J)) ; TEMP PLACE FOR INDEX TO DISCARD
|
||||
E S ZXML=IZXML ; PLACE FOR INDEX TO KEEP
|
||||
I '$D(@IZXML@(0)) D ; IF COUNT NOT IN NODE 0 COUNT THEM
|
||||
. S I="",LCNT=0
|
||||
. F S I=$O(@IZXML@(I)) Q:I="" S LCNT=LCNT+1
|
||||
E S LCNT=@IZXML@(0) ; LINE COUNT PASSED IN ARRAY
|
||||
I LCNT=0 D Q ; NO XML PASSED
|
||||
. W "ERROR IN XML FILE",!
|
||||
S DVDX=0 ; DEFAULT DO NOT PRODUCE VDX INDEX
|
||||
I $D(VDX) S DVDX=1 ; IF NAME PASSED, DO VDX
|
||||
S C0CSTK(0)=0 ; INITIALIZE STACK
|
||||
K LKASD ; KILL LOOKASIDE ARRAY
|
||||
D MKLASD(.LKASD,IZXML) ;MAKE LOOK ASIDE BUFFER FOR MULTIPLES
|
||||
F I=1:1:LCNT D ; PROCESS THE ENTIRE ARRAY
|
||||
. S LINE=@IZXML@(I)
|
||||
. I $D(TEMPLATE) D ;IF TEMPLATE IS REQUESTED
|
||||
. . S @TEMPLATE@(I)=$$CLEAN(LINE)
|
||||
. ;W LINE,!
|
||||
. S FOUND=0 ; INTIALIZED FOUND FLAG
|
||||
. I LINE?.E1"<!".E S FOUND=1 ; SKIP OVER COMMENTS
|
||||
. I FOUND'=1 D
|
||||
. . I (LINE?.E1"<"1.E1"</".E)!(LINE?.E1"<"1.E1"/>".E) D
|
||||
. . . ; THIS IS THE CASE THERE SECTION BEGINS AND ENDS
|
||||
. . . ; ON THE SAME LINE
|
||||
. . . ; W "FOUND ",LINE,!
|
||||
. . . S FOUND=1 ; SET FOUND FLAG
|
||||
. . . S CUR=$$XNAME(LINE) ; EXTRACT THE NAME
|
||||
. . . S CUR=CUR_$G(LKASD(CUR,I)) ; HANDLE MULTIPLES
|
||||
. . . D PUSH("C0CSTK",CUR) ; ADD TO THE STACK
|
||||
. . . D MKMDX("C0CSTK",.MDX,REDUX) ; GENERATE THE M INDEX
|
||||
. . . ; W "MDX=",MDX,!
|
||||
. . . I $D(@ZXML@(MDX)) D ; IN THE INDEX, IS A MULTIPLE
|
||||
. . . . ;I '$D(ZDUP(MDX)) S ZDUP(MDX)=2
|
||||
. . . . ;E S ZDUP(MDX)=ZDUP(MDX)+1
|
||||
. . . . ;W "DUP:",MDX,!
|
||||
. . . . ;I '$D(CURVAL) S CURVAL=""
|
||||
. . . . ;I DVDX S @VDX@(MDX_"["_ZDUP(MDX)_"]")=CURVAL
|
||||
. . . . S $P(@ZXML@(MDX),"^",2)=I ; UPDATE LAST LINE NUMBER
|
||||
. . . I '$D(@ZXML@(MDX)) D ; NOT IN THE INDEX, NOT A MULTIPLE
|
||||
. . . . S @ZXML@(MDX)=I_"^"_I ; ADD INDEX ENTRY-FIRST AND LAST
|
||||
. . . . S CURVAL=$$XVAL(LINE) ; VALUE
|
||||
. . . . S $P(@ZXML@(MDX),"^",3)=CURVAL ; THIRD PIECE
|
||||
. . . . I DVDX S @VDX@(MDX)=CURVAL ; FILL IN VDX ARRAY IF REQUESTED
|
||||
. . . . I $D(TEMPLATE) D ; IF TEMPLATE IS REQUESTED
|
||||
. . . . . S LINE=$$CLEAN(LINE) ; CLEAN OUT CONTROL CHARACTERS
|
||||
. . . . . S @TEMPLATE@(I)=$P(LINE,">",1)_">@@"_MDX_"@@</"_$P(LINE,"</",2)
|
||||
. . . D POP("C0CSTK",.TMP) ; REMOVE FROM STACK
|
||||
. I FOUND'=1 D ; THE LINE DOESN'T CONTAIN THE START AND END
|
||||
. . I LINE?.E1"</"1.E D ; LINE CONTAINS END OF A SECTION
|
||||
. . . ; W "FOUND ",LINE,!
|
||||
. . . S FOUND=1 ; SET FOUND FLAG
|
||||
. . . S CUR=$$XNAME(LINE) ; EXTRACT THE NAME
|
||||
. . . D MKMDX("C0CSTK",.MDX) ; GENERATE THE M INDEX
|
||||
. . . S $P(@ZXML@(MDX),"^",2)=I ; UPDATE LAST LINE NUMBER
|
||||
. . . D POP("C0CSTK",.TMP) ; REMOVE FROM STACK
|
||||
. . . S TMP=$P(TMP,"[",1) ; REMOVE [X] FROM MULTIPLE
|
||||
. . . I TMP'=CUR D ; MALFORMED XML, END MUST MATCH START
|
||||
. . . . W "MALFORMED XML ",CUR,"LINE "_I_LINE,!
|
||||
. . . . D PARY("C0CSTK") ; PRINT OUT THE STACK FOR DEBUGING
|
||||
. . . . Q
|
||||
. I FOUND'=1 D ; THE LINE MIGHT CONTAIN A SECTION BEGINNING
|
||||
. . I (LINE?.E1"<"1.E)&(LINE'["?>") D ; BEGINNING OF A SECTION
|
||||
. . . ; W "FOUND ",LINE,!
|
||||
. . . S FOUND=1 ; SET FOUND FLAG
|
||||
. . . S CUR=$$XNAME(LINE) ; EXTRACT THE NAME
|
||||
. . . S CUR=CUR_$G(LKASD(CUR,I)) ; HANDLE MULTIPLES
|
||||
. . . D PUSH("C0CSTK",CUR) ; ADD TO THE STACK
|
||||
. . . D MKMDX("C0CSTK",.MDX) ; GENERATE THE M INDEX
|
||||
. . . ; W "MDX=",MDX,!
|
||||
. . . I $D(@ZXML@(MDX)) D ; IN THE INDEX, IS A MULTIPLE
|
||||
. . . . S $P(@ZXML@(MDX),"^",2)=I ; UPDATE LAST LINE NUMBER
|
||||
. . . . ;B
|
||||
. . . I '$D(@ZXML@(MDX)) D ; NOT IN THE INDEX, NOT A MULTIPLE
|
||||
. . . . S @ZXML@(MDX)=I_"^" ; INSERT INTO THE INDEX
|
||||
S @ZXML@("INDEXED")=""
|
||||
S @ZXML@("//")="1^"_LCNT ; ROOT XPATH
|
||||
I NOINX K @ZXML ; DELETE UNWANTED INDEX
|
||||
Q
|
||||
;
|
||||
MKLASD(OUTBUF,INARY) ; CREATE A LOOKASIDE BUFFER FOR MULTILPLES
|
||||
;
|
||||
N ZI,ZN,ZA,ZLINE,ZLINE2,CUR,CUR2
|
||||
F ZI=1:1:LCNT-1 D ; PROCESS THE ENTIRE ARRAY
|
||||
. S ZLINE=@IZXML@(ZI)
|
||||
. I ZI<LCNT S ZLINE2=@IZXML@(ZI+1)
|
||||
. I ZLINE?.E1"</"1.E D ; NEXT LINE CONTAINS END OF A SECTION
|
||||
. . S CUR=$$XNAME(ZLINE) ; EXTRACT THE NAME
|
||||
. . I (ZLINE2?.E1"<"1.E)&(ZLINE'["?>") D ; BEGINNING OF A SECTION
|
||||
. . . S CUR2=$$XNAME(ZLINE2) ; EXTRACT THE NAME
|
||||
. . . I CUR=CUR2 D ; IF THIS IS A MULTIPLE
|
||||
. . . . S OUTBUF(CUR,ZI+1)=""
|
||||
;ZWR OUTBUF
|
||||
S ZI=""
|
||||
F S ZI=$O(OUTBUF(ZI)) Q:ZI="" D ; FOR EACH KIND OF MULTIPLE
|
||||
. S ZN=$O(OUTBUF(ZI,"")) ; LINE NUMBER OF SECOND MULTIPLE
|
||||
. F S ZN=$O(@IZXML@(ZN),-1) Q:ZN="" I $E($P(@IZXML@(ZN),"<"_ZI,2),1,1)=">" Q ;
|
||||
. S OUTBUF(ZI,ZN)=""
|
||||
S ZA=1,ZI="",ZN=""
|
||||
F S ZI=$O(OUTBUF(ZI)) Q:ZI="" D ; ADDING THE COUNT FOR THE MULIPLES [x]
|
||||
. S ZN="",ZA=1
|
||||
. F S ZN=$O(OUTBUF(ZI,ZN)) Q:ZN="" D ;
|
||||
. . S OUTBUF(ZI,ZN)="["_ZA_"]"
|
||||
. . S ZA=ZA+1
|
||||
Q
|
||||
;
|
||||
CLEAN(STR,TR) ; extrinsic function; returns string
|
||||
;; Removes all non printable characters from a string.
|
||||
;; STR by Value
|
||||
;; TR IS OPTIONAL TO IMPROVE PERFORMANCE
|
||||
N TR,I
|
||||
I '$D(TR) D ;
|
||||
. F I=0:1:31 S TR=$G(TR)_$C(I)
|
||||
. S TR=TR_$C(127)
|
||||
QUIT $TR(STR,TR)
|
||||
;
|
||||
QUERY(IARY,XPATH,OARY) ; RETURNS THE XML ARRAY MATCHING THE XPATH EXPRESSION
|
||||
; XPATH IS OF THE FORM "//FIRST/SECOND/THIRD"
|
||||
; IARY AND OARY ARE PASSED BY NAME
|
||||
I '$D(@IARY@("INDEXED")) D ; INDEX IS NOT PRESENT IN IARY
|
||||
. D INDEX(IARY) ; GENERATE AN INDEX FOR THE XML
|
||||
N FIRST,LAST ; FIRST AND LAST LINES OF ARRAY TO RETURN
|
||||
N TMP,I,J,QXPATH
|
||||
S FIRST=1
|
||||
I '$D(@IARY@(0)) D ; LINE COUNT NOT IN ZERO NODE
|
||||
. S @IARY@(0)=$O(@IARY@("//"),-1) ; THIS SHOULD USUALLY WORK
|
||||
S LAST=@IARY@(0) ; FIRST AND LAST DEFAULT TO ROOT
|
||||
I XPATH'="//" D ; NOT A ROOT QUERY
|
||||
. S TMP=@IARY@(XPATH) ; LOOK UP LINE VALUES
|
||||
. S FIRST=$P(TMP,"^",1)
|
||||
. S LAST=$P(TMP,"^",2)
|
||||
K @OARY
|
||||
S @OARY@(0)=+LAST-FIRST+1
|
||||
S J=1
|
||||
FOR I=FIRST:1:LAST D
|
||||
. S @OARY@(J)=@IARY@(I) ; COPY THE LINE TO OARY
|
||||
. S J=J+1
|
||||
; ZWR OARY
|
||||
Q
|
||||
;
|
||||
XF(IDX,XPATH) ; EXTRINSIC TO RETURN THE STARTING LINE FROM AN XPATH
|
||||
; INDEX WITH TWO PIECES START^FINISH
|
||||
; IDX IS PASSED BY NAME
|
||||
Q $P(@IDX@(XPATH),"^",1)
|
||||
;
|
||||
XL(IDX,XPATH) ; EXTRINSIC TO RETURN THE LAST LINE FROM AN XPATH
|
||||
; INDEX WITH TWO PIECES START^FINISH
|
||||
; IDX IS PASSED BY NAME
|
||||
Q $P(@IDX@(XPATH),"^",2)
|
||||
;
|
||||
START(ISTR) ; EXTRINSIC TO RETURN THE STARTING LINE FROM AN INDEX
|
||||
; TYPE STRING WITH THREE PIECES ARRAY;START;FINISH
|
||||
; COMPANION TO FINISH ; IDX IS PASSED BY NAME
|
||||
Q $P(ISTR,";",2)
|
||||
;
|
||||
FINISH(ISTR) ; EXTRINSIC TO RETURN THE LAST LINE FROM AN INDEX
|
||||
; TYPE STRING WITH THREE PIECES ARRAY;START;FINISH
|
||||
Q $P(ISTR,";",3)
|
||||
;
|
||||
ARRAY(ISTR) ; EXTRINSIC TO RETURN THE ARRAY REFERENCE FROM AN INDEX
|
||||
; TYPE STRING WITH THREE PIECES ARRAY;START;FINISH
|
||||
Q $P(ISTR,";",1)
|
||||
;
|
||||
BUILD(BLIST,BDEST) ; A COPY MACHINE THAT TAKE INSTRUCTIONS IN ARRAY BLIST
|
||||
; WHICH HAVE ARRAY;START;FINISH AND COPIES THEM TO DEST
|
||||
; DEST IS CLEARED TO START
|
||||
; USES PUSH TO DO THE COPY
|
||||
N I
|
||||
K @BDEST
|
||||
F I=1:1:@BLIST@(0) D ; FOR EACH INSTRUCTION IN BLIST
|
||||
. N J,ATMP
|
||||
. S ATMP=$$ARRAY(@BLIST@(I))
|
||||
. I $G(DEBUG) W "ATMP=",ATMP,!
|
||||
. I $G(DEBUG) W @BLIST@(I),!
|
||||
. F J=$$START(@BLIST@(I)):1:$$FINISH(@BLIST@(I)) D ;
|
||||
. . ; FOR EACH LINE IN THIS INSTR
|
||||
. . I $G(DEBUG) W "BDEST= ",BDEST,!
|
||||
. . I $G(DEBUG) W "ATMP= ",@ATMP@(J),!
|
||||
. . D PUSH(BDEST,@ATMP@(J))
|
||||
Q
|
||||
;
|
||||
QUEUE(BLST,ARRAY,FIRST,LAST) ; ADD AN ENTRY TO A BLIST
|
||||
;
|
||||
I $G(DEBUG) W "QUEUEING ",BLST,!
|
||||
D PUSH(BLST,ARRAY_";"_FIRST_";"_LAST)
|
||||
Q
|
||||
;
|
||||
CP(CPSRC,CPDEST) ; COPIES CPSRC TO CPDEST BOTH PASSED BY NAME
|
||||
; KILLS CPDEST FIRST
|
||||
N CPINSTR
|
||||
I $G(DEBUG) W "MADE IT TO COPY",CPSRC,CPDEST,!
|
||||
I @CPSRC@(0)<1 D ; BAD LENGTH
|
||||
. W "ERROR IN COPY BAD SOURCE LENGTH: ",CPSRC,!
|
||||
. Q
|
||||
; I '$D(@CPDEST@(0)) S @CPDEST@(0)=0 ; IF THE DEST IS EMPTY, INIT
|
||||
D QUEUE("CPINSTR",CPSRC,1,@CPSRC@(0)) ; BLIST FOR ENTIRE ARRAY
|
||||
D BUILD("CPINSTR",CPDEST)
|
||||
Q
|
||||
;
|
||||
QOPEN(QOBLIST,QOXML,QOXPATH) ; ADD ALL BUT THE LAST LINE OF QOXML TO QOBLIST
|
||||
; WARNING NEED TO DO QCLOSE FOR SAME XML BEFORE CALLING BUILD
|
||||
; QOXPATH IS OPTIONAL - WILL OPEN INSIDE THE XPATH POINT
|
||||
; USED TO INSERT CHILDREN NODES
|
||||
I @QOXML@(0)<1 D ; MALFORMED XML
|
||||
. W "MALFORMED XML PASSED TO QOPEN: ",QOXML,!
|
||||
. Q
|
||||
I $G(DEBUG) W "DOING QOPEN",!
|
||||
N S1,E1,QOT,QOTMP
|
||||
S S1=1 ; OPEN FROM THE BEGINNING OF THE XML
|
||||
I $D(QOXPATH) D ; XPATH PROVIDED
|
||||
. D QUERY(QOXML,QOXPATH,"QOT") ; INSURE INDEX
|
||||
. S E1=$P(@QOXML@(QOXPATH),"^",2)-1
|
||||
I '$D(QOXPATH) D ; NO XPATH PROVIDED, OPEN AT ROOT
|
||||
. S E1=@QOXML@(0)-1
|
||||
D QUEUE(QOBLIST,QOXML,S1,E1)
|
||||
; S QOTMP=QOXML_"^"_S1_"^"_E1
|
||||
; D PUSH(QOBLIST,QOTMP)
|
||||
Q
|
||||
;
|
||||
QCLOSE(QCBLIST,QCXML,QCXPATH) ; CLOSE XML AFTER A QOPEN
|
||||
; ADDS THE LIST LINE OF QCXML TO QCBLIST
|
||||
; USED TO FINISH INSERTING CHILDERN NODES
|
||||
; QCXPATH IS OPTIONAL - IF PROVIDED, WILL CLOSE UNTIL THE END
|
||||
; IF QOPEN WAS CALLED WITH XPATH, QCLOSE SHOULD BE TOO
|
||||
I @QCXML@(0)<1 D ; MALFORMED XML
|
||||
. W "MALFORMED XML PASSED TO QCLOSE: ",QCXML,!
|
||||
I $G(DEBUG) W "GOING TO CLOSE",!
|
||||
N S1,E1,QCT,QCTMP
|
||||
S E1=@QCXML@(0) ; CLOSE UNTIL THE END OF THE XML
|
||||
I $D(QCXPATH) D ; XPATH PROVIDED
|
||||
. D QUERY(QCXML,QCXPATH,"QCT") ; INSURE INDEX
|
||||
. S S1=$P(@QCXML@(QCXPATH),"^",2) ; REMAINING XML
|
||||
I '$D(QCXPATH) D ; NO XPATH PROVIDED, CLOSE AT ROOT
|
||||
. S S1=@QCXML@(0)
|
||||
D QUEUE(QCBLIST,QCXML,S1,E1)
|
||||
; D PUSH(QCBLIST,QCXML_";"_S1_";"_E1)
|
||||
Q
|
||||
;
|
||||
INSERT(INSXML,INSNEW,INSXPATH) ; INSERT INSNEW INTO INSXML AT THE
|
||||
; INSXPATH XPATH POINT INSXPATH IS OPTIONAL - IF IT IS
|
||||
; OMITTED, INSERTION WILL BE AT THE ROOT
|
||||
; NOTE INSERT IS NON DESTRUCTIVE AND WILL ADD THE NEW
|
||||
; XML AT THE END OF THE XPATH POINT
|
||||
; INSXML AND INSNEW ARE PASSED BY NAME INSXPATH IS A VALUE
|
||||
N INSBLD,INSTMP
|
||||
I $G(DEBUG) W "DOING INSERT ",INSXML,INSNEW,INSXPATH,!
|
||||
I $G(DEBUG) F G1=1:1:@INSXML@(0) W @INSXML@(G1),!
|
||||
I '$D(@INSXML@(1)) D ; INSERT INTO AN EMPTY ARRAY
|
||||
. D CP^C0CXPATH(INSNEW,INSXML) ; JUST COPY INTO THE OUTPUT
|
||||
I $D(@INSXML@(1)) D ; IF ORIGINAL ARRAY IS NOT EMPTY
|
||||
. I '$D(@INSXML@(0)) S @INSXML@(0)=$O(@INSXML@(""),-1) ;SET LENGTH
|
||||
. I $D(INSXPATH) D ; XPATH PROVIDED
|
||||
. . D QOPEN("INSBLD",INSXML,INSXPATH) ; COPY THE BEFORE
|
||||
. . I $G(DEBUG) D PARY^C0CXPATH("INSBLD")
|
||||
. I '$D(INSXPATH) D ; NO XPATH PROVIDED, OPEN AT ROOT
|
||||
. . D QOPEN("INSBLD",INSXML,"//") ; OPEN WITH ROOT XPATH
|
||||
. I '$D(@INSNEW@(0)) S @INSNEW@(0)=$O(@INSNEW@(""),-1) ;SIZE OF XML
|
||||
. D QUEUE("INSBLD",INSNEW,1,@INSNEW@(0)) ; COPY IN NEW XML
|
||||
. I $D(INSXPATH) D ; XPATH PROVIDED
|
||||
. . D QCLOSE("INSBLD",INSXML,INSXPATH) ; CLOSE WITH XPATH
|
||||
. I '$D(INSXPATH) D ; NO XPATH PROVIDED, CLOSE AT ROOT
|
||||
. . D QCLOSE("INSBLD",INSXML,"//") ; CLOSE WITH ROOT XPATH
|
||||
. D BUILD("INSBLD","INSTMP") ; PUT RESULTS IN INDEST
|
||||
. D CP^C0CXPATH("INSTMP",INSXML) ; COPY BUFFER TO SOURCE
|
||||
Q
|
||||
;
|
||||
INSINNER(INNXML,INNNEW,INNXPATH) ; INSERT THE INNER XML OF INNNEW
|
||||
; INTO INNXML AT THE INNXPATH XPATH POINT
|
||||
;
|
||||
N INNBLD,UXPATH
|
||||
N INNTBUF
|
||||
S INNTBUF=$NA(^TMP($J,"INNTBUF"))
|
||||
I '$D(INNXPATH) D ; XPATH NOT PASSED
|
||||
. S UXPATH="//" ; USE ROOT XPATH
|
||||
I $D(INNXPATH) S UXPATH=INNXPATH ; USE THE XPATH THAT'S PASSED
|
||||
I '$D(@INNXML@(0)) D ; INNXML IS EMPTY
|
||||
. D QUEUE^C0CXPATH("INNBLD",INNNEW,2,@INNNEW@(0)-1) ; JUST INNER
|
||||
. D BUILD("INNBLD",INNXML)
|
||||
I @INNXML@(0)>0 D ; NOT EMPTY
|
||||
. D QOPEN("INNBLD",INNXML,UXPATH) ;
|
||||
. D QUEUE("INNBLD",INNNEW,2,@INNNEW@(0)-1) ; JUST INNER XML
|
||||
. D QCLOSE("INNBLD",INNXML,UXPATH)
|
||||
. D BUILD("INNBLD",INNTBUF) ; BUILD TO BUFFER
|
||||
. D CP(INNTBUF,INNXML) ; COPY BUFFER TO DEST
|
||||
Q
|
||||
;
|
||||
INSB4(XDEST,XNEW) ; INSERT XNEW AT THE BEGINNING OF XDEST
|
||||
; BUT XDEST AN XNEW ARE PASSED BY NAME
|
||||
N XBLD,XTMP
|
||||
D QUEUE("XBLD",XDEST,1,1) ; NEED TO PRESERVE SECTION ROOT
|
||||
D QUEUE("XBLD",XNEW,1,@XNEW@(0)) ; ALL OF NEW XML FIRST
|
||||
D QUEUE("XBLD",XDEST,2,@XDEST@(0)) ; FOLLOWED BY THE REST OF SECTION
|
||||
D BUILD("XBLD","XTMP") ; BUILD THE RESULT
|
||||
D CP("XTMP",XDEST) ; COPY TO THE DESTINATION
|
||||
I $G(DEBUG) D PARY("XDEST")
|
||||
Q
|
||||
;
|
||||
REPLACE(REXML,RENEW,REXPATH) ; REPLACE THE XML AT THE XPATH POINT
|
||||
; WITH RENEW - NOTE THIS WILL DELETE WHAT WAS THERE BEFORE
|
||||
; REXML AND RENEW ARE PASSED BY NAME XPATH IS A VALUE
|
||||
; THE DELETED XML IS PUT IN ^TMP($J,"REPLACE_OLD")
|
||||
N REBLD,XFIRST,XLAST,OLD,XNODE,RETMP
|
||||
S OLD=$NA(^TMP($J,"REPLACE_OLD"))
|
||||
D QUERY(REXML,REXPATH,OLD) ; CREATE INDEX, TEST XPATH, MAKE OLD
|
||||
S XNODE=@REXML@(REXPATH) ; PULL OUT FIRST AND LAST LINE PTRS
|
||||
S XFIRST=$P(XNODE,"^",1)
|
||||
S XLAST=$P(XNODE,"^",2)
|
||||
I RENEW="" D ; WE ARE DELETING A SECTION, MUST SAVE THE TAG
|
||||
. D QUEUE("REBLD",REXML,1,XFIRST) ; THE BEFORE
|
||||
. D QUEUE("REBLD",REXML,XLAST,@REXML@(0)) ; THE REST
|
||||
I RENEW'="" D ; NEW XML IS NOT NULL
|
||||
. D QUEUE("REBLD",REXML,1,XFIRST-1) ; THE BEFORE
|
||||
. D QUEUE("REBLD",RENEW,1,@RENEW@(0)) ; THE NEW
|
||||
. D QUEUE("REBLD",REXML,XLAST+1,@REXML@(0)) ; THE REST
|
||||
I $G(DEBUG) W "REPLACE PREBUILD",!
|
||||
I $G(DEBUG) D PARY("REBLD")
|
||||
D BUILD("REBLD","RTMP")
|
||||
K @REXML ; KILL WHAT WAS THERE
|
||||
D CP("RTMP",REXML) ; COPY IN THE RESULT
|
||||
Q
|
||||
;
|
||||
DELETE(REXML,REXPATH) ; DELETE THE XML AT THE XPATH POINT
|
||||
; REXML IS PASSED BY NAME XPATH IS A VALUE
|
||||
N REBLD,XFIRST,XLAST,OLD,XNODE,RETMP
|
||||
S OLD=$NA(^TMP($J,"REPLACE_OLD"))
|
||||
D QUERY(REXML,REXPATH,OLD) ; CREATE INDEX, TEST XPATH, MAKE OLD
|
||||
S XNODE=@REXML@(REXPATH) ; PULL OUT FIRST AND LAST LINE PTRS
|
||||
S XFIRST=$P(XNODE,"^",1)
|
||||
S XLAST=$P(XNODE,"^",2)
|
||||
D QUEUE("REBLD",REXML,1,XFIRST-1) ; THE BEFORE
|
||||
D QUEUE("REBLD",REXML,XLAST+1,@REXML@(0)) ; THE REST
|
||||
I $G(DEBUG) D PARY("REBLD")
|
||||
D BUILD("REBLD","RTMP")
|
||||
K @REXML ; KILL WHAT WAS THERE
|
||||
D CP("RTMP",REXML) ; COPY IN THE RESULT
|
||||
Q
|
||||
;
|
||||
MISSING(IXML,OARY) ; SEARTH THROUGH INXLM AND PUT ANY @@X@@ VARS IN OARY
|
||||
; W "Reporting on the missing",!
|
||||
; W OARY
|
||||
I '$D(@IXML@(0)) W "MALFORMED XML PASSED TO MISSING",! Q
|
||||
N I
|
||||
S @OARY@(0)=0 ; INITIALIZED MISSING COUNT
|
||||
F I=1:1:@IXML@(0) D ; LOOP THROUGH WHOLE ARRAY
|
||||
. I @IXML@(I)?.E1"@@".E D ; MISSING VARIABLE HERE
|
||||
. . D PUSH^C0CXPATH(OARY,$P(@IXML@(I),"@@",2)) ; ADD TO OUTARY
|
||||
. . Q
|
||||
Q
|
||||
;
|
||||
MAP(IXML,INARY,OXML) ; SUBSTITUTE MULTIPLE @@X@@ VARS WITH VALUES IN INARY
|
||||
; AND PUT THE RESULTS IN OXML
|
||||
N XCNT
|
||||
I '$D(DEBUG) S DEBUG=0
|
||||
I '$D(IXML) W "MALFORMED XML PASSED TO MAP",! Q
|
||||
I '$D(@IXML@(0)) D ; INITIALIZE COUNT
|
||||
. S XCNT=$O(@IXML@(""),-1)
|
||||
E S XCNT=@IXML@(0) ;COUNT
|
||||
I $O(@INARY@(""))="" W "EMPTY ARRAY PASSED TO MAP",! Q
|
||||
N I,J,TNAM,TVAL,TSTR
|
||||
S @OXML@(0)=XCNT ; TOTAL LINES IN OUTPUT
|
||||
F I=1:1:XCNT D ; LOOP THROUGH WHOLE ARRAY
|
||||
. S @OXML@(I)=@IXML@(I) ; COPY THE LINE TO OUTPUT
|
||||
. I @OXML@(I)?.E1"@@".E D ; IS THERE A VARIABLE HERE?
|
||||
. . S TSTR=$P(@IXML@(I),"@@",1) ; INIT TO PART BEFORE VARS
|
||||
. . F J=2:2:10 D Q:$P(@IXML@(I),"@@",J+2)="" ; QUIT IF NO MORE VARS
|
||||
. . . I DEBUG W "IN MAPPING LOOP: ",TSTR,!
|
||||
. . . S TNAM=$P(@OXML@(I),"@@",J) ; EXTRACT THE VARIABLE NAME
|
||||
. . . S TVAL="@@"_$P(@IXML@(I),"@@",J)_"@@" ; DEFAULT UNCHANGED
|
||||
. . . I $D(@INARY@(TNAM)) D ; IS THE VARIABLE IN THE MAP?
|
||||
. . . . I '$D(@INARY@(TNAM,"F")) D ; NOT A SPECIAL FIELD
|
||||
. . . . . S TVAL=@INARY@(TNAM) ; PULL OUT MAPPED VALUE
|
||||
. . . . E D DOFLD ; PROCESS A FIELD
|
||||
. . . S TVAL=$$SYMENC^MXMLUTL(TVAL) ;MAKE SURE THE VALUE IS XML SAFE
|
||||
. . . S TSTR=TSTR_TVAL_$P(@IXML@(I),"@@",J+1) ; ADD VAR AND PART AFTER
|
||||
. . S @OXML@(I)=TSTR ; COPY LINE WITH MAPPED VALUES
|
||||
. . I DEBUG W TSTR
|
||||
I DEBUG W "MAPPED",!
|
||||
Q
|
||||
;
|
||||
DOFLD ; PROCESS A FILEMAN FIELD REFERENCED BY A VARIABLE
|
||||
;
|
||||
Q
|
||||
;
|
||||
TRIM(THEXML) ; TAKES OUT ALL NULL ELEMENTS
|
||||
; THEXML IS PASSED BY NAME
|
||||
N I,J,TMPXML,DEL,FOUND,INTXT
|
||||
S FOUND=0
|
||||
S INTXT=0
|
||||
I $G(DEBUG) W "DELETING EMPTY ELEMENTS",!
|
||||
F I=1:1:(@THEXML@(0)-1) D ; LOOP THROUGH ENTIRE ARRAY
|
||||
. S J=@THEXML@(I)
|
||||
. I J["<text>" D
|
||||
. . S INTXT=1 ; IN HTML SECTION, DON'T TRIM
|
||||
. . I $G(DEBUG) W "IN HTML SECTION",!
|
||||
. N JM,JP,JPX ; JMINUS AND JPLUS
|
||||
. S JM=@THEXML@(I-1) ; LINE BEFORE
|
||||
. I JM["</text>" S INTXT=0 ; LEFT HTML SECTION,START TRIM
|
||||
. S JP=@THEXML@(I+1) ; LINE AFTER
|
||||
. I INTXT=0 D ; IF NOT IN AN HTML SECTION
|
||||
. . S JPX=$TR(JP,"/","") ; REMOVE THE SLASH
|
||||
. . I J=JPX D ; AN EMPTY ELEMENT ON TWO LINES
|
||||
. . . I $G(DEBUG) W I,J,JP,!
|
||||
. . . S FOUND=1 ; FOUND SOMETHING TO BE DELETED
|
||||
. . . S DEL(I)="" ; SET LINE TO DELETE
|
||||
. . . S DEL(I+1)="" ; SET NEXT LINE TO DELETE
|
||||
. . I J["><" D ; AN EMPTY ELEMENT ON ONE LINE
|
||||
. . . I $G(DEBUG) W I,J,!
|
||||
. . . S FOUND=1 ; FOUND SOMETHING TO BE DELETED
|
||||
. . . S DEL(I)="" ; SET THE EMPTY LINE UP TO BE DELETED
|
||||
. . . I JM=JPX D ;
|
||||
. . . . I $G(DEBUG) W I,JM_J_JPX,!
|
||||
. . . . S DEL(I-1)=""
|
||||
. . . . S DEL(I+1)="" ; SET THE SURROUNDING LINES FOR DEL
|
||||
; . I J'["><" D PUSH("TMPXML",J)
|
||||
I FOUND D ; NEED TO DELETE THINGS
|
||||
. F I=1:1:@THEXML@(0) D ; COPY ARRAY LEAVING OUT DELELTED LINES
|
||||
. . I '$D(DEL(I)) D ; IF THE LINE IS NOT DELETED
|
||||
. . . D PUSH("TMPXML",@THEXML@(I)) ; COPY TO TMPXML ARRAY
|
||||
. D CP("TMPXML",THEXML) ; REPLACE THE XML WITH THE COPY
|
||||
Q FOUND
|
||||
;
|
||||
UNMARK(XSEC) ; REMOVE MARKUP FROM FIRST AND LAST LINE OF XML
|
||||
; XSEC IS A SECTION PASSED BY NAME
|
||||
N XBLD,XTMP
|
||||
D QUEUE("XBLD",XSEC,2,@XSEC@(0)-1) ; BUILD LIST FOR INNER XML
|
||||
D BUILD("XBLD","XTMP") ; BUILD THE RESULT
|
||||
D CP("XTMP",XSEC) ; REPLACE PASSED XML
|
||||
Q
|
||||
;
|
||||
PARY(GLO,ZN) ;PRINT AN ARRAY
|
||||
; IF ZN=-1 NO LINE NUMBERS
|
||||
N I
|
||||
F I=1:1:@GLO@(0) D ;
|
||||
. I $G(ZN)=-1 W @GLO@(I),!
|
||||
. E W I_" "_@GLO@(I),!
|
||||
Q
|
||||
;
|
||||
H2ARY(IARYRTN,IHASH,IPRE) ; CONVERT IHASH TO RETURN ARRAY
|
||||
; IPRE IS OPTIONAL PREFIX FOR THE ELEMENTS. USED FOR MUPTIPLES 1^"VAR"^VALUE
|
||||
I '$D(IPRE) S IPRE=""
|
||||
N H2I S H2I=""
|
||||
; W $O(@IHASH@(H2I)),!
|
||||
F S H2I=$O(@IHASH@(H2I)) Q:H2I="" D ; FOR EACH ELEMENT OF THE HASH
|
||||
. I $QS(H2I,$QL(H2I))="M" D Q ; SPECIAL CASE FOR MULTIPLES
|
||||
. . ;W H2I_"^"_@IHASH@(H2I),!
|
||||
. . N IH,IHI
|
||||
. . S IH=$NA(@IHASH@(H2I)) ;
|
||||
. . S IH2A=$O(@IH@("")) ; SKIP OVER MULTIPLE DISCRIPTOR
|
||||
. . S IH2=$NA(@IH@(IH2A)) ; PAST THE "M","DIRETIONS" FOR EXAMPLE
|
||||
. . S IHI="" ; INDEX INTO "M" MULTIPLES
|
||||
. . F S IHI=$O(@IH2@(IHI)) Q:IHI="" D ; FOR EACH SUB-MULTIPLE
|
||||
. . . ; W @IH@(IHI)
|
||||
. . . S IH3=$NA(@IH2@(IHI))
|
||||
. . . ; W "HEY",IH3,!
|
||||
. . . D H2ARY(.IARYRTN,IH3,IPRE_";"_IHI) ; RECURSIVE CALL - INDENTED ELEMENTS
|
||||
. . ; W IH,!
|
||||
. . ; W "C0CZZ",!
|
||||
. . ; W $NA(@IHASH@(H2I)),!
|
||||
. . Q ;
|
||||
. D PUSH(IARYRTN,IPRE_"^"_H2I_"^"_@IHASH@(H2I))
|
||||
. ; W @IARYRTN@(0),!
|
||||
Q
|
||||
;
|
||||
XVARS(XVRTN,XVIXML) ; RETURNS AN ARRAY XVRTN OF ALL UNIQUE VARIABLES
|
||||
; DEFINED IN INPUT XML XVIXML BY @@VAR@@
|
||||
; XVRTN AND XVIXML ARE PASSED BY NAME
|
||||
;
|
||||
N XVI,XVTMP,XVT
|
||||
F XVI=1:1:@XVIXML@(0) D ; FOR ALL LINES OF THE XML
|
||||
. S XVT=@XVIXML@(XVI)
|
||||
. I XVT["@@" S XVTMP($P(XVT,"@@",2))=XVI
|
||||
D H2ARY(XVRTN,"XVTMP")
|
||||
Q
|
||||
;
|
||||
DXVARS(DXIN) ;DISPLAY ALL VARIABLES IN A TEMPLATE
|
||||
; IF PARAMETERS ARE NULL, DEFAULTS TO CCR TEMPLATE
|
||||
;
|
||||
N DXUSE,DTMP ; DXUSE IS NAME OF VARIABLE, DTMP IS VARIABLE IF NOT SUPPLIED
|
||||
I DXIN="CCR" D ; NEED TO GO GET CCR TEMPLATE
|
||||
. D LOAD^C0CCCR0("DTMP") ; LOAD CCR TEMPLATE INTO DXTMP
|
||||
. S DXUSE="DTMP" ; DXUSE IS NAME
|
||||
E I DXIN="CCD" D ; NEED TO GO GET CCD TEMPLATE
|
||||
. D LOAD^C0CCCD1("DTMP") ; LOAD CCR TEMPLATE INTO DXTMP
|
||||
. S DXUSE="DTMP" ; DXUSE IS NAME
|
||||
E S DXUSE=DXIN ; IF PASSED THE TEMPLATE TO USE
|
||||
N DVARS ; PUT VARIABLE NAME RESULTS IN ARRAY HERE
|
||||
D XVARS("DVARS",DXUSE) ; PULL OUT VARS
|
||||
D PARY^C0CXPATH("DVARS") ;AND DISPLAY THEM
|
||||
Q
|
||||
;
|
||||
TEST ; Run all the test cases
|
||||
D TESTALL^C0CUNIT("C0CXPAT0")
|
||||
Q
|
||||
;
|
||||
ZTEST(WHICH) ; RUN ONE SET OF TESTS
|
||||
N ZTMP
|
||||
S DEBUG=1
|
||||
D ZLOAD^C0CUNIT("ZTMP","C0CXPAT0")
|
||||
D ZTEST^C0CUNIT(.ZTMP,WHICH)
|
||||
Q
|
||||
;
|
||||
TLIST ; LIST THE TESTS
|
||||
N ZTMP
|
||||
D ZLOAD^C0CUNIT("ZTMP","C0CXPAT0")
|
||||
D TLIST^C0CUNIT(.ZTMP)
|
||||
Q
|
||||
;
|
Loading…
Reference in New Issue