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

SDES2GETXPENTRY2.m

Go to the documentation of this file.
SDES2GETXPENTRY2 ;ALB/BLB,ANU - SDES2 GET EXPANDED ENTRY 2 ;APR 25, 2024
 ;;5.3;Scheduling;**867,878**;Aug 13, 1993;Build 11
 ;;Per VHA Directive 6402, this routine should not be modified
 Q
 ;
GETEXPANDEDENTRY(JSON,SDCONTEXT,PATIENTDATA) ;
 N RETURN,ERRORS,EXPANDEDENTRY,DFN,APPTIEN,CLINICIEN,VISITFILEIEN
 ;
 D VALIDATE(.ERRORS,$G(PATIENTDATA("APPOINTMENT IEN")),.SDCONTEXT)
 I $D(ERRORS) S ERRORS("ExpandedEntry",1)="" D BUILDJSON^SDES2JSON(.JSON,.ERRORS) Q
 ;
 D POPULATE(.PATIENTDATA,.DFN,.APPTIEN,.CLINICIEN,.VISITFILEIEN)
 ;
 D GETDIAGNOSIS(.EXPANDEDENTRY,VISITFILEIEN)
 D GETSTOPCODES(.EXPANDEDENTRY,CLINICIEN)
 D GETPROVIDERS(.EXPANDEDENTRY,VISITFILEIEN)
 D GETPROCEDURES(.EXPANDEDENTRY,VISITFILEIEN)
 D GETPATIENTCLASS(.EXPANDEDENTRY,APPTIEN)
 ;
 I '$D(EXPANDEDENTRY) S EXPANDEDENTRY("Expandedentry",1)=""
 D BUILDJSON^SDES2JSON(.JSON,.EXPANDEDENTRY)
 Q
 ;
POPULATE(PATIENTDATA,DFN,APPTIEN,CLINICIEN,VISITFILEIEN) ;
 N ENCOUNTERIEN
 S APPTIEN=$G(PATIENTDATA("APPOINTMENT IEN"))
 S DFN=$$GET1^DIQ(409.84,APPTIEN,.05,"I")
 S CLINICIEN=$$GET1^DIQ(409.831,$$GET1^DIQ(409.84,APPTIEN,.07,"I"),.04,"I")
 S ENCOUNTERIEN=$$GETAPT^SDVSIT2(DFN,$$GET1^DIQ(409.84,APPTIEN,.01,"I"),CLINICIEN)
 S VISITFILEIEN=$$GET1^DIQ(409.68,ENCOUNTERIEN,.05,"I")
 Q
 ;
GETDIAGNOSIS(EXPANDEDENTRY,VISITFILEIEN) ;
 N PURPOSOFVISITIEN,COUNT
 ;
 I '$G(VISITFILEIEN) S EXPANDEDENTRY("ExpandedEntry","Diagnosis",1)="" Q
 S PURPOSOFVISITIEN=0,COUNT=0
 F  S PURPOSOFVISITIEN=$O(^AUPNVPOV("AD",VISITFILEIEN,PURPOSOFVISITIEN)) Q:'PURPOSOFVISITIEN  D
 .S COUNT=COUNT+1
 .S EXPANDEDENTRY("ExpandedEntry","Diagnosis",COUNT,"ICDDiagnosisCode")=$$GET1^DIQ(9000010.07,PURPOSOFVISITIEN,.01,"E")
 .S EXPANDEDENTRY("ExpandedEntry","Diagnosis",COUNT,"ProviderNarrative")=$$GET1^DIQ(9000010.07,PURPOSOFVISITIEN,.04,"E")
 I '$D(EXPANDEDENTRY("ExpandedEntry","Diagnosis")) S EXPANDEDENTRY("ExpandedEntry","Diagnosis",1)=""
 Q
 ;
GETSTOPCODES(EXPANDEDENTRY,CLINICIEN) ;
 S EXPANDEDENTRY("ExpandedEntry","StopCode","AmisStopCodeNumber")=$$GET1^DIQ(40.7,$$GET1^DIQ(44,CLINICIEN,8,"I"),1)
 S EXPANDEDENTRY("ExpandedEntry","StopCode","AmisStopCodeName")=$$GET1^DIQ(44,CLINICIEN,8,"E")
 S EXPANDEDENTRY("ExpandedEntry","StopCode","CreditStopCodeName")=$$GET1^DIQ(44,CLINICIEN,2503,"E")
 S EXPANDEDENTRY("ExpandedEntry","StopCode","CreditStopCodeNumber")=$$GET1^DIQ(40.7,$$GET1^DIQ(44,CLINICIEN,2503,"I"),1,"I")
 I '$D(EXPANDEDENTRY("ExpandedEntry","StopCode")) S EXPANDEDENTRY("ExpandedEntry","StopCode")=""
 Q
 ;
