KIDS Distribution saved on Mar 30, 2021@12:52:49
Released SAMI*18.0*11 SEQ #11 T1 (1.18.0.11-i11-t1)
**KIDS**:SAMI*18.0*11^

**INSTALL NAME**
SAMI*18.0*11
"BLD",11508,0)
SAMI*18.0*11^SAMI^0^3210330^n
"BLD",11508,1,0)
^^1^1^3210329^
"BLD",11508,1,1,0)
Critical bugs fixed in Intake, CT eval, and reports
"BLD",11508,4,0)
^9.64PA^^
"BLD",11508,6)
^11
"BLD",11508,6.3)
4
"BLD",11508,"KRN",0)
^9.67PA^1.5^25
"BLD",11508,"KRN",.4,0)
.4
"BLD",11508,"KRN",.401,0)
.401
"BLD",11508,"KRN",.402,0)
.402
"BLD",11508,"KRN",.403,0)
.403
"BLD",11508,"KRN",.5,0)
.5
"BLD",11508,"KRN",.84,0)
.84
"BLD",11508,"KRN",1.5,0)
1.5
"BLD",11508,"KRN",1.6,0)
1.6
"BLD",11508,"KRN",1.61,0)
1.61
"BLD",11508,"KRN",1.62,0)
1.62
"BLD",11508,"KRN",3.6,0)
3.6
"BLD",11508,"KRN",3.8,0)
3.8
"BLD",11508,"KRN",9.2,0)
9.2
"BLD",11508,"KRN",9.8,0)
9.8
"BLD",11508,"KRN",9.8,"NM",0)
^9.68A^4^4
"BLD",11508,"KRN",9.8,"NM",1,0)
SAMINOT1^^0^B443163534
"BLD",11508,"KRN",9.8,"NM",2,0)
SAMIUR^^0^B291906917
"BLD",11508,"KRN",9.8,"NM",3,0)
SAMINUL^^0^B101598
"BLD",11508,"KRN",9.8,"NM",4,0)
SAMICSV^^0^B54323386
"BLD",11508,"KRN",9.8,"NM","B","SAMICSV",4)

"BLD",11508,"KRN",9.8,"NM","B","SAMINOT1",1)

"BLD",11508,"KRN",9.8,"NM","B","SAMINUL",3)

"BLD",11508,"KRN",9.8,"NM","B","SAMIUR",2)

"BLD",11508,"KRN",19,0)
19
"BLD",11508,"KRN",19.1,0)
19.1
"BLD",11508,"KRN",101,0)
101
"BLD",11508,"KRN",409.61,0)
409.61
"BLD",11508,"KRN",771,0)
771
"BLD",11508,"KRN",779.2,0)
779.2
"BLD",11508,"KRN",870,0)
870
"BLD",11508,"KRN",8989.51,0)
8989.51
"BLD",11508,"KRN",8989.52,0)
8989.52
"BLD",11508,"KRN",8993,0)
8993
"BLD",11508,"KRN",8994,0)
8994
"BLD",11508,"KRN","B",.4,.4)

"BLD",11508,"KRN","B",.401,.401)

"BLD",11508,"KRN","B",.402,.402)

"BLD",11508,"KRN","B",.403,.403)

"BLD",11508,"KRN","B",.5,.5)

"BLD",11508,"KRN","B",.84,.84)

"BLD",11508,"KRN","B",1.5,1.5)

"BLD",11508,"KRN","B",1.6,1.6)

"BLD",11508,"KRN","B",1.61,1.61)

"BLD",11508,"KRN","B",1.62,1.62)

"BLD",11508,"KRN","B",3.6,3.6)

"BLD",11508,"KRN","B",3.8,3.8)

"BLD",11508,"KRN","B",9.2,9.2)

"BLD",11508,"KRN","B",9.8,9.8)

"BLD",11508,"KRN","B",19,19)

"BLD",11508,"KRN","B",19.1,19.1)

"BLD",11508,"KRN","B",101,101)

"BLD",11508,"KRN","B",409.61,409.61)

"BLD",11508,"KRN","B",771,771)

"BLD",11508,"KRN","B",779.2,779.2)

"BLD",11508,"KRN","B",870,870)

"BLD",11508,"KRN","B",8989.51,8989.51)

"BLD",11508,"KRN","B",8989.52,8989.52)

"BLD",11508,"KRN","B",8993,8993)

"BLD",11508,"KRN","B",8994,8994)

"BLD",11508,"QDEF")
^^^^NO^^^^NO^^NO
"BLD",11508,"QUES",0)
^9.62^^
"BLD",11508,"REQB",0)
^9.611^7^6
"BLD",11508,"REQB",1,0)
SAMI*18.0*2^1
"BLD",11508,"REQB",2,0)
SAMI 18.0T05^1
"BLD",11508,"REQB",3,0)
SAMI*18.0*6^1
"BLD",11508,"REQB",5,0)
SAMI*18.0*8^1
"BLD",11508,"REQB",6,0)
SAMI*18.0*9^1
"BLD",11508,"REQB",7,0)
SAMI*18.0*10^1
"BLD",11508,"REQB","B","SAMI 18.0T05",2)

"BLD",11508,"REQB","B","SAMI*18.0*10",7)

"BLD",11508,"REQB","B","SAMI*18.0*2",1)

"BLD",11508,"REQB","B","SAMI*18.0*6",3)

"BLD",11508,"REQB","B","SAMI*18.0*8",5)

"BLD",11508,"REQB","B","SAMI*18.0*9",6)

"MBREQ")
0
"PKG",230,-1)
1^1
"PKG",230,0)
SAMI^SAMI^SCREENING APPLICATIONS MANAGEMENT - IELCAP
"PKG",230,22,0)
^9.49I^1^1
"PKG",230,22,1,0)
18.0^3191203
"PKG",230,22,1,"PAH",1,0)
11^3210330
"PKG",230,22,1,"PAH",1,1,0)
^^1^1^3210330
"PKG",230,22,1,"PAH",1,1,1,0)
Critical bugs fixed in Intake, CT eval, and reports
"QUES","XPF1",0)
Y
"QUES","XPF1","??")
^D REP^XPDH
"QUES","XPF1","A")
Shall I write over your |FLAG| File
"QUES","XPF1","B")
YES
"QUES","XPF1","M")
D XPF1^XPDIQ
"QUES","XPF2",0)
Y
"QUES","XPF2","??")
^D DTA^XPDH
"QUES","XPF2","A")
Want my data |FLAG| yours
"QUES","XPF2","B")
YES
"QUES","XPF2","M")
D XPF2^XPDIQ
"QUES","XPI1",0)
YO
"QUES","XPI1","??")
^D INHIBIT^XPDH
"QUES","XPI1","A")
Want KIDS to INHIBIT LOGONs during the install
"QUES","XPI1","B")
NO
"QUES","XPI1","M")
D XPI1^XPDIQ
"QUES","XPM1",0)
PO^VA(200,:EM
"QUES","XPM1","??")
^D MG^XPDH
"QUES","XPM1","A")
Enter the Coordinator for Mail Group '|FLAG|'
"QUES","XPM1","B")

"QUES","XPM1","M")
D XPM1^XPDIQ
"QUES","XPO1",0)
Y
"QUES","XPO1","??")
^D MENU^XPDH
"QUES","XPO1","A")
Want KIDS to Rebuild Menu Trees Upon Completion of Install
"QUES","XPO1","B")
NO
"QUES","XPO1","M")
D XPO1^XPDIQ
"QUES","XPZ1",0)
Y
"QUES","XPZ1","??")
^D OPT^XPDH
"QUES","XPZ1","A")
Want to DISABLE Scheduled Options, Menu Options, and Protocols
"QUES","XPZ1","B")
NO
"QUES","XPZ1","M")
D XPZ1^XPDIQ
"QUES","XPZ2",0)
Y
"QUES","XPZ2","??")
^D RTN^XPDH
"QUES","XPZ2","A")
Want to MOVE routines to other CPUs
"QUES","XPZ2","B")
NO
"QUES","XPZ2","M")
D XPZ2^XPDIQ
"RTN")
4
"RTN","SAMICSV")
0^4^B54323386
"RTN","SAMICSV",1,0)
SAMICSV ;ven/gpl - csv export ;2021-03-30T17:18Z
"RTN","SAMICSV",2,0)
 ;;18.0;SAMI;**7,11**;2020-01;Build 4
"RTN","SAMICSV",3,0)
 ;;1.18.0.11-i11
"RTN","SAMICSV",4,0)
 ;
"RTN","SAMICSV",5,0)
 ; SAMICSV contains a direct-mode interface to produce the VAPALS-
"RTN","SAMICSV",6,0)
 ; ELCAP CSV export.
"RTN","SAMICSV",7,0)
 ;
"RTN","SAMICSV",8,0)
 ; allow entry from top, fallthrough to EN
"RTN","SAMICSV",9,0)
 ;
"RTN","SAMICSV",10,0)
 ;
"RTN","SAMICSV",11,0)
 ;
"RTN","SAMICSV",12,0)
 ;@section 0 primary development
"RTN","SAMICSV",13,0)
 ;
"RTN","SAMICSV",14,0)
 ;
"RTN","SAMICSV",15,0)
 ;
"RTN","SAMICSV",16,0)
 ;@routine-credits
"RTN","SAMICSV",17,0)
 ;@primary-dev George P. Lilly (gpl)
"RTN","SAMICSV",18,0)
 ; gpl@vistaexpertise.net
"RTN","SAMICSV",19,0)
 ;@primary-dev-org Vista Expertise Network (ven)
"RTN","SAMICSV",20,0)
 ; http://vistaexpertise.net
"RTN","SAMICSV",21,0)
 ;@copyright 2017/2021, gpl, all rights reserved
"RTN","SAMICSV",22,0)
 ;@license see routine SAMIUL
"RTN","SAMICSV",23,0)
 ;
"RTN","SAMICSV",24,0)
 ;@last-updated 2021-03-30T17:18Z
"RTN","SAMICSV",25,0)
 ;@application Screening Applications Management (SAM)
"RTN","SAMICSV",26,0)
 ;@module Screening Applications Management - IELCAP (SAMI)
"RTN","SAMICSV",27,0)
 ;@suite-of-files SAMI Forms (311.101-311.199)
"RTN","SAMICSV",28,0)
 ;@version 1.18.0.11-i11
"RTN","SAMICSV",29,0)
 ;@release-date 2020-01
"RTN","SAMICSV",30,0)
 ;@patch-list **7,11**
"RTN","SAMICSV",31,0)
 ;
"RTN","SAMICSV",32,0)
 ;@additional-dev Frederick D. S. Marshall (toad)
"RTN","SAMICSV",33,0)
 ; toad@vistaexpertise.net
"RTN","SAMICSV",34,0)
 ;
"RTN","SAMICSV",35,0)
 ;@module-credits
"RTN","SAMICSV",36,0)
 ;@project VA Partnership to Increase Access to Lung Screening
"RTN","SAMICSV",37,0)
 ; (VA-PALS)
"RTN","SAMICSV",38,0)
 ; http://va-pals.org/
"RTN","SAMICSV",39,0)
 ;@funding 2017/2021, Bristol-Myers Squibb Foundation (bmsf)
"RTN","SAMICSV",40,0)
 ; https://www.bms.com/about-us/responsibility/bristol-myers-squibb-foundation.html
"RTN","SAMICSV",41,0)
 ;@partner-org Veterans Affairs Office of Rural health
"RTN","SAMICSV",42,0)
 ; https://www.ruralhealth.va.gov/
"RTN","SAMICSV",43,0)
 ;@partner-org International Early Lung Cancer Action Program (I-ELCAP)
"RTN","SAMICSV",44,0)
 ; http://ielcap.com/
"RTN","SAMICSV",45,0)
 ;@partner-org Paraxial Technologies (par)
"RTN","SAMICSV",46,0)
 ; http://paraxialtech.com/
"RTN","SAMICSV",47,0)
 ;@partner-org Open Source Electronic Health Record Alliance (OSEHRA)
"RTN","SAMICSV",48,0)
 ; https://www.osehra.org/groups/va-pals-open-source-project-group
"RTN","SAMICSV",49,0)
 ;
"RTN","SAMICSV",50,0)
 ;@module-log repo github.com:VA-PALS-ELCAP/SAMI-VAPALS-ELCAP.git
"RTN","SAMICSV",51,0)
 ;
"RTN","SAMICSV",52,0)
 ; 2020-08-20/09-24 ven/gpl 1.18.0.7-i7 9486abb2,5ae08772,ba0bcb82,
"RTN","SAMICSV",53,0)
 ; 1a2a1bf6,16511893
"RTN","SAMICSV",54,0)
 ;  SAMICSV: new routine, test build for extracting form data to csv
"RTN","SAMICSV",55,0)
 ; files, upgrade change site to handle patients without forms, audit
"RTN","SAMICSV",56,0)
 ; report, select from 7 forms for extract, fix dictionary spelling
"RTN","SAMICSV",57,0)
 ; for followup form, fix bug of line feeds in csv output interrupting
"RTN","SAMICSV",58,0)
 ; excel load.
"RTN","SAMICSV",59,0)
 ;
"RTN","SAMICSV",60,0)
 ; 2021-03-25 ven/gpl 1.18.0.11 e28a34d3
"RTN","SAMICSV",61,0)
 ;  SAMICSV: remove line feeds from variables.
"RTN","SAMICSV",62,0)
 ;
"RTN","SAMICSV",63,0)
 ; 2021-03-30 ven/toad 1.18.0.11-i11
"RTN","SAMICSV",64,0)
 ; SAMICSV: bump version, date, patch list, create hdr comments, lt
"RTN","SAMICSV",65,0)
 ; refactor.
"RTN","SAMICSV",66,0)
 ;
"RTN","SAMICSV",67,0)
 ;@contents
"RTN","SAMICSV",68,0)
 ; EN: entry point to generate csv files from forms for a site
"RTN","SAMICSV",69,0)
 ; ONEFORM: process one form for a site
"RTN","SAMICSV",70,0)
 ; $$FNAME = filename for site/form
"RTN","SAMICSV",71,0)
 ; DDICT: data dictionary for form
"RTN","SAMICSV",72,0)
 ; $$SAYFORM: prompts for form
"RTN","SAMICSV",73,0)
 ;
"RTN","SAMICSV",74,0)
 ;
"RTN","SAMICSV",75,0)
 ;
"RTN","SAMICSV",76,0)
EN ; entry point to generate csv files from forms for a site
"RTN","SAMICSV",77,0)
 ;
"RTN","SAMICSV",78,0)
 ; first pick a site
"RTN","SAMICSV",79,0)
 N X,Y,DIC,SITEIEN,SITEID
"RTN","SAMICSV",80,0)
 S DIC=311.12
"RTN","SAMICSV",81,0)
 S DIC(0)="AEMQ"
"RTN","SAMICSV",82,0)
 D ^DIC
"RTN","SAMICSV",83,0)
 I Y<1 Q  ; EXIT
"RTN","SAMICSV",84,0)
 S SITENUM=$P(Y,"^",2)
"RTN","SAMICSV",85,0)
 S SITEID=$$SITEID^SAMISITE(SITENUM)
"RTN","SAMICSV",86,0)
 Q:SITEID=""
"RTN","SAMICSV",87,0)
 ;
"RTN","SAMICSV",88,0)
 N SAMIFORM S SAMIFORM=$$SAYFORM()
"RTN","SAMICSV",89,0)
 Q:SAMIFORM=-1
"RTN","SAMICSV",90,0)
 ;
"RTN","SAMICSV",91,0)
 ; prompt for the directory
"RTN","SAMICSV",92,0)
 N SAMIDIR
"RTN","SAMICSV",93,0)
 D GETDIR^SAMIFDM(.SAMIDIR)
"RTN","SAMICSV",94,0)
 Q:SAMIDIR=""
"RTN","SAMICSV",95,0)
 ;
"RTN","SAMICSV",96,0)
 d ONEFORM(SITEID,SAMIFORM,SAMIDIR) ; process one form for a site
"RTN","SAMICSV",97,0)
 ;
"RTN","SAMICSV",98,0)
 quit  ; end of EN
"RTN","SAMICSV",99,0)
 ;
"RTN","SAMICSV",100,0)
 ;
"RTN","SAMICSV",101,0)
 ;
"RTN","SAMICSV",102,0)
ONEFORM(SITEID,SAMIFORM,SAMIDIR) ; process one form for a site
"RTN","SAMICSV",103,0)
 ;
"RTN","SAMICSV",104,0)
 n root s root=$$setroot^%wd("vapals-patients")
"RTN","SAMICSV",105,0)
 n groot s groot=$na(@root@("graph"))
"RTN","SAMICSV",106,0)
 n SAMII S SAMII=SITEID
"RTN","SAMICSV",107,0)
 n cnt s cnt=0
"RTN","SAMICSV",108,0)
 n forms s forms=0
"RTN","SAMICSV",109,0)
 ;
"RTN","SAMICSV",110,0)
 n SAMIOUT S SAMIOUT=$NA(^TMP("SAMICSV",$J))
"RTN","SAMICSV",111,0)
 k @SAMIOUT
"RTN","SAMICSV",112,0)
 ;
"RTN","SAMICSV",113,0)
 n DICT
"RTN","SAMICSV",114,0)
 d DDICT("DICT",SAMIFORM) ; get the data dictionary for this form
"RTN","SAMICSV",115,0)
 q:'$d(DICT)
"RTN","SAMICSV",116,0)
 ;
"RTN","SAMICSV",117,0)
 N SAMIN S SAMIN=1
"RTN","SAMICSV",118,0)
 N SAMIJJ s SAMIJJ=0
"RTN","SAMICSV",119,0)
 N OFFSET S OFFSET=0
"RTN","SAMICSV",120,0)
 I SAMIFORM="siform" d  ;
"RTN","SAMICSV",121,0)
 . S OFFSET=OFFSET+1
"RTN","SAMICSV",122,0)
 . s $p(@SAMIOUT@(SAMIN),"|",OFFSET)="saminame"
"RTN","SAMICSV",123,0)
 . S OFFSET=OFFSET+1
"RTN","SAMICSV",124,0)
 . s $p(@SAMIOUT@(SAMIN),"|",OFFSET)="ssn"
"RTN","SAMICSV",125,0)
 . S OFFSET=OFFSET+1
"RTN","SAMICSV",126,0)
 . s $p(@SAMIOUT@(SAMIN),"|",OFFSET)="last5"
