Fox a bunch of JPA bugs
This commit is contained in:
parent
bb86724e12
commit
54078be6e0
|
@ -9,6 +9,15 @@
|
||||||
<release version="0.3" date="2014-May-12" description="This release corrects lots of bugs and introduces the fluent client mode">
|
<release version="0.3" date="2014-May-12" description="This release corrects lots of bugs and introduces the fluent client mode">
|
||||||
</release>
|
</release>
|
||||||
<release version="0.4" date="TBD">
|
<release version="0.4" date="TBD">
|
||||||
|
<action type="add">
|
||||||
|
<![CDATA[<b>BREAKING CHANGE:</b>]]>: IdDt has been modified so that it
|
||||||
|
contains a partial or complete resource identity. Previously it contained
|
||||||
|
only the simple alphanumeric id of the resource (the part at the end of the "read" URL for
|
||||||
|
that resource) but it can now contain a complete URL or even a partial URL (e.g. "Patient/123")
|
||||||
|
and can optionally contain a version (e.g. "Patient/123/_history/456"). New methods have
|
||||||
|
been added to this datatype which provide just the numeric portion. See the JavaDoc
|
||||||
|
for more information.
|
||||||
|
</action>
|
||||||
<action type="add">
|
<action type="add">
|
||||||
Allow use of QuantityDt as a service parameter to support the "quantity" type. Previously
|
Allow use of QuantityDt as a service parameter to support the "quantity" type. Previously
|
||||||
QuantityDt did not implement IQueryParameterType so it was not valid, and there was no way to
|
QuantityDt did not implement IQueryParameterType so it was not valid, and there was no way to
|
||||||
|
|
|
@ -54,31 +54,13 @@ public abstract class BaseResourceReference extends BaseElement {
|
||||||
*/
|
*/
|
||||||
public BaseResourceReference(IResource theResource) {
|
public BaseResourceReference(IResource theResource) {
|
||||||
myResource = theResource;
|
myResource = theResource;
|
||||||
setResourceId(theResource.getId());
|
setReference(theResource.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the value(s) for <b>reference</b> (Relative, internal or absolute URL reference). creating it if it does not exist. Will not return <code>null</code>.
|
|
||||||
*
|
|
||||||
* <p>
|
|
||||||
* <b>Definition:</b> A reference to a location at which the other resource is found. The reference may a relative reference, in which case it is relative to the service base URL, or an absolute
|
|
||||||
* URL that resolves to the location where the resource is found. The reference may be version specific or not. If the reference is not to a FHIR RESTful server, then it should be assumed to be
|
|
||||||
* version specific. Internal fragment references (start with '#') refer to contained resources
|
|
||||||
* </p>
|
|
||||||
*/
|
|
||||||
public abstract IdDt getResourceId();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the resource ID
|
|
||||||
*
|
|
||||||
* <p>
|
|
||||||
* <b>Definition:</b> A reference to a location at which the other resource is found. The reference may a relative reference, in which case it is relative to the service base URL, or an absolute
|
|
||||||
* URL that resolves to the location where the resource is found. The reference may be version specific or not. If the reference is not to a FHIR RESTful server, then it should be assumed to be
|
|
||||||
* version specific. Internal fragment references (start with '#') refer to contained resources
|
|
||||||
* </p>
|
|
||||||
*/
|
|
||||||
public abstract void setResourceId(IdDt theResourceId);
|
|
||||||
|
|
||||||
|
public abstract BaseResourceReference setReference(IdDt theReference);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the actual loaded and parsed resource instance, <b>if it is already present</b>. This
|
* Gets the actual loaded and parsed resource instance, <b>if it is already present</b>. This
|
||||||
* method will return the resource instance only if it has previously been loaded using
|
* method will return the resource instance only if it has previously been loaded using
|
||||||
|
@ -107,7 +89,7 @@ public abstract class BaseResourceReference extends BaseElement {
|
||||||
return myResource;
|
return myResource;
|
||||||
}
|
}
|
||||||
|
|
||||||
IdDt resourceId = getResourceId();
|
IdDt resourceId = getReference();
|
||||||
if (resourceId == null) {
|
if (resourceId == null) {
|
||||||
throw new IllegalStateException("Reference has no resource ID defined");
|
throw new IllegalStateException("Reference has no resource ID defined");
|
||||||
}
|
}
|
||||||
|
@ -141,6 +123,8 @@ public abstract class BaseResourceReference extends BaseElement {
|
||||||
return myResource;
|
return myResource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected abstract IdDt getReference();
|
||||||
|
|
||||||
public void setResource(IResource theResource) {
|
public void setResource(IResource theResource) {
|
||||||
myResource = theResource;
|
myResource = theResource;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,20 @@
|
||||||
package ca.uhn.fhir.model.dstu.composite;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* #%L
|
|
||||||
* HAPI FHIR Library
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2014 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
|
package ca.uhn.fhir.model.dstu.composite;
|
||||||
* limitations under the License.
|
|
||||||
* #L%
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -33,19 +29,22 @@ import ca.uhn.fhir.model.primitive.IdDt;
|
||||||
import ca.uhn.fhir.model.primitive.StringDt;
|
import ca.uhn.fhir.model.primitive.StringDt;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HAPI/FHIR <b>ResourceReferenceDt</b> Datatype (A reference from one resource to another)
|
* HAPI/FHIR <b>ResourceReferenceDt</b> Datatype
|
||||||
*
|
* (A reference from one resource to another)
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* <b>Definition:</b> A reference from one resource to another
|
* <b>Definition:</b>
|
||||||
* </p>
|
* A reference from one resource to another
|
||||||
*
|
* </p>
|
||||||
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* <b>Requirements:</b>
|
* <b>Requirements:</b>
|
||||||
*
|
*
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
@DatatypeDef(name = "ResourceReferenceDt")
|
@DatatypeDef(name="ResourceReferenceDt")
|
||||||
public class ResourceReferenceDt extends BaseResourceReference implements ICompositeDatatype {
|
public class ResourceReferenceDt
|
||||||
|
extends BaseResourceReference implements ICompositeDatatype {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
@ -78,7 +77,7 @@ public class ResourceReferenceDt extends BaseResourceReference implements ICompo
|
||||||
* The reference itself
|
* The reference itself
|
||||||
*/
|
*/
|
||||||
public ResourceReferenceDt(String theId) {
|
public ResourceReferenceDt(String theId) {
|
||||||
setResourceId(new IdDt(theId));
|
setReference(new IdDt(theId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -89,86 +88,89 @@ public class ResourceReferenceDt extends BaseResourceReference implements ICompo
|
||||||
* The reference itself
|
* The reference itself
|
||||||
*/
|
*/
|
||||||
public ResourceReferenceDt(IdDt theResourceId) {
|
public ResourceReferenceDt(IdDt theResourceId) {
|
||||||
setResourceId(theResourceId);
|
setReference(theResourceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Child(name = "reference", type = StringDt.class, order = 0, min = 0, max = 1)
|
@Child(name="reference", type=IdDt.class, order=0, min=0, max=1)
|
||||||
@Description(shortDefinition = "Relative, internal or absolute URL reference", formalDefinition = "A reference to a location at which the other resource is found. The reference may a relative reference, in which case it is relative to the service base URL, or an absolute URL that resolves to the location where the resource is found. The reference may be version specific or not. If the reference is not to a FHIR RESTful server, then it should be assumed to be version specific. Internal fragment references (start with '#') refer to contained resources")
|
@Description(
|
||||||
private StringDt myReference;
|
shortDefinition="Relative, internal or absolute URL reference",
|
||||||
|
formalDefinition="A reference to a location at which the other resource is found. The reference may a relative reference, in which case it is relative to the service base URL, or an absolute URL that resolves to the location where the resource is found. The reference may be version specific or not. If the reference is not to a FHIR RESTful server, then it should be assumed to be version specific. Internal fragment references (start with '#') refer to contained resources"
|
||||||
@Child(name = "display", type = StringDt.class, order = 1, min = 0, max = 1)
|
)
|
||||||
@Description(shortDefinition = "Text alternative for the resource", formalDefinition = "Plain text narrative that identifies the resource in addition to the resource reference")
|
private IdDt myReference;
|
||||||
|
|
||||||
|
@Child(name="display", type=StringDt.class, order=1, min=0, max=1)
|
||||||
|
@Description(
|
||||||
|
shortDefinition="Text alternative for the resource",
|
||||||
|
formalDefinition="Plain text narrative that identifies the resource in addition to the resource reference"
|
||||||
|
)
|
||||||
private StringDt myDisplay;
|
private StringDt myDisplay;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEmpty() {
|
public boolean isEmpty() {
|
||||||
return super.isBaseEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(myReference, myDisplay);
|
return super.isBaseEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty( myReference, myDisplay);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends IElement> List<T> getAllPopulatedChildElementsOfType(Class<T> theType) {
|
public <T extends IElement> List<T> getAllPopulatedChildElementsOfType(Class<T> theType) {
|
||||||
return ca.uhn.fhir.util.ElementUtil.allPopulatedChildElements(theType, myReference, myDisplay);
|
return ca.uhn.fhir.util.ElementUtil.allPopulatedChildElements(theType, myReference, myDisplay);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value(s) for <b>reference</b> (Relative, internal or absolute URL reference). creating it if it does not
|
* Gets the value(s) for <b>reference</b> (Relative, internal or absolute URL reference).
|
||||||
* exist. Will not return <code>null</code>.
|
* creating it if it does
|
||||||
*
|
* not exist. Will not return <code>null</code>.
|
||||||
* <p>
|
*
|
||||||
* <b>Definition:</b> A reference to a location at which the other resource is found. The reference may a relative
|
* <p>
|
||||||
* reference, in which case it is relative to the service base URL, or an absolute URL that resolves to the location
|
* <b>Definition:</b>
|
||||||
* where the resource is found. The reference may be version specific or not. If the reference is not to a FHIR
|
* A reference to a location at which the other resource is found. The reference may a relative reference, in which case it is relative to the service base URL, or an absolute URL that resolves to the location where the resource is found. The reference may be version specific or not. If the reference is not to a FHIR RESTful server, then it should be assumed to be version specific. Internal fragment references (start with '#') refer to contained resources
|
||||||
* RESTful server, then it should be assumed to be version specific. Internal fragment references (start with '#')
|
* </p>
|
||||||
* refer to contained resources
|
|
||||||
* </p>
|
|
||||||
*/
|
*/
|
||||||
public StringDt getReference() {
|
public IdDt getReference() {
|
||||||
if (myReference == null) {
|
if (myReference == null) {
|
||||||
myReference = new StringDt();
|
myReference = new IdDt();
|
||||||
}
|
}
|
||||||
return myReference;
|
return myReference;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the value(s) for <b>reference</b> (Relative, internal or absolute URL reference)
|
* Sets the value(s) for <b>reference</b> (Relative, internal or absolute URL reference)
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* <b>Definition:</b> A reference to a location at which the other resource is found. The reference may a relative
|
* <b>Definition:</b>
|
||||||
* reference, in which case it is relative to the service base URL, or an absolute URL that resolves to the location
|
* A reference to a location at which the other resource is found. The reference may a relative reference, in which case it is relative to the service base URL, or an absolute URL that resolves to the location where the resource is found. The reference may be version specific or not. If the reference is not to a FHIR RESTful server, then it should be assumed to be version specific. Internal fragment references (start with '#') refer to contained resources
|
||||||
* where the resource is found. The reference may be version specific or not. If the reference is not to a FHIR
|
* </p>
|
||||||
* RESTful server, then it should be assumed to be version specific. Internal fragment references (start with '#')
|
|
||||||
* refer to contained resources
|
|
||||||
* </p>
|
|
||||||
*/
|
*/
|
||||||
public ResourceReferenceDt setReference(StringDt theValue) {
|
public ResourceReferenceDt setReference(IdDt theValue) {
|
||||||
myReference = theValue;
|
myReference = theValue;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the value for <b>reference</b> (Relative, internal or absolute URL reference)
|
* Sets the value for <b>reference</b> (Relative, internal or absolute URL reference)
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* <b>Definition:</b> A reference to a location at which the other resource is found. The reference may a relative
|
* <b>Definition:</b>
|
||||||
* reference, in which case it is relative to the service base URL, or an absolute URL that resolves to the location
|
* A reference to a location at which the other resource is found. The reference may a relative reference, in which case it is relative to the service base URL, or an absolute URL that resolves to the location where the resource is found. The reference may be version specific or not. If the reference is not to a FHIR RESTful server, then it should be assumed to be version specific. Internal fragment references (start with '#') refer to contained resources
|
||||||
* where the resource is found. The reference may be version specific or not. If the reference is not to a FHIR
|
* </p>
|
||||||
* RESTful server, then it should be assumed to be version specific. Internal fragment references (start with '#')
|
|
||||||
* refer to contained resources
|
|
||||||
* </p>
|
|
||||||
*/
|
*/
|
||||||
public ResourceReferenceDt setReference(String theString) {
|
public ResourceReferenceDt setReference( String theId) {
|
||||||
return setReference(new StringDt(theString));
|
myReference = new IdDt(theId);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value(s) for <b>display</b> (Text alternative for the resource). creating it if it does not exist. Will
|
* Gets the value(s) for <b>display</b> (Text alternative for the resource).
|
||||||
* not return <code>null</code>.
|
* creating it if it does
|
||||||
*
|
* not exist. Will not return <code>null</code>.
|
||||||
* <p>
|
*
|
||||||
* <b>Definition:</b> Plain text narrative that identifies the resource in addition to the resource reference
|
* <p>
|
||||||
* </p>
|
* <b>Definition:</b>
|
||||||
|
* Plain text narrative that identifies the resource in addition to the resource reference
|
||||||
|
* </p>
|
||||||
*/
|
*/
|
||||||
public StringDt getDisplay() {
|
public StringDt getDisplay() {
|
||||||
if (myDisplay == null) {
|
if (myDisplay == null) {
|
||||||
myDisplay = new StringDt();
|
myDisplay = new StringDt();
|
||||||
}
|
}
|
||||||
|
@ -177,39 +179,31 @@ public class ResourceReferenceDt extends BaseResourceReference implements ICompo
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the value(s) for <b>display</b> (Text alternative for the resource)
|
* Sets the value(s) for <b>display</b> (Text alternative for the resource)
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* <b>Definition:</b> Plain text narrative that identifies the resource in addition to the resource reference
|
* <b>Definition:</b>
|
||||||
* </p>
|
* Plain text narrative that identifies the resource in addition to the resource reference
|
||||||
|
* </p>
|
||||||
*/
|
*/
|
||||||
public ResourceReferenceDt setDisplay(StringDt theValue) {
|
public ResourceReferenceDt setDisplay(StringDt theValue) {
|
||||||
myDisplay = theValue;
|
myDisplay = theValue;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the value for <b>display</b> (Text alternative for the resource)
|
* Sets the value for <b>display</b> (Text alternative for the resource)
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* <b>Definition:</b> Plain text narrative that identifies the resource in addition to the resource reference
|
* <b>Definition:</b>
|
||||||
* </p>
|
* Plain text narrative that identifies the resource in addition to the resource reference
|
||||||
|
* </p>
|
||||||
*/
|
*/
|
||||||
public ResourceReferenceDt setDisplay(String theString) {
|
public ResourceReferenceDt setDisplay( String theString) {
|
||||||
myDisplay = new StringDt(theString);
|
myDisplay = new StringDt(theString);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public IdDt getResourceId() {
|
|
||||||
if (myReference == null) {
|
|
||||||
return new IdDt();
|
|
||||||
}
|
|
||||||
return new IdDt(myReference.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setResourceId(IdDt theResourceId) {
|
|
||||||
myReference = new StringDt(theResourceId.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -75,14 +75,6 @@ public class Binary extends BaseResource implements IResource {
|
||||||
return myContentType;
|
return myContentType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Do not call - throws {@link UnsupportedOperationException}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public NarrativeDt getText() {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEmpty() {
|
public boolean isEmpty() {
|
||||||
return (myContent.isEmpty()) && StringUtils.isBlank(myContentType);
|
return (myContent.isEmpty()) && StringUtils.isBlank(myContentType);
|
||||||
|
|
|
@ -16,26 +16,6 @@
|
||||||
|
|
||||||
package ca.uhn.fhir.model.dstu.resource;
|
package ca.uhn.fhir.model.dstu.resource;
|
||||||
|
|
||||||
/*
|
|
||||||
* #%L
|
|
||||||
* HAPI FHIR Library
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2014 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.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -185,33 +165,6 @@ public class Encounter extends BaseResource implements IResource {
|
||||||
*/
|
*/
|
||||||
public static final Include INCLUDE_SUBJECT = new Include("Encounter.subject");
|
public static final Include INCLUDE_SUBJECT = new Include("Encounter.subject");
|
||||||
|
|
||||||
/**
|
|
||||||
* Search parameter constant for <b>!fulfills</b>
|
|
||||||
* <p>
|
|
||||||
* Description: <b></b><br/>
|
|
||||||
* Type: <b>reference</b><br/>
|
|
||||||
* Path: <b>Encounter.fulfills</b><br/>
|
|
||||||
* </p>
|
|
||||||
*/
|
|
||||||
@SearchParamDefinition(name="!fulfills", path="Encounter.fulfills", description="", type="reference")
|
|
||||||
public static final String SP_FULFILLS = "!fulfills";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <b>Fluent Client</b> search parameter constant for <b>!fulfills</b>
|
|
||||||
* <p>
|
|
||||||
* Description: <b></b><br/>
|
|
||||||
* Type: <b>reference</b><br/>
|
|
||||||
* Path: <b>Encounter.fulfills</b><br/>
|
|
||||||
* </p>
|
|
||||||
*/
|
|
||||||
public static final ReferenceParam FULFILLS = new ReferenceParam(SP_FULFILLS);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constant for fluent queries to be used to add include statements. Specifies
|
|
||||||
* the path value of "<b>Encounter.fulfills</b>".
|
|
||||||
*/
|
|
||||||
public static final Include INCLUDE_FULFILLS = new Include("Encounter.fulfills");
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search parameter constant for <b>length</b>
|
* Search parameter constant for <b>length</b>
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -498,11 +451,11 @@ public class Encounter extends BaseResource implements IResource {
|
||||||
*
|
*
|
||||||
* @return Returns a reference to this object, to allow for simple chaining.
|
* @return Returns a reference to this object, to allow for simple chaining.
|
||||||
*/
|
*/
|
||||||
public Encounter addIdentifier( IdentifierUseEnum theUse, String theSystem, String theValue, String theLabel) {
|
public Encounter addIdentifier( String theSystem, String theValue) {
|
||||||
if (myIdentifier == null) {
|
if (myIdentifier == null) {
|
||||||
myIdentifier = new java.util.ArrayList<IdentifierDt>();
|
myIdentifier = new java.util.ArrayList<IdentifierDt>();
|
||||||
}
|
}
|
||||||
myIdentifier.add(new IdentifierDt(theUse, theSystem, theValue, theLabel));
|
myIdentifier.add(new IdentifierDt(theSystem, theValue));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -516,11 +469,11 @@ public class Encounter extends BaseResource implements IResource {
|
||||||
*
|
*
|
||||||
* @return Returns a reference to this object, to allow for simple chaining.
|
* @return Returns a reference to this object, to allow for simple chaining.
|
||||||
*/
|
*/
|
||||||
public Encounter addIdentifier( String theSystem, String theValue) {
|
public Encounter addIdentifier( IdentifierUseEnum theUse, String theSystem, String theValue, String theLabel) {
|
||||||
if (myIdentifier == null) {
|
if (myIdentifier == null) {
|
||||||
myIdentifier = new java.util.ArrayList<IdentifierDt>();
|
myIdentifier = new java.util.ArrayList<IdentifierDt>();
|
||||||
}
|
}
|
||||||
myIdentifier.add(new IdentifierDt(theSystem, theValue));
|
myIdentifier.add(new IdentifierDt(theUse, theSystem, theValue, theLabel));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -651,8 +604,24 @@ public class Encounter extends BaseResource implements IResource {
|
||||||
* Specific type of encounter (e.g. e-mail consultation, surgical day-care, skilled nursing, rehabilitation)
|
* Specific type of encounter (e.g. e-mail consultation, surgical day-care, skilled nursing, rehabilitation)
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public void addType(EncounterTypeEnum theValue) {
|
public BoundCodeableConceptDt<EncounterTypeEnum> addType(EncounterTypeEnum theValue) {
|
||||||
getType().add(new BoundCodeableConceptDt<EncounterTypeEnum>(EncounterTypeEnum.VALUESET_BINDER, theValue));
|
BoundCodeableConceptDt<EncounterTypeEnum> retVal = new BoundCodeableConceptDt<EncounterTypeEnum>(EncounterTypeEnum.VALUESET_BINDER, theValue);
|
||||||
|
getType().add(retVal);
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a value for <b>type</b> (Specific type of encounter)
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* <b>Definition:</b>
|
||||||
|
* Specific type of encounter (e.g. e-mail consultation, surgical day-care, skilled nursing, rehabilitation)
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
|
public BoundCodeableConceptDt<EncounterTypeEnum> addType() {
|
||||||
|
BoundCodeableConceptDt<EncounterTypeEnum> retVal = new BoundCodeableConceptDt<EncounterTypeEnum>(EncounterTypeEnum.VALUESET_BINDER);
|
||||||
|
getType().add(retVal);
|
||||||
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1157,8 +1126,24 @@ public class Encounter extends BaseResource implements IResource {
|
||||||
*
|
*
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public void addType(ParticipantTypeEnum theValue) {
|
public BoundCodeableConceptDt<ParticipantTypeEnum> addType(ParticipantTypeEnum theValue) {
|
||||||
getType().add(new BoundCodeableConceptDt<ParticipantTypeEnum>(ParticipantTypeEnum.VALUESET_BINDER, theValue));
|
BoundCodeableConceptDt<ParticipantTypeEnum> retVal = new BoundCodeableConceptDt<ParticipantTypeEnum>(ParticipantTypeEnum.VALUESET_BINDER, theValue);
|
||||||
|
getType().add(retVal);
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a value for <b>type</b> (Role of participant in encounter)
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* <b>Definition:</b>
|
||||||
|
*
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
|
public BoundCodeableConceptDt<ParticipantTypeEnum> addType() {
|
||||||
|
BoundCodeableConceptDt<ParticipantTypeEnum> retVal = new BoundCodeableConceptDt<ParticipantTypeEnum>(ParticipantTypeEnum.VALUESET_BINDER);
|
||||||
|
getType().add(retVal);
|
||||||
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1187,6 +1172,9 @@ public class Encounter extends BaseResource implements IResource {
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public ResourceReferenceDt getIndividual() {
|
public ResourceReferenceDt getIndividual() {
|
||||||
|
if (myIndividual == null) {
|
||||||
|
myIndividual = new ResourceReferenceDt();
|
||||||
|
}
|
||||||
return myIndividual;
|
return myIndividual;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1355,8 +1343,8 @@ public class Encounter extends BaseResource implements IResource {
|
||||||
*
|
*
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public Hospitalization setPreAdmissionIdentifier( IdentifierUseEnum theUse, String theSystem, String theValue, String theLabel) {
|
public Hospitalization setPreAdmissionIdentifier( String theSystem, String theValue) {
|
||||||
myPreAdmissionIdentifier = new IdentifierDt(theUse, theSystem, theValue, theLabel);
|
myPreAdmissionIdentifier = new IdentifierDt(theSystem, theValue);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1368,8 +1356,8 @@ public class Encounter extends BaseResource implements IResource {
|
||||||
*
|
*
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public Hospitalization setPreAdmissionIdentifier( String theSystem, String theValue) {
|
public Hospitalization setPreAdmissionIdentifier( IdentifierUseEnum theUse, String theSystem, String theValue, String theLabel) {
|
||||||
myPreAdmissionIdentifier = new IdentifierDt(theSystem, theValue);
|
myPreAdmissionIdentifier = new IdentifierDt(theUse, theSystem, theValue, theLabel);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2040,4 +2028,4 @@ public class Encounter extends BaseResource implements IResource {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -273,7 +273,7 @@ public class JsonParser extends BaseParser implements IParser {
|
||||||
}
|
}
|
||||||
case RESOURCE_REF: {
|
case RESOURCE_REF: {
|
||||||
ResourceReferenceDt referenceDt = (ResourceReferenceDt) theValue;
|
ResourceReferenceDt referenceDt = (ResourceReferenceDt) theValue;
|
||||||
IdDt value = referenceDt.getResourceId();
|
IdDt value = referenceDt.getReference();
|
||||||
if (theChildName != null) {
|
if (theChildName != null) {
|
||||||
theWriter.writeStartObject(theChildName);
|
theWriter.writeStartObject(theChildName);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -24,6 +24,8 @@ import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.IQueryParameterAnd;
|
import ca.uhn.fhir.model.api.IQueryParameterAnd;
|
||||||
import ca.uhn.fhir.model.api.IQueryParameterOr;
|
import ca.uhn.fhir.model.api.IQueryParameterOr;
|
||||||
import ca.uhn.fhir.model.dstu.valueset.QuantityCompararatorEnum;
|
import ca.uhn.fhir.model.dstu.valueset.QuantityCompararatorEnum;
|
||||||
|
@ -184,8 +186,12 @@ public class DateRangeParam implements IQueryParameterAnd {
|
||||||
* "2011-02-22" or "2011-02-22T13:12:00". Will be treated inclusively.
|
* "2011-02-22" or "2011-02-22T13:12:00". Will be treated inclusively.
|
||||||
*/
|
*/
|
||||||
public void setRangeFromDatesInclusive(Date theLowerBound, Date theUpperBound) {
|
public void setRangeFromDatesInclusive(Date theLowerBound, Date theUpperBound) {
|
||||||
myLowerBound = new QualifiedDateParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, theLowerBound);
|
if (theLowerBound != null) {
|
||||||
myUpperBound = new QualifiedDateParam(QuantityCompararatorEnum.LESSTHAN_OR_EQUALS, theUpperBound);
|
myLowerBound = new QualifiedDateParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, theLowerBound);
|
||||||
|
}
|
||||||
|
if (theUpperBound != null) {
|
||||||
|
myUpperBound = new QualifiedDateParam(QuantityCompararatorEnum.LESSTHAN_OR_EQUALS, theUpperBound);
|
||||||
|
}
|
||||||
validateAndThrowDataFormatExceptionIfInvalid();
|
validateAndThrowDataFormatExceptionIfInvalid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,8 +206,12 @@ public class DateRangeParam implements IQueryParameterAnd {
|
||||||
* "2011-02-22" or "2011-02-22T13:12:00". Will be treated inclusively.
|
* "2011-02-22" or "2011-02-22T13:12:00". Will be treated inclusively.
|
||||||
*/
|
*/
|
||||||
public void setRangeFromDatesInclusive(String theLowerBound, String theUpperBound) {
|
public void setRangeFromDatesInclusive(String theLowerBound, String theUpperBound) {
|
||||||
myLowerBound = new QualifiedDateParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, theLowerBound);
|
if (StringUtils.isNotBlank(theLowerBound)) {
|
||||||
myUpperBound = new QualifiedDateParam(QuantityCompararatorEnum.LESSTHAN_OR_EQUALS, theUpperBound);
|
myLowerBound = new QualifiedDateParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, theLowerBound);
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(theUpperBound)) {
|
||||||
|
myUpperBound = new QualifiedDateParam(QuantityCompararatorEnum.LESSTHAN_OR_EQUALS, theUpperBound);
|
||||||
|
}
|
||||||
validateAndThrowDataFormatExceptionIfInvalid();
|
validateAndThrowDataFormatExceptionIfInvalid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,8 @@ public class IdDtTest {
|
||||||
|
|
||||||
Patient actual = parseAndEncode(patient);
|
Patient actual = parseAndEncode(patient);
|
||||||
ResourceReferenceDt ref = actual.getManagingOrganization();
|
ResourceReferenceDt ref = actual.getManagingOrganization();
|
||||||
assertEquals("Organization", ref.getResourceId().getResourceType());
|
assertEquals("Organization", ref.getReference().getResourceType());
|
||||||
assertEquals("123", ref.getResourceId().getUnqualifiedId());
|
assertEquals("123", ref.getReference().getUnqualifiedId());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,9 +38,9 @@ public class IdDtTest {
|
||||||
|
|
||||||
Patient actual = parseAndEncode(patient);
|
Patient actual = parseAndEncode(patient);
|
||||||
ResourceReferenceDt ref = actual.getManagingOrganization();
|
ResourceReferenceDt ref = actual.getManagingOrganization();
|
||||||
assertEquals("Organization", ref.getResourceId().getResourceType());
|
assertEquals("Organization", ref.getReference().getResourceType());
|
||||||
assertEquals("123", ref.getResourceId().getUnqualifiedId());
|
assertEquals("123", ref.getReference().getUnqualifiedId());
|
||||||
assertEquals("999", ref.getResourceId().getUnqualifiedVersionId());
|
assertEquals("999", ref.getReference().getUnqualifiedVersionId());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,9 +53,9 @@ public class IdDtTest {
|
||||||
|
|
||||||
Patient actual = parseAndEncode(patient);
|
Patient actual = parseAndEncode(patient);
|
||||||
ResourceReferenceDt ref = actual.getManagingOrganization();
|
ResourceReferenceDt ref = actual.getManagingOrganization();
|
||||||
assertEquals(null, ref.getResourceId().getResourceType());
|
assertEquals(null, ref.getReference().getResourceType());
|
||||||
assertEquals("123", ref.getResourceId().getUnqualifiedId());
|
assertEquals("123", ref.getReference().getUnqualifiedId());
|
||||||
assertEquals("999", ref.getResourceId().getUnqualifiedVersionId());
|
assertEquals("999", ref.getReference().getUnqualifiedVersionId());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,8 +69,8 @@ public class IdDtTest {
|
||||||
|
|
||||||
Patient actual = parseAndEncode(patient);
|
Patient actual = parseAndEncode(patient);
|
||||||
ResourceReferenceDt ref = actual.getManagingOrganization();
|
ResourceReferenceDt ref = actual.getManagingOrganization();
|
||||||
assertEquals(null, ref.getResourceId().getResourceType());
|
assertEquals(null, ref.getReference().getResourceType());
|
||||||
assertEquals("123", ref.getResourceId().getUnqualifiedId());
|
assertEquals("123", ref.getReference().getUnqualifiedId());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,8 +83,8 @@ public class IdDtTest {
|
||||||
|
|
||||||
Patient actual = parseAndEncode(patient);
|
Patient actual = parseAndEncode(patient);
|
||||||
ResourceReferenceDt ref = actual.getManagingOrganization();
|
ResourceReferenceDt ref = actual.getManagingOrganization();
|
||||||
assertEquals(null, ref.getResourceId().getResourceType());
|
assertEquals(null, ref.getReference().getResourceType());
|
||||||
assertEquals("123", ref.getResourceId().getUnqualifiedId());
|
assertEquals("123", ref.getReference().getUnqualifiedId());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,8 +97,8 @@ public class IdDtTest {
|
||||||
|
|
||||||
Patient actual = parseAndEncode(patient);
|
Patient actual = parseAndEncode(patient);
|
||||||
ResourceReferenceDt ref = actual.getManagingOrganization();
|
ResourceReferenceDt ref = actual.getManagingOrganization();
|
||||||
assertEquals("Organization", ref.getResourceId().getResourceType());
|
assertEquals("Organization", ref.getReference().getResourceType());
|
||||||
assertEquals("123", ref.getResourceId().getUnqualifiedId());
|
assertEquals("123", ref.getReference().getUnqualifiedId());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,8 +111,8 @@ public class IdDtTest {
|
||||||
|
|
||||||
Patient actual = parseAndEncode(patient);
|
Patient actual = parseAndEncode(patient);
|
||||||
ResourceReferenceDt ref = actual.getManagingOrganization();
|
ResourceReferenceDt ref = actual.getManagingOrganization();
|
||||||
assertEquals("Organization", ref.getResourceId().getResourceType());
|
assertEquals("Organization", ref.getReference().getResourceType());
|
||||||
assertEquals("123", ref.getResourceId().getUnqualifiedId());
|
assertEquals("123", ref.getReference().getUnqualifiedId());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -347,7 +347,7 @@ public class JsonParserTest {
|
||||||
MyPatientWithOneDeclaredExtension actual = parser.parseResource(MyPatientWithOneDeclaredExtension.class, val);
|
MyPatientWithOneDeclaredExtension actual = parser.parseResource(MyPatientWithOneDeclaredExtension.class, val);
|
||||||
assertEquals(AddressUseEnum.HOME, patient.getAddressFirstRep().getUse().getValueAsEnum());
|
assertEquals(AddressUseEnum.HOME, patient.getAddressFirstRep().getUse().getValueAsEnum());
|
||||||
ResourceReferenceDt ref = actual.getFoo();
|
ResourceReferenceDt ref = actual.getFoo();
|
||||||
assertEquals("Organization/123", ref.getResourceId().getValue());
|
assertEquals("Organization/123", ref.getReference().getValue());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,7 +400,7 @@ public class JsonParserTest {
|
||||||
try {
|
try {
|
||||||
p.encodeResourceToString(obs);
|
p.encodeResourceToString(obs);
|
||||||
} catch (DataFormatException e) {
|
} catch (DataFormatException e) {
|
||||||
assertThat(e.getMessage(), StringContains.containsString("PeriodDt"));
|
assertThat(e.getMessage(), StringContains.containsString("DecimalDt"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -420,7 +420,7 @@ public class XmlParserTest {
|
||||||
try {
|
try {
|
||||||
p.encodeResourceToString(obs);
|
p.encodeResourceToString(obs);
|
||||||
} catch (DataFormatException e) {
|
} catch (DataFormatException e) {
|
||||||
assertThat(e.getMessage(), StringContains.containsString("PeriodDt"));
|
assertThat(e.getMessage(), StringContains.containsString("DecimalDt"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package ca.uhn.fhir.jpa.dao;
|
package ca.uhn.fhir.jpa.dao;
|
||||||
|
|
||||||
import static org.apache.commons.lang3.StringUtils.*;
|
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||||
|
|
||||||
import java.text.Normalizer;
|
import java.text.Normalizer;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -57,6 +57,7 @@ import ca.uhn.fhir.model.dstu.composite.CodingDt;
|
||||||
import ca.uhn.fhir.model.dstu.composite.ContactDt;
|
import ca.uhn.fhir.model.dstu.composite.ContactDt;
|
||||||
import ca.uhn.fhir.model.dstu.composite.HumanNameDt;
|
import ca.uhn.fhir.model.dstu.composite.HumanNameDt;
|
||||||
import ca.uhn.fhir.model.dstu.composite.IdentifierDt;
|
import ca.uhn.fhir.model.dstu.composite.IdentifierDt;
|
||||||
|
import ca.uhn.fhir.model.dstu.composite.PeriodDt;
|
||||||
import ca.uhn.fhir.model.dstu.composite.QuantityDt;
|
import ca.uhn.fhir.model.dstu.composite.QuantityDt;
|
||||||
import ca.uhn.fhir.model.dstu.composite.ResourceReferenceDt;
|
import ca.uhn.fhir.model.dstu.composite.ResourceReferenceDt;
|
||||||
import ca.uhn.fhir.model.dstu.valueset.SearchParamTypeEnum;
|
import ca.uhn.fhir.model.dstu.valueset.SearchParamTypeEnum;
|
||||||
|
@ -74,13 +75,14 @@ import com.google.common.collect.Lists;
|
||||||
|
|
||||||
public abstract class BaseFhirDao {
|
public abstract class BaseFhirDao {
|
||||||
private FhirContext myContext = new FhirContext();
|
private FhirContext myContext = new FhirContext();
|
||||||
|
|
||||||
@PersistenceContext(name = "FHIR_UT", type = PersistenceContextType.TRANSACTION, unitName = "FHIR_UT")
|
@PersistenceContext(name = "FHIR_UT", type = PersistenceContextType.TRANSACTION, unitName = "FHIR_UT")
|
||||||
private EntityManager myEntityManager;
|
private EntityManager myEntityManager;
|
||||||
@Autowired
|
@Autowired
|
||||||
private List<IFhirResourceDao<?>> myResourceDaos;
|
private List<IFhirResourceDao<?>> myResourceDaos;
|
||||||
|
|
||||||
private Map<Class<? extends IResource>, IFhirResourceDao<?>> myResourceTypeToDao;
|
private Map<Class<? extends IResource>, IFhirResourceDao<?>> myResourceTypeToDao;
|
||||||
|
|
||||||
public FhirContext getContext() {
|
public FhirContext getContext() {
|
||||||
return myContext;
|
return myContext;
|
||||||
}
|
}
|
||||||
|
@ -195,6 +197,8 @@ public abstract class BaseFhirDao {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseFhirDao.class);
|
||||||
|
|
||||||
private void searchHistoryHistory(List<HistoryTuple> theTuples, List<BaseHasResource> theRetVal) {
|
private void searchHistoryHistory(List<HistoryTuple> theTuples, List<BaseHasResource> theRetVal) {
|
||||||
Collection<HistoryTuple> tuples = Collections2.filter(theTuples, new com.google.common.base.Predicate<HistoryTuple>() {
|
Collection<HistoryTuple> tuples = Collections2.filter(theTuples, new com.google.common.base.Predicate<HistoryTuple>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -211,6 +215,8 @@ public abstract class BaseFhirDao {
|
||||||
if (ids.isEmpty()) {
|
if (ids.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ourLog.info("Retrieving {} history elements from ResourceHistoryTable", ids.size());
|
||||||
|
|
||||||
CriteriaBuilder builder = myEntityManager.getCriteriaBuilder();
|
CriteriaBuilder builder = myEntityManager.getCriteriaBuilder();
|
||||||
CriteriaQuery<ResourceHistoryTable> cq = builder.createQuery(ResourceHistoryTable.class);
|
CriteriaQuery<ResourceHistoryTable> cq = builder.createQuery(ResourceHistoryTable.class);
|
||||||
|
@ -258,19 +264,19 @@ public abstract class BaseFhirDao {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
String typeString = nextValue.getResourceId().getResourceType();
|
String typeString = nextValue.getReference().getResourceType();
|
||||||
if (isBlank(typeString)) {
|
if (isBlank(typeString)) {
|
||||||
throw new InvalidRequestException("Invalid resource reference found at path[" + nextPath + "] - Does not contain resource type - " + nextValue.getReference().getValue());
|
throw new InvalidRequestException("Invalid resource reference found at path[" + nextPath + "] - Does not contain resource type - " + nextValue.getReference().getValue());
|
||||||
}
|
}
|
||||||
Class<? extends IResource> type = getContext().getResourceDefinition(typeString).getImplementingClass();
|
Class<? extends IResource> type = getContext().getResourceDefinition(typeString).getImplementingClass();
|
||||||
String id = nextValue.getResourceId().getUnqualifiedId();
|
String id = nextValue.getReference().getUnqualifiedId();
|
||||||
if (StringUtils.isBlank(id)) {
|
if (StringUtils.isBlank(id)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
IFhirResourceDao<?> dao = getDao(type);
|
IFhirResourceDao<?> dao = getDao(type);
|
||||||
if (dao == null) {
|
if (dao == null) {
|
||||||
throw new InvalidRequestException("This server is not able to handle resources of type: " + nextValue.getResourceId().getResourceType());
|
throw new InvalidRequestException("This server is not able to handle resources of type: " + nextValue.getReference().getResourceType());
|
||||||
}
|
}
|
||||||
Long valueOf;
|
Long valueOf;
|
||||||
try {
|
try {
|
||||||
|
@ -333,6 +339,12 @@ public abstract class BaseFhirDao {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
nextEntity = new ResourceIndexedSearchParamDate(nextSpDef.getName(), nextValue.getValue(), nextValue.getValue());
|
nextEntity = new ResourceIndexedSearchParamDate(nextSpDef.getName(), nextValue.getValue(), nextValue.getValue());
|
||||||
|
} else if (nextObject instanceof PeriodDt) {
|
||||||
|
PeriodDt nextValue = (PeriodDt) nextObject;
|
||||||
|
if (nextValue.isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
nextEntity = new ResourceIndexedSearchParamDate(nextSpDef.getName(), nextValue.getStart().getValue(), nextValue.getEnd().getValue());
|
||||||
} else {
|
} else {
|
||||||
if (!multiType) {
|
if (!multiType) {
|
||||||
throw new ConfigurationException("Search param " + nextSpDef.getName() + " is of unexpected datatype: " + nextObject.getClass());
|
throw new ConfigurationException("Search param " + nextSpDef.getName() + " is of unexpected datatype: " + nextObject.getClass());
|
||||||
|
@ -377,7 +389,8 @@ public abstract class BaseFhirDao {
|
||||||
|
|
||||||
if (nextObject instanceof QuantityDt) {
|
if (nextObject instanceof QuantityDt) {
|
||||||
QuantityDt nextValue = (QuantityDt) nextObject;
|
QuantityDt nextValue = (QuantityDt) nextObject;
|
||||||
ResourceIndexedSearchParamNumber nextEntity = new ResourceIndexedSearchParamNumber(resourceName, nextValue.getValue().getValue(), nextValue.getSystem().getValueAsString(), nextValue.getUnits().getValue());
|
ResourceIndexedSearchParamNumber nextEntity = new ResourceIndexedSearchParamNumber(resourceName, nextValue.getValue().getValue(), nextValue.getSystem().getValueAsString(),
|
||||||
|
nextValue.getUnits().getValue());
|
||||||
nextEntity.setResource(theEntity);
|
nextEntity.setResource(theEntity);
|
||||||
retVal.add(nextEntity);
|
retVal.add(nextEntity);
|
||||||
} else {
|
} else {
|
||||||
|
@ -460,7 +473,8 @@ public abstract class BaseFhirDao {
|
||||||
} else if (nextObject instanceof ContactDt) {
|
} else if (nextObject instanceof ContactDt) {
|
||||||
ContactDt nextContact = (ContactDt) nextObject;
|
ContactDt nextContact = (ContactDt) nextObject;
|
||||||
if (nextContact.getValue().isEmpty() == false) {
|
if (nextContact.getValue().isEmpty() == false) {
|
||||||
ResourceIndexedSearchParamString nextEntity = new ResourceIndexedSearchParamString(resourceName, normalizeString(nextContact.getValue().getValueAsString()), nextContact.getValue().getValueAsString());
|
ResourceIndexedSearchParamString nextEntity = new ResourceIndexedSearchParamString(resourceName, normalizeString(nextContact.getValue().getValueAsString()), nextContact
|
||||||
|
.getValue().getValueAsString());
|
||||||
nextEntity.setResource(theEntity);
|
nextEntity.setResource(theEntity);
|
||||||
retVal.add(nextEntity);
|
retVal.add(nextEntity);
|
||||||
}
|
}
|
||||||
|
@ -549,12 +563,12 @@ public abstract class BaseFhirDao {
|
||||||
for (IFhirResourceDao<?> next : myResourceDaos) {
|
for (IFhirResourceDao<?> next : myResourceDaos) {
|
||||||
myResourceTypeToDao.put(next.getResourceType(), next);
|
myResourceTypeToDao.put(next.getResourceType(), next);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this instanceof IFhirResourceDao<?>) {
|
if (this instanceof IFhirResourceDao<?>) {
|
||||||
IFhirResourceDao<?> thiz = (IFhirResourceDao<?>) this;
|
IFhirResourceDao<?> thiz = (IFhirResourceDao<?>) this;
|
||||||
myResourceTypeToDao.put(thiz.getResourceType(), thiz);
|
myResourceTypeToDao.put(thiz.getResourceType(), thiz);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return myResourceTypeToDao.get(theType);
|
return myResourceTypeToDao.get(theType);
|
||||||
|
@ -685,11 +699,11 @@ public abstract class BaseFhirDao {
|
||||||
protected String toResourceName(IResource theResource) {
|
protected String toResourceName(IResource theResource) {
|
||||||
return myContext.getResourceDefinition(theResource).getName();
|
return myContext.getResourceDefinition(theResource).getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String toResourceName(Class<? extends IResource> theResourceType) {
|
protected String toResourceName(Class<? extends IResource> theResourceType) {
|
||||||
return myContext.getResourceDefinition(theResourceType).getName();
|
return myContext.getResourceDefinition(theResourceType).getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected ResourceTable updateEntity(final IResource theResource, ResourceTable entity, boolean theUpdateHistory) {
|
protected ResourceTable updateEntity(final IResource theResource, ResourceTable entity, boolean theUpdateHistory) {
|
||||||
if (entity.getPublished() == null) {
|
if (entity.getPublished() == null) {
|
||||||
entity.setPublished(new Date());
|
entity.setPublished(new Date());
|
||||||
|
@ -702,6 +716,12 @@ public abstract class BaseFhirDao {
|
||||||
|
|
||||||
entity.setVersion(entity.getVersion() + 1);
|
entity.setVersion(entity.getVersion() + 1);
|
||||||
|
|
||||||
|
Collection<ResourceIndexedSearchParamString> paramsString = new ArrayList<ResourceIndexedSearchParamString>(entity.getParamsString());
|
||||||
|
Collection<ResourceIndexedSearchParamToken> paramsToken = new ArrayList<ResourceIndexedSearchParamToken>(entity.getParamsToken());
|
||||||
|
Collection<ResourceIndexedSearchParamNumber> paramsNumber = new ArrayList<ResourceIndexedSearchParamNumber>(entity.getParamsNumber());
|
||||||
|
Collection<ResourceIndexedSearchParamDate> paramsDate = new ArrayList<ResourceIndexedSearchParamDate>(entity.getParamsDate());
|
||||||
|
Collection<ResourceLink> resourceLinks = new ArrayList<ResourceLink>(entity.getResourceLinks());
|
||||||
|
|
||||||
final List<ResourceIndexedSearchParamString> stringParams = extractSearchParamStrings(entity, theResource);
|
final List<ResourceIndexedSearchParamString> stringParams = extractSearchParamStrings(entity, theResource);
|
||||||
final List<ResourceIndexedSearchParamToken> tokenParams = extractSearchParamTokens(entity, theResource);
|
final List<ResourceIndexedSearchParamToken> tokenParams = extractSearchParamTokens(entity, theResource);
|
||||||
final List<ResourceIndexedSearchParamNumber> numberParams = extractSearchParamNumber(entity, theResource);
|
final List<ResourceIndexedSearchParamNumber> numberParams = extractSearchParamNumber(entity, theResource);
|
||||||
|
@ -711,6 +731,16 @@ public abstract class BaseFhirDao {
|
||||||
populateResourceIntoEntity(theResource, entity);
|
populateResourceIntoEntity(theResource, entity);
|
||||||
|
|
||||||
entity.setUpdated(new Date());
|
entity.setUpdated(new Date());
|
||||||
|
entity.setParamsString(stringParams);
|
||||||
|
entity.setParamsStringPopulated(stringParams.isEmpty()==false);
|
||||||
|
entity.setParamsToken(tokenParams);
|
||||||
|
entity.setParamsTokenPopulated(tokenParams.isEmpty()==false);
|
||||||
|
entity.setParamsNumber(numberParams);
|
||||||
|
entity.setParamsNumberPopulated(numberParams.isEmpty()==false);
|
||||||
|
entity.setParamsDate(dateParams);
|
||||||
|
entity.setParamsDatePopulated(dateParams.isEmpty()==false);
|
||||||
|
entity.setResourceLinks(links);
|
||||||
|
entity.setHasLinks(links.isEmpty()==false);
|
||||||
|
|
||||||
if (entity.getId() == null) {
|
if (entity.getId() == null) {
|
||||||
myEntityManager.persist(entity);
|
myEntityManager.persist(entity);
|
||||||
|
@ -719,16 +749,16 @@ public abstract class BaseFhirDao {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity.isParamsStringPopulated()) {
|
if (entity.isParamsStringPopulated()) {
|
||||||
for (ResourceIndexedSearchParamString next : entity.getParamsString()) {
|
for (ResourceIndexedSearchParamString next : paramsString) {
|
||||||
myEntityManager.remove(next);
|
myEntityManager.remove(next);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (ResourceIndexedSearchParamString next : stringParams) {
|
for (ResourceIndexedSearchParamString next : stringParams) {
|
||||||
myEntityManager.persist(next);
|
myEntityManager.persist(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity.isParamsTokenPopulated()) {
|
if (entity.isParamsTokenPopulated()) {
|
||||||
for (ResourceIndexedSearchParamToken next : entity.getParamsToken()) {
|
for (ResourceIndexedSearchParamToken next : paramsToken) {
|
||||||
myEntityManager.remove(next);
|
myEntityManager.remove(next);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -737,7 +767,7 @@ public abstract class BaseFhirDao {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity.isParamsNumberPopulated()) {
|
if (entity.isParamsNumberPopulated()) {
|
||||||
for (ResourceIndexedSearchParamNumber next : entity.getParamsNumber()) {
|
for (ResourceIndexedSearchParamNumber next : paramsNumber) {
|
||||||
myEntityManager.remove(next);
|
myEntityManager.remove(next);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -746,7 +776,7 @@ public abstract class BaseFhirDao {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity.isParamsDatePopulated()) {
|
if (entity.isParamsDatePopulated()) {
|
||||||
for (ResourceIndexedSearchParamDate next : entity.getParamsDate()) {
|
for (ResourceIndexedSearchParamDate next : paramsDate) {
|
||||||
myEntityManager.remove(next);
|
myEntityManager.remove(next);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -755,14 +785,14 @@ public abstract class BaseFhirDao {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity.isHasLinks()) {
|
if (entity.isHasLinks()) {
|
||||||
for (ResourceLink next : entity.getResourceLinks()) {
|
for (ResourceLink next : resourceLinks) {
|
||||||
myEntityManager.remove(next);
|
myEntityManager.remove(next);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (ResourceLink next : links) {
|
for (ResourceLink next : links) {
|
||||||
myEntityManager.persist(next);
|
myEntityManager.persist(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
myEntityManager.flush();
|
myEntityManager.flush();
|
||||||
theResource.setId(new IdDt(entity.getResourceType(), entity.getId().toString(), Long.toString(entity.getVersion())));
|
theResource.setId(new IdDt(entity.getResourceType(), entity.getId().toString(), Long.toString(entity.getVersion())));
|
||||||
|
|
||||||
|
@ -770,7 +800,7 @@ public abstract class BaseFhirDao {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected TagList getTags(Class<? extends IResource> theResourceType, IdDt theResourceId) {
|
protected TagList getTags(Class<? extends IResource> theResourceType, IdDt theResourceId) {
|
||||||
String resourceName=null;
|
String resourceName = null;
|
||||||
if (theResourceType != null) {
|
if (theResourceType != null) {
|
||||||
resourceName = toResourceName(theResourceType);
|
resourceName = toResourceName(theResourceType);
|
||||||
if (theResourceId != null && theResourceId.hasUnqualifiedVersionId()) {
|
if (theResourceId != null && theResourceId.hasUnqualifiedVersionId()) {
|
||||||
|
@ -783,7 +813,7 @@ public abstract class BaseFhirDao {
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<Long> tagIds = new HashSet<Long>();
|
Set<Long> tagIds = new HashSet<Long>();
|
||||||
findMatchingTagIds(resourceName, theResourceId, tagIds, ResourceTag.class);
|
findMatchingTagIds(resourceName, theResourceId, tagIds, ResourceTag.class);
|
||||||
findMatchingTagIds(resourceName, theResourceId, tagIds, ResourceHistoryTag.class);
|
findMatchingTagIds(resourceName, theResourceId, tagIds, ResourceHistoryTag.class);
|
||||||
|
|
|
@ -67,299 +67,15 @@ public class FhirResourceDao<T extends IResource> extends BaseFhirDao implements
|
||||||
|
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDao.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDao.class);
|
||||||
|
|
||||||
// name = "FHIR_UT", type = PersistenceContextType.TRANSACTION, unitName = "FHIR_UT"
|
|
||||||
@PersistenceContext()
|
@PersistenceContext()
|
||||||
private EntityManager myEntityManager;
|
private EntityManager myEntityManager;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private PlatformTransactionManager myPlatformTransactionManager;
|
private PlatformTransactionManager myPlatformTransactionManager;
|
||||||
|
|
||||||
private String myResourceName;
|
private String myResourceName;
|
||||||
private Class<T> myResourceType;
|
private Class<T> myResourceType;
|
||||||
|
private String mySecondaryPrimaryKeyParamName;
|
||||||
@Override
|
|
||||||
public void addTag(IdDt theId, String theScheme, String theTerm, String theLabel) {
|
|
||||||
BaseHasResource entity = readEntity(theId);
|
|
||||||
if (entity == null) {
|
|
||||||
throw new ResourceNotFoundException(theId);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (BaseTag next : new ArrayList<BaseTag>(entity.getTags())) {
|
|
||||||
if (next.getTag().getScheme().equals(theScheme) && next.getTag().getTerm().equals(theTerm)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TagDefinition def = getTag(theScheme, theTerm, theLabel);
|
|
||||||
BaseTag newEntity = entity.addTag(def);
|
|
||||||
|
|
||||||
myEntityManager.persist(newEntity);
|
|
||||||
myEntityManager.merge(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MethodOutcome create(final T theResource) {
|
|
||||||
ResourceTable entity = new ResourceTable();
|
|
||||||
entity.setResourceType(toResourceName(theResource));
|
|
||||||
|
|
||||||
updateEntity(theResource, entity, false);
|
|
||||||
|
|
||||||
MethodOutcome outcome = toMethodOutcome(entity);
|
|
||||||
return outcome;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TagList getAllResourceTags() {
|
|
||||||
return super.getTags(myResourceType, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Class<T> getResourceType() {
|
|
||||||
return myResourceType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TagList getTags(IdDt theResourceId) {
|
|
||||||
return super.getTags(myResourceType, theResourceId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<T> history() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IResource> history(Date theSince, Integer theLimit) {
|
|
||||||
return super.history(myResourceName, null, theSince, theLimit);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<T> history(IdDt theId) {
|
|
||||||
ArrayList<T> retVal = new ArrayList<T>();
|
|
||||||
|
|
||||||
String resourceType = getContext().getResourceDefinition(myResourceType).getName();
|
|
||||||
TypedQuery<ResourceHistoryTable> q = myEntityManager.createQuery(ResourceHistoryTable.Q_GETALL, ResourceHistoryTable.class);
|
|
||||||
q.setParameter("PID", theId.asLong());
|
|
||||||
q.setParameter("RESTYPE", resourceType);
|
|
||||||
|
|
||||||
// TypedQuery<ResourceHistoryTable> query =
|
|
||||||
// myEntityManager.createQuery(criteriaQuery);
|
|
||||||
List<ResourceHistoryTable> results = q.getResultList();
|
|
||||||
for (ResourceHistoryTable next : results) {
|
|
||||||
retVal.add(toResource(myResourceType, next));
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
retVal.add(read(theId.withoutVersion()));
|
|
||||||
} catch (ResourceNotFoundException e) {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
|
|
||||||
if (retVal.isEmpty()) {
|
|
||||||
throw new ResourceNotFoundException(theId);
|
|
||||||
}
|
|
||||||
|
|
||||||
return retVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IResource> history(Long theId, Date theSince, Integer theLimit) {
|
|
||||||
return super.history(myResourceName, theId, theSince, theLimit);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostConstruct
|
|
||||||
public void postConstruct() {
|
|
||||||
myResourceName = getContext().getResourceDefinition(myResourceType).getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public T read(IdDt theId) {
|
|
||||||
BaseHasResource entity = readEntity(theId);
|
|
||||||
|
|
||||||
T retVal = toResource(myResourceType, entity);
|
|
||||||
return retVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BaseHasResource readEntity(IdDt theId) {
|
|
||||||
BaseHasResource entity = myEntityManager.find(ResourceTable.class, theId.asLong());
|
|
||||||
if (theId.hasUnqualifiedVersionId()) {
|
|
||||||
if (entity.getVersion() != theId.getUnqualifiedVersionIdAsLong()) {
|
|
||||||
entity = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (entity == null) {
|
|
||||||
if (theId.hasUnqualifiedVersionId()) {
|
|
||||||
entity = myEntityManager.find(ResourceHistoryTable.class, new ResourceHistoryTablePk(myResourceName, theId.asLong(), theId.getUnqualifiedVersionIdAsLong()));
|
|
||||||
}
|
|
||||||
if (entity == null) {
|
|
||||||
throw new ResourceNotFoundException(theId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return entity;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeTag(IdDt theId, String theScheme, String theTerm) {
|
|
||||||
BaseHasResource entity = readEntity(theId);
|
|
||||||
if (entity == null) {
|
|
||||||
throw new ResourceNotFoundException(theId);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (BaseTag next : new ArrayList<BaseTag>(entity.getTags())) {
|
|
||||||
if (next.getTag().getScheme().equals(theScheme) && next.getTag().getTerm().equals(theTerm)) {
|
|
||||||
myEntityManager.remove(next);
|
|
||||||
entity.getTags().remove(next);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
myEntityManager.merge(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<T> search(Map<String, IQueryParameterType> theParams) {
|
|
||||||
SearchParameterMap map = new SearchParameterMap();
|
|
||||||
for (Entry<String, IQueryParameterType> nextEntry : theParams.entrySet()) {
|
|
||||||
map.put(nextEntry.getKey(), new ArrayList<List<IQueryParameterType>>());
|
|
||||||
map.get(nextEntry.getKey()).add(Collections.singletonList(nextEntry.getValue()));
|
|
||||||
}
|
|
||||||
return search(map);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<T> search(SearchParameterMap theParams) {
|
|
||||||
|
|
||||||
Set<Long> pids;
|
|
||||||
if (theParams.isEmpty()) {
|
|
||||||
pids = null;
|
|
||||||
} else {
|
|
||||||
pids = searchForIdsWithAndOr(theParams);
|
|
||||||
if (pids.isEmpty()) {
|
|
||||||
return new ArrayList<T>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Execute the query and make sure we return distinct results
|
|
||||||
{
|
|
||||||
CriteriaBuilder builder = myEntityManager.getCriteriaBuilder();
|
|
||||||
CriteriaQuery<ResourceTable> cq = builder.createQuery(ResourceTable.class);
|
|
||||||
Root<ResourceTable> from = cq.from(ResourceTable.class);
|
|
||||||
cq.where(builder.equal(from.get("myResourceType"), getContext().getResourceDefinition(myResourceType).getName()));
|
|
||||||
if (!theParams.isEmpty()) {
|
|
||||||
cq.where(from.get("myId").in(pids));
|
|
||||||
}
|
|
||||||
TypedQuery<ResourceTable> q = myEntityManager.createQuery(cq);
|
|
||||||
|
|
||||||
List<T> retVal = new ArrayList<T>();
|
|
||||||
for (ResourceTable next : q.getResultList()) {
|
|
||||||
T resource = toResource(myResourceType, next);
|
|
||||||
retVal.add(resource);
|
|
||||||
}
|
|
||||||
return retVal;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<T> search(String theParameterName, IQueryParameterType theValue) {
|
|
||||||
return search(Collections.singletonMap(theParameterName, theValue));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<Long> searchForIds(Map<String, IQueryParameterType> theParams) {
|
|
||||||
Map<String, List<List<IQueryParameterType>>> map = new HashMap<String, List<List<IQueryParameterType>>>();
|
|
||||||
for (Entry<String, IQueryParameterType> nextEntry : theParams.entrySet()) {
|
|
||||||
map.put(nextEntry.getKey(), new ArrayList<List<IQueryParameterType>>());
|
|
||||||
map.get(nextEntry.getKey()).add(Collections.singletonList(nextEntry.getValue()));
|
|
||||||
}
|
|
||||||
return searchForIdsWithAndOr(map);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<Long> searchForIds(String theParameterName, IQueryParameterType theValue) {
|
|
||||||
return searchForIds(Collections.singletonMap(theParameterName, theValue));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<Long> searchForIdsWithAndOr(Map<String, List<List<IQueryParameterType>>> theParams) {
|
|
||||||
Map<String, List<List<IQueryParameterType>>> params = theParams;
|
|
||||||
if (params == null) {
|
|
||||||
params = Collections.emptyMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
RuntimeResourceDefinition resourceDef = getContext().getResourceDefinition(myResourceType);
|
|
||||||
|
|
||||||
Set<Long> pids = new HashSet<Long>();
|
|
||||||
|
|
||||||
for (Entry<String, List<List<IQueryParameterType>>> nextParamEntry : params.entrySet()) {
|
|
||||||
String nextParamName = nextParamEntry.getKey();
|
|
||||||
RuntimeSearchParam nextParamDef = resourceDef.getSearchParam(nextParamName);
|
|
||||||
if (nextParamDef != null) {
|
|
||||||
if (nextParamDef.getParamType() == SearchParamTypeEnum.TOKEN) {
|
|
||||||
for (List<IQueryParameterType> nextAnd : nextParamEntry.getValue()) {
|
|
||||||
pids = addPredicateToken(pids, nextAnd);
|
|
||||||
if (pids.isEmpty()) {
|
|
||||||
return new HashSet<Long>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (nextParamDef.getParamType() == SearchParamTypeEnum.STRING) {
|
|
||||||
for (List<IQueryParameterType> nextAnd : nextParamEntry.getValue()) {
|
|
||||||
pids = addPredicateString(pids, nextAnd);
|
|
||||||
if (pids.isEmpty()) {
|
|
||||||
return new HashSet<Long>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (nextParamDef.getParamType() == SearchParamTypeEnum.QUANTITY) {
|
|
||||||
for (List<IQueryParameterType> nextAnd : nextParamEntry.getValue()) {
|
|
||||||
pids = addPredicateQuantity(pids, nextAnd);
|
|
||||||
if (pids.isEmpty()) {
|
|
||||||
return new HashSet<Long>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (nextParamDef.getParamType() == SearchParamTypeEnum.DATE) {
|
|
||||||
for (List<IQueryParameterType> nextAnd : nextParamEntry.getValue()) {
|
|
||||||
pids = addPredicateDate(pids, nextAnd);
|
|
||||||
if (pids.isEmpty()) {
|
|
||||||
return new HashSet<Long>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (nextParamDef.getParamType() == SearchParamTypeEnum.REFERENCE) {
|
|
||||||
for (List<IQueryParameterType> nextAnd : nextParamEntry.getValue()) {
|
|
||||||
pids = addPredicateReference(nextParamName, pids, nextAnd);
|
|
||||||
if (pids.isEmpty()) {
|
|
||||||
return new HashSet<Long>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw new IllegalArgumentException("Don't know how to handle parameter of type: " + nextParamDef.getParamType());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return pids;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Required
|
|
||||||
public void setResourceType(Class<? extends IResource> theTableType) {
|
|
||||||
myResourceType = (Class<T>) theTableType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MethodOutcome update(final T theResource, final IdDt theId) {
|
|
||||||
|
|
||||||
// TransactionTemplate template = new TransactionTemplate(myPlatformTransactionManager);
|
|
||||||
// ResourceTable savedEntity = template.execute(new TransactionCallback<ResourceTable>() {
|
|
||||||
// @Override
|
|
||||||
// public ResourceTable doInTransaction(TransactionStatus theStatus) {
|
|
||||||
// final ResourceTable entity = readEntity(theId);
|
|
||||||
// return updateEntity(theResource, entity,true);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
final ResourceTable entity = readEntityLatestVersion(theId);
|
|
||||||
ResourceTable savedEntity = updateEntity(theResource, entity, true);
|
|
||||||
|
|
||||||
return toMethodOutcome(savedEntity);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Set<Long> addPredicateDate(Set<Long> thePids, List<IQueryParameterType> theOrParams) {
|
private Set<Long> addPredicateDate(Set<Long> thePids, List<IQueryParameterType> theOrParams) {
|
||||||
if (theOrParams == null || theOrParams.isEmpty()) {
|
if (theOrParams == null || theOrParams.isEmpty()) {
|
||||||
|
@ -403,21 +119,42 @@ public class FhirResourceDao<T extends IResource> extends BaseFhirDao implements
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addPredicateDateFromRange(CriteriaBuilder builder, Root<ResourceIndexedSearchParamDate> from, List<Predicate> codePredicates, DateRangeParam range) {
|
private void addPredicateDateFromRange(CriteriaBuilder builder, Root<ResourceIndexedSearchParamDate> from, List<Predicate> codePredicates, DateRangeParam range) {
|
||||||
Predicate singleCode;
|
|
||||||
Date lowerBound = range.getLowerBoundAsInstant();
|
Date lowerBound = range.getLowerBoundAsInstant();
|
||||||
Date upperBound = range.getUpperBoundAsInstant();
|
Date upperBound = range.getUpperBoundAsInstant();
|
||||||
|
|
||||||
if (lowerBound != null && upperBound != null) {
|
Predicate lb = null;
|
||||||
Predicate low = builder.greaterThanOrEqualTo(from.<Date> get("myValueLow"), lowerBound);
|
if (lowerBound != null) {
|
||||||
Predicate high = builder.lessThanOrEqualTo(from.<Date> get("myValueHigh"), upperBound);
|
Predicate gt = builder.greaterThanOrEqualTo(from.<Date> get("myValueLow"), lowerBound);
|
||||||
singleCode = builder.and(low, high);
|
Predicate gin = builder.isNull(from.get("myValueLow"));
|
||||||
} else if (lowerBound != null) {
|
Predicate lbo = builder.or(gt, gin);
|
||||||
singleCode = builder.greaterThanOrEqualTo(from.<Date> get("myValueLow"), lowerBound);
|
|
||||||
} else {
|
Predicate lt = builder.greaterThanOrEqualTo(from.<Date> get("myValueHigh"), lowerBound);
|
||||||
singleCode = builder.lessThanOrEqualTo(from.<Date> get("myValueHigh"), upperBound);
|
Predicate lin = builder.isNull(from.get("myValueHigh"));
|
||||||
|
Predicate hbo = builder.or(lt, lin);
|
||||||
|
|
||||||
|
lb = builder.and(lbo, hbo);
|
||||||
}
|
}
|
||||||
|
|
||||||
codePredicates.add(singleCode);
|
Predicate ub = null;
|
||||||
|
if (upperBound != null) {
|
||||||
|
Predicate gt = builder.lessThanOrEqualTo(from.<Date> get("myValueLow"), upperBound);
|
||||||
|
Predicate gin = builder.isNull(from.get("myValueLow"));
|
||||||
|
Predicate lbo = builder.or(gt, gin);
|
||||||
|
|
||||||
|
Predicate lt = builder.lessThanOrEqualTo(from.<Date> get("myValueHigh"), upperBound);
|
||||||
|
Predicate lin = builder.isNull(from.get("myValueHigh"));
|
||||||
|
Predicate ubo = builder.or(lt, lin);
|
||||||
|
|
||||||
|
ub = builder.and(ubo, lbo);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lb != null && ub != null) {
|
||||||
|
codePredicates.add(builder.and(lb, ub));
|
||||||
|
} else if (lb != null) {
|
||||||
|
codePredicates.add(lb);
|
||||||
|
} else {
|
||||||
|
codePredicates.add(ub);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<Long> addPredicateQuantity(Set<Long> thePids, List<IQueryParameterType> theOrParams) {
|
private Set<Long> addPredicateQuantity(Set<Long> thePids, List<IQueryParameterType> theOrParams) {
|
||||||
|
@ -696,6 +433,140 @@ public class FhirResourceDao<T extends IResource> extends BaseFhirDao implements
|
||||||
return new HashSet<Long>(q.getResultList());
|
return new HashSet<Long>(q.getResultList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addTag(IdDt theId, String theScheme, String theTerm, String theLabel) {
|
||||||
|
BaseHasResource entity = readEntity(theId);
|
||||||
|
if (entity == null) {
|
||||||
|
throw new ResourceNotFoundException(theId);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (BaseTag next : new ArrayList<BaseTag>(entity.getTags())) {
|
||||||
|
if (next.getTag().getScheme().equals(theScheme) && next.getTag().getTerm().equals(theTerm)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TagDefinition def = getTag(theScheme, theTerm, theLabel);
|
||||||
|
BaseTag newEntity = entity.addTag(def);
|
||||||
|
|
||||||
|
myEntityManager.persist(newEntity);
|
||||||
|
myEntityManager.merge(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MethodOutcome create(final T theResource) {
|
||||||
|
ResourceTable entity = new ResourceTable();
|
||||||
|
entity.setResourceType(toResourceName(theResource));
|
||||||
|
|
||||||
|
updateEntity(theResource, entity, false);
|
||||||
|
|
||||||
|
MethodOutcome outcome = toMethodOutcome(entity);
|
||||||
|
return outcome;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TagList getAllResourceTags() {
|
||||||
|
return super.getTags(myResourceType, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Class<T> getResourceType() {
|
||||||
|
return myResourceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TagList getTags(IdDt theResourceId) {
|
||||||
|
return super.getTags(myResourceType, theResourceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<T> history() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<IResource> history(Date theSince, Integer theLimit) {
|
||||||
|
return super.history(myResourceName, null, theSince, theLimit);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<T> history(IdDt theId) {
|
||||||
|
ArrayList<T> retVal = new ArrayList<T>();
|
||||||
|
|
||||||
|
String resourceType = getContext().getResourceDefinition(myResourceType).getName();
|
||||||
|
TypedQuery<ResourceHistoryTable> q = myEntityManager.createQuery(ResourceHistoryTable.Q_GETALL, ResourceHistoryTable.class);
|
||||||
|
q.setParameter("PID", theId.asLong());
|
||||||
|
q.setParameter("RESTYPE", resourceType);
|
||||||
|
|
||||||
|
// TypedQuery<ResourceHistoryTable> query =
|
||||||
|
// myEntityManager.createQuery(criteriaQuery);
|
||||||
|
List<ResourceHistoryTable> results = q.getResultList();
|
||||||
|
for (ResourceHistoryTable next : results) {
|
||||||
|
retVal.add(toResource(myResourceType, next));
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
retVal.add(read(theId.withoutVersion()));
|
||||||
|
} catch (ResourceNotFoundException e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
if (retVal.isEmpty()) {
|
||||||
|
throw new ResourceNotFoundException(theId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<IResource> history(Long theId, Date theSince, Integer theLimit) {
|
||||||
|
return super.history(myResourceName, theId, theSince, theLimit);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void postConstruct() {
|
||||||
|
RuntimeResourceDefinition def = getContext().getResourceDefinition(myResourceType);
|
||||||
|
myResourceName = def.getName();
|
||||||
|
|
||||||
|
if (mySecondaryPrimaryKeyParamName != null) {
|
||||||
|
RuntimeSearchParam sp = def.getSearchParam(mySecondaryPrimaryKeyParamName);
|
||||||
|
if (sp == null) {
|
||||||
|
throw new ConfigurationException("Unknown search param on resource[" + myResourceName + "] for secondary key[" + mySecondaryPrimaryKeyParamName + "]");
|
||||||
|
}
|
||||||
|
if (sp.getParamType()!=SearchParamTypeEnum.TOKEN) {
|
||||||
|
throw new ConfigurationException("Search param on resource[" + myResourceName + "] for secondary key[" + mySecondaryPrimaryKeyParamName + "] is not a token type, only token is supported");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public T read(IdDt theId) {
|
||||||
|
BaseHasResource entity = readEntity(theId);
|
||||||
|
|
||||||
|
T retVal = toResource(myResourceType, entity);
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseHasResource readEntity(IdDt theId) {
|
||||||
|
BaseHasResource entity = myEntityManager.find(ResourceTable.class, theId.asLong());
|
||||||
|
if (theId.hasUnqualifiedVersionId()) {
|
||||||
|
if (entity.getVersion() != theId.getUnqualifiedVersionIdAsLong()) {
|
||||||
|
entity = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entity == null) {
|
||||||
|
if (theId.hasUnqualifiedVersionId()) {
|
||||||
|
entity = myEntityManager.find(ResourceHistoryTable.class, new ResourceHistoryTablePk(myResourceName, theId.asLong(), theId.getUnqualifiedVersionIdAsLong()));
|
||||||
|
}
|
||||||
|
if (entity == null) {
|
||||||
|
throw new ResourceNotFoundException(theId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
private ResourceTable readEntityLatestVersion(IdDt theId) {
|
private ResourceTable readEntityLatestVersion(IdDt theId) {
|
||||||
ResourceTable entity = myEntityManager.find(ResourceTable.class, theId.asLong());
|
ResourceTable entity = myEntityManager.find(ResourceTable.class, theId.asLong());
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
|
@ -704,6 +575,158 @@ public class FhirResourceDao<T extends IResource> extends BaseFhirDao implements
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeTag(IdDt theId, String theScheme, String theTerm) {
|
||||||
|
BaseHasResource entity = readEntity(theId);
|
||||||
|
if (entity == null) {
|
||||||
|
throw new ResourceNotFoundException(theId);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (BaseTag next : new ArrayList<BaseTag>(entity.getTags())) {
|
||||||
|
if (next.getTag().getScheme().equals(theScheme) && next.getTag().getTerm().equals(theTerm)) {
|
||||||
|
myEntityManager.remove(next);
|
||||||
|
entity.getTags().remove(next);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
myEntityManager.merge(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<T> search(Map<String, IQueryParameterType> theParams) {
|
||||||
|
SearchParameterMap map = new SearchParameterMap();
|
||||||
|
for (Entry<String, IQueryParameterType> nextEntry : theParams.entrySet()) {
|
||||||
|
map.put(nextEntry.getKey(), new ArrayList<List<IQueryParameterType>>());
|
||||||
|
map.get(nextEntry.getKey()).add(Collections.singletonList(nextEntry.getValue()));
|
||||||
|
}
|
||||||
|
return search(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<T> search(SearchParameterMap theParams) {
|
||||||
|
|
||||||
|
Set<Long> pids;
|
||||||
|
if (theParams.isEmpty()) {
|
||||||
|
pids = null;
|
||||||
|
} else {
|
||||||
|
pids = searchForIdsWithAndOr(theParams);
|
||||||
|
if (pids.isEmpty()) {
|
||||||
|
return new ArrayList<T>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Execute the query and make sure we return distinct results
|
||||||
|
{
|
||||||
|
CriteriaBuilder builder = myEntityManager.getCriteriaBuilder();
|
||||||
|
CriteriaQuery<ResourceTable> cq = builder.createQuery(ResourceTable.class);
|
||||||
|
Root<ResourceTable> from = cq.from(ResourceTable.class);
|
||||||
|
cq.where(builder.equal(from.get("myResourceType"), getContext().getResourceDefinition(myResourceType).getName()));
|
||||||
|
if (!theParams.isEmpty()) {
|
||||||
|
cq.where(from.get("myId").in(pids));
|
||||||
|
}
|
||||||
|
TypedQuery<ResourceTable> q = myEntityManager.createQuery(cq);
|
||||||
|
|
||||||
|
List<T> retVal = new ArrayList<T>();
|
||||||
|
for (ResourceTable next : q.getResultList()) {
|
||||||
|
T resource = toResource(myResourceType, next);
|
||||||
|
retVal.add(resource);
|
||||||
|
}
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<T> search(String theParameterName, IQueryParameterType theValue) {
|
||||||
|
return search(Collections.singletonMap(theParameterName, theValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<Long> searchForIds(Map<String, IQueryParameterType> theParams) {
|
||||||
|
Map<String, List<List<IQueryParameterType>>> map = new HashMap<String, List<List<IQueryParameterType>>>();
|
||||||
|
for (Entry<String, IQueryParameterType> nextEntry : theParams.entrySet()) {
|
||||||
|
map.put(nextEntry.getKey(), new ArrayList<List<IQueryParameterType>>());
|
||||||
|
map.get(nextEntry.getKey()).add(Collections.singletonList(nextEntry.getValue()));
|
||||||
|
}
|
||||||
|
return searchForIdsWithAndOr(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<Long> searchForIds(String theParameterName, IQueryParameterType theValue) {
|
||||||
|
return searchForIds(Collections.singletonMap(theParameterName, theValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<Long> searchForIdsWithAndOr(Map<String, List<List<IQueryParameterType>>> theParams) {
|
||||||
|
Map<String, List<List<IQueryParameterType>>> params = theParams;
|
||||||
|
if (params == null) {
|
||||||
|
params = Collections.emptyMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
RuntimeResourceDefinition resourceDef = getContext().getResourceDefinition(myResourceType);
|
||||||
|
|
||||||
|
Set<Long> pids = new HashSet<Long>();
|
||||||
|
|
||||||
|
for (Entry<String, List<List<IQueryParameterType>>> nextParamEntry : params.entrySet()) {
|
||||||
|
String nextParamName = nextParamEntry.getKey();
|
||||||
|
RuntimeSearchParam nextParamDef = resourceDef.getSearchParam(nextParamName);
|
||||||
|
if (nextParamDef != null) {
|
||||||
|
if (nextParamDef.getParamType() == SearchParamTypeEnum.TOKEN) {
|
||||||
|
for (List<IQueryParameterType> nextAnd : nextParamEntry.getValue()) {
|
||||||
|
pids = addPredicateToken(pids, nextAnd);
|
||||||
|
if (pids.isEmpty()) {
|
||||||
|
return new HashSet<Long>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (nextParamDef.getParamType() == SearchParamTypeEnum.STRING) {
|
||||||
|
for (List<IQueryParameterType> nextAnd : nextParamEntry.getValue()) {
|
||||||
|
pids = addPredicateString(pids, nextAnd);
|
||||||
|
if (pids.isEmpty()) {
|
||||||
|
return new HashSet<Long>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (nextParamDef.getParamType() == SearchParamTypeEnum.QUANTITY) {
|
||||||
|
for (List<IQueryParameterType> nextAnd : nextParamEntry.getValue()) {
|
||||||
|
pids = addPredicateQuantity(pids, nextAnd);
|
||||||
|
if (pids.isEmpty()) {
|
||||||
|
return new HashSet<Long>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (nextParamDef.getParamType() == SearchParamTypeEnum.DATE) {
|
||||||
|
for (List<IQueryParameterType> nextAnd : nextParamEntry.getValue()) {
|
||||||
|
pids = addPredicateDate(pids, nextAnd);
|
||||||
|
if (pids.isEmpty()) {
|
||||||
|
return new HashSet<Long>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (nextParamDef.getParamType() == SearchParamTypeEnum.REFERENCE) {
|
||||||
|
for (List<IQueryParameterType> nextAnd : nextParamEntry.getValue()) {
|
||||||
|
pids = addPredicateReference(nextParamName, pids, nextAnd);
|
||||||
|
if (pids.isEmpty()) {
|
||||||
|
return new HashSet<Long>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("Don't know how to handle parameter of type: " + nextParamDef.getParamType());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return pids;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Required
|
||||||
|
public void setResourceType(Class<? extends IResource> theTableType) {
|
||||||
|
myResourceType = (Class<T>) theTableType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If set, the given param will be treated as a secondary primary key, and multiple resources will not be able to share the same value.
|
||||||
|
*/
|
||||||
|
public void setSecondaryPrimaryKeyParamName(String theSecondaryPrimaryKeyParamName) {
|
||||||
|
mySecondaryPrimaryKeyParamName = theSecondaryPrimaryKeyParamName;
|
||||||
|
}
|
||||||
|
|
||||||
private MethodOutcome toMethodOutcome(final ResourceTable entity) {
|
private MethodOutcome toMethodOutcome(final ResourceTable entity) {
|
||||||
MethodOutcome outcome = new MethodOutcome();
|
MethodOutcome outcome = new MethodOutcome();
|
||||||
outcome.setId(new IdDt(entity.getResourceType() + '/' + entity.getId() + '/' + Constants.PARAM_HISTORY + '/' + entity.getVersion()));
|
outcome.setId(new IdDt(entity.getResourceType() + '/' + entity.getId() + '/' + Constants.PARAM_HISTORY + '/' + entity.getVersion()));
|
||||||
|
@ -738,4 +761,22 @@ public class FhirResourceDao<T extends IResource> extends BaseFhirDao implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MethodOutcome update(final T theResource, final IdDt theId) {
|
||||||
|
|
||||||
|
// TransactionTemplate template = new TransactionTemplate(myPlatformTransactionManager);
|
||||||
|
// ResourceTable savedEntity = template.execute(new TransactionCallback<ResourceTable>() {
|
||||||
|
// @Override
|
||||||
|
// public ResourceTable doInTransaction(TransactionStatus theStatus) {
|
||||||
|
// final ResourceTable entity = readEntity(theId);
|
||||||
|
// return updateEntity(theResource, entity,true);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
final ResourceTable entity = readEntityLatestVersion(theId);
|
||||||
|
ResourceTable savedEntity = updateEntity(theResource, entity, true);
|
||||||
|
|
||||||
|
return toMethodOutcome(savedEntity);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,11 +91,11 @@ public class FhirSystemDao extends BaseFhirDao implements IFhirSystemDao {
|
||||||
for (IResource nextResource : theResources) {
|
for (IResource nextResource : theResources) {
|
||||||
List<ResourceReferenceDt> allRefs = terser.getAllPopulatedChildElementsOfType(nextResource, ResourceReferenceDt.class);
|
List<ResourceReferenceDt> allRefs = terser.getAllPopulatedChildElementsOfType(nextResource, ResourceReferenceDt.class);
|
||||||
for (ResourceReferenceDt nextRef : allRefs) {
|
for (ResourceReferenceDt nextRef : allRefs) {
|
||||||
IdDt nextId = nextRef.getResourceId();
|
IdDt nextId = nextRef.getReference();
|
||||||
if (idConversions.containsKey(nextId)) {
|
if (idConversions.containsKey(nextId)) {
|
||||||
IdDt newId = idConversions.get(nextId);
|
IdDt newId = idConversions.get(nextId);
|
||||||
ourLog.info(" * Replacing resource ref {} with {}", nextId, newId);
|
ourLog.info(" * Replacing resource ref {} with {}", nextId, newId);
|
||||||
nextRef.setResourceId(newId);
|
nextRef.setReference(newId);
|
||||||
} else {
|
} else {
|
||||||
ourLog.info(" * Reference [{}] does not exist in bundle", nextId);
|
ourLog.info(" * Reference [{}] does not exist in bundle", nextId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,43 @@ public class ResourceHistoryTablePk implements Serializable {
|
||||||
myVersion = theVersion;
|
myVersion = theVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((myId == null) ? 0 : myId.hashCode());
|
||||||
|
result = prime * result + ((myResourceType == null) ? 0 : myResourceType.hashCode());
|
||||||
|
result = prime * result + ((myVersion == null) ? 0 : myVersion.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
ResourceHistoryTablePk other = (ResourceHistoryTablePk) obj;
|
||||||
|
if (myId == null) {
|
||||||
|
if (other.myId != null)
|
||||||
|
return false;
|
||||||
|
} else if (!myId.equals(other.myId))
|
||||||
|
return false;
|
||||||
|
if (myResourceType == null) {
|
||||||
|
if (other.myResourceType != null)
|
||||||
|
return false;
|
||||||
|
} else if (!myResourceType.equals(other.myResourceType))
|
||||||
|
return false;
|
||||||
|
if (myVersion == null) {
|
||||||
|
if (other.myVersion != null)
|
||||||
|
return false;
|
||||||
|
} else if (!myVersion.equals(other.myVersion))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return myId;
|
return myId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,11 @@ public class ResourceIndexedSearchParamDate extends BaseResourceIndexedSearchPar
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
public Date myValueLow;
|
public Date myValueLow;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public ResourceIndexedSearchParamDate() {
|
||||||
|
}
|
||||||
|
|
||||||
public ResourceIndexedSearchParamDate(String theName, Date theLow, Date theHigh) {
|
public ResourceIndexedSearchParamDate(String theName, Date theLow, Date theHigh) {
|
||||||
setName(theName);
|
setName(theName);
|
||||||
setValueLow(theLow);
|
setValueLow(theLow);
|
||||||
|
|
|
@ -3,6 +3,7 @@ package ca.uhn.fhir.jpa.entity;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
|
@ -26,7 +27,7 @@ import ca.uhn.fhir.rest.server.Constants;
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "HFJ_RESOURCE", uniqueConstraints = {})
|
@Table(name = "HFJ_RESOURCE", uniqueConstraints = {})
|
||||||
@Inheritance(strategy = InheritanceType.JOINED)
|
@Inheritance(strategy = InheritanceType.JOINED)
|
||||||
@org.hibernate.annotations.Table(appliesTo="HFJ_RESOURCE", indexes= {@Index(name="IDX_RES_DATE", columnNames= {"RES_UPDATED"})})
|
@org.hibernate.annotations.Table(appliesTo = "HFJ_RESOURCE", indexes = { @Index(name = "IDX_RES_DATE", columnNames = { "RES_UPDATED" }) })
|
||||||
public class ResourceTable extends BaseHasResource implements Serializable {
|
public class ResourceTable extends BaseHasResource implements Serializable {
|
||||||
static final int RESTYPE_LEN = 30;
|
static final int RESTYPE_LEN = 30;
|
||||||
|
|
||||||
|
@ -80,23 +81,21 @@ public class ResourceTable extends BaseHasResource implements Serializable {
|
||||||
@Column(name = "RES_VER")
|
@Column(name = "RES_VER")
|
||||||
private long myVersion;
|
private long myVersion;
|
||||||
|
|
||||||
public boolean hasTag(String theTerm, String theLabel, String theScheme) {
|
public ResourceTag addTag(TagDefinition theTag) {
|
||||||
for (ResourceTag next : getTags()) {
|
ResourceTag tag = new ResourceTag(this, theTag);
|
||||||
if (next.getTag().getTerm().equals(theTerm)) {
|
tag.setResourceType(getResourceType());
|
||||||
return true;
|
getTags().add(tag);
|
||||||
}
|
return tag;
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IdDt getIdDt() {
|
|
||||||
return new IdDt(myResourceType + '/' + myId + '/' + Constants.PARAM_HISTORY + '/' + myVersion);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return myId;
|
return myId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IdDt getIdDt() {
|
||||||
|
return new IdDt(myResourceType + '/' + myId + '/' + Constants.PARAM_HISTORY + '/' + myVersion);
|
||||||
|
}
|
||||||
|
|
||||||
public Collection<ResourceIndexedSearchParamDate> getParamsDate() {
|
public Collection<ResourceIndexedSearchParamDate> getParamsDate() {
|
||||||
if (myParamsDate == null) {
|
if (myParamsDate == null) {
|
||||||
myParamsDate = new ArrayList<ResourceIndexedSearchParamDate>();
|
myParamsDate = new ArrayList<ResourceIndexedSearchParamDate>();
|
||||||
|
@ -147,6 +146,15 @@ public class ResourceTable extends BaseHasResource implements Serializable {
|
||||||
return myVersion;
|
return myVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasTag(String theTerm, String theLabel, String theScheme) {
|
||||||
|
for (ResourceTag next : getTags()) {
|
||||||
|
if (next.getTag().getTerm().equals(theTerm)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isHasLinks() {
|
public boolean isHasLinks() {
|
||||||
return myHasLinks;
|
return myHasLinks;
|
||||||
}
|
}
|
||||||
|
@ -176,19 +184,35 @@ public class ResourceTable extends BaseHasResource implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParamsDate(Collection<ResourceIndexedSearchParamDate> theParamsDate) {
|
public void setParamsDate(Collection<ResourceIndexedSearchParamDate> theParamsDate) {
|
||||||
myParamsDate = theParamsDate;
|
if (!isParamsDatePopulated() && theParamsDate.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
getParamsDate().clear();
|
||||||
|
getParamsDate().addAll(theParamsDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParamsDatePopulated(boolean theParamsDatePopulated) {
|
public void setParamsDatePopulated(boolean theParamsDatePopulated) {
|
||||||
myParamsDatePopulated = theParamsDatePopulated;
|
myParamsDatePopulated = theParamsDatePopulated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setParamsNumber(List<ResourceIndexedSearchParamNumber> theNumberParams) {
|
||||||
|
if (!isParamsNumberPopulated() && theNumberParams.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
getParamsNumber().clear();
|
||||||
|
getParamsNumber().addAll(theNumberParams);
|
||||||
|
}
|
||||||
|
|
||||||
public void setParamsNumberPopulated(boolean theParamsNumberPopulated) {
|
public void setParamsNumberPopulated(boolean theParamsNumberPopulated) {
|
||||||
myParamsNumberPopulated = theParamsNumberPopulated;
|
myParamsNumberPopulated = theParamsNumberPopulated;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParamsString(Collection<ResourceIndexedSearchParamString> theParamsString) {
|
public void setParamsString(Collection<ResourceIndexedSearchParamString> theParamsString) {
|
||||||
myParamsString = theParamsString;
|
if (!isParamsStringPopulated() && theParamsString.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
getParamsString().clear();
|
||||||
|
getParamsString().addAll(theParamsString);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParamsStringPopulated(boolean theParamsStringPopulated) {
|
public void setParamsStringPopulated(boolean theParamsStringPopulated) {
|
||||||
|
@ -196,13 +220,25 @@ public class ResourceTable extends BaseHasResource implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParamsToken(Collection<ResourceIndexedSearchParamToken> theParamsToken) {
|
public void setParamsToken(Collection<ResourceIndexedSearchParamToken> theParamsToken) {
|
||||||
myParamsToken = theParamsToken;
|
if (!isParamsTokenPopulated() && theParamsToken.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
getParamsToken().clear();
|
||||||
|
getParamsToken().addAll(theParamsToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParamsTokenPopulated(boolean theParamsTokenPopulated) {
|
public void setParamsTokenPopulated(boolean theParamsTokenPopulated) {
|
||||||
myParamsTokenPopulated = theParamsTokenPopulated;
|
myParamsTokenPopulated = theParamsTokenPopulated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setResourceLinks(List<ResourceLink> theLinks) {
|
||||||
|
if (!isHasLinks() && theLinks.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
getResourceLinks().clear();
|
||||||
|
getResourceLinks().addAll(theLinks);
|
||||||
|
}
|
||||||
|
|
||||||
public void setResourceType(String theResourceType) {
|
public void setResourceType(String theResourceType) {
|
||||||
myResourceType = theResourceType;
|
myResourceType = theResourceType;
|
||||||
}
|
}
|
||||||
|
@ -231,11 +267,4 @@ public class ResourceTable extends BaseHasResource implements Serializable {
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResourceTag addTag(TagDefinition theTag) {
|
|
||||||
ResourceTag tag = new ResourceTag(this, theTag);
|
|
||||||
tag.setResourceType(getResourceType());
|
|
||||||
getTags().add(tag);
|
|
||||||
return tag;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import ca.uhn.fhir.model.dstu.composite.QuantityDt;
|
||||||
import ca.uhn.fhir.model.dstu.composite.ResourceReferenceDt;
|
import ca.uhn.fhir.model.dstu.composite.ResourceReferenceDt;
|
||||||
import ca.uhn.fhir.model.dstu.resource.Device;
|
import ca.uhn.fhir.model.dstu.resource.Device;
|
||||||
import ca.uhn.fhir.model.dstu.resource.DiagnosticReport;
|
import ca.uhn.fhir.model.dstu.resource.DiagnosticReport;
|
||||||
|
import ca.uhn.fhir.model.dstu.resource.Encounter;
|
||||||
import ca.uhn.fhir.model.dstu.resource.Location;
|
import ca.uhn.fhir.model.dstu.resource.Location;
|
||||||
import ca.uhn.fhir.model.dstu.resource.Observation;
|
import ca.uhn.fhir.model.dstu.resource.Observation;
|
||||||
import ca.uhn.fhir.model.dstu.resource.Organization;
|
import ca.uhn.fhir.model.dstu.resource.Organization;
|
||||||
|
@ -35,6 +36,7 @@ import ca.uhn.fhir.model.primitive.IdDt;
|
||||||
import ca.uhn.fhir.model.primitive.InstantDt;
|
import ca.uhn.fhir.model.primitive.InstantDt;
|
||||||
import ca.uhn.fhir.model.primitive.StringDt;
|
import ca.uhn.fhir.model.primitive.StringDt;
|
||||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||||
|
import ca.uhn.fhir.rest.param.DateRangeParam;
|
||||||
import ca.uhn.fhir.rest.param.QualifiedDateParam;
|
import ca.uhn.fhir.rest.param.QualifiedDateParam;
|
||||||
import ca.uhn.fhir.rest.param.ReferenceParam;
|
import ca.uhn.fhir.rest.param.ReferenceParam;
|
||||||
import ca.uhn.fhir.rest.param.StringParam;
|
import ca.uhn.fhir.rest.param.StringParam;
|
||||||
|
@ -52,6 +54,7 @@ public class FhirResourceDaoTest {
|
||||||
private static IFhirResourceDao<Location> ourLocationDao;
|
private static IFhirResourceDao<Location> ourLocationDao;
|
||||||
|
|
||||||
private static Date ourTestStarted;
|
private static Date ourTestStarted;
|
||||||
|
private static IFhirResourceDao<Encounter> ourEncounterDao;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPersistAndReadResource() {
|
public void testPersistAndReadResource() {
|
||||||
|
@ -378,7 +381,146 @@ public class FhirResourceDaoTest {
|
||||||
assertEquals(0, patients.size());
|
assertEquals(0, patients.size());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDatePeriodParamStartOnly() {
|
||||||
|
{
|
||||||
|
Encounter enc = new Encounter();
|
||||||
|
enc.addIdentifier("testDatePeriodParam", "01");
|
||||||
|
enc.getPeriod().getStart().setValueAsString("2001-01-02");
|
||||||
|
ourEncounterDao.create(enc);
|
||||||
|
}
|
||||||
|
|
||||||
|
SearchParameterMap params = new SearchParameterMap();
|
||||||
|
params.add(Encounter.SP_DATE, new DateRangeParam("2001-01-01", "2001-01-03"));
|
||||||
|
params.add(Encounter.SP_IDENTIFIER, new IdentifierDt("testDatePeriodParam", "01"));
|
||||||
|
List<Encounter> encs = ourEncounterDao.search(params);
|
||||||
|
assertEquals(1, encs.size());
|
||||||
|
|
||||||
|
params = new SearchParameterMap();
|
||||||
|
params.add(Encounter.SP_DATE, new DateRangeParam("2001-01-01", null));
|
||||||
|
params.add(Encounter.SP_IDENTIFIER, new IdentifierDt("testDatePeriodParam", "01"));
|
||||||
|
encs = ourEncounterDao.search(params);
|
||||||
|
assertEquals(1, encs.size());
|
||||||
|
|
||||||
|
params = new SearchParameterMap();
|
||||||
|
params.add(Encounter.SP_DATE, new DateRangeParam(null, "2001-01-03"));
|
||||||
|
params.add(Encounter.SP_IDENTIFIER, new IdentifierDt("testDatePeriodParam", "01"));
|
||||||
|
encs = ourEncounterDao.search(params);
|
||||||
|
assertEquals(1, encs.size());
|
||||||
|
|
||||||
|
params = new SearchParameterMap();
|
||||||
|
params.add(Encounter.SP_DATE, new DateRangeParam(null, "2001-01-01"));
|
||||||
|
params.add(Encounter.SP_IDENTIFIER, new IdentifierDt("testDatePeriodParam", "01"));
|
||||||
|
encs = ourEncounterDao.search(params);
|
||||||
|
assertEquals(0, encs.size());
|
||||||
|
|
||||||
|
params = new SearchParameterMap();
|
||||||
|
params.add(Encounter.SP_DATE, new DateRangeParam("2001-01-03",null));
|
||||||
|
params.add(Encounter.SP_IDENTIFIER, new IdentifierDt("testDatePeriodParam", "01"));
|
||||||
|
encs = ourEncounterDao.search(params);
|
||||||
|
assertEquals(0, encs.size());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDatePeriodParamEndOnly() {
|
||||||
|
{
|
||||||
|
Encounter enc = new Encounter();
|
||||||
|
enc.addIdentifier("testDatePeriodParam", "02");
|
||||||
|
enc.getPeriod().getEnd().setValueAsString("2001-01-02");
|
||||||
|
ourEncounterDao.create(enc);
|
||||||
|
}
|
||||||
|
|
||||||
|
SearchParameterMap params = new SearchParameterMap();
|
||||||
|
params.add(Encounter.SP_DATE, new DateRangeParam("2001-01-01", "2001-01-03"));
|
||||||
|
params.add(Encounter.SP_IDENTIFIER, new IdentifierDt("testDatePeriodParam", "02"));
|
||||||
|
List<Encounter> encs = ourEncounterDao.search(params);
|
||||||
|
assertEquals(1, encs.size());
|
||||||
|
|
||||||
|
params = new SearchParameterMap();
|
||||||
|
params.add(Encounter.SP_DATE, new DateRangeParam("2001-01-01", null));
|
||||||
|
params.add(Encounter.SP_IDENTIFIER, new IdentifierDt("testDatePeriodParam", "02"));
|
||||||
|
encs = ourEncounterDao.search(params);
|
||||||
|
assertEquals(1, encs.size());
|
||||||
|
|
||||||
|
params = new SearchParameterMap();
|
||||||
|
params.add(Encounter.SP_DATE, new DateRangeParam(null, "2001-01-03"));
|
||||||
|
params.add(Encounter.SP_IDENTIFIER, new IdentifierDt("testDatePeriodParam", "02"));
|
||||||
|
encs = ourEncounterDao.search(params);
|
||||||
|
assertEquals(1, encs.size());
|
||||||
|
|
||||||
|
params = new SearchParameterMap();
|
||||||
|
params.add(Encounter.SP_DATE, new DateRangeParam(null, "2001-01-01"));
|
||||||
|
params.add(Encounter.SP_IDENTIFIER, new IdentifierDt("testDatePeriodParam", "02"));
|
||||||
|
encs = ourEncounterDao.search(params);
|
||||||
|
assertEquals(0, encs.size());
|
||||||
|
|
||||||
|
params = new SearchParameterMap();
|
||||||
|
params.add(Encounter.SP_DATE, new DateRangeParam( "2001-01-03",null));
|
||||||
|
params.add(Encounter.SP_IDENTIFIER, new IdentifierDt("testDatePeriodParam", "02"));
|
||||||
|
encs = ourEncounterDao.search(params);
|
||||||
|
assertEquals(0, encs.size());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDatePeriodParamStartAndEnd() {
|
||||||
|
{
|
||||||
|
Encounter enc = new Encounter();
|
||||||
|
enc.addIdentifier("testDatePeriodParam", "03");
|
||||||
|
enc.getPeriod().getStart().setValueAsString("2001-01-02");
|
||||||
|
enc.getPeriod().getEnd().setValueAsString("2001-01-03");
|
||||||
|
ourEncounterDao.create(enc);
|
||||||
|
}
|
||||||
|
|
||||||
|
SearchParameterMap params = new SearchParameterMap();
|
||||||
|
params.add(Encounter.SP_DATE, new DateRangeParam("2001-01-01", "2001-01-03"));
|
||||||
|
params.add(Encounter.SP_IDENTIFIER, new IdentifierDt("testDatePeriodParam", "03"));
|
||||||
|
List<Encounter> encs = ourEncounterDao.search(params);
|
||||||
|
assertEquals(1, encs.size());
|
||||||
|
|
||||||
|
params = new SearchParameterMap();
|
||||||
|
params.add(Encounter.SP_DATE, new DateRangeParam("2001-01-02", "2001-01-06"));
|
||||||
|
params.add(Encounter.SP_IDENTIFIER, new IdentifierDt("testDatePeriodParam", "03"));
|
||||||
|
encs = ourEncounterDao.search(params);
|
||||||
|
assertEquals(1, encs.size());
|
||||||
|
|
||||||
|
params = new SearchParameterMap();
|
||||||
|
params.add(Encounter.SP_DATE, new DateRangeParam("2001-01-01", null));
|
||||||
|
params.add(Encounter.SP_IDENTIFIER, new IdentifierDt("testDatePeriodParam", "03"));
|
||||||
|
encs = ourEncounterDao.search(params);
|
||||||
|
assertEquals(1, encs.size());
|
||||||
|
|
||||||
|
params = new SearchParameterMap();
|
||||||
|
params.add(Encounter.SP_DATE, new DateRangeParam(null, "2001-01-03"));
|
||||||
|
params.add(Encounter.SP_IDENTIFIER, new IdentifierDt("testDatePeriodParam", "03"));
|
||||||
|
encs = ourEncounterDao.search(params);
|
||||||
|
assertEquals(1, encs.size());
|
||||||
|
|
||||||
|
params = new SearchParameterMap();
|
||||||
|
params.add(Encounter.SP_DATE, new DateRangeParam(null, "2001-01-05"));
|
||||||
|
params.add(Encounter.SP_IDENTIFIER, new IdentifierDt("testDatePeriodParam", "03"));
|
||||||
|
encs = ourEncounterDao.search(params);
|
||||||
|
assertEquals(1, encs.size());
|
||||||
|
|
||||||
|
params = new SearchParameterMap();
|
||||||
|
params.add(Encounter.SP_DATE, new DateRangeParam(null, "2001-01-01"));
|
||||||
|
params.add(Encounter.SP_IDENTIFIER, new IdentifierDt("testDatePeriodParam", "03"));
|
||||||
|
encs = ourEncounterDao.search(params);
|
||||||
|
assertEquals(0, encs.size());
|
||||||
|
|
||||||
|
params = new SearchParameterMap();
|
||||||
|
params.add(Encounter.SP_DATE, new DateRangeParam( "2001-01-05",null));
|
||||||
|
params.add(Encounter.SP_IDENTIFIER, new IdentifierDt("testDatePeriodParam", "03"));
|
||||||
|
encs = ourEncounterDao.search(params);
|
||||||
|
assertEquals(0, encs.size());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSearchStringParamWithNonNormalized() {
|
public void testSearchStringParamWithNonNormalized() {
|
||||||
{
|
{
|
||||||
|
@ -522,7 +664,8 @@ public class FhirResourceDaoTest {
|
||||||
|
|
||||||
// Update the name
|
// Update the name
|
||||||
p1.getNameFirstRep().getGivenFirstRep().setValue("testUpdateMaintainsSearchParamsBBB");
|
p1.getNameFirstRep().getGivenFirstRep().setValue("testUpdateMaintainsSearchParamsBBB");
|
||||||
IdDt p1id2 = ourPatientDao.update(p1, p1id).getId();
|
MethodOutcome update2 = ourPatientDao.update(p1, p1id);
|
||||||
|
IdDt p1id2 = update2.getId();
|
||||||
|
|
||||||
ids = ourPatientDao.searchForIds(Patient.SP_GIVEN, new StringDt("testUpdateMaintainsSearchParamsAAA"));
|
ids = ourPatientDao.searchForIds(Patient.SP_GIVEN, new StringDt("testUpdateMaintainsSearchParamsAAA"));
|
||||||
assertEquals(0, ids.size());
|
assertEquals(0, ids.size());
|
||||||
|
@ -555,6 +698,7 @@ public class FhirResourceDaoTest {
|
||||||
ourDeviceDao = ourCtx.getBean("myDeviceDao", IFhirResourceDao.class);
|
ourDeviceDao = ourCtx.getBean("myDeviceDao", IFhirResourceDao.class);
|
||||||
ourOrganizationDao = ourCtx.getBean("myOrganizationDao", IFhirResourceDao.class);
|
ourOrganizationDao = ourCtx.getBean("myOrganizationDao", IFhirResourceDao.class);
|
||||||
ourLocationDao = ourCtx.getBean("myLocationDao", IFhirResourceDao.class);
|
ourLocationDao = ourCtx.getBean("myLocationDao", IFhirResourceDao.class);
|
||||||
|
ourEncounterDao = ourCtx.getBean("myEncounterDao", IFhirResourceDao.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class FhirSystemDaoTest {
|
||||||
Thread.sleep(10);
|
Thread.sleep(10);
|
||||||
IdDt newpid3 = ourPatientDao.update(patient, pid).getId();
|
IdDt newpid3 = ourPatientDao.update(patient, pid).getId();
|
||||||
|
|
||||||
List<IResource> values = ourSystemDao.history(start, 1000);
|
List<IResource> values = ourSystemDao.history(start, null);
|
||||||
assertEquals(4, values.size());
|
assertEquals(4, values.size());
|
||||||
|
|
||||||
assertEquals(newpid3, values.get(0).getId());
|
assertEquals(newpid3, values.get(0).getId());
|
||||||
|
@ -207,7 +207,7 @@ public class FhirSystemDaoTest {
|
||||||
|
|
||||||
IdDt foundPatientId = patResults.get(0).getId();
|
IdDt foundPatientId = patResults.get(0).getId();
|
||||||
ResourceReferenceDt subject = obs.getSubject();
|
ResourceReferenceDt subject = obs.getSubject();
|
||||||
assertEquals(foundPatientId.getUnqualifiedId(), subject.getResourceId().getUnqualifiedId());
|
assertEquals(foundPatientId.getUnqualifiedId(), subject.getReference().getUnqualifiedId());
|
||||||
|
|
||||||
// Update
|
// Update
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
<property name="hibernate.connection.password" value="" />
|
<property name="hibernate.connection.password" value="" />
|
||||||
<property name="hibernate.jdbc.batch_size" value="0" />
|
<property name="hibernate.jdbc.batch_size" value="0" />
|
||||||
<property name="hibernate.cache.use_minimal_puts" value="false" />
|
<property name="hibernate.cache.use_minimal_puts" value="false" />
|
||||||
<property name="hibernate.show_sql" value="false" />
|
<property name="hibernate.show_sql" value="true" />
|
||||||
<property name="hibernate.cache.use_query_cache" value="false" />
|
<property name="hibernate.cache.use_query_cache" value="false" />
|
||||||
<property name="hibernate.cache.use_second_level_cache" value="false" />
|
<property name="hibernate.cache.use_second_level_cache" value="false" />
|
||||||
<property name="hibernate.cache.use_structured_entries" value="false" />
|
<property name="hibernate.cache.use_structured_entries" value="false" />
|
||||||
|
|
|
@ -40,6 +40,9 @@
|
||||||
<bean id="myQuestionnaireDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
|
<bean id="myQuestionnaireDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
|
||||||
<property name="resourceType" value="ca.uhn.fhir.model.dstu.resource.Questionnaire"/>
|
<property name="resourceType" value="ca.uhn.fhir.model.dstu.resource.Questionnaire"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
<bean id="myEncounterDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
|
||||||
|
<property name="resourceType" value="ca.uhn.fhir.model.dstu.resource.Encounter"/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
<bean id="myPersistenceDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" lazy-init="true">
|
<bean id="myPersistenceDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" lazy-init="true">
|
||||||
<property name="url" value="jdbc:derby:memory:myUnitTestDB;create=true" />
|
<property name="url" value="jdbc:derby:memory:myUnitTestDB;create=true" />
|
||||||
|
|
|
@ -1,97 +1,36 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry excluding="**/*.java" kind="src" output="target/test-classes" path="src/test/resources"/>
|
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||||
<classpathentry including="**/*.java" kind="src" path="src/main/java"/>
|
|
||||||
<classpathentry excluding="**/*.java" kind="src" path="src/main/resources"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/javax/json/javax.json-api/1.0/javax.json-api-1.0.jar" sourcepath="M2_REPO/javax/json/javax.json-api/1.0/javax.json-api-1.0-sources.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.jar" sourcepath="M2_REPO/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2-sources.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/javax/servlet/servlet-api/2.3/servlet-api-2.3.jar" sourcepath="M2_REPO/javax/servlet/servlet-api/2.3/servlet-api-2.3-sources.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/javax/enterprise/cdi-api/1.0/cdi-api-1.0.jar" sourcepath="M2_REPO/javax/enterprise/cdi-api/1.0/cdi-api-1.0-sources.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/javax/annotation/jsr250-api/1.0/jsr250-api-1.0.jar" sourcepath="M2_REPO/javax/annotation/jsr250-api/1.0/jsr250-api-1.0-sources.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/javax/inject/javax.inject/1/javax.inject-1.jar" sourcepath="M2_REPO/javax/inject/javax.inject/1/javax.inject-1-sources.jar"/>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/org/glassfish/javax.json/1.0.4/javax.json-1.0.4.jar" sourcepath="M2_REPO/org/glassfish/javax.json/1.0.4/javax.json-1.0.4-sources.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/org/codehaus/woodstox/woodstox-core-asl/4.2.0/woodstox-core-asl-4.2.0.jar" sourcepath="M2_REPO/org/codehaus/woodstox/woodstox-core-asl/4.2.0/woodstox-core-asl-4.2.0-sources.jar">
|
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="javadoc_location" value="jar:file:/home/t3903uhn/.m2/repository/org/codehaus/woodstox/woodstox-core-asl/4.2.0/woodstox-core-asl-4.2.0-javadoc.jar!/"/>
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="var" path="M2_REPO/org/codehaus/woodstox/stax2-api/3.1.1/stax2-api-3.1.1.jar" sourcepath="M2_REPO/org/codehaus/woodstox/stax2-api/3.1.1/stax2-api-3.1.1-sources.jar"/>
|
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||||
<classpathentry kind="var" path="M2_REPO/org/apache/commons/commons-lang3/3.2.1/commons-lang3-3.2.1.jar" sourcepath="M2_REPO/org/apache/commons/commons-lang3/3.2.1/commons-lang3-3.2.1-sources.jar">
|
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="javadoc_location" value="jar:file:/home/t3903uhn/.m2/repository/org/apache/commons/commons-lang3/3.2.1/commons-lang3-3.2.1-javadoc.jar!/"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="var" path="M2_REPO/commons-codec/commons-codec/1.9/commons-codec-1.9.jar" sourcepath="M2_REPO/commons-codec/commons-codec/1.9/commons-codec-1.9-sources.jar"/>
|
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||||
<classpathentry kind="var" path="M2_REPO/commons-io/commons-io/2.4/commons-io-2.4.jar" sourcepath="M2_REPO/commons-io/commons-io/2.4/commons-io-2.4-sources.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.7.6/slf4j-api-1.7.6.jar" sourcepath="M2_REPO/org/slf4j/slf4j-api/1.7.6/slf4j-api-1.7.6-sources.jar">
|
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="javadoc_location" value="jar:file:/home/t3903uhn/.m2/repository/org/slf4j/slf4j-api/1.7.6/slf4j-api-1.7.6-javadoc.jar!/"/>
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="var" path="M2_REPO/org/apache/httpcomponents/httpclient/4.3.3/httpclient-4.3.3.jar" sourcepath="M2_REPO/org/apache/httpcomponents/httpclient/4.3.3/httpclient-4.3.3-sources.jar"/>
|
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||||
<classpathentry kind="var" path="M2_REPO/org/apache/httpcomponents/httpcore/4.3.2/httpcore-4.3.2.jar" sourcepath="M2_REPO/org/apache/httpcomponents/httpcore/4.3.2/httpcore-4.3.2-sources.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/commons-logging/commons-logging/1.1/commons-logging-1.1.jar" sourcepath="M2_REPO/commons-logging/commons-logging/1.1/commons-logging-1.1-sources.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/org/apache/velocity/velocity/1.7/velocity-1.7.jar" sourcepath="M2_REPO/org/apache/velocity/velocity/1.7/velocity-1.7-sources.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar" sourcepath="M2_REPO/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1-sources.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/commons-lang/commons-lang/2.4/commons-lang-2.4.jar" sourcepath="M2_REPO/commons-lang/commons-lang/2.4/commons-lang-2.4-sources.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/org/apache/velocity/velocity-tools/2.0/velocity-tools-2.0.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0.jar" sourcepath="M2_REPO/commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0-sources.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/commons-digester/commons-digester/1.8/commons-digester-1.8.jar" sourcepath="M2_REPO/commons-digester/commons-digester/1.8/commons-digester-1.8-sources.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/commons-chain/commons-chain/1.1/commons-chain-1.1.jar" sourcepath="M2_REPO/commons-chain/commons-chain/1.1/commons-chain-1.1-sources.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/commons-validator/commons-validator/1.3.1/commons-validator-1.3.1.jar" sourcepath="M2_REPO/commons-validator/commons-validator/1.3.1/commons-validator-1.3.1-sources.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/dom4j/dom4j/1.1/dom4j-1.1.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/oro/oro/2.0.8/oro-2.0.8.jar" sourcepath="M2_REPO/oro/oro/2.0.8/oro-2.0.8-sources.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/sslext/sslext/1.2-0/sslext-1.2-0.jar" sourcepath="M2_REPO/sslext/sslext/1.2-0/sslext-1.2-0-sources.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/org/apache/struts/struts-core/1.3.8/struts-core-1.3.8.jar" sourcepath="M2_REPO/org/apache/struts/struts-core/1.3.8/struts-core-1.3.8-sources.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/antlr/antlr/2.7.2/antlr-2.7.2.jar" sourcepath="M2_REPO/antlr/antlr/2.7.2/antlr-2.7.2-sources.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/org/apache/struts/struts-taglib/1.3.8/struts-taglib-1.3.8.jar" sourcepath="M2_REPO/org/apache/struts/struts-taglib/1.3.8/struts-taglib-1.3.8-sources.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/org/apache/struts/struts-tiles/1.3.8/struts-tiles-1.3.8.jar" sourcepath="M2_REPO/org/apache/struts/struts-tiles/1.3.8/struts-tiles-1.3.8-sources.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/ch/qos/logback/logback-classic/1.1.1/logback-classic-1.1.1.jar" sourcepath="M2_REPO/ch/qos/logback/logback-classic/1.1.1/logback-classic-1.1.1-sources.jar">
|
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="javadoc_location" value="jar:file:/home/t3903uhn/.m2/repository/ch/qos/logback/logback-classic/1.1.1/logback-classic-1.1.1-javadoc.jar!/"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="var" path="M2_REPO/ch/qos/logback/logback-core/1.1.1/logback-core-1.1.1.jar" sourcepath="M2_REPO/ch/qos/logback/logback-core/1.1.1/logback-core-1.1.1-sources.jar">
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="javadoc_location" value="jar:file:/home/t3903uhn/.m2/repository/ch/qos/logback/logback-core/1.1.1/logback-core-1.1.1-javadoc.jar!/"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="var" path="M2_REPO/junit/junit/4.11/junit-4.11.jar" sourcepath="M2_REPO/junit/junit/4.11/junit-4.11-sources.jar">
|
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="javadoc_location" value="jar:file:/home/t3903uhn/.m2/repository/junit/junit/4.11/junit-4.11-javadoc.jar!/"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar" sourcepath="M2_REPO/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-sources.jar">
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
<attributes>
|
|
||||||
<attribute name="javadoc_location" value="jar:file:/home/t3903uhn/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-javadoc.jar!/"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/org/apache/maven/maven-project/2.2.1/maven-project-2.2.1.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/org/apache/maven/maven-settings/2.2.1/maven-settings-2.2.1.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/org/apache/maven/maven-model/2.2.1/maven-model-2.2.1.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/org/codehaus/plexus/plexus-utils/1.5.15/plexus-utils-1.5.15.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/org/codehaus/plexus/plexus-interpolation/1.11/plexus-interpolation-1.11.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/org/codehaus/plexus/plexus-container-default/1.0-alpha-9-stable-1/plexus-container-default-1.0-alpha-9-stable-1.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/classworlds/classworlds/1.1-alpha-2/classworlds-1.1-alpha-2.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/org/apache/maven/maven-profile/2.2.1/maven-profile-2.2.1.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/org/apache/maven/maven-artifact-manager/2.2.1/maven-artifact-manager-2.2.1.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/org/apache/maven/maven-repository-metadata/2.2.1/maven-repository-metadata-2.2.1.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/org/apache/maven/maven-artifact/2.2.1/maven-artifact-2.2.1.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/org/apache/maven/wagon/wagon-provider-api/1.0-beta-6/wagon-provider-api-1.0-beta-6.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/org/apache/maven/maven-plugin-registry/2.2.1/maven-plugin-registry-2.2.1.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/org/apache/maven/maven-plugin-api/3.2.1/maven-plugin-api-3.2.1.jar" sourcepath="M2_REPO/org/apache/maven/maven-plugin-api/3.2.1/maven-plugin-api-3.2.1-sources.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/org/eclipse/sisu/org.eclipse.sisu.plexus/0.0.0.M5/org.eclipse.sisu.plexus-0.0.0.M5.jar" sourcepath="M2_REPO/org/eclipse/sisu/org.eclipse.sisu.plexus/0.0.0.M5/org.eclipse.sisu.plexus-0.0.0.M5-sources.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/com/google/guava/guava/10.0.1/guava-10.0.1.jar" sourcepath="M2_REPO/com/google/guava/guava/10.0.1/guava-10.0.1-sources.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/org/sonatype/sisu/sisu-guice/3.1.0/sisu-guice-3.1.0-no_aop.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/aopalliance/aopalliance/1.0/aopalliance-1.0.jar" sourcepath="M2_REPO/aopalliance/aopalliance/1.0/aopalliance-1.0-sources.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/org/eclipse/sisu/org.eclipse.sisu.inject/0.0.0.M5/org.eclipse.sisu.inject-0.0.0.M5.jar" sourcepath="M2_REPO/org/eclipse/sisu/org.eclipse.sisu.inject/0.0.0.M5/org.eclipse.sisu.inject-0.0.0.M5-sources.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar" sourcepath="M2_REPO/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5-sources.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/org/codehaus/plexus/plexus-classworlds/2.4/plexus-classworlds-2.4.jar" sourcepath="M2_REPO/org/codehaus/plexus/plexus-classworlds/2.4/plexus-classworlds-2.4-sources.jar"/>
|
|
||||||
<classpathentry kind="var" path="M2_REPO/org/apache/maven/plugin-tools/maven-plugin-annotations/3.2/maven-plugin-annotations-3.2.jar" sourcepath="M2_REPO/org/apache/maven/plugin-tools/maven-plugin-annotations/3.2/maven-plugin-annotations-3.2-sources.jar"/>
|
|
||||||
<classpathentry combineaccessrules="false" kind="src" path="/hapi-fhir-base"/>
|
|
||||||
<classpathentry combineaccessrules="false" kind="src" path="/hapi-fhir-jpaserver-base"/>
|
|
||||||
<classpathentry kind="output" path="bin"/>
|
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
@ -183,24 +183,24 @@ public class TinderStructuresMojo extends AbstractMojo {
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
|
||||||
// ValueSetGenerator vsp = new ValueSetGenerator();
|
ValueSetGenerator vsp = new ValueSetGenerator();
|
||||||
// vsp.setDirectory("src/test/resources/vs/");
|
// vsp.setDirectory("src/test/resources/vs/");
|
||||||
// vsp.parse();
|
vsp.parse();
|
||||||
//
|
|
||||||
// DatatypeGeneratorUsingSpreadsheet dtp = new DatatypeGeneratorUsingSpreadsheet();
|
DatatypeGeneratorUsingSpreadsheet dtp = new DatatypeGeneratorUsingSpreadsheet();
|
||||||
// dtp.parse();
|
dtp.parse();
|
||||||
// dtp.bindValueSets(vsp);
|
dtp.bindValueSets(vsp);
|
||||||
//
|
|
||||||
// String dtOutputDir = "target/generated/valuesets/ca/uhn/fhir/model/dstu/composite";
|
String dtOutputDir = "target/generated/valuesets/ca/uhn/fhir/model/dstu/composite";
|
||||||
// dtp.writeAll(dtOutputDir);
|
dtp.writeAll(new File(dtOutputDir), "ca.uhn.fhir.model.dstu");
|
||||||
//
|
|
||||||
ResourceGeneratorUsingSpreadsheet rp = new ResourceGeneratorUsingSpreadsheet();
|
ResourceGeneratorUsingSpreadsheet rp = new ResourceGeneratorUsingSpreadsheet();
|
||||||
rp.setBaseResourceNames(Arrays.asList("list"));
|
rp.setBaseResourceNames(Arrays.asList("list", "encounter"));
|
||||||
rp.parse();
|
rp.parse();
|
||||||
// rp.bindValueSets(vsp);
|
// rp.bindValueSets(vsp);
|
||||||
|
|
||||||
String rpOutputDir = "target/generated/valuesets/ca/uhn/fhir/model/dstu/resource";
|
String rpOutputDir = "target/generated/valuesets/ca/uhn/fhir/model/dstu/resource";
|
||||||
rp.writeAll(new File(rpOutputDir), "ca.uhn.test");
|
rp.writeAll(new File(rpOutputDir), "ca.uhn.fhir.model.dstu");
|
||||||
//
|
//
|
||||||
// String vsOutputDir = "target/generated/valuesets/ca/uhn/fhir/model/dstu/valueset";
|
// String vsOutputDir = "target/generated/valuesets/ca/uhn/fhir/model/dstu/valueset";
|
||||||
// vsp.writeMarkedValueSets(vsOutputDir);
|
// vsp.writeMarkedValueSets(vsOutputDir);
|
||||||
|
|
|
@ -217,6 +217,10 @@ public abstract class BaseElement {
|
||||||
myShortName = theShortName;
|
myShortName = theShortName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clearTypes() {
|
||||||
|
getType().clear();
|
||||||
|
}
|
||||||
|
|
||||||
public void setTypeFromString(String theType) {
|
public void setTypeFromString(String theType) {
|
||||||
if (theType == null) {
|
if (theType == null) {
|
||||||
myType = null;
|
myType = null;
|
||||||
|
|
|
@ -13,6 +13,12 @@ public abstract class Child extends BaseElement {
|
||||||
|
|
||||||
private List<SimpleSetter> mySimpleStters = new ArrayList<SimpleSetter>();
|
private List<SimpleSetter> mySimpleStters = new ArrayList<SimpleSetter>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clearTypes() {
|
||||||
|
super.clearTypes();
|
||||||
|
mySimpleStters.clear();
|
||||||
|
}
|
||||||
|
|
||||||
public String getAnnotationType() {
|
public String getAnnotationType() {
|
||||||
return getSingleType();
|
return getSingleType();
|
||||||
}
|
}
|
||||||
|
|
|
@ -334,6 +334,7 @@ public abstract class BaseStructureParser {
|
||||||
for (BaseRootType next : myResources) {
|
for (BaseRootType next : myResources) {
|
||||||
ourLog.info("Writing Resource {}", next.getName());
|
ourLog.info("Writing Resource {}", next.getName());
|
||||||
|
|
||||||
|
scanForCorrections(next);
|
||||||
scanForTypeNameConflicts(next);
|
scanForTypeNameConflicts(next);
|
||||||
fixResourceReferenceClassNames(next, thePackageBase);
|
fixResourceReferenceClassNames(next, thePackageBase);
|
||||||
|
|
||||||
|
@ -349,6 +350,18 @@ public abstract class BaseStructureParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void scanForCorrections(BaseRootType theNext) {
|
||||||
|
if (theNext.getElementName().equals("ResourceReference")) {
|
||||||
|
for (BaseElement next : theNext.getChildren()) {
|
||||||
|
if (next.getElementName().equals("reference")) {
|
||||||
|
next.clearTypes();
|
||||||
|
next.setTypeFromString("id");
|
||||||
|
scanForSimpleSetters((Child) next);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private String translateClassName(String theName) {
|
private String translateClassName(String theName) {
|
||||||
if ("List".equals(theName)) {
|
if ("List".equals(theName)) {
|
||||||
return "ListResource";
|
return "ListResource";
|
||||||
|
|
|
@ -256,7 +256,7 @@ public class ${className}
|
||||||
* The reference itself
|
* The reference itself
|
||||||
*/
|
*/
|
||||||
public ResourceReferenceDt(String theId) {
|
public ResourceReferenceDt(String theId) {
|
||||||
setResourceId(new IdDt(theId));
|
setReference(new IdDt(theId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -267,7 +267,7 @@ public class ${className}
|
||||||
* The reference itself
|
* The reference itself
|
||||||
*/
|
*/
|
||||||
public ResourceReferenceDt(IdDt theResourceId) {
|
public ResourceReferenceDt(IdDt theResourceId) {
|
||||||
setResourceId(theResourceId);
|
setReference(theResourceId);
|
||||||
}
|
}
|
||||||
#end
|
#end
|
||||||
|
|
||||||
|
@ -404,19 +404,6 @@ public class ${className}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
#end
|
#end
|
||||||
#if ( ${className} == "ResourceReferenceDt" )
|
|
||||||
/** TODO: document */
|
|
||||||
@Override
|
|
||||||
public IdDt getResourceId() {
|
|
||||||
return new IdDt(myReference.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
/** TODO: document */
|
|
||||||
@Override
|
|
||||||
public void setResourceId(IdDt theResourceId) {
|
|
||||||
myReference = new StringDt(theResourceId.getValue());
|
|
||||||
}
|
|
||||||
#end
|
|
||||||
#childExtensionTypes( $childExtensionTypes )
|
#childExtensionTypes( $childExtensionTypes )
|
||||||
|
|
||||||
}
|
}
|
|
@ -134,6 +134,23 @@
|
||||||
}
|
}
|
||||||
#end
|
#end
|
||||||
#if ( ${child.boundCode} && ${child.repeatable} )
|
#if ( ${child.boundCode} && ${child.repeatable} )
|
||||||
|
/**
|
||||||
|
* Add a value for <b>${child.elementName}</b> (${child.shortName}) using an enumerated type. This
|
||||||
|
* is intended as a convenience method for situations where the FHIR defined ValueSets are mandatory
|
||||||
|
* or contain the desirable codes. If you wish to use codes other than those which are built-in,
|
||||||
|
* you may also use the {@link ${hash}addType()} method.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* <b>Definition:</b>
|
||||||
|
* ${child.definition}
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
|
public ${child.boundDatatype}<${child.bindingClass}> add${child.methodName}(${child.bindingClass} theValue) {
|
||||||
|
${child.boundDatatype}<${child.bindingClass}> retVal = new ${child.boundDatatype}<${child.bindingClass}>(${child.bindingClass}.VALUESET_BINDER, theValue);
|
||||||
|
get${child.methodName}().add(retVal);
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a value for <b>${child.elementName}</b> (${child.shortName})
|
* Add a value for <b>${child.elementName}</b> (${child.shortName})
|
||||||
*
|
*
|
||||||
|
@ -142,8 +159,10 @@
|
||||||
* ${child.definition}
|
* ${child.definition}
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public void add${child.methodName}(${child.bindingClass} theValue) {
|
public ${child.boundDatatype}<${child.bindingClass}> add${child.methodName}() {
|
||||||
get${child.methodName}().add(new ${child.boundDatatype}<${child.bindingClass}>(${child.bindingClass}.VALUESET_BINDER, theValue));
|
${child.boundDatatype}<${child.bindingClass}> retVal = new ${child.boundDatatype}<${child.bindingClass}>(${child.bindingClass}.VALUESET_BINDER);
|
||||||
|
get${child.methodName}().add(retVal);
|
||||||
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue