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

APCHS85.m

Go to the documentation of this file.
APCHS85 ; IHS/CMI/LAB - PART 8 OF APCHS -- SUMMARY PRODUCTION COMPONENTS ;
 ;;2.0;IHS PCC SUITE;**2,7,10,11**;MAY 14, 2009;Build 58
 ;
 ;
REPHX ; ********** REPRODUCTIVE HISTORY * 9000017 **********
 ; <SETUP>
 Q:$P(^DPT(APCHSPAT,0),U,2)'="F"
 Q:'$D(^AUPNREP(APCHSPAT))
 S APCHSN=^AUPNREP(APCHSPAT,0)
 I $D(^DD(9000017,2101)) D NEWREP G REPHXX
 ; <DISPLAY>
 X APCHSCKP Q:$D(APCHSQIT)  X:'APCHSNPG APCHSBRK
 S X=$P(APCHSN,U,2) I X]"" W X S APCHSP=3 D DTOBT W "  "
 S X=$P(APCHSN,U,4) S:X="" X="<not recorded>" S Y=X X:+X APCHSCVD W "LMP ",Y S APCHSP=5 D DTOBT W !
 S X=$$VAL^XBDIQ1(9000017,APCHSPAT,2.01) W "LACTATION STATUS: ",X W:X]"" "  (obtained "_$$DATE^APCHSMU($P($G(^AUPNREP(APCHSPAT,2)),U,2)) W !
 ;S X=$P(APCHSN,U,6) I X]"" S Y=$P(^DD(9000017,3,0),U,3),X=$P(Y,";",X+1) S APCHSM=$P(X,":",2) X APCHSCKP G:$D(APCHSQIT) REPHXX W "CONTRACEPTION: ",APCHSM S X=$P(APCHSN,U,7) X:+X "S Y=X X APCHSCVD W "", EFFECTIVE "",Y" S APCHSP=8 D DTOBT W !
 ;S X=$P(APCHSN,U,9) I X]"" X APCHSCKP G:$D(APCHSQIT) REPHXX D EDC
 D LATER
REPHXX K APCHSN,APCHSM,APCHSN11
 Q
 ;
NEWREP ;new reproductive factors dd
 S APCHSN11=$G(^AUPNREP(APCHSPAT,0))
 X APCHSCKP Q:$D(APCHSQIT)  X:'APCHSNPG APCHSBRK
 S X=$$RHX^AUPNREP(APCHSPAT) I X]"" W !,"Reproductive History: ",!?2,$P(X,";",1,4),";",!?3,$P(X,";",5,7),!?3,";",$P(X,";",8,99),! ;S APCHSP=30 D DTOBT11
 X APCHSCKP Q:$D(APCHSQIT)  ;X:'APCHSNPG APCHSBRK
 S X=$P(APCHSN,U,4) I X]"" W "LMP: " S Y=X X APCHSCVD W Y S APCHSP=5 D DTOBT W !
 S X=$$VAL^XBDIQ1(9000017,APCHSPAT,2.01) W "LACTATION STATUS: ",X W:X]"" "  (obtained "_$$DATE^APCHSMU($P($G(^AUPNREP(APCHSPAT,2)),U,2)),")" W !
 ;S X=$P(APCHSN,U,6) I X]"" S Y=$P(^DD(9000017,3,0),U,3),X=$P(Y,";",X+1) S APCHSM=$P(X,":",2) X APCHSCKP G:$D(APCHSQIT) REPHXX W "CONTRACEPTION: ",APCHSM S X=$P(APCHSN,U,7) X:+X "S Y=X X APCHSCVD W "", EFFECTIVE "",Y" S APCHSP=8 D DTOBT W !
 D LATER
 Q:$D(APCHSQIT)
 D EDC
 Q
 ;
