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

MDKRPC2.m

Go to the documentation of this file.
  1. MDKRPC2 ; HOIFO/DP - RPC Calls (Cont.) ;11/27/07 09:42
  1. ;;1.0;CLINICAL PROCEDURES;**6**;Apr 01, 2004;Build 102
  1. ;
  1. ; Reference IA #1625 [Supported] Use routine XUA4A72
  1. ; #10060 [Supported] FILE 200 references
  1. ; #10112 [Supported] VASITE calls
  1. ; #10090 [Supported] Institution File (#4) Read w/FM
  1. ; #2263 [Supported] XPAR calls
  1. ; #4440 [Supported] XUPROD calls
  1. ; #3065 [Supported] XLFNAME calls
  1. ; #4815 [Controlled] GMVDCSAV call
  1. ; #4866 [Private] File 120.51
  1. ; #4867 [Private] File 120.5
  1. ; #4868 [Private] - VA(200,"AUSER"
  1. RPC(RESULTS,OPTION,P1,P2,P3,P4,P5,P6,P7,P8,P9) ; Generic RPC tag
  1. S RESULTS=$NA(^TMP($J,"MDKRPC2")) K @RESULTS
  1. D @OPTION
  1. S:'$D(@RESULTS) @RESULTS@(0)="-1^No Results"
  1. Q
  1. ;
  1. ACTIVE ; Return all active dialysis treatments
  1. N MDAS,MDFLD,MDLP,MDLIST,MDMORE K ^TMP("MDAS",$J)
  1. F MDLP=1,2 S MDLIST=0 F S MDLIST=$O(^MDK(704.202,"AS",MDLP,MDLIST)) Q:MDLIST<1 S ^TMP("MDAS",$J,MDLIST)=""
  1. S MDMORE=".03;;STUDY_CHECKIN^.05;;USER_ID^.06;;DATETIME_ACCESSED^.07;;WORKSTATION_ID"
  1. D BLDFLD^MDXMLFM(.MDFLD,704.202,".01;I;STUDY_ID^.02;I;PATIENT_ID^.02:.01;;PATIENT_NAME^.02:.09;;PATIENT_SSN^.09;E;STATUS^.02:.02;I;PATIENT_SEX^.02:.03;I;PATIENT_DOB;DATE^.02:.033;;PATIENT_AGE^.04;;STUDY_LOCATION^"_MDMORE)
  1. D LOADALL^MDXMLFM($NA(^TMP("MDAS",$J)),704.202,.MDFLD)
  1. K ^TMP("MDAS",$J)
  1. Q
  1. ;
  1. ALLBYPT ; Return all treatments for a patient
  1. N MDFLD
  1. D BLDFLD^MDXMLFM(.MDFLD,704.202,".01;I;STUDY_ID^.02;I;PATIENT_ID^.03;I;STUDY_DATETIME^.09;I;STATUS")
  1. D LOADALL^MDXMLFM($NA(^MDK(704.202,"C",+P1)),704.202,.MDFLD)
  1. Q
  1. ;
  1. ALLRSLT ; Get all available results for a study
  1. ;
  1. ; If P2=1 then whole list is forced, otherwise, only Unmatched
  1. ;
  1. N MDFLD,MDFDA,MDLIST
  1. D BLDFLD^MDXMLFM(.MDFLD,703.1,".001;;ID^.05;;STUDY_ID")
  1. ;D:'$G(P3) LOADALL^MDXMLFM($NA(^MDD(703.1,"ASTUDYID",+P1)),703.1,.MDFLD)
  1. ;
  1. ; Remove the P3 reference once it's working!
  1. ;
  1. ; Prepare the lists
  1. S MDLIST=$NA(^TMP("MDTEMP",$J)) K @MDLIST
  1. S MDFDA=$NA(^TMP("MDFDA",$J)) K @MDFDA
  1. ; Scan results by study id
  1. F X=0:0 S X=$O(^MDD(703.1,"ASTUDYID",+P1,X)) Q:'X D
  1. .Q:$P(^MDD(703.1,X,0),U,9)="P" ; Skip pendings being filed now
  1. .Q:'$G(P2)&($P(^MDD(703.1,X,0),U,9)="M") ; Only new results requested
  1. .S ^TMP("MDTEMP",$J,X)="" ; Add this study to the list
  1. D LOADALL^MDXMLFM(.MDLIST,703.1,.MDFLD)
  1. Q
  1. ;
  1. CCOW ; Return CCOW site and production indicator
  1. S @RESULTS@(0)=$P($$SITE^VASITE(),"^",3)_"^"_$$PROD^XUPROD()
  1. Q
  1. ;
  1. GETRSLT ; Get instrument XML Result
  1. I '$D(^MDD(703.1,P1,.4)) S @RESULTS@(0)="0" Q
  1. M @RESULTS=^MDD(703.1,P1,.4)
  1. S @RESULTS@(0)=+$O(^MDD(703.1,P1,.4,""),-1)
  1. ; Set to matched
  1. N MDFDA S MDFDA(703.1,P1_",",.09)="M" D FILE^DIE("","MDFDA")
  1. Q
  1. ;
  1. GETXML ; Get a single XML field
  1. S X=$$GET1^DIQ(P1,P2,P3,,RESULTS)
  1. Q
  1. ;
  1. SETXML ; Set a single XML field
  1. S @RESULTS@(0)=$$XMLFILER(P1,P2,P3,"P4")
  1. Q
  1. ;
  1. UPDUSER ; Update User Access Information
  1. Q:$G(P1)=""
  1. Q:$G(P2)=""
  1. Q:$G(P3)=""
  1. N MDFDA S P1=P1_","
  1. S:+P2 MDFDA(704.202,P1,.05)=P2
  1. S:P3'="" MDFDA(704.202,P1,.06)=P3
  1. S:P4'="" MDFDA(704.202,P1,.07)=P4
  1. S:+P5 MDFDA(704.202,P1,.09)=P5
  1. D FILE^DIE("","MDFDA")
  1. K MDFDA
  1. S @RESULTS@(0)="1^Information Filed"
  1. ;
  1. GETOPT ; Get option from the Parameters File
  1. ;
  1. ; P1=Setting Name
  1. ; P2=Owner
  1. ;
  1. N MDOPT
  1. S MDOPT=$$FIND1^DIC(704.209,,"X",P1,"B","I $P(^(0),U,2)=P2")
  1. I MDOPT<0 S @RESULTS@(0)="-1^No such setting" Q
  1. S X=$$GET1^DIQ(704.209,MDOPT_",",.1,,RESULTS)
  1. Q
  1. ;
  1. LOCKOPT ; Lock/Unlock an option for update
  1. ;
  1. ; P1=Setting Name
  1. ; P2=0:Unlock;1:Lock
  1. ;
  1. N MDOPT
  1. S MDOPT=$$FIND1^DIC(704.209,,"X",P1,"B","I $P(^(0),U,2)=.5")
  1. I 'MDOPT S @RESULTS@(0)="-1^No such setting." Q
  1. I 'P2 D Q
  1. .L -(^MDK(704.209,+MDOPT,0)) S @RESULTS@(0)="1^Option Unlocked"
  1. .N MDFDA
  1. .S MDFDA(704.209,+MDOPT_",",.03)=""
  1. .S MDFDA(704.209,+MDOPT_",",.04)=""
  1. .S MDFDA(704.209,+MDOPT_",",.05)=""
  1. .D FILE^DIE("","MDFDA")
  1. .Q
  1. I +P2 L +(^MDK(704.209,+MDOPT,0)):0 I '$T S @RESULTS@(0)="-1^Unable to lock"_"^"_$P($G(^MDK(704.209,+MDOPT,0)),"^",3,5) Q
  1. N MDFDA D NOW^%DTC
  1. S MDFDA(704.209,+MDOPT_",",.03)=DUZ
  1. S MDFDA(704.209,+MDOPT_",",.04)=%
  1. S MDFDA(704.209,+MDOPT_",",.05)=$J
  1. D FILE^DIE("","MDFDA")
  1. S @RESULTS@(0)="1^Option locked"
  1. Q
  1. ;
  1. DELOPT ; Delete option from the RENAL SETTING file(#704.209)
  1. ;
  1. ; P1=Setting Name
  1. ; P2=Owner
  1. ;
  1. N DA,DIK,MDOPT
  1. S MDOPT=$$FIND1^DIC(704.209,,"X",P1,"B","I $P(^(0),U,2)=P2")
  1. I 'MDOPT S @RESULTS@(0)="1^No such setting." Q
  1. S DA=MDOPT,DIK="^MDK(704.209," D ^DIK
  1. S @RESULTS@(0)="1^Setting deleted."
  1. Q
  1. ;
  1. SETOPT ; Set option into RENAL SETTING file (#704.209)
  1. ;
  1. ; P1=Setting Name
  1. ; P2=Owner
  1. ; P3=Array of text
  1. ;
  1. N MDOPT
  1. S MDOPT=$$FIND1^DIC(704.209,,"X",P1,"B","I $P(^(0),U,2)=P2")
  1. D:'MDOPT ; Try to create a new entry
  1. .N MDFDA,MDIEN
  1. .S MDFDA(704.209,"+1,",.01)=P1
  1. .S MDFDA(704.209,"+1,",.02)=P2
  1. .D UPDATE^DIE("","MDFDA","MDIEN")
  1. .S MDOPT=+$G(MDIEN(1),-1)
  1. I 'MDOPT S @RESULTS@(0)="-1^Unable to create entry" Q
  1. S @RESULTS@(0)=$$XMLFILER(704.209,MDOPT_",",.1,"P3")
  1. Q
  1. ;
  1. ALLOPT ; Get all options by user
  1. N MDFLD
  1. D BLDFLD^MDXMLFM(.MDFLD,704.209,".001;;NUMBER^.01;;SETTING NAME")
  1. K ^TMP("DILIST",$J)
  1. D LIST^DIC(704.209,,"@;.01","P","*",,,"B","I $P(^(0),U,2)=P2")
  1. F X=0:0 S X=$O(^TMP("DILIST",$J,X)) Q:'X S ^TMP("DILIST",$J,"B",+^(X,0),X)=""
  1. D LOADALL^MDXMLFM($NA(^TMP("DILIST",$J,"B")),704.209,.MDFLD)
  1. Q
  1. ;
  1. XMLFILER(DD,IENS,FLD,ROOT) ; This files UUEncoded XML into Fileman WP
  1. N MDFLAG,MDERR,MDL,MDXL ; Set to control appending
  1. K ^TMP("MDKXML",$J)
  1. S MDXL="",MDL=0
  1. F S MDXL=$O(@ROOT@(MDXL)) Q:MDXL="" S MDL=MDL+1,^TMP("MDKXML",$J,MDL)=@ROOT@(MDXL)
  1. S MDFLAG=$S(@ROOT@(0)["-- Begin UUEncoded Data --":"",1:"A")
  1. D WP^DIE(DD,IENS,FLD,MDFLAG,$NA(^TMP("MDKXML",$J)),"MDERR")
  1. I $D(MDERR) Q "-1^"_$G(MDERR("DIERR",1,"TEXT",1),"Unknown Error")
  1. Q "1^Filed"_"^"_MDL
  1. ;
  1. GETPROV ; Get list of available providers with name starting with P1
  1. N MDFLD,MDDATE,MDDUP,MDRI,MDI1,MDI2,MDLAST,MDMAX,MDPREV,MDTTL,X,X1,X2
  1. D BLDFLD^MDXMLFM(.MDFLD,200,".001;;ID^.01;;PROV_NAME^8;;TITLE")
  1. S MDRI=0,MDMAX=44,(MDLAST,MDPREV)="",X1=DT,MDFROM=P1,X2=-30 D C^%DTC S MDDATE=DT K X
  1. S RESULTS=$NA(^TMP("MDPLIST",$J)) K @RESULTS K ^TMP("DILIST",$J)
  1. F Q:MDRI'<MDMAX S MDFROM=$O(^VA(200,"AUSER",MDFROM),1) Q:MDFROM="" D
  1. .S MDI1=""
  1. .F S MDI1=$O(^VA(200,"AUSER",MDFROM,MDI1),1) Q:'MDI1 D
  1. ..I MDDATE>0,$$GET^XUA4A72(MDI1,MDDATE)<1 Q ; Check date?
  1. ..S MDDUP=0 ; Init flag, check dupe.
  1. ..I ($P(MDPREV_" "," ")=$P(MDFROM_" "," ")) S MDDUP=1
  1. ..;
  1. ..; Append Title if not duplicated:
  1. ..I 'MDDUP D
  1. ...S MDI2=MDI1
  1. ...D TITLE ; Get Title.
  1. ...S MDRI=MDRI+1,^TMP("DILIST",$J,MDRI)=MDI1_U_$$NAMEFMT^XLFNAME(MDFROM,"F","DcMPC")_$S(MDTTL'="":U_"- "_MDTTL,1:"")
  1. ;F X=0:0 S X=$O(^TMP("DILIST",$J,X)) Q:'X S ^TMP("DILIST",$J,"B",+^(X),X)=""
  1. D LOADALL^MDXMLFM1($NA(^TMP("DILIST",$J)),200,.MDFLD)
  1. Q
  1. ;
  1. TITLE ; Retrieve Title or Title and Service/Section.
  1. ; (Assumes certain vars already set/new'd in calling code.)
  1. ;
  1. S MDTTL="" ; Init each time.
  1. ; DBIA# 4329:
  1. S MDTTL=$P($G(^VA(200,MDI2,0)),U,9) ; Get Title pointer.
  1. I MDTTL<1 S MDTTL="" ; Reset var if none.
  1. ; DBIA# 1234:
  1. I MDTTL>0 S MDTTL=$G(^DIC(3.1,MDTTL,0)) ; Actual Title value.
  1. Q
  1. ;
  1. VITALS ; File a vitals sign
  1. S P3=$$FIND1^DIC(120.51,,"MX",P3)
  1. I P3<1 S @RESULTS@(0)="-1^Unknown Vital Type" Q
  1. S X=P1_U_P2_U_P3_";"_P4_U_P5_U_P6
  1. L +^GMR(120.5,0)
  1. D EN1^GMVDCSAV(.ZZZ,X)
  1. S @RESULTS@(0)=+$O(^GMR(120.5,"A"),-1)
  1. S @RESULTS@(1)=X
  1. L -^GMR(120.5,0)
  1. Q
  1. ;
  1. GETINST ; Get list of Institutions with name starting with P1
  1. N MDFLD
  1. D BLDFLD^MDXMLFM(.MDFLD,4,".001;;STATION NUMBER^.01;;STATION NAME")
  1. K ^TMP("DILIST",$J)
  1. D FIND^DIC(4,,"@;.01","P",P1,"*")
  1. F X=0:0 S X=$O(^TMP("DILIST",$J,X)) Q:'X S ^TMP("DILIST",$J,"B",+^(X,0),X)=""
  1. D LOADALL^MDXMLFM($NA(^TMP("DILIST",$J,"B")),4,.MDFLD)
  1. Q
  1. GETADM ; Get Administrators
  1. N MDFLD
  1. D BLDFLD^MDXMLFM(.MDFLD,200,".001;;NUMBER^.01;;NAME")
  1. K ^TMP("DILIST",$J)
  1. D FIND^DIC(200,,"@;.01","P",P1,"*")
  1. F X=0:0 S X=$O(^TMP("DILIST",$J,X)) Q:'X S ^TMP("DILIST",$J,"B",+^(X,0),X)=""
  1. D LOADALL^MDXMLFM($NA(^TMP("DILIST",$J,"B")),200,.MDFLD)
  1. Q
  1. GUI ; Returns Hemodialysis version check
  1. ; Returns yes or no
  1. S @RESULTS@(0)=$$GET^XPAR("SYS","MDK GUI VERSION",P1,"E")
  1. S:@RESULTS@(0)="" @RESULTS@(0)="NO"
  1. Q
  1. CURRENT ; Current Version
  1. N MDKLST,MDK,MDKY,MDKY1 S @RESULTS@(0)=""
  1. D GETLST^XPAR(.MDKLST,"SYS","MDK GUI VERSION")
  1. F MDK=0:0 S MDK=$O(MDKLST(MDK)) Q:MDK<1 S MDKY=$G(MDKLST(MDK)) D
  1. . S MDKY1=$P(MDKY,"^")
  1. . I $$GET^XPAR("SYS","MDK GUI VERSION",MDKY1,"I") S:@RESULTS@(0)="" @RESULTS@(0)=MDKY1
  1. . Q
  1. S:@RESULTS@(0)="" @RESULTS@(0)="No Current Version Recorded."
  1. Q
  1. USERINF ; Current User Information
  1. N MDUSER
  1. S MDUSER(0)=DUZ
  1. S MDUSER(1)=$$GET1^DIQ(200,+MDUSER(0)_",",.01)
  1. S MDUSER(2)=MDUSER(1)
  1. S MDUSER(3)=""
  1. S MDUSER(4)=$$GET1^DIQ(200,+MDUSER(0)_",",8)
  1. S MDUSER(5)=$$GET1^DIQ(200,+MDUSER(0)_",",29)
  1. S MDUSER(6)=$$GET1^DIQ(200,+MDUSER(0)_",",200.07)
  1. S MDUSER(7)=$$GET1^DIQ(200,+MDUSER(0)_",",200.1)
  1. M @RESULTS=MDUSER K MDUSER
  1. Q