Se codifican lotes con determinaciones para derivar, primer etapa. #6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Requerimiento
HISTORIA DE USUARIO: COMO USUARIO DE LABORATORIO REQUIERO GENERAR LOTES PARA REALIZAR LAS DERIVACIONES
Funcionalidad desarrollada
UserStories llegó a completarse
Requiere actualizaciones en la base de datos
Si
No
use SilNeuquen
alter table LAB_Derivacion add idLote int
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LAB_DerivacionEstado](
[idEstado] [int] IDENTITY(0,1) NOT NULL,
[descripcion] varchar NOT NULL,
[baja] [bit] NOT NULL,
CONSTRAINT [PK_LAB_DerivacionEstado] PRIMARY KEY CLUSTERED
(
[idEstado] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[LAB_DerivacionEstado] ADD CONSTRAINT [DF_LAB_DerivacionEstado_baja] DEFAULT ((0)) FOR [baja]
GO
INSERT INTO LAB_DerivacionEstado (descripcion) VALUES('Pendiente de derivar')
INSERT INTO LAB_DerivacionEstado (descripcion) VALUES('Enviado')
INSERT INTO LAB_DerivacionEstado (descripcion) VALUES('No Enviado')
INSERT INTO LAB_DerivacionEstado (descripcion) VALUES('Pendiente para enviar')
use SilNeuquen
CREATE TABLE [dbo].[LAB_LoteDerivacion](
[idLoteDerivacion] [int] IDENTITY(1,1) NOT NULL,
[idEfectorOrigen] [int] NOT NULL,
[idEfectorDestino] [int] NOT NULL,
[estado] [int] NOT NULL,
[fechaRegistro] [datetime] NOT NULL,
[fechaEnvio] [datetime] NOT NULL,
[fechaIngreso] [datetime] NOT NULL,
[baja] [bit] NOT NULL,
[idUsuarioRegistro] [int] NULL,
[idUsuarioEnvio] [int] NULL,
[idUsuarioRecepcion] [int] NULL,
[observacion] varchar NULL,
CONSTRAINT [PK_LAB_Lote] PRIMARY KEY CLUSTERED
(
[idLoteDerivacion] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
USE [SilNeuquen]
GO
/****** Object: StoredProcedure [dbo].[LAB_LoteDerivacion_Envio] Script Date: 17/12/2024 12:12:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: Vanesa Rimada
-- Create date: 13/12/2024
-- Description: Actualiza el lote de derivacion y las derivaciones asociadas
-- =============================================
ALTER PROCEDURE [dbo].[LAB_LoteDerivacion_Envio]
@idLote as int,
@idUsuario as int,
@Resultado as varchar(max),
@estado as int,
@Observacion as varchar(max)
AS
BEGIN TRY
SET NOCOUNT ON;
ALTER VIEW vta_LAB_Derivaciones
AS
SELECT DISTINCT
TOP (100) PERCENT P.edad, P.unidadEdad, P.sexo, P.numero, P.fecha, P.idEspecialistaSolicitante AS especialista, CASE WHEN Pac.idPaciente = - 1 THEN 0 ELSE CASE WHEN Pac.idestado = 2 THEN '' ELSE CONVERT(varchar,
Pac.numeroDocumento) END END AS dni, CASE WHEN Pac.idPaciente = - 1 THEN P.descripcionProducto ELSE Pac.apellido END AS apellido, Pac.nombre, P.idProtocolo, I.descripcion AS determinacion,
dbo.Sys_Efector.nombre AS efectorDerivacion, P.idOrigen, P.idPrioridad, P.idEfector, P.idTipoServicio, I.idArea, I.idItem, DP.idDetalleProtocolo, CASE WHEN D .estado IS NULL THEN 0 ELSE d .estado END AS estado,
U.apellido + ' ' + SUBSTRING(U.nombre, 0, 5) AS username, D.observacion, D.resultado, D.idUsuarioResultado, D.fechaResultado, D.estado AS estadoDerivacion, P.Especialista AS solicitante, CONVERT(varchar(10),
Pac.fechaNacimiento, 103) AS fechaNacimiento, D.idEfectorDerivacion, D.idLote
FROM dbo.LAB_Protocolo AS P INNER JOIN
dbo.LAB_DetalleProtocolo AS DP ON P.idProtocolo = DP.idProtocolo INNER JOIN
dbo.LAB_Derivacion AS D ON D.idDetalleProtocolo = DP.idDetalleProtocolo INNER JOIN
dbo.Sys_Usuario AS U ON U.idUsuario = D.idUsuarioRegistro INNER JOIN
dbo.Sys_Paciente AS Pac ON P.idPaciente = Pac.idPaciente INNER JOIN
dbo.LAB_Item AS I ON DP.idItem = I.idItem INNER JOIN
dbo.Sys_Efector ON D.idEfectorDerivacion = dbo.Sys_Efector.idEfector
WHERE (P.baja = 0)
GROUP BY P.observacion, Pac.idEstado, Pac.numeroAdic, P.edad, P.sexo, P.idProtocolo, P.fecha, P.idEspecialistaSolicitante, Pac.numeroDocumento, Pac.apellido, Pac.nombre, P.idProtocolo, I.descripcion, dbo.Sys_Efector.nombre,
P.numero, P.numeroDiario, P.idOrigen, P.idPrioridad, D.idEfectorDerivacion, P.idTipoServicio, I.idArea, I.idItem, DP.idDetalleProtocolo, U.apellido, U.nombre, D.observacion, D.estado, P.unidadEdad, D.resultado,
D.idUsuarioResultado, D.fechaResultado, P.Especialista, Pac.fechaNacimiento, P.idEfector, Pac.idPaciente, P.descripcionProducto, P.numeroOrigen, D.idLote
INSERT INTO [dbo].[Sys_Menu]
([objeto],[idMenuSuperior],[posicion],[icono],[habilitado],[url],[fechaCreacion],[idUsuarioCreacion],[fechaModificacion],[idUsuarioModificacion]
,[idModulo],[esAccion])
VALUES
('Gestionar Lotes',190,4,'' ,1,'/Derivaciones/GestionarLote.aspx','',238,'',238,2,0)
GO
declare @id as int
set @id = ( Select IDENT_CURRENT('Sys_Menu') )
INSERT INTO [dbo].[Sys_Permiso]([idEfector],[idPerfil] ,[idMenu] ,[permiso])
VALUES (41,2 --Administrador
,@id ,2)
GO