LATER ;
 ;TABLE ALL CONTRACEPTIVE HX BY DATE BEGUN, IF NO DATE BEGUN PUT AT TOP
 ;IF NOTHING IN 21 MULTIPLE THEN DISPLAY SINGLE VALUED FIELDSD
 I '$O(^AUPNREP(APCHSPAT,2101,0)) D SINGLE Q
 NEW APCHCM,APCHX,APCHC,APCHDB,APCHM
 S APCHX=0 F  S APCHX=$O(^AUPNREP(APCHSPAT,2101,APCHX)) Q:APCHX'=+APCHX  D
 .Q:$P($G(^AUPNREP(APCHSPAT,2101,APCHX,1)),U,1)]""  ;DELETED
 .S APCHC=$P(^AUPNREP(APCHSPAT,2101,APCHX,0),U,1)
 .Q:'APCHC
 .S APCHDB=$P(^AUPNREP(APCHSPAT,2101,APCHX,0),U,2)
 .S APCHDE=$P(^AUPNREP(APCHSPAT,2101,APCHX,0),U,3)
 .Q:APCHDE]""  ;don't display history
 .S APCHDB=+APCHDB
 .S APCHCM((9999999-APCHDB),APCHX)=$$VAL^XBDIQ1(99999.11,APCHC,.01)_U_APCHDE_U_APCHDB
 .Q
 X APCHSCKP Q:$D(APCHSQIT)  ;X:'APCHSNPG APCHSBRK
 W !,"CURRENT CONTRACEPTION METHODS",!?3,"Contraceptive Method",?37,"Date Started",!  ;,?50,"Date Ended"
 S APCHDB="" F  S APCHDB=$O(APCHCM(APCHDB)) Q:APCHDB=""!($D(APCHSQIT))  D
 .S APCHX=0 F  S APCHX=$O(APCHCM(APCHDB,APCHX)) Q:APCHX'=+APCHX!($D(APCHSQIT))  D
 ..X APCHSCKP Q:$D(APCHSQIT)
 ..W ?5,$P(APCHCM(APCHDB,APCHX),U,1)
 ..S Y=$P(APCHCM(APCHDB,APCHX),U,3) I Y X APCHSCVD W ?37,Y
 ..;S Y=$P(APCHCM(APCHDB,APCHX),U,2) I Y]"" X APCHSCVD W ?50,Y
 ..S Y=$P(^AUPNREP(APCHSPAT,2101,APCHX,0),U,4) W:Y]"" ?55,"(obtained "_$$DATE^APCHSMU(Y)_")" W !
 ..;W !
 ..I $P(^AUPNREP(APCHSPAT,2101,APCHX,0),U,6)]"" W ?10,$P(^AUPNREP(APCHSPAT,2101,APCHX,0),U,6),!
 ..I $P(^AUPNREP(APCHSPAT,2101,APCHX,0),U,5)]"" W ?5,"Reason Discontinued: "_$P(^AUPNREP(APCHSPAT,2101,APCHX,0),U,5),!
 Q
SINGLE ;
 S X=$P(APCHSN,U,6) I X]"" S Y=$P(^DD(9000017,3,0),U,3),X=$P(Y,";",X+1) S APCHSM=$P(X,":",2) X APCHSCKP G:$D(APCHSQIT) REPHXX W "CONTRACEPTION: ",APCHSM S X=$P(APCHSN,U,7) X:+X "S Y=X X APCHSCVD W "", EFFECTIVE "",Y" S APCHSP=8 D DTOBT W !
 Q
DTOBT11 S Y=$P(APCHSN11,U,APCHSP) I Y]"" X APCHSCVD W " (obtained ",Y,")"
 Q
DTOBT S Y=$P(APCHSN,U,APCHSP) I Y]"" X APCHSCVD W " (obtained ",Y,")"
 Q
 ;