"RTN","SAMICSV",127,0)
 . S OFFSET=OFFSET+1
"RTN","SAMICSV",128,0)
 . s $p(@SAMIOUT@(SAMIN),"|",OFFSET)="sex"
"RTN","SAMICSV",129,0)
 . S OFFSET=OFFSET+1
"RTN","SAMICSV",130,0)
 . s $p(@SAMIOUT@(SAMIN),"|",OFFSET)="sbdob"
"RTN","SAMICSV",131,0)
 . S OFFSET=OFFSET+1
"RTN","SAMICSV",132,0)
 . s $p(@SAMIOUT@(SAMIN),"|",OFFSET)="samiru"
"RTN","SAMICSV",133,0)
 f  s SAMIJJ=$o(DICT(SAMIJJ)) q:+SAMIJJ=0  d  ;
"RTN","SAMICSV",134,0)
 . s $p(@SAMIOUT@(SAMIN),"|",SAMIJJ+OFFSET)=DICT(SAMIJJ) ; csv header
"RTN","SAMICSV",135,0)
 s @SAMIOUT@(SAMIN)="siteid|samistudyid|form|"_@SAMIOUT@(SAMIN)
"RTN","SAMICSV",136,0)
 ;S @SAMIOUT@(SAMIN)=@SAMIOUT@(SAMIN)_$C(13,10) ; carriage return line feed
"RTN","SAMICSV",137,0)
 ; 
"RTN","SAMICSV",138,0)
 f  s SAMII=$o(@groot@(SAMII)) q:SAMII=""  q:$e(SAMII,1,3)'[SITEID  d  ;
"RTN","SAMICSV",139,0)
 . s cnt=cnt+1
"RTN","SAMICSV",140,0)
 . w !,SAMII
"RTN","SAMICSV",141,0)
 . N SAMIJ S SAMIJ=SAMIFORM
"RTN","SAMICSV",142,0)
 . n done s done=0
"RTN","SAMICSV",143,0)
 . f  s SAMIJ=$O(@groot@(SAMII,SAMIJ)) q:SAMIJ=""  q:done  d  ;
"RTN","SAMICSV",144,0)
 . . i $e(SAMIJ,1,$l(SAMIFORM))'=SAMIFORM s done=1 q  ;
"RTN","SAMICSV",145,0)
 . . s forms=forms+1
"RTN","SAMICSV",146,0)
 . . n jj s jj=0
"RTN","SAMICSV",147,0)
 . . s SAMIN=SAMIN+1
"RTN","SAMICSV",148,0)
 . . S OFFSET=0
"RTN","SAMICSV",149,0)
 . . I SAMIFORM="siform" d  ;
"RTN","SAMICSV",150,0)
 . . . n kk s kk=$o(@root@("sid",SAMII,""))
"RTN","SAMICSV",151,0)
 . . . q:kk=""
"RTN","SAMICSV",152,0)
 . . . S OFFSET=OFFSET+1
"RTN","SAMICSV",153,0)
 . . . s $p(@SAMIOUT@(SAMIN),"|",OFFSET)=$g(@root@(kk,"saminame"))
"RTN","SAMICSV",154,0)
 . . . S OFFSET=OFFSET+1
"RTN","SAMICSV",155,0)
 . . . s $p(@SAMIOUT@(SAMIN),"|",OFFSET)=$g(@root@(kk,"ssn"))
"RTN","SAMICSV",156,0)
 . . . S OFFSET=OFFSET+1
"RTN","SAMICSV",157,0)
 . . . s $p(@SAMIOUT@(SAMIN),"|",OFFSET)=$g(@root@(kk,"last5"))
"RTN","SAMICSV",158,0)
 . . . S OFFSET=OFFSET+1
"RTN","SAMICSV",159,0)
 . . . s $p(@SAMIOUT@(SAMIN),"|",OFFSET)=$g(@root@(kk,"sex"))
"RTN","SAMICSV",160,0)
 . . . S OFFSET=OFFSET+1
"RTN","SAMICSV",161,0)
 . . . s $p(@SAMIOUT@(SAMIN),"|",OFFSET)=$g(@root@(kk,"sbdob"))
"RTN","SAMICSV",162,0)
 . . . S OFFSET=OFFSET+1
"RTN","SAMICSV",163,0)
 . . . s $p(@SAMIOUT@(SAMIN),"|",OFFSET)=$g(@root@(kk,"samiru"))
"RTN","SAMICSV",164,0)
 . . f  s jj=$o(DICT(jj)) q:+jj=0  d  ;
"RTN","SAMICSV",165,0)
 . . . ;s $P(@SAMIOUT@(SAMIN),"|",OFFSET+jj)=""""_$g(@groot@(SAMII,SAMIJ,DICT(jj)))_""""
"RTN","SAMICSV",166,0)
 . . . n val
"RTN","SAMICSV",167,0)
 . . . s val=$g(@groot@(SAMII,SAMIJ,DICT(jj)))_""""
"RTN","SAMICSV",168,0)
 . . . s val=$tr(val,$char(11))
"RTN","SAMICSV",169,0)
 . . . s $P(@SAMIOUT@(SAMIN),"|",OFFSET+jj)=""""_val
"RTN","SAMICSV",170,0)
 . . S @SAMIOUT@(SAMIN)=SITEID_"|"_SAMII_"|"_SAMIJ_"|"_@SAMIOUT@(SAMIN)
"RTN","SAMICSV",171,0)
 . . ;s @SAMIOUT@(SAMIN)=@SAMIOUT@(SAMIN)_$C(13,10)
"RTN","SAMICSV",172,0)
 . ;b
"RTN","SAMICSV",173,0)
 ;ZWR @SAMIOUT@(*)
"RTN","SAMICSV",174,0)
 w !,cnt_" patients, "_forms_" forms"
"RTN","SAMICSV",175,0)
 n filename s filename=$$FNAME(SITEID,SAMIFORM)
"RTN","SAMICSV",176,0)
 d GTF^%ZISH($na(@SAMIOUT@(1)),3,SAMIDIR,filename)
"RTN","SAMICSV",177,0)
 w !,"file "_filename_" written to directory "_SAMIDIR
"RTN","SAMICSV",178,0)
 ;
"RTN","SAMICSV",179,0)
 quit  ; end of ONEFORM
"RTN","SAMICSV",180,0)
 ;
"RTN","SAMICSV",181,0)
 ;
"RTN","SAMICSV",182,0)
 ;
"RTN","SAMICSV",183,0)
FNAME(SITE,FORM) ; extrinsic returns the filename for the site/form
"RTN","SAMICSV",184,0)
 ;
"RTN","SAMICSV",185,0)
 quit SITE_"-"_FORM_"-"_$$FMTHL7^XLFDT($$HTFM^XLFDT($H))_".csv" ; end of $$FNAME
"RTN","SAMICSV",186,0)
 ;
"RTN","SAMICSV",187,0)
 ;
"RTN","SAMICSV",188,0)
 ;
"RTN","SAMICSV",189,0)
DDICT(RTN,FORM) ; data dictionary for FORM, returned in RTN, passed by
"RTN","SAMICSV",190,0)
 ; name
"RTN","SAMICSV",191,0)
 ;
"RTN","SAMICSV",192,0)
 K @RTN
"RTN","SAMICSV",193,0)
 ;
"RTN","SAMICSV",194,0)
 N USEGR S USEGR=""
"RTN","SAMICSV",195,0)
 I FORM="siform" S USEGR="form fields - intake"
"RTN","SAMICSV",196,0)
 I FORM="sbform" S USEGR="form fields - background"
"RTN","SAMICSV",197,0)
 I FORM="ceform" S USEGR="form fields - ct evaluation"
"RTN","SAMICSV",198,0)
 I FORM="fuform" S USEGR="form fields - follow up"
"RTN","SAMICSV",199,0)
 I FORM="bxform" S USEGR="form fields - biopsy"
"RTN","SAMICSV",200,0)
 I FORM="itform" S USEGR="form fields - intervention"
"RTN","SAMICSV",201,0)
 I FORM="ptform" S USEGR="form fields - pet evaluation"
"RTN","SAMICSV",202,0)
 ;
"RTN","SAMICSV",203,0)
 Q:USEGR=""
"RTN","SAMICSV",204,0)
 N root s root=$$setroot^%wd(USEGR)
"RTN","SAMICSV",205,0)
 Q:$g(root)=""
"RTN","SAMICSV",206,0)
 N II S II=0
"RTN","SAMICSV",207,0)
 f  s II=$o(@root@("field",II)) q:+II=0  d  ;
"RTN","SAMICSV",208,0)
 . s @RTN@(II)=$g(@root@("field",II,"input",1,"name"))
"RTN","SAMICSV",209,0)
 ;
"RTN","SAMICSV",210,0)
 quit  ; end of DDICT
"RTN","SAMICSV",211,0)
 ;
"RTN","SAMICSV",212,0)
 ;
"RTN","SAMICSV",213,0)
 ;
"RTN","SAMICSV",214,0)
 ;^%wd(17.040801,"B","form fields - background",437)=""
"RTN","SAMICSV",215,0)
 ;^%wd(17.040801,"B","form fields - biopsy",438)=""
"RTN","SAMICSV",216,0)
 ;^%wd(17.040801,"B","form fields - ct evaluation",439)=""
"RTN","SAMICSV",217,0)
 ;^%wd(17.040801,"B","form fields - follow up",440)=""
"RTN","SAMICSV",218,0)
 ;^%wd(17.040801,"B","form fields - follow-up",359)=""
"RTN","SAMICSV",219,0)
 ;^%wd(17.040801,"B","form fields - intake",491)=""
"RTN","SAMICSV",220,0)
 ;^%wd(17.040801,"B","form fields - intervention",442)=""
"RTN","SAMICSV",221,0)
 ;^%wd(17.040801,"B","form fields - pet evaluation",443)=""
"RTN","SAMICSV",222,0)
 ;
"RTN","SAMICSV",223,0)
 ;
"RTN","SAMICSV",224,0)
 ;
"RTN","SAMICSV",225,0)
SAYFORM() ; prompts for the form
"RTN","SAMICSV",226,0)
 ;
"RTN","SAMICSV",227,0)
 N ZI,ZF,DIR
"RTN","SAMICSV",228,0)
 S ZF(1)="siform"
"RTN","SAMICSV",229,0)
 S ZF(2)="sbform"
"RTN","SAMICSV",230,0)
 S ZF(3)="ceform"
"RTN","SAMICSV",231,0)
 S ZF(4)="fuform"
"RTN","SAMICSV",232,0)
 S ZF(5)="bxform"
"RTN","SAMICSV",233,0)
 S ZF(6)="itform"
"RTN","SAMICSV",234,0)
 S ZF(7)="ptform"
"RTN","SAMICSV",235,0)
 K DIR
"RTN","SAMICSV",236,0)
 S DIR(0)="SO^"
"RTN","SAMICSV",237,0)
 F ZI=1:1:7 S DIR(0)=DIR(0)_ZI_":"_ZF(ZI)_";"
"RTN","SAMICSV",238,0)
 S DIR("L")="Select form to extract:"
"RTN","SAMICSV",239,0)
 S DIR("L",1)="1 Intake form (siform)"
"RTN","SAMICSV",240,0)
 S DIR("L",2)="2 Background form (sbform)"
"RTN","SAMICSV",241,0)
 S DIR("L",3)="3 CT Evaluation form (ceform)"
"RTN","SAMICSV",242,0)
 S DIR("L",4)="4 Followup form (fuform)"
"RTN","SAMICSV",243,0)
 S DIR("L",5)="5 Biopsy form (bxform)"
"RTN","SAMICSV",244,0)
 S DIR("L",6)="6 Intervention form (itform)"
"RTN","SAMICSV",245,0)
 S DIR("L",7)="7 Pet Evaluation form (ptform)"
"RTN","SAMICSV",246,0)
 D ^DIR
"RTN","SAMICSV",247,0)
 ;
"RTN","SAMICSV",248,0)
 Q:X="" -1
"RTN","SAMICSV",249,0)
 quit ZF(X) ; end of $$SAYFORM
"RTN","SAMICSV",250,0)
 ;
"RTN","SAMICSV",251,0)
 ;
"RTN","SAMICSV",252,0)
 ;
"RTN","SAMICSV",253,0)
EOR ; end of routine SAMICSV
"RTN","SAMINOT1")
0^1^B443163534
"RTN","SAMINOT1",1,0)
SAMINOT1 ;ven/gpl - text notes ;2021-03-30T17:02Z
"RTN","SAMINOT1",2,0)
 ;;18.0;SAMI;**2,6,8,10,11**;2020-01;Build 4
"RTN","SAMINOT1",3,0)
 ;;1.18.0.11-i11
"RTN","SAMINOT1",4,0)
 ;
"RTN","SAMINOT1",5,0)
 ; SAMINOT1 contains a web service & associated subroutines to produce
"RTN","SAMINOT1",6,0)
 ; VAPALS-ELCAP text notes.
"RTN","SAMINOT1",7,0)
 ;
"RTN","SAMINOT1",8,0)
 quit  ; no entry from top
"RTN","SAMINOT1",9,0)
 ;
"RTN","SAMINOT1",10,0)
 ;
"RTN","SAMINOT1",11,0)
 ;
"RTN","SAMINOT1",12,0)
 ;@section 0 primary development
"RTN","SAMINOT1",13,0)
 ;
"RTN","SAMINOT1",14,0)
 ;
"RTN","SAMINOT1",15,0)
 ;
"RTN","SAMINOT1",16,0)
 ;@routine-credits
"RTN","SAMINOT1",17,0)
 ;@primary-dev George P. Lilly (gpl)
"RTN","SAMINOT1",18,0)
 ; gpl@vistaexpertise.net
"RTN","SAMINOT1",19,0)
 ;@primary-dev-org Vista Expertise Network (ven)
"RTN","SAMINOT1",20,0)
 ; http://vistaexpertise.net
"RTN","SAMINOT1",21,0)
 ;@copyright 2017/2021, gpl, all rights reserved
"RTN","SAMINOT1",22,0)
 ;@license see routine SAMIUL
"RTN","SAMINOT1",23,0)
 ;
"RTN","SAMINOT1",24,0)
 ;@last-updated 2021-03-30T17:02Z
"RTN","SAMINOT1",25,0)
 ;@application Screening Applications Management (SAM)
"RTN","SAMINOT1",26,0)
 ;@module Screening Applications Management - IELCAP (SAMI)
"RTN","SAMINOT1",27,0)
 ;@suite-of-files SAMI Forms (311.101-311.199)
"RTN","SAMINOT1",28,0)
 ;@version 1.18.0.10-i11
"RTN","SAMINOT1",29,0)
 ;@release-date 2020-01
"RTN","SAMINOT1",30,0)
 ;@patch-list **2,6,8,10,11**
"RTN","SAMINOT1",31,0)
 ;
"RTN","SAMINOT1",32,0)
 ;@additional-dev Frederick D. S. Marshall (toad)
"RTN","SAMINOT1",33,0)
 ; toad@vistaexpertise.net
"RTN","SAMINOT1",34,0)
 ;@additional-dev Larry G. Carlson (lgc)
"RTN","SAMINOT1",35,0)
 ; larry.g.carlson@gmail.com
"RTN","SAMINOT1",36,0)
 ;@additional-dev Linda M. R. Yaw (lmry)
"RTN","SAMINOT1",37,0)
 ; linda.yaw@vistaexpertise.net
"RTN","SAMINOT1",38,0)
 ;@additional-dev Alexis R. Carlson (arc)
"RTN","SAMINOT1",39,0)
 ; whatisthehumanspirit@gmail.com
"RTN","SAMINOT1",40,0)
 ;@additional-dev Domenic DiNatale (dom)
"RTN","SAMINOT1",41,0)
 ; domenic.dinatale@paraxialtech.com
"RTN","SAMINOT1",42,0)
 ;
"RTN","SAMINOT1",43,0)
 ;@module-credits
"RTN","SAMINOT1",44,0)
 ;@project VA Partnership to Increase Access to Lung Screening
"RTN","SAMINOT1",45,0)
 ; (VA-PALS)
"RTN","SAMINOT1",46,0)
 ; http://va-pals.org/
"RTN","SAMINOT1",47,0)
 ;@funding 2017/2021, Bristol-Myers Squibb Foundation (bmsf)
"RTN","SAMINOT1",48,0)
 ; https://www.bms.com/about-us/responsibility/bristol-myers-squibb-foundation.html
"RTN","SAMINOT1",49,0)
 ;@partner-org Veterans Affairs Office of Rural health
"RTN","SAMINOT1",50,0)
 ; https://www.ruralhealth.va.gov/
"RTN","SAMINOT1",51,0)
 ;@partner-org International Early Lung Cancer Action Program (I-ELCAP)
"RTN","SAMINOT1",52,0)
 ; http://ielcap.com/
"RTN","SAMINOT1",53,0)
 ;@partner-org Paraxial Technologies (par)
"RTN","SAMINOT1",54,0)
 ; http://paraxialtech.com/
"RTN","SAMINOT1",55,0)
 ;@partner-org Open Source Electronic Health Record Alliance (OSEHRA)
"RTN","SAMINOT1",56,0)
 ; https://www.osehra.org/groups/va-pals-open-source-project-group
"RTN","SAMINOT1",57,0)
 ;
"RTN","SAMINOT1",58,0)
 ;@module-log repo github.com:VA-PALS-ELCAP/SAMI-VAPALS-ELCAP.git
"RTN","SAMINOT1",59,0)
 ; see routine SAMINUL
"RTN","SAMINOT1",60,0)
 ;
"RTN","SAMINOT1",61,0)
 ;
"RTN","SAMINOT1",62,0)
 ;
"RTN","SAMINOT1",63,0)
 ;@section 1 wsi WSNOTE^SAMINOT1 & related subroutines
"RTN","SAMINOT1",64,0)
 ;
"RTN","SAMINOT1",65,0)
 ;
"RTN","SAMINOT1",66,0)
 ;
"RTN","SAMINOT1",67,0)
EXISTCE(SID,FORM) ; extrinsic returns "true" or "false"
"RTN","SAMINOT1",68,0)
 ;
"RTN","SAMINOT1",69,0)
 ; if a Chart Eligibility Note exists
"RTN","SAMINOT1",70,0)
 ;
"RTN","SAMINOT1",71,0)
 n root s root=$$setroot^%wd("vapals-patients")
"RTN","SAMINOT1",72,0)
 n gvals s gvals=$na(@root@("graph",SID,FORM))
"RTN","SAMINOT1",73,0)
 ;i $g(@root@("graph",SID,FORM,"sicechrt"))="y" q "true"
"RTN","SAMINOT1",74,0)
 i $g(@gvals@("chart-eligibility-complete"))="true" q "true"
"RTN","SAMINOT1",75,0)
 ;
"RTN","SAMINOT1",76,0)
 quit "false" ; end of $$EXISTCE
"RTN","SAMINOT1",77,0)
 ;
"RTN","SAMINOT1",78,0)
 ;
"RTN","SAMINOT1",79,0)
 ;
"RTN","SAMINOT1",80,0)
EXISTPRE(SID,FORM) ; extrinsic returns "true" or "false"
"RTN","SAMINOT1",81,0)
 ;
"RTN","SAMINOT1",82,0)
 ; if a Pre-enrollment Note exists
"RTN","SAMINOT1",83,0)
 ;
"RTN","SAMINOT1",84,0)
 n root s root=$$setroot^%wd("vapals-patients")
"RTN","SAMINOT1",85,0)
 n gvals s gvals=$na(@root@("graph",SID,FORM))
"RTN","SAMINOT1",86,0)
 ;i $g(@root@("graph",SID,FORM,"sipedisc"))="y" q "true"
"RTN","SAMINOT1",87,0)
 ;i $g(@gvals@("pre-note-complete"))="true" i $g(@gvals@("siperslt"))="y" q "true"
"RTN","SAMINOT1",88,0)
 i $g(@gvals@("pre-note-complete"))="true" q "true"
"RTN","SAMINOT1",89,0)
 ;
"RTN","SAMINOT1",90,0)
 quit "false" ; end of $$EXISTPRE
"RTN","SAMINOT1",91,0)
 ;
"RTN","SAMINOT1",92,0)
 ;
"RTN","SAMINOT1",93,0)
 ;
"RTN","SAMINOT1",94,0)
EXISTINT(SID,FORM) ; extrinsic returns "true" or "false"
"RTN","SAMINOT1",95,0)
 ;
"RTN","SAMINOT1",96,0)
 ; if an Intake Note exists
"RTN","SAMINOT1",97,0)
 ;
"RTN","SAMINOT1",98,0)
 n root s root=$$setroot^%wd("vapals-patients")
"RTN","SAMINOT1",99,0)
 i $g(@root@("graph",SID,FORM,"sistatus"))="y" q "true"
"RTN","SAMINOT1",100,0)
 ;
"RTN","SAMINOT1",101,0)
 quit "false" ; end of $$EXISTINT
"RTN","SAMINOT1",102,0)
 ;
"RTN","SAMINOT1",103,0)
 ;
"RTN","SAMINOT1",104,0)
 ;
"RTN","SAMINOT1",105,0)
WSNOTE(return,filter) ; web service which returns a text note
"RTN","SAMINOT1",106,0)
 ;
"RTN","SAMINOT1",107,0)
 n debug s debug=0
"RTN","SAMINOT1",108,0)
 i $g(filter("debug"))=1 s debug=1
"RTN","SAMINOT1",109,0)
 ;
"RTN","SAMINOT1",110,0)
 k return
"RTN","SAMINOT1",111,0)
 s HTTPRSP("mime")="text/html"
"RTN","SAMINOT1",112,0)
 ;
"RTN","SAMINOT1",113,0)
 n si
"RTN","SAMINOT1",114,0)
 s si=$g(filter("studyid"))
"RTN","SAMINOT1",115,0)
 i si="" d  ;
"RTN","SAMINOT1",116,0)
 . s si="XXX00333"
"RTN","SAMINOT1",117,0)
 q:si=""
"RTN","SAMINOT1",118,0)
 ;
"RTN","SAMINOT1",119,0)
 n samikey
"RTN","SAMINOT1",120,0)
 s samikey=$g(filter("form"))
"RTN","SAMINOT1",121,0)
 n root s root=$$setroot^%wd("vapals-patients")
"RTN","SAMINOT1",122,0)
 i samikey="" d  ;
"RTN","SAMINOT1",123,0)
 . s samikey=$o(@root@("graph",si,"siform"))
"RTN","SAMINOT1",124,0)
 . ;w !,samikey
"RTN","SAMINOT1",125,0)
 . ;b
"RTN","SAMINOT1",126,0)
 ;
"RTN","SAMINOT1",127,0)
 n vals
"RTN","SAMINOT1",128,0)
 m vals=@root@("graph",si,samikey)
"RTN","SAMINOT1",129,0)
 ;
"RTN","SAMINOT1",130,0)
 n note,nien,ntype
"RTN","SAMINOT1",131,0)
 s ntype=""
"RTN","SAMINOT1",132,0)
 s note=""
"RTN","SAMINOT1",133,0)
 s nien=$g(filter("nien"))
"RTN","SAMINOT1",134,0)
 i nien="" d
"RTN","SAMINOT1",135,0)
 . s:$g(vals("samistatus"))="complete" ntype="intake"
"RTN","SAMINOT1",136,0)
 . s:$g(vals("samistatus"))="chart-eligibility" ntype="eligibility"
"RTN","SAMINOT1",137,0)
 . s:$g(vals("samistatus"))="pre-enrollment-discussion" ntype="pre-note"
"RTN","SAMINOT1",138,0)
 . q:ntype=""
"RTN","SAMINOT1",139,0)
 . ;d nien=$$NTTYPE add code to pull the latest note by type
"RTN","SAMINOT1",140,0)
 q:nien=""
"RTN","SAMINOT1",141,0)
 n notebase
"RTN","SAMINOT1",142,0)
 s notebase=$$NTLOCN(si,samikey,nien) ; global location for the note
"RTN","SAMINOT1",143,0)
 s note=$na(@notebase@("text"))
"RTN","SAMINOT1",144,0)
 i '$d(@note) q
"RTN","SAMINOT1",145,0)
 ;
"RTN","SAMINOT1",146,0)
 new temp,tout
"RTN","SAMINOT1",147,0)
 do GETTMPL^SAMICASE("temp","vapals:note")
"RTN","SAMINOT1",148,0)
 quit:'$data(temp)
"RTN","SAMINOT1",149,0)
 ;
"RTN","SAMINOT1",150,0)
 n cnt s cnt=0
"RTN","SAMINOT1",151,0)
 n zi s zi=""
"RTN","SAMINOT1",152,0)
 ;
"RTN","SAMINOT1",153,0)
 f  s zi=$o(temp(zi)) q:zi=""  d  ;
"RTN","SAMINOT1",154,0)
 . ;
"RTN","SAMINOT1",155,0)
 . n line s line=temp(zi)
"RTN","SAMINOT1",156,0)
 . D LOAD^SAMIFORM(.line,samikey,si,.filter,.vals)
"RTN","SAMINOT1",157,0)
 . s temp(zi)=line
"RTN","SAMINOT1",158,0)
 . ;
"RTN","SAMINOT1",159,0)
 . s cnt=cnt+1
"RTN","SAMINOT1",160,0)
 . s tout(cnt)=temp(zi)
"RTN","SAMINOT1",161,0)
 . ;
"RTN","SAMINOT1",162,0)
 . i temp(zi)["report-text" d  ;
"RTN","SAMINOT1",163,0)
 . . i temp(zi)["#" q  ;
"RTN","SAMINOT1",164,0)
 . . n zj s zj=""
"RTN","SAMINOT1",165,0)
 . . f  s zj=$o(@note@(zj)) q:zj=""  d  ;
"RTN","SAMINOT1",166,0)
 . . . s cnt=cnt+1
"RTN","SAMINOT1",167,0)
 . . . ;s tout(cnt)=@note@(zj)_"<br>"
"RTN","SAMINOT1",168,0)
 . . . s tout(cnt)=@note@(zj)_$char(13,10)
"RTN","SAMINOT1",169,0)
 m return=tout
"RTN","SAMINOT1",170,0)
 ;
"RTN","SAMINOT1",171,0)
 quit  ; end of WSNOTE
"RTN","SAMINOT1",172,0)
 ;
"RTN","SAMINOT1",173,0)
 ;
"RTN","SAMINOT1",174,0)
 ;
"RTN","SAMINOT1",175,0)
NOTE(filter) ; extrnisic which creates a note
"RTN","SAMINOT1",176,0)
 ;
"RTN","SAMINOT1",177,0)
 ; returns 1 if successful, 0 if not
"RTN","SAMINOT1",178,0)
 ;
"RTN","SAMINOT1",179,0)
 ; set up patient values
"RTN","SAMINOT1",180,0)
 ;
"RTN","SAMINOT1",181,0)
 n vals
"RTN","SAMINOT1",182,0)
 ;
"RTN","SAMINOT1",183,0)
 n si
"RTN","SAMINOT1",184,0)
 s si=$g(filter("studyid"))
"RTN","SAMINOT1",185,0)
 i si="" d  ;
"RTN","SAMINOT1",186,0)
 . s si="XXX00333"
"RTN","SAMINOT1",187,0)
 q:si=""
"RTN","SAMINOT1",188,0)
 ;
"RTN","SAMINOT1",189,0)
 n samikey
"RTN","SAMINOT1",190,0)
 s samikey=$g(filter("form"))
"RTN","SAMINOT1",191,0)
 n root s root=$$setroot^%wd("vapals-patients")
"RTN","SAMINOT1",192,0)
 i samikey="" d  ;
"RTN","SAMINOT1",193,0)
 . s samikey=$o(@root@("graph",si,"siform"))
"RTN","SAMINOT1",194,0)
 . ;w !,samikey
"RTN","SAMINOT1",195,0)
 . ;b
"RTN","SAMINOT1",196,0)
 ;
"RTN","SAMINOT1",197,0)
 s vals=$na(@root@("graph",si,samikey))
"RTN","SAMINOT1",198,0)
 ;
"RTN","SAMINOT1",199,0)
 i '$d(@vals) d  q 0 ;
"RTN","SAMINOT1",200,0)
 . ;w !,"error, patient values not found"
"RTN","SAMINOT1",201,0)
 ;zwr @vals@(*)
"RTN","SAMINOT1",202,0)
 ;
"RTN","SAMINOT1",203,0)
 k ^SAMIUL("NOTE")
"RTN","SAMINOT1",204,0)
 m ^SAMIUL("NOTE","vals")=@vals
"RTN","SAMINOT1",205,0)
 m ^SAMIUL("NOTE","filter")=filter
"RTN","SAMINOT1",206,0)
 ;
"RTN","SAMINOT1",207,0)
 n didnote s didnote=0
"RTN","SAMINOT1",208,0)
 ;
"RTN","SAMINOT1",209,0)
 i $g(@vals@("samistatus"))="chart-eligibility" d  ;
"RTN","SAMINOT1",210,0)
 . q:$g(@vals@("chart-eligibility-complete"))="true"
"RTN","SAMINOT1",211,0)
 . d MKEL(si,samikey,vals,.filter) ;
"RTN","SAMINOT1",212,0)
 . s didnote=1
"RTN","SAMINOT1",213,0)
 ;
"RTN","SAMINOT1",214,0)
 i $g(@vals@("samistatus"))="pre-enrollment-discussion" d  ;
"RTN","SAMINOT1",215,0)
 . q:$g(@vals@("pre-note-complete"))="true"
"RTN","SAMINOT1",216,0)
 . d MKPRE(si,samikey,vals,.filter) ;
"RTN","SAMINOT1",217,0)
 . s didnote=1
"RTN","SAMINOT1",218,0)
 ;
"RTN","SAMINOT1",219,0)
 i $g(@vals@("samistatus"))="complete" d  ;
"RTN","SAMINOT1",220,0)
 . q:$$HASINNT(vals)
"RTN","SAMINOT1",221,0)
 . d MKIN(si,samikey,vals,.filter) ;
"RTN","SAMINOT1",222,0)
 . s didnote=1
"RTN","SAMINOT1",223,0)
 ;
"RTN","SAMINOT1",224,0)
 n nien s nien=0
"RTN","SAMINOT1",225,0)
 i didnote=1 s nien=$$NTIEN(si,samikey)
"RTN","SAMINOT1",226,0)
 ;
"RTN","SAMINOT1",227,0)
 quit nien ; end of $$NOTE
"RTN","SAMINOT1",228,0)
 ;
"RTN","SAMINOT1",229,0)
 ;
"RTN","SAMINOT1",230,0)
 ;
"RTN","SAMINOT1",231,0)
HASINNT(vals) ; extrinsic returns 1 if intake note is present
"RTN","SAMINOT1",232,0)
 ;
"RTN","SAMINOT1",233,0)
 ; else returns 0
"RTN","SAMINOT1",234,0)
 ;
"RTN","SAMINOT1",235,0)
 n zzi,zzrtn s (zzi,zzrtn)=0
"RTN","SAMINOT1",236,0)
 q:'$d(@vals)
"RTN","SAMINOT1",237,0)
 f  s zzi=$o(@vals@("notes",zzi)) q:+zzi=0  d  ;
"RTN","SAMINOT1",238,0)
 . i $g(@vals@("notes",zzi,"name"))["Intake" s zzrtn=1
"RTN","SAMINOT1",239,0)
 ;
"RTN","SAMINOT1",240,0)
 quit zzrtn ; end of $$HASINNT
"RTN","SAMINOT1",241,0)
 ;
"RTN","SAMINOT1",242,0)
 ;
"RTN","SAMINOT1",243,0)
 ;
"RTN","SAMINOT1",244,0)
MKEL(sid,form,vals,filter) ;
"RTN","SAMINOT1",245,0)
 ;
"RTN","SAMINOT1",246,0)
 n cnt s cnt=0
"RTN","SAMINOT1",247,0)
 ;n dest s dest=$na(@vals@("eligibility-note"))
"RTN","SAMINOT1",248,0)
 n dest s dest=$$MKNT(vals,"Eligibility Note","eligibility",.filter)
"RTN","SAMINOT1",249,0)
 k @dest
"RTN","SAMINOT1",250,0)
 d OUT("Lung Screening Program Chart Eligibility Note")
"RTN","SAMINOT1",251,0)
 d OUT("")
"RTN","SAMINOT1",252,0)
 d ELNOTE(vals,dest,cnt)
"RTN","SAMINOT1",253,0)
 ;
"RTN","SAMINOT1",254,0)
 quit  ; end of MKEL
"RTN","SAMINOT1",255,0)
 ;
"RTN","SAMINOT1",256,0)
 ;
"RTN","SAMINOT1",257,0)
 ;
"RTN","SAMINOT1",258,0)
MKPRE(sid,form,vals,filter) ;
"RTN","SAMINOT1",259,0)
 ;
"RTN","SAMINOT1",260,0)
 n cnt s cnt=0
"RTN","SAMINOT1",261,0)
 ;n dest s dest=$na(@vals@("pre-note"))
"RTN","SAMINOT1",262,0)
 n dest s dest=$$MKNT(vals,"Pre-enrollment Discussion Note","prenote",.filter)
"RTN","SAMINOT1",263,0)
 k @dest
"RTN","SAMINOT1",264,0)
 i $g(@vals@("chart-eligibility-complete"))'="true" d  ;
"RTN","SAMINOT1",265,0)
 . d OUT("Lung Screening Program Chart Eligibility and Pre-enrollment Discussion Note")
"RTN","SAMINOT1",266,0)
 . d OUT("")
"RTN","SAMINOT1",267,0)
 . d ELNOTE(vals,dest,cnt)
"RTN","SAMINOT1",268,0)
 i $g(@vals@("chart-eligibility-complete"))="true" d  ;
"RTN","SAMINOT1",269,0)
 . d OUT("Lung Screening Program Pre-enrollment Discussion Note")
"RTN","SAMINOT1",270,0)
 . d OUT("")
"RTN","SAMINOT1",271,0)
 d PRENOTE(vals,dest,cnt)
"RTN","SAMINOT1",272,0)
 ;
"RTN","SAMINOT1",273,0)
 quit  ; end of MKPRE
"RTN","SAMINOT1",274,0)
 ;
"RTN","SAMINOT1",275,0)
 ;
"RTN","SAMINOT1",276,0)
 ;
"RTN","SAMINOT1",277,0)
MKIN(sid,form,vals,filter) ;
"RTN","SAMINOT1",278,0)
 ;
"RTN","SAMINOT1",279,0)
 n cnt s cnt=0
"RTN","SAMINOT1",280,0)
 ;n dest s dest=$na(@vals@("intake-note"))
"RTN","SAMINOT1",281,0)
 n dest s dest=$$MKNT(vals,"Intake Note","intake",.filter)
"RTN","SAMINOT1",282,0)
 k @dest
"RTN","SAMINOT1",283,0)
 d OUT("Lung Screening Program Intake Note")
"RTN","SAMINOT1",284,0)
 d OUT("")
"RTN","SAMINOT1",285,0)
 i $g(@vals@("chart-eligibility-complete"))'="true" d  ;
"RTN","SAMINOT1",286,0)
 . d ELNOTE(vals,dest,cnt)
"RTN","SAMINOT1",287,0)
 i $g(@vals@("pre-note-complete"))'="true" d  ;
"RTN","SAMINOT1",288,0)
 . d PRENOTE(vals,dest,cnt)
"RTN","SAMINOT1",289,0)
 d INNOTE(vals,dest,cnt)
"RTN","SAMINOT1",290,0)
 ;
"RTN","SAMINOT1",291,0)
 quit  ; end of MKIN
"RTN","SAMINOT1",292,0)
 ;
"RTN","SAMINOT1",293,0)
 ;
"RTN","SAMINOT1",294,0)
 ;
"RTN","SAMINOT1",295,0)
MKNT(vals,title,ntype,filter) ; extrinsic makes a note date=now returns 
"RTN","SAMINOT1",296,0)
 ;
"RTN","SAMINOT1",297,0)
 ; global addr. filter must be passed by reference
"RTN","SAMINOT1",298,0)
 ;
"RTN","SAMINOT1",299,0)
 n ntdt s ntdt=$$NTDTTM($$NOW^XLFDT)
"RTN","SAMINOT1",300,0)
 n ntptr
"RTN","SAMINOT1",301,0)
 s ntptr=$$MKNTLOC(vals,title,ntdt,$g(ntype),.filter)
"RTN","SAMINOT1",302,0)
 ;
"RTN","SAMINOT1",303,0)
 quit ntptr ; end of $$MKNT
