source: WorldVistAEHR/trunk/r/CLINICAL_PROCEDURES-MD/MDPCE2.m@ 949

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

initial load of WorldVistAEHR

File size: 5.0 KB
Line 
1MDPCE2 ; HOIFO/NCA - Routine For Data Extract For Hemo Dialysis;9/10/04 11:23
2 ;;1.0;CLINICAL PROCEDURES;**6**;Apr 01, 2004;Build 102
3 ; Integration Agreements:
4 ; IA# 1889 [Subscription] Create New Visit - DATA2PCE^PXAPI call
5 ; 1890 [Subscription] Delete existing visit - DELVFILE^PXAPI call
6 ; 1995 [Supported] ICPTCOD API Call
7 ; 3990 [Supported] ICDCODE API Call
8 ; 10040 [Supported] Hospital Location File Access
9 ; 10082 [Supported] Global Access to ICD Diagnosis file (#80)
10 ; 10048 [Supported] FILE 9.4 references
11 ; 10103 [Supported] XLFDT calls
12 ;
13EN1(MDENC,MDINST,MDPDTE,MDPR,MDTYP,MDETYP,MDCLOC) ; [Function] PCE Visit Creation
14 ; Input parameters
15 ; 1. MDENC [Literal/Required] Billing data array
16 ; 2. MDINST [Literal/Required] Transaction IEN
17 ; 3. MDPDTE [Literal/Optional] Procedure Date/Time
18 ; 4. MDPR [Literal/Required] CP Definition
19 ; 5. MDTYP [Literal/Required] Type of Visit (Ambulatory or Hospitalization)
20 ; 6. MDETYP [Literal/Required] Encounter Type (Primary or Ancillary)
21 ; 7. MDCLOC [Literal/Required] Workload Reporting hospital location
22 ;
23 N DATA,MDCCOD,MDCLIN,MDPERR,MDJ,MDK,MDL,MDLST,MDM,MDNOD,MDOK,MDPKG,MDPROV,MDRES,MDSC,MDSTR,MDV1,MDVISIT,MDDRES K ^TMP("MDPXAPI",$J)
24 S MDOUT="",(MDOK,MDSC)=0
25 S MDPKG=$$FIND1^DIC(9.4,"","MX","CLINICAL PROCEDURES")
26 I 'MDPKG Q "-1^CLINICAL PROCEDURES does not exist in Package File."
27 I '$D(^MDD(702,MDINST,0)) Q "-1^No Study Record."
28 S MDSTR=$G(^MDD(702,MDINST,0))
29 S MDCLIN=$G(^MDD(702,MDINST,1))
30 S MDRES=""
31 I +$P(MDCLIN,U) S MDRES=$$DELVFILE^PXAPI("PRV^POV^CPT",+$P(MDCLIN,U),"","CLINICAL PROCEDURES") S MDVISIT=+MDCLIN
32 ;I +MDRES<0 Q $P(MDRES,"^")_"^Cannot purge existing visit during PCE data set."
33 S (MDJ,MDK,MDL,MDM)=0,MDJ=MDJ+1,MDPROV=""
34 I '$G(MDCLOC) S MDCLOC=$$GET1^DIQ(702.01,+MDPR_",",.05,"I") I 'MDCLOC Q "-1^No Hospital Location for CP Definition."
35 S ^TMP("MDPXAPI",$J,"ENCOUNTER",MDJ,"ENC D/T")=MDPDTE
36 S ^TMP("MDPXAPI",$J,"ENCOUNTER",MDJ,"PATIENT")=$P(MDSTR,"^",1)
37 S ^TMP("MDPXAPI",$J,"ENCOUNTER",MDJ,"HOS LOC")=MDCLOC
38 S ^TMP("MDPXAPI",$J,"ENCOUNTER",MDJ,"SERVICE CATEGORY")=$S(MDTYP="V":"A",1:MDTYP)
39 S ^TMP("MDPXAPI",$J,"ENCOUNTER",MDJ,"ENCOUNTER TYPE")=MDETYP
40 I $$GET1^DIQ(44,MDCLOC_",",3,"I") S ^TMP("MDPXAPI",$J,"ENCOUNTER",MDJ,"INSTITUTION")=$$GET1^DIQ(44,MDCLOC_",",3,"I")
41 S MDLST="" F S MDLST=$O(MDENC(MDLST)) Q:MDLST="" S MDNOD=$G(MDENC(MDLST)) D
42 .I $P(MDNOD,"^")["SC" D Q
43 ..S:+$P(MDNOD,";",2) ^TMP("MDPXAPI",$J,"ENCOUNTER",MDJ,"SC")=+$P($P(MDNOD,";",2),U,2) S:+$P($P(MDNOD,";",2),U,2)>0 MDSC=1
44 ..I $P(MDNOD,";",3)="AO" Q:+MDSC>0 S:+$P(MDNOD,";",4) ^TMP("MDPXAPI",$J,"ENCOUNTER",MDJ,"AO")=+$P($P(MDNOD,";",4),"^",2)
45 ..I $P(MDNOD,";",5)="IR" Q:+MDSC>0 S:+$P(MDNOD,";",6) ^TMP("MDPXAPI",$J,"ENCOUNTER",MDJ,"IR")=+$P($P(MDNOD,";",6),"^",2)
46 ..I $P(MDNOD,";",7)="EC" Q:+MDSC>0 S:+$P(MDNOD,";",8) ^TMP("MDPXAPI",$J,"ENCOUNTER",MDJ,"EC")=+$P($P(MDNOD,";",8),"^",2)
47 ..I $P(MDNOD,";",9)="MST" Q:+MDSC>0 S:+$P(MDNOD,";",10) ^TMP("MDPXAPI",$J,"ENCOUNTER",MDJ,"MST")=+$P($P(MDNOD,";",10),"^",2)
48 ..I $P(MDNOD,";",11)="HNC" Q:+MDSC>0 S:+$P(MDNOD,";",12) ^TMP("MDPXAPI",$J,"ENCOUNTER",MDJ,"HNC")=+$P($P(MDNOD,";",12),"^",2)
49 ..I $P(MDNOD,";",13)="CV" Q:+MDSC>0 S:+$P(MDNOD,";",14) ^TMP("MDPXAPI",$J,"ENCOUNTER",MDJ,"CV")=+$P($P(MDNOD,";",14),"^",2)
50 .I $P(MDNOD,"^")="PRV" I $P(MDNOD,"^",2)'="" D Q
51 ..S MDK=MDK+1,^TMP("MDPXAPI",$J,"PROVIDER",MDK,"NAME")=$P(MDNOD,"^",2) S:'MDOK MDOK=1
52 ..S ^TMP("MDPXAPI",$J,"PROVIDER",MDK,"PRIMARY")=$P(MDNOD,"^",6)
53 ..S:MDPROV="" MDPROV=$P(MDNOD,"^",2)
54 ..Q
55 .I $P(MDNOD,"^")="POV" D Q
56 ..Q:$P(MDNOD,"^",3)=""
57 ..S MDCCOD=$$CODEN^ICDCODE($P(MDNOD,"^",3),"") S MDCCOD=+$P(MDCCOD,"^") Q:+MDCCOD<1
58 ..S MDL=MDL+1,^TMP("MDPXAPI",$J,"DX/PL",MDL,"DIAGNOSIS")=MDCCOD
59 ..S ^TMP("MDPXAPI",$J,"DX/PL",MDL,"PRIMARY")=$P(MDNOD,"^",6)
60 ..S ^TMP("MDPXAPI",$J,"DX/PL",MDL,"ORD/RES")="R"
61 ..S ^TMP("MDPXAPI",$J,"DX/PL",MDL,"CATEGORY")=$P(MDNOD,"^",4)
62 ..S ^TMP("MDPXAPI",$J,"DX/PL",MDL,"NARRATIVE")=$P($G(^ICD9(+MDCCOD,0)),"^",3)
63 ..S:MDPROV ^TMP("MDPXAPI",$J,"DX/PL",MDL,"ENC PROVIDER")=MDPROV
64 ..S:'MDOK MDOK=1
65 .I $P(MDNOD,"^")="CPT" D Q
66 ..Q:$P(MDNOD,U,3)=""
67 ..S MDCCOD=$$CPT^ICPTCOD($P(MDNOD,U,3)) Q:+MDCCOD<1
68 ..S MDM=MDM+1 S:'MDOK MDOK=1
69 ..S ^TMP("MDPXAPI",$J,"PROCEDURE",MDM,"PROCEDURE")=$P(MDCCOD,"^")
70 ..S ^TMP("MDPXAPI",$J,"PROCEDURE",MDM,"NARRATIVE")=$P(MDCCOD,"^",3)
71 ..S ^TMP("MDPXAPI",$J,"PROCEDURE",MDM,"CATEGORY")=$P(MDNOD,"^",4)
72 ..S ^TMP("MDPXAPI",$J,"PROCEDURE",MDM,"QTY")=$P(MDNOD,"^",7)
73 ..S:MDPROV ^TMP("MDPXAPI",$J,"PROCEDURE",MDM,"ENC PROVIDER")=MDPROV
74 I MDOK S ^TMP("MDPXAPI",$J,"ENCOUNTER",1,"CHECKOUT D/T")=$$NOW^XLFDT
75 S MDRES=$$DATA2PCE^PXAPI("^TMP(""MDPXAPI"",$J)",MDPKG,"CLINICAL PROCEDURES",.MDVISIT,"","",1,"",.MDPERR)
76 I MDRES<1 D Q MDOUT
77 .S MDOUT=1
78 .I MDVISIT>0 S MDFDA(702,MDINST_",",.13)=MDVISIT,MDOUT=MDVISIT_"^"_MDCLOC_";"_MDPDTE_";"_MDTYP,MDFDA(702,MDINST_",",.07)=MDTYP_";"_MDPDTE_";"_MDCLOC D FILE^DIE("K","MDFDA")
79 .K ^TMP("MDPXAPI",$J) Q
80 S:MDVISIT>0 MDFDA(702,MDINST_",",.13)=MDVISIT
81 S MDOUT=MDVISIT_"^"_MDCLOC_";"_MDPDTE_";"_MDTYP
82 S MDFDA(702,MDINST_",",.07)=MDTYP_";"_MDPDTE_";"_MDCLOC
83 D FILE^DIE("K","MDFDA") K ^TMP("MDPXAPI",$J)
84 Q MDOUT
Note: See TracBrowser for help on using the repository browser.