Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: SDESGETLETTERS

SDESGETLETTERS.m

Go to the documentation of this file.
SDESGETLETTERS ;ALB/BWF - VISTA SCHEDULING RPCS ;JUNE 10, 2022
 ;;5.3;Scheduling;**819**;Aug 13, 1993;Build 5
 ;;Per VHA Directive 6402, this routine should not be modified
 ;
 Q
 ; return letter types for the LETTER TYPE file (#407.6)
GETLETTERTYPES(RES,EAS) ;
 N X,LCNT,LETARRY,ERR
 D VALIDATEEAS(.ERR,$G(EAS))
 I $D(ERR) D  Q
 .S ERR("LetterType",1)=""
 .D BUILDJSON^SDESBUILDJSON(.RES,.ERR)
 S X=0
 F  S X=$O(^VA(407.6,X)) Q:'X  D
 .S LCNT=$G(LCNT)+1
 .S LETARRY("LetterType",LCNT,"Type")=$$GET1^DIQ(407.6,X,.01,"E")
 .S LETARRY("LetterType",LCNT,"Name")=$$GET1^DIQ(407.6,X,1,"E")
 I '$D(LETARRY) S LETARRY("LetterType",1)=""
 D BUILDJSON^SDESBUILDJSON(.RES,.LETARRY)
 Q
 ; 407.5 - LETTER
 ; 407.6 - LETTER TYPE
 ; 403.52 - RECALL REMINDERS LETTERS
 ; get a list of all letters ,full text
 ; TYPE - type of letter (N - NO show, A - Appointment Cancellation, P - PreAppointment Cancellation, C - Clinic Cancelled)
 ; TEXT - (optional) text to match
 ; BRIEF - 1 for brief data return (no letter text), 0 or "" for full letter/letter text
GETLETTERSBYTYPE(RES,TYPE,TEXT,BRIEF,EAS) ;
 N LETIEN,LCNT,LETARRY,F,ERR
 S F=407.5
 D VALLETTERTYPE(.ERR,TYPE)
 D VALLETTERTEXT(.ERR,TEXT)
 D VALIDATEEAS(.ERR,$G(EAS))
 I $D(ERR) D  Q
 .S ERR("Letter",1)=""
 .D BUILDJSON^SDESBUILDJSON(.RES,.ERR) Q
 S (LETIEN,LCNT)=0
 F  S LETIEN=$O(^VA(F,"C",TYPE,LETIEN)) Q:'LETIEN  D
 .I $L($G(TEXT)),$E($$GET1^DIQ(F,LETIEN,.01,"E"),1,$L(TEXT))'=TEXT Q
 .D BUILDLETTER(.LETARRY,LETIEN,.LCNT,$G(BRIEF))
 I '$D(LETARRY) S LETARRY("Letter",1)=""
 D BUILDJSON^SDESBUILDJSON(.RES,.LETARRY)
 Q
 ;
GETLETTERBYIEN(RES,IEN,EAS)    ;
 N ERR,LETARRY,CNT
 D VALLETTERIEN(.ERR,IEN)
 D VALIDATEEAS(.ERR,$G(EAS))
 I $D(ERR) D  Q
 .S ERR("Letter",1)=""
 .D BUILDJSON^SDESBUILDJSON(.RES,.ERR) Q
 S CNT=$G(CNT)+1
 D BUILDLETTER(.LETARRY,IEN,.CNT)
 I '$D(LETARRY) S LETARRY("Letter",1)=""
 D BUILDJSON^SDESBUILDJSON(.RES,.LETARRY)
 Q
 ; BRIEF - indicates a brief list, without the letter text
BUILDLETTER(LETARRY,IEN,LCNT,BRIEF)    ;
 N LETDATA,LIENS,LETDATA,INITSEC,FINSEC,LIENS,F,LETTERIEN,LETTERTYPE
 S F=407.5
 S LCNT=$G(LCNT)+1
 S LIENS=IEN_","
 D GETS^DIQ(F,IEN_",","**","IE","LETDATA")
 S LETARRY("Letter",LCNT,"ID")=IEN
 S LETARRY("Letter",LCNT,"Name")=$G(LETDATA(F,LIENS,.01,"E"))
 S TYPE=$$GET1^DIQ(407.5,IEN,1,"E")
 S LETTERIEN=$O(^VA(407.6,"B",TYPE,0))
 S LETTERTYPE=$$GET1^DIQ(407.6,LETTERIEN,1,"E")
 S LETARRY("Letter",LCNT,"Type")=LETTERTYPE
 Q:$G(BRIEF)
 S LETARRY("Letter",LCNT,"PrintDefaultProvider")=$G(LETDATA(F,LIENS,4,"E"))
 S LETARRY("Letter",LCNT,"PrintClinicLocation")=$G(LETDATA(F,LIENS,5,"E"))
 S INITSEC=0
 F  S INITSEC=$O(LETDATA(F,LIENS,2,INITSEC)) Q:'INITSEC  D
 .S LETARRY("Letter",LCNT,"InitialSection",INITSEC)=$G(LETDATA(F,LIENS,2,INITSEC))
 S FINSEC=0
 F  S FINSEC=$O(LETDATA(F,LIENS,3,FINSEC)) Q:'FINSEC  D
 .S LETARRY("Letter",LCNT,"FinalSection",FINSEC)=$G(LETDATA(F,LIENS,3,FINSEC))
 Q
VALLETTERIEN(ERRORS,IEN)   ;
 I '$L($G(IEN)) D ERRLOG^SDESJSON(.ERRORS,227) Q
 I '$D(^VA(407.5,IEN)) D ERRLOG^SDESJSON(.ERRORS,225)
 Q
VALLETTERTYPE(ERRORS,TYPE) ;
 I '$L($G(TYPE)) D ERRLOG^SDESJSON(.ERRORS,228) Q
 I '$D(^VA(407.5,"C",TYPE)) D ERRLOG^SDESJSON(.ERRORS,226)
 Q
VALLETTERTEXT(ERRORS,TEXT)  ;
 I $L($G(TEXT)),$L($G(TEXT))<2 D ERRLOG^SDESJSON(.ERRORS,64)
 Q
VALIDATEEAS(ERRORS,SDEAS) ;
 I $L(SDEAS) S SDEAS=$$EASVALIDATE^SDESUTIL($G(SDEAS))
 I $P($G(SDEAS),U)=-1 D ERRLOG^SDESJSON(.ERRORS,142)
 Q