"RTN","SAMINOT1",304,0)
 ;
"RTN","SAMINOT1",305,0)
 ;
"RTN","SAMINOT1",306,0)
 ;
"RTN","SAMINOT1",307,0)
MKNTLOC(vals,title,ndate,ntype,filter) ; extrinsic returns the 
"RTN","SAMINOT1",308,0)
 ;
"RTN","SAMINOT1",309,0)
 ;location for the note
"RTN","SAMINOT1",310,0)
 ;
"RTN","SAMINOT1",311,0)
 n nien
"RTN","SAMINOT1",312,0)
 s nien=$o(@vals@("notes",""),-1)+1
"RTN","SAMINOT1",313,0)
 s filter("nien")=nien
"RTN","SAMINOT1",314,0)
 n nloc s nloc=$na(@vals@("notes",nien))
"RTN","SAMINOT1",315,0)
 s @nloc@("name")=title_" "_$g(ndate)
"RTN","SAMINOT1",316,0)
 s @nloc@("date")=$g(ndate)
"RTN","SAMINOT1",317,0)
 s @nloc@("type")=$g(ntype)
"RTN","SAMINOT1",318,0)
 ;
"RTN","SAMINOT1",319,0)
 quit $name(@nloc@("text")) ; end of $$MKNTLOC
"RTN","SAMINOT1",320,0)
 ;
"RTN","SAMINOT1",321,0)
 ;
"RTN","SAMINOT1",322,0)
 ;
"RTN","SAMINOT1",323,0)
NTDTTM(ZFMDT) ; extrinsic returns the date and time in Note format
"RTN","SAMINOT1",324,0)
 ;
"RTN","SAMINOT1",325,0)
 ; ZFMDT is the fileman date/time to translate
"RTN","SAMINOT1",326,0)
 ;
"RTN","SAMINOT1",327,0)
 quit $$FMTE^XLFDT(ZFMDT,"5") ; end of $$NTDTTM
"RTN","SAMINOT1",328,0)
 ;
"RTN","SAMINOT1",329,0)
 ;
"RTN","SAMINOT1",330,0)
 ;
"RTN","SAMINOT1",331,0)
NTLOCN(sid,form,nien) ; extrinsic returns the location of the Nth note
"RTN","SAMINOT1",332,0)
 ;
"RTN","SAMINOT1",333,0)
 n root s root=$$setroot^%wd("vapals-patients")
"RTN","SAMINOT1",334,0)
 ;
"RTN","SAMINOT1",335,0)
 quit $name(@root@("graph",sid,form,"notes",nien)) ; end of $$NTLOCN
"RTN","SAMINOT1",336,0)
 ;
"RTN","SAMINOT1",337,0)
 ;
"RTN","SAMINOT1",338,0)
 ;
"RTN","SAMINOT1",339,0)
NTLAST(sid,form,ntype) ; extrinsic returns the location of the latest note
"RTN","SAMINOT1",340,0)
 ;
"RTN","SAMINOT1",341,0)
 ; of the type ntype
"RTN","SAMINOT1",342,0)
 ;
"RTN","SAMINOT1",343,0)
 quit  ; end of NTLAST
"RTN","SAMINOT1",344,0)
 ;
"RTN","SAMINOT1",345,0)
 ;
"RTN","SAMINOT1",346,0)
 ;
"RTN","SAMINOT1",347,0)
NTIEN(sid,form) ; extrinsic which returns the latest note for this form
"RTN","SAMINOT1",348,0)
 ;
"RTN","SAMINOT1",349,0)
 n root s root=$$setroot^%wd("vapals-patients")
"RTN","SAMINOT1",350,0)
 n rtn s rtn=$o(@root@("graph",sid,form,"notes"," "),-1)
"RTN","SAMINOT1",351,0)
 ;
"RTN","SAMINOT1",352,0)
 quit rtn ; end of $$NTIEN
"RTN","SAMINOT1",353,0)
 ;
"RTN","SAMINOT1",354,0)
 ;
"RTN","SAMINOT1",355,0)
 ;
"RTN","SAMINOT1",356,0)
NTLIST(nlist,sid,form) ; returns the note list in nlist, passed by ref
"RTN","SAMINOT1",357,0)
 ;
"RTN","SAMINOT1",358,0)
 n zn,root,gn
"RTN","SAMINOT1",359,0)
 s root=$$setroot^%wd("vapals-patients")
"RTN","SAMINOT1",360,0)
 s zn=0
"RTN","SAMINOT1",361,0)
 s gn=$na(@root@("graph",sid,form,"notes"))
"RTN","SAMINOT1",362,0)
 q:'$d(@gn)
"RTN","SAMINOT1",363,0)
 f  s zn=$o(@gn@(zn)) q:+zn=0  d  ;
"RTN","SAMINOT1",364,0)
 . s @nlist@(zn,"name")=@gn@(zn,"name")
"RTN","SAMINOT1",365,0)
 . s @nlist@(zn,"nien")=zn
"RTN","SAMINOT1",366,0)
 ;
"RTN","SAMINOT1",367,0)
 quit  ; end of NTLIST
"RTN","SAMINOT1",368,0)
 ;
"RTN","SAMINOT1",369,0)
 ;
"RTN","SAMINOT1",370,0)
 ;
"RTN","SAMINOT1",371,0)
TLST ;
"RTN","SAMINOT1",372,0)
 ;
"RTN","SAMINOT1",373,0)
 set SID="XXX00677"
"RTN","SAMINOT1",374,0)
 set FORM="siform-2019-04-23"
"RTN","SAMINOT1",375,0)
 do NTLIST("G",SID,FORM)
"RTN","SAMINOT1",376,0)
 ;ZWR G
"RTN","SAMINOT1",377,0)
 ;
"RTN","SAMINOT1",378,0)
 quit  ; end of TLST
"RTN","SAMINOT1",379,0)
 ;
"RTN","SAMINOT1",380,0)
 ;
"RTN","SAMINOT1",381,0)
 ;
"RTN","SAMINOT1",382,0)
ELNOTE(vals,dest,cnt) ; eligibility NOTE TEXT
"RTN","SAMINOT1",383,0)
 ;
"RTN","SAMINOT1",384,0)
 D OUT("")
"RTN","SAMINOT1",385,0)
 D OUT("Date of chart review: "_$$XVAL("sidc",vals))
"RTN","SAMINOT1",386,0)
 D GLOUT("The participant was identified as a potential lung screening candidate by: ")
"RTN","SAMINOT1",387,0)
 D GLOUT($$XVAL("siceiden",vals),4)
"RTN","SAMINOT1",388,0)
 if $$XVAL("siceiden",vals)="referral" d  ;
"RTN","SAMINOT1",389,0)
 . D OUT("Date of Referral: "_$$XVAL("sicerfdt",vals))
"RTN","SAMINOT1",390,0)
 . n spec s spec=""
"RTN","SAMINOT1",391,0)
 . s:$$XVAL("sicerfpc",vals)="y" spec=spec_" Primary Care"
"RTN","SAMINOT1",392,0)
 . s:$$XVAL("sicerfwh",vals)="y" spec=spec_" Women's Health"
"RTN","SAMINOT1",393,0)
 . s:$$XVAL("sicerfge",vals)="y" spec=spec_" Geriatrics"
"RTN","SAMINOT1",394,0)
 . s:$$XVAL("sicerfpu",vals)="y" spec=spec_" Pulmonology"
"RTN","SAMINOT1",395,0)
 . s:$$XVAL("sicerfon",vals)="y" spec=spec_" Oncology"
"RTN","SAMINOT1",396,0)
 . s:$$XVAL("sicerfsc",vals)="y" spec=spec_" Smoking Cessation"
"RTN","SAMINOT1",397,0)
 . s:$$XVAL("sicerfot",vals)="y" spec=spec_" "_$$XVAL("sicerfoo",vals)
"RTN","SAMINOT1",398,0)
 . D GLOUT("Specialty of referring provider: ")
"RTN","SAMINOT1",399,0)
 . D GLOUT(spec,4)
"RTN","SAMINOT1",400,0)
 n elig
"RTN","SAMINOT1",401,0)
 s elig=$$XVAL("sicechrt",vals)
"RTN","SAMINOT1",402,0)
 D OUT("The participant is eligible based on chart review: "_$s(elig="y":"Yes",1:"no"))
"RTN","SAMINOT1",403,0)
 D OUT("")
"RTN","SAMINOT1",404,0)
 s @vals@("chart-eligibility-complete")="true"
"RTN","SAMINOT1",405,0)
 ;
"RTN","SAMINOT1",406,0)
 quit  ; end of ELNOTE
"RTN","SAMINOT1",407,0)
 ;
"RTN","SAMINOT1",408,0)
 ;
"RTN","SAMINOT1",409,0)
 ;
"RTN","SAMINOT1",410,0)
PRENOTE(vals,dest,cnt) ;
"RTN","SAMINOT1",411,0)
 ;
"RTN","SAMINOT1",412,0)
 i $g(@vals@("sipedisc"))'="y" q  ; no prelim discussion
"RTN","SAMINOT1",413,0)
 D OUT("")
"RTN","SAMINOT1",414,0)
 ;d OUT("A pre-enrollment discussion was held.")
"RTN","SAMINOT1",415,0)
 ;[If Yes is selected then add the following 5 lines]
"RTN","SAMINOT1",416,0)
 D OUT("The program attempted to reach the Veteran to discuss lung screening.")
"RTN","SAMINOT1",417,0)
 D OUT("Date of pre-enrollment discussion: "_$$XVAL("sipedc",vals))
"RTN","SAMINOT1",418,0)
 n via s via=""
"RTN","SAMINOT1",419,0)
 s:$$XVAL("sipecnip",vals)="1" via=via_" In person"
"RTN","SAMINOT1",420,0)
 s:$$XVAL("sipecnte",vals)="1" via=via_" Telephone"
"RTN","SAMINOT1",421,0)
 s:$$XVAL("sipecnth",vals)="1" via=via_" TeleHealth"
"RTN","SAMINOT1",422,0)
 s:$$XVAL("sipecnml",vals)="1" via=via_" Mailed Letter"
"RTN","SAMINOT1",423,0)
 s:$$XVAL("sipecnpp",vals)="1" via=via_" Message in patient portal"
"RTN","SAMINOT1",424,0)
 s:$$XVAL("sipecnvd",vals)="1" via=via_" Video-on-Demand (VOD)"
"RTN","SAMINOT1",425,0)
 s:$$XVAL("sipecnot",vals)="1" via=via_" "_$$XVAL("sipecnoo",vals)
"RTN","SAMINOT1",426,0)
 ;D OUT("The lung screening program reached the potential candidate or was contacted via:"_via)
"RTN","SAMINOT1",427,0)
 D GLOUT("The lung screening program reached the potential candidate or was contacted via:")
"RTN","SAMINOT1",428,0)
 D GLOUT(via,4)
"RTN","SAMINOT1",429,0)
 ;D OUT("The pre-enrollment discussion with the participant resulted in: "_$$SUBRSLT($$XVAL("siperslt",vals)))
"RTN","SAMINOT1",430,0)
 D OUT("The pre-enrollment discussion with the participant resulted in: ")
"RTN","SAMINOT1",431,0)
 D GLOUT($$SUBRSLT($$XVAL("siperslt",vals)),4)
"RTN","SAMINOT1",432,0)
 D OUT("Comments: ")
"RTN","SAMINOT1",433,0)
 D GLOUT($$XVAL("sipecmnt",vals),4)
"RTN","SAMINOT1",434,0)
 ;
"RTN","SAMINOT1",435,0)
 s @vals@("pre-note-complete")="true"
"RTN","SAMINOT1",436,0)
 ;
"RTN","SAMINOT1",437,0)
 quit  ; end of PRENOTE
"RTN","SAMINOT1",438,0)
 ;
"RTN","SAMINOT1",439,0)
 ;
"RTN","SAMINOT1",440,0)
 ;
"RTN","SAMINOT1",441,0)
SUBRSLT(XVAL) ; translation of discussion result
"RTN","SAMINOT1",442,0)
 ;
"RTN","SAMINOT1",443,0)
 q:XVAL="y" "Participant is interested in discussing lung screening. The program will proceed with enrollment process."
"RTN","SAMINOT1",444,0)
 q:XVAL="u" "Participant is unsure of lung screening. Ok to contact in the future."
"RTN","SAMINOT1",445,0)
 q:XVAL="nn" "Participant is not interested in discussing lung screening at this time. Ok to contact in the future."
"RTN","SAMINOT1",446,0)
 q:XVAL="nf" "Participant is not interested in discussing lung screening in the future."
"RTN","SAMINOT1",447,0)
 q:XVAL="na" "Unable to reach participant at this time"
"RTN","SAMINOT1",448,0)
 ;
"RTN","SAMINOT1",449,0)
 quit "" ; end of $$SUBRSLT
"RTN","SAMINOT1",450,0)
 ;
"RTN","SAMINOT1",451,0)
 ;
"RTN","SAMINOT1",452,0)
 ;
"RTN","SAMINOT1",453,0)
INNOTE(vals,dest,cnt) ;
"RTN","SAMINOT1",454,0)
 ;
"RTN","SAMINOT1",455,0)
 ;Lung Screening Program Intake Note
"RTN","SAMINOT1",456,0)
 ;
"RTN","SAMINOT1",457,0)
 ;Date of intake discussion contact:       [Date]
"RTN","SAMINOT1",458,0)
 ;How did you learn about the Lung Screening Program?:  [Selection]
"RTN","SAMINOT1",459,0)
 ;Primary address verified:                 [Yes/No]
"RTN","SAMINOT1",460,0)
 ;Rural status:                                        [Urban/Rural/Unknown]
"RTN","SAMINOT1",461,0)
 ;Preferred address and contact number:
"RTN","SAMINOT1",462,0)
 ;     [Address 1]
"RTN","SAMINOT1",463,0)
 ;           [Address 2]
"RTN","SAMINOT1",464,0)
 ;              [Address]
"RTN","SAMINOT1",465,0)
 ;
"RTN","SAMINOT1",466,0)
 ;Ever smoked?:            [Ever Smoked Text]
"RTN","SAMINOT1",467,0)
 ;Smoking Status:          [Never Smoked/Past/Current/Willing to Quit]
"RTN","SAMINOT1",468,0)
 ;CIGs per day:               [Input Number]
"RTN","SAMINOT1",469,0)
 ;PPD:                              [Computed Number]
"RTN","SAMINOT1",470,0)
 ;# of years:                    [Input Number]
"RTN","SAMINOT1",471,0)
 ;Pack Years:                   [Computed Number]
"RTN","SAMINOT1",472,0)
 ;
"RTN","SAMINOT1",473,0)
 ;[If a Quit Date is entered add the following line]
"RTN","SAMINOT1",474,0)
 ;Quit smoking on:         [Date]
"RTN","SAMINOT1",475,0)
 ;
"RTN","SAMINOT1",476,0)
 ;[If Smoking Cessation education text is entered add the following line]
"RTN","SAMINOT1",477,0)
 ;Smoking cessation education provided: [Show Input Text]
"RTN","SAMINOT1",478,0)
 ;
"RTN","SAMINOT1",479,0)
 ;[If a Lung Cancer Dx date is entered show the following 1 to 2 lines]
"RTN","SAMINOT1",480,0)
 ;Prior lung cancer diagnosis date: [Date]
"RTN","SAMINOT1",481,0)
 ;[If a location not in the VA is specified show the next line]
"RTN","SAMINOT1",482,0)
 ;Location where prior lung cancer diagnosis was made: [Location Text]
"RTN","SAMINOT1",483,0)
 ;
"RTN","SAMINOT1",484,0)
 ;[If Any Prior CT Date is entered show the following 1 to 2 lines]
"RTN","SAMINOT1",485,0)
 ;Prior CT:                   [Date]
"RTN","SAMINOT1",486,0)
 ;[If a location not in the VA is specified show the next line]
"RTN","SAMINOT1",487,0)
 ;Location where prior lung cancer diagnosis was made: [Location Text]
"RTN","SAMINOT1",488,0)
 ;
"RTN","SAMINOT1",489,0)
 ;Shared Decision Making:
"RTN","SAMINOT1",490,0)
 ;
"RTN","SAMINOT1",491,0)
 d OUT(" ")
"RTN","SAMINOT1",492,0)
 d OUT("   "_"Date of intake discussion contact: "_$$XVAL("sidc",vals))
"RTN","SAMINOT1",493,0)
 n learn s learn=""
"RTN","SAMINOT1",494,0)
 s:$$XVAL("silnip",vals) learn=learn_" In person"
"RTN","SAMINOT1",495,0)
 s:$$XVAL("silnph",vals) learn=learn_" Telephone"
"RTN","SAMINOT1",496,0)
 s:$$XVAL("silnth",vals) learn=learn_" TeleHealth"
"RTN","SAMINOT1",497,0)
 s:$$XVAL("silnml",vals) learn=learn_" Mailed letter"
"RTN","SAMINOT1",498,0)
 s:$$XVAL("silnpp",vals) learn=learn_" Message in patient portal"
"RTN","SAMINOT1",499,0)
 s:$$XVAL("silnvd",vals) learn=learn_" Video-on-Demand (VOD)"
"RTN","SAMINOT1",500,0)
 s:$$XVAL("silnot",vals) learn=learn_" "_$$XVAL("silnoo",vals)
"RTN","SAMINOT1",501,0)
 ;d GLOUT("   "_"How did you learn about the Lung Screening Program?: "_learn,4)
"RTN","SAMINOT1",502,0)
 d GLOUT("How did you learn about the Lung Screening Program?: ",4)
"RTN","SAMINOT1",503,0)
 d GLOUT(learn,6)
"RTN","SAMINOT1",504,0)
 n verified s verified=""
"RTN","SAMINOT1",505,0)
 s:$$XVAL("sipav",vals)="y" verified="Yes"
"RTN","SAMINOT1",506,0)
 s:$$XVAL("sipav",vals)="n" verified="No"
"RTN","SAMINOT1",507,0)
 d OUT("   "_"Primary address verified: "_verified)
"RTN","SAMINOT1",508,0)
 n rural s rural=""
"RTN","SAMINOT1",509,0)
 s:$$XVAL("sirs",vals)="r" rural="rural"
"RTN","SAMINOT1",510,0)
 s:$$XVAL("sirs",vals)="u" rural="urban"
