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

SDES2VAL44.m

Go to the documentation of this file.
SDES2VAL44 ;ALB/BWF,MGD/BLB - SDES2 Clinic validation utilities ;DEC 31, 2023
 ;;5.3;Scheduling;**853,857,864,866,871**;Aug 13, 1993;Build 13
 ;;Per VHA Directive 6402, this routine should not be modified
 ;
 Q
 ; ISREQUIRED - 1       = true  - this forces a clinic ien to be passed in and must be valid
 ;              0 or "" = false - the incoming value of "" will pass validation - i.e. not required
 ; ALLOWDELETE - 1      = true  - this allows '@' to be valid for deletion. "" is also valid since
 ;                                it does the same as '@' from a data perspective
 ;              0 or "" = false - '@' will not be valid
VALCLINIEN(ERRORS,SDIEN,ISREQUIRED,ALLOWDELETE) ;
 I $G(ISREQUIRED),SDIEN="" D ERRLOG^SDES2JSON(.ERRORS,18) Q
 I '$G(ISREQUIRED),SDIEN="" Q
 I $G(ALLOWDELETE),(SDIEN="@")!(SDIEN="") Q
 I '$G(ALLOWDELETE),SDIEN="@" D ERRLOG^SDES2JSON(.ERRORS,229,"Clinic ID") Q
 I '$D(^SC(SDIEN,0)) D ERRLOG^SDES2JSON(.ERRORS,19)
 Q
 ;
