mirror of
https://github.com/hapifhir/hapi-fhir.git
synced 2025-02-16 18:05:19 +00:00
Fix userSelected null vs false
This commit is contained in:
parent
5defca0b39
commit
c9cff78af9
@ -221,11 +221,9 @@ public class Tag extends BaseElement implements IElement, IBaseCoding {
|
||||
return this;
|
||||
}
|
||||
|
||||
// fixme review all callers
|
||||
@Override
|
||||
public boolean getUserSelected() { return myUserSelected != null && myUserSelected; }
|
||||
|
||||
// fixme review all callers
|
||||
@Override
|
||||
public IBaseCoding setUserSelected(boolean theUserSelected) {
|
||||
myUserSelected = theUserSelected;
|
||||
|
@ -783,6 +783,7 @@ public class JsonParser extends BaseParser implements IJsonLikeParser {
|
||||
writeOptionalTagWithTextNode(theEventWriter, "system", tag.getScheme());
|
||||
writeOptionalTagWithTextNode(theEventWriter, "code", tag.getTerm());
|
||||
writeOptionalTagWithTextNode(theEventWriter, "display", tag.getLabel());
|
||||
// wipmb should we be writing the new properties here? There must be another path.
|
||||
theEventWriter.endObject();
|
||||
}
|
||||
theEventWriter.endArray();
|
||||
|
@ -28,7 +28,6 @@ public interface IBaseCoding extends IBase {
|
||||
|
||||
String getSystem();
|
||||
|
||||
// fixme review all callers
|
||||
boolean getUserSelected();
|
||||
|
||||
String getVersion();
|
||||
@ -41,7 +40,6 @@ public interface IBaseCoding extends IBase {
|
||||
|
||||
IBaseCoding setVersion(String theVersion);
|
||||
|
||||
// fixme review all callers
|
||||
IBaseCoding setUserSelected(boolean theUserSelected);
|
||||
|
||||
|
||||
|
@ -0,0 +1,4 @@
|
||||
---
|
||||
type: fix
|
||||
issue: 4819
|
||||
title: "Tags no longer provide a default `false` value for `userSelected`."
|
@ -382,7 +382,6 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> extends BaseStora
|
||||
|
||||
/**
|
||||
* <code>null</code> will only be returned if the scheme and tag are both blank
|
||||
* fixme fix all callers
|
||||
*/
|
||||
protected TagDefinition getTagOrNull(TransactionDetails theTransactionDetails, TagTypeEnum theTagType, String theScheme,
|
||||
String theTerm, String theLabel, String theVersion, Boolean theUserSelected) {
|
||||
@ -423,7 +422,7 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> extends BaseStora
|
||||
String theVersion, Boolean theUserSelected) {
|
||||
|
||||
TypedQuery<TagDefinition> q = buildTagQuery(theTagType, theScheme, theTerm, theVersion, theUserSelected);
|
||||
//FIXME MB: this is new.
|
||||
//wipmb: this is new.
|
||||
q.setMaxResults(1);
|
||||
|
||||
TransactionTemplate template = new TransactionTemplate(myTransactionManager);
|
||||
|
@ -38,6 +38,7 @@ import ca.uhn.fhir.jpa.model.entity.ResourceEncodingEnum;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceHistoryTable;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceTable;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceTag;
|
||||
import ca.uhn.fhir.jpa.model.entity.TagDefinition;
|
||||
import ca.uhn.fhir.jpa.model.entity.TagTypeEnum;
|
||||
import ca.uhn.fhir.jpa.partition.IPartitionLookupSvc;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
@ -349,19 +350,25 @@ public class JpaStorageResourceParser implements IJpaStorageResourceParser {
|
||||
List<IBaseCoding> securityLabels = new ArrayList<>();
|
||||
List<IdDt> profiles = new ArrayList<>();
|
||||
for (BaseTag next : theTagList) {
|
||||
switch (next.getTag().getTagType()) {
|
||||
TagDefinition nextTag = next.getTag();
|
||||
switch (nextTag.getTagType()) {
|
||||
case PROFILE:
|
||||
profiles.add(new IdDt(next.getTag().getCode()));
|
||||
profiles.add(new IdDt(nextTag.getCode()));
|
||||
break;
|
||||
case SECURITY_LABEL:
|
||||
IBaseCoding secLabel = (IBaseCoding) myContext.getVersion().newCodingDt();
|
||||
secLabel.setSystem(next.getTag().getSystem());
|
||||
secLabel.setCode(next.getTag().getCode());
|
||||
secLabel.setDisplay(next.getTag().getDisplay());
|
||||
secLabel.setSystem(nextTag.getSystem());
|
||||
secLabel.setCode(nextTag.getCode());
|
||||
secLabel.setDisplay(nextTag.getDisplay());
|
||||
securityLabels.add(secLabel);
|
||||
break;
|
||||
case TAG:
|
||||
tagList.add(new Tag(next.getTag().getSystem(), next.getTag().getCode(), next.getTag().getDisplay()));
|
||||
Tag e = new Tag(nextTag.getSystem(), nextTag.getCode(), nextTag.getDisplay());
|
||||
e.setVersion(nextTag.getVersion());
|
||||
if (nextTag.getUserSelected() != null) {
|
||||
e.setUserSelected(nextTag.getUserSelected());
|
||||
}
|
||||
tagList.add(e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -149,8 +149,8 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks<VersionEnum> {
|
||||
|
||||
|
||||
{ //We added this constraint when userSelected and Version were added. It is no longer necessary.
|
||||
// Builder.BuilderWithTableName tagDefTable = version.onTable("HFJ_TAG_DEF");
|
||||
// tagDefTable.dropIndex("20230503.1", "IDX_TAGDEF_TYPESYSCODEVERUS");
|
||||
Builder.BuilderWithTableName tagDefTable = version.onTable("HFJ_TAG_DEF");
|
||||
tagDefTable.dropIndex("20230503.1", "IDX_TAGDEF_TYPESYSCODEVERUS");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,7 +22,22 @@ import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
class CodingSpyTest {
|
||||
|
||||
/**
|
||||
* Ensure we can read the default null value of userSelected on Coding
|
||||
*/
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("getCases")
|
||||
void canReadValueUserSelected(IBaseCoding theObject, Boolean theValue) {
|
||||
IBaseCoding value = theObject.setSystem("http://example.com").setCode("value");
|
||||
if (theValue != null) {
|
||||
theObject.setUserSelected(theValue);
|
||||
}
|
||||
|
||||
Boolean result = new CodingSpy().getBooleanObject(theObject);
|
||||
|
||||
assertEquals(theValue, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
void canReadNullUserSelected() {
|
||||
@ -55,18 +70,6 @@ class CodingSpyTest {
|
||||
}
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("getCases")
|
||||
void canReadValueUserSelected(IBaseCoding theObject, Boolean theValue) {
|
||||
IBaseCoding value = theObject.setSystem("http://example.com").setCode("value");
|
||||
if (theValue != null) {
|
||||
theObject.setUserSelected(theValue);
|
||||
}
|
||||
|
||||
Boolean result = new CodingSpy().getBooleanObject(theObject);
|
||||
|
||||
assertEquals(theValue, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
void booleanNulls() {
|
||||
|
@ -48,11 +48,6 @@ import java.util.Collection;
|
||||
name = "HFJ_TAG_DEF",
|
||||
indexes = {
|
||||
@Index(name = "IDX_TAG_DEF_TP_CD_SYS", columnList = "TAG_TYPE, TAG_CODE, TAG_SYSTEM, TAG_ID"),
|
||||
},
|
||||
//FIXME GGG Drop this constraint
|
||||
uniqueConstraints = {
|
||||
@UniqueConstraint(name = "IDX_TAGDEF_TYPESYSCODEVERUS",
|
||||
columnNames = {"TAG_TYPE", "TAG_SYSTEM", "TAG_CODE", "TAG_VERSION", "TAG_USER_SELECTED"})
|
||||
}
|
||||
)
|
||||
public class TagDefinition implements Serializable {
|
||||
|
Loading…
x
Reference in New Issue
Block a user