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

SDECXML2.m

Go to the documentation of this file.
SDECXML2 ;ALB/JCH - SCHEDULING ENHANCEMENTS 3 UTILITIES ;11/03/14 10:59am
 ;;5.3;Scheduling;**628**;Aug 13, 1993;Build 371
 ;
 ;
PROVIDER(SDLCNT,SDRPTYP,SDAT,SDFAC,SDIV,SDGRP,SDCLN,SDPRV,DTINC,CLNTAG,GRPFLG,SDCALL,DTNAM,SDGALL,SDNODE) ; Provider
 N PRTOT,SDDATA,SDLG,APPTOT,APPLEN,SDSTPNAM,STSTP,SDACTAP,ACTOT,GRPCODE,ADJDIFF,ADJDEM,APPDEM,APPLEN
 N APPEST,APPNEW,APPOVR,DIC,DR,DTNAMAR,SDRESCH,SDSTP,STRING
 I ($G(SDGRP)=0)&(SDGALL=1) Q
 ;S DTNAM=$G(DTNAMAR(DTINC))
 S SDSTPNAM=$P($G(^SC(+$P(SDCLN,"^",2),0)),"^")
 ;
 ; Appointments - demand
 I SDIV="All",SDGRP="All" D  Q
 .D PRALALAL^SDECXML4(.SDLCNT,SDRPTYP,SDAT,SDFAC,SDIV,SDGRP,SDCLN,SDPRV,DTINC,DTNAM)
 ;
 I SDIV,SDGRP="All",$P(SDCLN,"^",2) D  Q
 .D PRALAL^SDECXML4(.SDLCNT,SDRPTYP,SDAT,SDFAC,SDIV,"All",SDCLN,SDPRV,DTINC,DTNAM)
 ;
 I SDIV="All" D
 .S APPTOT="",APPLEN="",SDACTAP="",APPDEM="",ACTOT="",SDSTP="",ADJDIFF="",ADJDEM="",ADJDEM=""
 .F  S APPLEN=$O(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"GRP",SDGRP,"CLIN",SDCLN,SDPRV,"APP","LEN",APPLEN)) Q:'APPLEN  D
 ..S SDSTP="" F  S SDSTP=$O(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"GRP",SDGRP,"CLIN",SDCLN,SDPRV,"APP","LEN",APPLEN,SDSTP)) Q:SDSTP=""  D
 ...Q:SDSTP="STAT"  S ACTOT=""
 ...;I '$G(GRPFLG) S SDFILT=$$GRP^SDECXML(SDGRP) D SETTMPF^SDECXML(.SDLCNT,SDFILT,13)
 ...S APPTOT=$G(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"GRP",SDGRP,"CLIN",SDCLN,SDPRV,"APP","LEN",APPLEN,SDSTP))
 ...S APPDEM=APPDEM+APPTOT
 ..S SDRESCH="" F  S SDRESCH=$O(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"GRP",SDGRP,"CLIN",SDCLN,SDPRV,"APP","LEN",APPLEN,"STAT",SDRESCH)) Q:SDRESCH=""  D
 ...Q:'($P(SDRESCH,";")="NSR"!($P(SDRESCH,";")="CPR")!($P(SDRESCH,";")="CCR"))
 ...S ADJDIFF=ADJDIFF+(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"GRP",SDGRP,"CLIN",SDCLN,SDPRV,"APP","LEN",APPLEN,"STAT",SDRESCH)*APPLEN)
 .S ADJDEM=APPDEM I ADJDIFF&APPDEM S ADJDEM=APPDEM-ADJDIFF
 .S ADJDEM=$S($G(ADJDIFF):ADJDEM,1:APPDEM)
 .D PARSE^SDECXML2(APPDEM,SDCLN,SDPRV,"DEM",APPLEN,SDSTP,ADJDEM)
 .;
 I $G(SDIV) D
 .S APPTOT="",APPLEN="",SDACTAP="",APPDEM="",ACTOT="",SDSTP="",ADJDIFF="",ADJDEM="",APPLEN=""
 .S APPLEN="" F  S APPLEN=$O(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,SDGRP,SDCLN,SDPRV,"APP","LEN",APPLEN)) Q:'APPLEN  D
 ..S SDSTP="" F  S SDSTP=$O(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,SDGRP,SDCLN,SDPRV,"APP","LEN",APPLEN,SDSTP)) Q:SDSTP=""  D
 ...Q:SDSTP="STAT"  S ACTOT=""
 ...I '$G(GRPFLG) S SDFILT=$$GRP^SDECXML(SDGRP) D SETTMPF^SDECXML(.SDLCNT,SDFILT,13)
 ...S APPTOT=$G(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,SDGRP,SDCLN,SDPRV,"APP","LEN",APPLEN,SDSTP))
 ...S APPDEM=APPDEM+APPTOT
 ..S SDRESCH="" F  S SDRESCH=$O(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,SDGRP,SDCLN,SDPRV,"APP","LEN",APPLEN,"STAT",SDRESCH)) Q:SDRESCH=""  D
 ...Q:'($P(SDRESCH,";")="NSR"!($P(SDRESCH,";")="CPR")!($P(SDRESCH,";")="CCR"))
 ...S ADJDIFF=ADJDIFF+(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,SDGRP,SDCLN,SDPRV,"APP","LEN",APPLEN,"STAT",SDRESCH)*APPLEN)
 .S ADJDEM=APPDEM I ADJDIFF&APPDEM S ADJDEM=APPDEM-ADJDIFF
 .S ADJDEM=$S($G(ADJDIFF):ADJDEM,1:APPDEM)
 .D PARSE^SDECXML2(APPDEM,SDCLN,SDPRV,"DEM",APPLEN,SDSTP,ADJDEM)
 .;
 ; Appointments - lengths
 S APPTOT="",APPLEN="",SDACTAP="",APPDEM="",ACTOT=""
 I SDIV="All" S APPLEN="" F  S APPLEN=$O(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"GRP",SDGRP,"CLIN",SDCLN,SDPRV,"APP","LEN",APPLEN)) Q:'APPLEN  D
 .S SDSTP="" F  S SDSTP=$O(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"GRP",SDGRP,"CLIN",SDCLN,SDPRV,"APP","LEN",APPLEN,SDSTP)) Q:SDSTP=""  D
 ..Q:SDSTP="STAT"  S ACTOT=""
 ..S APPTOT=$G(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"GRP",SDGRP,"CLIN",SDCLN,SDPRV,"APP","LEN",APPLEN,SDSTP))
 ..;Q:(APPTOT="")
 ..I '$G(GRPFLG) S SDFILT=$$GRP^SDECXML(SDGRP) D SETTMPF^SDECXML(.SDLCNT,SDFILT,13)
 ..S APPOVR=$P(APPTOT,"^",2),APPNEW=$P(APPTOT,"^",3),APPEST=$P(APPTOT,"^",4),ACTOT=APPNEW+APPEST
 ..I ACTOT D PARSE^SDECXML2(ACTOT,SDCLN,SDPRV,"APPACT",APPLEN,SDSTP)
 ..I APPOVR S SDDATA=$$PROV^SDECXML(SDPRV)_" "_$$OVRAP^SDECXML2(APPOVR,APPLEN,SDSTP) D SETREC^SDECXML(.SDLCNT,SDDATA,15)
 ..I APPNEW S SDDATA=$$PROV^SDECXML(SDPRV)_" "_$$NEWAP^SDECXML2(APPNEW,APPLEN,SDSTP) D SETREC^SDECXML(.SDLCNT,SDDATA,15)
 ..I APPEST S SDDATA=$$PROV^SDECXML(SDPRV)_" "_$$ESTAP^SDECXML2(APPEST,APPLEN,SDSTP) D SETREC^SDECXML(.SDLCNT,SDDATA,15)
 ;
 S APPTOT="",APPLEN="",SDACTAP="",APPDEM="",ACTOT=""
 I $G(SDIV) S APPLEN="" F  S APPLEN=$O(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,SDGRP,SDCLN,SDPRV,"APP","LEN",APPLEN)) Q:'APPLEN  D
 .S SDSTP="" F  S SDSTP=$O(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,SDGRP,SDCLN,SDPRV,"APP","LEN",APPLEN,SDSTP)) Q:SDSTP=""  D
 ..Q:SDSTP="STAT"  S ACTOT=""
 ..S APPTOT=$G(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,SDGRP,SDCLN,SDPRV,"APP","LEN",APPLEN,SDSTP))
 ..;Q:(APPTOT="")
 ..I '$G(GRPFLG) S SDFILT=$$GRP^SDECXML(SDGRP) D SETTMPF^SDECXML(.SDLCNT,SDFILT,13)
 ..S APPOVR=$P(APPTOT,"^",2),APPNEW=$P(APPTOT,"^",3),APPEST=$P(APPTOT,"^",4),ACTOT=APPNEW+APPEST
 ..I ACTOT D PARSE^SDECXML2(ACTOT,SDCLN,SDPRV,"APPACT",APPLEN,SDSTP)
 ..I APPOVR S SDDATA=$$PROV^SDECXML(SDPRV)_" "_$$OVRAP^SDECXML2(APPOVR,APPLEN,SDSTP) D SETREC^SDECXML(.SDLCNT,SDDATA,15)
 ..I APPNEW S SDDATA=$$PROV^SDECXML(SDPRV)_" "_$$NEWAP^SDECXML2(APPNEW,APPLEN,SDSTP) D SETREC^SDECXML(.SDLCNT,SDDATA,15)
 ..I APPEST S SDDATA=$$PROV^SDECXML(SDPRV)_" "_$$ESTAP^SDECXML2(APPEST,APPLEN,SDSTP) D SETREC^SDECXML(.SDLCNT,SDDATA,15)
 ;
 I $G(SDIV) S PRTOT=$G(^XTMP(SDNODE,DTNAM,SDRPTYP,SDAT,SDFAC,SDIV,SDGRP,SDCLN,SDPRV))
 I SDIV="All" S PRTOT=$G(^XTMP(SDNODE,"PROVIDER",DTNAM,SDRPTYP,SDAT,"GRP",SDGRP,"CLIN",SDCLN,SDPRV))
 I ($G(PRTOT)]"") N SDI F SDI=1:1:4 D
 .S SDDATA=$$PROV^SDECXML(SDPRV)_" "_$S(SDI=1:$$ENC^SDECXML($P(PRTOT,"^",SDI)),SDI=2:$$NEW^SDECXML($P(PRTOT,"^",SDI)),SDI=3:$$EST^SDECXML($P(PRTOT,"^",SDI)),SDI=4:$$TEL^SDECXML($P(PRTOT,"^",SDI)),1:"")
 .Q:($TR(SDDATA,"^","")="")
 .I '$G(GRPFLG) S SDFILT=$$GRP^SDECXML(SDGRP) D SETTMPF^SDECXML(.SDLCNT,SDFILT,13)
 .D SETREC^SDECXML(.SDLCNT,SDDATA,15)
 Q
 ;