VALNAME(ERRORS,SDNAME,FDATA) ; required - cannot be deleted with @ or "" - can be changed
 I SDNAME="@" D ERRLOG^SDES2JSON(.ERRORS,229,"Clinic Name") Q
 I SDNAME="" D ERRLOG^SDES2JSON(.ERRORS,50) Q
 S SDNAME=$$UP^XLFSTR(SDNAME)
 I $L(SDNAME)>30!($L(SDNAME)<2)!'(SDNAME'?1P.E)!(SDNAME'?.ANP) D ERRLOG^SDES2JSON(.ERRORS,51) Q
 I SDNAME'="",$D(^SC("B",$E(SDNAME,1,30))) D ERRLOG^SDES2JSON(.ERRORS,481) Q
 S FDATA("NAME")=SDNAME
 Q
 ;
VALABBR(ERRORS,SDABR,FDATA) ;
 I SDABR="@" S FDATA("ABBREVIATION")="" Q
 I SDABR'="",$L(SDABR)>7 D ERRLOG^SDES2JSON(.ERRORS,251) Q
 S FDATA("ABBREVIATION")=SDABR
 Q
 ;
VALPATFNAME(ERRORS,SDPATNAME,FDATA) ;
 I SDPATNAME="@" S FDATA("PATIENT FRIENDLY NAME")="" Q
 I SDPATNAME'="",(($L(SDPATNAME)<3)!($L(SDPATNAME)>80)) D ERRLOG^SDES2JSON(.ERRORS,482) Q
 S FDATA("PATIENT FRIENDLY NAME")=SDPATNAME
 Q
 ;
VALMEETATFACIL(ERRORS,SDMEETATFAC,FDATA) ; required, cannot be deleted with "@" or "" - can be changed
 I SDMEETATFAC="@" D ERRLOG^SDES2JSON(.ERRORS,229,"Clinic meets at this facility?") Q
 ; Default to Y like SDBUILD
 I SDMEETATFAC="" S SDMEETATFAC="Y"
 I '$$CHECKYN^SDES2UTIL(SDMEETATFAC) D ERRLOG^SDES2JSON(.ERRORS,87) Q
 S FDATA("MEETS AT FACILITY")=SDMEETATFAC
 Q
 ;
VALDIRPATSCHED(ERRORS,SDPATSCHED,FDATA) ; required, cannot be deleted with "@" or "" - can be changed
 I SDPATSCHED="@" D ERRLOG^SDES2JSON(.ERRORS,229,"Direct Patient Scheduling") Q
 I SDPATSCHED="" D ERRLOG^SDES2JSON(.ERRORS,88) Q
 I '$$CHECKYN^SDES2UTIL(SDPATSCHED) D ERRLOG^SDES2JSON(.ERRORS,89) Q
 S FDATA("DIRECT PATIENT SCHEDULING")=SDPATSCHED
 Q
 ;
VALDISPAPPT(ERRORS,SDCLINIC,FDATA) ; required, cannot be deleted with "@" or "" - can be changed
 N SDDISPAPPT
 S SDDISPAPPT=$G(SDCLINIC("DISPLAY APPOINTMENTS"))
 I SDDISPAPPT="@" D ERRLOG^SDES2JSON(.ERRORS,229,"Display Clinic Appointment to Patients") Q
 I SDDISPAPPT="" D ERRLOG^SDES2JSON(.ERRORS,90) Q
 I '$$CHECKYN^SDES2UTIL(SDDISPAPPT) D ERRLOG^SDES2JSON(.ERRORS,91)
 S FDATA("DISPLAY APPOINTMENTS")=SDDISPAPPT
 Q
 ;
VALSERVICE(ERRORS,SDCLINIC,FDATA) ; required, cannot be deleted with @ or "" - can be changed
 N VRET
 D VALFIELD^SDES2VALUTIL(.VRET,.ERRORS,44,9,$G(SDCLINIC("SERVICE")),1,,92,93,229)
 S FDATA("SERVICE")=$G(VRET(44,9,"I"))
 Q
 ;
VALNONCOUNT(ERRORS,SDCLINIC,FDATA) ; required, cannot be deleted with "@" or "" - can be changed
 N SDNONCOUNT
 S SDNONCOUNT=$G(SDCLINIC("NON-COUNT"))
 I SDNONCOUNT="" D ERRLOG^SDES2JSON(.ERRORS,94) Q
 I SDNONCOUNT="@" D ERRLOG^SDES2JSON(.ERRORS,229,"Non-count Clinic") Q
 I '$$CHECKYN^SDES2UTIL(SDNONCOUNT) D ERRLOG^SDES2JSON(.ERRORS,95) Q
 S FDATA("NON-COUNT")=SDNONCOUNT
 Q
 ;
VALDIV(ERRORS,SDCLINIC,FDATA) ; required field, cannot be deleted with @ or "" - can be changed
 N SDDIVISION
 S SDDIVISION=$G(SDCLINIC("DIVISION"))
 I SDDIVISION="@" D ERRLOG^SDES2JSON(.ERRORS,229,"Division") Q
 I SDDIVISION="" D ERRLOG^SDES2JSON(.ERRORS,96) Q
 I +SDDIVISION,$D(^DG(40.8,SDDIVISION,0)) S FDATA("DIVISION")=SDDIVISION Q
 S SDDIVISION=$O(^DG(40.8,"B",$E(SDDIVISION,1,30),"A"),-1)
 I SDDIVISION="" S SDDIVISION=$G(SDCLINIC("DIVISION")),SDDIVISION=$O(^DG(40.8,"C",$E(SDDIVISION,1,30),""),-1)
 I 'SDDIVISION D ERRLOG^SDES2JSON(.ERRORS,97) Q
 S FDATA("DIVISION")=SDDIVISION
 Q
 ;
VALINCPERHOUR(ERRORS,SDCLINIC,FDATA) ; required field, cannot be deleted with @ or "" - can't be changed
 N SDDISINCPERHOUR,ERR
 S SDDISINCPERHOUR=$G(SDCLINIC("DISPLAY INCREMENTS PER HOUR"))
 I SDDISINCPERHOUR="" D ERRLOG^SDES2JSON(.ERRORS,117) Q
 I SDDISINCPERHOUR="@" D ERRLOG^SDES2JSON(.ERRORS,229) Q
 I SDDISINCPERHOUR'="" D
 .S ERR='$F("^60^30^20^15^10^","^"_SDDISINCPERHOUR_"^")
 .I ERR D ERRLOG^SDES2JSON(.ERRORS,118) Q
 .S SDDISINCPERHOUR=60\SDDISINCPERHOUR
 .S FDATA("DISPLAY INCREMENTS PER HOUR")=SDDISINCPERHOUR
 Q
 ;
VALAPPTTYPE(ERRORS,SDCLINIC,FDATA) ;
 N SDAPPTTYP
 S SDAPPTTYP=$G(SDCLINIC("DEFAULT APPOINTMENT TYPE"))
 I SDAPPTTYP=""!(SDAPPTTYP="@") S FDATA("DEFAULT APPOINTMENT TYPE")="" Q
 I +SDAPPTTYP,$D(^SD(409.1,SDAPPTTYP,0)) S FDATA("DEFAULT APPOINTMENT TYPE")=SDAPPTTYP Q
 S SDAPPTTYP=$O(^SD(409.1,"B",$E(SDAPPTTYP,1,30),""),-1)
 I 'SDAPPTTYP D ERRLOG^SDES2JSON(.ERRORS,83) Q
 I SDAPPTTYP S FDATA("DEFAULT APPOINTMENT TYPE")=SDAPPTTYP Q
 ;
VALINPATMED(ERRORS,SDCLINIC,FDATA) ;
 N SDINPATMED
 S SDINPATMED=$G(SDCLINIC("ADMIN INPATIENT MEDS"))
 I SDINPATMED="@"!(SDINPATMED="") S FDATA("ADMIN INPATIENT MEDS")="" Q
 I SDINPATMED'="Y" D ERRLOG^SDES2JSON(.ERRORS,122) Q
 S FDATA("ADMIN INPATIENT MEDS")=$$YNTOBOOL^SDES2UTIL(SDINPATMED)
 Q
 ;
VALPHONE(ERRORS,SDPHONE,FDATA) ;
 I SDPHONE=""!(SDPHONE="@") S FDATA("TELEPHONE")="" Q
 I $L(SDPHONE)<3!($L(SDPHONE)>13) D ERRLOG^SDES2JSON(.ERRORS,483) Q
 S FDATA("TELEPHONE")=SDPHONE
 Q
VALPHONEEXT(ERRORS,SDPHONEEXT,FDATA) ;
 I SDPHONEEXT=""!(SDPHONEEXT="@") S FDATA("TELEPHONE EXTENSION")="" Q
 I $L(SDPHONEEXT)>26 D ERRLOG^SDES2JSON(.ERRORS,424) Q
 S FDATA("TELEPHONE EXTENSION")=SDPHONEEXT
 Q
 ;
VALXRAY(ERRORS,SDREQXRAY,FDATA) ;
 I SDREQXRAY="@"!(SDREQXRAY="") S FDATA("REQUIRE X-RAY")="" Q
 I SDREQXRAY'="Y" D ERRLOG^SDES2JSON(.ERRORS,123) Q
 S FDATA("REQUIRE X-RAY")=SDREQXRAY
 Q
 ;
VALSCHEDHOLIDAY(ERRORS,SDSCHEDHOLIDAY,FDATA) ; SCHEDULE ON HOLIDAYS?
 I SDSCHEDHOLIDAY="@"!(SDSCHEDHOLIDAY="") S FDATA("SCHEDULE ON HOLIDAYS")="" Q
 I SDSCHEDHOLIDAY'="",SDSCHEDHOLIDAY'="Y" D ERRLOG^SDES2JSON(.ERRORS,360) Q
 S FDATA("SCHEDULE ON HOLIDAYS")=SDSCHEDHOLIDAY
 Q
 ;
VALPROFILE(ERRORS,SDCLINIC,FDATA) ; required - cannot be deleted with '@' or "" - can be changed
 N SDREQPROFILE
 S SDREQPROFILE=$G(SDCLINIC("REQUIRE ACTION PROFILES"))
 I SDREQPROFILE="" D ERRLOG^SDES2JSON(.ERRORS,477) Q
 I SDREQPROFILE="@" D ERRLOG^SDES2JSON(.ERRORS,229,"Require Action Profiles") Q
 I '$$CHECKYN^SDES2UTIL(SDREQPROFILE) D ERRLOG^SDES2JSON(.ERRORS,100) Q
 S SDREQPROFILE=$$YNTOBOOL^SDES2UTIL(SDREQPROFILE)
 I SDREQPROFILE?1N S FDATA("REQUIRE ACTION PROFILES")='SDREQPROFILE   ;Because this field is defined oddly where 1=No and 0=Yes
 Q
 ;
VALNOSHOWLET(ERRORS,SDCLINIC,FDATA) ;
 N SDNOSHOWLET,NOSHOWERRORS
 S SDNOSHOWLET=$G(SDCLINIC("NO-SHOW LETTER"))
 I SDNOSHOWLET=""!(SDNOSHOWLET="@") S FDATA("NO-SHOW LETTER")="" Q
 S SDNOSHOWLET=$$LETTERIEN(.NOSHOWERRORS,SDNOSHOWLET)
 I 'SDNOSHOWLET D ERRLOG^SDES2JSON(.ERRORS,82,"No-show") Q
 S FDATA("NO-SHOW LETTER")=SDNOSHOWLET
 Q
 ;
VALPREAPTLET(ERRORS,SDCLINIC,FDATA) ;
 N SDPREAPTLET,PREAPTERRORS
 S SDPREAPTLET=$G(SDCLINIC("PRE-APPOINTMENT LETTER"))
 I SDPREAPTLET=""!(SDPREAPTLET="@") S FDATA("PRE-APPOINTMENT LETTER")="" Q
 S SDPREAPTLET=$$LETTERIEN(.PREAPTERRORS,SDPREAPTLET)
 I 'SDPREAPTLET D ERRLOG^SDES2JSON(.ERRORS,82,"Pre appointment") Q
 S FDATA("PRE-APPOINTMENT LETTER")=SDPREAPTLET
 Q
 ;
VALCANLET(ERRORS,SDCLINIC,FDATA) ;
 N SDCANLET,CANLETERRORS
 S SDCANLET=$G(SDCLINIC("CLINIC CANCELLATION LETTER"))
 I SDCANLET=""!(SDCANLET="@") S FDATA("CLINIC CANCELLATION LETTER")="" Q
 S SDCANLET=$$LETTERIEN(.CANLETERRORS,SDCANLET)
 I 'SDCANLET D ERRLOG^SDES2JSON(.ERRORS,82,"Clinic cancellation") Q
 S FDATA("CLINIC CANCELLATION LETTER")=SDCANLET
 Q
 ;
VALAPTCANLET(ERRORS,SDCLINIC,FDATA) ;
 N SDAPTCANLET,CANLETERRORS
 S SDAPTCANLET=$G(SDCLINIC("APPOINTMENT CANCELLATION LETTER"))
 I SDAPTCANLET=""!(SDAPTCANLET="@") S FDATA("APPOINTMENT CANCELLATION LETTER")="" Q
 S SDAPTCANLET=$$LETTERIEN(.CANLETERRORS,SDAPTCANLET)
 I 'SDAPTCANLET D ERRLOG^SDES2JSON(.ERRORS,82,"Appointment cancellation") Q
 S FDATA("APPOINTMENT CANCELLATION LETTER")=SDAPTCANLET
 Q
 ;
VALINOUTTIME(ERRORS,SDCLINIC,FDATA) ;
 N SDINOUTTIME
 S SDINOUTTIME=$G(SDCLINIC("ASK CHECK IN/OUT"))
 I SDINOUTTIME="@"!(SDINOUTTIME="") S FDATA("ASK CHECK IN/OUT")="" Q
 I '$$CHECKYN^SDES2UTIL(SDINOUTTIME) D ERRLOG^SDES2JSON(.ERRORS,101) Q
 S SDINOUTTIME=$$YNTOBOOL^SDES2UTIL(SDINOUTTIME)
 S FDATA("ASK CHECK IN/OUT")=SDINOUTTIME
 Q
 ;
VALSTARTHOUR(ERRORS,SDSTARTHR,FDATA) ; HOUR CLINIC DISPLAY BEGINS
 I SDSTARTHR="" S SDSTARTHR=8 ;default
 I SDSTARTHR'="" S SDSTARTHR=+SDSTARTHR
 I SDSTARTHR>16 D ERRLOG^SDES2JSON(.ERRORS,119) Q
 S FDATA("HOUR CLINIC DISPLAY BEGINS")=SDSTARTHR
 Q
 ;
VALDEFAULTTOPRAC(ERRORS,SDCLINIC,FDATA) ;
 N SDPRACTIONER
 S SDPRACTIONER=$G(SDCLINIC("DEFAULT TO PC PRACTITIONER"))
 I SDPRACTIONER="@"!(SDPRACTIONER="") S FDATA("DEFAULT TO PC PRACTITIONER")="" Q
 I '$$CHECKYN^SDES2UTIL(SDPRACTIONER) D ERRLOG^SDES2JSON(.ERRORS,102) Q
 S SDPRACTIONER=$$YNTOBOOL^SDES2UTIL(SDPRACTIONER)
 S FDATA("DEFAULT TO PC PRACTITIONER")=SDPRACTIONER
 Q
 ;
VALWORKLOAD(ERRORS,SDCLINIC,FDATA) ;
 N SDWORKLOAD
 S SDWORKLOAD=$G(SDCLINIC("WORKLOAD VALIDATION"))
 I SDWORKLOAD="@"!(SDWORKLOAD="") S FDATA("WORKLOAD VALIDATION")="" Q
 I '$$CHECKYN^SDES2UTIL(SDWORKLOAD) D ERRLOG^SDES2JSON(.ERRORS,103) Q
 S SDWORKLOAD=$$YNTOBOOL^SDES2UTIL(SDWORKLOAD)
 S FDATA("WORKLOAD VALIDATION")=SDWORKLOAD
 Q
 ;
VALALLOWNOSHOW(ERRORS,SDALLOWNOSHW,FDATA) ; required - cannot be deleted with '@' or "" - can be changed
 I SDALLOWNOSHW="@" D ERRLOG^SDES2JSON(.ERRORS,229,"Allowable Consecutive No-Shows") Q
 I SDALLOWNOSHW="" D ERRLOG^SDES2JSON(.ERRORS,104) Q
 I SDALLOWNOSHW["."!(SDALLOWNOSHW'?1.3N) D ERRLOG^SDES2JSON(.ERRORS,105) Q
 S FDATA("ALLOWABLE CONSECUTIVE NO-SHOWS")=SDALLOWNOSHW
 Q
 ;
VALMAXFUTBOOK(ERRORS,SDMAXFUTBOOK,FDATA) ; required, cannot be deleted with '@' or "" - can be changed
 I SDMAXFUTBOOK="@" D ERRLOG^SDES2JSON(.ERRORS,229,"Max # Days for Future Booking") Q
 I SDMAXFUTBOOK="" D ERRLOG^SDES2JSON(.ERRORS,106) Q
 I SDMAXFUTBOOK'?1.3N D ERRLOG^SDES2JSON(.ERRORS,107) Q
 I SDMAXFUTBOOK["."!((SDMAXFUTBOOK<11)!(SDMAXFUTBOOK>999)) D ERRLOG^SDES2JSON(.ERRORS,107) Q
 S FDATA("MAX DAYS FUTURE BOOKING")=SDMAXFUTBOOK
 Q
 ;
VALNOACCESS(ERRORS,SDNOACCESS,FDATA)  ;
 I SDNOACCESS="@"!(SDNOACCESS="") S FDATA("PROHIBIT ACCESS TO CLINIC")="" Q
 I SDNOACCESS'="Y" D ERRLOG^SDES2JSON(.ERRORS,485) Q
 S FDATA("PROHIBIT ACCESS TO CLINIC")=SDNOACCESS
 Q
 ;
VALINCLUDEFROOM(ERRORS,SDFILEROOM,FDATA) ;
 I SDFILEROOM="@"!(SDFILEROOM="") S FDATA("INCLUDE ON FILE ROOM LISTS")="" Q
 I '$$CHECKYN^SDES2UTIL(SDFILEROOM) D ERRLOG^SDES2JSON(.ERRORS,495) Q
 S FDATA("INCLUDE ON FILE ROOM LISTS")=SDFILEROOM
 Q
 ;
VALLOCATION(ERRORS,SDLOCATION,FDATA) ;
 I SDLOCATION=""!(SDLOCATION="@") S FDATA("PHYSICAL LOCATION")="" Q
 I $L(SDLOCATION)<1!($L(SDLOCATION)>25) D ERRLOG^SDES2JSON(.ERRORS,484) Q
 S FDATA("PHYSICAL LOCATION")=SDLOCATION
 Q
 ;
VALPRINCLINIC(ERRORS,SDPRINCLINIC,FDATA) ;
 I SDPRINCLINIC="@"!(SDPRINCLINIC="") S FDATA("PRINCIPAL CLINIC")="" Q
 I +SDPRINCLINIC,$$INACTIVE^SDES2UTIL(SDPRINCLINIC,DT) D ERRLOG^SDES2JSON(.ERRORS,510,SDPRINCLINIC) Q
 I +SDPRINCLINIC,$D(^SC(SDPRINCLINIC,0)) S FDATA("PRINCIPAL CLINIC")=SDPRINCLINIC Q
 S SDPRINCLINIC=$O(^SC("B",$E(SDPRINCLINIC,1,30),""),-1)
 I SDPRINCLINIC="" D ERRLOG^SDES2JSON(.ERRORS,110) Q
 I $$INACTIVE^SDES2UTIL(SDPRINCLINIC,DT) D ERRLOG^SDES2JSON(.ERRORS,510,$$GET1^DIQ(44,SDPRINCLINIC,.01,"E")) Q
 S FDATA("PRINCIPAL CLINIC")=SDPRINCLINIC
 Q
 ;
VALOVBDAYMAX(ERRORS,SDCLINIC,FDATA)   ; required, cannot be deleted with '@' or "" - can be changed
 N SDOVBDAYMAX
 S SDOVBDAYMAX=$G(SDCLINIC("OVERBOOKS/DAY MAX"))
 I SDOVBDAYMAX="@" D ERRLOG^SDES2JSON(.ERRORS,229,"Overbooks/Day Maximum") Q
 I SDOVBDAYMAX="" D ERRLOG^SDES2JSON(.ERRORS,111) Q
 I SDOVBDAYMAX'?1.4N D ERRLOG^SDES2JSON(.ERRORS,112) Q
 S FDATA("OVERBOOKS/DAY MAX")=SDOVBDAYMAX
 Q
 ;
VALCHECKIN(ERRORS,SDCLINIC,FDATA) ; required, cannot be deleted with '@' or "" - can be changed
 N SDECHECKIN
 S SDECHECKIN=$G(SDCLINIC("E-CHECKIN ALLOWED"))
 I SDECHECKIN="" D ERRLOG^SDES2JSON(.ERRORS,478) Q
 I SDECHECKIN="@" D ERRLOG^SDES2JSON(.ERRORS,229,"E-Checkin Allowed") Q
 I '$$CHECKYN^SDES2UTIL(SDECHECKIN) D ERRLOG^SDES2JSON(.ERRORS,113) Q
 S SDECHECKIN=$$YNTOBOOL^SDES2UTIL(SDECHECKIN)
 S FDATA("E-CHECKIN ALLOWED")=SDECHECKIN
 Q
 ;
VALPRECHECKIN(ERRORS,SDCLINIC,FDATA) ; required, cannot be deleted with '@' or "" - can be changed
 N SDPRECHECKIN
 S SDPRECHECKIN=$G(SDCLINIC("PRE-CHECKIN ALLOWED"))
 I SDPRECHECKIN="" D ERRLOG^SDES2JSON(.ERRORS,476) Q
 I SDPRECHECKIN="@" D ERRLOG^SDES2JSON(.ERRORS,229,"Pre-Check-in Allowed") Q
 I '$$CHECKYN^SDES2UTIL(SDPRECHECKIN) D ERRLOG^SDES2JSON(.ERRORS,114) Q
 S SDPRECHECKIN=$$YNTOBOOL^SDES2UTIL(SDPRECHECKIN)
 S FDATA("PRE-CHECKIN ALLOWED")=SDPRECHECKIN
 Q
 ;
VALAPPTLENGTH(ERRORS,SDLENGTHOFAPT,FDATA) ; required, cannot be deleted with '@' or "" - can be changed
 I SDLENGTHOFAPT="@" D ERRLOG^SDES2JSON(.ERRORS,229,"Length of Appointment") Q
 I SDLENGTHOFAPT="" D ERRLOG^SDES2JSON(.ERRORS,115) Q
 I ((SDLENGTHOFAPT<10)!(SDLENGTHOFAPT>240)) D ERRLOG^SDES2JSON(.ERRORS,116) Q
 I (SDLENGTHOFAPT#10'=0),(SDLENGTHOFAPT#15'=0) D ERRLOG^SDES2JSON(.ERRORS,116) Q
 S FDATA("LENGTH OF APPOINTMENT")=SDLENGTHOFAPT
 Q
 ;
VALVARAPTLENGTH(ERRORS,SDCLINIC,FDATA) ;
 N SDVARAPTLNG
 S SDVARAPTLNG=$G(SDCLINIC("VARIABLE APPOINTMENT LENGTH"))
 I SDVARAPTLNG="@"!(SDVARAPTLNG="") S FDATA("VARIABLE APPOINTMENT LENGTH")="" Q
 I '$$CHECKYN^SDES2UTIL(SDVARAPTLNG) D ERRLOG^SDES2JSON(.ERRORS,301) Q
 I SDVARAPTLNG="Y" S SDVARAPTLNG="V",FDATA("VARIABLE APPOINTMENT LENGTH")=SDVARAPTLNG Q
 S SDVARAPTLNG=""
 S FDATA("VARIABLE APPOINTMENT LENGTH")=SDVARAPTLNG
 Q
 ;
VALPRIMAMIS(ERRORS,SDCLINIC,FDATA) ; PRIMARY AMIS STOP CODE
 N SDPRIMAMIS,SDAMISERROR
 S SDPRIMAMIS=$G(SDCLINIC("PRIMARY AMIS"))
 I SDPRIMAMIS="" D ERRLOG^SDES2JSON(.ERRORS,479) Q
 I SDPRIMAMIS="@" D ERRLOG^SDES2JSON(.ERRORS,229,"Primary AMIS") Q
 S SDAMISERROR=$$VALIDATEAMIS^SDES2UTIL(.SDPRIMAMIS,"P")
 I SDAMISERROR D ERRLOG^SDES2JSON(.ERRORS,SDAMISERROR) Q
 S FDATA("PRIMARY AMIS")=SDPRIMAMIS
 Q
 ;
VALCREDITAMIS(ERRORS,SDCLINIC,FDATA) ; CREDIT AMIS STOP CODE
 N SDCREDITAMIS,SDAMISERROR
 S SDCREDITAMIS=$G(SDCLINIC("CREDIT AMIS"))
 I SDCREDITAMIS=""!(SDCREDITAMIS="@") S FDATA("CREDIT AMIS")=SDCREDITAMIS Q
 S SDAMISERROR=$$VALIDATEAMIS^SDES2UTIL(.SDCREDITAMIS,"C")
 I SDAMISERROR D ERRLOG^SDES2JSON(.ERRORS,SDAMISERROR) Q
 S FDATA("CREDIT AMIS")=SDCREDITAMIS
 Q
 ;
CONDAMISCHECK(ERRORS,SDPRIMAMIS,SDCREDITAMIS) ;
 ; Primary & Credit Stop Codes can't be the same
 I SDPRIMAMIS=SDCREDITAMIS D ERRLOG^SDES2JSON(.ERRORS,380)
 Q
 ;
LETTERIEN(ERRORS,LETTER) ;Look up the letter IEN
 I LETTER'="@",LETTER'="" D
 .I +LETTER,$$GET1^DIQ(407.5,LETTER,.01)'="" Q
 .S LETTER=$O(^VA(407.5,"B",$E(LETTER,1,30),""))
 Q LETTER
 ;
VALPBSPID(ERRORS,PBSPID,FDATA) ;
 N VAL
 I $L(PBSPID)>100 D ERRLOG^SDES2JSON(.ERRORS,556)
 S FDATA("PBSPID")=PBSPID
 Q
 ;