-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdatabase.sql
4768 lines (4339 loc) · 124 KB
/
database.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
DSA Lims - Laboratory Information Management System
Copyright (C) 2018 Norwegian Radiation Protection Authority
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Authors: Dag Robole,
*/
create database dsa_lims
go
use dsa_lims
go
/*===========================================================================*/
/* tbl instance_status */
if OBJECT_ID('dbo.instance_status', 'U') is not null drop table instance_status;
create table instance_status (
id int primary key not null,
name nvarchar(20) not null
)
go
insert into instance_status values(1, 'Active')
insert into instance_status values(2, 'Inactive')
insert into instance_status values(3, 'Deleted')
go
create proc csp_select_instance_status
as
select *
from instance_status
order by id
go
/*===========================================================================*/
/* tbl workflow_status */
if OBJECT_ID('dbo.workflow_status', 'U') is not null drop table workflow_status;
create table workflow_status (
id int primary key not null,
name nvarchar(20) not null
)
go
insert into workflow_status values(1, 'Construction')
insert into workflow_status values(2, 'Complete')
insert into workflow_status values(3, 'Rejected')
go
create proc csp_select_workflow_status
as
select *
from workflow_status
order by id
go
/*===========================================================================*/
/* tbl sigma_values */
if OBJECT_ID('dbo.sigma_values', 'U') is not null drop table sigma_values;
create table sigma_values (
value float not null,
name nvarchar(20) not null
)
go
insert into sigma_values values(1.0, '1 (68.3%)')
insert into sigma_values values(1.96, '1.96 (95%)')
insert into sigma_values values(2.0, '2 (95.5%)')
insert into sigma_values values(3.0, '3 (99.9%)')
go
create proc csp_select_sigma_values
as
select *
from sigma_values
order by value
go
/*===========================================================================*/
/* tbl sigma_mda_values */
if OBJECT_ID('dbo.sigma_mda_values', 'U') is not null drop table sigma_mda_values;
create table sigma_mda_values (
value float not null,
name nvarchar(20) not null
)
go
insert into sigma_mda_values values(1.0, '1 (84.1%)')
insert into sigma_mda_values values(1.645, '1.645 (95%)')
insert into sigma_mda_values values(2.0, '2 (97.2%)')
insert into sigma_mda_values values(3.0, '3 (99.95%)')
go
create proc csp_select_sigma_mda_values
as
select *
from sigma_mda_values
order by value
go
/*===========================================================================*/
/* tbl audit_log */
if OBJECT_ID('dbo.audit_log', 'U') is not null drop table audit_log;
create table audit_log (
id uniqueidentifier primary key not null,
source_table nvarchar(50) not null,
source_id uniqueidentifier not null,
operation nvarchar(50) not null,
comment nvarchar(200) default null,
value nvarchar(max) not null,
create_date datetime not null
)
go
create proc csp_insert_audit_message
@id uniqueidentifier,
@source_table nvarchar(50),
@source_id uniqueidentifier,
@operation nvarchar(50),
@comment nvarchar(200),
@value nvarchar(max),
@create_date datetime
as
insert into audit_log values(@id, @source_table, @source_id, @operation, @comment, @value, @create_date);
go
/*===========================================================================*/
/* tbl counters */
if OBJECT_ID('dbo.counters', 'U') is not null drop table counters;
create table counters (
name nvarchar(50) primary key not null,
value int default 1
)
go
insert into counters (name) values('database_version')
insert into counters (name) values('sample_counter')
go
/*===========================================================================*/
/* tbl person */
if OBJECT_ID('dbo.person', 'U') is not null drop table person;
create table person (
id uniqueidentifier primary key not null,
name nvarchar(128) not null,
email nvarchar(80) default null,
phone nvarchar(80) default null,
address nvarchar(1000) default null,
create_date datetime not null,
update_date datetime not null
)
go
create proc csp_insert_person
@id uniqueidentifier,
@name nvarchar(128),
@email nvarchar(80),
@phone nvarchar(80),
@address nvarchar(1000),
@create_date datetime,
@update_date datetime
as
insert into person values (
@id,
@name,
@email,
@phone,
@address,
@create_date,
@update_date
);
go
create proc csp_update_person
@id uniqueidentifier,
@name nvarchar(128),
@email nvarchar(80),
@phone nvarchar(80),
@address nvarchar(1000),
@update_date datetime
as
update person set
name = @name,
email = @email,
phone = @phone,
address = @address,
update_date = @update_date
where id = @id
go
create proc csp_select_person
@id uniqueidentifier
as
select *
from person
where id = @id
go
create proc csp_select_persons
as
select *
from person where email is not NULL
order by name
go
create proc csp_select_persons_short
as
select
id,
name + ' (' + email + ')' as 'name'
from person where email is not NULL
order by name
go
/*===========================================================================*/
/* tbl role */
if OBJECT_ID('dbo.role', 'U') is not null drop table role;
create table role (
id uniqueidentifier primary key not null,
name nvarchar(80) not null
)
go
insert into role values(NEWID(), 'Laboratory Administrator')
insert into role values(NEWID(), 'Laboratory Operator')
insert into role values(NEWID(), 'Order Administrator')
insert into role values(NEWID(), 'Order Operator')
insert into role values(NEWID(), 'Sample Registrator')
insert into role values(NEWID(), 'Spectator')
go
/*===========================================================================*/
/* tbl account_x_role */
if OBJECT_ID('dbo.account_x_role', 'U') is not null drop table account_x_role;
create table account_x_role (
account_id uniqueidentifier not null,
role_id uniqueidentifier not null
)
go
/*===========================================================================*/
/* tbl account */
if OBJECT_ID('dbo.account', 'U') is not null drop table account;
create table account (
id uniqueidentifier primary key not null,
username nvarchar(50) unique not null,
person_id uniqueidentifier not null,
laboratory_id uniqueidentifier default null,
language_code nvarchar(8) default 'en',
instance_status_id int not null default 1,
password_hash binary(32) not null,
create_date datetime not null,
update_date datetime not null
)
go
create proc csp_insert_account
@id uniqueidentifier,
@username nvarchar(50),
@person_id uniqueidentifier,
@laboratory_id uniqueidentifier,
@language_code nvarchar(8),
@instance_status_id int,
@password_hash binary(32),
@create_date datetime,
@update_date datetime
as
insert into account values (
@id,
@username,
@person_id,
@laboratory_id,
@language_code,
@instance_status_id,
@password_hash,
@create_date,
@update_date
);
go
create proc csp_update_account
@id uniqueidentifier,
@laboratory_id uniqueidentifier,
@language_code nvarchar(8),
@instance_status_id int,
@update_date datetime
as
update account set
laboratory_id = @laboratory_id,
language_code = @language_code,
instance_status_id = @instance_status_id,
update_date = @update_date
where id = @id
go
create view cv_account
as
select
a.id,
a.person_id,
p.name,
p.email,
p.phone,
p.address,
a.username,
a.laboratory_id,
a.language_code,
a.instance_status_id,
a.password_hash,
a.create_date,
a.update_date
from account a
inner join person p on a.person_id = p.id
go
create proc csp_select_account
@id uniqueidentifier
as
select *
from cv_account
where id = @id
go
create proc csp_select_accounts
@instance_status_level int
as
select *
from cv_account
where instance_status_id <= @instance_status_level and email is not NULL
order by name
go
create proc csp_select_accounts_short
@instance_status_level int
as
select
id,
name + ' (' + email + ')' as name
from cv_account
where instance_status_id <= @instance_status_level and email is not NULL
order by name
go
create proc csp_select_accounts_flat
@instance_status_level int
as
select
av.id,
av.name,
av.email,
av.phone,
av.address,
av.username,
l.name as 'laboratory_name',
av.language_code,
st.name as 'instance_status_name',
av.create_date,
av.update_date
from cv_account av
left outer join laboratory l on av.laboratory_id = l.id
inner join instance_status st on av.instance_status_id = st.id
where av.instance_status_id <= @instance_status_level and av.email is not NULL
order by av.name
go
create proc csp_select_accounts_for_laboratory
@laboratory_id uniqueidentifier,
@instance_status_level int
as
select *
from cv_account
where laboratory_id = @laboratory_id and instance_status_id <= @instance_status_level and email is not NULL
order by name
go
create proc csp_select_accounts_for_laboratory_short
@laboratory_id uniqueidentifier,
@instance_status_level int
as
select
id,
name + ' (' + email + ')' as name
from cv_account
where laboratory_id = @laboratory_id and instance_status_id <= @instance_status_level and email is not NULL
order by instance_status_id, name
go
/*===========================================================================*/
/* tbl company */
if OBJECT_ID('dbo.company', 'U') is not null drop table company;
create table company (
id uniqueidentifier primary key not null,
name nvarchar(128) not null,
email nvarchar(80) default null,
phone nvarchar(80) default null,
address nvarchar(1000) default null,
instance_status_id int not null default 1,
comment nvarchar(1000) default null,
create_date datetime not null,
create_id uniqueidentifier not null,
update_date datetime not null,
update_id uniqueidentifier not null
)
go
create proc csp_insert_company
@id uniqueidentifier,
@name nvarchar(128),
@email nvarchar(80),
@phone nvarchar(80),
@address nvarchar(1000),
@instance_status_id int,
@comment nvarchar(1000),
@create_date datetime,
@create_id uniqueidentifier,
@update_date datetime,
@update_id uniqueidentifier
as
insert into company values (
@id,
@name,
@email,
@phone,
@address,
@instance_status_id,
@comment,
@create_date,
@create_id,
@update_date,
@update_id
);
go
create proc csp_update_company
@id uniqueidentifier,
@name nvarchar(128),
@email nvarchar(80),
@phone nvarchar(80),
@address nvarchar(1000),
@instance_status_id int,
@comment nvarchar(1000),
@update_date datetime,
@update_id uniqueidentifier
as
update company set
name = @name,
email = @email,
phone = @phone,
address = @address,
instance_status_id = @instance_status_id,
comment = @comment,
update_date = @update_date,
update_id = @update_id
where id = @id
go
create proc csp_select_company
@id uniqueidentifier
as
select *
from company
where id = @id
go
create proc csp_select_companies
@instance_status_level int
as
select *
from company
where instance_status_id <= @instance_status_level
order by name
go
create proc csp_select_companies_short
@instance_status_level int
as
select
id,
name
from company
where instance_status_id <= @instance_status_level
order by name
go
create proc csp_select_companies_flat
@instance_status_level int
as
select
c.id,
c.name,
c.email,
c.phone,
c.address,
st.name as 'instance_status_name',
c.comment,
c.create_date,
c.create_id,
c.update_date,
c.update_id
from company c
inner join instance_status st on c.instance_status_id = st.id
and c.instance_status_id <= @instance_status_level
order by c.name
go
/*===========================================================================*/
/* tbl customer */
if OBJECT_ID('dbo.customer', 'U') is not null drop table customer;
create table customer (
id uniqueidentifier primary key not null,
person_id uniqueidentifier not null,
company_id uniqueidentifier default null,
instance_status_id int not null default 1,
comment nvarchar(1000) default null,
create_date datetime not null,
create_id uniqueidentifier not null,
update_date datetime not null,
update_id uniqueidentifier not null
)
go
create proc csp_insert_customer
@id uniqueidentifier,
@person_id uniqueidentifier,
@company_id uniqueidentifier,
@instance_status_id int,
@comment nvarchar(1000),
@create_date datetime,
@create_id uniqueidentifier,
@update_date datetime,
@update_id uniqueidentifier
as
insert into customer values (
@id,
@person_id,
@company_id,
@instance_status_id,
@comment,
@create_date,
@create_id,
@update_date,
@update_id
);
go
create proc csp_update_customer
@id uniqueidentifier,
@company_id uniqueidentifier,
@instance_status_id int,
@comment nvarchar(1000),
@update_date datetime,
@update_id uniqueidentifier
as
update customer set
company_id = @company_id,
instance_status_id = @instance_status_id,
comment = @comment,
update_date = @update_date,
update_id = @update_id
where id = @id
go
create view cv_customer
as
select
c.id,
c.person_id,
c.company_id,
p.name as 'person_name',
p.email as 'person_email',
p.phone as 'person_phone',
p.address as 'person_address',
co.name as 'company_name',
co.email as 'company_email',
co.phone as 'company_phone',
co.address as 'company_address',
c.instance_status_id,
c.comment,
c.create_date,
c.create_id,
c.update_date,
c.update_id
from customer c
inner join person p on c.person_id = p.id
left outer join company co on c.company_id = co.id
go
create proc csp_select_customer
@id uniqueidentifier
as
select *
from cv_customer
where id = @id
go
create proc csp_select_customers
@instance_status_level int
as
select *
from cv_customer
where instance_status_id <= @instance_status_level
order by person_name
go
create proc csp_select_customers_short
@instance_status_level int
as
select
id,
person_name + ' (' + person_email + ')' as 'name'
from cv_customer
where instance_status_id <= @instance_status_level
order by person_name
go
create proc csp_select_customers_flat
@instance_status_level int
as
select
cv.id,
cv.person_name,
cv.person_email,
cv.person_phone,
cv.person_address,
cv.company_name,
cv.company_email,
cv.company_phone,
cv.company_address,
st.name as 'instance_status_name'
from cv_customer cv
inner join instance_status st on cv.instance_status_id = st.id
and cv.instance_status_id <= @instance_status_level
order by cv.person_name
go
/*===========================================================================*/
/* tbl sampler */
if OBJECT_ID('dbo.sampler', 'U') is not null drop table sampler;
create table sampler (
id uniqueidentifier primary key not null,
person_id uniqueidentifier not null,
company_id uniqueidentifier default null,
instance_status_id int not null default 1,
comment nvarchar(1000) default null,
create_date datetime not null,
create_id uniqueidentifier not null,
update_date datetime not null,
update_id uniqueidentifier not null
)
go
create proc csp_insert_sampler
@id uniqueidentifier,
@person_id uniqueidentifier,
@company_id uniqueidentifier,
@instance_status_id int,
@comment nvarchar(1000),
@create_date datetime,
@create_id uniqueidentifier,
@update_date datetime,
@update_id uniqueidentifier
as
insert into sampler values (
@id,
@person_id,
@company_id,
@instance_status_id,
@comment,
@create_date,
@create_id,
@update_date,
@update_id
);
go
create proc csp_update_sampler
@id uniqueidentifier,
@company_id uniqueidentifier,
@instance_status_id int,
@comment nvarchar(1000),
@update_date datetime,
@update_id uniqueidentifier
as
update sampler set
company_id = @company_id,
instance_status_id = @instance_status_id,
comment = @comment,
update_date = @update_date,
update_id = @update_id
where id = @id
go
create view cv_sampler
as
select
s.id,
s.person_id,
s.company_id,
p.name as 'person_name',
p.email as 'person_email',
p.phone as 'person_phone',
p.address as 'person_address',
co.name as 'company_name',
co.email as 'company_email',
co.phone as 'company_phone',
co.address as 'company_address',
s.instance_status_id,
s.comment,
s.create_date,
s.create_id,
s.update_date,
s.update_id
from sampler s
inner join person p on s.person_id = p.id
left outer join company co on s.company_id = co.id
go
create proc csp_select_sampler
@id uniqueidentifier
as
select *
from cv_sampler
where id = @id
go
create proc csp_select_samplers
@instance_status_level int
as
select *
from cv_sampler
where instance_status_id <= @instance_status_level
order by person_name
go
create proc csp_select_samplers_short
@instance_status_level int
as
select
id,
person_name + ' (' + person_email + ')' as 'name'
from cv_sampler
where instance_status_id <= @instance_status_level
order by instance_status_id, person_name
go
create proc csp_select_samplers_flat
@instance_status_level int
as
select
sv.id,
sv.person_name,
sv.person_email,
sv.person_phone,
sv.person_address,
sv.company_name,
sv.company_email,
sv.company_phone,
sv.company_address,
st.name as 'instance_status_name'
from cv_sampler sv
inner join instance_status st on sv.instance_status_id = st.id
and sv.instance_status_id <= @instance_status_level
order by sv.person_name
go
/*===========================================================================*/
/* tbl sampling_method */
if OBJECT_ID('dbo.sampling_method', 'U') is not null drop table sampling_method;
create table sampling_method (
id uniqueidentifier primary key not null,
name nvarchar(256) not null,
instance_status_id int not null default 1,
comment nvarchar(1000) default null,
create_date datetime not null,
create_id uniqueidentifier not null,
update_date datetime not null,
update_id uniqueidentifier not null
)
go
create proc csp_insert_sampling_method
@id uniqueidentifier,
@name nvarchar(256),
@instance_status_id int,
@comment nvarchar(1000),
@create_date datetime,
@create_id uniqueidentifier,
@update_date datetime,
@update_id uniqueidentifier
as
insert into sampling_method values (
@id,
@name,
@instance_status_id,
@comment,
@create_date,
@create_id,
@update_date,
@update_id
);
go
create proc csp_update_sampling_method
@id uniqueidentifier,
@name nvarchar(256),
@instance_status_id int,
@comment nvarchar(1000),
@update_date datetime,
@update_id uniqueidentifier
as
update sampling_method set
name = @name,
instance_status_id = @instance_status_id,
comment = @comment,
update_date = @update_date,
update_id = @update_id
where id = @id
go
create proc csp_select_sampling_methods
@instance_status_level int
as
select *
from sampling_method
where instance_status_id <= @instance_status_level
order by name
go
create proc csp_select_sampling_methods_short
@instance_status_level int
as
select
id,
name
from sampling_method
where instance_status_id <= @instance_status_level
order by instance_status_id, name
go
create proc csp_select_sampling_methods_flat
@instance_status_level int
as
select
s.id,
s.name,
st.name as 'instance_status_name',
s.comment,
s.create_date,
s.create_id,
s.update_date,
s.update_id
from sampling_method s, instance_status st
where s.instance_status_id = st.id and s.instance_status_id <= @instance_status_level
order by s.name
go
create proc csp_select_sampling_method
@id uniqueidentifier
as
select * from sampling_method where id = @id
go
/*===========================================================================*/
/* tbl laboratory */
if OBJECT_ID('dbo.laboratory', 'U') is not null drop table laboratory;
create table laboratory (
id uniqueidentifier primary key not null,
name nvarchar(256) unique not null,
name_prefix nvarchar(8) unique not null,
address nvarchar(256) default null,
email nvarchar(80) default null,
phone nvarchar(80) default null,
last_assignment_counter_year int default 2000,
assignment_counter int default 1,
instance_status_id int not null default 1,
comment nvarchar(1000) default null,
laboratory_logo varbinary(max) default null,
accredited_logo varbinary(max) default null,
create_date datetime not null,
create_id uniqueidentifier not null,
update_date datetime not null,
update_id uniqueidentifier not null
)
go
create proc csp_insert_laboratory
@id uniqueidentifier,
@name nvarchar(256),
@name_prefix nvarchar(8),
@address nvarchar(256),
@email nvarchar(80),
@phone nvarchar(80),
@last_assignment_counter_year int,
@assignment_counter int,
@instance_status_id int,
@comment nvarchar(1000),
@laboratory_logo varbinary(max),
@accredited_logo varbinary(max),
@create_date datetime,
@create_id uniqueidentifier,
@update_date datetime,
@update_id uniqueidentifier
as
insert into laboratory values (
@id,
@name,
@name_prefix,
@address,
@email,
@phone,
@last_assignment_counter_year,
@assignment_counter,
@instance_status_id,
@comment,
@laboratory_logo,
@accredited_logo,
@create_date,
@create_id,
@update_date,
@update_id
);
go
create proc csp_update_laboratory
@id uniqueidentifier,
@name nvarchar(256),
@name_prefix nvarchar(8),
@address nvarchar(256),
@email nvarchar(80),
@phone nvarchar(80),
@instance_status_id int,
@comment nvarchar(1000),
@laboratory_logo varbinary(max),
@accredited_logo varbinary(max),
@update_date datetime,
@update_id uniqueidentifier
as
update laboratory set
id = @id,
name = @name,
name_prefix = @name_prefix,
address = @address,
email = @email,
phone = @phone,
instance_status_id = @instance_status_id,
comment = @comment,
laboratory_logo = @laboratory_logo,
accredited_logo = @accredited_logo,
update_date = @update_date,
update_id = @update_id
where id = @id
go
create proc csp_increment_assignment_counter
@laboratory_id uniqueidentifier,
@current_count int output
as