diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/TermValueSet.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/TermValueSet.java index 723472895bc..28a60a1fef8 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/TermValueSet.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/TermValueSet.java @@ -43,6 +43,7 @@ import static org.apache.commons.lang3.StringUtils.length; public class TermValueSet implements Serializable { private static final long serialVersionUID = 1L; + public static final int MAX_EXPANSION_STATUS_LENGTH = 50; public static final int MAX_NAME_LENGTH = 200; public static final int MAX_URL_LENGTH = 200; @@ -68,6 +69,15 @@ public class TermValueSet implements Serializable { @OneToMany(mappedBy = "myValueSet") private List myConcepts; + @Enumerated(EnumType.STRING) + @Column(name = "EXPANSION_STATUS", nullable = false, length = MAX_EXPANSION_STATUS_LENGTH) + private TermValueSetExpansionStatusEnum myExpansionStatus; + + public TermValueSet() { + super(); + myExpansionStatus = TermValueSetExpansionStatusEnum.NOT_EXPANDED; + } + public Long getId() { return myId; } @@ -110,6 +120,14 @@ public class TermValueSet implements Serializable { return myConcepts; } + public TermValueSetExpansionStatusEnum getExpansionStatus() { + return myExpansionStatus; + } + + public void setExpansionStatus(TermValueSetExpansionStatusEnum theExpansionStatus) { + myExpansionStatus = theExpansionStatus; + } + @Override public boolean equals(Object theO) { if (this == theO) return true; @@ -139,6 +157,7 @@ public class TermValueSet implements Serializable { .append("myResourcePid", myResourcePid) .append("myName", myName) .append(myConcepts != null ? ("myConcepts - size=" + myConcepts.size()) : ("myConcepts=(null)")) + .append("myExpansionStatus", myExpansionStatus) .toString(); } } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/TermValueSetExpansionStatusEnum.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/TermValueSetExpansionStatusEnum.java new file mode 100644 index 00000000000..05a64e63341 --- /dev/null +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/TermValueSetExpansionStatusEnum.java @@ -0,0 +1,29 @@ +package ca.uhn.fhir.jpa.entity; + +/* + * #%L + * HAPI FHIR JPA Server + * %% + * Copyright (C) 2014 - 2019 University Health Network + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + +public enum TermValueSetExpansionStatusEnum { + + NOT_EXPANDED, + EXPANSION_IN_PROGRESS, + EXPANDED + +} diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcImplR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcImplR4Test.java index dbd4a91eeea..f7eaa42c369 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcImplR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcImplR4Test.java @@ -7,7 +7,6 @@ import ca.uhn.fhir.jpa.entity.*; import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.rest.api.server.IBundleProvider; -import ca.uhn.fhir.rest.param.StringParam; import ca.uhn.fhir.rest.param.UriParam; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; @@ -964,6 +963,7 @@ public class TerminologySvcImplR4Test extends BaseJpaR4Test { assertEquals("http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2", valueSet.getUrl()); assertEquals("Terminology Services Connectation #1 Extensional case #2", valueSet.getName()); assertEquals(codeSystem.getConcept().size(), valueSet.getConcepts().size()); + assertEquals(TermValueSetExpansionStatusEnum.NOT_EXPANDED, valueSet.getExpansionStatus()); TermValueSetConcept concept = valueSet.getConcepts().get(0); ourLog.info("Code:\n" + concept.toString()); diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/tasks/HapiFhirJpaMigrationTasks.java b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/tasks/HapiFhirJpaMigrationTasks.java index 36659301668..49e6cfb439c 100644 --- a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/tasks/HapiFhirJpaMigrationTasks.java +++ b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/tasks/HapiFhirJpaMigrationTasks.java @@ -115,6 +115,11 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks { .toColumn("RES_ID") .references("HFJ_RESOURCE", "RES_ID"); termValueSetTable.addColumn("NAME").nullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.STRING, TermValueSet.MAX_NAME_LENGTH); + termValueSetTable.addColumn("EXPANSION_STATUS").nonNullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.STRING, TermValueSet.MAX_EXPANSION_STATUS_LENGTH); + termValueSetTable + .addIndex("IDX_VALUESET_EXP_STATUS") + .unique(false) + .withColumns("EXPANSION_STATUS"); // TermValueSetConcept version.startSectionWithMessage("Processing table: TRM_VALUESET_CONCEPT");