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

BQIPTFHS.m

Go to the documentation of this file.
BQIPTFHS ;APTIV/HC/ALA-Patient Family History ; 02 Jan 2008  12:27 PM
 ;;2.4;ICARE MANAGEMENT SYSTEM;;Apr 01, 2015;Build 41
 ;
 Q
 ;
HIS(DATA,DFN) ; EP -- BQI PATIENT FAMILY HISTORY
 ;
 ;Description - all the family history that a patient has
 ;
 ;Input
 ;  DFN - Patient internal entry number
 ;
 NEW UID,II,IEN,DIAG,NARR,RELAT,AGE,STAT,DTMNT,PROV,RELN,RELT,STC,STT,PRVR,PRVN,NIEN
 NEW ARRAY,CIEN,RIEN,AGC,FHXDTLM,RORD,ORD,FHXRLTN,RELD,RELNM
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQIPTFHS",UID))
 K @DATA
 ;
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIPTFHS D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 S @DATA@(II)="I00010FHXIEN^I00010FHXRIEN^T00060FHXRLTN^T00060FHXRLDS^T00060FHXDXN^T00080DXNARR^T00020FHXAGE^T00020FHXSTAT^D00030FHXDTNT^T00100APCDTNQ"_$C(30)
 I $$VERSION^XPDUTL("BJPC")<2.0 D
 . S IEN="",RIEN=""
 . F  S IEN=$O(^AUPNFH("AC",DFN,IEN)) Q:IEN=""  D
 .. S DIEN=$$GET1^DIQ(9000014,IEN_",",.01,"I") I DIEN="" Q
 .. S DTMNT=$$GET1^DIQ(9000014,IEN_",",.03,"I")
 .. I $$VERSION^XPDUTL("BCSV") S DIAG=$$ICD9^BQIUL3(DIEN,DTMNT,2)_"-"_$$ICD9^BQIUL3(DIEN,DTMNT,4) ; csv
 .. I '$$VERSION^XPDUTL("BCSV") S DIAG=$$GET1^DIQ(80,DIEN_",",.01,"E")_"-"_$$GET1^DIQ(80,DIEN_",",3,"E")
 .. S DIAG=DIEN_$C(28)_DIAG
 .. ;S DIAG=$$GET1^DIQ(9000014,IEN_",",.01,"E") I DIAG="" Q
 .. S NARR=$$GET1^DIQ(9000014,IEN_",",.04,"E")
 .. S NIEN=$$GET1^DIQ(9000014,IEN_",",.04,"I")
 .. I $$PATCH^XPDUTL("BJPC*2.0*10") S NARR=$$PNPROB^AUPNVUTL(NIEN)
 .. S RELN=$$GET1^DIQ(9000014,IEN_",",.07,"I")
 .. S RELT=$$GET1^DIQ(9000014,IEN_",",.07,"E")
 .. S RELNM=RELT S:RELNM="" RELNM="~"
 .. S RELAT="" I RELN'="" S RELAT=RELN_$C(28)_RELT
 .. S AGE=$$GET1^DIQ(9000014,IEN_",",.05,"E")
 .. S STC=$$GET1^DIQ(9000014,IEN_",",.06,"I")
 .. S STT=$$GET1^DIQ(9000014,IEN_",",.06,"E")
 .. S STAT="" I STC'="" S STAT=STC_$C(28)_STT
 .. S ARRAY(RELNM,IEN)=IEN_U_U_RELAT_U_U_DIAG_U_NARR_U_AGE_U_STAT_U_$$FMTE^BQIUL1(DTMNT)_U_NIEN_$C(28)_NARR_$C(30)
 . S RELNM=""
 . F  S RELNM=$O(ARRAY(RELNM)) Q:RELNM=""  D
 .. S IEN=""
 .. F  S IEN=$O(ARRAY(RELNM,IEN)) Q:IEN=""  S II=II+1,@DATA@(II)=ARRAY(RELNM,IEN)
 ;
 I $$VERSION^XPDUTL("BJPC")>1.0 D
 . NEW FAM,FREL
 . S CIEN=""
 . F  S CIEN=$O(^AUPNFH("AC",DFN,CIEN)) Q:CIEN=""  D
 .. S DTMNT=$$GET1^DIQ(9000014,CIEN_",",.12,"I")
 .. S DIEN=$$GET1^DIQ(9000014,CIEN_",",.01,"I") I DIEN="" Q
 .. I $$VERSION^XPDUTL("BCSV") S DIAG=$$ICD9^BQIUL3(DIEN,DTMNT,2)_"-"_$$ICD9^BQIUL3(DIEN,DTMNT,4) ; csv
 .. I '$$VERSION^XPDUTL("BCSV") S DIAG=$$GET1^DIQ(80,DIEN_",",.01,"E")_"-"_$$GET1^DIQ(80,DIEN_",",3,"E")
 .. S DIAG=DIEN_$C(28)_DIAG
 .. S NARR=$$GET1^DIQ(9000014,CIEN_",",.04,"E")
 .. S NIEN=$$GET1^DIQ(9000014,CIEN_",",.04,"I")
 .. S AGC=$$GET1^DIQ(9000014,CIEN_",",.11,"I")
 .. S AGE="" I AGC'="" S AGE=AGC_$C(28)_$$GET1^DIQ(9000014,CIEN_",",.11,"E")
 .. S RIEN=$$GET1^DIQ(9000014,CIEN_",",.09,"I")
 .. I RIEN'="" S FAM(RIEN)=""
 .. D GFAM
 .. S ARRAY(RORD,RELNM,CIEN)=CIEN_U_RIEN_U_RELAT_U_RELD_U_DIAG_U_NARR_U_AGE_U_STAT_U_$$FMTE^BQIUL1(FHXDTLM)_U_NIEN_$C(28)_NARR_$C(30)
 . ;
 . S CIEN=""
 . F  S CIEN=$O(^AUPNFHR("AA",DFN,CIEN)) Q:'CIEN  S RIEN="" D
 .. F  S RIEN=$O(^AUPNFHR("AA",DFN,CIEN,RIEN)) Q:RIEN=""  D
 ... I $D(FAM(RIEN)) Q
 ... ; For family without diagnoses search FAMILY HISTORY FAMILY MEMBERS file
 ... D GFAM
 ... S ARRAY(RORD,RELNM,"R"_RIEN)=U_RIEN_U_RELAT_U_RELD_U_U_U_U_STAT_U_$$FMTE^BQIUL1(FHXDTLM)_U_$C(30)
 . ;
 . S ORD=""
 . F  S ORD=$O(ARRAY(ORD)) Q:ORD=""  D
 .. S RELNM=""
 .. F  S RELNM=$O(ARRAY(ORD,RELNM)) Q:RELNM=""  D
 ... S IEN=""
 ... F  S IEN=$O(ARRAY(ORD,RELNM,IEN)) Q:IEN=""  S II=II+1,@DATA@(II)=ARRAY(ORD,RELNM,IEN)
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
ERR ;
 D ^%ZTER
 NEW Y,ERRDTM
 S Y=$$NOW^XLFDT() X ^DD("DD") S ERRDTM=Y
 S BMXSEC="Recording that an error occurred at "_ERRDTM
 I $D(II),$D(DATA) S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
