source: FOIAVistA/tag/r/SCHEDULING-SD-SC/SCCVCST3.m@ 1590

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

initial load of FOIAVistA 6/30/08 version

File size: 5.9 KB
Line 
1SCCVCST3 ;ALB/TMP - Scheduling Conversion Template Utilities - CST; APR 20, 1998
2 ;;5.3;Scheduling;**211**;Aug 13, 1993
3 ;
4ONE ; -- Select/Convert one pt's encounter episode - no CST needed
5 D FULL^VALM1
6 ; -- is conversion enabled
7 IF '$$OK^SCCVU(1) G ONEQ
8 ;
9 F W !! Q:$$SEL1()
10 ;
11ONEQ S VALMBCK="R"
12 Q
13 ;
14SEL1() ; Select an entry, convert
15 N DIR,X,Y,SCFILE,SCFILE1,SCCVDFN,SCCVTYP,SCCVDA,SCCVCOD,SCQUIT,DA,DIC,DIQ,SCSTOP,SCCVEVT,SCPREF,Z,SCCVACRP,SCCV900,SCCVDIS
16 S SCCVACRP=$$ENDDATE^SCCVU()
17 S SCCV900=+$O(^DIC(40.7,"C",900,0))
18 S SCSTOP=0
19 S DIR(0)="SAMB^C:Convert;R:Reconvert",DIR("A")="(C)onvert/(R)econvert: ",DIR("B")="Convert"
20 D ^DIR K DIR
21 I Y["^" S SCSTOP=1 G SEL1Q
22 S SCCVEVT=$S(Y="C":1,1:2),SCPREF=$S(SCCVEVT=1:"",1:"re")
23 ;
24 S DIR(0)="SABM^E:Encounter;D:Disposition;A:Appointment;S:Standalone Add/Edit",SCCVCOD=$P(DIR(0),U,2)
25 S DIR("A")="TYPE OF ENTRY TO "_$S(SCCVEVT=1:"",1:"RE")_"CONVERT: ",DIR("?")="Select the type of entry you want to "_SCPREF_"convert from the list"
26 D ^DIR K DIR
27 I "EDAS"'[Y S SCSTOP=1 G SEL1Q
28 S SCCVTYP=Y,SCCVTYPN=$P($P(SCCVCOD,SCCVTYP_":",2),";")
29 ;
30 S DIC="^DPT(",DIC(0)="AEMQ" D ^DIC ;Select patient
31 G:Y'>0 SEL1Q
32 S SCCVDFN=+Y
33 ;
34 S SCFILE=$$SETFL($S(SCCVTYP="E":0,SCCVTYP="D":3,SCCVTYP="A":1,1:2),SCCVDFN)
35 S SCFILE1=$S(SCFILE["SCE"!(SCFILE["SDV"):SCFILE_"("_$S(SCFILE["SCE":"""ADFN"","_SCCVDFN_",",1:""),1:$P(SCFILE,")")_",") ;Indirection format
36 ;
37 ; Select a specific entry
38 S SCQUIT=0
39 W !
40 S DIR(0)=$S(SCFILE["SCE":"NAO^^I $P($G(^SCE(X,0)),U,2)'=SCCVDFN K X",SCFILE["SDV":"FAO^^D DTCNVT^SCCVCST3(.X)",1:"DAO^:"_SCCVACRP_":RXP")
41 S DIR("A")="ENTER THE "_$S(SCFILE["SDV":"SCHEDULING VISIT ENTRY #",SCFILE["SCE":"ENCOUNTER ENTRY #",SCFILE["""DIS""":"DISPOSITION DATE/TIME",1:"APPOINTMENT DATE/TIME")_", IF KNOWN: "
42 S DIR("?",1)="Enter the "_$S(SCFILE["SCE":"internal entry number",1:"date/time")_" of the "_SCCVTYPN_" to "_SCPREF_"convert, if you know it"
43 S Z=2
44 I SCFILE["SDV" S DIR("?",2)="Date may be entered in internal or external format",Z=Z+1
45 S DIR("?",Z)="Must be a valid "_SCCVTYPN_$S(SCFILE'["SCE":" date/time",1:"")_" for the patient"_$S(SCFILE'["SCE":", on or before "_$$FMTE^XLFDT(SCCVACRP,"1D"),1:"")
46 S DIR("?")="If not known, Press RETURN to review the "_SCCVTYPN_"s on a specific date"
47 D ^DIR K DIR
48 W !!
49 ;
50 S SCCVDA=$S(Y'>0:0,SCFILE'["""DIS""":+Y,1:9999999-Y)
51 I SCCVDA D CHK(SCCVEVT,SCCVTYPN,SCFILE,SCFILE1,$S(SCFILE'["SCE":+Y,1:+$G(^SCE(SCCVDA,0))),SCCVDA,0,.SCQUIT,.SCONE) ;Specific entry selected
52 ;
53 G:SCQUIT SEL1Q
54 ;
55 ; Select entry by date or date/time
56 S DIR(0)="DAO^:"_SCCVACRP_":PTSX"
57 S DIR("A")="DATE: "
58 S DIR("?",1)="Enter a valid date or date and time of the patient's "_SCCVTYPN_" to "_SCPREF_"convert."
59 S DIR("?",2)=" The date must be on or before "_$$FMTE^XLFDT(SCCVACRP,1)_".",DIR("?",3)=" "
60 S DIR("?",4)="If you enter only a date, all the patient's "_SCCVTYPN_"s on that date will be",DIR("?",5)=" presented one at a time. If the entry displayed is the correct one,"
61 S DIR("?")=" you may request it be "_SCPREF_"converted or if not the correct one, reject it."
62 D ^DIR K DIR
63 G:'Y SEL1Q
64 S SCDTM=+Y,SCQUIT=0
65 ;
66 I SCDTM'["." D G:SCQUIT SEL1Q ; Date only entered
67 . ; SCQUIT is set to 1 when an entry is selected for conversion
68 . ; SCONE is set to 1 if at least one valid entry is found
69 . ;
70 . N SCONE,SC,SCV,SCF,SCD
71 . S SCF=$S(SCFILE["SCE":"^SCE(""ADFN"","_SCCVDFN_")",SCFILE["SDV":"^SDV(""ADT"","_SCCVDFN_")",1:SCFILE)
72 . S SCONE=$S(SCF["SCE":$O(@SCF@(SCDTM)),SCF["""S""":$O(@SCF@(SCDTM)),SCF["""DIS""":9999999-$O(@SCF@(9999999-SCDTM),-1),1:$O(@SCF@(SCDTM-1)))
73 . S SCONE=(SCONE\1=SCDTM)
74 . I '$G(SCONE) D NOENT^SCCVCST4(SCCVTYPN,SCCVDFN,SCDTM) S SCQUIT=1 Q ;No valid entry found
75 . I SCCVEVT=2 S SCONE=0
76 . ;
77 . I SCFILE["SCE"!(SCFILE["""S""") D ; Encounters and Appts
78 .. S SC=SCDTM,SCONE=0
79 .. F S SC=$O(@SCF@(SC)) Q:'SC!((SC\1)'=SCDTM) D Q:SCQUIT
80 ... I SCF["SCE" D ; Encounters
81 .... S SCD=0 F S SCD=$O(@SCF@(SC,SCD)) Q:'SCD W "." I '$P($G(^SCE(SCD,0)),U,6) D CHK(SCCVEVT,SCCVTYPN,SCFILE,SCFILE1,+$G(^SCE(SCD,0)),SCD,1,.SCQUIT,.SCONE) Q:SCQUIT
82 ... ;
83 ... I SCF["""S""" D ; Appts
84 .... D CHK(SCCVEVT,SCCVTYPN,SCFILE,SCFILE1,SC,SC,1,.SCQUIT,.SCONE)
85 . ;
86 . I SCFILE["""DIS""" D ; Dispositions
87 .. S SCDTM=9999999-SCDTM-1,SC=SCDTM+1,SCONE=0
88 .. F S SC=$O(@SCF@(SC),-1) Q:'SC!((SC\1)'=SCDTM) W "." D Q:SCQUIT
89 ... D CHK(SCCVEVT,SCCVTYPN,SCFILE,SCFILE1,9999999-SC,SC,1,.SCQUIT,.SCONE)
90 . I SCFILE["SDV" D ; Add/edits
91 .. S SCONE=0,SC=$G(@SCF@(SCDTM))
92 .. Q:SC=""
93 .. D CHK(SCCVEVT,SCCVTYPN,SCFILE,SCFILE1,SC,SC,1,.SCQUIT,.SCONE)
94 . ;
95 . I 'SCONE S SCQUIT=1 D NOENT^SCCVCST4(SCCVTYPN,SCCVDFN,SCDTM) Q
96 . ;
97 . I 'SCQUIT,SCONE S DIR(0)="EA",DIR("A",1)="NO ENTRY SELECTED",DIR("A")="PRESS RETURN " D ^DIR K DIR
98 ;
99 I SCDTM["." D ; Date and time entered
100 . I SCFILE["SCE" D ; Encounter
101 .. S SCCVDA=0 F S SCCVDA=$O(^SCE("ADFN",SCCVDFN,SCDTM,SCCVDA)) W "." Q:'SCCVDA D
102 ... D CHK(SCCVEVT,SCCVTYPN,SCFILE,SCFILE1,SCDTM,SCCVDA,1,.SCQUIT,.SCONE)
103 . ;
104 . I SCFILE'["SCE" D ; Non-encounter
105 .. S SCCVDA=$S(SCFILE'["""DIS""":SCDTM,1:9999999-SCDTM)
106 .. D CHK(SCCVEVT,SCCVTYPN,SCFILE,SCFILE1,SCDTM,SCCVDA,0,.SCQUIT,.SCONE)
107SEL1Q Q SCSTOP
108 ;
109SETFL(SCCVTYP,SCCVDFN) ;Set the lookup format of the file
110 ; INPUT: SCCVTYP, SCCVDFN
111 ; FUNCTION OUTPUT: Lookup format of filename for type/patient
112 ;
113 Q $S(SCCVTYP=0:"^SCE",SCCVTYP=3:"^DPT("_SCCVDFN_",""DIS"")",SCCVTYP=1:"^DPT("_SCCVDFN_",""S"")",SCCVTYP=2:"^SDV",1:"")
114 ;
115CHK(SCCVEVT,SCCVTYPN,SCFILE,SCFILE1,SCDTM,SC,SCMULT,SCQUIT,SCONE) ;
116 ; Check for validity for convert, display entry, convert if confirmed
117 N SCV,DIR,Y
118 I $$VAL1^SCCVCST5(SCCVEVT,SCFILE,SC,SCMULT) D
119 .S SCONE=1
120 .W ! S SCV=$$DISP1^SCCVCST4(SCCVTYPN,SCFILE1,SC)
121 .I 'SCV S:SCV="^" SCQUIT=1 Q
122 .S SCQUIT=1 D CONV1^SCCVCST4(SCCVEVT,SCFILE,SCCVDFN,SCDTM,SC)
123 Q
124 ;
125DTCNVT(X) ; Convert date/time for disposition
126 N SCZ,SCX,Y,Z,%DT
127 S %DT="RXPT"
128 I X["@"!(X'[".") D
129 . S SCX=$P(X,"@",2)
130 . S SCZ=$TR(SCX,"APMapm"),Z=$L(SCZ) ;strip AM/PM from time
131 . I Z>4 S %DT=%DT_"S" S:Z=5 X=$P(X,"@")_"@"_SCZ_"0"
132 D ^%DT S X=Y
133 K:Y<0 X
134 Q
135 ;
Note: See TracBrowser for help on using the repository browser.