"RTN","SAMINOT1",511,0)
 d OUT("   "_""_"Rural status: "_rural)
"RTN","SAMINOT1",512,0)
 d OUT("   "_"Preferred address and contact number: ")
"RTN","SAMINOT1",513,0)
 n pa s pa=""
"RTN","SAMINOT1",514,0)
 i $$XVAL("sipsa",vals)'="" d  ;
"RTN","SAMINOT1",515,0)
 . d OUT("      "_$$XVAL("sipsa",vals))
"RTN","SAMINOT1",516,0)
 . n csz s csz=""
"RTN","SAMINOT1",517,0)
 . s:$$XVAL("sipc",vals)'="" csz=$$XVAL("sipc",vals)
"RTN","SAMINOT1",518,0)
 . s:$$XVAL("sips",vals)'="" csz=csz_", "_$$XVAL("sips",vals)
"RTN","SAMINOT1",519,0)
 . s:$$XVAL("sipz",vals)'="" csz=csz_" "_$$XVAL("sipz",vals)
"RTN","SAMINOT1",520,0)
 . d OUT("      "_csz)
"RTN","SAMINOT1",521,0)
 d:$$XVAL("sippn",vals)'="" OUT("      "_$$XVAL("sippn",vals))
"RTN","SAMINOT1",522,0)
 d OUT("   "_"Ever smoked?: ")
"RTN","SAMINOT1",523,0)
 d GLOUT($$XVAL("sies",vals),6)
"RTN","SAMINOT1",524,0)
 n sstatus s sstatus=""
"RTN","SAMINOT1",525,0)
 s:$$XVAL("siesm",vals)="n" sstatus=sstatus_" Never smoked"
"RTN","SAMINOT1",526,0)
 s:$$XVAL("siesm",vals)="p" sstatus=sstatus_" Past"
"RTN","SAMINOT1",527,0)
 s:$$XVAL("siesm",vals)="c" sstatus=sstatus_" Current"
"RTN","SAMINOT1",528,0)
 s:$$XVAL("siesq",vals)=1 sstatus=sstatus_" Willing to quit"
"RTN","SAMINOT1",529,0)
 d OUT("   Smoking Status: "_sstatus)
"RTN","SAMINOT1",530,0)
 d OUT("   "_"CIGs per day: ")
"RTN","SAMINOT1",531,0)
 d OUT("      "_$$XVAL("sicpd",vals))
"RTN","SAMINOT1",532,0)
 d OUT("   "_"PPD: ")
"RTN","SAMINOT1",533,0)
 d OUT("      "_$$XVAL("sippd",vals))
"RTN","SAMINOT1",534,0)
 d OUT("   "_"# of years: ")
"RTN","SAMINOT1",535,0)
 d OUT("      "_$$XVAL("sisny",vals))
"RTN","SAMINOT1",536,0)
 d OUT("   "_"PPY: ")
"RTN","SAMINOT1",537,0)
 d OUT("      "_$$XVAL("sippy",vals))
"RTN","SAMINOT1",538,0)
 d OUT("")
"RTN","SAMINOT1",539,0)
 i $$XVAL("siq",vals)'="" d  ;
"RTN","SAMINOT1",540,0)
 . d OUT("Quit smoking on: "_$$XVAL("siq",vals))
"RTN","SAMINOT1",541,0)
 . d OUT("")
"RTN","SAMINOT1",542,0)
 i $$XVAL("sicep",vals)'="" d  ;
"RTN","SAMINOT1",543,0)
 . d OUT("Smoking cessation education provided:")
"RTN","SAMINOT1",544,0)
 . d GLOUT("    "_$$XVAL("sicep",vals),4)
"RTN","SAMINOT1",545,0)
 i $$XVAL("sicadx",vals)'="" d
"RTN","SAMINOT1",546,0)
 . d OUT("Prior lung cancer diagnosis date: "_$$XVAL("sicadx",vals))
"RTN","SAMINOT1",547,0)
 . i $$XVAL("sicadxl",vals)'="" d  ;
"RTN","SAMINOT1",548,0)
 . . d OUT("Location where prior lung cancer diagnosis was made:")
"RTN","SAMINOT1",549,0)
 . . d GLOUT("    "_$$XVAL("sicadxl",vals),4)
"RTN","SAMINOT1",550,0)
 i $$XVAL("siptct",vals)'="" d
"RTN","SAMINOT1",551,0)
 . d OUT("Prior CT: "_$$XVAL("siptct",vals))
"RTN","SAMINOT1",552,0)
 . i $$XVAL("siptctl",vals)'="" d  ;
"RTN","SAMINOT1",553,0)
 . . d OUT("Location where prior CT was made:")
"RTN","SAMINOT1",554,0)
 . . d GLOUT("    "_$$XVAL("siptctl",vals),4)
"RTN","SAMINOT1",555,0)
 d OUT(" ")
"RTN","SAMINOT1",556,0)
 d OUT("Shared Decision Making: ")
"RTN","SAMINOT1",557,0)
 d OUT(" ")
"RTN","SAMINOT1",558,0)
 n shareddm
"RTN","SAMINOT1",559,0)
 s shareddm=+$$XVAL("siidmdc",vals)
"RTN","SAMINOT1",560,0)
 i shareddm=1 d SDM(dest)
"RTN","SAMINOT1",561,0)
 e  d OUT("Shared decision making was not applicable")
"RTN","SAMINOT1",562,0)
 d OUT(" ")
"RTN","SAMINOT1",563,0)
 n ldct s ldct=""
"RTN","SAMINOT1",564,0)
 s:$$XVAL("sildct",vals)="n" ldct="No"
"RTN","SAMINOT1",565,0)
 s:$$XVAL("sildct",vals)="l" ldct="No"
"RTN","SAMINOT1",566,0)
 s:$$XVAL("sildct",vals)="y" ldct="Yes"
"RTN","SAMINOT1",567,0)
 d GLOUT("The veteran has decided to enroll in the Lung Screening Program: "_ldct)
"RTN","SAMINOT1",568,0)
 i $$XVAL("sildct",vals)="l" d  ;
"RTN","SAMINOT1",569,0)
 . d GLOUT("The veteran has indicated it is okay to contact in the future to discuss enrolling in the Lung Screening Program.",4)
"RTN","SAMINOT1",570,0)
 i ldct="Yes" d  ;
"RTN","SAMINOT1",571,0)
 . d OUT("LDCT ordered: "_ldct)
"RTN","SAMINOT1",572,0)
 . d OUT("    "_"Veteran enrolled in the LSS program. Results and coordination of care ")
"RTN","SAMINOT1",573,0)
 . d OUT("    "_"will be made by the LSS team.  ")
"RTN","SAMINOT1",574,0)
 . i $$XVAL("siclin",vals)'="" d  ;
"RTN","SAMINOT1",575,0)
 n tmpclin s tmpclin=$$XVAL("siclin",vals)
"RTN","SAMINOT1",576,0)
 i tmpclin'="" d  ;
"RTN","SAMINOT1",577,0)
 . d OUT("Clinical Indications for Initial Screening CT:")
"RTN","SAMINOT1",578,0)
 . d GLOUT("    "_tmpclin,4)
"RTN","SAMINOT1",579,0)
 ;
"RTN","SAMINOT1",580,0)
 ;The veteran has decided to enroll in the Lung Screening Program: [Yes/No]
"RTN","SAMINOT1",581,0)
 ;
"RTN","SAMINOT1",582,0)
 ;[If Not enroll at this time but okay to contact in the future, add the following line]
"RTN","SAMINOT1",583,0)
 ;The veteran has indicated it is okay to contact in the future to discuss enrolling in the Lung Screening Program.
"RTN","SAMINOT1",584,0)
 ;
"RTN","SAMINOT1",585,0)
 ;[If Yes is answered for enrollment add the following two lines]
"RTN","SAMINOT1",586,0)
 ;LDCT ordered:                Yes
"RTN","SAMINOT1",587,0)
 ;Veteran enrolled in the Lung Screening Program. Results and coordination of care will be made by the Lung Screening Program team.
"RTN","SAMINOT1",588,0)
 ;
"RTN","SAMINOT1",589,0)
 ;[If Clinical Indication text is provided add them to the note]
"RTN","SAMINOT1",590,0)
 ;Clinical Indications:          [Show Input Text]
"RTN","SAMINOT1",591,0)
 ;
"RTN","SAMINOT1",592,0)
 ;
"RTN","SAMINOT1",593,0)
 quit  ; end of INNOTE
"RTN","SAMINOT1",594,0)
 ;
"RTN","SAMINOT1",595,0)
 ;
"RTN","SAMINOT1",596,0)
 ;
"RTN","SAMINOT1",597,0)
SDM(ary) ; adds Shared Decision Making text to array ary, passed by name
"RTN","SAMINOT1",598,0)
 ;
"RTN","SAMINOT1",599,0)
 n ii s ii=$o(@ary@(" "),-1)
"RTN","SAMINOT1",600,0)
 s ii=ii+1
"RTN","SAMINOT1",601,0)
 s @ary@(ii)="Veteran of age and exposure to cigarette smoke as described above, and "
"RTN","SAMINOT1",602,0)
 s ii=ii+1
"RTN","SAMINOT1",603,0)
 s @ary@(ii)="without a current diagnosis or obvious symptoms suggestive of lung cancer, "
"RTN","SAMINOT1",604,0)
 s ii=ii+1
"RTN","SAMINOT1",605,0)
 s @ary@(ii)="has been educated today about the estimated risk for lung cancer, the "
"RTN","SAMINOT1",606,0)
 s ii=ii+1
"RTN","SAMINOT1",607,0)
 s @ary@(ii)="possibility of cure or life prolonging if an early lung cancer were to be "
"RTN","SAMINOT1",608,0)
 s ii=ii+1
"RTN","SAMINOT1",609,0)
 s @ary@(ii)="found during screening, the possibility of imaging abnormalities not being "
"RTN","SAMINOT1",610,0)
 s ii=ii+1
"RTN","SAMINOT1",611,0)
 s @ary@(ii)="lung cancer, the possibility of complications from additional diagnostic "
"RTN","SAMINOT1",612,0)
 s ii=ii+1
"RTN","SAMINOT1",613,0)
 s @ary@(ii)="procedures, and the approximate amount of radiation exposure associated "
"RTN","SAMINOT1",614,0)
 s ii=ii+1
"RTN","SAMINOT1",615,0)
 s @ary@(ii)="with each screening procedure. In addition, the Veteran has been educated "
"RTN","SAMINOT1",616,0)
 s ii=ii+1
"RTN","SAMINOT1",617,0)
 s @ary@(ii)="today about the importance of adhering to annual lung screening, the "
"RTN","SAMINOT1",618,0)
 s ii=ii+1
"RTN","SAMINOT1",619,0)
 s @ary@(ii)="possible impact of other medical conditions on the overall health status, "
"RTN","SAMINOT1",620,0)
 s ii=ii+1
"RTN","SAMINOT1",621,0)
 s @ary@(ii)="the importance of avoiding exposure to cigarette smoke, available tobacco "
"RTN","SAMINOT1",622,0)
 s ii=ii+1
"RTN","SAMINOT1",623,0)
 s @ary@(ii)="cessation programs and available lung screening services at this site. "
"RTN","SAMINOT1",624,0)
 s ii=ii+1
"RTN","SAMINOT1",625,0)
 s @ary@(ii)="Education material was provided to the veteran. "
"RTN","SAMINOT1",626,0)
 s ii=ii+1
"RTN","SAMINOT1",627,0)
 ;s @ary@(ii)="Based on this information, the Veteran has opted for "
"RTN","SAMINOT1",628,0)
 ;
"RTN","SAMINOT1",629,0)
 quit  ; end of SDM
"RTN","SAMINOT1",630,0)
 ;
"RTN","SAMINOT1",631,0)
 ;
"RTN","SAMINOT1",632,0)
 ;
"RTN","SAMINOT1",633,0)
GLOUT(ln,indent) ; glob out first wrap ln then put it in dest
"RTN","SAMINOT1",634,0)
 ;
"RTN","SAMINOT1",635,0)
 n arytmp
"RTN","SAMINOT1",636,0)
 s arytmp(1)=ln
"RTN","SAMINOT1",637,0)
 i $g(indent)="" s indent=1
"RTN","SAMINOT1",638,0)
 d wrap^%tt("arytmp",indent_":80")
"RTN","SAMINOT1",639,0)
 n ii s ii=""
"RTN","SAMINOT1",640,0)
 f  s ii=$o(arytmp(ii)) q:ii=""  d  ;
"RTN","SAMINOT1",641,0)
 . d OUT(arytmp(ii))
"RTN","SAMINOT1",642,0)
 ;
"RTN","SAMINOT1",643,0)
 quit  ; end of GLOUT
"RTN","SAMINOT1",644,0)
 ;
"RTN","SAMINOT1",645,0)
 ;
"RTN","SAMINOT1",646,0)
 ;
"RTN","SAMINOT1",647,0)
OUT(ln) ;
"RTN","SAMINOT1",648,0)
 ;
"RTN","SAMINOT1",649,0)
 s cnt=cnt+1
"RTN","SAMINOT1",650,0)
 n lnn
"RTN","SAMINOT1",651,0)
 ;s debug=1
"RTN","SAMINOT1",652,0)
 s lnn=$o(@dest@(" "),-1)+1
"RTN","SAMINOT1",653,0)
 s @dest@(lnn)=ln
"RTN","SAMINOT1",654,0)
 ;
"RTN","SAMINOT1",655,0)
 ;i $g(debug)=1 d  ;
"RTN","SAMINOT1",656,0)
 ;. i ln["<" q  ; no markup
"RTN","SAMINOT1",657,0)
 ;. n zs s zs=$STACK
"RTN","SAMINOT1",658,0)
 ;. n zp s zp=$STACK(zs-2,"PLACE")
"RTN","SAMINOT1",659,0)
 ;. s @dest@(lnn)=zp_":"_ln
"RTN","SAMINOT1",660,0)
 ;
"RTN","SAMINOT1",661,0)
 quit  ; end of OUT
"RTN","SAMINOT1",662,0)
 ;
"RTN","SAMINOT1",663,0)
 ;
"RTN","SAMINOT1",664,0)
 ;
"RTN","SAMINOT1",665,0)
XVAL(var,vals) ; extrinsic returns the patient value for var
"RTN","SAMINOT1",666,0)
 ;
"RTN","SAMINOT1",667,0)
 ; vals is passed by name
"RTN","SAMINOT1",668,0)
 ;
"RTN","SAMINOT1",669,0)
 n zr
"RTN","SAMINOT1",670,0)
 s zr=$g(@vals@(var))
"RTN","SAMINOT1",671,0)
 ;i zr="" s zr="["_var_"]"
"RTN","SAMINOT1",672,0)
 ;
"RTN","SAMINOT1",673,0)
 quit zr ; end of $$XVAL
"RTN","SAMINOT1",674,0)
 ;
"RTN","SAMINOT1",675,0)
 ;
"RTN","SAMINOT1",676,0)
 ;
"RTN","SAMINOT1",677,0)
EOR ; end of routine SAMINOT1
"RTN","SAMINUL")
0^3^B101598
"RTN","SAMINUL",1,0)
SAMINUL ;ven/gpl - ielcap: note log ;2021-03-30T17:02Z
"RTN","SAMINUL",2,0)
 ;;18.0;SAMI;**9,10,11**;2020-01;Build 4
"RTN","SAMINUL",3,0)
 ;;1.18.0.11-i11
"RTN","SAMINUL",4,0)
 ;
"RTN","SAMINUL",5,0)
 ; SAMINOTE contains subroutines for producing the ELCAP Note Pages.
"RTN","SAMINUL",6,0)
 ; SAMINUL contains the development log for the SAMINOT* routines.
"RTN","SAMINUL",7,0)
 ; It contains no executable code.
"RTN","SAMINUL",8,0)
 ;
"RTN","SAMINUL",9,0)
 quit  ; no entry from top
"RTN","SAMINUL",10,0)
 ;
"RTN","SAMINUL",11,0)
 ;
"RTN","SAMINUL",12,0)
 ;
"RTN","SAMINUL",13,0)
 ;@section 0 primary development
"RTN","SAMINUL",14,0)
 ;
"RTN","SAMINUL",15,0)
 ;
"RTN","SAMINUL",16,0)
 ;
"RTN","SAMINUL",17,0)
 ;@routine-credits
"RTN","SAMINUL",18,0)
 ;@primary-dev George P. Lilly (gpl)
"RTN","SAMINUL",19,0)
 ; gpl@vistaexpertise.net
"RTN","SAMINUL",20,0)
 ;@primary-dev-org Vista Expertise Network (ven)
"RTN","SAMINUL",21,0)
 ; http://vistaexpertise.net
"RTN","SAMINUL",22,0)
 ;@copyright 2017/2021, gpl, all rights reserved
"RTN","SAMINUL",23,0)
 ;@license see routine SAMIUL
"RTN","SAMINUL",24,0)
 ;
"RTN","SAMINUL",25,0)
 ;@last-updated 2021-03-30T17:02Z
"RTN","SAMINUL",26,0)
 ;@application Screening Applications Management (SAM)
"RTN","SAMINUL",27,0)
 ;@module Screening Applications Management - IELCAP (SAMI)
"RTN","SAMINUL",28,0)
 ;@suite-of-files SAMI Forms (311.101-311.199)
"RTN","SAMINUL",29,0)
 ;@version 1.18.0.10-i11
"RTN","SAMINUL",30,0)
 ;@release-date 2020-01
"RTN","SAMINUL",31,0)
 ;@patch-list **9,10,11**
"RTN","SAMINUL",32,0)
 ;
"RTN","SAMINUL",33,0)
 ;@additional-dev Frederick D. S. Marshall (toad)
"RTN","SAMINUL",34,0)
 ; toad@vistaexpertise.net
"RTN","SAMINUL",35,0)
 ;@additional-dev Larry G. Carlson (lgc)
"RTN","SAMINUL",36,0)
 ; larry.g.carlson@gmail.com
"RTN","SAMINUL",37,0)
 ;@additional-dev Linda M. R. Yaw (lmry)
"RTN","SAMINUL",38,0)
 ; linda.yaw@vistaexpertise.net
"RTN","SAMINUL",39,0)
 ;@additional-dev Alexis R. Carlson (arc)
"RTN","SAMINUL",40,0)
 ; whatisthehumanspirit@gmail.com
