Skip to content

Commit

Permalink
OPSMN-5121: Fixed the participant API to update the death date when v…
Browse files Browse the repository at this point in the history
…ital status is Dead.

The death date was ignored.
  • Loading branch information
vinayakapawar committed Sep 26, 2019
1 parent 53a8173 commit 4f535ca
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ private void setBirthAndDeathDate(ParticipantDetail detail, Participant particip
participant.setBirthDate(birthDate);
}

if (!DEAD_STATUS.equals(participant.getVitalStatus())) {
if (participant.getVitalStatus() == null || !DEAD_STATUS.equals(participant.getVitalStatus().getValue())) {
participant.setDeathDate(null);
} else if (!partial || detail.isAttrModified("deathDate")) {
Date deathDate = detail.getDeathDate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ private void updateParticipantIfExists(StagedParticipantDetail input) {
}

if (input.isAttrModified("ethnicities")) {
detail.setEthnicities(getPvsText(PvAttributes.ETHNICITY, input.getEthnicities(), ParticipantErrorCode.INVALID_ETHNICITY));
detail.setEthnicities(input.getEthnicities());
}

if (input.isAttrModified("gender")) {
detail.setGender(getPvText(PvAttributes.GENDER, input.getGender(), ParticipantErrorCode.INVALID_GENDER));
detail.setGender(input.getGender());
}

if (input.isAttrModified("lastName")) {
Expand All @@ -107,11 +107,11 @@ private void updateParticipantIfExists(StagedParticipantDetail input) {
}

if (input.isAttrModified("vitalStatus")) {
detail.setVitalStatus(getPvText(PvAttributes.VITAL_STATUS, input.getVitalStatus(), ParticipantErrorCode.INVALID_VITAL_STATUS));
detail.setVitalStatus(input.getVitalStatus());
}

if (input.isAttrModified("races")) {
detail.setRaces(getPvsText(PvAttributes.RACE, input.getRaces(), ParticipantErrorCode.INVALID_RACE));
detail.setRaces(input.getRaces());
}

if (input.isAttrModified("pmis")) {
Expand Down Expand Up @@ -219,11 +219,6 @@ public PermissibleValue getPv(String attr, String value, ErrorCode invErrorCode)
return pv;
}

public String getPvText(String attr, String value, ErrorCode invErrorCode) {
PermissibleValue pv = getPv(attr, value, invErrorCode);
return pv != null ? pv.getValue() : null;
}

public Set<PermissibleValue> getPvs(String attr, Collection<String> values, ErrorCode invErrorCode) {
if (CollectionUtils.isEmpty(values)) {
return new HashSet<>();
Expand All @@ -236,9 +231,4 @@ public Set<PermissibleValue> getPvs(String attr, Collection<String> values, Erro

return new HashSet<>(pvs);
}

public Set<String> getPvsText(String attr, Collection<String> values, ErrorCode invErrorCode) {
Set<PermissibleValue> pvs = getPvs(attr, values, invErrorCode);
return Utility.nullSafeStream(pvs).map(pv -> pv.getValue()).collect(Collectors.toSet());
}
}

0 comments on commit 4f535ca

Please sign in to comment.