Skip to content

Commit d17134c

Browse files
committed
OPSMN-7001: Added a PV driven reason field to the specimen dispose event.
Users have to select reason for why they are disposing the specimen. The app is shipped with the following 5 reason values: 1) Processed 2) Distributed 3) Not Specified 4) Damaged 5) Destroyed The first 3 values should not be touched, renamed or removed. They are used by system workflows / API whenever a specimen is closed after creation of children specimens, distributed or no reason is available. However, if desired, OpenSpecimen admins can add more reason values like 1) Stolen 2) Lost / Misplaced 3) Inaccessible 4) Spilled
1 parent a32f99e commit d17134c

File tree

17 files changed

+213
-41
lines changed

17 files changed

+213
-41
lines changed

WEB-INF/resources/com/krishagni/catissueplus/core/biospecimen/schema/specimen-disposal.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@
3737
<attribute>reason</attribute>
3838
</field>
3939

40+
<field>
41+
<caption>#getMessage("specimen_event_comments")</caption>
42+
<attribute>comments</attribute>
43+
</field>
44+
4045
<record>
4146
<caption>#getMessage("specimen_event_user")</caption>
4247
<attribute>user</attribute>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<databaseChangeLog
3+
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
6+
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
7+
8+
<changeSet author="vpawar" id="Specimen disposal event - Move existing reasons to the description" dbms="mysql">
9+
<sql>
10+
update
11+
catissue_disposal_event_param
12+
set
13+
comments = concat(ifnull(reason, ''), '\n', ifnull(comments, ''))
14+
</sql>
15+
</changeSet>
16+
17+
<changeSet author="vpawar" id="Specimen disposal event - Move the reason to the description" dbms="oracle">
18+
<sql>
19+
update
20+
catissue_disposal_event_param
21+
set
22+
comments = concat(reason, concat('\n', comments))
23+
</sql>
24+
</changeSet>
25+
26+
<changeSet author="vpawar" id="Specimen disposal event - Set Not Specified as reason for all existing disposal events">
27+
<sql>
28+
update
29+
catissue_disposal_event_param
30+
set
31+
reason_id = (
32+
select
33+
identifier
34+
from
35+
catissue_permissible_value
36+
where
37+
public_id = 'specimen_dispose_reason' and
38+
value = 'Not Specified'
39+
)
40+
</sql>
41+
</changeSet>
42+
43+
<changeSet author="vpawar" id="Add mandatory constraint on disposal event reason">
44+
<addNotNullConstraint tableName="CATISSUE_DISPOSAL_EVENT_PARAM" columnName="REASON_ID" columnDataType="${int.type}" />
45+
</changeSet>
46+
</databaseChangeLog>

WEB-INF/resources/db/12.1/schema.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,13 @@
1616
<column name="ACTIVITY_STATUS" type="${text.type}(32)" defaultValue="Active" />
1717
</addColumn>
1818
</changeSet>
19+
20+
<changeSet author="vpawar" id="Add reason PV in the specimen disposal event table">
21+
<addColumn tableName="CATISSUE_DISPOSAL_EVENT_PARAM">
22+
<column name="REASON_ID" type="${int.type}">
23+
<constraints foreignKeyName="FK_DISPOSE_REASON_PV" referencedTableName="CATISSUE_PERMISSIBLE_VALUE"
24+
referencedColumnNames="IDENTIFIER" />
25+
</column>
26+
</addColumn>
27+
</changeSet>
1928
</databaseChangeLog>