EDC ;S Y=$P(APCHSN,U,9)
 ;X APCHSCVD W "*** NOTE: EDC ",Y S APCHSP=11 D DTOBT
 ;I X<DT W " -- OUTDATED!"
 ;E  S X=$P(APCHSN,U,10),APCHSM="UNKNOWN METHOD" S:X Y=$P(^DD(9000017,4.05,0),U,3),X=$P(Y,";",X+1),APCHSM=$P(X,":",2)  W " BY ",APCHSM
 ;W !
 I $G(APCHAEDD) D ALLEDD Q
 NEW APCHDEDD,APCHDEDT,APCHDOBT,APCHBY
 S APCHDEDD=$$VALI^XBDIQ1(9000017,APCHSPAT,1311)
 I APCHDEDD]"" D  Q
 .;I APCHDEDD="L" S APCHDEDT=$$VALI^XBDIQ1(9000017,APCHSPAT,1302),APCHDOBT=$$VALI^XBDIQ1(9000017,APCHSPAT,1303)
 .;I APCHDEDD="U" S APCHDEDT=$$VALI^XBDIQ1(9000017,APCHSPAT,1305),APCHDOBT=$$VALI^XBDIQ1(9000017,APCHSPAT,1306)
 .;I APCHDEDD="C" S APCHDEDT=$$VALI^XBDIQ1(9000017,APCHSPAT,1308),APCHDOBT=$$VALI^XBDIQ1(9000017,APCHSPAT,1309)
 .X APCHSCKP Q:$D(APCHSQIT)
 .W "***NOTE: Definitive EDD: ",$$DATE^APCHSMU(APCHDEDD),"  (obtained ",$$DATE^APCHSMU($P($P($G(^AUPNREP(APCHSPAT,13)),U,12),".")),")"   ; 
 .I APCHDEDD<$$FMADD^XLFDT(DT,-14) W " -- OUTDATED!"
 .X APCHSCKP Q:$D(APCHSQIT)
 .W !
 .I $P($G(^AUPNREP(APCHSPAT,15)),U,2)]"" W "Comment: ",$P(^AUPNREP(APCHSPAT,15),U,2)
 .X APCHSCKP Q:$D(APCHSQIT)
 .W !
 ;no definitive EDD so print latest of the 4 values
 ;
 S APCHDOBT="",APCHBY="",APCHDEDT=""
 I $$VAL^XBDIQ1(9000017,APCHSPAT,1302)]"" S APCHDEDT=$$VALI^XBDIQ1(9000017,APCHSPAT,1302),APCHDOBT=$$VALI^XBDIQ1(9000017,APCHSPAT,1303),APCHBY="LMP"
 I $$VAL^XBDIQ1(9000017,APCHSPAT,1305)]"",$$VALI^XBDIQ1(9000017,APCHSPAT,1306)>APCHDOBT S APCHDEDT=$$VALI^XBDIQ1(9000017,APCHSPAT,1305),APCHDOBT=$$VALI^XBDIQ1(9000017,APCHSPAT,1306),APCHBY="ULTRASOUND"
 I $$VAL^XBDIQ1(9000017,APCHSPAT,1308)]"",$$VALI^XBDIQ1(9000017,APCHSPAT,1309)>APCHDOBT S APCHDEDT=$$VALI^XBDIQ1(9000017,APCHSPAT,1308),APCHDOBT=$$VALI^XBDIQ1(9000017,APCHSPAT,1309),APCHBY="CLINICAL PARAMETERS"
 I $$VAL^XBDIQ1(9000017,APCHSPAT,1314)]"",$$VALI^XBDIQ1(9000017,APCHSPAT,1315)>APCHDOBT S APCHDEDT=$$VALI^XBDIQ1(9000017,APCHSPAT,1314),APCHDOBT=$$VALI^XBDIQ1(9000017,APCHSPAT,1315),APCHBY="UNKNOWN METHOD"
 I APCHDEDT]"" D
 .X APCHSCKP Q:$D(APCHSQIT)
 .W "***NOTE: EDD: ",$$DATE^APCHSMU(APCHDEDT),"  (obtained ",$$DATE^APCHSMU(APCHDOBT),") BY ",APCHBY
 .I APCHDEDT<$$FMADD^XLFDT(DT,-14) W " -- OUTDATED!"
 .X APCHSCKP Q:$D(APCHSQIT)
 .W !
 .S F=$S(APCHBY="LMP":1401,APCHBY="ULTRASOUND":1402,APCHBY="CLINICAL PARAMETERS":1501,1:"1601")
 .I $$VAL^XBDIQ1(9000017,APCHSPAT,F)]"" W "Comment: ",$$VAL^XBDIQ1(9000017,APCHSPAT,F)
 .X APCHSCKP Q:$D(APCHSQIT)
 .W !
 Q
 ;
REPEDDHX ;EP - REPRODUCTIVE HISTORY - ALL EDDS
 S APCHAEDD=1
 D REPHX
 K APCHAEDD
 Q
 ;