"RTN","SAMINUL",41,0)
 ;@additional-dev Domenic DiNatale (dom)
"RTN","SAMINUL",42,0)
 ; domenic.dinatale@paraxialtech.com
"RTN","SAMINUL",43,0)
 ;
"RTN","SAMINUL",44,0)
 ;@module-credits
"RTN","SAMINUL",45,0)
 ;@project VA Partnership to Increase Access to Lung Screening
"RTN","SAMINUL",46,0)
 ; (VA-PALS)
"RTN","SAMINUL",47,0)
 ; http://va-pals.org/
"RTN","SAMINUL",48,0)
 ;@funding 2017/2021, Bristol-Myers Squibb Foundation (bmsf)
"RTN","SAMINUL",49,0)
 ; https://www.bms.com/about-us/responsibility/bristol-myers-squibb-foundation.html
"RTN","SAMINUL",50,0)
 ;@partner-org Veterans Affairs Office of Rural health
"RTN","SAMINUL",51,0)
 ; https://www.ruralhealth.va.gov/
"RTN","SAMINUL",52,0)
 ;@partner-org International Early Lung Cancer Action Program (I-ELCAP)
"RTN","SAMINUL",53,0)
 ; http://ielcap.com/
"RTN","SAMINUL",54,0)
 ;@partner-org Paraxial Technologies (par)
"RTN","SAMINUL",55,0)
 ; http://paraxialtech.com/
"RTN","SAMINUL",56,0)
 ;@partner-org Open Source Electronic Health Record Alliance (OSEHRA)
"RTN","SAMINUL",57,0)
 ; https://www.osehra.org/groups/va-pals-open-source-project-group
"RTN","SAMINUL",58,0)
 ;
"RTN","SAMINUL",59,0)
 ;@module-log repo github.com:VA-PALS-ELCAP/SAMI-VAPALS-ELCAP.git
"RTN","SAMINUL",60,0)
 ;
"RTN","SAMINUL",61,0)
 ; 2019-04-04/18 ven/gpl 1.18.0-t04 c0bb7dbf,f7b48936,9d1f2cdc,
"RTN","SAMINUL",62,0)
 ;  ba5f366d,5b2e32dc,ce322911
"RTN","SAMINUL",63,0)
 ;  SAMINOT1: flags for intake form, fix crash on intake form, initial
"RTN","SAMINUL",64,0)
 ; version of new intake notes, revise text for pre-enrollment
"RTN","SAMINUL",65,0)
 ; discusstion note, complete new intake notes, add intake notes to
"RTN","SAMINUL",66,0)
 ; case review page.
"RTN","SAMINUL",67,0)
 ;
"RTN","SAMINUL",68,0)
 ; 2019-04-16/23 ven/lgc 1.18.0-t04 e54b76d1,21388d8a,f0505e51,
"RTN","SAMINUL",69,0)
 ;  89bffd3b
"RTN","SAMINUL",70,0)
 ;  SAMINOT1: SAMIFRM2 > SAMIFORM, remove spaces at end of lines,
"RTN","SAMINUL",71,0)
 ; control characters, SAMISUB2 > LOAD.
"RTN","SAMINUL",72,0)
 ;
"RTN","SAMINUL",73,0)
 ; 2019-04-23 ven/toad 1.18.0-t04 423a3946
"RTN","SAMINUL",74,0)
 ;  SAMINOT1: resolve gpl/lgc collision, restore SAMISUB2 > LOAD.
"RTN","SAMINUL",75,0)
 ;
"RTN","SAMINUL",76,0)
 ; 2019-04-30 ven/gpl 1.18.0-t04 cf73510c
"RTN","SAMINUL",77,0)
 ;  SAMINOT1: additions to intake note for prior scans & format.
"RTN","SAMINUL",78,0)
 ;
"RTN","SAMINUL",79,0)
 ; 2019-05-07 ven/lmry 1.18.0-t04 4a8ead45
"RTN","SAMINUL",80,0)
 ;  SAMINOT1: edit SAMINOT1 for XINDEX.
"RTN","SAMINUL",81,0)
 ;
"RTN","SAMINUL",82,0)
 ; 2019-05-07 ven/lgc 1.18.0-t04 f63ef57c
"RTN","SAMINUL",83,0)
 ;  SAMINOT1: cleanup for XINDEX.
"RTN","SAMINUL",84,0)
 ;
"RTN","SAMINUL",85,0)
 ; 2019-06-18 ven/arc 1.18.0-t04 91022482
"RTN","SAMINUL",86,0)
 ;  SAMINOT1: ^SAMIGPL > ^SAMIUL.
"RTN","SAMINUL",87,0)
 ;
"RTN","SAMINUL",88,0)
 ; 2019-07-01 ven/gpl 1.18.0-t04 72868e60
"RTN","SAMINUL",89,0)
 ;  SAMINOT1: update shared decision making text in intake note.
"RTN","SAMINUL",90,0)
 ;
"RTN","SAMINUL",91,0)
 ; 2019-08-03/14 ven/gpl 1.18.0-t04 bea65f7b,578f61d4
"RTN","SAMINUL",92,0)
 ;  SAMINOT1: fix bugs in Have you ever smoked processing in changelog
"RTN","SAMINUL",93,0)
 ; & intake note, restored ever smoked comment field to intake note.
"RTN","SAMINUL",94,0)
 ;
"RTN","SAMINUL",95,0)
 ; 2019-09-06 par/dom 1.18.0-t04 2ff47189 VAP-452
"RTN","SAMINUL",96,0)
 ;  SAMINOT1: patient > participant.
"RTN","SAMINUL",97,0)
 ;
"RTN","SAMINUL",98,0)
 ; 2019-09-26 ven/gpl 1.18.0-t04 92b12324 VAP-420
"RTN","SAMINUL",99,0)
 ;  SAMINOT1: smoking history.
"RTN","SAMINUL",100,0)
 ;
"RTN","SAMINUL",101,0)
 ; 2019-10-01 par/dom 1.18.0-t04 37c418a1,4caf1a98 VAP-457,344
"RTN","SAMINUL",102,0)
 ;  SAMINOT1: remove thorax, capitalization consistency.
"RTN","SAMINUL",103,0)
 ;
"RTN","SAMINUL",104,0)
 ; 2020-01-17/20 ven/lgc 1.18.0.1-i1 8557207f,d7d24834,0301ad95.
"RTN","SAMINUL",105,0)
 ;  659f2526,0ff2b83f,49615242,5bf7c398,dc5f618c
"RTN","SAMINUL",106,0)
 ;  SAMINOT2: followup note, fixed typos in VC note, followup LCS note
"RTN","SAMINUL",107,0)
 ; minus CT Eval pulls, LCS note with CT Eval extracts, fixed bug in
"RTN","SAMINUL",108,0)
 ; LSC CT eval extract, include entire impression section of CT Eval
"RTN","SAMINUL",109,0)
 ; report in LCS Note, improved import of impressions, limit to one
"RTN","SAMINUL",110,0)
 ; note per followup form.
"RTN","SAMINUL",111,0)
 ;
"RTN","SAMINUL",112,0)
 ; 2020-01-23 ven/arc 1.18.0.2-i2 9a24242a
"RTN","SAMINUL",113,0)
 ;  SAMINOT1: fix word wrap on intake note & typos in ct
"RTN","SAMINUL",114,0)
 ; eval report.
"RTN","SAMINUL",115,0)
 ;
"RTN","SAMINUL",116,0)
 ; 2020-08-12 ven/gpl 1.18.0.6-i6 781744c3
"RTN","SAMINUL",117,0)
 ;  SAMINOT1: chg to support hl7 transmission of notes.
"RTN","SAMINUL",118,0)
 ;
"RTN","SAMINUL",119,0)
 ; 2020-09-22 ven/gpl 1.18.0.6-i6 06459eda
"RTN","SAMINUL",120,0)
 ;  SAMINOT1: fix to match kids file.
"RTN","SAMINUL",121,0)
 ;
"RTN","SAMINUL",122,0)
 ; 2021-02-01/24 ven/gpl 1.18.0.8-i8 8e4ec441,cde71a55
"RTN","SAMINUL",123,0)
 ;  SAMINOT1: fix intake note format, fix error that sent note twice
"RTN","SAMINUL",124,0)
 ; to VistA.
"RTN","SAMINUL",125,0)
 ;
"RTN","SAMINUL",126,0)
 ; 2021-03-02 ven/gpl 1.18.0.9-i9 479dc041
"RTN","SAMINUL",127,0)
 ;  SAMINOT2: return error message if no ct eval form exists when
"RTN","SAMINUL",128,0)
 ; generating a fu note.
"RTN","SAMINUL",129,0)
 ;
"RTN","SAMINUL",130,0)
 ; 2021-03-15/16 ven/toad 1.18.0.9-i9 a46a2cc1
"RTN","SAMINUL",131,0)
 ;  SAMINUL: create routine.
"RTN","SAMINUL",132,0)
 ;  SAMINOT2: bump date & patch list, add contents, lt refactor.
"RTN","SAMINUL",133,0)
 ;
"RTN","SAMINUL",134,0)
 ; 2021-03-17 ven/toad 1.18.0.9-i9 62da30b4
"RTN","SAMINUL",135,0)
 ; SAMINOT2: remove blank from end of 1 line.
"RTN","SAMINUL",136,0)
 ;
"RTN","SAMINUL",137,0)
 ; 2021-03-22 ven/gpl 1.18.0.10-i10 6319a1eb
"RTN","SAMINUL",138,0)
 ;  SAMINOT1: fix logic bug in detecting pre-enrollment existing.
"RTN","SAMINUL",139,0)
 ;
"RTN","SAMINUL",140,0)
 ; 2021-03-23 ven/toad 1.18.0.10-i10 96f461d0
"RTN","SAMINUL",141,0)
 ;  SAMINOT1: bump date & patch list, lt refactor.
"RTN","SAMINUL",142,0)
 ;
"RTN","SAMINUL",143,0)
 ; 2021-03-29 ven/gpl 1.18.0.11-i11 6cd83445 VAP-483
"RTN","SAMINUL",144,0)
 ;  SAMINOT1: allow N/A for shared decision making on intake form:
"RTN","SAMINUL",145,0)
 ; in INNOTE new & set shareddm & use to call SDM or report n/a, based
"RTN","SAMINUL",146,0)
 ; on siidmdc.
"RTN","SAMINUL",147,0)
 ;
"RTN","SAMINUL",148,0)
 ; 2021-03-30 ven/toad 1.18.0.11-i11
"RTN","SAMINUL",149,0)
 ; SAMINOT1: bump version, date, log.
"RTN","SAMINUL",150,0)
 ;
"RTN","SAMINUL",151,0)
 ;
"RTN","SAMINUL",152,0)
 ;
"RTN","SAMINUL",153,0)
EOR ; end of routine SAMINUL
"RTN","SAMIUR")
0^2^B291906917
"RTN","SAMIUR",1,0)
SAMIUR ;ven/gpl - user reports ;2021-03-30T15:50Z
"RTN","SAMIUR",2,0)
 ;;18.0;SAMI;**5,10,11**;2020-01;Build 4
"RTN","SAMIUR",3,0)
 ;;1.18.0.11-i11
"RTN","SAMIUR",4,0)
 ;
"RTN","SAMIUR",5,0)
 ; SAMIUR contains a web service & associated subroutines to produce
"RTN","SAMIUR",6,0)
 ; the VAPALS-ELCAP user reports.
"RTN","SAMIUR",7,0)
 ;
"RTN","SAMIUR",8,0)
 quit  ; no entry from top
"RTN","SAMIUR",9,0)
 ;
"RTN","SAMIUR",10,0)
 ;
"RTN","SAMIUR",11,0)
 ;
"RTN","SAMIUR",12,0)
 ;@section 0 primary development
"RTN","SAMIUR",13,0)
 ;
"RTN","SAMIUR",14,0)
 ;
"RTN","SAMIUR",15,0)
 ;
"RTN","SAMIUR",16,0)
 ;@routine-credits
"RTN","SAMIUR",17,0)
 ;@primary-dev George P. Lilly (gpl)
"RTN","SAMIUR",18,0)
 ; gpl@vistaexpertise.net
"RTN","SAMIUR",19,0)
 ;@primary-dev-org Vista Expertise Network (ven)
"RTN","SAMIUR",20,0)
 ; http://vistaexpertise.net
"RTN","SAMIUR",21,0)
 ;@copyright 2017/2021, gpl, all rights reserved
"RTN","SAMIUR",22,0)
 ;@license see routine SAMIUL
"RTN","SAMIUR",23,0)
 ;
"RTN","SAMIUR",24,0)
 ;@last-updated 2021-03-30T15:50Z
"RTN","SAMIUR",25,0)
 ;@application Screening Applications Management (SAM)
"RTN","SAMIUR",26,0)
 ;@module Screening Applications Management - IELCAP (SAMI)
"RTN","SAMIUR",27,0)
 ;@suite-of-files SAMI Forms (311.101-311.199)
"RTN","SAMIUR",28,0)
 ;@version 1.18.0.11-i11
"RTN","SAMIUR",29,0)
 ;@release-date 2020-01
"RTN","SAMIUR",30,0)
 ;@patch-list **5,10,11**
"RTN","SAMIUR",31,0)
 ;
"RTN","SAMIUR",32,0)
 ;@additional-dev Frederick D. S. Marshall (toad)
"RTN","SAMIUR",33,0)
 ; toad@vistaexpertise.net
"RTN","SAMIUR",34,0)
 ;@additional-dev Larry G. Carlson (lgc)
"RTN","SAMIUR",35,0)
 ; larry.g.carlson@gmail.com
"RTN","SAMIUR",36,0)
 ;@additional-dev Alexis R. Carlson (arc)
"RTN","SAMIUR",37,0)
 ; whatisthehumanspirit@gmail.com
"RTN","SAMIUR",38,0)
 ;
"RTN","SAMIUR",39,0)
 ;@module-credits
"RTN","SAMIUR",40,0)
 ;@project VA Partnership to Increase Access to Lung Screening
"RTN","SAMIUR",41,0)
 ; (VA-PALS)
"RTN","SAMIUR",42,0)
 ; http://va-pals.org/
"RTN","SAMIUR",43,0)
 ;@funding 2017/2021, Bristol-Myers Squibb Foundation (bmsf)
"RTN","SAMIUR",44,0)
 ; https://www.bms.com/about-us/responsibility/bristol-myers-squibb-foundation.html
"RTN","SAMIUR",45,0)
 ;@partner-org Veterans Affairs Office of Rural health
"RTN","SAMIUR",46,0)
 ; https://www.ruralhealth.va.gov/
"RTN","SAMIUR",47,0)
 ;@partner-org International Early Lung Cancer Action Program (I-ELCAP)
"RTN","SAMIUR",48,0)
 ; http://ielcap.com/
"RTN","SAMIUR",49,0)
 ;@partner-org Paraxial Technologies (par)
"RTN","SAMIUR",50,0)
 ; http://paraxialtech.com/
"RTN","SAMIUR",51,0)
 ;@partner-org Open Source Electronic Health Record Alliance (OSEHRA)
"RTN","SAMIUR",52,0)
 ; https://www.osehra.org/groups/va-pals-open-source-project-group
"RTN","SAMIUR",53,0)
 ;
"RTN","SAMIUR",54,0)
 ;@module-log repo github.com:VA-PALS-ELCAP/SAMI-VAPALS-ELCAP.git
"RTN","SAMIUR",55,0)
 ;
"RTN","SAMIUR",56,0)
 ; 2020-02-10/12 ven/gpl 1.18.0-t04 d543f7bb,f9869dfb,0e4d8b9a
"RTN","SAMIUR",57,0)
 ;  SAMIUR: 1st version of revised user reports, progress on user
"RTN","SAMIUR",58,0)
 ; reports, fixed a bug in enrollment report.
"RTN","SAMIUR",59,0)
 ;
"RTN","SAMIUR",60,0)
 ; 2020-02-18 ven/lgc 1.18.0-t04 76874314
"RTN","SAMIUR",61,0)
 ;  SAMIUR: update recently edited routines.
"RTN","SAMIUR",62,0)
 ;
"RTN","SAMIUR",63,0)
 ; 2020-03-10/12 ven/gpl 1.18.0-t04 8de06b06,4ad52d64
"RTN","SAMIUR",64,0)
 ;  SAMIUR: user report date filtering, fix end date logic in UR.
"RTN","SAMIUR",65,0)
 ;
"RTN","SAMIUR",66,0)
 ; 2020-04-16/23 ven/lgc 1.18.0-t04 e54b76d1b,89bffd3b
"RTN","SAMIUR",67,0)
 ;  SAMIUR: SAMIFRM2 > SAMIFORM, SAMISUB2 > LOAD.
"RTN","SAMIUR",68,0)
 ;
"RTN","SAMIUR",69,0)
 ; 2020-08-04 ven/gpl 1.18.0-t04 cd865e2b VPA-438
"RTN","SAMIUR",70,0)
 ;  SAMIUR: requested changes to followup report.
"RTN","SAMIUR",71,0)
 ;
"RTN","SAMIUR",72,0)
 ; 2020-09-26 ven/gpl 1.18.0-t04 92b12324 VAP-420
"RTN","SAMIUR",73,0)
 ;  SAMIUR: add smoking history.
"RTN","SAMIUR",74,0)
 ;
"RTN","SAMIUR",75,0)
 ; 2020-01-01/05 ven/arc 1.18.0 399f8547,62e3200f
"RTN","SAMIUR",76,0)
 ;  SAMIUR: unmatched participant processing.
"RTN","SAMIUR",77,0)
 ;
"RTN","SAMIUR",78,0)
 ; 2020-04-29/05-13 ven/gpl 1.18.0.5-i5 e8b8ea2d,61c7d208
"RTN","SAMIUR",79,0)
 ;  SAMIUR: fixes for reports, worklist functionality.
"RTN","SAMIUR",80,0)
 ;
"RTN","SAMIUR",81,0)
 ; 2021-03-22/23 ven/gpl 1.18.0.10-i10 256efe63,ba81b86a2
"RTN","SAMIUR",82,0)
 ;  SAMIUR: sort all reports by name, added row totals to reports.
"RTN","SAMIUR",83,0)
 ;
"RTN","SAMIUR",84,0)
 ; 2021-03-23 ven/toad 1.18.0.10-i10 96f461d0,af86e0eb