WEB-INF/resources/db/12.1/seed-data.xml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,72 @@
1616
insert into rbac_resources(identifier, name) values(rbac_resources_seq.nextval, 'PrintRule');
1717
</sql>
1818
</changeSet>
19+
20+
<changeSet author="vpawar" id="Specimen dispose reason">
21+
<sql>
22+
insert into catissue_cde
23+
(public_id, long_name, definition, version, last_updated)
24+
values
25+
('specimen_dispose_reason', 'Specimen Dispose Reason', 'Specimen Dispose Reason', '12.1', ${now});
26+
</sql>
27+
</changeSet>
28+
29+
<changeSet author="vpawar" id="Specimen dispose reason - PVs" dbms="mysql">
30+
<sql>
31+
insert into catissue_permissible_value
32+
(identifier, public_id, value, activity_status)
33+
values
34+
(default, 'specimen_dispose_reason', 'Damaged', 'Active'),
35+
(default, 'specimen_dispose_reason', 'Destroyed', 'Active'),
36+
(default, 'specimen_dispose_reason', 'Distributed', 'Active'),
37+
(default, 'specimen_dispose_reason', 'Not Specified', 'Active'),
38+
(default, 'specimen_dispose_reason', 'Processed', 'Active')
39+
</sql>
40+
</changeSet>
41+
42+
43+
<changeSet author="vpawar" id="Specimen dispose reason - Damaged" dbms="oracle">
44+
<sql>
45+
insert into catissue_permissible_value
46+
(identifier, public_id, value, activity_status)
47+
values
48+
(catissue_permi_value_seq.nextval, 'specimen_dispose_reason', 'Damaged', 'Active');
49+
</sql>
50+
</changeSet>
51+
52+
<changeSet author="vpawar" id="Specimen dispose reason - Destroyed" dbms="oracle">
53+
<sql>
54+
insert into catissue_permissible_value
55+
(identifier, public_id, value, activity_status)
56+
values
57+
(catissue_permi_value_seq.nextval, 'specimen_dispose_reason', 'Destroyed', 'Active');
58+
</sql>
59+
</changeSet>
60+
61+
<changeSet author="vpawar" id="Specimen dispose reason - Distributed" dbms="oracle">
62+
<sql>
63+
insert into catissue_permissible_value
64+
(identifier, public_id, value, activity_status)
65+
values
66+
(catissue_permi_value_seq.nextval, 'specimen_dispose_reason', 'Distributed', 'Active');
67+
</sql>
68+
</changeSet>
69+
70+
<changeSet author="vpawar" id="Specimen dispose reason - Not Specified" dbms="oracle">
71+
<sql>
72+
insert into catissue_permissible_value
73+
(identifier, public_id, value, activity_status)
74+
values
75+
(catissue_permi_value_seq.nextval, 'specimen_dispose_reason', 'Not Specified', 'Active');
76+
</sql>
77+
</changeSet>
78+
79+
<changeSet author="vpawar" id="Specimen dispose reason - Processed" dbms="oracle">
80+
<sql>
81+
insert into catissue_permissible_value
82+
(identifier, public_id, value, activity_status)
83+
values
84+
(catissue_permi_value_seq.nextval, 'specimen_dispose_reason', 'Processed', 'Active');
85+
</sql>
86+
</changeSet>
1987
</databaseChangeLog>

WEB-INF/resources/db/db-os-changelog-master-fresh.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@
193193
<include file="db/12.1/seed-data.xml" />
194194
<include file="db/12.1/audit.xml" />
195195
<include file="db/12.1/config.xml" />
196+
<include file="db/12.1/migration.xml" />
196197

197198
<!-- Views are created always at the last -->
198199
<include file="db/views.xml"/>

WEB-INF/resources/db/db-os-changelog-master-upgrade.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@
194194
<include file="db/12.1/seed-data.xml" />
195195
<include file="db/12.1/audit.xml" />
196196
<include file="db/12.1/config.xml" />
197+
<include file="db/12.1/migration.xml" />
197198

198199
<!-- Views are created always at the last -->
199200
<include file="db/views.xml"/>

WEB-INF/resources/errors/messages.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,8 @@ specimen_stored_in_af_transfer_na=Specimen {0} stored in automated freezer {1} c
10921092

10931093
specimen_stored_in_af_check_out_na=Specimen {0} stored in automated freezer {1} cannot be checked out. It must be retrieved from the freezer.
10941094

1095+
specimen_inv_dispose_reason=Invalid specimen disposal reason: {0}.
1096+
10951097
specimen_anatomic_site=Anatomic Site
10961098

10971099
specimen_additional_label=Additional Label

WEB-INF/resources/spe-forms/disposal-event.xml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
<primaryKey>IDENTIFIER</primaryKey>
99

1010
<row>
11-
<textArea>
11+
<pvField>
1212
<name>reason</name>
1313
<udn>reason</udn>
1414
<caption>#getMessage("disposal_event_reason")</caption>
15-
<column>REASON</column>
16-
<height>2</height>
17-
</textArea>
15+
<column>REASON_ID</column>
16+
<mandatory>true</mandatory>
17+
<attribute>specimen_dispose_reason</attribute>
18+
</pvField>
1819
</row>
1920

2021
<row>

WEB-INF/src/com/krishagni/catissueplus/core/administrative/services/impl/StorageContainerServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1350,7 +1350,7 @@ public ResponseEvent<Map<String, Object>> updateBoxSpecimens(RequestEvent<BoxDet
13501350
}
13511351

13521352
if ("DISPOSED".equals(input.getRemoveSpecimensReason())) {
1353-
existing.values().forEach(spmn -> spmn.close(AuthUtil.getCurrentUser(), Calendar.getInstance().getTime(), input.getRemoveSpecimensComments()));
1353+
existing.values().forEach(spmn -> spmn.close(AuthUtil.getCurrentUser(), Calendar.getInstance().getTime(), Specimen.NOT_SPECIFIED, null));
13541354
} else {
13551355
existing.values().forEach(spmn -> spmn.virtualise(input.getRemoveSpecimensComments()));
13561356
}