ALLEDD ;
 ;print all EDDs with data
 ;1311, 1314, 1302, 1305, 1308
 NEW APCHDEDD,APCHDEDT,APCHDOBT,APCHBY
 S APCHDEDD=$$VALI^XBDIQ1(9000017,APCHSPAT,1311)
 I APCHDEDD]"" D
 .;I APCHDEDD="L" S APCHDEDT=$$VALI^XBDIQ1(9000017,APCHSPAT,1302),APCHDOBT=$$VALI^XBDIQ1(9000017,APCHSPAT,1303)
 .;I APCHDEDD="U" S APCHDEDT=$$VALI^XBDIQ1(9000017,APCHSPAT,1305),APCHDOBT=$$VALI^XBDIQ1(9000017,APCHSPAT,1306)
 .;I APCHDEDD="C" S APCHDEDT=$$VALI^XBDIQ1(9000017,APCHSPAT,1308),APCHDOBT=$$VALI^XBDIQ1(9000017,APCHSPAT,1309)
 .X APCHSCKP Q:$D(APCHSQIT)
 .W "***NOTE: Definitive EDD: ",$$DATE^APCHSMU(APCHDEDD),"  (obtained ",$$DATE^APCHSMU($P($P($G(^AUPNREP(APCHSPAT,13)),U,12),".")),")"  ; BY ",$S(APCHDEDD="L":"LMP",APCHDEDD="U":"ULTRASOUND",APCHDEDD="C":"CLINICAL PARAMETERS",1:"UNKNOWN METHOD")
 .I APCHDEDD<$$FMADD^XLFDT(DT,-14) W " -- OUTDATED!"
 .X APCHSCKP Q:$D(APCHSQIT)
 .W !
 .I $P($G(^AUPNREP(APCHSPAT,15)),U,2)]"" W "Comment: ",$P(^AUPNREP(APCHSPAT,15),U,2)
 .X APCHSCKP Q:$D(APCHSQIT)
 .W !
 ;NOW PRINT ALL OTHER EDD VALUES
 I $$VAL^XBDIQ1(9000017,APCHSPAT,1302)]"" S APCHDEDT=$$VALI^XBDIQ1(9000017,APCHSPAT,1302),APCHDOBT=$$VALI^XBDIQ1(9000017,APCHSPAT,1303),APCHBY="LMP" D W
 I $$VAL^XBDIQ1(9000017,APCHSPAT,1305)]"" S APCHDEDT=$$VALI^XBDIQ1(9000017,APCHSPAT,1305),APCHDOBT=$$VALI^XBDIQ1(9000017,APCHSPAT,1306),APCHBY="ULTRASOUND" D W
 I $$VAL^XBDIQ1(9000017,APCHSPAT,1308)]"" S APCHDEDT=$$VALI^XBDIQ1(9000017,APCHSPAT,1308),APCHDOBT=$$VALI^XBDIQ1(9000017,APCHSPAT,1309),APCHBY="CLINICAL PARAMETERS" D W
 I $$VAL^XBDIQ1(9000017,APCHSPAT,1314)]"" S APCHDEDT=$$VALI^XBDIQ1(9000017,APCHSPAT,1314),APCHDOBT=$$VALI^XBDIQ1(9000017,APCHSPAT,1315),APCHBY="UNKNOWN METHOD" D W
 Q
W ;
 I APCHDEDT]"" D
 .X APCHSCKP Q:$D(APCHSQIT)
 .W "***NOTE: EDD: ",$$DATE^APCHSMU(APCHDEDT),"  (obtained ",$$DATE^APCHSMU(APCHDOBT),") BY ",APCHBY
 .I APCHDEDT<$$FMADD^XLFDT(DT,-14) W " -- OUTDATED!"
 .X APCHSCKP Q:$D(APCHSQIT)
 .W !
 .S F=$S(APCHBY="LMP":1401,APCHBY="ULTRASOUND":1402,APCHBY="CLINICAL PARAMETERS":1501,1:"1601")
 .I $$VAL^XBDIQ1(9000017,APCHSPAT,F)]"" W "Comment: ",$$VAL^XBDIQ1(9000017,APCHSPAT,F)
 .X APCHSCKP Q:$D(APCHSQIT)
 .W !
 .Q
 Q