source: FOIAVistA/trunk/r/CLINICAL_PROCEDURES-MD/MDAPI1.m@ 1169

Last change on this file since 1169 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

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