USE [LABORATORY] GO /****** Object: StoredProcedure [dbo].[Lab_BF_Save_ExamProperties] Script Date: 11/21/2017 15:23:01 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[Lab_BF_Save_ExamProperties] @ExamID varchar(4), @ExamName varchar(65), @ShortName varchar(45), @SectionID as varchar(3), @RateA as float, @RateB as Float, @RateC as float, @RateD as float, @RateE as float, @ProfFeeA as float, @ProfFeeB as float, @ProfFeeC as float, @ProfFeeD as float, @ProfFeeE as float, @Fixrate as varchar(1), -- Y/N @Status as varchar(1), -- A/I @MedicareType as varchar(1), -- 1/2/3/4/N @Common as varchar(1), -- Y/N @Classification varchar(1), -- C/R/L @Confidential varchar(1), -- Y/N @ISOCode varchar(15), @Stat varchar(1), -- Null/''/Y/N @OpenQuantity as bit, @OpenProfFee as bit, @isProcedure as bit, @AutoMarkup as varchar(1), -- Y/N @Form as varchar(1), @ProfId1 as varchar(10), @LabGrp as varchar(3), @HolidayMarkUp as bit = 0, @WithPF as bit = 0, @SupExamId as varchar(4) = null, @ResultName varchar(65) = null, @WithReagent bit = 0, @Detail bit = 0, @MarkUpPercentage float = 0, @MaxQty integer = 0, @EditNurseRequest varchar(1) = N, @PathoSelection varchar(1) = N, @ResultWholePage varchar(1) = N, @UserId varchar(10) = null, @Method varchar(500) = null AS /*Declare @WithPF bit IF (@PROFFEEA = 0) AND (@PROFFEEB = 0) AND (@PROFFEEC = 0) AND (@PROFFEED = 0) AND (@PROFFEEE = 0) SET @WITHPF = 0 ELSE SET @WITHPF = 1; */ If exists(Select LabExamId From Build_File..tbCoLabExam where LabExamId = @ExamID) Begin Update Build_File..tbCoLabExam Set LabExam = @ExamName, LabSectionID = @SectionID, RateA = @RateA, RateB = @RateB, RateC = @RateC, RateD = @RateD, RateE = @RateE, RateG = @RateE, RateH = @RateE, RateF = @RateE, ProfFeeA = @ProfFeeA, ProfFeeB = @ProfFeeB, ProfFeeC = @ProfFeeC, ProfFeeD = @ProfFeeD, ProfFeeE = @ProfFeeE, Fixrate = @Fixrate, Status = @Status, MedicareType = @MedicareType, Common = @Common, Classification = @Classification, ResultConfidential = @Confidential, ISOFormCode = @ISOCode, Stat = @Stat, OpenQuantity = @OpenQuantity, OpenProfFee = @OpenProfFee, isProcedure = @isProcedure, AutoMarkup = @AutoMarkup, Form = @Form, ProfID1 = @ProfId1, WITHPF = @WITHPF, LabGrp = @LabGrp, HolidayMarkUp = @HolidayMarkUp, SupplementalExam = @SupExamID, BreakdownInDetail = @Detail, MarkUpPercentage = @MarkupPercentage, MaxQty = @MaxQty, PathoSelection = @PathoSelection, EditNurseRequest = @EditNurseRequest, Method = @Method Where LabExamId = @ExamID; if exists (SELECT * FROM Build_File..tbCoLabValues WHERE CODE = @ExamId) BEGIN Update Build_File..tbCoLabValues Set ChargingName = @ExamName, ShortName = @ShortName, LabSectionId = @SectionId, ResultName = @ResultName, WithReagent = @WithReagent Where Code = @ExamId; END; ELSE BEGIN Insert Into Build_file..tbCoLabValues(Code, ChargingName, ShortName, LabSectionId, ResultName, WithReagent) Values(@ExamId, @ExamName, @ShortName, @SectionId, @ResultName, @WithReagent); END; End Else Begin Insert Into Build_File..tbCoLabExam(LabExamID, LabExam, LabSectionId, RateA, RateB, RateC, RateD, RateE, RateG, RateH, RateF, ProfFeeA, ProfFeeB, ProfFeeC, ProfFeeD, ProfFeeE, Fixrate, Status, MedicareType, Common, Classification, ResultConfidential, ISOFormCode, Stat, OpenQuantity, OpenProfFee, isProcedure, AutoMarkup, Form, ProfId1, WITHPF, LabGrp, HolidayMarkUp, SupplementalExam, MarkupPercentage, MaxQty, PathoSelection, EditNurseRequest,Method) Values(@ExamId, @ExamName, @SectionID, @RateA, @RateB, @RateC, @RateD, @RateE, @RateE, @RateE, @RateE, @ProfFeeA, @ProfFeeB, @ProfFeeC, @ProfFeeD, @ProfFeeE, @Fixrate, @Status, @MedicareType, @Common, @Classification, @Confidential, @ISOCode, @Stat, @OpenQuantity, @OpenProfFee, @isProcedure, @AutoMarkup, @Form, @ProfId1, @WITHPF, @LabGrp, @HolidayMarkUp, @SupExamID, @MarkupPercentage, @MaxQty, @PathoSelection, @EditNurseRequest,@Method); Insert Into Build_file..tbCoLabValues(Code, ChargingName, ShortName, LabSectionId, ResultName, WithReagent) Values(@ExamId, @ExamName, @ShortName, @SectionId, @ResultName, @WithReagent); End; If IsNull(@Form, '') in ('P', 'K', 'C') Begin If exists (Select top 1 ExamID from BUILD_FILE..tbCoLabProfile where ExamID = @ExamID) Begin Update BUILD_FILE..tbCoLabProfile Set Exam = @ExamName, Active = case when ISNull(@Status, '') = 'A' Then 1 Else 0 End, UserId = @UserID Where ExamID = @ExamId; End; Else Begin INSERT into BUILD_FILE..tbCoLabProfile (ExamId, Exam, Active, UserID) Values(@ExamId, @ExamName, case when ISNull(@Status, '') = 'A' Then 1 Else 0 End, @UserID ); End; End;