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

ORWDXIHS.m

Go to the documentation of this file.
ORWDXIHS ; IHS/CIA/DKM - Order dialog utilities for IHS ;18-Jul-2016 12:51;DU
 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**1002,1008,1010,1012,1013,1015,1016**;Dec 17, 1997;Build 41
 ;
 ;Modified - IHS/MSC/PLS - 06/22/2011 - Line ADDIND+1
 ;                         06/28/2013 - Line ADDIND+4
 ;           IHS/MSC/MGH   07/18/2016 - Made Exclusionary on status
 ;
 ; RPC: Returns clinical indicators for orderable item.
 ;   DFN  = Patient IEN
 ;   VIEN = Visit IEN
 ;   OI   = Orderable item (not currently used)
 ;   SNOMED = flag for EHR 13
CLININD(DATA,DFN,VIEN,OI,SNOMED) ;EP
 N IEN,ITM,ICD,STAT
 K DATA
 S IEN=0,VIEN=+VIEN,SNOMED=$G(SNOMED)
 D SNOMED(.DATA,DFN,VIEN,OI) Q
 ;IHS/MSC/MGH No longer needed since its all changed to snomed p15
 ;F  S IEN=+$O(^AUPNVPOV("AD",VIEN,IEN)) Q:'IEN  D
 ;.S ITM=$$GET1^DIQ(9000010.07,IEN,.04),ICD=+$G(^AUPNVPOV(IEN,0))
 ;.D ADDIND(1,ITM,ICD)
 ;F  S IEN=+$O(^AUPNPROB("ACTIVE",DFN,"A",IEN)) Q:'IEN  D
 ;.S ITM=$$GET1^DIQ(9000011,IEN,.05),ICD=+$G(^AUPNPROB(IEN,0))
 ;.D ADDIND(2,ITM,ICD)
 ;K DATA(0)
 Q
ADDIND(SUB,ITM,ICD,IEN,CONCID) ;EP-
 N CODE
 I $$AICD S CODE=$P($$ICDDX^ICDEX(ICD,$$NOW^XLFDT),U,2)
 E  S CODE=$$GET1^DIQ(80,ICD,.01)
 ;Q:CODE=".9999"  ;IHS/MSC/PLS - 06/28/13 - per Susan
 I '$L(ITM) D
 .I $$AICD S ITM=$P($$ICDDX^ICDEX(ICD,$$NOW^XLFDT),U,4)
 .E  S ITM=$$GET1^DIQ(80,ICD,3)
 I $L(ITM),'$D(DATA(0,ITM)) D
 .S DATA(0,ITM)="",DATA(SUB,ITM)=ITM_U_$S(SUB=1:"POV",1:"PL")_U_CODE_U_IEN_U_CONCID
 .;E  S DATA(0,ITM)="",DATA(SUB,ITM)=ITM_U_$P("POV^PL",U,SUB)_U_CODE
 Q
SNOMED(DATA,DFN,VIEN,OI) ;EP-
 N IEN,ITM,NARR,SUB,IMP,VDT,SNODATA,POVIEN
 S VIEN=$G(VIEN)
 S IEN=0
 S STAT="" F  S STAT=$O(^AUPNPROB("ACTIVE",DFN,STAT)) Q:STAT=""  D
 .Q:STAT="I"!(STAT="D")                     ;Patch 1016 Make it exclusionary
 .S IEN="" F  S IEN=+$O(^AUPNPROB("ACTIVE",DFN,STAT,IEN)) Q:'IEN  D
 ..S ITM=$$GET1^DIQ(9000011,IEN,.05),ICD=+$G(^AUPNPROB(IEN,0))
 ..S CONCID=$$GET1^DIQ(9000011,IEN,80001)
 ..Q:CONCID=""
 ..;IHS/MSC/MGH Patch 1013 for ICD-10 conversion
 ..S SNODATA=$$CONC^BSTSAPI(CONCID_"^^^1")
 ..S ICD=$P($P(SNODATA,U,5),";",1)
 ..I $D(^AUPNPROB(IEN,14,"B",VIEN)) D
 ...S SUB=1
 ...S POVIEN="" F  S POVIEN=$O(^AUPNVPOV("AD",VIEN,POVIEN)) Q:POVIEN=""  D
 ....I $P($G(^AUPNVPOV(POVIEN,0)),U,16)=IEN D
 .....S ICD=$$GET1^DIQ(9000010.07,POVIEN,.01)
 ..E  S SUB=$S(STAT="A":2,STAT="S":3,STAT="E":4,STAT="O":5,STAT="R":6,1:2)  ;Patch 1016 add in routine/admin
 ..D ADDIND(SUB,ITM,ICD,IEN,CONCID)
 K DATA(0)
 Q
 ;
 ; Returns boolean flag indicating if order has a SNOMED Concept ID
ORDSMCID(DATA,ORIFN) ;EP-
 N RES
 S RES=$$VALUE^ORCSAVE2(+ORIFN,"SNMDCNPTID")
 S DATA=$L(RES)>0
 Q
 ;
 ; Input: ORIFN: Order File IEN
 ;        SNMD: Snomed Description^Source^ICD|..n(optional)^Problem IEN(optional)^Snomed Concept ID
UPSNMD(DATA,ORIFN,SNMD) ;EP-
 D RESP^ORCSAVE2(+ORIFN,"OR GTX CLININD",$P(SNMD,U))
 D RESP^ORCSAVE2(+ORIFN,"OR GTX CLININD2",$P($P(SNMD,U,3),"|"))
 D RESP^ORCSAVE2(+ORIFN,"OR GTX SNMDCNPTID",$P(SNMD,U,5))
 D ORDSMCID(.DATA,ORIFN)
 Q
AICD() ;EP
 Q $S($$VERSION^XPDUTL("AICD")<"4.0":0,1:1)