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

PXAIPOVV.m

Go to the documentation of this file.
  1. PXAIPOVV ;ISL/JVS,PKR - VALIDATE DIAGNOSIS ;02/04/2021
  1. ;;1.0;PCE PATIENT CARE ENCOUNTER;**121,194,199,211**;Aug 12, 1996;Build 454
  1. ;
  1. ;Reference to ICDEX supported by ICR #5747.
  1. ;
  1. ERRSET ;Set the rest of the error data.
  1. S STOP=1
  1. S PXAERRF("POV")=1
  1. S PXADI("DIALOG")=8390001.001
  1. S PXAERR(7)="DX/PL"
  1. Q
  1. ;
  1. PRIM(VISITIEN,PXADATA,PXAERRF) ;Make sure there is only one primary diagnosis.
  1. N DIAG,IND,NPDIAG,NPDN,PDLISTN,PRIM
  1. S IND=0
  1. F S IND=+$O(@PXADATA@("DX/PL",IND)) Q:IND=0 D
  1. . S DIAG=$G(@PXADATA@("DX/PL",IND,"DIAGNOSIS"))
  1. . I DIAG="" Q
  1. . S PRIM=$G(@PXADATA@("DX/PL",IND,"PRIMARY"))
  1. .;Check for a change to the existing primary diagnosis.
  1. . I $D(PDLISTE(DIAG)) D
  1. .. I +$G(@PXADATA@("DX/PL",IND,"DELETE")) K PDLISTE(DIAG) Q
  1. .. I (PRIM=0)!(PRIM="S") K PDLISTE(DIAG)
  1. .;Check for adding a new primary diagnosis.
  1. . I (PRIM=1)!(PRIM="P") S PDLISTN(DIAG)=""
  1. . I +$G(@PXADATA@("DX/PL",IND,"DELETE")) K PDLISTN(DIAG) Q
  1. ;
  1. S DIAG="",NPDN=0
  1. F S DIAG=$O(PDLISTN(DIAG)) Q:DIAG="" S NPDN=NPDN+1,NPDIAG(NPDN)=DIAG
  1. ;
  1. I NPDN>1 D Q
  1. . S PXAERR(9)="DIAGNOSIS"
  1. . S PXAERR(12)=NPDN_" diagnoses have been designated as primary, there can only be one."
  1. . S PXAERR(12)=PXAERR(12)_" They are: "
  1. . F IND=1:1:NPDN S PXAERR(12)=PXAERR(12)_$S(IND=1:" ",1:",")_NPDIAG(IND)
  1. . D ERRSET
  1. Q
  1. ;
  1. VAL ;Validate the input data.
  1. I $G(PXAA("DIAGNOSIS"))="" D Q
  1. . S PXAERR(9)="DIAGNOSIS"
  1. . S PXAERR(12)="The ICD diagnosis is missing."
  1. . D ERRSET
  1. ;
  1. ;Save the code or the pointer.
  1. S PXAERR(11)=$G(PXAA("DIAGNOSIS"))
  1. ;
  1. N CODE,CODEIEN,CODESYS,EVENTDT,FMT,ICDDATA,SERVCAT,TEMP
  1. S TEMP=^AUPNVSIT(PXAVISIT,0)
  1. S SERVCAT=$P(TEMP,U,7)
  1. ;For historical encounters use the Date the Visit was created.
  1. S EVENTDT=$S(SERVCAT="E":$P(TEMP,U,2),$G(PXAA("EVENT D/T"))'="":PXAA("EVENT D/T"),1:$P(TEMP,U,1))
  1. S FMT=$S(PXAA("DIAGNOSIS")?1.N:"I",1:"E")
  1. I FMT="E" S CODE=PXAA("DIAGNOSIS"),CODEIEN=$P($$CODEN^ICDEX(CODE,80),"~",1)
  1. I FMT="I" S CODEIEN=PXAA("DIAGNOSIS"),CODE=$$CODEC^ICDEX(80,CODEIEN)
  1. I CODEIEN'>0 D Q
  1. . S PXAERR(9)="DIAGNOSIS"
  1. . S PXAERR(11)=PXAA("DIAGNOSIS")
  1. . S PXAERR(12)=PXAERR(11)_" is not a valid code or pointer."
  1. . D ERRSET
  1. ;
  1. ;If a code was passed store the pointer.
  1. I FMT="E" S PXAA("DIAGNOSIS")=CODEIEN
  1. ;
  1. ;If this is a deletion no further validation is required.
  1. I $G(PXAA("DELETE"))=1 Q
  1. ;
  1. ;Make sure the code is active.
  1. S CODESYS=$$CSI^ICDEX(80,CODEIEN)
  1. I '$$ISCACT^PXLEX(CODESYS,CODE,EVENTDT) D
  1. . S PXAERR(9)="DIAGNOSIS"
  1. . S PXAERR(11)=PXAA("DIAGNOSIS")
  1. . S PXAERR(12)=PXAERR(11)_" is not an active ICD code."
  1. . D ERRSET
  1. ;
  1. ;If Primary is input validate it.
  1. ;* N PRIM
  1. ;* S PRIM=$G(PXAA("PRIMARY"))
  1. ;* S PXAA("PRIMARY")=$S(PRIM=1:"P",PRIM=0:"S",1:PRIM)
  1. ;* I $G(PXAA("PRIMARY"))'="",'$$SET^PXAIVAL(9000010.07,"PRIMARY",.12,PXAA("PRIMARY"),.PXAERR) D Q
  1. ;* . S PXAERR(9)="PRIMARY"
  1. ;* . S PXAERR(11)=PXAA("PRIMARY")
  1. ;* . D ERRSET
  1. ;
  1. ;If ORD/RES is input validate it.
  1. ;* I $G(PXAA("ORD/RES"))'="",'$$SET^PXAIVAL(9000010.07,"ORD/RES",.17,PXAA("ORD/RES"),.PXAERR) D Q
  1. ;* . S PXAERR(9)="ORD/RES"
  1. ;* . S PXAERR(11)=PXAA("ORD/RES")
  1. ;* . D ERRSET
  1. ;
  1. ;If Lexicon Term is input validate it.
  1. ;* I $G(PXAA("LEXICON TERM"))'="",'$D(^LEX(757.01,PXAA("LEXICON TERM"),0)) D Q
  1. ;* . S PXAERR(9)="LEXICON TERM"
  1. ;* . S PXAERR(11)=PXAA("LEXICON TERM")
  1. ;* . S PXAERR(12)=PXAA("LEXICON TERM")_" is not a valid point to the Clinical Expression file #757.01."
  1. ;* . D ERRSET
  1. ;
  1. ;If Narrative is input validate it.
  1. ;* I $G(PXAA("NARRATIVE"))'="",'$$TEXT^PXAIVAL("PROVIDER NARRATIVE",PXAA("NARRATIVE"),2,245,.PXAERR) D Q
  1. ;* . D ERRSET
  1. ;*Control characters are not allowed.
  1. ;*I '$$VPNARR^PXPNARR(PXAA("NARRATIVE")) D Q
  1. ;*. S PXAERR(9)="PROVIDER NARRATIVE"
  1. ;*. S PXAERR(11)=PXAA("NARRATIVE")
  1. ;*. S PXAERR(12)="Control characters are not allowed."
  1. ;*. D ERRSET
  1. ;
  1. ;Provider Narrative is required so if it is not input create one from
  1. ;the code description.
  1. I $G(PXAA("NARRATIVE"))="" S PXAA("NARRATIVE")=$$DXNARR^PXUTL1(CODEIEN,EVENTDT)
  1. ;
  1. ;If Provider Narrative Category is input validate it.
  1. ;* I $G(PXAA("CATEGORY"))'="",'$$TEXT^PXAIVAL("PROVIDER NARRATIVE CATEGORY",PXAA("CATEGORY"),2,245,.PXAERR) D Q
  1. ;* . D ERRSET
  1. ;*Control characters are not allowed.
  1. ;*I '$$VPNARR^PXPNARR(PXAA("PROVIDER NARRATIVE CATEGORY")) D Q
  1. ;*. S PXAERR(9)="PROVIDER NARRATIVE CATEGORY"
  1. ;*. S PXAERR(11)=PXAA("CATEGORY")
  1. ;*. S PXAERR(12)="Control characters are not allowed."
  1. ;*. D ERRSET
  1. ;
  1. ;If an Ordering Provider is passed verify it is valid.
  1. ;* I $G(PXAA("ORD PROVIDER"))'="",'$$PRV^PXAIVAL(PXAA("ORD PROVIDER"),"ORD",.PXAA,.PXAERR,PXAVISIT) D Q
  1. ;* . D ERRSET
  1. ;
  1. ;If an Encounter Provider is passed verify it is valid.
  1. ;* I $G(PXAA("ENC PROVIDER"))'="",'$$PRV^PXAIVAL(PXAA("ENC PROVIDER"),"ENC",.PXAA,.PXAERR,PXAVISIT) D Q
  1. ;* . D ERRSET
  1. ;
  1. ;If Event D/T is input verify it is a valid FileMan date and not in
  1. ;the future.
  1. ;* I $G(PXAA("EVENT D/T"))'="",'$$EVENTDT^PXAIVAL(PXAA("EVENT D/T"),"T",.PXAERR) D Q
  1. ;* . D ERRSET
  1. ;
  1. ;If a Comment is input verify it.
  1. ;* I $G(PXAA("COMMENT"))'="",'$$TEXT^PXAIVAL("COMMENT",PXAA("COMMENT"),1,245,.PXAERR) D Q
  1. ;* . D ERRSET
  1. ;
  1. ;If PKG is input verify it.
  1. ;* I $G(PXAA("PKG"))'="" D
  1. ;* . N PKG
  1. ;* . S PKG=$$VPKG^PXAIVAL(PXAA("PKG"),.PXAERR)
  1. ;* . I PKG=0 S PXAERR(9)="PKG" D ERRSET Q
  1. ;* . S PXAA("PKG")=PKG
  1. ;* I $G(STOP)=1 Q
  1. ;
  1. ;If SOURCE is input verify it.
  1. ;* I $G(PXAA("SOURCE"))'="" D
  1. ;* . N SRC
  1. ;* . S SRC=$$VSOURCE^PXAIVAL(PXAA("SOURCE"),.PXAERR)
  1. ;* . I SRC=0 S PXAERR(9)="SOURCE" D ERRSET Q
  1. ;* . S PXAA("SOURCE")=SRC
  1. ;* I $G(STOP)=1 Q
  1. ;
  1. ;If PL IEN is input validate it.
  1. ;* I $G(PXAA("PL IEN"))'="",'$D(^AUPNPROB(PXAA("PL IEN"),0)) D Q
  1. ;* . S PXAERR(9)="PL IEN"
  1. ;* . S PXAERR(11)=PXAA("PL IEN")
  1. ;* . S PXAERR(12)=PXAA("PL IEN")_" is not a valid point to the Problem file #9000011."
  1. ;* . D ERRSET
  1. ;
  1. ;There is nothing to verify for PL ADD.
  1. ;
  1. ;If PL ACTIVE is input validate it.
  1. ;* I $G(PXAA("PL ACTIVE"))'="",PXAA("PL ACTIVE")'="A",PXAA("PL ACTIVE")'="I" D Q
  1. ;* . S PXAERR(9)="PL ACTIVE"
  1. ;* . S PXAERR(11)=PXAA("PL ACTIVE")
  1. ;* . S PXAERR(12)=PXAA("PL ACTIVE")_" is not a valid value for PL ACTIVE, A or I are allowed."
  1. ;* . D ERRSET
  1. ;
  1. ;If PL Onset Date is input verify it.
  1. ;* I $G(PXAA("PL ONSET DATE"))'="",'$$DATETIME^PXAIVAL("PL ONSET DATE",PXAA("PL ONSET DATE"),"",.PXAERR) D Q
  1. ;* . S PXAERR(9)="PL ONSET DATE"
  1. ;* . S PXAERR(11)=PXAA("PL ONSET DATE")
  1. ;* . D ERRSET
  1. ;
  1. ;If PL Resolved Date is input verify it.
  1. ;* I $G(PXAA("PL RESOLVED DATE"))'="",'$$DATETIME^PXAIVAL("PL RESOLVED DATE",PXAA("PL RESOLVED DATE"),"",.PXAERR) D Q
  1. ;* . S PXAERR(9)="PL RESOLVED DATE"
  1. ;* . S PXAERR(11)=PXAA("PL RESOLVED DATE")
  1. ;* . D ERRSET
  1. ;
  1. ;If PL SC is input verify it.
  1. ;* I $G(PXAA("PL SC"))'="",'$$SET^PXAIVAL(9000010.07,"PL SC",80001,PXAA("PL SC"),.PXAERR) D Q
  1. ;* . S PXAERR(9)="PL SC"
  1. ;* . S PXAERR(11)=PXAA("PL SC")
  1. ;* . D ERRSET
  1. ;
  1. ;If PL AO is input verify it.
  1. ;* I $G(PXAA("PL AO"))'="",'$$SET^PXAIVAL(9000010.07,"PL AO",80002,PXAA("PL AO"),.PXAERR) D Q
  1. ;* . S PXAERR(9)="PL AO"
  1. ;* . S PXAERR(11)=PXAA("PL AO")
  1. ;* . D ERRSET
  1. ;
  1. ;If PL IR is input verify it.
  1. ;* I $G(PXAA("PL IR"))'="",'$$SET^PXAIVAL(9000010.07,"PL IR",80003,PXAA("PL IR"),.PXAERR) D Q
  1. ;* . S PXAERR(9)="PL IR"
  1. ;* . S PXAERR(11)=PXAA("PL IR")
  1. ;* . D ERRSET
  1. ;
  1. ;If PL EC is input verify it.
  1. ;* I $G(PXAA("PL EC"))'="",'$$SET^PXAIVAL(9000010.07,"PL EC",80004,PXAA("PL EC"),.PXAERR) D Q
  1. ;* . S PXAERR(9)="PL EC"
  1. ;* . S PXAERR(11)=PXAA("PL EC")
  1. ;* . D ERRSET
  1. ;
  1. ;If PL MST is input verify it.
  1. ;* I $G(PXAA("PL MST"))'="",'$$SET^PXAIVAL(9000010.07,"PL MST",80005,PXAA("PL MST"),.PXAERR) D Q
  1. ;* . S PXAERR(9)="PL MST"
  1. ;* . S PXAERR(11)=PXAA("PL MST")
  1. ;* . D ERRSET
  1. ;
  1. ;If PL HNC is input verify it.
  1. ;* I $G(PXAA("PL HNC"))'="",'$$SET^PXAIVAL(9000010.07,"PL HNC",80006,PXAA("PL HNC"),.PXAERR) D Q
  1. ;* . S PXAERR(9)="PL HNC"
  1. ;* . S PXAERR(11)=PXAA("PL HNC")
  1. ;* . D ERRSET
  1. ;
  1. ;If PL CV is input verify it.
  1. ;* I $G(PXAA("PL CV"))'="",'$$SET^PXAIVAL(9000010.07,"PL CV",80007,PXAA("PL CV"),.PXAERR) D Q
  1. ;* . S PXAERR(9)="PL CV"
  1. ;* . S PXAERR(11)=PXAA("PL CV")
  1. ;* . D ERRSET
  1. ;
  1. ;If PL SHAD is input verify it.
  1. ;* I $G(PXAA("PL SHAD"))'="",'$$SET^PXAIVAL(9000010.07,"PL SHAD",80008,PXAA("PL SHAD"),.PXAERR) D Q
  1. ;* . S PXAERR(9)="PL SHAD"
  1. ;* . S PXAERR(11)=PXAA("PL SHAD")
  1. ;* . D ERRSET
  1. Q
  1. ;
  1. VAL04 ;Setup error array for missing or invalid Provider Narrative.
  1. S PXAERR(9)="PROVIDER NARRATIVE"
  1. S PXAERR(11)=$G(PXAA("NARRATIVE"))
  1. S PXAERR(12)="We are unable to retrieve a provider narrative from the PROVIDER NARRATIVE file #9999999.27"
  1. D ERRSET
  1. Q
  1. ;
  1. VAL802 ;Setup error array for missing or invalid Provider Narrative Category.
  1. ;Provider Narrative Category is not required, so make this a warning.
  1. S PXAERR(9)="PROVIDER NARRATIVE CATEGORY"
  1. S PXAERR(11)=$G(PXAA("CATEGORY"))
  1. S PXAERR(12)="We are unable to retrieve a provider narrative category from the PROVIDER NARRATIVE file #9999999.27"
  1. S PXADI("DIALOG")=8390001.002
  1. S PXAERR(7)="DX/PL"
  1. S PXAERRW("POV")=1
  1. Q
  1. ;