Skip to content

Instantly share code, notes, and snippets.

@TimSC
Last active September 29, 2017 09:57
Show Gist options
  • Save TimSC/58e48882e4e7c307ff8519383510cc58 to your computer and use it in GitHub Desktop.
Save TimSC/58e48882e4e7c307ff8519383510cc58 to your computer and use it in GitHub Desktop.
Trying to dump Mumps data
dumpusers; Dump users functionality
xmlEscapeApostrophe(string) ; Private ; Escape apostrophe
;
n out,x,c
;
s out=""
f x=1:1:$l(string) d
. s c=$e(string,x)
. i "'"[c s out=out_"'" q
. s out=out_c
q out
dump5(k1,k2,k3,k4,k5)
;
w "<l5 k='",$$xmlEscapeApostrophe(k5),"'/>",!
q
dump4(k1,k2,k3,k4)
;
w "<l4 k='",$$xmlEscapeApostrophe(k4),"'"
s exists4=$data(^user(k1,k2,k3,k4))
if (exists4#10)=1 do
. w " value='",$$xmlEscapeApostrophe(^user(k1,k2,k3,k4)),"'"
w ">",!
if (exists4-(exists4#10))=10 do
. set k5="" for do q:k5=""
. . s k5=$o(^user(k1,k2,k3,k4,k5)) q:k5=""
. . d dump5(k1,k2,k3,k4,k5)
w "</l4>",!
q
dump3(k1,k2,k3)
;
w "<l3 k='",$$xmlEscapeApostrophe(k3),"'"
s exists3=$data(^user(k1,k2,k3))
if (exists3#10)=1 do
. w " value='",$$xmlEscapeApostrophe(^user(k1,k2,k3)),"'"
w ">",!
if (exists3-(exists3#10))=10 do
. set k4="" for do q:k4=""
. . s k4=$o(^user(k1,k2,k3,k4)) q:k4=""
. . d dump4(k1,k2,k3,k4)
w "</l3>",!
q
dump2(k1,k2)
;
w "<l2 k='",$$xmlEscapeApostrophe(k2),"'"
s exists2=$data(^user(k1,k2))
if (exists2#10)=1 do
. w " value='",$$xmlEscapeApostrophe(^user(k1,k2)),"'"
w ">",!
if (exists2-(exists2#10))=10 do
. set k3="" for do q:k3=""
. . s k3=$o(^user(k1,k2,k3)) q:k3=""
. . d dump3(k1,k2,k3)
w "</l2>",!
q
dump(k1)
;
w "<l1 k='",$$xmlEscapeApostrophe(k1),"'"
s exists=$data(^user(k1))
if (exists#10)=1 do
. w " value='",$$xmlEscapeApostrophe(^user(k1)),"'"
w ">",!
if (exists-(exists#10))=10 do
. set k2="" for do q:k2=""
. . s k2=$o(^user(k1,k2)) q:k2=""
. . d dump2(k1,k2)
w "</l1>",!
q
test() ; Public
;
w "<?xml version='1.0' encoding='UTF-8'?>",!
w "<users>",!
set uid="" for do q:uid=""
. s uid=$o(^user(uid)) q:uid=""
. d dump(uid)
w "</users>",!
q
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment