source: WorldVistAEHR/trunk/r/SCHEDULING-SD-SC/SDVSIT0.m@ 1147

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

initial load of WorldVistAEHR

File size: 4.2 KB
Line 
1SDVSIT0 ;MJK/ALB,ESW,SCK - OE Processing ; 11/21/02 11:00am
2 ;;5.3;Scheduling;**27,99,132,257,430**;AUG 13, 1993
3 ;
4ADD(SDT,SDVSIT) ; -- add/find outpatient encounter
5 ; input SDT = visit date internal format
6 ; SDVSIT = <see bottom of routine>
7 ;
8 ; returned = ien of 409.67
9 ; *** search code to be written ***
10 ; -- set up vars
11 S SDVSIT("VST")=""
12 ; -- add a visit file entry
13 D VISIT(SDT,.SDVSIT)
14 ; -- add opt encounter
15 Q $$NEW(SDT,.SDVSIT)
16 ;
17NEW(SDT,SDVSIT) ; -- create new outpatient encounter record
18 ; input SDT = visit date internal format
19 ; SDVSIT = <see bottom of routine>
20 ;
21 ; returned = ien of 409.67
22 ;
23 N SDOE,X,DA,DR,DIE,DQ,DE,I
24 ; -- creation hard set for performance
25 S I=$P(^SCE(0),U,3)
26LOCK S I=I+1 L +^SCE(I):1 I '$T!$D(^SCE(I)) L -^SCE(I) G LOCK
27 S ^SCE(I,0)=SDT,^SCE("B",SDT,I)="",^SCE(0)=$P(^SCE(0),"^",1,2)_"^"_I_"^"_($P(^SCE(0),"^",4)+1),^DISV($S($D(DUZ)'[0:DUZ,1:0),"^SCE(")=I,Y=I
28 ;K DD,DO S SDOE=0,X=SDT,DIC="^SCE(",DIC(0)="L" D FILE^DICN G NEWQ:'Y
29 S:'$G(SDVSIT("ELG")) SDVSIT("ELG")=$P($G(^DPT(SDVSIT("DFN"),.36)),U)
30 S SDVSIT("STA")=$$STATUS(+SDVSIT("DFN"),SDT,+$G(SDVSIT("LOC")),SDVSIT("ORG"),"KILL")
31 S (SDOE,DA)=+Y,DIE="^SCE(",DR="[SD ENCOUNTER ENTRY]" D ^DIE
32 D:$$REQ^SDM1A(SDT)'="CO" EN^SDCOM(SDOE,0,99999)
33 L -^SCE(SDOE)
34NEWQ Q SDOE
35 ;
36VISIT(SDT,SDVSIT) ; -- add visit file entry
37 N VSIT,DFN,DIE,DIC,DR,DA,X,VSITPKG
38 ; -- is visit tracking loaded
39 S X="VSITKIL" X ^%ZOSF("TEST") I '$T G VISITQ
40 ; -- set up vars
41 ;S VSIT(0)="ENMD0",VSIT=SDT,DFN=SDVSIT("DFN"),VSITPKG="SD"
42 S VSIT(0)="F",VSIT=SDT,DFN=SDVSIT("DFN"),VSITPKG="SD"
43 S VSIT("CLN")=$G(SDVSIT("CLN")),VSIT("SVC")=$S($G(SDVSIT("SVC"))]"":SDVSIT("SVC"),$$INP^SDAM2(DFN,SDT)="I":"I",1:"A")
44 ;S VSIT("INS")=$P($G(^DG(40.8,+$G(SDVSIT("DIV")),0)),U,7)
45 S VSIT("ELG")=$S($G(SDVSIT("ELG")):SDVSIT("ELG"),1:+$G(^DPT(DFN,.36)))
46 I $G(SDVSIT("LOC")) S VSIT("LOC")=SDVSIT("LOC")
47 I $G(SDVSIT("PAR")) S X=$G(^SCE(SDVSIT("PAR"),0)) I X]"" S VSIT=+X I $P(X,U,5) S VSIT("LNK")=$P(X,U,5)
48 S VSIT("ACT")=$$GETARN^SDPFSS2(SDT,DFN,$G(SDVSIT("LOC")))
49 I $G(VSIT("LNK")) D ;PX/96 - accept passed INSTITUTION
50 .N DR,DIC,DA,DIQ,INST,DIC1
51 .S DR=".06",DIC=9000010,DIC1=DIC,DA=VSIT("LNK"),DIQ="INST",DIQ(0)="I" D EN^DIQ1
52 .S VSIT("INS")=+$G(INST(DIC1,DA,DR,"I"))
53 .I VSIT("INS")'>0 S VSIT("INS")=$P($G(^DG(40.8,+$G(SDVSIT("DIV")),0)),U,7)
54 .Q
55 ;
56 I '$G(SDVSIT("PAR")) D
57 . S VSIT("PRI")="P"
58 E D
59 . I SDVSIT("ORG")=4 D
60 .. S VSIT("PRI")="C",VSIT("SVC")=$S($$INP^SDAM2(DFN,SDT)="I":"D",1:"X")
61 . E D
62 .. S VSIT("PRI")="S"
63 ;
64 ; -- changes for database conversion to pass in source and service
65 I $D(SCCVT) D
66 . I $G(SCCVT("SOR"))'="" S VSIT("SOR")=$$SOURCE^PXAPI(SCCVT("SOR"))
67 . I $G(SCCVT("SVC"))'="" S VSIT("SVC")=SCCVT("SVC")
68 . I $G(SCCVT("LOC"))'="" S VSIT("LOC")=SCCVT("LOC")
69 ;
70 ; -- do checks
71 I 'VSIT,'DFN,'VSIT("ELG")!('VSIT("INS"))!('VSIT("CLN")) G VISITQ
72 ;
73 ; -- add/find visit
74 ;-- change call if orinating process is a disposition.
75 I SDVSIT("ORG")=3 D DISPVSIT^PXAPI
76 I SDVSIT("ORG")'=3 D ^VSIT
77 IF +$G(VSIT("IEN"))>0 S SDVSIT("VST")=+VSIT("IEN")
78VISITQ Q
79 ;
80STATUS(DFN,SDT,SDCL,SDORG,SDACT) ; -- 409.68;.07 x-ref
81 N Y S Y=0
82 I $$INP^SDAM2(DFN,SDT)="I" S Y=8
83 I 'Y,$P($G(^SC(+SDCL,0)),U,17)="Y" S Y=12
84 I 'Y S Y=$S(SDACT="SET":2,$$REQ^SDM1A(SDT)="CO":14,1:2)
85 Q Y
86 ;
87 ;
88 ; Additional input/output variable documentation
89 ;
90 ; SDVSIT("LOC") = file # 44 ien (location)
91 ; ("ELG") = file # 8 ien (eligibility)
92 ; ("CLN") = file # 40.7 ien (clinic stop code)
93 ; ("DIV") = file # 40.8 ien (med ctr div)
94 ; ("DFN") = file # 2 ien (patient)
95 ; ("STA") = file #409.63 ien (appt status)
96 ; ("ORG") = orginating process
97 ; 1 - appt
98 ; 2 - add/edit
99 ; 3 - disposition
100 ; ("TYP") = file #409.1 ien (appt type)
101 ; ("VST") = file #9000010 ien (visit)
102 ; ("LNK") = file #9000010 ien (parent visit)
103 ; ("REF") = extended reference
104 ; appt - ^SC(<clinic>,"S",<date/time>,1,<ext ref>,0)
105 ; disp - ^DPT(<dfn>,"DIS",<ext ref>,0)
106 ; ("PAR") = file #409.68 ien (outpatient encounter)
107 ; - parent encounter ien
108 ; SDVIEN = passed in Visit file ien
109 ;
Note: See TracBrowser for help on using the repository browser.