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

BJPN20PS.m

Go to the documentation of this file.
  1. BJPN20PS ;GDIT/HS/BEE-Prenatal Care Module 2.0 Post Install ; 08 May 2012 12:00 PM
  1. ;;2.0;PRENATAL CARE MODULE;;Feb 24, 2015;Build 63
  1. ;
  1. Q
  1. ;
  1. PST ;EP - Prenatal 2.0 Post Installation Code
  1. ;
  1. NEW BI,TEXT,DIK,DA
  1. ;
  1. ;If PRENATAL 1.0 was installed, perform conversion
  1. D CONV
  1. ;
  1. ;Recompile the new "E" index (by PROBLEM)
  1. I +$O(^BJPNPL(0))>0 D
  1. . W !!,"Recompiling cross references"
  1. . S DIK="^BJPNPL(" D IXALL2^DIK
  1. . S DIK="^BJPNPL(" D IXALL^DIK
  1. ;
  1. ;Recompile the new "E" index (by PROBLEM)
  1. S DIK="^BJPNPL(",DIK(1)=".1^F" D ENALL^DIK
  1. ;
  1. ; UPDATE THE VUECENTRIC REGISTERED OBJECTS FILE
  1. D REG^BJPN20RG
  1. ;
  1. XPST Q
  1. ;
  1. CONV ;Convert existing PIP/VOB entries to use new BJPN SNOMED TERMS entries
  1. ;
  1. NEW DIK
  1. ;
  1. ;Only convert if backup from pre-install is present
  1. Q:'$D(^XTMP("BJPN"))
  1. ;
  1. ;Process each panel entry
  1. K ^TMP("BJPNCVVOB",$J)
  1. S BJPNPL=0 F S BJPNPL=$O(^BJPNPL(BJPNPL)) Q:'BJPNPL D
  1. . NEW STS
  1. . S STS=$$PRC1PIP(BJPNPL)
  1. K ^TMP("BJPNCVVOB",$J)
  1. ;
  1. Q
  1. ;
  1. PRC1PIP(BJPNPL) ;EP - Process one PIP entry
  1. ;
  1. ;In a number of cases FileMan sets cannot be used as they would cause invalid audit entries
  1. ;to be generated. The audit entries get set up manually where needed
  1. ;
  1. NEW BJPNSMD,CONCID,CONSTR,DESCID,DFN,PIEN,PRBIEN,PROBLEM,STS,ICD,AUPNPROB,CPREG
  1. NEW PEDD,DEDD,ERROR,DESCSTR,IENS,DA,DIK,NEWPRB,LMB,LMD,ENB,END
  1. ;
  1. ;Check to see if the PROBLEM field is populated, if so conversion completed
  1. S PROBLEM=$$GET1^DIQ(90680.01,BJPNPL_",",".1","I") I PROBLEM]"" S STS="2^PIP entry already converted" Q STS
  1. ;
  1. ;Skip deleted problem entries
  1. I $$GET1^DIQ(90680.01,BJPNPL_",","2.02","I")]"" S STS="0^PIP Problem has been deleted" Q STS
  1. ;
  1. ;Get the SNOMED 90620.02 file pointer
  1. S BJPNSMD=$$GET1^DIQ(90680.01,BJPNPL_",",".03","I") I BJPNSMD="" S STS="0^Invalid SNOMED pointer" Q STS
  1. ;
  1. ;Get the Concept ID - Quit if invalid
  1. W !,"Processing Prenatal PIP entry: ",BJPNPL
  1. S CONCID=$$GET1^DIQ(90680.02,BJPNSMD_",",".07","I") I CONCID="" S STS="0^Missing Concept ID" Q STS
  1. S CONSTR=$$CONC^BSTSAPI(CONCID_"^^^1") I $P(CONSTR,U,2)="" S STS="0^DTS could not find Concept ID" Q STS
  1. ;
  1. ;Get the description ID - If invalid, use preferred term
  1. S DESCID=$$GET1^DIQ(90680.02,BJPNSMD_",",".03","I")
  1. S:DESCID="" DESCID=$P(CONSTR,U,3) I DESCID="" S STS="0^Could not locate Description ID" Q STS
  1. S DESCSTR=$$DESC^BSTSAPI(DESCID_"^^1") I $P(DESCSTR,U)="" S STS="0^DTS could not find Description ID" Q STS
  1. ;
  1. ;Valid Concept ID and Description Id found - ok to continue
  1. ;
  1. ;Get the patient DFN
  1. S DFN=$$GET1^DIQ(90680.01,BJPNPL_",",".02","I") I DFN="" S STS="0^Missing DFN in ^BJPNPL" Q STS
  1. ;
  1. ;Check to see if we have a problem on the IPL already
  1. S (PRBIEN,PIEN,NEWPRB)="" F S PIEN=$O(^AUPNPROB("APCT",DFN,CONCID,PIEN)) Q:'PIEN D I PRBIEN]"" Q
  1. . NEW DELPRB
  1. . S DELPRB=$$GET1^DIQ(9000011,PIEN_",",2.02,"I") I DELPRB]"" Q ;Skip deletes
  1. . S PRBIEN=PIEN ;Found a match
  1. ;
  1. ;Get the ICD code
  1. S DA=1,DA(1)=BJPNSMD S IENS=$$IENS^DILF(.DA)
  1. S ICD=$$GET1^DIQ(90680.21,IENS,".01","I")
  1. ;
  1. I ICD="" D I ICD="" S STS="0^Missing ICD Code" Q STS
  1. . NEW X,DIC,X,Y
  1. . S X=".9999" I $$VERSION^XPDUTL("AICD")>3.51,$T(IMP^ICDEXA)]"",$$IMP^ICDEXA(30)>DT S X="ZZZ.999"
  1. . S DIC="^ICD9(",DIC(0)="XMO" D ^DIC I +Y<0 S ICD="" Q
  1. . S ICD=+Y
  1. ;
  1. ;If new problem, create new entry, quit if one wasn't created
  1. I PRBIEN="" D Q:'+STS
  1. . S NEWPRB=1 ;Record that this is a new problem being added
  1. . NEW RET,VIEN,FRSTIEN,LIST,NARR,LOC,PRBCNT,Y,PIP,DA,DIK
  1. . ;
  1. . S STS=0
  1. . ;
  1. . ;Get the visit IEN that the problem was added
  1. . S FRSTIEN=$O(^AUPNVOB("B",BJPNPL,""))
  1. . S VIEN=$$GET1^DIQ(9000010.43,FRSTIEN_",",".03","I") I VIEN="" S STS="0^No visit found" Q
  1. . ;
  1. . ;Get the provider text - now provider text | descriptive SNOMED CT
  1. . S NARR=$$GET1^DIQ(90680.01,BJPNPL_",",".05","E")
  1. . ;
  1. . ;Get the location
  1. . S LOC=$$GET1^DIQ(9000010,VIEN_",",".06","I")
  1. . ;
  1. . ;Get the next problem #
  1. . D NEXTID^BGOPROB(.RET,DFN)
  1. . S PRBCNT=+$P(RET,"-",2)
  1. . ;
  1. . ; DFN = Patient IEN
  1. . ; PRIEN = IEN of problem, null if new
  1. . ; VIEN = Needed if asthma DX
  1. . ; List(n)
  1. . ; "P"[1] ^ SNOMED CT [2] ^ Descriptive CT [3] ^ Provider text [4] ^ Mapped ICD [5]
  1. . ; ^ Location [6] ^ Date of Onset [7] ^ Status [8] ^ Class [9] ^Problem # [10] ^ Priority [11] ^ INP DX [12]
  1. . ; "A"[1] ^ Classification [2] ^ Control [3] ^ V asthma IEN [4]
  1. . ; "Q"[1] ^ TYPE [2] ^ Qualifier IEN [3] ^ Qual SNOMED [4] ^ By [5] ^ When [6] ^ Delete [7]
  1. . ;SET(RET,DFN,PRIEN,VIEN,ARRAY) ;EP
  1. . S LIST(0)="P"_U_CONCID_U_DESCID_U_NARR_U_ICD_U_LOC_U_U_"Episodic"_U_U_PRBCNT_U_"0"
  1. . ;
  1. . ;Turn off auditing
  1. . NEW AFLD,AI,RES F AI=.01,.03,.05,.12,80001,80002,"1401,.01","1501,.01" S RES=$$OFF^BJPN20AU(9000011,AI) S:RES]"" AFLD(AI)=RES
  1. . ;
  1. . ;Log the problem
  1. . D SET^BGOPROB(.RET,DFN,"",VIEN,.LIST)
  1. . ;
  1. . ;Perform BUSA audit
  1. . D LOG^BJPNUTIL("P","A","BJPN20PS","Added problem to IPL/PIP",DFN)
  1. . ;
  1. . ;Turn auditing back on
  1. . S AI="" F S AI=$O(AFLD(AI)) Q:AI="" D ON^BJPN20AU(9000011,AI,AFLD(AI))
  1. . K AFLD,AI,RES
  1. . ;
  1. . I '+RET S STS="0^Could not create new problem entry" Q
  1. . S PRBIEN=+RET
  1. . ;
  1. . ;Return success
  1. . S STS=1
  1. ;
  1. ;If Problem IEN present, update PIP file
  1. I PRBIEN]"" S $P(^BJPNPL(BJPNPL,0),U,10)=PRBIEN
  1. ;
  1. ;Determine whether to check the PIP box in the problem file
  1. S CPREG=$$GET1^DIQ(9000017,DFN_",",1101,"I") ;Currently pregnant
  1. S DEDD=$$GET1^DIQ(9000017,DFN_",",1311,"I") ;Definitive EDD
  1. S PEDD=$$DEDD^BJPNPDET(DFN) ;Definitive EDD - PIP
  1. ;
  1. ;If we have currently pregnant and definitive EDD, mark PIP
  1. S PIP="" I CPREG="Y",DEDD]"" S PIP=1
  1. ;
  1. ;Not pregnant, but PIP EDD is still defined - meaning PIP has not been closed
  1. I CPREG'="Y",PEDD]"" S PIP=1
  1. ;
  1. ;PIP entry is inactive - never mark PIP
  1. I $$GET1^DIQ(90680.01,BJPNPL_",",".08","I")'="A" S PIP=""
  1. ;
  1. ;File the entry
  1. S $P(^AUPNPROB(PRBIEN,0),U,19)=PIP
  1. ;
  1. ;If existing problem retrieve modified/entered info
  1. I 'NEWPRB D
  1. . S LMB=$$GET1^DIQ(9000011,PRBIEN,".14","I")
  1. . S LMD=$$GET1^DIQ(9000011,PRBIEN,".03","I")
  1. . S END=$$GET1^DIQ(9000011,PRBIEN,".08","I")
  1. . S ENB=$$GET1^DIQ(9000011,PRBIEN,"1.03","I")
  1. ;
  1. ;If existing problem, back up current POVs)
  1. I 'NEWPRB D
  1. . NEW TYPE,VSIEN
  1. . F TYPE=14,15 S VSIEN="" F S VSIEN=$O(^AUPNPROB(PRBIEN,TYPE,"B",VSIEN)) Q:VSIEN="" S ^TMP("BJPNCVVOB",$J,PRBIEN,TYPE,VSIEN)=""
  1. ;
  1. ;Copy Care Plan Notes to Visit Instructions, POV info, auditing
  1. D VOB^BJPN20P1(BJPNPL,PRBIEN,NEWPRB)
  1. ;
  1. ;Turn off auditing
  1. NEW AFLD,AI,RES F AI=.01,.03,.05,.12,80001,80002,"1401,.01","1501,.01" S RES=$$OFF^BJPN20AU(9000011,AI) S:RES]"" AFLD(AI)=RES
  1. ;
  1. ;Get the current problem ICD - we may need to change it to the one passed in
  1. NEW CICD
  1. S CICD=$$GET1^DIQ(9000011,PRBIEN_",",.01,"I")
  1. I CICD'=ICD,ICD]"" D
  1. . NEW AUPN,ERROR
  1. . S AUPN(9000011,PRBIEN_",",".01")=ICD
  1. . D FILE^DIE("","AUPN","ERROR")
  1. K CICD
  1. ;
  1. ;Now re-index again
  1. S DA=PRBIEN,DIK="^AUPNPROB(" D IX^DIK
  1. ;
  1. ;Determine which enter/last modified information to use
  1. I 'NEWPRB D
  1. . NEW CLMD,CEND,AUPN,ERROR
  1. . ;
  1. . ;Use latest last modified information
  1. . S CLMD=$$GET1^DIQ(9000011,PRBIEN,".03","I")
  1. . I CLMD]"",CLMD<$G(LMD) D
  1. .. S AUPN(9000011,PRBIEN_",",".03")=LMD
  1. .. S AUPN(9000011,PRBIEN_",",".14")=$G(LMB)
  1. .;
  1. .;Use earliest entered by information
  1. . S CEND=$$GET1^DIQ(9000011,PRBIEN,".08","I")
  1. . I $G(END)]"",END<CEND D
  1. .. S AUPN(9000011,PRBIEN_",",".08")=END
  1. .. S AUPN(9000011,PRBIEN_",","1.03")=$G(ENB)
  1. . ;
  1. . ;File any changes
  1. . I $D(AUPN) D FILE^DIE("","AUPN","ERROR")
  1. ;
  1. ;Turn auditing back on
  1. S AI="" F S AI=$O(AFLD(AI)) Q:AI="" D ON^BJPN20AU(9000011,AI,AFLD(AI))
  1. K AFLD,AI,RES
  1. ;
  1. Q 1