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

SDES2GETEXPENTRY.m

Go to the documentation of this file.
SDES2GETEXPENTRY ;ALB/BLB - SDES2 GET EXPANDED ENTRY ;Sep 25, 2023
 ;;5.3;Scheduling;**861**;Aug 13, 1993;Build 17
 ;;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,PATIENTDATA("APPOINTMENT IEN"),.SDCONTEXT)
 I $D(ERRORS) M RETURN=ERRORS S EXPANDEDENTRY("ExpandedEntry",1)="" D BUILDJSON^SDES2JSON(.JSON,.RETURN) 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)=""
 M RETURN=EXPANDEDENTRY D BUILDJSON^SDES2JSON(.JSON,.RETURN)
 Q
 ;
POPULATE(PATIENTDATA,DFN,APPTIEN,CLINICIEN,VISITFILEIEN) ;
 N ENCOUNTERIEN
 S APPTIEN=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
 ;
 S PURPOSOFVISITIEN=0,COUNT=0
 F  S PURPOSOFVISITIEN=$O(^AUPNVPOV("AD",VISITFILEIEN,PURPOSOFVISITIEN)) Q:'PURPOSOFVISITIEN  D
 .S COUNT=COUNT+1
 .S EXPANDEDENTRY("ExpandedEntry","ICDDiagnosisCode",COUNT)=$$GET1^DIQ(9000010.07,PURPOSOFVISITIEN,.01,"E")
 .S EXPANDEDENTRY("ExpandedEntry","Diagnosis",COUNT)=$$GET1^DIQ(9000010.07,PURPOSOFVISITIEN,.04,"E")
 I '$D(EXPANDEDENTRY("ExpandedEntry","ICDDiagnosisCode")) S EXPANDEDENTRY("ExpandedEntry","ICDDiagnosisCode")=""
 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
 ;
 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
 ;
 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
 ;
 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
 ..;
 ..I $D(^SDD(409.42,"AO",OUTPENCOUNTERIEN,CLASSTYPEIEN)) D  Q
 ...S CLASSIEN=0,CLASSIEN=$O(^SDD(409.42,"AO",OUTPENCOUNTERIEN,CLASSTYPEIEN,CLASSIEN))
 ...S EXPANDEDENTRY("ExpandedEntry","PatientClassification",CLASSTYPEIEN,"IsClassificationActive")=$$GET1^DIQ(409.42,CLASSIEN,.03,"E")
 ..;
 ..S EXPANDEDENTRY("ExpandedEntry","PatientClassification",CLASSTYPEIEN,"IsClassificationActive")="NO"
 Q
 ;
VALIDATE(ERRORS,APPTIEN,SDCONTEXT) ;
 N VALRETURN
 D VALFILEIEN^SDES2VALUTIL(.VALRETURN,.ERRORS,409.84,APPTIEN,1,,14,15) ;
 D VALCONTEXT^SDES2VALCONTEXT(.ERRORS,.SDCONTEXT)
 Q
 ;