UPD(DATA,DFN,FHXIEN,FHXDXN,PARMS) ;EP - BQI UPDATE FAMILY HISTORY
 ;Input
 ;  DFN    - Patient internal entry number
 ;  FHXIEN - Family History IEN if null create a new one
 ;  if the FHXIEN is null then FHXDXN (the diagnosis) must be defined 
 ;  PARMS  - Data values
 ;
 NEW UID,II,VFIEN,FILE,LIST,BN,BQ,PDATA,NAME,VALUE,PFIEN,PTYP,CHIEN,FIELD
 NEW BQIDATA,ERROR,RESULT
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQIPTFHU",UID))
 K @DATA
 ;
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIPTFHS D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 S @DATA@(II)="I00010RESULT^T001024ERROR"_$C(30)
 ;
 S FHXIEN=$G(FHXIEN,""),FHXDXN=$G(FHXDXN,"")
 I FHXIEN=""&(FHXDXN="") S BMXSEC="RPC Call Failed: Needs diagnosis" Q
 ;
 ;if deleting a family history record
 I FHXDXN="@" D DEL G DONE
 ;
 S VFIEN=$O(^BQI(90506.3,"B","Family History",""))
 I VFIEN="" S BMXSEC="RPC Call Failed: Family History Definition does not exist." Q
 S FILE=$P(^BQI(90506.3,VFIEN,0),U,2)
 ;
 S PARMS=$G(PARMS,"")
 I PARMS="" D
 . S LIST="",BN=""
 . F  S BN=$O(PARMS(BN)) Q:BN=""  S LIST=LIST_PARMS(BN)
 . K PARMS
 . S PARMS=LIST
 . K LIST
 ;
 I FHXIEN="" D NREC
 ;
 F BQ=1:1:$L(PARMS,$C(28)) D  Q:$G(BMXSEC)'=""
 . S PDATA=$P(PARMS,$C(28),BQ) Q:PDATA=""
 . S NAME=$P(PDATA,"=",1),VALUE=$P(PDATA,"=",2,99) I VALUE="" Q
 . S PFIEN=$O(^BQI(90506.3,VFIEN,10,"AC",NAME,""))
 . I PFIEN="" S BMXSEC=NAME_" not a valid parameter for this update" Q
 . S PTYP=$P($G(^BQI(90506.3,VFIEN,10,PFIEN,1)),U,1)
 . I PTYP="D" S VALUE=$$DATE^BQIUL1(VALUE)
 . ;I PTYP="T" S VALUE=VALUE
 . I PTYP="C" D
 .. S CHIEN=$O(^BQI(90506.3,VFIEN,10,PFIEN,5,"B",VALUE,"")) I CHIEN="" Q
 .. S VALUE=$P(^BQI(90506.3,VFIEN,10,PFIEN,5,CHIEN,0),U,2)
 . S FIELD=$P($G(^BQI(90506.3,VFIEN,10,PFIEN,3)),U,1)
 . S BQIDATA(FILE,FHXIEN_",",FIELD)=VALUE
 ;
 K ERROR
 I $D(BQIDATA)>0 D FILE^DIE("","BQIDATA","ERROR")
 S RESULT=1_U
 I $D(ERROR)>0 S RESULT=-1_U_$G(ERROR("DIERR",1,"TEXT",1))
 S II=II+1,@DATA@(II)=RESULT_$C(30)
 ;
