Fix a few issues with JPA

This commit is contained in:
jamesagnew 2014-05-21 16:17:45 -04:00
parent 8053967032
commit 1b44e7282d
18 changed files with 413 additions and 77 deletions

View File

@ -61,12 +61,12 @@ import ca.uhn.fhir.model.dstu.composite.IdentifierDt;
import ca.uhn.fhir.model.dstu.resource.Conformance;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.model.primitive.StringDt;
import ca.uhn.fhir.parser.DataFormatException;
import ca.uhn.fhir.rest.annotation.Metadata;
import ca.uhn.fhir.rest.client.GenericClient;
import ca.uhn.fhir.rest.client.api.IBasicClient;
import ca.uhn.fhir.rest.server.Constants;
import ca.uhn.fhir.rest.server.EncodingEnum;
import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
public class RestfulServerTesterServlet extends HttpServlet {
@ -94,6 +94,8 @@ public class RestfulServerTesterServlet extends HttpServlet {
myStaticResources.put("shBrushPlain.js", "text/javascript");
myStaticResources.put("shCore.css", "text/css");
myStaticResources.put("shThemeDefault.css", "text/css");
myStaticResources.put("json2.js", "text/javascript");
myStaticResources.put("minify.json.js", "text/javascript");
myCtx = new FhirContext();
}
@ -154,6 +156,10 @@ public class RestfulServerTesterServlet extends HttpServlet {
ctx.setVariable("conf", conformance);
ctx.setVariable("base", myServerBase);
ctx.setVariable("jsonEncodedConf", myCtx.newJsonParser().encodeResourceToString(conformance));
theResp.setContentType("text/html");
theResp.setCharacterEncoding("UTF-8");
myTemplateEngine.process(theReq.getPathInfo(), ctx, theResp.getWriter());
} catch (Exception e) {
ourLog.error("Failed to respond", e);
@ -167,9 +173,11 @@ public class RestfulServerTesterServlet extends HttpServlet {
myTemplateEngine.getCacheManager().clearAllCaches();
}
GenericClient client = (GenericClient) myCtx.newRestfulGenericClient(myServerBase);
client.setKeepResponses(true);
boolean returnsResource;
try {
GenericClient client = (GenericClient) myCtx.newRestfulGenericClient(myServerBase);
client.setKeepResponses(true);
String method = theReq.getParameter("method");
String prettyParam = theReq.getParameter("configPretty");
@ -182,14 +190,6 @@ public class RestfulServerTesterServlet extends HttpServlet {
client.setEncoding(EncodingEnum.JSON);
}
String requestUrl;
String action;
String resultStatus;
String resultBody;
String resultSyntaxHighlighterClass;
boolean returnsResource;
try {
if ("conformance".equals(method)) {
returnsResource = true;
client.conformance();
@ -241,57 +241,24 @@ public class RestfulServerTesterServlet extends HttpServlet {
client.history(def.getImplementingClass(), new IdDt(id));
} else if ("create".equals(method)) {
RuntimeResourceDefinition def = getResourceType(theReq);
String resourceText = StringUtils.defaultString(theReq.getParameter("resource"));
if (StringUtils.isBlank(resourceText)) {
theResp.sendError(Constants.STATUS_HTTP_400_BAD_REQUEST, "No resource content specified");
}
IResource resource;
if (client.getEncoding() == null || client.getEncoding() == EncodingEnum.XML) {
resource = myCtx.newXmlParser().parseResource(def.getImplementingClass(), resourceText);
} else {
resource = myCtx.newJsonParser().parseResource(def.getImplementingClass(), resourceText);
}
IResource resource = parseIncomingResource(theReq, theResp, client);
returnsResource = false;
client.create(resource);
} else if ("validate".equals(method)) {
RuntimeResourceDefinition def = getResourceType(theReq);
String resourceText = StringUtils.defaultString(theReq.getParameter("resource"));
if (StringUtils.isBlank(resourceText)) {
theResp.sendError(Constants.STATUS_HTTP_400_BAD_REQUEST, "No resource content specified");
}
IResource resource;
if (client.getEncoding() == null || client.getEncoding() == EncodingEnum.XML) {
resource = myCtx.newXmlParser().parseResource(def.getImplementingClass(), resourceText);
} else {
resource = myCtx.newJsonParser().parseResource(def.getImplementingClass(), resourceText);
}
IResource resource = parseIncomingResource(theReq, theResp, client);
returnsResource = false;
client.validate(resource);
} else if ("update".equals(method)) {
RuntimeResourceDefinition def = getResourceType(theReq);
String resourceText = StringUtils.defaultString(theReq.getParameter("resource"));
if (StringUtils.isBlank(resourceText)) {
theResp.sendError(Constants.STATUS_HTTP_400_BAD_REQUEST, "No resource content specified");
}
String id = StringUtils.defaultString(theReq.getParameter("id"));
if (StringUtils.isBlank(id)) {
theResp.sendError(Constants.STATUS_HTTP_400_BAD_REQUEST, "No ID specified");
}
IResource resource;
if (client.getEncoding() == null || client.getEncoding() == EncodingEnum.XML) {
resource = myCtx.newXmlParser().parseResource(def.getImplementingClass(), resourceText);
} else {
resource = myCtx.newJsonParser().parseResource(def.getImplementingClass(), resourceText);
}
IResource resource = parseIncomingResource(theReq, theResp, client);
returnsResource = false;
client.update(new IdDt(id), resource);
@ -343,11 +310,16 @@ public class RestfulServerTesterServlet extends HttpServlet {
theResp.sendError(Constants.STATUS_HTTP_400_BAD_REQUEST, "Invalid method: " + method);
return;
}
} catch (BaseServerResponseException e) {
ourLog.error("Failed to invoke method", e);
returnsResource = false;
}
} catch (DataFormatException e) {
ourLog.error("Failed to invoke method", e);
returnsResource = false;
} catch (Exception e) {
ourLog.error("Failure during processing", e);
returnsResource = false;
}
try {
HttpRequestBase lastRequest = client.getLastRequest();
String requestBody = null;
String requestSyntaxHighlighterClass = null;
@ -377,13 +349,14 @@ public class RestfulServerTesterServlet extends HttpServlet {
}
}
}
requestUrl = lastRequest.getURI().toASCIIString();
action = client.getLastRequest().getMethod();
resultStatus = client.getLastResponse().getStatusLine().toString();
resultBody = client.getLastResponseBody();
String resultSyntaxHighlighterClass;
String requestUrl = lastRequest!=null?lastRequest.getURI().toASCIIString():null;
String action = client.getLastRequest()!=null?client.getLastRequest().getMethod():null;
String resultStatus = client.getLastResponse()!=null?client.getLastResponse().getStatusLine().toString():null;
String resultBody = client.getLastResponseBody();
HttpResponse lastResponse = client.getLastResponse();
ContentType ct = ContentType.get(lastResponse.getEntity());
ContentType ct = lastResponse!=null?ContentType.get(lastResponse.getEntity()):null;
String mimeType = ct != null ? ct.getMimeType() : null;
EncodingEnum ctEnum = EncodingEnum.forContentType(mimeType);
String narrativeString = "";
@ -408,8 +381,8 @@ public class RestfulServerTesterServlet extends HttpServlet {
}
}
Header[] requestHeaders = applyHeaderFilters(lastRequest.getAllHeaders());
Header[] responseHeaders = applyHeaderFilters(lastResponse.getAllHeaders());
Header[] requestHeaders = lastRequest!=null?applyHeaderFilters(lastRequest.getAllHeaders()): new Header[0];
Header[] responseHeaders = lastResponse!=null?applyHeaderFilters(lastResponse.getAllHeaders()):new Header[0];
WebContext ctx = new WebContext(theReq, theResp, theReq.getServletContext(), theReq.getLocale());
ctx.setVariable("base", myServerBase);
@ -431,6 +404,28 @@ public class RestfulServerTesterServlet extends HttpServlet {
}
}
private IResource parseIncomingResource(HttpServletRequest theReq, HttpServletResponse theResp, GenericClient theClient) throws ServletException, IOException {
RuntimeResourceDefinition def = getResourceType(theReq);
String resourceText = StringUtils.defaultString(theReq.getParameter("resource"));
if (StringUtils.isBlank(resourceText)) {
theResp.sendError(Constants.STATUS_HTTP_400_BAD_REQUEST, "No resource content specified");
}
IResource resource;
if (theClient.getEncoding() == null) {
if (resourceText.trim().startsWith("{")) {
resource = myCtx.newJsonParser().parseResource(def.getImplementingClass(), resourceText);
}else {
resource = myCtx.newXmlParser().parseResource(def.getImplementingClass(), resourceText);
}
} else if (theClient.getEncoding() == EncodingEnum.XML) {
resource = myCtx.newXmlParser().parseResource(def.getImplementingClass(), resourceText);
} else {
resource = myCtx.newJsonParser().parseResource(def.getImplementingClass(), resourceText);
}
return resource;
}
private Header[] applyHeaderFilters(Header[] theAllHeaders) {
if (myFilterHeaders == null || myFilterHeaders.isEmpty()) {
return theAllHeaders;
@ -445,8 +440,8 @@ public class RestfulServerTesterServlet extends HttpServlet {
}
/**
* If set, the headers named here will be stripped from requests/responses before they are displayed to the user. This can be used, for instance, to filter out "Authorization" headers. Note that
* names are not case sensitive.
* If set, the headers named here will be stripped from requests/responses before they are displayed to the user.
* This can be used, for instance, to filter out "Authorization" headers. Note that names are not case sensitive.
*/
public void setFilterHeaders(String... theHeaderNames) {
myFilterHeaders = new HashSet<String>();

View File

@ -14,6 +14,9 @@ This file is a Thymeleaf template for the
<script type="text/javascript" src="jquery-2.1.0.min.js"></script>
<script type="text/javascript" src="PublicTester.js"></script>
<link rel="stylesheet" type="text/css" href="PublicTester.css"/>
<meta charset="UTF-8"/>
<script type="text/javascript" src="json2.js"></script>
<script type="text/javascript" src="minify.json.js"></script>
</head>
<body>
<table border="0" width="100%">
@ -117,7 +120,6 @@ This file is a Thymeleaf template for the
</table>
</th:block>
</th:block>
</td>
</tr>
</table>

View File

@ -81,6 +81,14 @@ function displayConformance(button, expandoTr) {
clearCurrentForm(postCompleteFunction);
}
function minifyTextarea(self) {
var value = value;
value = value.replace(/[\u00A0\u1680\u180e\u2000-\u2009\u200a\u200b\u202f\u205f\u3000]/g,' ');
//value = JSON.minify(value);
$('#textarea').val(value);
return addConfigElementsToForm(self);
}
/** Create a tester form for the 'read' method */
function displayCreate(button, expandoTr, resourceName) {
highlightSelectedLink(button);
@ -89,11 +97,11 @@ function displayCreate(button, expandoTr, resourceName) {
$('<tr class="testerNameRow" style="display: none;" />').append(
$('<td class="testerNameCell">Create</td>'),
$('<td />').append(
$('<form/>', { action: 'PublicTesterResult.html', method: 'POST', onsubmit: "addConfigElementsToForm(this);" }).append(
$('<form/>', { action: 'PublicTesterResult.html', method: 'POST', onsubmit: "minifyTextarea(this);" }).append(
$('<input />', { name: 'method', value: 'create', type: 'hidden' }),
$('<input />', { name: 'resourceName', value: resourceName, type: 'hidden' }),
$('<div class="textareaWrapper">').append(
$('<textarea />', { name: 'resource', rows: 10, style: 'white-space: nowrap;' })
$('<textarea />', { id: 'textarea', name: 'resource', rows: 10, style: 'white-space: nowrap;' })
),
$('<br />'),
$('<input />', { type: 'submit', value: 'Submit' })
@ -137,11 +145,11 @@ function displayUpdate(button, expandoTr, resourceName) {
$('<tr class="testerNameRow" style="display: none;" />').append(
$('<td class="testerNameCell">Update</td>'),
$('<td />').append(
$('<form/>', { action: 'PublicTesterResult.html', method: 'POST', onsubmit: "addConfigElementsToForm(this);" }).append(
$('<form/>', { action: 'PublicTesterResult.html', method: 'POST', onsubmit: "minifyTextarea(this);" }).append(
$('<input />', { name: 'method', value: 'update', type: 'hidden' }),
$('<input />', { name: 'resourceName', value: resourceName, type: 'hidden' }),
$('<input />', { name: 'id', placeholder: 'Resource ID', type: 'text' }),
$('<textarea />', { name: 'resource', cols: 100, rows: 10, style: 'white-space: nowrap;' }),
$('<textarea />', { id: 'textarea', name: 'resource', cols: 100, rows: 10, style: 'white-space: nowrap;' }),
$('<br />'),
$('<input />', { type: 'submit', value: 'Submit' })
)
@ -282,10 +290,10 @@ function displayValidate(button, expandoTr, resourceName) {
$('<tr class="testerNameRow" style="display: none;" />').append(
$('<td class="testerNameCell">Validate</td>'),
$('<td />').append(
$('<form/>', { action: 'PublicTesterResult.html', method: 'POST', onsubmit: "addConfigElementsToForm(this);" }).append(
$('<form/>', { action: 'PublicTesterResult.html', method: 'POST', onsubmit: "minifyTextarea(this);" }).append(
$('<input />', { name: 'method', value: 'validate', type: 'hidden' }),
$('<input />', { name: 'resourceName', value: resourceName, type: 'hidden' }),
$('<textarea />', { name: 'resource', cols: 100, rows: 10, style: 'white-space: nowrap;' }),
$('<textarea />', { id: 'textarea', name: 'resource', cols: 100, rows: 10, style: 'white-space: nowrap;' }),
$('<br />'),
$('<input />', { type: 'submit', value: 'Submit' })
)

View File

@ -0,0 +1,11 @@
/*!
http://www.JSON.org/json2.js
2009-09-29
Public Domain.
NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
See http://www.JSON.org/js.html
*/
if(!this.JSON){this.JSON={}}(function(){function l(c){return c<10?'0'+c:c}if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(c){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+l(this.getUTCMonth()+1)+'-'+l(this.getUTCDate())+'T'+l(this.getUTCHours())+':'+l(this.getUTCMinutes())+':'+l(this.getUTCSeconds())+'Z':null};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(c){return this.valueOf()}}var o=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,p=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,h,m,r={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},j;function q(a){p.lastIndex=0;return p.test(a)?'"'+a.replace(p,function(c){var f=r[c];return typeof f==='string'?f:'\\u'+('0000'+c.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function n(c,f){var a,e,d,i,k=h,g,b=f[c];if(b&&typeof b==='object'&&typeof b.toJSON==='function'){b=b.toJSON(c)}if(typeof j==='function'){b=j.call(f,c,b)}switch(typeof b){case'string':return q(b);case'number':return isFinite(b)?String(b):'null';case'boolean':case'null':return String(b);case'object':if(!b){return'null'}h+=m;g=[];if(Object.prototype.toString.apply(b)==='[object Array]'){i=b.length;for(a=0;a<i;a+=1){g[a]=n(a,b)||'null'}d=g.length===0?'[]':h?'[\n'+h+g.join(',\n'+h)+'\n'+k+']':'['+g.join(',')+']';h=k;return d}if(j&&typeof j==='object'){i=j.length;for(a=0;a<i;a+=1){e=j[a];if(typeof e==='string'){d=n(e,b);if(d){g.push(q(e)+(h?': ':':')+d)}}}}else{for(e in b){if(Object.hasOwnProperty.call(b,e)){d=n(e,b);if(d){g.push(q(e)+(h?': ':':')+d)}}}}d=g.length===0?'{}':h?'{\n'+h+g.join(',\n'+h)+'\n'+k+'}':'{'+g.join(',')+'}';h=k;return d}}if(typeof JSON.stringify!=='function'){JSON.stringify=function(c,f,a){var e;h='';m='';if(typeof a==='number'){for(e=0;e<a;e+=1){m+=' '}}else if(typeof a==='string'){m=a}j=f;if(f&&typeof f!=='function'&&(typeof f!=='object'||typeof f.length!=='number')){throw new Error('JSON.stringify');}return n('',{'':c})}}if(typeof JSON.parse!=='function'){JSON.parse=function(i,k){var g;function b(c,f){var a,e,d=c[f];if(d&&typeof d==='object'){for(a in d){if(Object.hasOwnProperty.call(d,a)){e=b(d,a);if(e!==undefined){d[a]=e}else{delete d[a]}}}}return k.call(c,f,d)}o.lastIndex=0;if(o.test(i)){i=i.replace(o,function(c){return'\\u'+('0000'+c.charCodeAt(0).toString(16)).slice(-4)})}if(/^[\],:{}\s]*$/.test(i.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){g=eval('('+i+')');return typeof k==='function'?b({'':g},''):g}throw new SyntaxError('JSON.parse');}}}());

View File

@ -0,0 +1,61 @@
/*! JSON.minify()
v0.1 (c) Kyle Simpson
MIT License
*/
(function(global){
if (typeof global.JSON == "undefined" || !global.JSON) {
global.JSON = {};
}
global.JSON.minify = function(json) {
var tokenizer = /"|(\/\*)|(\*\/)|(\/\/)|\n|\r/g,
in_string = false,
in_multiline_comment = false,
in_singleline_comment = false,
tmp, tmp2, new_str = [], ns = 0, from = 0, lc, rc
;
tokenizer.lastIndex = 0;
while (tmp = tokenizer.exec(json)) {
lc = RegExp.leftContext;
rc = RegExp.rightContext;
if (!in_multiline_comment && !in_singleline_comment) {
tmp2 = lc.substring(from);
if (!in_string) {
tmp2 = tmp2.replace(/(\n|\r|\s)*/g,"");
}
new_str[ns++] = tmp2;
}
from = tokenizer.lastIndex;
if (tmp[0] == "\"" && !in_multiline_comment && !in_singleline_comment) {
tmp2 = lc.match(/(\\)*$/);
if (!in_string || !tmp2 || (tmp2[0].length % 2) == 0) { // start of string with ", or unescaped " character found to end string
in_string = !in_string;
}
from--; // include " character in next catch
rc = json.substring(from);
}
else if (tmp[0] == "/*" && !in_string && !in_multiline_comment && !in_singleline_comment) {
in_multiline_comment = true;
}
else if (tmp[0] == "*/" && !in_string && in_multiline_comment && !in_singleline_comment) {
in_multiline_comment = false;
}
else if (tmp[0] == "//" && !in_string && !in_multiline_comment && !in_singleline_comment) {
in_singleline_comment = true;
}
else if ((tmp[0] == "\n" || tmp[0] == "\r") && !in_string && !in_multiline_comment && in_singleline_comment) {
in_singleline_comment = false;
}
else if (!in_multiline_comment && !in_singleline_comment && !(/\n|\r|\s/.test(tmp[0]))) {
new_str[ns++] = tmp[0];
}
}
new_str[ns++] = rc;
return new_str.join("");
};
})(this);

View File

@ -0,0 +1,115 @@
<?xml version="1.0" encoding="UTF-8"?><Patient xmlns="http://hl7.org/fhir">
<text>
<status value="generated"/>
<div xmlns="http://www.w3.org/1999/xhtml">
<table>
<tbody>
<tr>
<td>Name</td>
<td>Peter James <b>Chalmers</b> (&quot;Jim&quot;)</td>
</tr>
<tr>
<td>Address</td>
<td>534 Erewhon, Pleasantville, Vic, 3999</td>
</tr>
<tr>
<td>Contacts</td>
<td>Home: unknown. Work: (03) 5555 6473</td>
</tr>
<tr>
<td>Id</td>
<td>MRN: 12345 (Acme Healthcare)</td>
</tr>
</tbody>
</table>
</div>
</text>
<!-- MRN assigned by ACME healthcare on 6-May 2001 -->
<identifier>
<use value="usual"/>
<label value="MRN"/>
<system value="urn:oid:1.2.36.146.595.217.0.1"/>
<value value="12345"/>
<period>
<start value="2001-05-06"/>
</period>
<assigner>
<display value="Acme Healthcare"/>
</assigner>
</identifier>
<!-- Peter James Chalmers, but called "Jim" -->
<name>
<use value="official"/>
<family value="Chalmers"/>
<given value="Peter"/>
<given value="James"/>
</name>
<name>
<use value="usual"/>
<given value="Jim"/>
</name>
<telecom>
<use value="home"/>
<!-- home communication details aren't known -->
</telecom>
<telecom>
<system value="phone"/>
<value value="(03) 5555 6473"/>
<use value="work"/>
</telecom>
<!-- use FHIR code system for male / female -->
<gender>
<coding>
<system value="http://hl7.org/fhir/v3/AdministrativeGender"/>
<code value="M"/>
<display value="Male"/>
</coding>
</gender>
<birthDate value="1974-12-25"/>
<deceasedBoolean value="false"/>
<address>
<use value="home"/>
<line value="534 Erewhon St"/>
<city value="PleasantVille"/>
<state value="Vic"/>
<zip value="3999"/>
</address>
<contact>
<relationship>
<coding>
<system value="http://hl7.org/fhir/patient-contact-relationship"/>
<code value="partner"/>
</coding>
</relationship>
<name>
<family value="du">
<!-- the "du" part is a family name prefix (VV in iso 21090) -->
<extension url="http://hl7.org/fhir/Profile/iso-21090#qualifier">
<valueCode value="VV"/>
</extension>
</family>
<family value="Marché"/>
<given value="Bénédicte"/>
</name>
<telecom>
<system value="phone"/>
<value value="+33 (237) 998327"/>
</telecom>
</contact>
<managingOrganization>
<reference value="Organization/1"/>
</managingOrganization>
<active value="true"/>
</Patient>

View File

@ -770,7 +770,12 @@ public class FhirResourceDao<T extends IResource> implements IFhirResourceDao<T>
}
Map<Class<? extends IResource>, IFhirResourceDao<?>> resourceTypeToDao = getResourceTypeToDao();
IFhirResourceDao<?> dao = resourceTypeToDao.get(type);
IFhirResourceDao<?> dao;
if (type.equals(myResourceType)) {
dao = this;
}else {
dao = resourceTypeToDao.get(type);
}
if (dao == null) {
throw new InvalidRequestException("This server is not able to handle resources of type: " + nextValue.getResourceType());
}

View File

@ -17,7 +17,7 @@ import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
@Entity
@Table(name = "RES_VER", uniqueConstraints = {})
@Table(name = "HFJ_RES_VER", uniqueConstraints = {})
public class ResourceHistoryTable extends BaseHasResource implements Serializable {
public static final String Q_GETALL = "SELECT h FROM ResourceHistoryTable h WHERE h.myPk.myId = :PID AND h.myPk.myResourceType = :RESTYPE ORDER BY h.myUpdated ASC";

View File

@ -13,7 +13,7 @@ import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Table(name = "HISTORY_TAG")
@Table(name = "HFJ_HISTORY_TAG")
public class ResourceHistoryTag extends BaseTag implements Serializable {
private static final long serialVersionUID = 1L;

View File

@ -13,7 +13,8 @@ import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@Entity
@Table(name = "SPIDX_DATE", indexes= {@Index(name="IDX_SP_DATE", columnList="SP_VALUE_LOW,SP_VALUE_HIGH")})
@Table(name = "HFJ_SPIDX_DATE", indexes= {@Index(name="IDX_SP_DATE", columnList="SP_VALUE_LOW,SP_VALUE_HIGH")})
//@org.hibernate.annotations.Table(appliesTo="HFJ_SPIDX_DATE",indexes= {@Index(name="IDX_SP_DATE", columnList="SP_VALUE_LOW,SP_VALUE_HIGH")})
public class ResourceIndexedSearchParamDate extends BaseResourceIndexedSearchParam {
private static final long serialVersionUID = 1L;

View File

@ -8,7 +8,7 @@ import javax.persistence.Index;
import javax.persistence.Table;
@Entity
@Table(name = "SPIDX_NUMBER", indexes= {@Index(name="IDX_SP_NUMBER", columnList="SP_VALUE")})
@Table(name = "HFJ_SPIDX_NUMBER", indexes= {@Index(name="IDX_SP_NUMBER", columnList="SP_VALUE")})
public class ResourceIndexedSearchParamNumber extends BaseResourceIndexedSearchParam {
private static final long serialVersionUID = 1L;

View File

@ -6,7 +6,7 @@ import javax.persistence.Index;
import javax.persistence.Table;
@Entity
@Table(name = "SPIDX_STRING", indexes= {@Index(name="IDX_SP_STRING", columnList="SP_VALUE_NORMALIZED")})
@Table(name = "HFJ_SPIDX_STRING", indexes= {@Index(name="IDX_SP_STRING", columnList="SP_VALUE_NORMALIZED")})
public class ResourceIndexedSearchParamString extends BaseResourceIndexedSearchParam {
private static final long serialVersionUID = 1L;

View File

@ -6,7 +6,7 @@ import javax.persistence.Index;
import javax.persistence.Table;
@Entity
@Table(name = "SPIDX_TOKEN", indexes = { @Index(name = "IDX_SP_STRING", columnList = "SP_SYSTEM,SP_VALUE") })
@Table(name = "HFJ_SPIDX_TOKEN", indexes = { @Index(name = "IDX_SP_STRING", columnList = "SP_SYSTEM,SP_VALUE") })
public class ResourceIndexedSearchParamToken extends BaseResourceIndexedSearchParam {
private static final long serialVersionUID = 1L;

View File

@ -14,13 +14,14 @@ import javax.persistence.Table;
import org.apache.commons.lang3.Validate;
@Entity
@Table(name = "RES_LINK")
@Table(name = "HFJ_RES_LINK")
public class ResourceLink implements Serializable {
private static final long serialVersionUID = 1L;
@GeneratedValue(strategy = GenerationType.AUTO)
@Id
@Column(name = "PID")
private Long myId;
@Column(name = "SRC_PATH", length = 100, nullable = false)

View File

@ -21,7 +21,7 @@ import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.primitive.IdDt;
@Entity
@Table(name = "RESOURCE", uniqueConstraints = {})
@Table(name = "HFJ_RESOURCE", uniqueConstraints = {})
@Inheritance(strategy = InheritanceType.JOINED)
public class ResourceTable extends BaseHasResource implements Serializable {
private static final long serialVersionUID = 1L;

View File

@ -1,5 +1,6 @@
package ca.uhn.fhir.jpa.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
@ -9,13 +10,14 @@ import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Table(name = "RES_TAG")
@Table(name = "HFJ_RES_TAG")
public class ResourceTag extends BaseTag {
private static final long serialVersionUID = 1L;
@GeneratedValue(strategy=GenerationType.AUTO)
@Id
@Column(name = "PID")
private Long myId;
@ManyToOne(cascade= {})

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding//src/test/java/ca/uhn/fhir/jpa/test/Upload.java=UTF-8

View File

@ -0,0 +1,133 @@
package ca.uhn.fhir.jpa.test;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.rest.api.MethodOutcome;
import ca.uhn.fhir.rest.client.IGenericClient;
public class Upload {
public static void main(String[] args) {
String msg = "{\n" +
" \"resourceType\": \"Patient\",\n" +
" \"text\": {\n" +
" \"status\": \"generated\",\n" +
" \"div\": \"<div>\\n <table>\\n <tbody>\\n <tr>\\n <td>Name</td>\\n <td>Peter James <b>Chalmers</b> (&quot;Jim&quot;)</td>\\n </tr>\\n <tr>\\n <td>Address</td>\\n <td>534 Erewhon, Pleasantville, Vic, 3999</td>\\n </tr>\\n <tr>\\n <td>Contacts</td>\\n <td>Home: unknown. Work: (03) 5555 6473</td>\\n </tr>\\n <tr>\\n <td>Id</td>\\n <td>MRN: 12345 (Acme Healthcare)</td>\\n </tr>\\n </tbody>\\n </table>\\n </div>\"\n" +
" },\n" +
" \"identifier\": [\n" +
" {\n" +
" \"use\": \"usual\",\n" +
" \"label\": \"MRN\",\n" +
" \"system\": \"urn:oid:1.2.36.146.595.217.0.1\",\n" +
" \"value\": \"12345\",\n" +
" \"period\": {\n" +
" \"start\": \"2001-05-06\"\n" +
" },\n" +
" \"assigner\": {\n" +
" \"display\": \"Acme Healthcare\"\n" +
" }\n" +
" }\n" +
" ],\n" +
" \"name\": [\n" +
" {\n" +
" \"use\": \"official\",\n" +
" \"family\": [\n" +
" \"Chalmers\"\n" +
" ],\n" +
" \"given\": [\n" +
" \"Peter\",\n" +
" \"James\"\n" +
" ]\n" +
" },\n" +
" {\n" +
" \"use\": \"usual\",\n" +
" \"given\": [\n" +
" \"Jim\"\n" +
" ]\n" +
" }\n" +
" ],\n" +
" \"telecom\": [\n" +
" {\n" +
" \"use\": \"home\"\n" +
" },\n" +
" {\n" +
" \"system\": \"phone\",\n" +
" \"value\": \"(03) 5555 6473\",\n" +
" \"use\": \"work\"\n" +
" }\n" +
" ],\n" +
" \"gender\": {\n" +
" \"coding\": [\n" +
" {\n" +
" \"system\": \"http://hl7.org/fhir/v3/AdministrativeGender\",\n" +
" \"code\": \"M\",\n" +
" \"display\": \"Male\"\n" +
" }\n" +
" ]\n" +
" },\n" +
" \"birthDate\": \"1974-12-25\",\n" +
" \"deceasedBoolean\": false,\n" +
" \"address\": [\n" +
" {\n" +
" \"use\": \"home\",\n" +
" \"line\": [\n" +
" \"534 Erewhon St\"\n" +
" ],\n" +
" \"city\": \"PleasantVille\",\n" +
" \"state\": \"Vic\",\n" +
" \"zip\": \"3999\"\n" +
" }\n" +
" ],\n" +
" \"contact\": [\n" +
" {\n" +
" \"relationship\": [\n" +
" {\n" +
" \"coding\": [\n" +
" {\n" +
" \"system\": \"http://hl7.org/fhir/patient-contact-relationship\",\n" +
" \"code\": \"partner\"\n" +
" }\n" +
" ]\n" +
" }\n" +
" ],\n" +
" \"name\": {\n" +
" \"family\": [\n" +
" \"du\",\n" +
" \"Marché\"\n" +
" ],\n" +
" \"_family\": [\n" +
" {\n" +
" \"extension\": [\n" +
" {\n" +
" \"url\": \"http://hl7.org/fhir/Profile/iso-21090#qualifier\",\n" +
" \"valueCode\": \"VV\"\n" +
" }\n" +
" ]\n" +
" },\n" +
" null\n" +
" ],\n" +
" \"given\": [\n" +
" \"Bénédicte\"\n" +
" ]\n" +
" },\n" +
" \"telecom\": [\n" +
" {\n" +
" \"system\": \"phone\",\n" +
" \"value\": \"+33 (237) 998327\"\n" +
" }\n" +
" ]\n" +
" }\n" +
" ],\n" +
" \"active\": true\n" +
"}";
FhirContext ctx = new FhirContext();
IGenericClient client = ctx.newRestfulGenericClient("http://localhost:8888/fhir/context");
MethodOutcome outcome = client.create(ctx.newJsonParser().parseResource(msg));
System.out.println(outcome.getId());
}
}