WEB-INF/src/com/krishagni/catissueplus/core/biospecimen/domain/Specimen.java

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import com.krishagni.catissueplus.core.biospecimen.repository.DaoFactory;
4646
import com.krishagni.catissueplus.core.biospecimen.services.impl.CpWorkflowTxnCache;
4747
import com.krishagni.catissueplus.core.common.OpenSpecimenAppCtxProvider;
48+
import com.krishagni.catissueplus.core.common.PvAttributes;
4849
import com.krishagni.catissueplus.core.common.access.AccessCtrlMgr;
4950
import com.krishagni.catissueplus.core.common.domain.PrintItem;
5051
import com.krishagni.catissueplus.core.common.errors.OpenSpecimenException;
@@ -93,6 +94,8 @@ public class Specimen extends BaseExtensionEntity {
9394

9495
public static final String NOT_SPECIFIED = "Not Specified";
9596

97+
public static final String PROCESSED = "Processed";
98+
9699
public static final String EXTN = "SpecimenExtension";
97100

98101
private static final String ENTITY_NAME = "specimen";
@@ -1180,10 +1183,6 @@ public List<PrintItem<Specimen>> getPrePrintItems() {
11801183
return result;
11811184
}
11821185

1183-
public void close(User user, Date time, String reason) {
1184-
close(user, time, reason, null);
1185-
}
1186-
11871186
public void close(User user, Date time, String reason, String comments) {
11881187
if (!getActivityStatus().equals(Status.ACTIVITY_STATUS_ACTIVE.getStatus())) {
11891188
return;
@@ -1323,8 +1322,8 @@ public void update(Specimen specimen) {
13231322
setUpdated(true);
13241323
}
13251324

1326-
public void updateStatus(Specimen otherSpecimen, String reason) {
1327-
updateStatus(otherSpecimen.getActivityStatus(), AuthUtil.getCurrentUser(), Calendar.getInstance().getTime(), reason, isForceDelete());
1325+
public void updateStatus(Specimen otherSpecimen, String comments) {
1326+
updateStatus(otherSpecimen.getActivityStatus(), AuthUtil.getCurrentUser(), Calendar.getInstance().getTime(), "Not Specified", comments, isForceDelete());
13281327

13291328
//
13301329
// OPSMN-4629
@@ -1343,7 +1342,7 @@ public void updateStatus(Specimen otherSpecimen, String reason) {
13431342
}
13441343
}
13451344

1346-
public void updateStatus(String activityStatus, User user, Date date, String reason, boolean isForceDelete) {
1345+
public void updateStatus(String activityStatus, User user, Date date, String reason, String comments, boolean isForceDelete) {
13471346
if (isReserved()) {
13481347
throw OpenSpecimenException.userError(SpecimenErrorCode.RESV_EDIT_NOT_ALLOWED, getLabel());
13491348
}
@@ -1355,7 +1354,7 @@ public void updateStatus(String activityStatus, User user, Date date, String rea
13551354
if (Status.ACTIVITY_STATUS_DISABLED.getStatus().equals(activityStatus)) {
13561355
disable(!isForceDelete);
13571356
} else if (Status.ACTIVITY_STATUS_CLOSED.getStatus().equals(activityStatus)) {
1358-
close(user, date, reason);
1357+
close(user, date, reason, comments);
13591358
} else if (Status.ACTIVITY_STATUS_ACTIVE.getStatus().equals(activityStatus)) {
13601359
activate();
13611360
}
@@ -1450,7 +1449,7 @@ public void distribute(DistributionOrderItem item) {
14501449
item.setStatus(DistributionOrderItem.Status.DISTRIBUTED);
14511450
setAvailabilityStatus(DISTRIBUTED);
14521451
} else if (item.isDistributedAndClosed()) {
1453-
close(order.getDistributor(), order.getExecutionDate(), "Distributed to " + dpShortTitle);
1452+
close(order.getDistributor(), order.getExecutionDate(), "Distributed", "Distributed to " + dpShortTitle);
14541453
setAvailabilityStatus(DISTRIBUTED);
14551454
}
14561455
}
@@ -1559,12 +1558,20 @@ private void updateCreatedBy(User user) {
15591558

15601559
private void addDisposalEvent(User user, Date time, String reason, String comments) {
15611560
SpecimenDisposalEvent event = new SpecimenDisposalEvent(this);
1562-
event.setReason(reason);
1561+
if (StringUtils.isBlank(reason)) {
1562+
reason = Specimen.NOT_SPECIFIED;
1563+
}
1564+
1565+
PermissibleValue pv = daoFactory.getPermissibleValueDao().getByValue(PvAttributes.SPECIMEN_DISPOSE_REASON, reason);
1566+
if (pv == null) {
1567+
throw OpenSpecimenException.userError(SpecimenErrorCode.INV_DISPOSE_REASON, reason);
1568+
}
1569+
1570+
event.setReason(pv);
15631571
event.setUser(user);
15641572
event.setTime(time);
15651573
event.setComments(comments);
15661574
event.saveOrUpdate();
1567-
15681575
zeroOutAvailableQty();
15691576
}
15701577

0 commit comments

Comments
 (0)