DONE ;
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
NREC ; Create new record
 K DIC,DR,DA
 NEW DIC,X,Y
 S DIC="^AUPNFH(",DIC(0)="L",X=FHXDXN,DIC("DR")=".02////"_DFN_";.03////^S X=DT;.07////"_$G(FHXRLTN)
 K DO,DD D FILE^DICN
 S FHXIEN=+Y
 Q
 ;
DEL ; Delete a record
 NEW DIK,DA
 S RESULT=1_U
 S DIK="^AUPNFH("
 I FHXIEN'="" S DA=FHXIEN D ^DIK
 I FHXIEN="" S RESULT=-1_U_"No Family History record passed in to delete"
 S II=II+1,@DATA@(II)=RESULT_$C(30)
 Q
 ;
GFAM ; Get family history family members data
 S RELN=$$GET1^DIQ(9000014.1,RIEN_",",.01,"I")
 S RORD=$$GET1^DIQ(9999999.36,RELN_",",2103,"E") S:RORD="" RORD="~"
 S RELT=$$GET1^DIQ(9000014.1,RIEN_",",.01,"E")
 S RELNM=RELT S:RELNM="" RELNM="~"
 S RELD=$$GET1^DIQ(9000014.1,RIEN_",",.03,"E")
 S RELAT="" I RELN'="" S RELAT=RELN_$C(28)_RELT ;_" "_RELD
 S STC=$$GET1^DIQ(9000014.1,RIEN_",",.04,"I")
 S STT=$$GET1^DIQ(9000014.1,RIEN_",",.04,"E")
 S STAT="" I STC'="" S STAT=STC_$C(28)_STT
 S FHXDTLM=$$GET1^DIQ(9000014.1,RIEN_",",.09,"I")
 Q