"RTN","SAMIUR",85,0)
 ; SAMIUR: add version info & dev log, lt refactor, fix XINDEX errors.
"RTN","SAMIUR",86,0)
 ;
"RTN","SAMIUR",87,0)
 ; 2021-03-29 ven/gpl 1.18.0.11-i11 e809f2a2
"RTN","SAMIUR",88,0)
 ;  SAMIUR: prevent crash when reports have no matches: in WSREPORT
"RTN","SAMIUR",89,0)
 ; set SRT="" and uncomment zwrite SRT; in WKLIST add 2 commented-out
"RTN","SAMIUR",90,0)
 ; debugging lines.
"RTN","SAMIUR",91,0)
 ;
"RTN","SAMIUR",92,0)
 ; 2021-03-30 ven/toad 1.18.0.11-i11
"RTN","SAMIUR",93,0)
 ; SAMIUR: bump version, date, log; in WSREPORT comment zwrite SRT.
"RTN","SAMIUR",94,0)
 ;
"RTN","SAMIUR",95,0)
 ;
"RTN","SAMIUR",96,0)
 ;
"RTN","SAMIUR",97,0)
WSREPORT(SAMIRTN,filter) ; generate a report based on parameters in the filter
"RTN","SAMIUR",98,0)
 ;
"RTN","SAMIUR",99,0)
 ; here are the user reports that are defined:
"RTN","SAMIUR",100,0)
 ;  1. followup
"RTN","SAMIUR",101,0)
 ;  2. activity
"RTN","SAMIUR",102,0)
 ;  3. missingct
"RTN","SAMIUR",103,0)
 ;  4. incomplete
"RTN","SAMIUR",104,0)
 ;  5. outreach
"RTN","SAMIUR",105,0)
 ;  6. enrollment
"RTN","SAMIUR",106,0)
 ;  7. worklist
"RTN","SAMIUR",107,0)
 ; the report to generate is passed in parameter samireporttype
"RTN","SAMIUR",108,0)
 ;
"RTN","SAMIUR",109,0)
 n debug s debug=0
"RTN","SAMIUR",110,0)
 i $g(filter("debug"))=1 s debug=1
"RTN","SAMIUR",111,0)
 i $g(filter("debug"))=1 s debug=1
"RTN","SAMIUR",112,0)
 k SAMIRTN
"RTN","SAMIUR",113,0)
 s HTTPRSP("mime")="text/html"
"RTN","SAMIUR",114,0)
 ;
"RTN","SAMIUR",115,0)
 n type,temp
"RTN","SAMIUR",116,0)
 s type=$g(filter("samireporttype"))
"RTN","SAMIUR",117,0)
 i type="" d  q  ; report type missing
"RTN","SAMIUR",118,0)
 . d GETHOME^SAMIHOM3(.SAMIRTN,.filter) ; send them to home
"RTN","SAMIUR",119,0)
 ;
"RTN","SAMIUR",120,0)
 d getThis^%wd("temp","table.html") ; page template
"RTN","SAMIUR",121,0)
 q:'$d(temp)
"RTN","SAMIUR",122,0)
 ;
"RTN","SAMIUR",123,0)
 n SAMIPATS
"RTN","SAMIUR",124,0)
 ;s pats=""
"RTN","SAMIUR",125,0)
 n datephrase
"RTN","SAMIUR",126,0)
 d SELECT(.SAMIPATS,type,.datephrase,.filter) ; select patients for the report
"RTN","SAMIUR",127,0)
 ;q:'$d(SAMIPATS)
"RTN","SAMIUR",128,0)
 ;
"RTN","SAMIUR",129,0)
 n ln,cnt,ii
"RTN","SAMIUR",130,0)
 s (ii,ln,cnt)=0
"RTN","SAMIUR",131,0)
 f  s ii=$o(temp(ii)) q:+ii=0  q:$g(temp(ii))["<thead"  d  ;
"RTN","SAMIUR",132,0)
 . s cnt=cnt+1
"RTN","SAMIUR",133,0)
 . s ln=$g(temp(ii))
"RTN","SAMIUR",134,0)
 . n samikey,si
"RTN","SAMIUR",135,0)
 . s (samikey,si)=""
"RTN","SAMIUR",136,0)
 . d LOAD^SAMIFORM(.ln,samikey,si,.filter)
"RTN","SAMIUR",137,0)
 . ;i ln["PAGE NAME" d findReplace^%ts(.ln,"PAGE NAME",$$PNAME(type,datephrase))
"RTN","SAMIUR",138,0)
 . i ln["PAGE NAME" d findReplace^%ts(.ln,"PAGE NAME",$$PNAME(type,""))
"RTN","SAMIUR",139,0)
 . i ln["CRITERIA" d findReplace^%ts(.ln,"CRITERIA",datephrase)
"RTN","SAMIUR",140,0)
 . i ln["@@REPORTTYPE@@" d findReplace^%ts(.ln,"@@REPORTTYPE@@",type)
"RTN","SAMIUR",141,0)
 . ;
