source: FOIAVistA/tag/r/SCHEDULING-SD-SC/SDAMA205.m@ 1621

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

initial load of FOIAVistA 6/30/08 version

File size: 3.8 KB
Line 
1SDAMA205 ;BPOIFO/ACS-Scheduling Replacement APIs ; 12/13/04 3:17pm
2 ;;5.3;Scheduling;**347**;13 Aug 1993
3 ;
4 ;*****************************************************************
5 ; CHANGE LOG
6 ;
7 ; DATE PATCH DESCRIPTION
8 ;-------- ---------- -----------------------------------------
9 ;07/21/04 SD*5.3*347 CALLED FROM GETAPPT^SDAMA201.
10 ;
11 ;*****************************************************************
12GETAPPT(SDPATIEN,SDFIELDS,SDAPSTAT,SDSTART,SDEND,SDRESULT,SDIOSTAT) ;
13 ;*****************************************************************
14 ;
15 ; GET APPOINTMENTS FOR PATIENT
16 ;
17 ;INPUT
18 ; SDPATIEN Patient IEN (required)
19 ; SDFIELDS Fields requested (optional)
20 ; SDAPSTAT Appointment Status Filter (optional)
21 ; SDSTART Start date/time (optional)
22 ; SDEND End date/time (optional)
23 ; SDRESULT Record count returned here (optional)
24 ; SDIOSTAT Patient Status filter (optional)
25 ;
26 ;OUTPUT
27 ; ^TMP($J,"SDAMA201","GETAPPT",X,Y)=FieldYdata
28 ; where "X" is an incremental appointment counter and
29 ; "Y" is the field number requested
30 ;
31 ;*****************************************************************
32 N SDAPDT,SDAPINAM,SDARRAY,SDRTNNAM,SDAPNUM,SDCNVRT,SDDATA,SDX,SDY,SDZ
33 S SDAPINAM="GETAPPT",SDRTNNAM="SDAMA201",SDRESULT=0
34 K ^TMP($J,SDRTNNAM,SDAPINAM)
35 S SDRESULT=$$VALIDATE^SDAMA200(.SDPATIEN,.SDFIELDS,.SDAPSTAT,.SDSTART,.SDEND,SDAPINAM,SDRTNNAM,.SDIOSTAT)
36 I SDRESULT=-1 Q
37 ;
38 ;CONVERT INPUT VALUES TO SDAPI FILTER VALUES
39 S SDARRAY("SORT")="P"
40 S SDARRAY(4)=SDPATIEN
41 I $G(SDSTART)>0!($G(SDEND)>0) S SDARRAY(1)=$G(SDSTART)_";"_$G(SDEND)
42 ;convert Field List
43 S SDARRAY("FLDS")=""
44 F SDX=1:1 S SDY=$P(SDFIELDS,";",SDX) Q:SDY="" D
45 .I SDY=12,SDFIELDS[3 Q ; Patient Status not needed if Appt. Stat. exists.
46 .I SDY=12 S SDY=3 ; Patient Status and Appointment Status are the same here.
47 .S SDARRAY("FLDS")=SDARRAY("FLDS")_SDY_";"
48 I '$L(SDFIELDS) S SDARRAY("FLDS")="1;2;3;4;5;6;7;8;9;10;11"
49 ;convert Appt. List
50 S SDZ=""
51 ;IO Status has been validated by SDAMA200 to be I or O
52 I $L($G(SDIOSTAT))=1 S SDZ=$S(SDIOSTAT="I":"I;",SDIOSTAT="O":SDAPSTAT_";")
53 I $L($G(SDIOSTAT))'=1,$L($G(SDAPSTAT)) D
54 .F SDX=1:1:$L(SDAPSTAT,";") S SDY=$P(SDAPSTAT,";",SDX) D
55 ..S SDZ=SDZ_$S(SDY="R":"R;I;",SDY="N":"NS;NSR;",SDY="C":"CC;CP;CCR;CPR;",1:SDY_";")
56 E S SDZ="R;I;CC;CP;CCR;CPR;NS;NSR;NT;"
57 I $L(SDZ) S SDARRAY(3)=$E(SDZ,1,$L(SDZ)-1)
58 ;
59 ;CALL SDAPI TO RETRIEVE APPOINTMENT INFO
60 S SDRESULT=$$SDAPI^SDAMA301(.SDARRAY)
61 I SDRESULT=0 Q ; No Appointment info returned.
62 ;
63 I SDRESULT=-1 D Q ; Error(s) Encountered.
64 .S SDX=$O(^TMP($J,"SDAMA301",""))
65 .S SDX=$S(SDX=101:101,SDX=115:114,SDX=116:114,1:117)
66 .D ERROR^SDAMA200(SDX,"GETAPPT",0,"SDAMA201")
67 .K ^TMP($J,"SDAMA301")
68 ;
69 ; Convert Appt. Info Returned from SDAPI to GETAPPT Format.
70 F SDX=1,5,7,9,11,12 S SDCNVRT(SDX)=""
71 F SDX=2,4,8,10 S SDCNVRT(SDX)="S SDDATA=$TR(SDDATA,"";"",""^"")"
72 S SDCNVRT(3)="S SDDATA=$P(SDDATA,"";""),SDDATA=$S(SDDATA=""R"":SDDATA,SDDATA=""I"":""R"",$E(SDDATA,1)=""C"":""C"",$E(SDDATA,1,2)=""NS"":""N"",1:""NT"")"
73 S SDCNVRT(6)="S SDDATA=$G(^TMP($J,""SDAMA301"",SDPATIEN,SDAPDT,""C""))"
74 ;
75 S SDAPNUM=0,SDAPDT=""
76 ;Loop through returned appointments from SDAPI
77 F S SDAPDT=$O(^TMP($J,"SDAMA301",SDPATIEN,SDAPDT)) Q:SDAPDT="" S SDX=^(SDAPDT) D
78 .S SDAPNUM=SDAPNUM+1
79 .;Loop through requested fields
80 .F SDY=1:1 S SDZ=$P($G(SDFIELDS),";",SDY) Q:SDZ="" D
81 ..;Retrieve data for requested field
82 ..S SDDATA=$P(SDX,"^",SDZ)
83 ..;Convert Overbook to N if null value returned from SDAPI
84 ..I SDZ=7,SDDATA="" S SDDATA="N"
85 ..X SDCNVRT(SDZ) S ^TMP($J,"SDAMA201","GETAPPT",SDAPNUM,SDZ)=SDDATA
86 .;Set Patient Status Value in output based on Appt Status
87 .I $P($P(SDX,U,3),";")="I" S ^TMP($J,"SDAMA201","GETAPPT",SDAPNUM,12)="I"
88 .I $S($P($P(SDX,U,3),";")="R":1,$P($P(SDX,U,3),";")="NT":1,1:0) S ^TMP($J,"SDAMA201","GETAPPT",SDAPNUM,12)="O"
89 K ^TMP($J,"SDAMA301")
90 Q
91 ;
Note: See TracBrowser for help on using the repository browser.