- MDAPI1 ; HOIFO/NCA - Electrocardiogram Data Extraction ;12/4/02 12:32
- ;;1.0;CLINICAL PROCEDURES;**1**;Apr 01, 2004
- ; Reference IA #3854 API call
- ; IA #10154 Access 2nd piece of ^DD(filenumber,fieldnumber,0)
- GET(RESULTS,MDARDFN,MDSDT,MDEDT,MDFLDS) ; Returns list of data from Electrocardiogram File #691.5
- ; Input: RESULTS - the global ^TMP array in which (Required)
- ; to return results.
- ; MDARDFN - the patient DFN. (Required)
- ; MDSDT - the start date of the date (Required)
- ; range to return the data in.
- ; This must be in FM internal
- ; format.
- ; MDEDT - the end date of the date (Required)
- ; range to return the data in.
- ; This must be in FM internal
- ; format.
- ; MDFLDS - a list of fields from file #691.5 to (Required)
- ; be returned in RESULTS. MDFLDS should
- ; contain a list of fields delimited by ";"
- ; example: MDFLDS=".01;11;20..."
- ;
- ; Output: RESULTS (Passed by Reference)
- ; Global array returned in the FM DIQ call format.
- ;
- ; Example API call:
- ;
- ; S RESULTS="^TMP(""NAMESPACE"",$J)"
- ; D GET^MDAPI1(.RESULTS,162,2900101,3021001,".01;11")
- ;
- ; return:
- ; ^TMP("NAMESPACE",$J,file #,record ien_",",field #,"E")=Data
- ; ^TMP("NAMESPACE",$J,subfile #,entry #_","_record ien,
- ; field of the multiple,"E")=data
- ;
- ; Only the Electrocardiogram records in the following
- ; statuses will be returned in the list:
- ;
- ; RELEASED ON-LINE VERIFIED
- ; RELEASED OFF-LINE VERIFIED
- ; RELEASED NOT VERIFIED
- ; RELEASED ON-LINE VERIFIED OF SUPERSEDED
- ; RELEASED OFF-LINE VERIFIED OF SUPERSEDED
- ;
- ; ^TMP("NAMESPACE",$J,0) will equal one of the following,
- ; if the call failed:
- ; -1^No Patient DFN.
- ; -1^No Start Date Range.
- ; -1^No End Date Range.
- ; -1^Start Date greater than End Date.
- ; -1^No fields defined.
- ;
- ; If a local variable is defined in RESULTS,
- ; ^TMP("MDAPI",$J,0) equals
- ; -1^Global TMP array only.
- ;
- ; If no return array defined,^TMP("MDAPI",$J,0) equals
- ; -1^No return array global.
- ;
- ; If no data, ^TMP("NAMESPACE",$J,0) equals
- ; -1^No data for patient.
- ;
- N MDCODE,MDDR,MDK,MDLP,MDN,MDNOD,MDSUBF,MDX,MDY
- K ^TMP("MDAPI",$J)
- I '$D(RESULTS) S ^TMP("MDAPI",$J,0)="-1^No return array global." Q
- I $G(RESULTS)'["^TMP" S ^TMP("MDAPI",$J,0)="-1^Global TMP array only." Q
- I '+$G(MDARDFN) S @RESULTS@(0)="-1^No Patient DFN." Q
- I '$G(MDSDT) S @RESULTS@(0)="-1^No Start Date Range." Q
- I '$G(MDEDT) S @RESULTS@(0)="-1^No End Date Range." Q
- I MDSDT>MDEDT S @RESULTS@(0)="-1^Start Date greater than End Date." Q
- I $G(MDFLDS)="" S @RESULTS@(0)="-1^No fields defined." Q
- S (MDDR,MDX,MDY)="",MDEDT=MDEDT\1+.3
- S MDN=$L(MDFLDS,";")
- F MDK=1:1:MDN S MDY=+$P(MDFLDS,";",MDK) I MDY D
- .Q:'$$VFIELD^DILFD(691.5,MDY)
- .S MDNOD=$P($G(^DD(691.5,+MDY,0)),"^",2),MDSUBF=0
- .I +MDNOD[691.5&($E(MDNOD,$L(MDNOD)-1,$L(MDNOD))="PA") S MDSUBF=1
- .S MDDR=MDDR_$S(MDDR="":"",1:";")_MDY_$S(MDSUBF:"*",1:"")
- .Q
- S MDLP=0 F S MDLP=$O(^MCAR(691.5,"C",MDARDFN,MDLP)) Q:MDLP<1 D
- .S MDX=$G(^MCAR(691.5,MDLP,0)) Q:MDX=""
- .Q:$P(MDX,"^")<MDSDT!($P(MDX,"^")>MDEDT)
- .S MDCODE=$P($G(^MCAR(691.5,MDLP,"ES")),"^",7)
- .S:MDCODE="" MDCODE="RNV"
- .I MDCODE="S"!(MDCODE["D") Q
- .D GETS^DIQ(691.5,MDLP_",",MDDR,"E",$NA(@RESULTS))
- .Q
- I '$D(@(RESULTS)) S @RESULTS@(0)="-1^No data for patient."
- Q
- --- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMDAPI1 3752 printed Feb 18, 2025@23:08:32 Page 2
- MDAPI1 ; HOIFO/NCA - Electrocardiogram Data Extraction ;12/4/02 12:32
- +1 ;;1.0;CLINICAL PROCEDURES;**1**;Apr 01, 2004
- +2 ; Reference IA #3854 API call
- +3 ; IA #10154 Access 2nd piece of ^DD(filenumber,fieldnumber,0)
- GET(RESULTS,MDARDFN,MDSDT,MDEDT,MDFLDS) ; Returns list of data from Electrocardiogram File #691.5
- +1 ; Input: RESULTS - the global ^TMP array in which (Required)
- +2 ; to return results.
- +3 ; MDARDFN - the patient DFN. (Required)
- +4 ; MDSDT - the start date of the date (Required)
- +5 ; range to return the data in.
- +6 ; This must be in FM internal
- +7 ; format.
- +8 ; MDEDT - the end date of the date (Required)
- +9 ; range to return the data in.
- +10 ; This must be in FM internal
- +11 ; format.
- +12 ; MDFLDS - a list of fields from file #691.5 to (Required)
- +13 ; be returned in RESULTS. MDFLDS should
- +14 ; contain a list of fields delimited by ";"
- +15 ; example: MDFLDS=".01;11;20..."
- +16 ;
- +17 ; Output: RESULTS (Passed by Reference)
- +18 ; Global array returned in the FM DIQ call format.
- +19 ;
- +20 ; Example API call:
- +21 ;
- +22 ; S RESULTS="^TMP(""NAMESPACE"",$J)"
- +23 ; D GET^MDAPI1(.RESULTS,162,2900101,3021001,".01;11")
- +24 ;
- +25 ; return:
- +26 ; ^TMP("NAMESPACE",$J,file #,record ien_",",field #,"E")=Data
- +27 ; ^TMP("NAMESPACE",$J,subfile #,entry #_","_record ien,
- +28 ; field of the multiple,"E")=data
- +29 ;
- +30 ; Only the Electrocardiogram records in the following
- +31 ; statuses will be returned in the list:
- +32 ;
- +33 ; RELEASED ON-LINE VERIFIED
- +34 ; RELEASED OFF-LINE VERIFIED
- +35 ; RELEASED NOT VERIFIED
- +36 ; RELEASED ON-LINE VERIFIED OF SUPERSEDED
- +37 ; RELEASED OFF-LINE VERIFIED OF SUPERSEDED
- +38 ;
- +39 ; ^TMP("NAMESPACE",$J,0) will equal one of the following,
- +40 ; if the call failed:
- +41 ; -1^No Patient DFN.
- +42 ; -1^No Start Date Range.
- +43 ; -1^No End Date Range.
- +44 ; -1^Start Date greater than End Date.
- +45 ; -1^No fields defined.
- +46 ;
- +47 ; If a local variable is defined in RESULTS,
- +48 ; ^TMP("MDAPI",$J,0) equals
- +49 ; -1^Global TMP array only.
- +50 ;
- +51 ; If no return array defined,^TMP("MDAPI",$J,0) equals
- +52 ; -1^No return array global.
- +53 ;
- +54 ; If no data, ^TMP("NAMESPACE",$J,0) equals
- +55 ; -1^No data for patient.
- +56 ;
- +57 NEW MDCODE,MDDR,MDK,MDLP,MDN,MDNOD,MDSUBF,MDX,MDY
- +58 KILL ^TMP("MDAPI",$JOB)
- +59 IF '$DATA(RESULTS)
- SET ^TMP("MDAPI",$JOB,0)="-1^No return array global."
- QUIT
- +60 IF $GET(RESULTS)'["^TMP"
- SET ^TMP("MDAPI",$JOB,0)="-1^Global TMP array only."
- QUIT
- +61 IF '+$GET(MDARDFN)
- SET @RESULTS@(0)="-1^No Patient DFN."
- QUIT
- +62 IF '$GET(MDSDT)
- SET @RESULTS@(0)="-1^No Start Date Range."
- QUIT
- +63 IF '$GET(MDEDT)
- SET @RESULTS@(0)="-1^No End Date Range."
- QUIT
- +64 IF MDSDT>MDEDT
- SET @RESULTS@(0)="-1^Start Date greater than End Date."
- QUIT
- +65 IF $GET(MDFLDS)=""
- SET @RESULTS@(0)="-1^No fields defined."
- QUIT
- +66 SET (MDDR,MDX,MDY)=""
- SET MDEDT=MDEDT\1+.3
- +67 SET MDN=$LENGTH(MDFLDS,";")
- +68 FOR MDK=1:1:MDN
- SET MDY=+$PIECE(MDFLDS,";",MDK)
- IF MDY
- Begin DoDot:1
- +69 if '$$VFIELD^DILFD(691.5,MDY)
- QUIT
- +70 SET MDNOD=$PIECE($GET(^DD(691.5,+MDY,0)),"^",2)
- SET MDSUBF=0
- +71 IF +MDNOD[691.5&($EXTRACT(MDNOD,$LENGTH(MDNOD)-1,$LENGTH(MDNOD))="PA")
- SET MDSUBF=1
- +72 SET MDDR=MDDR_$SELECT(MDDR="":"",1:";")_MDY_$SELECT(MDSUBF:"*",1:"")
- +73 QUIT
- End DoDot:1
- +74 SET MDLP=0
- FOR
- SET MDLP=$ORDER(^MCAR(691.5,"C",MDARDFN,MDLP))
- if MDLP<1
- QUIT
- Begin DoDot:1
- +75 SET MDX=$GET(^MCAR(691.5,MDLP,0))
- if MDX=""
- QUIT
- +76 if $PIECE(MDX,"^")<MDSDT!($PIECE(MDX,"^")>MDEDT)
- QUIT
- +77 SET MDCODE=$PIECE($GET(^MCAR(691.5,MDLP,"ES")),"^",7)
- +78 if MDCODE=""
- SET MDCODE="RNV"
- +79 IF MDCODE="S"!(MDCODE["D")
- QUIT
- +80 DO GETS^DIQ(691.5,MDLP_",",MDDR,"E",$NAME(@RESULTS))
- +81 QUIT
- End DoDot:1
- +82 IF '$DATA(@(RESULTS))
- SET @RESULTS@(0)="-1^No data for patient."
- +83 QUIT