"RTN","SAMIUR",142,0)
 . i ln["name=""start-date""" d findReplace^%ts(.ln,"start-date""","start-date"" value="""_$g(filter("start-date"))_"""")
"RTN","SAMIUR",143,0)
 . i ln["name=""end-date""" d findReplace^%ts(.ln,"end-date""","end-date"" value="""_$g(filter("end-date"))_"""")
"RTN","SAMIUR",144,0)
 . s SAMIRTN(cnt)=ln
"RTN","SAMIUR",145,0)
 . ;
"RTN","SAMIUR",146,0)
 n RPT,ik
"RTN","SAMIUR",147,0)
 d RPTTBL^SAMIUR2(.RPT,type) ; get the report specs
"RTN","SAMIUR",148,0)
 i '$d(RPT) d  q  ; don't know about this report
"RTN","SAMIUR",149,0)
 . d GETHOME^SAMIHOM3(.SAMIRTN,.filter) ; send them to home
"RTN","SAMIUR",150,0)
 ;
"RTN","SAMIUR",151,0)
 ; output the header
"RTN","SAMIUR",152,0)
 ;
"RTN","SAMIUR",153,0)
 s cnt=cnt+1 s SAMIRTN(cnt)="<thead><tr>"
"RTN","SAMIUR",154,0)
 s ir=""
"RTN","SAMIUR",155,0)
 f  s ir=$o(RPT(ir)) q:ir=""  d  ;
"RTN","SAMIUR",156,0)
 . s cnt=cnt+1
"RTN","SAMIUR",157,0)
 . s SAMIRTN(cnt)="<th>"_$g(RPT(ir,"header"))_"</th>"
"RTN","SAMIUR",158,0)
 s cnt=cnt+1 s SAMIRTN(cnt)="</tr></thead>"
"RTN","SAMIUR",159,0)
 ;
"RTN","SAMIUR",160,0)
 s cnt=cnt+1 s SAMIRTN(cnt)="<tbody>"
"RTN","SAMIUR",161,0)
 ;
"RTN","SAMIUR",162,0)
 i type'="worklist" d  ; 
"RTN","SAMIUR",163,0)
 . d NUHREF(.SAMIPATS) ; create the nuhref link for all patients
"RTN","SAMIUR",164,0)
 ;
"RTN","SAMIUR",165,0)
 n SRT s SRT=""
"RTN","SAMIUR",166,0)
 i $g(filter("sort"))="" s filter("sort")="name"
"RTN","SAMIUR",167,0)
 d SORT(.SRT,.SAMIPATS,.filter)
"RTN","SAMIUR",168,0)
 ;zwr SRT
"RTN","SAMIUR",169,0)
 ;
"RTN","SAMIUR",170,0)
 ;s ij=0
"RTN","SAMIUR",171,0)
 ;f  s ij=$o(SAMIPATS(ij)) q:+ij=0  d  ;
"RTN","SAMIUR",172,0)
 ;. n ij2 s ij2=0
"RTN","SAMIUR",173,0)
 ;. f  s ij2=$o(SAMIPATS(ij,ij2)) q:+ij2=0  d  ;
"RTN","SAMIUR",174,0)
 ;. . n dfn s dfn=ij2
"RTN","SAMIUR",175,0)
 n iz,ij,ij2,dfn,rows
"RTN","SAMIUR",176,0)
 s rows=0
"RTN","SAMIUR",177,0)
 s (iz,ij,ij2,dfn)=""
"RTN","SAMIUR",178,0)
 f  s iz=$o(SRT(iz)) q:iz=""  d  ;
"RTN","SAMIUR",179,0)
 . s ij=$o(SRT(iz,""))
"RTN","SAMIUR",180,0)
 . s dfn=$o(SRT(iz,ij,""))
"RTN","SAMIUR",181,0)
 . d  ;
"RTN","SAMIUR",182,0)
 . . s cnt=cnt+1 s SAMIRTN(cnt)="<tr>"
"RTN","SAMIUR",183,0)
 . . s ir=""
"RTN","SAMIUR",184,0)
 . . f  s ir=$o(RPT(ir)) q:ir=""  d  ;
"RTN","SAMIUR",185,0)
 . . . s cnt=cnt+1
"RTN","SAMIUR",186,0)
 . . . n XR,XRV
"RTN","SAMIUR",187,0)
 . . . ;s XR=$g(RPT(ir,"routine"))_"("_ij_",.SAMIPATS)"
"RTN","SAMIUR",188,0)
 . . . s XR="S XRV="_$g(RPT(ir,"routine"))_"("_ij_","_dfn_",.SAMIPATS)"
"RTN","SAMIUR",189,0)
 . . . ;s XRV=@XR
"RTN","SAMIUR",190,0)
 . . . X XR
"RTN","SAMIUR",191,0)
 . . . s SAMIRTN(cnt)="<td>"_$g(XRV)_"</td>"
"RTN","SAMIUR",192,0)
 . . ;
"RTN","SAMIUR",193,0)
 . . s cnt=cnt+1
"RTN","SAMIUR",194,0)
 . . s SAMIRTN(cnt)="</tr>"
"RTN","SAMIUR",195,0)
 . . s rows=rows+1
"RTN","SAMIUR",196,0)
 s cnt=cnt+1
"RTN","SAMIUR",197,0)
 s SAMIRTN(cnt)="<tr><td>Total: "_rows_"</td></tr>"
"RTN","SAMIUR",198,0)
 ;
"RTN","SAMIUR",199,0)
 s cnt=cnt+1 s SAMIRTN(cnt)="</tbody>"
"RTN","SAMIUR",200,0)
 f  s ii=$o(temp(ii)) q:temp(ii)["</tbody>"  d  ;
"RTN","SAMIUR",201,0)
 . ; skip past template headers and blank body
"RTN","SAMIUR",202,0)
 f  s ii=$o(temp(ii)) q:+ii=0  d  ;
"RTN","SAMIUR",203,0)
 . s cnt=cnt+1
"RTN","SAMIUR",204,0)
 . s ln=$g(temp(ii))
"RTN","SAMIUR",205,0)
 . n samikey,si
"RTN","SAMIUR",206,0)
 . s (samikey,si)=""
"RTN","SAMIUR",207,0)
 . d LOAD^SAMIFORM(.ln,samikey,si,.filter)
"RTN","SAMIUR",208,0)
 . s SAMIRTN(cnt)=ln
"RTN","SAMIUR",209,0)
 ;
"RTN","SAMIUR",210,0)
 quit  ; end of WSREPORT
"RTN","SAMIUR",211,0)
 ;
"RTN","SAMIUR",212,0)
 ;
"RTN","SAMIUR",213,0)
 ;
"RTN","SAMIUR",214,0)
SORT(SRTN,SAMIPATS,FILTER) ;
"RTN","SAMIUR",215,0)
 n typ s typ=$g(FILTER("sort"))
"RTN","SAMIUR",216,0)
 i typ="" s typ="name"
"RTN","SAMIUR",217,0)
 n iz,dt,dfn,nm
"RTN","SAMIUR",218,0)
 s (dt,dfn,nm)=""
"RTN","SAMIUR",219,0)
 s iz=0
"RTN","SAMIUR",220,0)
 n indx
"RTN","SAMIUR",221,0)
 f  s dt=$o(SAMIPATS(dt)) q:+dt=0  d  ;
"RTN","SAMIUR",222,0)
 . f  s dfn=$o(SAMIPATS(dt,dfn)) q:+dfn=0  d  ;
"RTN","SAMIUR",223,0)
 . . i typ="name" d  ;
"RTN","SAMIUR",224,0)
 . . . s nm=$g(SAMIPATS(dt,dfn,"name"))
"RTN","SAMIUR",225,0)
 . . . i nm="" s nm=" "
"RTN","SAMIUR",226,0)
 . . . s indx(nm,dt,dfn)=""
"RTN","SAMIUR",227,0)
 n iiz s iiz=""
"RTN","SAMIUR",228,0)
 s (dt,dfn)=""
"RTN","SAMIUR",229,0)
 f  s iiz=$o(indx(iiz)) q:iiz=""  d  ;
"RTN","SAMIUR",230,0)
 . f  s dt=$o(indx(iiz,dt)) q:dt=""  d  ;
"RTN","SAMIUR",231,0)
 . . f  s dfn=$o(indx(iiz,dt,dfn)) q:dfn=""  d  ;
"RTN","SAMIUR",232,0)
 . . . s iz=iz+1
"RTN","SAMIUR",233,0)
 . . . s SRTN(iz,dt,dfn)=iiz
"RTN","SAMIUR",234,0)
 ;
"RTN","SAMIUR",235,0)
 quit  ; end of SORT
"RTN","SAMIUR",236,0)
 ;
"RTN","SAMIUR",237,0)
 ;
"RTN","SAMIUR",238,0)
 ;
"RTN","SAMIUR",239,0)
NUHREF(SAMIPATS) ; create the nuhref link to casereview for all patients
"RTN","SAMIUR",240,0)
 n ij
"RTN","SAMIUR",241,0)
 n root s root=$$setroot^%wd("vapals-patients")
"RTN","SAMIUR",242,0)
 s ij=0
"RTN","SAMIUR",243,0)
 f  s ij=$o(SAMIPATS(ij)) q:+ij=0  d  ;
"RTN","SAMIUR",244,0)
 . n ij2 s ij2=0
"RTN","SAMIUR",245,0)
 . f  s ij2=$o(SAMIPATS(ij,ij2)) q:+ij2=0  d  ;
"RTN","SAMIUR",246,0)
 . . n dfn s dfn=ij2
"RTN","SAMIUR",247,0)
 . . s SAMIPATS(ij,dfn,"sid")=$g(@root@(dfn,"samistudyid"))
"RTN","SAMIUR",248,0)
 . . n sid s sid=SAMIPATS(ij,dfn,"sid")
"RTN","SAMIUR",249,0)
 . . s SAMIPATS(ij,dfn,"name")=$g(@root@(dfn,"saminame"))
"RTN","SAMIUR",250,0)
 . . n name s name=SAMIPATS(ij,dfn,"name")
"RTN","SAMIUR",251,0)
 . . s SAMIPATS(ij,dfn,"ssn")=$$GETSSN^SAMIFORM(sid)
"RTN","SAMIUR",252,0)
 . . new nuhref set nuhref="<form method=POST action=""/vapals"">"
"RTN","SAMIUR",253,0)
 . . set nuhref=nuhref_"<input type=hidden name=""samiroute"" value=""casereview"">"
"RTN","SAMIUR",254,0)
 . . set nuhref=nuhref_"<input type=hidden name=""studyid"" value="_sid_">"
"RTN","SAMIUR",255,0)
 . . set nuhref=nuhref_"<input value="""_name_""" class=""btn btn-link"" role=""link"" type=""submit""></form>"
"RTN","SAMIUR",256,0)
 . . s SAMIPATS(ij,dfn,"nuhref")=nuhref
"RTN","SAMIUR",257,0)
 ;
"RTN","SAMIUR",258,0)
 quit  ; end of NUHREF
"RTN","SAMIUR",259,0)
 ;
"RTN","SAMIUR",260,0)
 ;
"RTN","SAMIUR",261,0)
 ;
"RTN","SAMIUR",262,0)
SELECT(SAMIPATS,ztype,datephrase,filter) ;selects patients for report
"RTN","SAMIUR",263,0)
 ;
"RTN","SAMIUR",264,0)
 ;m ^gpl("select")=filter
"RTN","SAMIUR",265,0)
 n type s type=ztype
"RTN","SAMIUR",266,0)
 i type="unmatched" d  q  ;
"RTN","SAMIUR",267,0)
 . d UNMAT(.SAMIPATS,ztype,.datephrase,.filter)
"RTN","SAMIUR",268,0)
 i type="worklist" d  q  ;
"RTN","SAMIUR",269,0)
 . d WKLIST(.SAMIPATS,ztype,.datephrase,.filter)
"RTN","SAMIUR",270,0)
 i $g(type)="" s type="enrollment"
"RTN","SAMIUR",271,0)
 i type="cumpy" s type="enrollment"
"RTN","SAMIUR",272,0)
 n site s site=$g(filter("siteid"))
"RTN","SAMIUR",273,0)
 n strdt,enddt,fmstrdt,fmenddt
"RTN","SAMIUR",274,0)
 s strdt=$g(filter("start-date"))
"RTN","SAMIUR",275,0)
 s fmstrdt=$$KEY2FM^SAMICASE(strdt)
"RTN","SAMIUR",276,0)
 i fmstrdt=-1 d  ;
"RTN","SAMIUR",277,0)
 . s fmstrdt=2000101
"RTN","SAMIUR",278,0)
 . i type="followup" s fmstrdt=$$NOW^XLFDT
"RTN","SAMIUR",279,0)
 . i type="activity" s fmstrdt=$$FMADD^XLFDT($$NOW^XLFDT,-31)
"RTN","SAMIUR",280,0)
 i strdt="" s filter("start-date")=$$VAPALSDT^SAMICASE(fmstrdt)
"RTN","SAMIUR",281,0)
 s enddt=$g(filter("end-date"))
"RTN","SAMIUR",282,0)
 s fmenddt=$$KEY2FM^SAMICASE(enddt)
"RTN","SAMIUR",283,0)
 i fmenddt=-1 d  ;
"RTN","SAMIUR",284,0)
 . s fmenddt=$$NOW^XLFDT
"RTN","SAMIUR",285,0)
 . i type="followup" s fmenddt=$$FMADD^XLFDT($$NOW^XLFDT,31)
"RTN","SAMIUR",286,0)
 i enddt="" s filter("end-date")=$$VAPALSDT^SAMICASE(fmenddt)
"RTN","SAMIUR",287,0)
 s datephrase=""
"RTN","SAMIUR",288,0)
 n zi s zi=0
"RTN","SAMIUR",289,0)
 n root s root=$$setroot^%wd("vapals-patients")
"RTN","SAMIUR",290,0)
 ;
"RTN","SAMIUR",291,0)
 f  s zi=$o(@root@(zi)) q:+zi=0  d  ;
"RTN","SAMIUR",292,0)
 . n sid s sid=$g(@root@(zi,"samistudyid"))
"RTN","SAMIUR",293,0)
 . q:sid=""
"RTN","SAMIUR",294,0)
 . q:$e(sid,1,3)'=site
"RTN","SAMIUR",295,0)
 . n items s items=""
"RTN","SAMIUR",296,0)
 . d GETITEMS^SAMICASE("items",sid)
"RTN","SAMIUR",297,0)
 . q:'$d(items)
"RTN","SAMIUR",298,0)
 . n efmdate,edate,siform,ceform,cefud,fmcefud,cedos,fmcedos
"RTN","SAMIUR",299,0)
 . s siform=$o(items("siform-"))
"RTN","SAMIUR",300,0)
 . i $g(@root@("graph",sid,siform,"sistatus"))="inactive" q  ;
"RTN","SAMIUR",301,0)
 . s ceform=$o(items("ceform-a"),-1)
"RTN","SAMIUR",302,0)
 . s (cefud,fmcefud,cedos,fmcedos)=""
"RTN","SAMIUR",303,0)
 . i ceform'="" d  ;
"RTN","SAMIUR",304,0)
 . . s cefud=$g(@root@("graph",sid,ceform,"cefud"))
"RTN","SAMIUR",305,0)
 . . i cefud'="" s fmcefud=$$KEY2FM^SAMICASE(cefud)
"RTN","SAMIUR",306,0)
 . . s cedos=$g(@root@("graph",sid,ceform,"cedos"))
"RTN","SAMIUR",307,0)
 . . i cedos'="" s fmcedos=$$KEY2FM^SAMICASE(cedos)
"RTN","SAMIUR",308,0)
 . s edate=$g(@root@("graph",sid,siform,"sidc"))
"RTN","SAMIUR",309,0)
 . i edate="" s edate=$g(@root@("graph",sid,siform,"samicreatedate"))
"RTN","SAMIUR",310,0)
 . s efmdate=$$KEY2FM^SAMICASE(edate)
"RTN","SAMIUR",311,0)
 . s edate=$$VAPALSDT^SAMICASE(efmdate)
"RTN","SAMIUR",312,0)
 . ;
"RTN","SAMIUR",313,0)
 . i type="followup" d  ;
"RTN","SAMIUR",314,0)
 . . ;n nplus30 s nplus30=$$FMADD^XLFDT($$NOW^XLFDT,31)
"RTN","SAMIUR",315,0)
 . . i +fmcefud<fmstrdt q  ; before start date
"RTN","SAMIUR",316,0)
 . . i (+fmcefud<(fmenddt+1)) d  ; before end date
"RTN","SAMIUR",317,0)
 . . . i ceform="" q  ; no ct eval so no followup date
"RTN","SAMIUR",318,0)
 . . . s SAMIPATS(fmcefud,zi,"edate")=edate
"RTN","SAMIUR",319,0)
 . . . s SAMIPATS(fmcefud,zi)=""
"RTN","SAMIUR",320,0)
 . . . i ceform="" s cefud="baseline"
"RTN","SAMIUR",321,0)
 . . . s SAMIPATS(fmcefud,zi,"cefud")=cefud
"RTN","SAMIUR",322,0)
 . . . s SAMIPATS(fmcefud,zi,"cedos")=cedos
"RTN","SAMIUR",323,0)
 . . . s SAMIPATS(fmcefud,zi,"ceform")=ceform
"RTN","SAMIUR",324,0)
 . . . s SAMIPATS(fmcefud,zi,"ceform-vals")=$na(@root@("graph",sid,ceform))
"RTN","SAMIUR",325,0)
 . . . s SAMIPATS(fmcefud,zi,"siform")=siform
"RTN","SAMIUR",326,0)
 . . . s SAMIPATS(fmcefud,zi,"siform-vals")=$na(@root@("graph",sid,siform))
"RTN","SAMIUR",327,0)
 . . . m SAMIPATS(fmcefud,zi,"items")=items
"RTN","SAMIUR",328,0)
 . . s datephrase=" before "_$$VAPALSDT^SAMICASE(fmenddt)
"RTN","SAMIUR",329,0)
 . . q
"RTN","SAMIUR",330,0)
 . i type="activity" d  ;
"RTN","SAMIUR",331,0)
 . . ;n nminus30 s nminus30=$$FMADD^XLFDT($$NOW^XLFDT,-31)
"RTN","SAMIUR",332,0)
 . . n anyform s anyform=$o(items("sort",""),-1)
"RTN","SAMIUR",333,0)
 . . n fmanyform s fmanyform=$$KEY2FM^SAMICASE(anyform)
"RTN","SAMIUR",334,0)
 . . i +fmanyform<fmstrdt q  ; before the start date
"RTN","SAMIUR",335,0)
 . . ;i (+fmanyform<(fmenddt+1))!(+efmdate>fmenddt) d  ; need any new form
"RTN","SAMIUR",336,0)
 . . i (+fmanyform<(fmenddt+1))  d  ;
"RTN","SAMIUR",337,0)
 . . . s SAMIPATS(efmdate,zi,"edate")=edate
"RTN","SAMIUR",338,0)
 . . . s SAMIPATS(efmdate,zi)=""
"RTN","SAMIUR",339,0)
 . . . i ceform="" s cefud="baseline"
"RTN","SAMIUR",340,0)
 . . . s SAMIPATS(efmdate,zi,"cefud")=cefud
"RTN","SAMIUR",341,0)
 . . . s SAMIPATS(efmdate,zi,"cedos")=cedos
"RTN","SAMIUR",342,0)
 . . . s SAMIPATS(efmdate,zi,"ceform")=ceform
"RTN","SAMIUR",343,0)
 . . . s SAMIPATS(efmdate,zi,"siform")=siform
"RTN","SAMIUR",344,0)
 . . . m SAMIPATS(efmdate,zi,"items")=items
"RTN","SAMIUR",345,0)
 . . s datephrase=" after "_$$VAPALSDT^SAMICASE(fmstrdt)
"RTN","SAMIUR",346,0)
 . ;
"RTN","SAMIUR",347,0)
 . ; date filter for all the rest of the reports
"RTN","SAMIUR",348,0)
 . ;
"RTN","SAMIUR",349,0)
 . i efmdate<fmstrdt q  ; before the start date
"RTN","SAMIUR",350,0)
 . i efmdate>(fmenddt+1) q  ; after the end date
"RTN","SAMIUR",351,0)
 . ;
"RTN","SAMIUR",352,0)
 . i type="incomplete" d  ;
"RTN","SAMIUR",353,0)
 . . n complete s complete=1
"RTN","SAMIUR",354,0)
 . . n zj s zj=""
"RTN","SAMIUR",355,0)
 . . n gr s gr=$na(@root@("graph",sid))
"RTN","SAMIUR",356,0)
 . . f  s zj=$o(@gr@(zj)) q:zj=""  d  ;
"RTN","SAMIUR",357,0)
 . . . i $g(@gr@(zj,"samistatus"))="incomplete" d  ;
"RTN","SAMIUR",358,0)
 . . . . s complete=0
"RTN","SAMIUR",359,0)
 . . . . s SAMIPATS(efmdate,zi,"iform")=$g(SAMIPATS(efmdate,zi,"iform"))_" "_zj
"RTN","SAMIUR",360,0)
 . . i complete=0 d  ; has incomplete form(s) 
"RTN","SAMIUR",361,0)
 . . . s SAMIPATS(efmdate,zi,"edate")=edate
"RTN","SAMIUR",362,0)
 . . . s SAMIPATS(efmdate,zi)=""
"RTN","SAMIUR",363,0)
 . . . i ceform="" s cefud="baseline"
"RTN","SAMIUR",364,0)
 . . . s SAMIPATS(efmdate,zi,"cefud")=cefud
"RTN","SAMIUR",365,0)
 . . . s SAMIPATS(efmdate,zi,"ceform")=ceform
"RTN","SAMIUR",366,0)
 . . . s SAMIPATS(efmdate,zi,"siform")=siform
"RTN","SAMIUR",367,0)
 . . . m SAMIPATS(efmdate,zi,"items")=items
"RTN","SAMIUR",368,0)
 . . s datephrase=""
"RTN","SAMIUR",369,0)
 . . q
"RTN","SAMIUR",370,0)
 . i type="missingct" d  ;
"RTN","SAMIUR",371,0)
 . . i ceform="" d  ; has incomplete form(s) 
"RTN","SAMIUR",372,0)
 . . . s SAMIPATS(efmdate,zi,"edate")=edate
"RTN","SAMIUR",373,0)
 . . . s SAMIPATS(efmdate,zi)=""
"RTN","SAMIUR",374,0)
 . . . i ceform="" s cefud="baseline"
"RTN","SAMIUR",375,0)
 . . . s SAMIPATS(efmdate,zi,"cefud")=cefud
"RTN","SAMIUR",376,0)
 . . . s SAMIPATS(efmdate,zi,"ceform")=ceform
"RTN","SAMIUR",377,0)
 . . . s SAMIPATS(efmdate,zi,"siform")=siform
"RTN","SAMIUR",378,0)
 . . . m SAMIPATS(efmdate,zi,"items")=items
"RTN","SAMIUR",379,0)
 . . s datephrase=""
"RTN","SAMIUR",380,0)
 . . q
"RTN","SAMIUR",381,0)
 . i type="outreach" d  ;
"RTN","SAMIUR",382,0)
 . . q
"RTN","SAMIUR",383,0)
 . i type="enrollment" d  ;
"RTN","SAMIUR",384,0)
 . . s SAMIPATS(efmdate,zi,"edate")=edate
"RTN","SAMIUR",385,0)
 . . s SAMIPATS(efmdate,zi)=""
"RTN","SAMIUR",386,0)
 . . s SAMIPATS(efmdate,zi,"cefud")=cefud
"RTN","SAMIUR",387,0)
 . . s SAMIPATS(efmdate,zi,"ceform")=ceform
"RTN","SAMIUR",388,0)
 . . s SAMIPATS(efmdate,zi,"cedos")=cedos
"RTN","SAMIUR",389,0)
 . . s SAMIPATS(efmdate,zi,"siform")=siform
"RTN","SAMIUR",390,0)
 . . m SAMIPATS(efmdate,zi,"items")=items
"RTN","SAMIUR",391,0)
 . s datephrase=" as of "_$$VAPALSDT^SAMICASE($$NOW^XLFDT)
"RTN","SAMIUR",392,0)
 ;
"RTN","SAMIUR",393,0)
 quit  ; end of SELECT
"RTN","SAMIUR",394,0)
 ;
"RTN","SAMIUR",395,0)
 ;
"RTN","SAMIUR",396,0)
 ;
"RTN","SAMIUR",397,0)
UNMAT(SAMIPATS,ztype,datephrase,filter) ;
"RTN","SAMIUR",398,0)
 ;
"RTN","SAMIUR",399,0)
 s datephrase="Unmatched Persons"
"RTN","SAMIUR",400,0)
 n lroot s lroot=$$setroot^%wd("patient-lookup")
"RTN","SAMIUR",401,0)
 n dfn s dfn=9000000
"RTN","SAMIUR",402,0)
 f  s dfn=$o(@lroot@("dfn",dfn)) q:+dfn=0  d  ;
"RTN","SAMIUR",403,0)
 . n ien s ien=$o(@lroot@("dfn",dfn,""))
"RTN","SAMIUR",404,0)
 . q:ien=""
"RTN","SAMIUR",405,0)
 . i $g(@lroot@(ien,"remotedfn"))'="" q  ;
"RTN","SAMIUR",406,0)
 . m SAMIPATS(ien,dfn)=@lroot@(ien)
"RTN","SAMIUR",407,0)
 . ;new name set name=$g(SAMIPATS(ien,dfn,"saminame"))
"RTN","SAMIUR",408,0)
 . new name set name=$g(SAMIPATS(ien,dfn,"sinamef"))
"RTN","SAMIUR",409,0)
 . set name=name_","_SAMIPATS(ien,dfn,"sinamel")
"RTN","SAMIUR",410,0)
 . new nuhref set nuhref="<form method=POST action=""/vapals"">"
"RTN","SAMIUR",411,0)
 . set nuhref=nuhref_"<input type=hidden name=""samiroute"" value=""editperson"">"
"RTN","SAMIUR",412,0)
 . set nuhref=nuhref_"<input type=hidden name=""dfn"" value="_dfn_">"
"RTN","SAMIUR",413,0)
 . set nuhref=nuhref_"<input value="""_name_""" class=""btn btn-link"" role=""link"" type=""submit""></form>"
"RTN","SAMIUR",414,0)
 . s SAMIPATS(ien,dfn,"editref")=nuhref
"RTN","SAMIUR",415,0)
 ;
"RTN","SAMIUR",416,0)
 quit  ; end of UNMAT
"RTN","SAMIUR",417,0)
 ;
"RTN","SAMIUR",418,0)
 ;
"RTN","SAMIUR",419,0)
 ;
"RTN","SAMIUR",420,0)
WKLIST(SAMIPATS,ztype,datephrase,filter) ;
"RTN","SAMIUR",421,0)
 ;
"RTN","SAMIUR",422,0)
 ; add site
"RTN","SAMIUR",423,0)
 ; add compare to vapals-patients
"RTN","SAMIUR",424,0)
 ; add navigation to enrollment
"RTN","SAMIUR",425,0)
 ;
"RTN","SAMIUR",426,0)
 k ^gpl("worklist")
"RTN","SAMIUR",427,0)
 m ^gpl("worklist")=filter
"RTN","SAMIUR",428,0)
 n site
"RTN","SAMIUR",429,0)
 s site=$g(filter("siteid"))
"RTN","SAMIUR",430,0)
 q:site=""
"RTN","SAMIUR",431,0)
 s datephrase="Work List"
"RTN","SAMIUR",432,0)
 n lroot s lroot=$$setroot^%wd("patient-lookup")
"RTN","SAMIUR",433,0)
 n proot s proot=$$setroot^%wd("vapals-patients")
"RTN","SAMIUR",434,0)
 n dfn s dfn=0
"RTN","SAMIUR",435,0)
 f  s dfn=$o(@lroot@("dfn",dfn)) q:+dfn=0  d  ;
"RTN","SAMIUR",436,0)
 . q:$o(@proot@("dfn",dfn,""))'=""
"RTN","SAMIUR",437,0)
 . n ien s ien=$o(@lroot@("dfn",dfn,""))
"RTN","SAMIUR",438,0)
 . q:ien=""
"RTN","SAMIUR",439,0)
 . ;w !,"dfn= ",dfn
"RTN","SAMIUR",440,0)
 . ;zwr @lroot@(ien,*)
"RTN","SAMIUR",441,0)
 . q:$g(@lroot@(ien,"siteid"))'=site
"RTN","SAMIUR",442,0)
 . m ^gpl("worklist","lroot",ien)=@lroot@(ien)
"RTN","SAMIUR",443,0)
 . m SAMIPATS(ien,dfn)=@lroot@(ien)
"RTN","SAMIUR",444,0)
 . new name set name=$g(SAMIPATS(ien,dfn,"saminame"))
"RTN","SAMIUR",445,0)
 . ;new name set name=$g(SAMIPATS(ien,dfn,"sinamef"))
"RTN","SAMIUR",446,0)
 . ;set name=name_","_SAMIPATS(ien,dfn,"sinamel")
"RTN","SAMIUR",447,0)
 . new nuhref set nuhref="<form method=POST action=""/vapals"">"
"RTN","SAMIUR",448,0)
 . set nuhref=nuhref_"<input type=hidden name=""samiroute"" value=""newcase"">"
"RTN","SAMIUR",449,0)
 . set nuhref=nuhref_"<input type=hidden name=""dfn"" value="_dfn_">"
"RTN","SAMIUR",450,0)
 . set nuhref=nuhref_"<input type=hidden name=""siteid"" value="_site_">"
"RTN","SAMIUR",451,0)
 . set nuhref=nuhref_"<input value="""_name_""" class=""btn btn-link"" role=""link"" type=""submit""></form>"
"RTN","SAMIUR",452,0)
 . s SAMIPATS(ien,dfn,"workref")=nuhref
"RTN","SAMIUR",453,0)
 m ^gpl("worklist","pats")=SAMIPATS
"RTN","SAMIUR",454,0)
 ;
"RTN","SAMIUR",455,0)
 quit  ; end of WKLIST
"RTN","SAMIUR",456,0)
 ;
"RTN","SAMIUR",457,0)
 ;
"RTN","SAMIUR",458,0)
 ;
"RTN","SAMIUR",459,0)
PNAME(type,phrase) ; extrinsic returns the PAGE NAME for the report
"RTN","SAMIUR",460,0)
 ;
"RTN","SAMIUR",461,0)
 ;i type="followup" q "Followup next 30 days -"_$g(phrase)
"RTN","SAMIUR",462,0)
 i type="followup" q "Followup "_$g(phrase)
"RTN","SAMIUR",463,0)
 ;i type="activity" q "Activity last 30 days -"_$g(phrase)
"RTN","SAMIUR",464,0)
 i type="activity" q "Activity "_$g(phrase)
"RTN","SAMIUR",465,0)
 i type="missingct" q "Intake but no CT Evaluation"_$g(phrase)
"RTN","SAMIUR",466,0)
 i type="incomplete" q "Incomplete Forms"_$g(phrase)
"RTN","SAMIUR",467,0)
 i type="outreach" q "Outreach"_$g(phrase)
"RTN","SAMIUR",468,0)
 i type="enrollment" q "Enrollment"_$g(phrase)
"RTN","SAMIUR",469,0)
 ;
"RTN","SAMIUR",470,0)
 quit "" ; end of $$PNAME
"RTN","SAMIUR",471,0)
 ;
"RTN","SAMIUR",472,0)
 ;
"RTN","SAMIUR",473,0)
 ;
"RTN","SAMIUR",474,0)
EOR ; end of SAMIUR
"VER")
8.0^22.2
**END**
**END**