DIVNAME(DIV) ; Division name
 K DIVNAME,DIC,DR
 I DIV="All" Q DIV
 N DIE,DIQ,DIR,DA,X,Y
 S DIQ(0)="I",DIC=40.8,DA=+$G(DIV),DR=".01"
 D GETS^DIQ(DIC,DA,DR,"I","DIVNAME")
 S DIVNAME=$G(DIVNAME(DIC,DA_",",.01,"I"))
 I DIVNAME=""!($L(DIVNAME)<3) S DIVNAME=$P($$SITE^VASITE(),"^",2)
 Q DIVNAME
 ;
OUTPUT(TEXT,PAD,SDLCNT,SDEBUG) ; Generic Set/Output
 I $G(XMLNODE)="" S XMLNODE=$S($G(SDFLTFLG):"FLTXML",1:"SDECXML")
 I TEXT["/Rg" S GRPFLG=0
 I TEXT["/Rs" S CLNTAG=0
 S SDLCNT=$G(SDLCNT)+1
 I $G(SDEBUG) U IO W:(SDLCNT>1) ! W ?PAD,TEXT
 S ^XTMP("SDVSE",XMLNODE,SDLCNT)=TEXT
 Q
 ;
CLINIC(SDLCNT,SDRPTYP,SDAT,SDFAC,SDIV,SDGRP,SDCLIN,DTINC,SDNODE,CLNTAG,SDCALL,GRPFLG,SDEBUG,XMLNODE) ; Clinic
 N CLTOT,SDFILT,SDMEAS,SDDATA,DTNAM,TMPCLIN,GRPTOT,PRGDTOT,SDCLDIV,ACTOT,SDCLNALL,SDCLPR
 S DTNAM=$G(DTNAMAR(DTINC))
 I '$G(SDCALL) D ALLCLIN^SDECXML5(.SDLCNT,SDRPTYP,SDAT,SDFAC,SDIV,SDGRP,DTINC,.CLNTAG,"",SDCALL,SDNODE,.GRPFLG,SDEBUG,XMLNODE)
 D ONECLIN^SDECXML4(.SDLCNT,SDRPTYP,SDAT,SDFAC,SDIV,SDGRP,SDCLIN,DTINC,"",SDEBUG,.CLNTAG,.GRPFLG,SDNODE,XMLNODE) ; Single Clinic
 ;
 Q
 ;
NEWAP(NEW,LEN,STOP) ; Return new patients
 N STOPNAM
 ;S STOPNAM=$$GRPNAM^SDECXML(STOP)
 S STOPNAM=$P($$GRPNAM^SDECXML(STOP),") ",2)
 S STRING="Mn="""_LEN_" Min Appointments - "_STOPNAM_""" Vt=""New Patients"" Vl="""_NEW_"""" Q STRING
ESTAP(EST,LEN,STOP) ; Return established patients
 N STOPNAM
 ;S STOPNAM=$$GRPNAM^SDECXML(STOP)
 S STOPNAM=$P($$GRPNAM^SDECXML(STOP),") ",2)
 S STRING="Mn="""_LEN_" Min Appointments - "_STOPNAM_""" Vt=""Established Patients"" Vl="""_EST_"""" Q STRING
OVRAP(OVR,LEN,STOP) ; Appointment 
 N STOPNAM
 S STOPNAM=$P($$GRPNAM^SDECXML(STOP),") ",2)
 S STRING="Mn="""_LEN_" Min Appointments - "_STOPNAM_""" Vt=""Overbooks"" Vl="""_OVR_""""
 Q STRING
ACTUALAP(ACTUAL,LEN,STOP) ; Appointment 
 N STOPNAM
 S STOPNAM=$P($$GRPNAM^SDECXML(STOP),") ",2)
 S STRING="Mn="""_LEN_" Min Appointments - "_STOPNAM_""" Vt=""Actual"" Vl="""_ACTUAL_""""
 Q STRING
 ;
PARSE(TOT,CL,PR,TYPE,LEN,STOP,ADJ) ; Get record attributes, write/set
 I $G(TYPE)="" D  Q
 .N SDI F SDI=1:1:4 D
 ..S SDDATA=$$PROV^SDECXML(PR)_" "_$S(SDI=1:$$ENC^SDECXML($P(TOT,"^",SDI)),SDI=2:$$NEW^SDECXML($P(TOT,"^",SDI)),SDI=3:$$EST^SDECXML($P(TOT,"^",SDI)),SDI=4:$$TEL^SDECXML($P(TOT,"^",SDI)),1:"")
 ..Q:($TR(SDDATA,"^","")="")
 ..D SETREC^SDECXML(.SDLCNT,SDDATA,15)
 ;
 I $G(TYPE)="OVR" D
 .S SDDATA=$$PROV^SDECXML(PR)_" "_$$RCAOVR^SDECXML($P(TOT,"^"))
 .Q:SDDATA=""
 .D SETREC^SDECXML(.SDLCNT,SDDATA,15)
 ;
 I $E($G(TYPE),1,3)="APP" D
 .S SDDATA=$$PROV^SDECXML(PR)_" "_$S(TYPE="APPOVR":$$OVRAP^SDECXML2(TOT,LEN,STOP),TYPE="APPNEW":$$NEWAP^SDECXML2(TOT,LEN,STOP),TYPE="APPEST":$$ESTAP^SDECXML2(TOT,LEN,STOP),TYPE="APPACT":$$ACTUALAP^SDECXML2(TOT,LEN,STOP),1:"")
 .Q:SDDATA=""
 .D SETREC^SDECXML(.SDLCNT,SDDATA,15)
 ;
 I $G(TYPE)="DEM" S SDDATA=$$PROV^SDECXML(PR)_" "_$$RCADEM^SDECXML(TOT) D
 .I $G(ADJ)<0
 .D SETREC^SDECXML(.SDLCNT,SDDATA,15)
 .S SDDATA=$$PROV^SDECXML(PR)_" "_$$RCADEMA^SDECXML($G(ADJ))
 .D SETREC^SDECXML(.SDLCNT,SDDATA,15)
 ;
 I $G(TYPE)="SUP" D
 .S SDDATA=$$PROV^SDECXML("All")_" "_$$RCASUP^SDECXML($P(TOT,"^"))
 .Q:SDDATA=""
 .D SETREC^SDECXML(.SDLCNT,SDDATA,15)
 Q