YTQREST ;SLC/KCM - RESTful API front controller ; 1/25/2017
;;5.01;MENTAL HEALTH;**158,178,182,181,187,199,202,204,208,223,238,239,249**;Dec 30, 1994;Build 30
;
; Reference to EN^XPAR in ICR #2263
; Reference to XUP in ICR #4409
;
; .HTTPREQ: HTTP-formatted request and JSON body (if present)
; .HTTPRSP: HTTP-formatted response and JSON body (if present)
;
QADMIN(HTTPRSP,HTTPREQ) ; questionnaire administration resources
;;GET /api/mha/getconn/ GETCONN^YTQREST
;;GET /api/mha/dtime/ GETDTIM^YTQREST
;;GET /api/mha/rbac/ RBAC^YTQRQAD7
;;GET /api/mha/patient/:dfn/identifiers PID^YTQRQAD
;;GET /api/mha/patient/:dfn/name NM4DFN^YTQRQAD
;;GET /api/mha/persons PERSONS^YTQRQAD
;;GET /api/mha/persons/:match PERSONS^YTQRQAD
;;GET /api/mha/user/:duz/name NM4DUZ^YTQRQAD
;;GET /api/mha/users/:match/:adminId USERS^YTQRQAD
;;GET /api/mha/instruments/active LSTALL^YTQRQAD
;;GET /api/mha/instruments/cprs LSTCPRS^YTQRQAD
;;GET /api/mha/instrument/:instrumentName GETSPEC^YTQRQAD
;;GET /api/mha/checks/:instrumentName GETCHKS^YTQRQAD2
;;POST /api/mha/assignment NEWASMT^YTQRQAD1
;;POST /api/mha/assignment/edit/:assignmentId?1.N EDITASMT^YTQRQAD5
;;GET /api/mha/assignment/:assignmentId?1.N ASMTBYID^YTQRQAD1
;;GET /api/mha/assignment/:assignmentId?1.N/:division ASMTBYID^YTQRQAD1
;;GET /api/mha/assignment/:assignmentId?36ANP ASMTBYID^YTQRQAD1
;;GET /api/mha/assignment/:assignmentId?36ANP/:division ASMTBYID^YTQRQAD1
;;GET /api/mha/assignment/graph/:dfn/:instrument GETGRAPH^YTQRQAD5
;;DELETE /api/mha/assignment/:assignmentId TRSASMT^YTQRQAD1
;;DELETE /api/mha/assignment/:assignmentId/:instrument/:delfrmassign DELTEST^YTQRQAD1
;;DELETE /api/mha/assignment/:assignmentId/:instrument DELTEST^YTQRQAD1
;;POST /api/mha/instrument/admin SAVEADM^YTQRQAD2
;;GET /api/mha/instrument/admin/:adminId?1.N GETADM^YTQRQAD2
;;GET /api/mha/instrument/admin/:adminId?36ANP1"-".N GETADM^YTQRQAD2
;;GET /api/mha/instrument/report/:adminId?1.N REPORT^YTQRQAD3
;;GET /api/mha/instrument/note/:adminId?1.N GETNOTE^YTQRQAD3
;;POST /api/mha/instrument/note SETNOTE^YTQRQAD3
;;DELETE /api/mha/instrument/mhadmin/:adminId?1.N DELMHAD^YTQRQAD1
;;GET /api/mha/permission/cosign/:adminId/:userId ALWCSGN^YTQRQAD3
;;GET /api/mha/permission/needcosign/:userId NEEDCSGN^YTQRQAD3
;;GET /api/mha/instrument/list/:dfn?1.N GETLIST^YTQRQAD4
;;GET /api/mha/location/list GETLOCS^YTQRQAD4
;;GET /api/mha/location/list/:locmatch GETLOCS^YTQRQAD4
;;GET /api/mha/location/name/:locId?1.N GETLNAM^YTQRQAD4
;;GET /api/mha/category/list GETCATA^YTQRQAD4
;;GET /api/mha/specialgraph/interptext GETINTRP^YTQRQAD4
;;GET /api/mha/assignment/list/:dfn?1.N ASMTLST^YTQRQAD4
;;GET /api/mha/consult/list/:dfn?1.N GETCONS^YTQRQAD7
;;GET /api/mha/assignment/staff/:assignmentId?1.N ASMTSTAF^YTQRQAD7
;;GET /api/mha/assignmentparam/pref GETASMTP^YTQRQAD7
;;POST /api/mha/assignmentparam/pref SETASMTP^YTQRQAD7
;;GET /api/mha/instrument/lists/fav/userfav GETIFAV^YTQRQAD7
;;POST /api/mha/instrument/lists/fav/userfav SETIFAV^YTQRQAD7
;;GET /api/mha/instrument/lists/batteries/userbat GETBAT^YTQRQAD7
;;POST /api/mha/instrument/lists/batteries/userbat SETBAT^YTQRQAD7
;;GET /api/mha/instrument/comments/:adminId?1.N LOADCOM^YTQRQAD7
;;POST /api/mha/instrument/comments SETCOM^YTQRQAD3
;;GET /api/mha/instrumentgraph/prefs GETGRAPH^YTQRQAD7
;;POST /api/mha/instrumentgraph/prefs SETGRAPH^YTQRQAD7
;;GET /api/mha/specialgraph/rptpref GETSPCLG^YTQRQAD7
;;POST /api/mha/specialgraph/rptpref SETSPCLG^YTQRQAD7
;;GET /api/mha/reports/rptpref GETRPT^YTQRQAD7
;;POST /api/mha/reports/rptpref SETRPT^YTQRQAD7
;;GET /api/mha/notes/noteprefs GETNP^YTQRQAD7
;;POST /api/mha/notes/noteprefs SETNP^YTQRQAD7
;;GET /api/mha/instrument/description/:instrumentName GINSTD^YTQRQAD
;;GET /api/mha/assignment/cat/:assignmentId?1.N GCATINFO^YTQRCAT
;;GET /api/mha/assignment/cat/:assignmentId?36ANP GCATINFO^YTQRCAT
;;POST /api/mha/assignment/cat/:assignmentId?1.N PCATINFO^YTQRCAT
;;POST /api/mha/assignment/cat/:assignmentId?36ANP PCATINFO^YTQRCAT
;;GET /api/mha/cat/interview/:interviewId GETCATI^YTQRCAT
;;POST /api/mha/cat/interview/:interviewId SETCATI^YTQRCAT
;;POST /api/wrapper/close WRCLOSE^YTQRQAD
;;GET /api/dashboard/widget/:widgetName WEBWIDG^YSBRPC
;;GET /api/dashboard/highrisk/cssrs/:adminId WEBRPRT^YSBDD1
;;GET /api/dashboard/highrisk/hrpp/:dfn WEBPROF^YSBDD1
;;GET /api/dashboard/highrisk/note/:noteId WEBNOTE^YSBDD1
;;GET /api/dashboard/userpref WEBGUSRP^YTQRQAD7
;;POST /api/dashboard/userpref WEBPUSRP^YTQRQAD7
;;GET /api/mha/cdb/patient/pid/:dfn PID2^YTQRCDB2
;;GET /api/mha/cdb/timezone/ TZ^YTQRCDB2
;;GET /api/mha/cdb/instrument/list/:dfn?1.N GETLIST^YTQRCDB2
;;GET /api/mha/cdb/instrument/adminlist/:dfn/:instrumentName GETALST^YTQRCDB2
;;GET /api/mha/cdb/namelist/poi/:poilist GETPAT^YTQRCDB5
;;GET /api/mha/cdb/namelist/doc/:doclist GETDOC^YTQRCDB5
;;POST /api/mha/cdb/instrument/admin SAVEADM^YTQRCDB
;;POST /api/mha/cdb/instrument/admin/scores SCORADM^YTQRCDB
;;POST /api/mha/cdb/instrument/admin/reviewed RVW^YTQRCDB
;;POST /api/mha/cdb/instrument/note SETNOTE^YTQRCDB3
;;
D HANDLE^YTQRUTL("QADMIN^YTQREST",.HTTPREQ,.HTTPRSP)
Q
;Removed from list above 4/30/19
;;GET /api/mha/assignment/:lastName/:last4?4N ASMTBYNM^YTQRQAD1
;Removed 7/16/20
;;GET /api/mha/division/current/ TMPDIV^YTQRQAD
QENTRY(HTTPRSP,HTTPREQ) ; questionnaire entry for patient
;;GET /api/mha/patient/:dfn/identifiers PID^YTQRQAD
;;GET /api/mha/instrument/:instrumentName GETSPEC^YTQRQAD
;;GET /api/mha/checks/:instrumentName GETCHKS^YTQRQAD2
;;GET /api/mha/assignment/:assignmentId?1.N ASMTBYID^YTQRQAD1
;;GET /api/mha/instrument/admin/:adminId?1.N GETADM^YTQRQAD2
;;POST /api/mha/instrument/admin SAVEADM^YTQRQAD2
;;GET /api/mha/assignment/cat/:assignmentId?1.N GCATINFO^YTQRCAT
;;POST /api/mha/assignment/cat/:assignmentId?1.N PCATINFO^YTQRCAT
;;GET /api/mha/cat/interview/:interviewId GETCATI^YTQRCAT
;;POST /api/mha/cat/interview/:interviewId SETCATI^YTQRCAT
;;
D HANDLE^YTQRUTL("QENTRY^YTQREST",.HTTPREQ,.HTTPRSP)
Q
; removed
;;GET /api/mha/assignment/:lastName/:last4?4N ASMTBYNM^YTQRQAD1
QSETUP(HTTPRSP,HTTPREQ) ; questionnaire setup resources
Q
REVIEW(HTTPRSP,HTTPREQ) ; results review resources
Q
ASI(HTTPRSP,HTTPREQ) ; addiction severity index resources
Q
GETCONN(ARGS,RESULTS) ;Respond to the connection check
N DATAOUT,ERRARY,JSONOUT
K ^TMP("YTQ-JSON",$J)
S DATAOUT("connection","status")="OK"
S DATAOUT("connection","datetime")=$$HTE^XLFDT($H,2)
D ENCODE^XLFJSON("DATAOUT","JSONOUT","ERRARY")
S ^TMP("YTQ-JSON",$J,1,0)=JSONOUT(1)
S RESULTS=$NA(^TMP("YTQ-JSON",$J))
Q
GETDTIM(ARGS,RESULTS) ;Return user DTIME timeout
N DATAOUT,ERRARY,JSONOUT,YSDTIME
K ^TMP("YTQ-JSON",$J)
S YSDTIME=$$DTIME^XUP(DUZ) ;User level first
S:+YSDTIME=0 YSDTIME=$$GET^XPAR("USR^SYS","ORWOR TIMEOUT CHART",1,"I") ;ORWOR 2nd
I 'YSDTIME,$G(DTIME) S YSDTIME=DTIME ;Default last
S DATAOUT("timeout","dtime")=$G(DTIME)
D ENCODE^XLFJSON("DATAOUT","JSONOUT","ERRARY")
S ^TMP("YTQ-JSON",$J,1,0)=JSONOUT(1)
S RESULTS=$NA(^TMP("YTQ-JSON",$J))
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HYTQREST 7222 printed Sep 15, 2024@21:42:52 Page 2
YTQREST ;SLC/KCM - RESTful API front controller ; 1/25/2017
+1 ;;5.01;MENTAL HEALTH;**158,178,182,181,187,199,202,204,208,223,238,239,249**;Dec 30, 1994;Build 30
+2 ;
+3 ; Reference to EN^XPAR in ICR #2263
+4 ; Reference to XUP in ICR #4409
+5 ;
+6 ; .HTTPREQ: HTTP-formatted request and JSON body (if present)
+7 ; .HTTPRSP: HTTP-formatted response and JSON body (if present)
+8 ;
QADMIN(HTTPRSP,HTTPREQ) ; questionnaire administration resources
+1 ;;GET /api/mha/getconn/ GETCONN^YTQREST
+2 ;;GET /api/mha/dtime/ GETDTIM^YTQREST
+3 ;;GET /api/mha/rbac/ RBAC^YTQRQAD7
+4 ;;GET /api/mha/patient/:dfn/identifiers PID^YTQRQAD
+5 ;;GET /api/mha/patient/:dfn/name NM4DFN^YTQRQAD
+6 ;;GET /api/mha/persons PERSONS^YTQRQAD
+7 ;;GET /api/mha/persons/:match PERSONS^YTQRQAD
+8 ;;GET /api/mha/user/:duz/name NM4DUZ^YTQRQAD
+9 ;;GET /api/mha/users/:match/:adminId USERS^YTQRQAD
+10 ;;GET /api/mha/instruments/active LSTALL^YTQRQAD
+11 ;;GET /api/mha/instruments/cprs LSTCPRS^YTQRQAD
+12 ;;GET /api/mha/instrument/:instrumentName GETSPEC^YTQRQAD
+13 ;;GET /api/mha/checks/:instrumentName GETCHKS^YTQRQAD2
+14 ;;POST /api/mha/assignment NEWASMT^YTQRQAD1
+15 ;;POST /api/mha/assignment/edit/:assignmentId?1.N EDITASMT^YTQRQAD5
+16 ;;GET /api/mha/assignment/:assignmentId?1.N ASMTBYID^YTQRQAD1
+17 ;;GET /api/mha/assignment/:assignmentId?1.N/:division ASMTBYID^YTQRQAD1
+18 ;;GET /api/mha/assignment/:assignmentId?36ANP ASMTBYID^YTQRQAD1
+19 ;;GET /api/mha/assignment/:assignmentId?36ANP/:division ASMTBYID^YTQRQAD1
+20 ;;GET /api/mha/assignment/graph/:dfn/:instrument GETGRAPH^YTQRQAD5
+21 ;;DELETE /api/mha/assignment/:assignmentId TRSASMT^YTQRQAD1
+22 ;;DELETE /api/mha/assignment/:assignmentId/:instrument/:delfrmassign DELTEST^YTQRQAD1
+23 ;;DELETE /api/mha/assignment/:assignmentId/:instrument DELTEST^YTQRQAD1
+24 ;;POST /api/mha/instrument/admin SAVEADM^YTQRQAD2
+25 ;;GET /api/mha/instrument/admin/:adminId?1.N GETADM^YTQRQAD2
+26 ;;GET /api/mha/instrument/admin/:adminId?36ANP1"-".N GETADM^YTQRQAD2
+27 ;;GET /api/mha/instrument/report/:adminId?1.N REPORT^YTQRQAD3
+28 ;;GET /api/mha/instrument/note/:adminId?1.N GETNOTE^YTQRQAD3
+29 ;;POST /api/mha/instrument/note SETNOTE^YTQRQAD3
+30 ;;DELETE /api/mha/instrument/mhadmin/:adminId?1.N DELMHAD^YTQRQAD1
+31 ;;GET /api/mha/permission/cosign/:adminId/:userId ALWCSGN^YTQRQAD3
+32 ;;GET /api/mha/permission/needcosign/:userId NEEDCSGN^YTQRQAD3
+33 ;;GET /api/mha/instrument/list/:dfn?1.N GETLIST^YTQRQAD4
+34 ;;GET /api/mha/location/list GETLOCS^YTQRQAD4
+35 ;;GET /api/mha/location/list/:locmatch GETLOCS^YTQRQAD4
+36 ;;GET /api/mha/location/name/:locId?1.N GETLNAM^YTQRQAD4
+37 ;;GET /api/mha/category/list GETCATA^YTQRQAD4
+38 ;;GET /api/mha/specialgraph/interptext GETINTRP^YTQRQAD4
+39 ;;GET /api/mha/assignment/list/:dfn?1.N ASMTLST^YTQRQAD4
+40 ;;GET /api/mha/consult/list/:dfn?1.N GETCONS^YTQRQAD7
+41 ;;GET /api/mha/assignment/staff/:assignmentId?1.N ASMTSTAF^YTQRQAD7
+42 ;;GET /api/mha/assignmentparam/pref GETASMTP^YTQRQAD7
+43 ;;POST /api/mha/assignmentparam/pref SETASMTP^YTQRQAD7
+44 ;;GET /api/mha/instrument/lists/fav/userfav GETIFAV^YTQRQAD7
+45 ;;POST /api/mha/instrument/lists/fav/userfav SETIFAV^YTQRQAD7
+46 ;;GET /api/mha/instrument/lists/batteries/userbat GETBAT^YTQRQAD7
+47 ;;POST /api/mha/instrument/lists/batteries/userbat SETBAT^YTQRQAD7
+48 ;;GET /api/mha/instrument/comments/:adminId?1.N LOADCOM^YTQRQAD7
+49 ;;POST /api/mha/instrument/comments SETCOM^YTQRQAD3
+50 ;;GET /api/mha/instrumentgraph/prefs GETGRAPH^YTQRQAD7
+51 ;;POST /api/mha/instrumentgraph/prefs SETGRAPH^YTQRQAD7
+52 ;;GET /api/mha/specialgraph/rptpref GETSPCLG^YTQRQAD7
+53 ;;POST /api/mha/specialgraph/rptpref SETSPCLG^YTQRQAD7
+54 ;;GET /api/mha/reports/rptpref GETRPT^YTQRQAD7
+55 ;;POST /api/mha/reports/rptpref SETRPT^YTQRQAD7
+56 ;;GET /api/mha/notes/noteprefs GETNP^YTQRQAD7
+57 ;;POST /api/mha/notes/noteprefs SETNP^YTQRQAD7
+58 ;;GET /api/mha/instrument/description/:instrumentName GINSTD^YTQRQAD
+59 ;;GET /api/mha/assignment/cat/:assignmentId?1.N GCATINFO^YTQRCAT
+60 ;;GET /api/mha/assignment/cat/:assignmentId?36ANP GCATINFO^YTQRCAT
+61 ;;POST /api/mha/assignment/cat/:assignmentId?1.N PCATINFO^YTQRCAT
+62 ;;POST /api/mha/assignment/cat/:assignmentId?36ANP PCATINFO^YTQRCAT
+63 ;;GET /api/mha/cat/interview/:interviewId GETCATI^YTQRCAT
+64 ;;POST /api/mha/cat/interview/:interviewId SETCATI^YTQRCAT
+65 ;;POST /api/wrapper/close WRCLOSE^YTQRQAD
+66 ;;GET /api/dashboard/widget/:widgetName WEBWIDG^YSBRPC
+67 ;;GET /api/dashboard/highrisk/cssrs/:adminId WEBRPRT^YSBDD1
+68 ;;GET /api/dashboard/highrisk/hrpp/:dfn WEBPROF^YSBDD1
+69 ;;GET /api/dashboard/highrisk/note/:noteId WEBNOTE^YSBDD1
+70 ;;GET /api/dashboard/userpref WEBGUSRP^YTQRQAD7
+71 ;;POST /api/dashboard/userpref WEBPUSRP^YTQRQAD7
+72 ;;GET /api/mha/cdb/patient/pid/:dfn PID2^YTQRCDB2
+73 ;;GET /api/mha/cdb/timezone/ TZ^YTQRCDB2
+74 ;;GET /api/mha/cdb/instrument/list/:dfn?1.N GETLIST^YTQRCDB2
+75 ;;GET /api/mha/cdb/instrument/adminlist/:dfn/:instrumentName GETALST^YTQRCDB2
+76 ;;GET /api/mha/cdb/namelist/poi/:poilist GETPAT^YTQRCDB5
+77 ;;GET /api/mha/cdb/namelist/doc/:doclist GETDOC^YTQRCDB5
+78 ;;POST /api/mha/cdb/instrument/admin SAVEADM^YTQRCDB
+79 ;;POST /api/mha/cdb/instrument/admin/scores SCORADM^YTQRCDB
+80 ;;POST /api/mha/cdb/instrument/admin/reviewed RVW^YTQRCDB
+81 ;;POST /api/mha/cdb/instrument/note SETNOTE^YTQRCDB3
+82 ;;
+83 DO HANDLE^YTQRUTL("QADMIN^YTQREST",.HTTPREQ,.HTTPRSP)
+84 QUIT
+85 ;Removed from list above 4/30/19
+86 ;;GET /api/mha/assignment/:lastName/:last4?4N ASMTBYNM^YTQRQAD1
+87 ;Removed 7/16/20
+88 ;;GET /api/mha/division/current/ TMPDIV^YTQRQAD
QENTRY(HTTPRSP,HTTPREQ) ; questionnaire entry for patient
+1 ;;GET /api/mha/patient/:dfn/identifiers PID^YTQRQAD
+2 ;;GET /api/mha/instrument/:instrumentName GETSPEC^YTQRQAD
+3 ;;GET /api/mha/checks/:instrumentName GETCHKS^YTQRQAD2
+4 ;;GET /api/mha/assignment/:assignmentId?1.N ASMTBYID^YTQRQAD1
+5 ;;GET /api/mha/instrument/admin/:adminId?1.N GETADM^YTQRQAD2
+6 ;;POST /api/mha/instrument/admin SAVEADM^YTQRQAD2
+7 ;;GET /api/mha/assignment/cat/:assignmentId?1.N GCATINFO^YTQRCAT
+8 ;;POST /api/mha/assignment/cat/:assignmentId?1.N PCATINFO^YTQRCAT
+9 ;;GET /api/mha/cat/interview/:interviewId GETCATI^YTQRCAT
+10 ;;POST /api/mha/cat/interview/:interviewId SETCATI^YTQRCAT
+11 ;;
+12 DO HANDLE^YTQRUTL("QENTRY^YTQREST",.HTTPREQ,.HTTPRSP)
+13 QUIT
+14 ; removed
+15 ;;GET /api/mha/assignment/:lastName/:last4?4N ASMTBYNM^YTQRQAD1
QSETUP(HTTPRSP,HTTPREQ) ; questionnaire setup resources
+1 QUIT
REVIEW(HTTPRSP,HTTPREQ) ; results review resources
+1 QUIT
ASI(HTTPRSP,HTTPREQ) ; addiction severity index resources
+1 QUIT
GETCONN(ARGS,RESULTS) ;Respond to the connection check
+1 NEW DATAOUT,ERRARY,JSONOUT
+2 KILL ^TMP("YTQ-JSON",$JOB)
+3 SET DATAOUT("connection","status")="OK"
+4 SET DATAOUT("connection","datetime")=$$HTE^XLFDT($HOROLOG,2)
+5 DO ENCODE^XLFJSON("DATAOUT","JSONOUT","ERRARY")
+6 SET ^TMP("YTQ-JSON",$JOB,1,0)=JSONOUT(1)
+7 SET RESULTS=$NAME(^TMP("YTQ-JSON",$JOB))
+8 QUIT
GETDTIM(ARGS,RESULTS) ;Return user DTIME timeout
+1 NEW DATAOUT,ERRARY,JSONOUT,YSDTIME
+2 KILL ^TMP("YTQ-JSON",$JOB)
+3 ;User level first
SET YSDTIME=$$DTIME^XUP(DUZ)
+4 ;ORWOR 2nd
if +YSDTIME=0
SET YSDTIME=$$GET^XPAR("USR^SYS","ORWOR TIMEOUT CHART",1,"I")
+5 ;Default last
IF 'YSDTIME
IF $GET(DTIME)
SET YSDTIME=DTIME
+6 SET DATAOUT("timeout","dtime")=$GET(DTIME)
+7 DO ENCODE^XLFJSON("DATAOUT","JSONOUT","ERRARY")
+8 SET ^TMP("YTQ-JSON",$JOB,1,0)=JSONOUT(1)
+9 SET RESULTS=$NAME(^TMP("YTQ-JSON",$JOB))
+10 QUIT
+11 ;