Attribute VB_Name = "mdlMembers" Option Explicit Const YELLOW = &H80000018 Const WHITE = &H80000005 Const BLACK = &H80000008 Public conMember As New ADODB.Connection Public recMember As New ADODB.Recordset Public Rec As New ADODB.Recordset 'Public Sub Emphasize(msflexVar As MSHFlexGrid, lHigh As Boolean) ' If msflexVar.Rows > 0 Then ' If lHigh Then ' msflexVar.CellBackColor = YELLOW ' msflexVar.CellForeColor = BLACK ' Else ' msflexVar.CellBackColor = WHITE ' msflexVar.CellForeColor = BLACK ' End If ' End If 'End Sub Public Function GetPatientAdmDate(stridnum As String) As String Dim SQL As String If IsNumeric(Right(stridnum, 1)) = True Then SQL = "Select isnull(Convert(Varchar(10), AdmDate, 101),'') AdmDate from patient_data..tbpatient where IDNum = '" & stridnum & "'" ElseIf Right(stridnum, 1) = "B" Then SQL = "Select isnull(Convert(Varchar(10), AdmDate, 101),'') AdmDate from patient_data..tboutpatient where IDNum = '" & stridnum & "'" ElseIf Right(stridnum, 1) = "D" Then SQL = "Select isnull(Convert(Varchar(10), AdmDate, 101),'') AdmDate from medicare..tbmedpatient where IDNum = '" & stridnum & "'" Else SQL = "Select isnull(Convert(Varchar(10), AdmDate, 101),'') AdmDate from patient_data..tbpatient where IDNum = '" & stridnum & "'" End If With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then GetPatientAdmDate = !AdmDate & "" End If .Close End With Set Rec = Nothing End Function Public Function GetMemberType(stridnum As String) As Integer Dim SQL As String SQL = "Medicare..Medic_GetMemberType '" & stridnum & "'" With recMember If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then GetMemberType = CInt(!MemberType) Else GetMemberType = 1 End If .Close End With Set recMember = Nothing GetMemberType = IIf(GetMemberType = 0, 1, GetMemberType) End Function 'added by angelika 9/14/2015 Public Function CheckIfHemoPatient(stridnum As String) As Boolean Dim Rec As New ADODB.Recordset Dim SQL As String CheckIfHemoPatient = False SQL = "select hemonum from patient_data..tboutpatient where idnum = '" & stridnum & "' and ishemodialysis = '1'" With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then CheckIfHemoPatient = True End If .Close End With Set Rec = Nothing End Function Public Function CheckEntryForm1(stridnum As String) As Boolean Dim SQL As String SQL = "Select * from tbQualityObjective " SQL = SQL + "where IDNum = '" & stridnum & "' and (Form1User is not null or " SQL = SQL + "Form1Date is not null)" CheckEntryForm1 = False With recMember If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then CheckEntryForm1 = True End If .Close End With Set recMember = Nothing End Function Public Function Get_DcrDate(stridnum As String) As String Dim SQL As String If IsNumeric(Right(stridnum, 1)) = True Then SQL = "Select isnull(AdmDate,'') AdmDate, isnull(DcrDate,'1900-01-01 00:00:00.000') DcrDate from Patient_Data..tbPatient where IDNum = '" & stridnum & "'" Else SQL = "Select isnull(AdmDate,'') AdmDate, isnull(DcrDate,'1900-01-01 00:00:00.000') DcrDate from Patient_Data..tboutPatient where IDNum = '" & stridnum & "'" End If With recMember If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then If !AdmDate <> "" Then Get_DcrDate = IIf(ValidateDate(!DCRDate, !AdmDate), !DCRDate & "", "") End If End If .Close End With Set recMember = Nothing End Function Public Function ValidateDate(ByVal strValue As Date, ByVal strAdmDate As Date) As Boolean ValidateDate = False If IsDate(strValue) Then If IsNumeric(Right(stridnum, 1)) = True Then If strValue > strAdmDate Then ValidateDate = True Else ValidateDate = False End If Else If strValue >= Format(strAdmDate, "mm/dd/yyyy") Then ValidateDate = True Else ValidateDate = False End If End If Else ValidateDate = False End If End Function Public Function GetServerDate() As String Dim SQL As String SQL = "Select getdate() as ServerDate" With recMember If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then ServerDate = Format(!ServerDate, "mm/dd/yyyy hh:mm:ss") End If .Close End With Set recMember = Nothing End Function Public Function GetHospitalCode() As String Dim SQL As String SQL = "Select top 1 isnull(HospitalCode,'') as HospitalCode from Medicare..tbmedhospital" With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then pstrHospitalCode = !HospitalCode & "" End If .Close End With End Function 'added by angelika 9.1.2015 (minimized adjustment on classmedicare) Public Function GetRegion() As String Dim SQL As String SQL = "Select top 1 isnull(region,'') as region from Medicare..tbmedhospital" With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then region = !region & "" End If .Close End With End Function Public Function isPaidtoBill(stridnum As String) As Boolean Dim SQL As String isPaidtoBill = False SQL = "Select isnull(isPTB, '') as PTB from Medicare..tbMedActual where IDNum = '" & stridnum & "'" With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then If !PTB = "N" Then strOptionType = "N" isPaidtoBill = False ElseIf !PTB = "" Then isPaidtoBill = True Else strOptionType = "Y" isPaidtoBill = False End If Else isPaidtoBill = True End If .Close End With Set Rec = Nothing End Function Public Function GetDcrDate(stridnum As String) As String Dim SQL As String If CheckIfExistAdmDate(stridnum) Then SQL = "Select max(DateDischarges) Discharge from Medicare..tbMedicOutDischarges where IDNum = '" & stridnum & "'" With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then GetDcrDate = !Discharge End If .Close End With Set Rec = Nothing End If End Function Public Function Getadmdate(stridnum As String) As String Dim SQL As String If CheckIfExistAdmDate(stridnum) Then SQL = "Select min(isnull(DateDischarges,getdate())) Admitted from Medicare..tbMedicOutDischarges where IDNum = '" & stridnum & "'" With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then Getadmdate = !Admitted End If .Close End With Set Rec = Nothing End If End Function Public Function GetDoctorPF(strDocID As String, DocType As String) As String Dim SQL As String SQL = "select isnull(MedicarePF,0) MedicarPF from Medicare..tbMedDoctors where IDnum = '" & stridnum & "' and DocCode = '" & strDocID & "'" With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then If DocType = "P" Then PhysicianPF = Val(!MedicarPF) ElseIf DocType = "S" Then SurgeonPF = Val(!MedicarPF) ElseIf DocType = "A" Then AnesPF = Val(!MedicarPF) End If End If .Close End With DoctorPF = PhysicianPF + SurgeonPF + AnesPF Set Rec = Nothing End Function Public Function CheckIfExistAdmDate(stridnum As String) As Boolean Dim SQL As String SQL = "Select * from Medicare..tbMedicOutDischarges where IDNum = '" & stridnum & "'" With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then CheckIfExistAdmDate = True Else CheckIfExistAdmDate = False End If .Close End With Set Rec = Nothing End Function ' 'Public Function GetDocSpecialization(DocCode As String) As String ' Dim Rec As New ADODB.Recordset ' Dim SQL As String ' ' SQL = "Select Specialization from Build_File..tbcoDoctor D left Outer Join Build_File..tbcoSpecialization S " & _ ' " on D.SpecializationID = S.SpecializationID where DoctorID = '" & DocCode & "'" ' ' GetDocSpecialization = "" ' ' With Rec ' If .State > 0 Then .Close ' .CursorLocation = adUseClient ' .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly ' ' If .RecordCount > 0 Then ' GetDocSpecialization = !Specialization ' End If ' .Close ' End With ' Set Rec = Nothing 'End Function Public Function GetDocSpecialization(DocCode As String) As String Dim Rec As New ADODB.Recordset Dim SQL As String SQL = "Select isnull(PMCC,'') PMCC from Build_File..tbcoDoctor D where DoctorID = '" & DocCode & "'" GetDocSpecialization = "" With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then GetDocSpecialization = !PMCC & "" End If .Close End With Set Rec = Nothing End Function Public Function GetDocExpiryDate(DocCode As String) As String Dim Rec As New ADODB.Recordset Dim SQL As String 'AC-01102022 Revised SQL = "Select isnull(PHICExpireDate,'') PHICExpireDate from Build_File..tbcoDoctor D where DoctorID = '" & DocCode & "' and (phicEXPIREDATE is not null and phicEXPIREDATE <> 'NULL' and PHICExpireDate <> ' / / ' AND PHICExpireDate <> '')" GetDocExpiryDate = "" With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly ' If .RecordCount > 0 Then If .EOF = False Then GetDocExpiryDate = !PHICExpireDate Else MsgBox "A Non-Philhealth Accredited. Please contact IT Personnel!", vbInformation, "MESSAGE" End If .Close End With Set Rec = Nothing End Function Public Function GetAuthorizedBeds() As String Dim SQL As String SQL = "Select top 1 isnull(AuthorizedBeds,'300') AuthorizedBeds from Medicare..tbMedHospital" With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then GetAuthorizedBeds = !AuthorizedBeds End If .Close End With Set Rec = Nothing End Function Public Function GetMSSD() As String Dim SQL As String SQL = "Select top 1 isnull(MSSD,'') MSSD from Medicare..tbMedHospital" With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then GetMSSD = !MSSD End If .Close End With Set Rec = Nothing End Function Public Function GetOperationDate(stridnum As String, strDocCode As String) As String Dim SQL As String SQL = "Select OperationDate from Station..tbNurseDischargeNotice where IDNum = '" & stridnum & "'" With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then If IsNull(!OperationDate) Then GetOperationDate = "" Else GetOperationDate = Format(!OperationDate, "MM/DD/YYYY") End If End If .Close End With Set Rec = Nothing End Function Public Function GetActualUserID(stridnum As String) As String Dim Rec As New ADODB.Recordset Dim SQL As String GetActualUserID = "" SQL = "Select UserID from Medicare..tbMedActual where IDNum = '" & stridnum & "'" With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then GetActualUserID = !UserID & "" End If .Close End With ActualUserID = GetActualUserID Set Rec = Nothing End Function Public Function CheckConfinementinOtherHospital(stridnum As String) As Boolean Dim Rec As New ADODB.Recordset Dim SQL As String SQL = "Medic_ConfinementinOtherHospital '" & stridnum & "'" CheckConfinementinOtherHospital = False With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If Not .EOF Then CheckConfinementinOtherHospital = True End If .Close End With Set Rec = Nothing End Function Public Function CheckHemoChemoDischarges(stridnum As String) As Boolean Dim Rec As New ADODB.Recordset Dim SQL As String SQL = "Select * from Medicare..tbMedicOutDischarges where IDNum = '" & stridnum & "'" CheckHemoChemoDischarges = False With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then CheckHemoChemoDischarges = True End If .Close End With Set Rec = Nothing End Function 'added angelika 4.29.2015 Public Function checkIfDepositExist(stridnum As String) As Boolean Dim Rec As New ADODB.Recordset Dim STR As String 'STR = "Select Membernumber from medicare..tbmedpatient where membernumber is not null and membernumber != '' and idnum = '" & strIdnum & "'" 'STR = "Select idnum, membernumber from medicare..tbmedform1 where membernumber is not null and membernumber != '' and idnum = '" & strIdNum & "'" If stridnum Like "B" Then STR = "Select revenueid from billing..tbBillOPDailyOut where revenueid = 'DE' and idnum = '" & stridnum & "'" Else STR = "Select revenueid from billing..tbBillDailyBill where revenueid = 'DE' and idnum = '" & stridnum & "'" End If With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .Open STR, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then checkIfDepositExist = True End If .Close End With End Function Public Function checkIfCompanyInsuranceExist(stridnum As String) As Boolean Dim Rec As New ADODB.Recordset Dim STR As String 'STR = "Select Membernumber from medicare..tbmedpatient where membernumber is not null and membernumber != '' and idnum = '" & strIdnum & "'" 'STR = "Select idnum, membernumber from medicare..tbmedform1 where membernumber is not null and membernumber != '' and idnum = '" & strIdNum & "'" If stridnum Like "B" Then STR = "Select AccountNum, hospPlan from patient_data..tboutpatient where AccountNum is not null and hospPlan in ('I','C') and idnum = '" & stridnum & "'" Else STR = "Select AccountNum, hospPlan from patient_data..tbpatient where AccountNum is not null and hospPlan in ('I','C') and idnum = '" & stridnum & "'" End If With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .Open STR, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then checkIfCompanyInsuranceExist = True End If .Close End With End Function Public Function CheckDischargeDate(stridnum As String) As String Dim recSQL As New ADODB.Recordset Dim strSQL As String pubDcrDate = "" If IsNumeric(Right(stridnum, 1)) = True Then strSQL = "Select DcrDate From Patient_Data..tbPatient Where IDNum = '" & stridnum & "'" Else strSQL = "Select DcrDate From Patient_Data..tboutPatient Where IDNum = '" & stridnum & "'" End If With recSQL If .State > 0 Then .Close .CursorLocation = adUseClient .Open strSQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then If Not IsNull(!DCRDate) Then CheckDischargeDate = !DCRDate End If End If If .State > 0 Then .Close End With pubDcrDate = CheckDischargeDate End Function Public Function GetRUVAmount(strRUV As String, strCaseType As String) As String Dim Rec As New ADODB.Recordset Dim SQL As String SQL = "Select RUVRate [RUVRate] From Medicare..tbMedORRates Where Type = '" & strCaseType & "' and '" & _ strRUV & "' between FromRUV and ToRUV" With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then GetRUVAmount = ![RUVRate] & "" End If .Close End With Set Rec = Nothing End Function Public Function GetNewRUVAmount(strRUV As String, strCaseType As String) As String Dim Rec As New ADODB.Recordset Dim SQL As String SQL = "Select RUVRate [RUVRate] From Medicare..tbMedNewORRates Where Type = '" & strCaseType & "' and '" & _ strRUV & "' between FromRUV and ToRUV" With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then GetNewRUVAmount = ![RUVRate] & "" End If .Close End With Set Rec = Nothing End Function Public Sub getdoccount() Dim Rec As New ADODB.Recordset Dim SQL As String SQL = "Select doccount from medicare..tbmeddoctors where IDNum = '" & Trim$(stridnum) & "'" With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then doccountx = !DocCount End If .Close End With Set Rec = Nothing End Sub Public Sub GetAdministrator() Dim Rec As New ADODB.Recordset Dim SQL As String SQL = "Medicare..Medic_ValidateHospitalInfo" With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then pstrAdministrator = !Administrator pstrAdminTitle = !AdminTitle blnCashMeds = !isAllowCashMeds blnWithOperationDate = !isAllowOperationDate blnAllowUpdateSlashingCharges = !isAllowUpdateSlashingCharges blnAllowDistributeSlashing = !isAllowDistributeSlashing blnAllowPrintOutDiagnosis = !isAllowPrintOutDiagnosis intAllowedPrintOutDiagnosis = !AllowedPrintOutDiagnosis blnAllowTentativeTransmittal = !isAllowTentativeTransmittal blnAllowShowElapsedClaims = !isAllowShowElapsedClaims blnAllowShowRTHClaims = !isAllowShowRTHClaims blnAllowMaximize = !isAllowMaximize blnAllowPrintPartV = !isAllowPrintPartV blnAllowUpdateDoctorPF = !isAllowUpdateDoctorPF blnAllowLateSubmission = !isAllowLateSubmission blnAllowTransmittalRefiled = !isAllowTransmittalRefiled PubSlashingForm = !SlashingForm & "" blnAllowSlashing = !isAllowSlashing blnAllowSignatoryUserAccount = !isAllowSignatoryUserAccount blnAllowPatientAutomaticCompute = !isAllowPatientAutomaticCompute blnAllowEntryAutomaticCompute = !isAllowEntryAutomaticCompute blnAllowBuildFileNew = !isAllowBuildFileNew blnAllowIndexNumber = !IsAllowIndexNumber blnAllowDirectAutomaticCompute = !isAllowDirectAutomaticCompute blnAllowDeleteTransmittal = !IsAllowDeleteTransmittal blnAllowShowPerformedDate = !IsAllowShowPerformedDate blnAllowLockedFormsPrinting = !IsAllowLockedFormsPrinting PubFormsImplementationDate = !FormsImplementationDate PubACRFormsImplementationDate = !ACRFormsImplementationDate blnAllowSeparatePart45 = !IsAllowSeparatePart45 blnAllowEditPatientDays = !IsAllowEditPatientDays blnAllowPart23Signatory = !IsAllowPart23Signatory pstrPHICAccountNum = !AccountNum PubBenefitsImplementationDate = !BenefitsImplementationDate blnPart34onEntry = !isPart34onEntry blnisAllowPBEF = !isAllowPBEF PubisPBEFImplementationDate = !IsPBEFImplementationdate 'to be continued blnEnablePBEF = !EnablePBEF blnisAllowCaseRateTerms = !isAllowCaseRateTerms PubAllowCaseRateTermsImplementationDate = !AllowCaseRateTermsImplementationDate blnisAllowFieldsCF2 = !isAllowFieldsCF2 blnEnablePFPHICValidCF1 = !EnablePFPHICValidCF1 blnisValidate90daysCaserate = !isValidate90daysCaserate blnAllowShowAdmittedPHICPx = !isAllowShowAdmittedPHICPx blnAllowShowAdmittedPHICPxImplementationDate = !isAllowShowAdmittedPHICPx_ImplementationDate blnPBEFTransmittal = !PBEFTransmittal blnPBEFTransmittalImplementationDate = !PBEFTransmittalImplementationDate blnAutoPFSharing = !AutoComputePFSharing blnCF2Preprint = !EnablePrePrintCF2 bln90daysConfinement = !EnablePrompt90DaysCF1 blnisTransmittalCaseType = !isTransmittalCaseType blnisallowSplitCaserate = !isallowSplitCaserate blnisDistributeWholeCaserate = !isDistributeWholeCaserate End If .Close End With Set Rec = Nothing End Sub Public Function CheckRelationship(stridnum As String, Optional strHospNum As String) As Boolean Dim Rec As New ADODB.Recordset Dim SQL As String CheckRelationship = False SQL = "if exists(Select isnull(Relationship,'') Relationship from Medicare..tbMedRelationship where IDNum = '" & Trim$(stridnum) & "') begin " & _ "Select isnull(Relationship,'') Relationship from Medicare..tbMedRelationship where IDNum = '" & Trim$(stridnum) & "' end else begin Select isnull(F.Relationship,'') " & _ "Relationship from medicare..tbMedMember D left outer join Medicare..tbMedRelationship F on F.Membernumber = D.Membernumber " & _ "left outer join Patient_Data..tbpatient A on A.IdNum = F.idnum " & _ "left outer join Patient_Data..tbmaster G on G.hospnum = A.hospnum " & _ "where A.HospNum = '" & Trim$(strHospNum) & "' end" With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If Not .EOF Then pubMemberRelationship = !Relationship CheckRelationship = True End If .Close End With Set Rec = Nothing End Function Public Function GetPackage(stridnum As String) As String Dim Rec As New ADODB.Recordset Dim SQL As String GetPackage = "" If IsNumeric(Right(stridnum, 1)) = True Then SQL = "Select isnull(Patient_data.dbo.fn_GetPackage(PackageID),'') as Package from Patient_Data..tbPatient2 where IDNum = '" & Trim$(stridnum) & "'" Else SQL = "Select isnull(Patient_data.dbo.fn_GetPackage(PackageID),'') as Package from Patient_Data..tbOutPatient where IDNum = '" & Trim$(stridnum) & "'" End If With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then GetPackage = !Package End If .Close End With Set Rec = Nothing PublicPackage = GetPackage isPublicPackage = IIf(GetPackage = "", False, True) End Function Public Function IsCashMeds(stridnum As String) As Boolean Dim Rec As New ADODB.Recordset Dim SQL As String IsCashMeds = False SQL = "Select isnull(isCashMeds,0) isCashMeds from Medicare..tbMedPatient where IDNum = '" & Trim$(stridnum) & "'" With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then IsCashMeds = !IsCashMeds End If .Close End With Set Rec = Nothing End Function Public Function CheckORNumber(strORNumber As String) As Boolean Dim Rec As New ADODB.Recordset Dim SQL As String CheckORNumber = False PublicORAmount = 0 If Left(Trim$(strORNumber), 2) <> "OR" Then strORNumber = "OR" + strORNumber End If If ClientName = "NKTI" Then If Right(Trim$(strORNumber), 1) <> "N" Then strORNumber = strORNumber + "N" End If End If If ClientName = "BIHMI" Or ClientName = "WCI" Then SQL = "Select * from billing..tbCashLumpSum where RefNum = '" & Trim$(strORNumber) & "'" ElseIf ClientName = "PSH" Then SQL = "Select * from Billing..tbCashORMaster where RefNum = '" & Trim$(strORNumber) & "' And RevenueID in ('MU','PM') " & _ "And IDNum = 'CASH'" ElseIf ClientName = "UPHDMC" Then SQL = "Select * from Billing..tbCashORMaster where RefNum = '" & Trim$(strORNumber) & "' And RevenueID = 'CP' " & _ "And IDNum = 'P12'" ElseIf ClientName = "NKTI" Then SQL = "select Refnum, isnull(CheckAmount,0) Amount from billing..tbcashormaster where refnum = '" & Trim$(strORNumber) & "'" Else SQL = "Select * from Billing..tbCashORMaster where RefNum = '" & Trim$(strORNumber) & "' And RevenueID = 'CP' " & _ "And IDNum In ('PHIC', 'PHGS', 'PHOW', 'PHIC-SSS', 'PHIC-GSI', 'PHIC-OWW','" & pstrPHICAccountNum & "')" End If With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then CheckORNumber = True PublicORAmount = Format(!Amount, "########0.00") End If .Close End With Set Rec = Nothing End Function Public Function GetORAmount(strORNumber As String, stridnum As String) As Double Dim Rec As New ADODB.Recordset Dim SQL As String If stridnum = "" Then SQL = "(Select (isnull(sum(Amount),0) - isnull(sum(Tax),0)) + (Select isnull(sum(Payment),0) From MEDICARE..tbmeddoctors where ornumber = '" & _ Trim$(strORNumber) & "' ) [Amount] from Medicare..tbMedPayment where ORNumber = '" & Trim$(strORNumber) & "')" Else If ClientName = "MGH" Then SQL = "(Select (isnull(sum(Amount),0) - isnull(sum(Tax),0)) + (Select isnull(sum(Payment),0) From MEDICARE..tbmeddoctors where ornumber = '" & _ Trim$(strORNumber) & "' and not IDNum = '" & Trim$(stridnum) & "' ) [Amount] from Medicare..tbMedPayment where ORNumber = '" & _ Trim$(strORNumber) & "' and not IDNum = '" & Trim$(stridnum) & "')" Else SQL = "(Select (isnull(sum(Amount),0)) + (Select isnull(sum(Payment),0) From MEDICARE..tbmeddoctors where ornumber = '" & _ Trim$(strORNumber) & "' and not IDNum = '" & Trim$(stridnum) & "' ) [Amount] from Medicare..tbMedPayment where ORNumber = '" & _ Trim$(strORNumber) & "' and not IDNum = '" & Trim$(stridnum) & "')" End If End If GetORAmount = 0 With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then GetORAmount = !Amount End If .Close End With Set Rec = Nothing End Function Public Function GetAdmDiagnosis(stridnum As String) As String Dim Rec As New ADODB.Recordset Dim SQL As String SQL = "Select isnull(AdmDiagnosis,'') Diagnosis from Patient_Data..tbPatientHistory where IDNum = '" & Trim$(stridnum) & "'" With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If Not .EOF Then GetAdmDiagnosis = !Diagnosis End If .Close End With Set Rec = Nothing End Function Public Function GetPatientName(stridnum As String) As String Dim SQL As String SQL = "Select Medicare.dbo.funcGetFullName('" & stridnum & "') as PatientName" With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then GetPatientName = !PatientName End If .Close End With Set Rec = Nothing End Function Public Function CheckisDistribute(stridnum As String) As Boolean Dim Rec As New ADODB.Recordset Dim SQL As String CheckisDistribute = False SQL = "Select top 1 isnull(isDistribute,0) isDistribute from Medicare..Medic_Compensable where isCompensable = 0 and Position in ('2','3') and IDNum = '" & Trim$(stridnum) & "'" With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If Not .EOF Then If !isDistribute = "True" Then CheckisDistribute = True End If End If .Close End With Set Rec = Nothing End Function Public Function isHMO(strAccountNum As String) As Boolean Dim Rec As New ADODB.Recordset Dim SQL As String SQL = "Patient_Data..SP_AOPD_CheckCompanyAccount '" & Trim$(strAccountNum) & "'" isHMO = False With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .CursorType = adOpenDynamic .LockType = adLockReadOnly .Open SQL, user.sqlconnection If .RecordCount > 0 Then isHMO = True End If .Close End With Set Rec = Nothing End Function Public Function CheckIfWithTransDate(stridnum As String) As Boolean Dim Rec As New ADODB.Recordset Dim SQL As String CheckIfWithTransDate = False SQL = "Select Case isnull(TransDate,'') When '' then '0' Else '1' End TransDate from Medicare..tbMedPatient where IDNum = '" & Trim$(stridnum) & "'" With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If Not .EOF Then If !TransDate = "1" Then CheckIfWithTransDate = True End If End If .Close End With Set Rec = Nothing End Function Public Function EmployeeInitial() As String Dim SQL As String Dim Rec As New ADODB.Recordset SQL = "Select isnull(Initial,'') Initial from Password..tbPasswordMaster where EmployeeID = '" & Trim$(user.employeecode) & "'" With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .CursorType = adOpenDynamic .LockType = adLockReadOnly .Open SQL, user.sqlconnection If .RecordCount > 0 Then EmployeeInitial = !Initial & "" End If .Close End With Set Rec = Nothing End Function Public Function GetPatientAdmTime(stridnum As String) As String Dim SQL As String SQL = "Select AdmDate from Patient_Data..tbPatient where IDNum = '" & stridnum & "' " & _ "UNION ALL " & _ "Select AdmDate from Patient_Data..tbOutPatient where IDNum = '" & stridnum & "'" With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then GetPatientAdmTime = Format(!AdmDate, "HH:MM:SS") End If .Close End With Set Rec = Nothing End Function Public Function GetAppliedDate(strAdmDate As String) As String Dim SQL As String SQL = "Select top 1 ApplieDDate From Medicare..tbMedNewRates Where AppliedDate <= '" & Trim$(strAdmDate) & "'" & _ "Group By AppliedDate Order By AppliedDate Desc" With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .CursorType = adOpenDynamic .LockType = adLockReadOnly .Open SQL, user.sqlconnection If .RecordCount > 0 Then GetAppliedDate = Format(!AppliedDate & "", "MM/DD/YYYY") End If .Close End With Set Rec = Nothing End Function Public Function HMOAmount(stridnum As String, strPosition As String) As Double Dim SQL As String SQL = "Medicare..Medic_GetHMOAmount '" & Trim$(stridnum) & "', '" & Trim$(strPosition) & "'" HMOAmount = 0 With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .CursorType = adOpenDynamic .LockType = adLockReadOnly .Open SQL, user.sqlconnection If .RecordCount > 0 Then HMOAmount = !HMO End If .Close End With Set Rec = Nothing End Function Public Function DiscountAmount(stridnum As String, strPosition As String) As Double Dim SQL As String SQL = "Medicare..Medic_GetDiscountAmount '" & Trim$(stridnum) & "', '" & Trim$(strPosition) & "'" DiscountAmount = 0 With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .CursorType = adOpenDynamic .LockType = adLockReadOnly .Open SQL, user.sqlconnection If .RecordCount > 0 Then DiscountAmount = !Discount End If .Close End With Set Rec = Nothing End Function Public Function IsPatientMember(ByVal IdNum As String) As Boolean Dim SQL As String IsPatientMember = False If IsNumeric(Right(IdNum, 1)) Then SQL = "select isnull(Member,0) [Member] from Patient_Data..tbpatient A " & _ " left join Medicare..tbAdmPHICTable B ON A.MedicareType = B.PHICCode " & _ " where A.IdNum = '" & IdNum & "' " Else SQL = "select isnull(Member,0) [Member] from Patient_Data..tboutpatient A " & _ " left join Medicare..tbAdmPHICTable B ON A.MedicareType = B.PHICCode " & _ " where A.IdNum = '" & IdNum & "' " End If With recMember If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then IsPatientMember = ![Member] End If .Close End With Set recMember = Nothing End Function Public Function GetPHICNumber(ByVal IdNum As String) As String Dim SQL As String GetPHICNumber = "" SQL = "select isnull(MemberNumber,'') [MemberNumber] from Medicare..tbMedForm1 where IDNum = '" & IdNum & "' " With recMember If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then GetPHICNumber = ![MemberNumber] End If .Close End With Set recMember = Nothing End Function Public Function HMOPFAmount(stridnum As String, strDocID As String) As Double Dim SQL As String SQL = "Select IsNull(HMO,0) HMO From Billing..tbBillHMOChargesDetailed Where IDNUm = '" & Trim$(stridnum) & _ "' And ItemID = '" & Trim$(strDocID) & "' And RevenueID = 'MD'" HMOPFAmount = 0 With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .CursorType = adOpenDynamic .LockType = adLockReadOnly .Open SQL, user.sqlconnection If .RecordCount > 0 Then HMOPFAmount = !HMO End If .Close End With Set Rec = Nothing End Function Public Function DiscountPFAmount(stridnum As String, strDocID As String) As Double Dim SQL As String SQL = "Select IsNull(Amount,0) Amount From Billing..tbBillDailyBill Where IDNUm = '" & Trim$(stridnum) & _ "' And ItemID = '" & Trim$(strDocID) & "' And RevenueID = 'FD' " & _ "UNION ALL " & _ "Select IsNull(Amount,0) Amount From Billing..tbBillOPDailyOut Where IDNUm = '" & Trim$(stridnum) & _ "' And ItemID = '" & Trim$(strDocID) & "' And RevenueID = 'FD' " DiscountPFAmount = 0 With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .CursorType = adOpenDynamic .LockType = adLockReadOnly .Open SQL, user.sqlconnection If .RecordCount > 0 Then DiscountPFAmount = !Amount End If .Close End With Set Rec = Nothing End Function Public Function PHICClaimGroup(strDocID As String) As String Dim SQL As String PHICClaimGroup = "" SQL = "Select Isnull(PHICClaimGroup,'') PHICClaimGroup From Build_File..tbCoDoctor Where DoctorID = '" & Trim$(strDocID) & "'" With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .CursorType = adOpenDynamic .LockType = adLockReadOnly .Open SQL, user.sqlconnection If .RecordCount > 0 Then PHICClaimGroup = !PHICClaimGroup & "" End If .Close End With Set Rec = Nothing End Function Public Function PHICDoctorRates(strClaimGroup As String, strCaseType As String) As Boolean Dim SQL As String PubMaxDailyPF = 0 PubDailyPF = 0 PubSurgeonPFBelow500 = 0 PubSurgeonPFUp500 = 0 PubAnesPFBelow500 = 0 PubAnesPFUp500 = 0 PHICDoctorRates = False SQL = "Select * From Medicare..tbMedDoctorRates Where GroupCode = '" & Trim$(strClaimGroup) & "' And CaseType = '" & Trim$(strCaseType) & "'" With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .CursorType = adOpenDynamic .LockType = adLockReadOnly .Open SQL, user.sqlconnection If .RecordCount > 0 Then PubMaxDailyPF = !MaxDailyVisit PubDailyPF = !DailyVisit PubSurgeonPFBelow500 = !SurgeonBelow500 PubSurgeonPFUp500 = !SurgeonUp500 PubAnesPFBelow500 = !AnesBelow500 PubAnesPFUp500 = !AnesUp500 PHICDoctorRates = True End If .Close End With Set Rec = Nothing End Function Public Function GetPackageType(stridnum As String) As Long Dim SQL As String SQL = "Select IsNull(PackageID,'1') PackageID From Medicare..tbMedActual Where IDNum = '" & stridnum & "'" With recMember If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then If !PackageID = "" Then GetPackageType = 1 Else GetPackageType = !PackageID End If Else GetPackageType = 1 End If .Close End With Set recMember = Nothing GetPackageType = IIf(GetPackageType = 0, 1, GetPackageType) End Function Public Function GetSecondaryPackageType(stridnum As String) As Long Dim SQL As String SQL = "Select IsNull(PackageIDSecondary,'1') PackageIDSecondary From Medicare..tbMedActual Where IDNum = '" & stridnum & "'" With recMember If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then If !PackageIDSecondary = "" Then GetSecondaryPackageType = 1 Else GetSecondaryPackageType = !PackageIDSecondary End If Else GetSecondaryPackageType = 1 End If .Close End With Set recMember = Nothing GetSecondaryPackageType = IIf(GetSecondaryPackageType = 0, 1, GetSecondaryPackageType) End Function Public Function GetFirstMultiplier(stridnum As String) As Integer Dim SQL As String SQL = "Select IsNull(FirstMultiplier,'1') FirstMultiplier From Medicare..tbMedActual Where IDNum = '" & stridnum & "'" With recMember If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then If !FirstMultiplier = "" Then GetFirstMultiplier = 1 Else GetFirstMultiplier = CInt(!FirstMultiplier) End If Else GetFirstMultiplier = 1 End If .Close End With Set recMember = Nothing GetFirstMultiplier = IIf(GetFirstMultiplier = 0, 1, GetFirstMultiplier) End Function Public Function GetSecondMultiplier(stridnum As String) As Integer Dim SQL As String SQL = "Select IsNull(SecondMultiplier,'1') SecondMultiplier From Medicare..tbMedActual Where IDNum = '" & stridnum & "'" With recMember If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then If !SecondMultiplier = "" Then GetSecondMultiplier = 1 Else GetSecondMultiplier = CInt(!SecondMultiplier) End If Else GetSecondMultiplier = 1 End If .Close End With Set recMember = Nothing GetSecondMultiplier = IIf(GetSecondMultiplier = 0, 1, GetSecondMultiplier) End Function Public Function GetForm2Printed(stridnum As String) As Boolean Dim Rec As New ADODB.Recordset Dim SQL As String GetForm2Printed = False SQL = "Select Isnull(isForm2Printed,0) isForm2Printed From Medicare..tbMedpatient where IDNum = '" & stridnum & "'" With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .CursorType = adOpenDynamic .LockType = adLockReadOnly .Open SQL, user.sqlconnection If .RecordCount > 0 Then GetForm2Printed = !isForm2Printed End If .Close End With Set Rec = Nothing End Function Public Function GetIsBenefits(stridnum As String) As Boolean Dim Rec As New ADODB.Recordset Dim SQL As String GetIsBenefits = False isPackage = "0" SQL = "Select Isnull(PackageID,1) PackageID From Medicare..tbMedActual where IDNum = '" & stridnum & "'" With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .CursorType = adOpenDynamic .LockType = adLockReadOnly .Open SQL, user.sqlconnection If .RecordCount > 0 Then If !PackageID > 1 Then GetIsBenefits = True isPackage = "1" End If End If .Close End With Set Rec = Nothing End Function Public Function GetPackageName(stridnum As String) As String Dim Rec As New ADODB.Recordset Dim SQL As String GetPackageName = "" SQL = "Select Isnull(b.Package,'NONE') Package From Medicare..tbMedActual a " & _ "left outer join medicare..tbmedpackage b on a.packageid = b.packageid where a.IDNum = '" & stridnum & "'" With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .CursorType = adOpenDynamic .LockType = adLockReadOnly .Open SQL, user.sqlconnection If .RecordCount > 0 Then GetPackageName = !Package End If .Close End With Set Rec = Nothing End Function Public Function GetTrackingNumber(stridnum As String) As String Dim Rec As New ADODB.Recordset Dim SQL As String GetTrackingNumber = "" SQL = "Select Isnull(TrackingNumber,'') TrackingNumber From Medicare..tbMedPatient where IDNum = '" & stridnum & "'" With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .CursorType = adOpenDynamic .LockType = adLockReadOnly .Open SQL, user.sqlconnection If .RecordCount > 0 Then GetTrackingNumber = !TrackingNumber & "" End If .Close End With Set Rec = Nothing End Function Public Function CheckCF1Exist(ByVal IdNum As String) As Boolean Dim SQL As String CheckCF1Exist = False SQL = "select isnull(idnum,'') [idnum] from Medicare..tbMedForm1 where IDNum = '" & IdNum & "' " With recMember If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then CheckCF1Exist = True End If .Close End With Set recMember = Nothing End Function Public Function CheckCF4RequireStartDate() As String Dim Rec As New ADODB.Recordset Dim SQL As String SQL = "Select isnull(Value, '') CF4RequireStartDate From Station..tbNurseSetup Where Field = 'CF4RequireStart' and Status = 1" With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .RecordCount > 0 Then pubRequireCF4StartDate = Format(!CF4RequireStartDate, "mm/dd/yyyy") End If .Close End With Set Rec = Nothing End Function Public Function CheckAdmissionDate(stridnum As String) As String Dim recSQL As New ADODB.Recordset Dim strSQL As String If IsNumeric(Right(stridnum, 1)) = True Then strSQL = "Select Admdate From Patient_Data..tbPatient Where IDNum = '" & stridnum & "'" Else strSQL = "Select Admdate From Patient_Data..tboutPatient Where IDNum = '" & stridnum & "'" End If With recSQL If .State > 0 Then .Close .CursorLocation = adUseClient .Open strSQL, user.sqlconnection, adOpenDynamic, adLockReadOnly If .EOF = False Then If Not IsNull(!AdmDate) Then pubAdmDate = Format(!AdmDate, "mm/dd/yyyy") End If End If If .State > 0 Then .Close End With End Function 'AC-01102022 Public Function GetDocValidStart(DocCode As String) As String Dim Rec As New ADODB.Recordset Dim SQL As String SQL = "Select isnull(PHICValidFrom,'') PHICValidFrom from Build_File..tbcoDoctor D where DoctorID = '" & DocCode & "' and PhilHealthNum <> ''" GetDocValidStart = "" With Rec If .State > 0 Then .Close .CursorLocation = adUseClient .Open SQL, user.sqlconnection, adOpenDynamic, adLockReadOnly ' If .RecordCount > 0 Then If .EOF = False Then GetDocValidStart = !PHICValidFrom End If .Close End With Set Rec = Nothing End Function