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

KMPSYNTH.m

Go to the documentation of this file.
  1. KMPSYNTH ;SP/JML - VistA Synthetic Transactions ;2/1/2023
  1. ;;4.0;CAPACITY MANAGEMENT;**1,3**;3/1/2018;Build 17
  1. ;
  1. ; Reference to ^DPT in ICR #10035
  1. ; Reference to PTSEC^DGSEC4 in ICR #3027
  1. ; Reference to GET^VPR in ICR #7135
  1. ; Reference to GET^VPRJD in ICR #7136
  1. ;
  1. SYNRCMD(KMPJSON) ;
  1. N KMPA,KMPARRAY,KMPARRAY1,KMPB,KMPC,KMPEND,KMPI,KMPRET,KMPSTART
  1. S KMPSTART=$$STATS()
  1. F KMPI=1:1:1000 D
  1. .S KMPA=$R(100),KMPB=$R(100),KMPC=KMPA+KMPB,KMPARRAY(KMPI)=KMPC D
  1. ..M KMPARRAY1=KMPARRAY K KMPARRAY
  1. ..D ONE
  1. ..D TWO
  1. S KMPEND=$$STATS()
  1. S KMPJSON.SystemCpuTime=$P(KMPEND,"^",1)-$P(KMPSTART,"^",1)
  1. S KMPJSON.UserCpuTime=$P(KMPEND,"^",2)-$P(KMPSTART,"^",2)
  1. S KMPJSON.RoutineCommands=$P(KMPEND,"^",3)-$P(KMPSTART,"^",3)
  1. S KMPJSON.GlobalRefs=$P(KMPEND,"^",4)-$P(KMPSTART,"^",4)
  1. S KMPJSON.Runtime=$NUMBER(($P($P(KMPEND,"^",5),",",2)-$P($P(KMPSTART,"^",5),",",2))*1000,0)
  1. Q
  1. ;
  1. ONE ;
  1. N KMPAAA,KMPANS1,KMPANS2,KMPANS3,KMPANS4,KMPANS5,KMPANS6,KMPARR,KMPBBB,KMPCCC,KMPX,KMPY,KMPZ
  1. S KMPAAA=$R(100),KMPBBB=$R(100),KMPCCC=$R(100)
  1. I KMPBBB=0 S KMPBBB=1000
  1. S KMPANS1=KMPAAA-KMPBBB S KMPANS1=$S(KMPANS1<1:1,1:KMPANS1)
  1. S KMPANS2=KMPAAA+KMPBBB S KMPANS2=$S(KMPANS2<1:1,1:KMPANS2)
  1. S KMPANS3=KMPAAA/KMPBBB S KMPANS3=$S(KMPANS3<1:1,1:KMPANS3)
  1. S KMPANS4=KMPAAA*KMPBBB S KMPANS4=$S(KMPANS4<1:1,1:KMPANS4)
  1. S KMPANS5=(KMPANS1/KMPANS2)*KMPANS3
  1. S KMPANS6=KMPANS4#2,KMPANS6=KMPANS1*KMPANS2*KMPANS3*KMPANS4
  1. F KMPX=1:1:100 D
  1. .F KMPY=1:1:100 D
  1. ..S KMPARR(KMPY)=KMPANS1*KMPANS2
  1. ..S KMPARR(KMPY,KMPY)=KMPANS3*KMPANS4
  1. ..S KMPARR(KMPY,KMPY,KMPY)=KMPANS1_"^"_KMPANS2_"^"_KMPANS3_"^"_KMPANS4
  1. S KMPZ=""
  1. F S KMPZ=$O(KMPARR(KMPZ)) Q:KMPZ="" D
  1. .K KMPARR(KMPZ)
  1. Q
  1. ;
  1. TWO ;
  1. N KMPALPHA,KMPFIRST,KMPFL,KMPI,KMPLAST,KMPLEN,KMPSENTARR,KMPSENTENCE,KMPSENTENCE2,KMPTOT
  1. S KMPALPHA="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  1. S KMPSENTENCE="THIS IS A ROUTINE TO GENERATE ROUTINE COMMANDS"
  1. S KMPLEN=$L(KMPSENTENCE," ")
  1. S KMPFIRST=$P(KMPSENTENCE," "),KMPLAST=$P(KMPSENTENCE," ",KMPLEN)
  1. S KMPFL=KMPFIRST_","_KMPLAST
  1. F KMPI=1:1:KMPLEN S KMPSENTARR(KMPI)=$P(KMPSENTENCE," ",KMPI)
  1. S KMPI=""
  1. F S KMPI=$O(KMPSENTARR(KMPI)) Q:KMPI="" D
  1. .S KMPSENTENCE2=$G(KMPSENTENCE2)_":"_$G(KMPSENTARR(KMPI))
  1. S KMPTOT=0 F KMPI=1:1:$L(KMPSENTENCE2) D
  1. .S KMPTOT=KMPTOT+$A($E(KMPSENTENCE2,KMPI))
  1. Q
  1. ;
  1. SYNFILE(KMPJSON) ;
  1. N KMPBB,KMPEND,KMPF,KMPFILE,KMPI,KMPLINE,KMPPATH,KMPSTART,KMPSTAT,KMPTEXT,KMPDFILE,KMPFILES
  1. N KMPLN,KMPMATCH,KMPDELS,KMPSTART1,KMPEND1,KMPSTART2,KMPEND2,KMPSTART3,KMPEND3,POP
  1. S KMPSTART1=$$STATS(),KMPSTAT=""
  1. ; create file and write lorem ipsem text
  1. S KMPPATH=$$DEFDIR^%ZISH(),KMPFILE="VistaSystemMonitor"_$J_".txt"
  1. D OPEN^%ZISH("KMPFILE",KMPPATH,KMPFILE,"W")
  1. I POP=1 S KMPJSON.FileOpen="Failure" Q
  1. I POP=0 D
  1. .S KMPJSON.FileOpen="Success"
  1. .U IO
  1. .F KMPI=1:1:500 D
  1. ..S KMPTEXT="",KMPLINE=1
  1. ..F D Q:KMPTEXT=""
  1. ...S KMPTEXT=$P($TEXT(LOREM+KMPLINE),";;",2)
  1. ...W !,KMPTEXT
  1. ...S KMPLINE=KMPLINE+1
  1. D CLOSE^%ZISH("KMPFILE")
  1. S (KMPEND1,KMPSTART2)=$$STATS()
  1. D OPEN^%ZISH("KMPFILE",KMPPATH,KMPFILE,"R")
  1. I POP=1 S KMPJSON.FileOpen="Failure" Q
  1. I POP=0 D
  1. .F U IO R KMPLN:1 Q:$$STATUS^%ZISH S KMPBB=KMPLN
  1. .D CLOSE^%ZISH("KMPFILE")
  1. S (KMPEND2,KMPSTART3)=$$STATS()
  1. ; delete any files created with this routine
  1. S KMPMATCH("VistaSystemMonitor*.txt")=""
  1. S KMPBB=$$LIST^%ZISH(KMPPATH,"KMPMATCH","KMPFILES")
  1. S KMPFILE="",KMPDELS=0
  1. F S KMPFILE=$O(KMPFILES(KMPFILE)) Q:KMPFILE="" D
  1. .S KMPDFILE(KMPFILE)=""
  1. .S KMPDELS=KMPDELS+1
  1. S KMPBB=$$DEL^%ZISH(KMPPATH,$NA(KMPDFILE))
  1. S KMPEND3=$$STATS()
  1. ; calculate stats and return
  1. S KMPJSON.ReadSystemCpuTime=$P(KMPEND1,"^",1)-$P(KMPSTART1,"^",1)
  1. S KMPJSON.ReadUserCpuTime=$P(KMPEND1,"^",2)-$P(KMPSTART1,"^",2)
  1. S KMPJSON.ReadRoutineCommands=$P(KMPEND1,"^",3)-$P(KMPSTART1,"^",3)
  1. S KMPJSON.ReadGlobalRefs=$P(KMPEND1,"^",4)-$P(KMPSTART1,"^",4)
  1. S KMPJSON.ReadRuntime=$NUMBER(($P($P(KMPEND1,"^",5),",",2)-$P($P(KMPSTART1,"^",5),",",2))*1000,0)
  1. S KMPJSON.WriteSystemCpuTime=$P(KMPEND2,"^",1)-$P(KMPSTART2,"^",1)
  1. S KMPJSON.WriteUserCpuTime=$P(KMPEND2,"^",2)-$P(KMPSTART2,"^",2)
  1. S KMPJSON.WriteRoutineCommands=$P(KMPEND2,"^",3)-$P(KMPSTART2,"^",3)
  1. S KMPJSON.WriteGlobalRefs=$P(KMPEND2,"^",4)-$P(KMPSTART2,"^",4)
  1. S KMPJSON.WriteRuntime=$NUMBER(($P($P(KMPEND2,"^",5),",",2)-$P($P(KMPSTART2,"^",5),",",2))*1000,0)
  1. S KMPJSON.DeleteSystemCpuTime=$P(KMPEND3,"^",1)-$P(KMPSTART3,"^",1)
  1. S KMPJSON.DeleteUserCpuTime=$P(KMPEND3,"^",2)-$P(KMPSTART3,"^",2)
  1. S KMPJSON.DeleteRoutineCommands=$P(KMPEND3,"^",3)-$P(KMPSTART3,"^",3)
  1. S KMPJSON.DeleteGlobalRefs=$P(KMPEND3,"^",4)-$P(KMPSTART3,"^",4)
  1. S KMPJSON.DeleteRuntime=$NUMBER(($P($P(KMPEND3,"^",5),",",2)-$P($P(KMPSTART3,"^",5),",",2))*1000,0)
  1. S KMPJSON.DeletedFileCount=KMPDELS
  1. Q
  1. SYNVPR(KMPJSON,KMPDFN,KMPCDOMS) ;
  1. N DT,KMPDARR,KMPEND,KMPI,KMPLAST,KMPLINE,KMPLINE2,KMPRET,KMPSTART,KMPTCHAR
  1. S KMPSTART=$$STATS()
  1. S DT=$$DT^XLFDT
  1. S KMPDARR=##class(%DynamicArray).%New()
  1. S KMPTCHAR=0,KMPI=0
  1. I $G(KMPDFN)="" S KMPDFN=$O(^DPT("A"),-1) ;supported by ICR #10035
  1. D GET^VPRD(.KMPRET,KMPDFN,$G(KMPCDOMS)) ;supported by ICR #7135
  1. S KMPLAST=$O(@KMPRET@(999),-1)
  1. F KMPI=1:1:KMPLAST D
  1. .S KMPLINE=$G(@KMPRET@(KMPI))
  1. .Q:KMPLINE=""
  1. .S KMPTCHAR=KMPTCHAR+$L(KMPLINE)
  1. .S $P(KMPLINE2,"X",$L(KMPLINE))="X"
  1. .D KMPDARR.%Push(KMPLINE2)
  1. .K KMPLINE2
  1. K @KMPRET
  1. S KMPJSON.Payload=KMPDARR
  1. S KMPJSON.TotalLines=KMPLAST
  1. S KMPJSON.TotalCharacters=KMPTCHAR
  1. S KMPJSON.Dfn=KMPDFN
  1. S KMPEND=$$STATS()
  1. S KMPJSON.SystemCpuTime=$P(KMPEND,"^",1)-$P(KMPSTART,"^",1)
  1. S KMPJSON.UserCpuTime=$P(KMPEND,"^",2)-$P(KMPSTART,"^",2)
  1. S KMPJSON.RoutineCommands=$P(KMPEND,"^",3)-$P(KMPSTART,"^",3)
  1. S KMPJSON.GlobalRefs=$P(KMPEND,"^",4)-$P(KMPSTART,"^",4)
  1. S KMPJSON.Runtime=$NUMBER(($P($P(KMPEND,"^",5),",",2)-$P($P(KMPSTART,"^",5),",",2))*1000,0)
  1. Q
  1. ;
  1. PATLIST(KMPJSON,KMPMAX) ;
  1. ; LAST 4, LASTNAME, FIRSTMIDNAME, DUZ, last appointment
  1. N KMPPARR,KMPDFN,KMPCNT,KMPSTOP,DGSENS,DGSENFLG,KMPN0,KMPNAME,KMPLNAME,KMPFMNAME,KMPSSN,KMPLAST4,KMPSCDT,KMPPAT
  1. ;
  1. S KMPPARR=##class(%DynamicArray).%New()
  1. S KMPMAX=+$G(KMPMAX) I KMPMAX=0 S KMPMAX=10
  1. S KMPDFN="A",KMPCNT=0,KMPSTOP=0
  1. F S KMPDFN=$O(^DPT(KMPDFN),-1) Q:KMPDFN=""!(KMPSTOP) D ;supported by ICR #10035
  1. .; Quit if patient is deceased
  1. .Q:$P($G(^DPT(KMPDFN,.35)),"^")]""
  1. .; Quit if patient is restricted
  1. .D PTSEC^DGSEC4(.DGSENS,KMPDFN) ;supported by ICR #3027
  1. .Q:DGSENS(1)'=0
  1. .S KMPN0=$G(^DPT(KMPDFN,0))
  1. .S KMPNAME=$P(KMPN0,"^"),KMPLNAME=$P(KMPNAME,","),KMPFMNAME=$P(KMPNAME,",",2)
  1. .S KMPSSN=$P(KMPN0,"^",9),KMPLAST4=$E(KMPSSN,6,9)
  1. .S KMPSCDT=$O(^DPT(KMPDFN,"S",""),-1)
  1. .S KMPPAT=##class(%DynamicObject).%New()
  1. .S KMPPAT.SsnLast4=KMPLAST4,KMPPAT.LastName=KMPLNAME
  1. .S KMPPAT.FirstMiddleName=KMPFMNAME,KMPPAT.Dfn=KMPDFN
  1. .S KMPPAT.LastApptDate=$P($$TSTAMP^KMPUTLW(KMPSCDT,"FILEMAN"),"^")
  1. .D KMPPARR.%Push(KMPPAT)
  1. .S KMPCNT=KMPCNT+1
  1. .I KMPCNT>=KMPMAX S KMPSTOP=1
  1. S KMPJSON.Patients=KMPPARR
  1. Q
  1. ;
  1. STATS() ;
  1. N KMPVCPU,KMPVPROC,KMPVRET
  1. S KMPVRET=""
  1. S KMPVPROC=##class(%SYS.ProcessQuery).%OpenId($J)
  1. I KMPVPROC="" Q KMPVRET
  1. ; cpu time
  1. S KMPVCPU=KMPVPROC.GetCPUTime()
  1. S $P(KMPVRET,"^")=$P(KMPVCPU,",")
  1. S $P(KMPVRET,"^",2)=$P(KMPVCPU,",",2)
  1. ; m commands - commands
  1. S $P(KMPVRET,"^",3)=KMPVPROC.CommandsExecuted
  1. ; global references
  1. S $P(KMPVRET,"^",4)=KMPVPROC.GlobalReferences
  1. ; current time UTC
  1. S $P(KMPVRET,"^",5)=$ZTIMESTAMP
  1. K KMPVPROC
  1. Q KMPVRET
  1. ;
  1. LOREM ;
  1. ;;Lorem ipsum is a pseudo-Latin text used in web design, typography,
  1. ;;layout, and printing ;; in place of English to emphasise design
  1. ;;elements over content. It's also called placeholder (or filler)
  1. ;;text. It's a convenient tool for mock-ups. It helps to outline
  1. ;;the visual elements of a document or presentation, eg typography,
  1. ;;font, or layout. Lorem ipsum is mostly a part of a Latin text by
  1. ;;the classical author and philosopher Cicero. Its words and letters
  1. ;;have been changed by addition or removal, so to deliberately render
  1. ;;its content nonsensical; it's not genuine, correct, or comprehensible
  1. ;;Latin anymore. While lorem ipsum's still resembles classical Latin,
  1. ;;it actually has no meaning whatsoever. As Cicero's text doesn't
  1. ;;contain the letters K, W, or Z, alien to latin, these, and others
  1. ;;are often inserted randomly to mimic the typographic appearence
  1. ;;of European languages, as are digraphs not to be found in the original.
  1. ;;In a professional context it often happens that private or corporate
  1. ;;clients corder a publication to be made and presented with the
  1. ;;actual content still not being ready. Think of a news blog that's
  1. ;;filled with content hourly on the day of going live. However,
  1. ;;reviewers tend to be distracted by comprehensible content, say, a
  1. ;;random text copied from a newspaper or the internet. The are likely
  1. ;;to focus on the text, disregarding the layout and its elements.
  1. ;;Besides, random text risks to be unintendedly humorous or offensive,
  1. ;;an unacceptable risk in corporate environments. Lorem ipsum and its
  1. ;;many variants have been employed since the early 1960ies, and quite
  1. ;;likely since the sixteenth century.
  1. ;;Lorem Ipsum: common examples layout based on Lorem Ipsum Most of
  1. ;;its text is made up from sections 1.10.32-3 of Cicero's De finibus
  1. ;;bonorum et malorum (On the Boundaries of Goods and Evils; finibus
  1. ;;may also be translated as purposes). Neque porro quisquam est qui
  1. ;;dolorem ipsum quia dolor sit amet, consectetur, adipisci velit is
  1. ;;The first known version ("Neither is there anyone who loves grief
  1. ;;itself since it is grief and thus wants to obtain it"). It was found
  1. ;;by Richard McClintock, a philologist, director of publications at
  1. ;;Hampden-Sydney College in Virginia; he searched for citings of
  1. ;;consectetur in classical Latin literature, a term of remarkably
  1. ;;low frequency in that literary corpus. Cicero famously orated
  1. ;;against his political opponent Lucius Sergius Catilina. Occasionally
  1. ;;the first Oration against Catiline is taken for type specimens:
  1. ;;Quo usque tandem abutere, Catilina, patientia nostra? Quam diu
  1. ;;etiam furor iste tuus nos eludet? (How long, O Catiline, will you
  1. ;;abuse our patience? And for how long will that madness of yours
  1. ;;mock us?) Cicero's version of Liber Primus (first Book), sections
  1. ;;1.10.32-3 (fragments included in most Lorem Ipsum variants in red):
  1. ;;Cicero writing letters; from an early edition by Hieronymus Scotus
  1. ;;Sed ut perspiciatis, unde omnis iste natus error sit voluptatem
  1. ;;accusantium doloremque laudantium, totam rem aperiam eaque ipsa,
  1. ;;quae ab illo inventore veritatis et quasi architecto beatae vitae
  1. ;;dicta sunt, explicabo. Nemo enim ipsam voluptatem, quia voluptas sit,
  1. ;;aspernatur aut odit aut fugit, sed quia consequuntur magni dolores
  1. ;;eos, qui ratione voluptatem sequi nesciunt, neque porro quisquam est,
  1. ;;qui dolorem ipsum, quia dolor sit amet, consectetur, adipisci[ng]
  1. ;;velit, sed quia non numquam [do] eius modi tempora inci[di]dunt, ut
  1. ;;labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima
  1. ;;veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam,
  1. ;;nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure
  1. ;;reprehenderit, qui in ea voluptate velit esse, quam nihil molestiae
  1. ;;consequatur, vel illum, qui dolorem eum fugiat, quo voluptas nulla
  1. ;;pariatur?
  1. ;;Lorem Ipsum: translation
  1. ;;The Latin scholar H. Rackham translated the above in 1914:
  1. ;;De Finibus Bonorum Et Malorum But I must explain to you how all this
  1. ;;mistaken idea of denouncing pleasure and praising pain was born and I
  1. ;;will give you a complete account of the system, and expound the actual
  1. ;;teachings of the great explorer of the truth, the master-builder
  1. ;;of human happiness. No one rejects, dislikes, or avoids pleasure itself,
  1. ;;because it is pleasure, but because those who do not know how to pursue
  1. ;;pleasure rationally encounter consequences that are extremely painful.
  1. ;;Nor again is there anyone who loves or pursues or desires to obtain pain
  1. ;;of itself, because it is pain, but occasionally circumstances occur in
  1. ;;which toil and pain can procure him some great pleasure. To take a
  1. ;;trivial example, which of us ever undertakes laborious physical exercise,
  1. ;;except to obtain some advantage from it? But who has any right to find
  1. ;;fault with a man who chooses to enjoy a pleasure that has no annoying
  1. ;;consequences, or one who avoids a pain that produces no resultant
  1. ;;pleasure? On the other hand, we denounce with righteous indignation
  1. ;;and dislike men who are so beguiled and demoralized by the charms of
  1. ;;pleasure of the moment, so blinded by desire, that they cannot foresee
  1. ;;the pain and trouble that are bound to ensue; and equal blame belongs
  1. ;;to those who fail in their duty through weakness of will, which is the
  1. ;;same as saying through shrinking from toil and pain. These cases are
  1. ;;perfectly simple and easy to distinguish. In a free hour, when our
  1. ;;power of choice is untrammelled and when nothing prevents our being able
  1. ;;to do what we like best, every pleasure is to be welcomed and every pain
  1. ;;avoided. But in certain circumstances and owing to the claims of duty
  1. ;;or the obligations of business it will frequently occur that pleasures
  1. ;;have to be repudiated and annoyances accepted. The wise man therefore
  1. ;;always holds in these matters to this principle of selection: he
  1. ;;rejects pleasures to secure other greater pleasures, or else
  1. ;;he endures pains to avoid worse pains.
  1. ;;Lorem Ipsum: variants and technical information
  1. ;;Adobe Fireworks Lorem Ipsum plugin In 1985 Aldus Corporation launched
  1. ;;its first desktop publishing program Aldus PageMaker for Apple Macintosh
  1. ;;computers, released in 1987 for PCs running Windows 1.0. Both contained
  1. ;;the variant lorem ipsum most common today. Laura Perry, then art director
  1. ;;with Aldus, modified prior versions of Lorem Ipsum text from typographical
  1. ;;specimens; in the 1960s and 1970s it appeared often in lettering
  1. ;;catalogs by Letraset. Anecdotal evidence has it that Letraset used Lorem
  1. ;;ipsum already from 1970 onwards, eg. for grids (page layouts) for ad
  1. ;;agencies. Many early desktop publishing programs, eg. Adobe PageMaker,
  1. ;;used it to create template. Most text editors like MS Word or Lotus
  1. ;;Notes generate random lorem text when needed, either as pre-installed
  1. ;;module or plug-in to be added. Word selection or sequence don't
  1. ;;necessarily match the original, which is intended to add variety.
  1. ;;Presentation software like Keynote or Pages use it as a samples for
  1. ;;screenplay layout. Content management software as Joomla, Drupal, Mambo,
  1. ;;PHP-Nuke, WordPress, or Movable Type offer Lorem Ipsum plug-ins
  1. ;;with the same functionality.
  1. ;;DONE