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

YTQRQAD8.m

Go to the documentation of this file.
  1. YTQRQAD8 ;BAL/KTL - RESTful Calls to set/get MHA Note ; 1/25/2017
  1. ;;5.01;MENTAL HEALTH;**199,207,202,204,208,250**;Dec 30, 1994;Build 26
  1. ;
  1. ; Reference to TIUCNSLT in ICR #5546
  1. ; Reference to TIUPUTU in ICR #3351
  1. ; Reference to TIUSRVA in ICR #5541
  1. ;
  1. Q
  1. SAVPNOT(ASGN,ADMIN,CONSULT,COSIGNER,YS) ;Save Progress Note Text in XTMP until session complete
  1. N NOD,LN,CNT,ADMCNT
  1. S NOD="YTQASMT-SET-"_ASGN
  1. I '$D(^XTMP(NOD)) D SETERROR^YTQRUTL(400,"Assignment Not Found") Q
  1. S CNT=$O(^XTMP(NOD,2,"PNOTE","TXT",""),-1)
  1. S ADMCNT=$O(^XTMP(NOD,2,"PNOTE","ADMINS",""),-1)
  1. S ADMCNT=ADMCNT+1,^XTMP(NOD,2,"PNOTE","ADMINS",ADMCNT)=ADMIN_U_$G(CONSULT)_U_$G(COSIGNER)
  1. I CNT'="" S CNT=CNT+1,$P(^XTMP(NOD,2,"PNOTE","TXT",CNT),"_",75)="" ;Add Note Divider
  1. S LN=0 F S LN=$O(YS(LN)) Q:+LN=0 D
  1. . S CNT=CNT+1,^XTMP(NOD,2,"PNOTE","TXT",CNT)=YS(LN)
  1. Q
  1. FILPNOT(ASGN,ADMIN,CONSULT,DATA,TMPYS,FRMDEL) ;File the aggregate Progress Note
  1. ;FRMDEL = If invoked from delete the last instrument and Aggregate Progress Note exists
  1. N YSADMIN,YSCONSULT,YSCOSIGNER,NOD,REMAIN,I
  1. N CNT,LN,YS,YSDATA
  1. I +ASGN=0 S ASGN=$G(DATA("assignmentId"))
  1. I +ASGN=0 D SETERROR^YTQRUTL(400,"No Assignment") Q 0
  1. S COSIGNER=$G(DATA("cosigner"))
  1. S FRMDEL=$G(FRMDEL)
  1. S NOD="YTQASMT-SET-"_ASGN
  1. I COSIGNER="",(+$G(^XTMP(NOD,1,"cosigner"))'=0) S COSIGNER=^XTMP(NOD,1,"cosigner")
  1. ;I '$D(^XTMP(NOD)) D SETERROR^YTQRUTL(400,"Assignment Not Found") Q 1 ;If no ^XTMP, must be only instrument
  1. S YSADMIN=$G(^XTMP(NOD,2,"PNOTE","ADMINS",1))
  1. I +YSADMIN'=0 D ;Previously filed first admin, override incoming parameters
  1. . S CONSULT=$P(YSADMIN,U,2),ADMIN=$P(YSADMIN,U)
  1. . I $P(YSADMIN,U,3)'="",(COSIGNER="") S COSIGNER=$P(YSADMIN,U,3) ;Only use if main assignment cosigner not set
  1. I +ADMIN=0 D SETERROR^YTQRUTL(400,"No Admin for Note") Q 2
  1. S CNT=$O(^XTMP(NOD,2,"PNOTE","TXT",""),-1)
  1. M YS=^XTMP(NOD,2,"PNOTE","TXT")
  1. I $D(TMPYS) D ;TMPYS is not sent if last action for Assignment was Save instrument Admin and not SAVE NOTE
  1. . I CNT'="" S CNT=CNT+1,$P(YS(CNT),"_",75)="" ;Add Note Divider
  1. . ; Add last instrument progress note text to previously saved Progress Note txt.
  1. . S LN=0 F S LN=$O(TMPYS(LN)) Q:+LN=0 D
  1. .. S CNT=CNT+1,YS(CNT)=TMPYS(LN)
  1. I COSIGNER]"" S YS("COSIGNER")=COSIGNER
  1. S YS("AD")=ADMIN
  1. I CONSULT S YS("CON")=CONSULT D CCREATE^YTQCONS(.YSDATA,.YS) I 1
  1. E D PCREATE^YTQTIU(.YSDATA,.YS)
  1. I YSDATA(1)'="[DATA]" D SETERROR^YTQRUTL(500,"Note not saved") Q 3
  1. ;Saved progress note for all completed instruments. If last instrument, Delete Assignment
  1. K ^XTMP(NOD,2) ;Kill Aggregate Progress Note
  1. S REMAIN=""
  1. S I=0 F S I=$O(^XTMP(NOD,1,"instruments",I)) Q:'I D
  1. . I $G(^XTMP(NOD,1,"instruments",I,"complete"))'="true" S REMAIN=1
  1. I 'REMAIN,(FRMDEL'=1),$D(^XTMP(NOD,0)) D DELASMT1^YTQRQAD1(ASGN) ;Last instrument OK to Kill Assignment
  1. K ^XTMP(NOD,2) ;KILL Filed progress note text
  1. Q $G(YSDATA(2))
  1. ;
  1. WEBGUSRP(ARGS,RESULTS) ;Get DB Col Pref
  1. N YSWPARR,JSONOUT
  1. K ^TMP("YTQ-JSON",$J)
  1. D GETPARAM^YTQRQAD7("YSB USER COLUMN PREFERENCE","",.YSWPARR)
  1. I $G(YSWPARR(1,0))="" D
  1. . K YSWPARR D DFLTUP(JSONOUT)
  1. . D TOTMP^YSBRPC(.JSONOUT)
  1. I $D(YSWPARR) M ^TMP("YTQ-JSON",$J)=YSWPARR
  1. S RESULTS=$NA(^TMP("YTQ-JSON",$J))
  1. Q
  1. WEBPUSRP(ARGS,DATA) ; Set DB Col Pref
  1. ;Requires HTTPREQ from YTQREST
  1. N YSRET
  1. S YSRET=$$SETPARAM^YTQRQAD7("YSB USER COLUMN PREFERENCE","/api/mha/dashboard/userpref/",.HTTPREQ,,"DASH COLS")
  1. Q YSRET
  1. DFLTUP(XJSON) ;
  1. N II,XDATA,XNAM,XJ,SPC,XCNT,XTABC
  1. S $P(SPC," ",10)=""
  1. S XCNT=1,XTABC=1,XJSON(XCNT)="{"
  1. D GETWDGT^YSBRPC(.XDATA)
  1. S II=0 F S II=$O(XDATA("widgets",II)) Q:+II=0 D
  1. . S XNAM=$G(XDATA("widgets",II,"name"))
  1. . S XNAM=$S(XNAM="HIGH RISK":"highRisk",XNAM="MBC":"measurementBased",1:XNAM)
  1. . K XDATA("widgets",II,"instrumentList")
  1. . K XDATA("widgets",II,"name")
  1. . M XJ(XNAM)=XDATA("widgets",II)
  1. . S XJ(XNAM,"display")="true"
  1. . S XJ(XNAM,"filterList","name")="name"
  1. . S XJ(XNAM,"filterList","value")=""
  1. D ENCODE^YSBJSON("XJ","XJSON","ERRARY")
  1. Q