|
|
Hi guys..
I am new here and i don't see any php section but I think this is more of a database one because i have no errors in my code but for some reason, it is inserting into my memberships table but the users' table is working...
|
|
|
|
|
Very interesting. Now do you have some useful information that would help people to figure out what you are referring to?
|
|
|
|
|
Appreciate the prompt reply. .. i am not on my pc now because it is very late but will post the code tomorrow and thanks for your patience as i am a newbie at php
|
|
|
|
|
 I have been trying to do a multiple select option in my html form, so I will include that file here as well.... Someone else also replied to my question, do I need to post it back to him or her? I think i will post it just in case but here are my html and php code... From my experience, when this type of problem happened, it is usually the problem of my sql variables. Also, I am trying to use implode and did something like $subscriptionplan = implode(',', $subscriptionplan); in order to insert the following into a single column: Level 1, Level 2, Level 3...
Can you also check my signup2.php page and let me know if I did do the if statements correctly as I have been following mmtuts on youtube but shouldn't it be elseif()?
// Code for html
<?php
if(isset($_SESSION['u_uid'])) {
header("Location: index.php?signup=mustsignupfirst");
exit();
} else {
include_once 'index.php';
include_once 'includes/dbh.php';
}
?>
<section class="main-container">
<div class="main-wrapper">
<h2>Signup</h2>
<form class="signup-form" action="includes/signup2.php" method="POST">
<label>Firstname</label>
<br></br>
<input type="text" name="first" placeholder="Firstname">
<label>Lastname</label>
<br></br>
<input type="text" name="last" placeholder="Lastname">
<label>E-Mail</label>
<br></br>
<input type="text" name="email" placeholder="E-mail">
<label>Username</label>
<br></br>
<input type="text" name="uid" placeholder="Username">
<label>Password</label>
<br></br>
<input type="password" name="pwd" placeholder="Password">
<label>Basic Subscription Plan</label>
<br></br>
<select name="freelesson">
<option value="Primer Level">Primer Level: Free</option>
</select>
<br></br>
<label>Premium Subscription Plan 1</label>
<br></br>
<select name="subscriptionplan[]" multiple="multiple">
<option value="">Choose Subscription Plan 1</option>
<option value="None">None</option>
<option value="Level 1">Level 1</option>
<option value="Level 2">Level 2</option>
<option value="Level 3">Level 3</option>
</select>
<br></br>
<button type="submit" name="submit">Sign up</button>
</form>
<?php
$fullUrl = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
if (strpos($fullUrl, "signup=empty") == true) {
echo "<br>";
echo "<p class='error'>You did not fill in all fields!</p>";
}
elseif (strpos($fullUrl, "signup=invalid") == true) {
echo "<br>";
echo "<p class='error'>Your first name and last name have invalid characters!</p>";
}
elseif (strpos($fullUrl, "signup=email") == true) {
echo "<br>";
echo "<p class='error'>You have an invalid email address!</p>";
}
elseif (strpos($fullUrl, "signup=notalphanumeric") == true) {
echo "<br>";
echo "<p class='error'>Password has to contain both letters and numbers!</p>";
}
elseif (strpos($fullUrl, "signup=usertaken") == true) {
echo "<br>";
echo "<p class='error'>Username already taken!</p>";
}
elseif (strpos($fullUrl, "signup=success") == true) {
echo "<br>";
echo "<p class='success'>You have been signed up!</p>";
}
elseif (strpos($fullUrl, "signup=chooseoneplanonly") == true) {
echo "<br>";
echo "<p class='error'>You can't choose more than one of the same plan!</p>";
}
elseif (strpos($fullUrl, "signup.php?signup=cannotchoosealllevel1") == true) {
echo "<br>";
echo "<p class='error'>Cannot choose the same level plan!</p>";
}
elseif (strpos($fullUrl, "signup.php?signup=cannotchoosealllevel2") == true) {
echo "<br>";
echo "<p class='error'>Cannot choose the same level plan!</p>";
}
elseif (strpos($fullUrl, "signup.php?signup=cannotchoosealllevel3") == true) {
echo "<br>";
echo "<p class='error'>Cannot choose the same level plan!</p>";
}
?>
</div>
</section>
<?php
include_once 'footer.php';
?>
// This is my php code for signup2.php:
<?php
if (!isset($_POST['submit'])) {
header("Location: ../signup.php");
exit();
} else {
include_once 'dbh.php';
$first = $_POST['first'];
$last = $_POST['last'];
$email = $_POST['email'] ;
$uid = $_POST['uid'];
$password = $_POST['pwd'];
$user_permission = 'Standard User';
$freelesson = $_POST['freelesson'];
$datejoined = date('Y-m-d H:i:s', strtotime('+1 day'));
$user_activate = 0;
$premium = 0;
$subscriptionplan = $_POST['subscriptionplan'];
$subscriptionplandate = date('Y-m-d H:i:s', strtotime('+1 day'));
$subscriptionplandate2 = date('Y-m-d H:i:s', strtotime('+1 day'));
$subscriptionplandate3 = date('Y-m-d H:i:s', strtotime('+1 day'));
$fees = 0;
$fees2 = 0;
$fees3 = 0;
$totalfees = 0;
$paid = 0;
$paid2 = 0;
$paid3 = 0;
$expirydate = date('Y-m-d H:i:s', strtotime('+1 day'));
$expirydate2 = date('Y-m-d H:i:s', strtotime('+1 day'));
$expirydate3 = date('Y-m-d H:i:s', strtotime('+1 day'));
$paidbydate = date('Y-m-d H:i:s', strtotime('+1 day'));
$paidbydate2 = date('Y-m-d H:i:s', strtotime('+1 day'));
$paidbydate3 = date('Y-m-d H:i:s', strtotime('+1 day'));
$overdue = 0;
$overdue2 = 0;
$overdue3 = 0;
$activate = 0;
if (empty($first) || empty($last) || empty($email) || empty($uid)|| empty($password)) {
header("Location: ../signup.php?signup=empty");
exit();
} else {
if (!preg_match("/^[a-zA-Z]*$/", $first) || !preg_match("/^[a-zA-Z]*$/", $last)) {
header("Location: ../signup.php?signup=invalid");
exit();
} else {
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
header("Location: ../signup.php?signup=email");
exit();
} else {
if (Strlen($password) < 5) {
header("Location: ../signup.php?signup=invalidlength");
exit();
} else {
if (!preg_match('/^(?=.*\d)(?=.*[A-Za-z])[0-9A-Za-z!@#$%]{8,20}$/', $password)) {
header ("Location: ../signup.php?signup=notalphanumeric");
exit();
} else {
if($subscriptionplan == '') {
header("Location: ../signup.php?signup=mustchooseplan");
exti();
}
$sql = "SELECT * FROM users WHERE user_uid = ?;";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql)) {
echo "SQL statement failed";
} else {
mysqli_stmt_bind_param($stmt, "s", $uid);
}
if($resultCheck > 0) {
header("Location: ../signup.php?signup=usertaken");
exit();
} else {
$token = 'qqewreqreqwsdfdfdafcbvcQERFGHFGHGFHRETERTDF!@#$%^^()';
$token = str_shuffle($token);
$token = substr($token, 0, 10);
$token2 = 'qqewreqreqwsdfdfdafcbvcQERFGHFGHGFHRETERTDF!@#$%^^()';
$token2 = str_shuffle($token2);
$token2 = substr($token2, 0, 10);
$paid = 0;
$activate = 0;
$hashedPwd = password_hash($password, PASSWORD_DEFAULT);
$sql ="INSERT INTO users (user_first, user_last, user_email, user_uid, user_password, user_permission, freelesson, datejoined, user_token, user_activate, premium) VALUES (?,?,?,?,?,?,?,?,?,?,?);";
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt, $sql)) {
echo "SQL error";
} else {
mysqli_stmt_bind_param($stmt, "sssssssssss", $first, $last, $email, $uid, $hashedPwd, $user_permission, $freelesson,$datejoined, $token, $user_activate, $premium);
mysqli_stmt_execute($stmt);
}
$sql ="INSERT INTO memberships (user_uid, subscriptionplan, subscriptionplandate, subscriptionplandate2, subscriptionplandate3, fees, fees2, fees3, totalfees, paid, paid2, paid3, expirydate, expirydate2, expirydate3, paidbydate, paidbydate2, paidbydate3, overdue, overdue2, overdue3, token, activate) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt, $sql)) {
echo "SQL error";
} else {
mysqli_stmt_bind_param($stmt, "sssssssssssssssssssssss", $uid, $subscriptionplan, $subscriptionplandate, $subscriptionplandate2, $subscriptionplandate3, $fees, $fees2, $fees3, $totalfees, $paid, $paid2, $paid3, $expirydate, $expirydate2, $expirydate3, $paidbydate, $paidbydate2, $paidbydate3, $overdue, $overdue2, $overdue3, $token2, $activate);
mysqli_stmt_execute($stmt);
}
$company = "pianocourse101@hotmail.com";
$subject = "Activate your email account";
$mailTo = "piano0011@hotmail.com";
$headers = "From: ".$company;
$txt = "Thank you for registering with pianocourse101! At pianocourse101, your child can now learn how to play the piano right from the comfort of your own home! \n\nOur lessons are based from the Bastien Piano Basics series because it is both fun and educational for your child. \n\nHowever, you must activate your FREE membership account by clicking on the link below: \n\n http://localhost/loginsystem/includes/activate.php?email=".$mailTo."&activatetoken=".$token."" ;
mail($mailTo, $subject, $txt, $headers);
header("Location: ../signup.php?signup=success");
exit();
}
}
}
}
}
}
}
|
|
|
|
|
I thought you had a Database question. Please edit that response and explain exactly what the problem is and where it occurs.
|
|
|
|
|
I am not sure if it is a database or php problem but for some reason, it is not inserting information into my memberships table... The users information is correct, so that is why I posted the php code
|
|
|
|
|
|
I am confused here because I thought it was a database question... well, it is a php and database question but there is no php section and I also am not sure how to copy and paste the sniptool because it shows that the information is not inserted into the database table but when using the query from the database, it does work... I have checked my sql query and I have got all the variables correct but am also including a multiple select option, where I have included name="subscription[]". Is this question clearer?
|
|
|
|
|
I have replied but apparently, it is under review, how long does a review take? Should I post it again here?
|
|
|
|
|
It depends, and no.
I deleted the spare, but reposting what didn't work last time doesn't help - reviewing takes as long as it takes for a human volunteer to notice it (and on a Sunday morning that may take a short time) and check it carefully to see if the automated system is right or wrong. Have a little patience, please - you would not believe the amount of spam we get from time to time ...
Just reposting the same stuff will make the automated system more convinced you are a nasty spammy person, not less, and will probably decrease your chances of getting messages through in future.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
|
You're welcome!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
There will be a line of code that contains the words "INSERT INTO" and the name of the table. Find it, paste code here.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hi!
I have sent a reply but it is currently under review but that was to another person. Do I need to reply to your message or will you be able to see it?
|
|
|
|
|
That is strange... I wonder why this is not under review? How long does a review take?
|
|
|
|
|
Hi,
I am getting following error message when trying to restore a Backup of Sql Server 2012 Database on a Sql Server 2008 Server, the error message says following:
This error arises if you attempt to restore a database from a backup created on a later version of SQL Server to an earlier version of SQL Server. You can only restore to the same or a later version of SQL Server.
Any help or suggestion would be greatly helpful, thanks in advance
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
Just install the SQL Server 2008 (Express edition = it is free!) and you'll be able to restore this DB.
PS; check whether it was SQL Server 2008 or SQL Server 2008 R2.
|
|
|
|
|
Read the message again; it is very clear on what is wrong and how to solve it.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
It says but little confused about how is it going to resolve by just installing lower version - lol, thanks for helping for both of you.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
You can't restore a backup from a higher version on a lower version.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hi,
I have a Contolflow Task in my SSIS Package, which sends Emails, and because we don't need it and msdb.dbo.sp_send_dbmail is disabled on our SQL Server, I have first disabled the Controlflow task that sends Email using msdb.dbo.sp_send_dbmail (basically Execute SQL Task).
It was working fine on my local machine, when I deployed the Package on to a Server as SQL Agent Job, Job didn't execute threw error. Then I disabled the Email task on Package deployed it again, but surprisingly, Job is giving the same error as " msdb.dbo.sp_send_dbmail is disabled"
Then I completely deleted the Task and deployed again, still it is giving me the same error, to check when I opened the Package in notepad the task still showing.
Is there any way we can completely get rid of the task from SSIS Package, any help would be very helpful - thanks in advance.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
Hi,
I am executing the following query, its taking too long to execute, can anybody give me any advice what can I do to improve its performance, because its taking hours of time to execute. Thanks in advance.
SELECT
vw_OwnerXML5010.Owner,
vw_OwnerXML5010.Billing_EIN AS TP_EIN,
vw_OwnerXML5010.TP_Name AS TP_NAME,
vw_OwnerXML5010.County_Code AS County_Code,
(
SELECT
(
SELECT
vw_ServiceFacilityXML5010.Service_Facility_NPI AS "Service_Facility_NPI",
vw_ServiceFacilityXML5010.County_Owned_Indicator AS "County_Owned_Indicator",
(
Select
vw_ServicesXML5010.Procedure_Code AS "Procedure_Code",
vw_ServicesXML5010.Modifier1 As "Modifier1",
vw_ServicesXML5010.Modifier2 AS "Modifier2",
vw_ServicesXML5010.Modifier3 AS "Modifier3",
vw_ServicesXML5010.Modifier4 AS "Modifier4",
vw_ServicesXML5010.From_Date AS "From_Date",
vw_ServicesXML5010.To_Date AS "To_Date",
vw_ServicesXML5010.Revenue_Code AS "Revenue_Code",
vw_ServicesXML5010.Place_Of_Service AS "Place_Of_Service",
vw_ServicesXML5010.Taxonomy_Code AS "Taxonomy_Code"
FROM
vw_ServicesXML5010
WHERE
vw_ServiceFacilityXML5010.Service_Facility_NPI = vw_ServicesXML5010.Service_Facility_NPI and
vw_ServiceFacilityXML5010.County_Code = vw_ServicesXML5010.County_Code
and vw_ServiceFacilityXML5010.Billing_EIN = vw_ServicesXML5010.Billing_EIN
FOR XML PATH('Service'), TYPE , ELEMENTS XSINIL
)
FROM
vw_ServiceFacilityXML5010
WHERE
vw_ServiceFacilityXML5010.County_Code = vw_OwnerXML5010.County_Code
and vw_ServiceFacilityXML5010.Billing_EIN = vw_OwnerXML5010.Billing_EIN
FOR XML PATH ('TB_SERVICE_FACILITY'), TYPE
) FOR XML PATH ('TB_BILLING_PROVIDER_FILE'), TYPE
)
FROM
dbo.vw_SDMCPhaseTwoParentLevelXML vw_OwnerXML5010
ORDER BY vw_OwnerXML5010.County_Code
FOR XML PATH ('TB_TRADING_PARTNER'), root('TB_BILLING_PROVIDER_FILES')
Here are the following Views:
CREATE VIEW [dbo].[vw_SDMCPhaseTwoParentLevelXML]
AS
SELECT
DISTINCT 'DMH' AS [Owner]
,'' AS [Billing_NPI]
,SUBSTRING(RTRIM(LE.TaxId), 1, 9) AS [Billing_EIN]
,'' AS DirectIndicator
,CO.PK_Geographic_Location_Code AS [County_Code]
,CO.County_Name AS [TP_Name]
FROM
dbo.LegalEntity LE<br />
INNER JOIN dbo.county CO
ON LE.FKCountyLKPId = CO.PKCountyId
Where LEFT(LegalEntityNbr,3) NOT IN ('HFP', '00F')
AND LEFT(LegalEntityNbr,3) IN ('000')
AND CO.PK_Geographic_Location_Code NOT IN ('99', '00', '65', '66')
GO
CREATE VIEW [dbo].[vw_ServiceFacilityXML5010]
AS
SELECT
distinct VW.Billing_EIN AS [Billing_EIN]
,CO.PK_Geographic_Location_Code AS [County_Code]<br />
,US.NPINumber AS [Service_Facility_NPI]
, 'true' AS [County_Owned_Indicator]
FROM
dbo.Provider C
INNER JOIN dbo.ProviderDate CD
ON CD.FKProviderId = C.PKProviderId
INNER JOIN dbo.ProviderService CS
ON CS.FKProviderDateId = CD.PKProviderDateId and cs.FKProviderId=cd.FKProviderId
INNER JOIN dbo.ProviderService CSD
ON CSD.FKProviderId = CS.FKProviderId
LEFT OUTER JOIN dbo.ProviderService MCS
ON MCS.FKProviderId = CS.FKProviderId
LEFT OUTER JOIN dbo.ProviderService MCSD
ON MCSD.FKProviderId = MCS.FKProviderId
INNER JOIN dbo.ServiceFunctionCategoryLKP SFC
ON SFC.PKServiceFunctionCategoryLKPId = CS.FKServFuncCatMCModeOfServiceId
INNER JOIN dbo.ModeOfServiceLKP MS
ON MS.Code = SFC.ModeOfServiceCode
LEFT OUTER JOIN dbo.ServFuncCatMCModeOfService SFCMMS
ON MS.Code= SFCMMS.MCModeOfServiceCode
LEFT OUTER JOIN dbo.MCModeOfServiceLKP MMS
ON MMS.PKMCModeOfServiceLKPId = SFCMMS.MCModeOfServiceCode
INNER JOIN dbo.NPIAssociation USP
ON USP.FKParentId = C.PKProviderId AND USP.FKParentTypeLKPId=(SELECT Top 1 PKParentTypeLKPId from ParentTypeLKP WHERE ParentCode='PRV')
INNER JOIN dbo.NPI US
ON US.PKNPIId = USP.FKNPIId
INNER JOIN dbo.LegalEntity LE
ON LE.PKLegalEntityId = C.FKLegalEntityId
--INNER JOIN dbo.usrTaxid TX
-- ON LE.FKTaxId = TX.PKTaxId
INNER JOIN dbo.County CO
ON C.FKCountyLKPId = CO.PKCountyId
INNER JOIN VW_SDMCPhaseTwoParentLevelXML VW
ON CO.PK_Geographic_Location_Code = VW.county_code
INNER JOIN dbo.ProviderType FT
ON C.ProviderTypeId = FT.ProviderTypeId
INNER JOIN dbo.MCMSSFCrosswalkLKP SP
ON MMS.Code = SP.MCModeOfServiceCode
Where LEFT(LegalEntityNbr,3) IN ('000', 'AFC')
AND LEFT(LegalEntityNbr,3) NOT IN ('HFP', '00F')<br />
AND MMS.Code IS NOT NULL
AND CO.PK_Geographic_Location_Code NOT IN ('99', '00', '65', '66')
AND SP.ServiceFunctionCategoryCode = SFC.ServiceFunctionCategoryCode
UNION ALL<br />
SELECT
distinct VW.Billing_EIN AS [Billing_EIN]
,CO.PK_Geographic_Location_Code AS [County_Code]<br />
,US.NPINumber AS [Service_Facility_NPI]
FROM
dbo.Provider C
INNER JOIN dbo.ProviderDate CD
ON CD.FKProviderId = C.PKProviderId
INNER JOIN dbo.ProviderService CS
ON CS.FKProviderDateId = CD.PKProviderDateId and cs.FKProviderId=cd.FKProviderId
INNER JOIN dbo.ProviderService CSD
ON CSD.FKProviderId = CS.FKProviderId
LEFT OUTER JOIN dbo.ProviderService MCS
ON MCS.FKProviderId = CS.FKProviderId
LEFT OUTER JOIN dbo.ProviderService MCSD
ON MCSD.FKProviderId = MCS.FKProviderId
INNER JOIN dbo.ServiceFunctionCategoryLKP SFC
ON SFC.PKServiceFunctionCategoryLKPId = CS.FKServFuncCatMCModeOfServiceId
INNER JOIN dbo.ModeOfServiceLKP MS
ON MS.Code = SFC.ModeOfServiceCode
LEFT OUTER JOIN dbo.ServFuncCatMCModeOfService SFCMMS
ON MS.Code= SFCMMS.MCModeOfServiceCode
LEFT OUTER JOIN dbo.MCModeOfServiceLKP MMS
ON MMS.PKMCModeOfServiceLKPId = SFCMMS.MCModeOfServiceCode
INNER JOIN dbo.NPIAssociation USP
ON USP.FKParentId = C.PKProviderId AND USP.FKParentTypeLKPId=(SELECT Top 1 PKParentTypeLKPId from ParentTypeLKP WHERE ParentCode='PRV')
INNER JOIN dbo.NPI US
ON US.PKNPIId = USP.FKNPIId
INNER JOIN dbo.LegalEntity LE
ON LE.PKLegalEntityId = C.FKLegalEntityId
--INNER JOIN dbo.usrTaxid TX
-- ON LE.FKTaxId = TX.PKTaxId
INNER JOIN dbo.County CO
ON C.FKCountyLKPId = CO.PKCountyId
INNER JOIN VW_SDMCPhaseTwoParentLevelXML VW
ON CO.PK_Geographic_Location_Code = VW.county_code
INNER JOIN dbo.ProviderType FT
ON C.ProviderTypeId = FT.ProviderTypeId
INNER JOIN dbo.MCMSSFCrosswalkLKP SP
ON MMS.Code = SP.MCModeOfServiceCode
Where LEFT(LegalEntityNbr,3) NOT IN ('000', 'AFC','HFP', '00F')<br />
AND MMS.Code IS NOT NULL
AND CO.PK_Geographic_Location_Code NOT IN ('99', '00', '65', '66')
AND SP.ServiceFunctionCategoryCode = SFC.ServiceFunctionCategoryCode
GO
CREATE VIEW [dbo].[vw_ServicesXML5010]
AS
SELECT
VW.Billing_EIN AS [Billing_EIN]
,CO.PK_Geographic_Location_Code AS [County_Code]
,US.NPINumber AS [Service_Facility_NPI]
,ISNULL(SP.RevenueCode, '') AS [Revenue_Code]
,SP.ProcedureCode AS [Procedure_Code]
,SP.Modifier1 as Modifier1
,ISNULL(SP.Modifier2, '') AS [Modifier2]
,ISNULL(SP.Modifier3, '') AS [Modifier3]
,ISNULL(SP.Modifier4, '') AS [Modifier4]
,CASE
WHEN SP.MCModeOfServiceCode = '12' AND SP.ServiceFunctionCategoryCode = '20' THEN '23'
WHEN SP.MCModeOfServiceCode = '12' AND SP.ServiceFunctionCategoryCode = '25' THEN '20'
WHEN SP.MCModeOfServiceCode = '18' AND SP.ServiceFunctionCategoryCode = '20' THEN '23'
WHEN SP.MCModeOfServiceCode = '18' AND SP.ServiceFunctionCategoryCode = '25' THEN '20'
ELSE ''
END Place_Of_Service
, '' AS Taxonomy_Code
,ISNULL(CONVERT(VARCHAR(8), CS.MCBeginDate, 112), '') AS [From_Date]
,CONVERT(VARCHAR(8), CS.MCEndDate, 112) AS [To_Date]
FROM
dbo.Provider C
INNER JOIN dbo.ProviderDate CD
ON CD.FKProviderId = C.PKProviderId
INNER JOIN dbo.ProviderService CS
ON CS.FKProviderDateId = CD.PKProviderDateId
INNER JOIN dbo.ServFuncCatMCModeOfService SFC
ON SFC.PKServFuncCatMCModeOfServiceId = CS.FKServFuncCatMCModeOfServiceId
INNER JOIN dbo.ModeOfServiceLKP MS
ON MS.Code = SFC.ModeOfServiceCode
LEFT OUTER JOIN dbo.MCModeOfServiceLKP MMS
ON MMS.Code = SFC.MCModeOfServiceCode
INNER JOIN dbo.NPIAssociation USP
ON USP.FKParentId = C.PKProviderId AND USP.FKParentTypeLKPId IN
(
SELECT PKParentTypeLKPId FROM dbo.ParentTypeLKP a WHERE ParentCode IN ('PRV') --, 'NPI'
)
INNER JOIN dbo.NPI US
ON US.PKNPIId = USP.FKNPIId
INNER JOIN dbo.LegalEntity LE
ON LE.PKLegalEntityId = C.FKLegalEntityId
--INNER JOIN dbo.usrTaxid TX
-- ON LE.FKTaxId = TX.PKTaxId
INNER JOIN dbo.County CO
ON C.FKCountyLKPId = CO.PKCountyId
INNER JOIN VW_SDMCPhaseTwoParentLevelXML VW
ON CO.PK_Geographic_Location_Code = VW.county_code
INNER JOIN dbo.FacilityDesignationLKP FT
ON US.FKFacilityDesignationLKPId = FT.PKFacilityDesignationLKPId
INNER JOIN dbo.MCMSSFCrosswalkLKP SP
ON MMS.Code = SP.MCModeOfServiceCode
Where LEFT(LegalEntityNbr,3) NOT IN ('HFP', '00F')
AND MMS.Code IS NOT NULL
AND CO.PK_Geographic_Location_Code NOT IN ('99', '00', '65', '66')
AND SP.FKServFuncCatMCModeOfServiceId = SFC.PKServFuncCatMCModeOfServiceId
AND SP.Modifier1 <> 'HK'
UNION ALL
SELECT
VW.Billing_EIN AS [Billing_EIN]
,CO.PK_Geographic_Location_Code AS [County_Code]
,US.NPINumber AS [Service_Facility_NPI]
,ISNULL(SP.RevenueCode, '') AS [Revenue_Code]
,SP.ProcedureCode AS [Procedure_Code]
,SP.Modifier1 as Modifier1
,ISNULL(SP.Modifier2, '') AS [Modifier2]
,ISNULL(SP.Modifier3, '') AS [Modifier3]
,ISNULL(SP.Modifier4, '') AS [Modifier4]
,CASE
WHEN SP.MCModeOfServiceCode = '12' AND SP.ServiceFunctionCategoryCode = '20' THEN '23'
WHEN SP.MCModeOfServiceCode = '12' AND SP.ServiceFunctionCategoryCode = '25' THEN '20'
WHEN SP.MCModeOfServiceCode = '18' AND SP.ServiceFunctionCategoryCode = '20' THEN '23'
WHEN SP.MCModeOfServiceCode = '18' AND SP.ServiceFunctionCategoryCode = '25' THEN '20'
ELSE ''
END Place_Of_Service
, '' AS Taxonomy_Code
,CASE
WHEN (SP.ProcedureCode = 'H2015' or SP.ProcedureCode = 'T1017')AND SP.Modifier1 = 'HK' --all Katie A. Services start on 20130101
THEN '20130101'
ELSE
ISNULL(CONVERT(VARCHAR(8), CS.MCBeginDate, 112), '')
END [From_Date]
,CONVERT(VARCHAR(8), CS.MCEndDate, 112) AS [To_Date] -- end date is not changing for Katie A. services. Just eliminate the rows that have an end date
FROM
dbo.Provider C
INNER JOIN dbo.ProviderDate CD
ON CD.FKProviderId = C.PKProviderId
INNER JOIN dbo.ProviderService CS
ON CS.FKProviderDateId = CD.PKProviderDateId
INNER JOIN dbo.ServFuncCatMCModeOfService SFC
ON SFC.PKServFuncCatMCModeOfServiceId = CS.FKServFuncCatMCModeOfServiceId
INNER JOIN dbo.ModeOfServiceLKP MS
ON MS.Code = SFC.ModeOfServiceCode
LEFT OUTER JOIN dbo.MCModeOfServiceLKP MMS
ON MMS.Code = SFC.MCModeOfServiceCode
INNER JOIN dbo.NPIAssociation USP
ON USP.FKParentId = C.PKProviderId AND USP.FKParentTypeLKPId IN
(
SELECT PKParentTypeLKPId FROM dbo.ParentTypeLKP a WHERE ParentCode IN ('PRV') --, 'NPI'
)
INNER JOIN dbo.NPI US
ON US.PKNPIId = USP.FKNPIId
INNER JOIN dbo.LegalEntity LE
ON LE.PKLegalEntityId = C.FKLegalEntityId
--INNER JOIN dbo.usrTaxid TX
-- ON LE.FKTaxId = TX.PKTaxId
INNER JOIN dbo.County CO
ON C.FKCountyLKPId = CO.PKCountyId
INNER JOIN VW_SDMCPhaseTwoParentLevelXML VW
ON CO.PK_Geographic_Location_Code = VW.county_code
INNER JOIN dbo.FacilityDesignationLKP FT
ON US.FKFacilityDesignationLKPId = FT.PKFacilityDesignationLKPId
INNER JOIN dbo.MCMSSFCrosswalkLKP SP
ON MMS.Code = SP.MCModeOfServiceCode
Where LEFT(LegalEntityNbr,3) NOT IN ('HFP', '00F')
AND MMS.Code IS NOT NULL
AND CO.PK_Geographic_Location_Code NOT IN ('99', '00', '65', '66')
AND SP.ServiceFunctionCategoryCode = SFC.ServiceFunctionCategoryCode
AND (SP.Modifier1 = 'HK' and (CS.MCEndDate is null or (CS.MCBeginDate >= '20130101' or CS.MCEndDate > '20130101')))
GO
Any help would be greatly helpful, thanks in advance.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
CHill60 wrote: You might get a better response with some sample data and expected results This is getting old now. When posting SQL queries and asking "what is wrong" or "how does this not work" or ... well, anything, you should include some sample data for all of the tables used in your query.
Nobody wants to use up their spare time (which is how this forum works) traipsing through 200+ lines of code in the off-chance they might spot something that could be improved.
Help us to help you.
|
|
|
|
|
Some of the tables in that Query have 15 Columns too, I don't know how can I put all that Data here on the forum itself, it will be more huge message than currently, I am assuming this current message itself is too big.
What I am asking is, are there any places that I can be suspicious of taking more time than normal. Any help would be very very helpful buddy.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|