GETPROVIDERS(EXPANDEDENTRY,VISITFILEIEN) ;
 N VISITPROVIDERIEN,COUNT
 ;
 I '$G(VISITFILEIEN) S EXPANDEDENTRY("ExpandedEntry","Provider",1)="" Q
 S VISITPROVIDERIEN=0,COUNT=0
 F  S VISITPROVIDERIEN=$O(^AUPNVPRV("AD",VISITFILEIEN,VISITPROVIDERIEN)) Q:'VISITPROVIDERIEN  D
 .S COUNT=COUNT+1
 .S EXPANDEDENTRY("ExpandedEntry","Provider",COUNT)=$$GET1^DIQ(9000010.06,VISITPROVIDERIEN,.01,"E")
 I '$D(EXPANDEDENTRY("ExpandedEntry","Provider")) S EXPANDEDENTRY("ExpandedEntry","Provider",1)=""
 Q
 ;
GETPROCEDURES(EXPANDEDENTRY,VISITFILEIEN) ;
 N PROCEDUREIEN,MODIFIERIEN,COUNT,COUNT2
 ;
 I '$G(VISITFILEIEN) S EXPANDEDENTRY("ExpandedEntry","ClinicalProcedure",1)="" Q
 S PROCEDUREIEN=0,COUNT=0
 F  S PROCEDUREIEN=$O(^AUPNVCPT("AD",VISITFILEIEN,PROCEDUREIEN)) Q:'PROCEDUREIEN  D
 .S COUNT=COUNT+1
 .S EXPANDEDENTRY("ExpandedEntry","ClinicalProcedure",COUNT,"ClinicalProcedureCode")=$$GET1^DIQ(9000010.18,PROCEDUREIEN,.01,"I")
 .S EXPANDEDENTRY("ExpandedEntry","ClinicalProcedure",COUNT,"NumberOfTimesProcedurePerformed")=$$GET1^DIQ(9000010.18,PROCEDUREIEN,.16,"I")
 .S EXPANDEDENTRY("ExpandedEntry","ClinicalProcedure",COUNT,"ProviderNarrative")=$$GET1^DIQ(9000010.18,PROCEDUREIEN,.04,"E")
 .;
 .S MODIFIERIEN=0,COUNT2=0
 .F  S MODIFIERIEN=$O(^AUPNVCPT(PROCEDUREIEN,1,MODIFIERIEN)) Q:'MODIFIERIEN  D
 ..S COUNT2=COUNT2+1
 ..S EXPANDEDENTRY("ExpandedEntry","ClinicalProcedure",COUNT,"ClinicalProcedureModifierCode",COUNT2)=$$GET1^DIQ(81.3,$$GET1^DIQ(9000010.181,MODIFIERIEN_","_PROCEDUREIEN_",",.01,"I"),.01,"I")
 ..S EXPANDEDENTRY("ExpandedEntry","ClinicalProcedure",COUNT,"ClinicalProcedureModifier",COUNT2)=$$GET1^DIQ(81.3,$$GET1^DIQ(9000010.181,MODIFIERIEN_","_PROCEDUREIEN_",",.01,"I"),.02,"I")
 I '$D(EXPANDEDENTRY("ExpandedEntry","ClinicalProcedure")) S EXPANDEDENTRY("ExpandedEntry","ClinicalProcedure",1)=""
 Q
 ;
GETPATIENTCLASS(EXPANDEDENTRY,APPTIEN) ;
 N CLASSNAME,CLASSTYPEIEN,CLASSIEN,OUTPENCOUNTERIEN,SDISCLACTIVE
 ;
 S OUTPENCOUNTERIEN=$$GET1^DIQ(2.98,$$GET1^DIQ(409.84,APPTIEN,.01,"I")_","_$$GET1^DIQ(409.84,APPTIEN,.05,"I")_",",21,"I")
 S CLASSNAME=""
 F  S CLASSNAME=$O(^SD(409.41,"B",CLASSNAME)) Q:CLASSNAME=""  D
 .S CLASSTYPEIEN=0
 .F  S CLASSTYPEIEN=$O(^SD(409.41,"B",CLASSNAME,CLASSTYPEIEN)) Q:'CLASSTYPEIEN  D
 ..S EXPANDEDENTRY("ExpandedEntry","PatientClassification",CLASSTYPEIEN,"ClassificationName")=CLASSNAME
 ..;
 ..S SDISCLACTIVE="Not Applicable"
 ..I $D(^SDD(409.42,"AO",OUTPENCOUNTERIEN,CLASSTYPEIEN)) D
 ...S CLASSIEN=0,CLASSIEN=+$O(^SDD(409.42,"AO",OUTPENCOUNTERIEN,CLASSTYPEIEN,CLASSIEN))
 ...S SDISCLACTIVE=$S($$GET1^DIQ(409.42,CLASSIEN,.03,"I")=1:"Yes",$$GET1^DIQ(409.42,CLASSIEN,.03,"I")=0:"No",1:"Not Applicable")
 ..S EXPANDEDENTRY("ExpandedEntry","PatientClassification",CLASSTYPEIEN,"IsClassificationActive")=SDISCLACTIVE
 ..;
 Q
 ;
VALIDATE(ERRORS,APPTIEN,SDCONTEXT) ;
 N VALRETURN
 D VALFILEIEN^SDES2VALUTIL(.VALRETURN,.ERRORS,409.84,APPTIEN,1,,14,15) ;
 D VALCONTEXT^SDES2VALCONTEXT(.ERRORS,.SDCONTEXT)
 Q
 ;