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

PXAIVAL.m

Go to the documentation of this file.
  1. PXAIVAL ;ISL/PKR - Validation for V-file input. ;05/31/2022
  1. ;;1.0;PCE PATIENT CARE ENCOUNTER;**211,217**;Aug 12, 1996;Build 134
  1. ;
  1. ;Some fields are the same for all the V-files, the same validation
  1. ;routine can be used for all of them.
  1. ;
  1. ;====================
  1. DATETIME(FIELDNAM,PXDT,%DT,PXAERR) ;Validate a date and time.
  1. I PXDT="@" Q 1
  1. ;Verify it is a valid FileMan date.
  1. I $$VFMDATE^PXDATE(PXDT,%DT)=-1 D Q 0
  1. . S PXAERR(9)=FIELDNAM
  1. . S PXAERR(11)=PXDT
  1. . S PXAERR(12)=PXDT_" is not a valid internal FileMan date."
  1. . I %DT'["R",%DT'["T" S PXAERR(13)="Time is not allowed for this date."
  1. ;
  1. ;Verify it is not a future date.
  1. I $$FUTURE^PXDATE(PXDT) D Q 0
  1. . S PXAERR(9)=FIELDNAM
  1. . S PXAERR(11)=PXDT
  1. . S PXAERR(12)=PXDT_" is a future date."
  1. Q 1
  1. ;
  1. ;====================
  1. EVENTDT(EVENTDT,%DT,PXAERR) ;Validate EVENT D/T.
  1. I EVENTDT="@" Q 1
  1. ;Verify it is a valid FileMan date.
  1. I $$VFMDATE^PXDATE(EVENTDT,%DT)=-1 D Q 0
  1. . S PXAERR(9)="EVENT D/T"
  1. . S PXAERR(11)=EVENTDT
  1. . S PXAERR(12)=EVENTDT_" is not a valid FileMan date."
  1. ;
  1. ;Verify it is not a future date.
  1. I $$FUTURE^PXDATE(EVENTDT) D Q 0
  1. . S PXAERR(9)="EVENT D/T"
  1. . S PXAERR(11)=EVENTDT
  1. . S PXAERR(12)=EVENTDT_" is a future date."
  1. Q 1
  1. ;
  1. ;====================
  1. MAG(MAG,MPARAMS,PXAERR) ;If a measurement is being input verify that the
  1. ;magnitude is in the allowed range.
  1. I MAG="@" D Q 0
  1. . S PXAERR(9)="MAGNITUDE"
  1. . S PXAERR(11)=MAG
  1. . S PXAERR(12)="Measurements cannot be deleted, they can be edited."
  1. I MAG="" D Q 0
  1. . S PXAERR(9)="MAGNITUDE"
  1. . S PXAERR(11)="NULL"
  1. . S PXAERR(12)="Magnitude cannot be NULL."
  1. ;
  1. N UCUMCHECK,UCUMCODE,UCUMERROR,UCUMIEN,UCUMSPECIAL
  1. S (UCUMERROR,UCUMSPECIAL)=0
  1. S UCUMIEN=$P(MPARAMS,U,4)
  1. I UCUMIEN="" D Q 0
  1. . S PXAERR(9)="UCUM CODE"
  1. . S PXAERR(11)="NULL"
  1. . S PXAERR(12)="UCUM CODE cannot be NULL."
  1. ;
  1. S UCUMCODE=$$UCUMCODE^LEXMUCUM(UCUMIEN)
  1. I $P(UCUMCODE,U,1)="{unit not defined}" D Q 0
  1. . S PXAERR(9)="UCUM CODE"
  1. . S PXAERR(11)="Unit not defined"
  1. . S PXAERR(12)=$P(UCUMCODE,U,2)
  1. ;
  1. ;There are two UCUM CODES where MAGNITUDE is not a
  1. ;number: {mm/dd/yyyy} and {clock_time}. These require
  1. ;special validation.
  1. S (UCUMERROR,UCUMSPECIAL)=0
  1. I UCUMCODE="{mm/dd/yyyy}" D
  1. . S UCUMSPECIAL=1
  1. . I MAG'?2N1"/"2N1"/"4N D
  1. .. S PXAERR(9)="UCUM month-day-year"
  1. .. S PXAERR(11)=MAG
  1. .. S PXAERR(12)=MAG_" does not follow the format mm/dd/yyyy."
  1. .. S UCUMERROR=1
  1. . I UCUMERROR=1 Q
  1. . N %DT,X,Y
  1. . S %DT="N",X=MAG
  1. . D ^%DT
  1. . I Y=-1 D
  1. .. S PXAERR(9)="UCUM month-day-year"
  1. .. S PXAERR(11)=MAG
  1. .. S PXAERR(12)=MAG_" is not a vaild date."
  1. .. S UCUMERROR=1
  1. I UCUMERROR=1 Q 0
  1. ;
  1. I UCUMCODE="{clock_time}" D
  1. . S UCUMSPECIAL=1
  1. . I MAG'?1.2N1":"2N1(1"AM",1"PM") D
  1. .. S PXAERR(9)="UCUM clock time e.g 12:30PM"
  1. .. S PXAERR(11)=MAG
  1. .. S PXAERR(12)=MAG_" does not follow the format HH:MMAM or HH:MMPM."
  1. .. S UCUMERROR=1
  1. . I UCUMERROR=1 Q
  1. . N HH,MM
  1. . S HH=$P(MAG,":",1)
  1. . I (HH<1)!(HH>12) D
  1. .. S PXAERR(9)="UCUM clock time e.g 12:30PM"
  1. .. S PXAERR(11)=MAG
  1. .. S PXAERR(12)=HH_" is not a valid hour."
  1. .. S UCUMERROR=1
  1. . I UCUMERROR=1 Q
  1. . S MM=$P(MAG,":",2),MM=$E(MM,1,2)
  1. . I (MM<1)!(MM>59) D
  1. .. S PXAERR(9)="UCUM clock time e.g 12:30PM"
  1. .. S PXAERR(11)=MAG
  1. .. S PXAERR(12)=MM_" is not valid for minutes."
  1. .. S UCUMERROR=1
  1. I UCUMERROR=1 Q 0
  1. I UCUMSPECIAL=1 Q 1
  1. ;
  1. ;Check for a valid magnitude, a positive or negative number,
  1. ;up to 14 digits and 9 decimal places.
  1. I MAG'?0.1(0.1"-",0.1"+")0.14N0.1(1"."0.9N) D Q 0
  1. . S PXAERR(9)="MAGNITUDE"
  1. . S PXAERR(11)=MAG
  1. . S PXAERR(12)="Magnitude "_MAG_", is not a number in the acceptable range."
  1. N MAX,MAXDEC,MIN,NUM,NUMDEC
  1. S MIN=$P(MPARAMS,U,1),MAX=$P(MPARAMS,U,2),MAXDEC=$P(MPARAMS,U,3)
  1. S NUM=+PXAA("MAGNITUDE")
  1. I (MIN>NUM)!(MAX<NUM) D Q 0
  1. . S PXAERR(9)="MAGNITUDE"
  1. . S PXAERR(11)=MAG
  1. . S PXAERR(12)="Magnitude "_MAG_" is outside the range "_MIN_" to "_MAX
  1. S NUMDEC=$L($P(NUM,".",2))
  1. I NUMDEC>MAXDEC D Q 0
  1. . S PXAERR(9)="MAGNITUDE"
  1. . S PXAERR(11)=MAG
  1. . S PXAERR(12)="The maximum number of decimals is "_MAXDEC_", the input contains "_NUMDEC_"."
  1. ;If magnitude is a fraction does not start with 0 add it.
  1. Q 1
  1. ;
  1. ;====================
  1. PRV(PXDUZ,PRVTYPE,PXAA,PXAERR,PXAVISIT) ;Validate a provider.
  1. ;PRVTYP can be "ENC PROVIDER" or "ORD PROVIDER".
  1. I '$$VPRV^PXAIPRVV(PXDUZ,.PXAA,.PXAERR,PXAVISIT) D Q 0
  1. . S PXAERR(9)=PRVTYPE_" PROVIDER"
  1. . S PXAERR(11)=PXDUZ
  1. Q 1
  1. ;
  1. ;====================
  1. SET(FILENUM,FIELDNAM,FIELDNUM,VALUE,PXAERR) ;Validate Set of Codes input.
  1. I VALUE="@" Q 1
  1. N EXTERNAL,MSG
  1. S EXTERNAL=$$EXTERNAL^DILFD(FILENUM,FIELDNUM,"",VALUE,"MSG")
  1. I (EXTERNAL=""),$D(MSG) D Q 0
  1. . S PXAERR(9)=FIELDNAM
  1. . S PXAERR(11)=VALUE
  1. . S PXAERR(12)=MSG("DIERR",1,"TEXT",1)
  1. . S PXAERR(13)=MSG("DIERR",1,"TEXT",2)
  1. Q 1
  1. ;
  1. ;====================
  1. TEXT(FIELDNAM,TEXT,MIN,MAX,PXAERR) ;Validate a free text field.
  1. I TEXT="@" Q 1
  1. I (($L(TEXT)<MIN)!($L(TEXT)>MAX)) D Q 0
  1. . S PXAERR(9)=FIELDNAM
  1. . S PXAERR(11)=TEXT
  1. . S PXAERR(12)="The length of "_FIELDNAM_" is less than "_MIN_" or greater than "_MAX_"."
  1. Q 1
  1. ;
  1. ;====================
  1. VPKG(PKG,PXAERR) ;Is the Package parameter valid?
  1. N FLAGS,IEN,MSG
  1. S FLAGS=$S(+PKG=PKG:"A",1:"M")
  1. S IEN=+$$FIND1^DIC(9.4,"",FLAGS,PKG,"","","MSG")
  1. I IEN=0 D Q 0
  1. . S PXAERR(9)="PKG"
  1. . S PXAERR(11)="The value is: "_PKG
  1. . I FLAGS="A" S PXAERR(12)=PKG_" is not a valid pointer to the Package file #9.4"
  1. . I FLAGS="M" S PXAERR(12)=$G(MSG("DIERR",1,"TEXT",1))
  1. Q IEN
  1. ;
  1. ;====================
  1. VSOURCE(SOURCE,PXAERR) ;Is the Data Source valid?
  1. I +SOURCE=SOURCE,($D(^PX(839.7,SOURCE,0))) Q SOURCE
  1. I +SOURCE=SOURCE,('$D(^PX(839.7,SOURCE,0))) D Q Q
  1. . S PXAERR(7)="ENCOUNTER"
  1. . S PXAERR(9)="DATA2PCE parameter SOURCE"
  1. . S PXAERR(11)="The value is: "_SOURCE
  1. . S PXAERR(12)=SOURCE_" is not a valid pointer to the PCE Data Source file #839.7"
  1. ;
  1. I ($L(SOURCE)<3)!($L(SOURCE)>64) D Q 0
  1. . S PXAERR(7)="ENCOUNTER"
  1. . S PXAERR(9)="DATA2PCE parameter SOURCE"
  1. . S PXAERR(11)="The value is: "_SOURCE
  1. . S PXAERR(12)="The length of SOURCE is less than 3 or greater than 64."
  1. Q $$SOURCE^PXAPIUTL(SOURCE)
  1. ;