Work on term

This commit is contained in:
James Agnew 2017-05-06 11:41:30 +02:00
parent ef772547c3
commit 262e39e57a
4 changed files with 87 additions and 4 deletions

View File

@ -66,7 +66,6 @@ import org.hibernate.search.annotations.TokenizerDef;
import ca.uhn.fhir.jpa.entity.TermConceptParentChildLink.RelationshipTypeEnum; import ca.uhn.fhir.jpa.entity.TermConceptParentChildLink.RelationshipTypeEnum;
import ca.uhn.fhir.jpa.search.DeferConceptIndexingInterceptor; import ca.uhn.fhir.jpa.search.DeferConceptIndexingInterceptor;
//@formatter:off
@Entity @Entity
@Indexed(interceptor=DeferConceptIndexingInterceptor.class) @Indexed(interceptor=DeferConceptIndexingInterceptor.class)
@Table(name="TRM_CONCEPT", uniqueConstraints= { @Table(name="TRM_CONCEPT", uniqueConstraints= {
@ -80,7 +79,6 @@ import ca.uhn.fhir.jpa.search.DeferConceptIndexingInterceptor;
filters = { filters = {
}) })
}) })
//@formatter:on
public class TermConcept implements Serializable { public class TermConcept implements Serializable {
private static final int MAX_DESC_LENGTH = 400; private static final int MAX_DESC_LENGTH = 400;
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(TermConcept.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(TermConcept.class);
@ -102,7 +100,6 @@ public class TermConcept implements Serializable {
@Fields({ @Field(name = "myCodeSystemVersionPid") }) @Fields({ @Field(name = "myCodeSystemVersionPid") })
private long myCodeSystemVersionPid; private long myCodeSystemVersionPid;
//@formatter:off
@Column(name="DISPLAY", length=MAX_DESC_LENGTH, nullable=true) @Column(name="DISPLAY", length=MAX_DESC_LENGTH, nullable=true)
@Fields({ @Fields({
@Field(name = "myDisplay", index = org.hibernate.search.annotations.Index.YES, store = Store.YES, analyze = Analyze.YES, analyzer = @Analyzer(definition = "standardAnalyzer")), @Field(name = "myDisplay", index = org.hibernate.search.annotations.Index.YES, store = Store.YES, analyze = Analyze.YES, analyzer = @Analyzer(definition = "standardAnalyzer")),
@ -111,7 +108,9 @@ public class TermConcept implements Serializable {
@Field(name = "myDisplayPhonetic", index = org.hibernate.search.annotations.Index.YES, store = Store.NO, analyze = Analyze.YES, analyzer = @Analyzer(definition = "autocompletePhoneticAnalyzer")) @Field(name = "myDisplayPhonetic", index = org.hibernate.search.annotations.Index.YES, store = Store.NO, analyze = Analyze.YES, analyzer = @Analyzer(definition = "autocompletePhoneticAnalyzer"))
}) })
private String myDisplay; private String myDisplay;
//@formatter:on
@OneToMany(mappedBy="myConcept")
private Collection<TermConceptProperty> myProperties;
@Id() @Id()
@SequenceGenerator(name = "SEQ_CONCEPT_PID", sequenceName = "SEQ_CONCEPT_PID") @SequenceGenerator(name = "SEQ_CONCEPT_PID", sequenceName = "SEQ_CONCEPT_PID")

View File

@ -0,0 +1,71 @@
package ca.uhn.fhir.jpa.entity;
/*
* #%L
* HAPI FHIR JPA Server
* %%
* Copyright (C) 2014 - 2017 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%
*/
import java.io.Serializable;
import javax.persistence.*;
@Entity
@Table(name = "TRM_CONCEPT_PROPERTY", uniqueConstraints = {
}, indexes = {
})
public class TermConceptProperty implements Serializable {
private static final long serialVersionUID = 1L;
@ManyToOne
@JoinColumn(name = "CONCEPT_PID", referencedColumnName = "PID", foreignKey = @ForeignKey(name = "FK_CONCEPTPROP_CONCEPT"))
private TermConcept myConcept;
@Id()
@SequenceGenerator(name = "SEQ_CONCEPT_PROP_PID", sequenceName = "SEQ_CONCEPT_PROP_PID")
@GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ_CONCEPT_PROP_PID")
@Column(name = "PID")
private Long myId;
@Column(name="PROP_KEY", length=200, nullable=false)
private String myKey;
@Column(name="PROP_VAL", length=200, nullable=true)
private String myValue;
public String getKey() {
return myKey;
}
public String getValue() {
return myValue;
}
public void setConcept(TermConcept theConcept) {
myConcept = theConcept;
}
public void setKey(String theKey) {
myKey = theKey;
}
public void setValue(String theValue) {
myValue = theValue;
}
}

View File

@ -290,6 +290,8 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test {
@Test @Test
public void testExpandWithOpEquals() { public void testExpandWithOpEquals() {
ValueSet result = myValueSetDao.expandByIdentifier("http://hl7.org/fhir/ValueSet/doc-typecodes", ""); ValueSet result = myValueSetDao.expandByIdentifier("http://hl7.org/fhir/ValueSet/doc-typecodes", "");
ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(result)); ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(result));
} }

View File

@ -8,6 +8,7 @@ import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import static org.mockito.Matchers.any; import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@ -78,8 +79,18 @@ public class TerminologyLoaderSvcTest {
RequestDetails details = mock(RequestDetails.class); RequestDetails details = mock(RequestDetails.class);
mySvc.loadLoinc(list(bos1.toByteArray(), bos2.toByteArray()), details); mySvc.loadLoinc(list(bos1.toByteArray(), bos2.toByteArray()), details);
verify(myTermSvc, times(1)).storeNewCodeSystemVersion(mySystemCaptor.capture(), myCsvCaptor.capture(), any(RequestDetails.class));
TermCodeSystemVersion ver = myCsvCaptor.getValue();
TermConcept code = ver.getConcepts().iterator().next();
assertEquals("10013-1", code.getCode());
} }
@Captor
private ArgumentCaptor<String> mySystemCaptor;
/** /**
* This is just for trying stuff, it won't run without * This is just for trying stuff, it won't run without