How Can I Access A Patient's Id? - hapi-fhir

Please have a look at the following Patient response that I received from http://fhirtest.uhn.ca/baseDstu3. I would like to access the 4081340 value in the id tag but I have been unable to find it in the org.hl7.fhir.dstu3.model.Patient API. Would someone please show me how?
<Patient xmlns="http://hl7.org/fhir">
<id value="4081340"></id>
<meta>
<versionId value="1"></versionId>
<lastUpdated value="2018-06-04T15:13:28.069+00:00"></lastUpdated>
</meta>
<text>
<status value="generated"></status>
<div xmlns="http://www.w3.org/1999/xhtml">
<div class="hapiHeaderText">Robert Jozef
<b>VAESSEN </b>
</div>
<table class="hapiPropertyTable">
<tbody>
<tr>
<td>Identifier</td>
<td>12345</td>
</tr>
<tr>
<td>Date of birth</td>
<td>
<span>30 January 1954</span>
</td>
</tr>
</tbody>
</table>
</div>
</text>
<identifier>
<system value="http://dmw.levy.com/mrn"></system>
<value value="12345"></value>
</identifier>
<name>
<family value="Vaessen"></family>
<given value="Robert"></given>
<given value="Jozef"></given>
</name>
<gender value="male"></gender>
<birthDate value="1954-01-30"></birthDate>
</Patient>
Update:
The reason that I want to access the 4081340 value is that I need it in order to execute code such as this:
private void deletePatient(String id) {
try {
OperationOutcome outcome = (OperationOutcome) client.delete().resourceById(new IdDt("Patient", id)).execute();
}
catch (Exception e) {
System.out.printf("Cannot delete patient with id = %s\n%s\n", id, e.getMessage());
}
}
private void retrievePatient(String id) {
try {
Patient patient = client.read().resource(Patient.class).withId(id).execute();
String description = parser.encodeResourceToString(patient);
System.out.printf("Successfully retrieved patient with ID = %s:\n%s\n", id, description);
}
catch (ResourceNotFoundException e) {
System.out.printf("Cannot find patient with id = %s\n", id);
}
}
The following statements all print http://hapi.fhir.org/baseDstu3/Patient/4081340/_history/1. I could parse that to obtain the 4081340
System.out.printf("\t%s\n", patient.getId());
System.out.printf("\t%s\n", patient.getIdBase());
System.out.printf("\t%s\n", patient.getIdElement());
When I examine a Patient in the debugger, I can see the value in the field myUnqualifiedId but I cannot discover how to get at it.

I found it:
patient.getIdElement().getIdPart()

Related

Get list from DB using stuts2

I have a list in Stuts2 and I would like to see it in the jpa I put the name of the list but I dosen't work and I dont recive any error
<s:iterator value="UserService.users">
<tr>
<td><s:property value="nom" /></td>
<td><s:property value="prenom" /></td>
<td><s:property value="username" /></td>
<td><s:property value="password" /></td>
<td><s:property value="tel" /></td>
</tr>
</s:iterator>
public static void list() {
SessionFactory sessionFactory = new Configuration().
configure("hibernate.cfg.xml").
addAnnotatedClass(User.class).
buildSessionFactory();
Session session = sessionFactory.openSession();
try{
session.beginTransaction();
List<User> users = session.createQuery("from User").getResultList();
for(User u : users){
System.out.println(u);
}
session.getTransaction().commit();
}finally{
sessionFactory.close();
}
}
A Struts 2 tutorial will save you some time; this is very basic and shows little effort.
Make users a property on the action and expose it with a getter.
<s:iterator value="users">
<s:property value="nom" />
...

Why Does My FAMILY Query Fail?

Please have a look at the following code wherein I have a method that searches by family name and another that searches by system. Following the code I have provided the results that were produced by invoking each of these two methods. You can see that the system search returned three patients, the third one having the family name Vaessen. But, when I search for the family name Vaessen a timeout results. Would someone please help me to understand why this is happening?
Note: As you can see from the timeout exception, I am querying the public fhir server http://fhirtest.uhn.ca/baseDstu3
public void findPatientsInFamily(String family) {
System.out.printf("\n\nFinding patients in family %s\n", family);
findPatients(Patient.FAMILY.matches().value(family));
}
public void findPatientsInSystem(String system) {
System.out.printf("\n\nFinding patients in system %s\n", system);
findPatients(Patient.IDENTIFIER.hasSystemWithAnyCode(system));
}
#SuppressWarnings("rawtypes")
public void findPatients(ICriterion criterion) {
try {
Bundle bundle = client.search().forResource(Patient.class).where(criterion).returnBundle(Bundle.class).execute();
for (BundleEntryComponent entry : bundle.getEntry()) {
if (entry.getResource().getResourceType() == ResourceType.Patient) {
Patient patient = (Patient) entry.getResource();
System.out.printf("%s\n", parser.encodeResourceToString(patient));
}
}
}
catch(Exception e) {
System.out.printf("Cannot find patients\n%s\n", e.getMessage());
}
}
Results for the findPatientsInSystem(String system) method:
Finding patients in system http://dmw.levy.com/mrn
<Patient xmlns="http://hl7.org/fhir">
<id value="4172808"></id>
<meta>
<versionId value="1"></versionId>
<lastUpdated value="2018-06-07T14:10:52.336+00:00"></lastUpdated>
</meta>
<text>
<status value="generated"></status>
<div xmlns="http://www.w3.org/1999/xhtml">
<div class="hapiHeaderText">Rachael
<b>LANEHART </b>
</div>
<table class="hapiPropertyTable">
<tbody>
<tr>
<td>Identifier</td>
<td>12345</td>
</tr>
<tr>
<td>Date of birth</td>
<td>
<span>30 December 1985</span>
</td>
</tr>
</tbody>
</table>
</div>
</text>
<identifier>
<system value="http://dmw.levy.com/mrn"></system>
<value value="12345"></value>
</identifier>
<name>
<family value="Lanehart"></family>
<given value="Rachael"></given>
</name>
<gender value="female"></gender>
<birthDate value="1985-12-30"></birthDate>
</Patient>
<Patient xmlns="http://hl7.org/fhir">
<id value="4149602"></id>
<meta>
<versionId value="1"></versionId>
<lastUpdated value="2018-06-06T20:52:11.831+00:00"></lastUpdated>
</meta>
<text>
<status value="generated"></status>
<div xmlns="http://www.w3.org/1999/xhtml">
<div class="hapiHeaderText">Ravi
<b>THAKKAR </b>
</div>
<table class="hapiPropertyTable">
<tbody>
<tr>
<td>Identifier</td>
<td>12345</td>
</tr>
<tr>
<td>Date of birth</td>
<td>
<span>14 April 1962</span>
</td>
</tr>
</tbody>
</table>
</div>
</text>
<identifier>
<system value="http://dmw.levy.com/mrn"></system>
<value value="12345"></value>
</identifier>
<name>
<family value="Thakkar"></family>
<given value="Ravi"></given>
</name>
<gender value="male"></gender>
<birthDate value="1962-04-14"></birthDate>
</Patient>
<Patient xmlns="http://hl7.org/fhir">
<id value="4013201"></id>
<meta>
<versionId value="1"></versionId>
<lastUpdated value="2018-06-01T18:30:23.902+00:00"></lastUpdated>
</meta>
<text>
<status value="generated"></status>
<div xmlns="http://www.w3.org/1999/xhtml">
<div class="hapiHeaderText">Robert Jozef
<b>VAESSEN </b>
</div>
<table class="hapiPropertyTable">
<tbody>
<tr>
<td>Identifier</td>
<td>12345</td>
</tr>
<tr>
<td>Date of birth</td>
<td>
<span>30 January 1954</span>
</td>
</tr>
</tbody>
</table>
</div>
</text>
<identifier>
<system value="http://dmw.levy.com/mrn"></system>
<value value="12345"></value>
</identifier>
<name>
<family value="Vaessen"></family>
<given value="Robert"></given>
<given value="Jozef"></given>
</name>
<gender value="male"></gender>
<birthDate value="1954-01-30"></birthDate>
</Patient>
Results for the findPatientsInFamily(String family) method:
Finding patients in family Vaessen
Cannot find patients
Failed to parse response from server when performing GET to URL http://fhirtest.uhn.ca/baseDstu3/Patient?family=Vaessen - java.net.SocketTimeoutException: Read timed out
The way in which your code queries the FHIR Server should be fine for a Patient search by system or family name.
I tried the public test server through the UI at http://fhirtest.uhn.ca/ and everything appears to be down currently. Every request returns an error. There is already an issue posted here on GIT https://github.com/jamesagnew/hapi-fhir/issues/998.
It is also possible that when the server is back up, there may be so much patient data that your request will still error unless a large connection timeout is set, or more filter criteria is provided.

Footable table timeout when row count is over 1000

I have tried to implement footable pluglin on an MVC application and it currently has 3000+ users which fail to load and the browser page times out. For the User Admin section I have created the following View:
#model IEnumerable<MyBudgetWeb.Models.ApplicationUser>
#{
ViewBag.Title = "Index";
}
<script src="~/Scripts/jquery-1.10.2.js"></script>
<script type="text/javascript">
$(function () {
$('.footable').footable();
});
</script>
<br /><br />
<h2>Bill Pay Users</h2>
<input id="filter" type="text" placeholder="Filter" />
<br /><br />
#if (Model.Count() > 0)
{
<table class="table" data-filter="#filter" data-page-size="50">
<thead>
<tr>
<th data-type="numeric">Customer Number</th>
<th data-type="numeric">Account Name</th>
<th data-type="numeric" data-hide="phone">Go Live Date</th>
<th data-type="numeric" data-hide="phone">Online Live Date</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
#foreach (var item in Model)
{
<tr>
<td>#item.CustomerNumber</td>
<td>#item.AccountName</td>
<td>#item.GoLiveDate</td>
<td>#item.OnlineCreationTimestamp</td>
<td>
#Html.ActionLink("Edit", "Edit", new { id = item.Id }) |
#Html.ActionLink("Details", "Details", new { id = item.Id }) |
#*#Html.ActionLink("Delete", "Delete", new { id = item.Id })*#
</td>
</tr>
}
</tbody>
<tfoot class="hide-if-no-paging">
<tr>
<td colspan="12" class="text-center">
<ul class="pagination"></ul>
</td>
</tr>
</tfoot>
</table>
}
else
{
<h2>You are still awaiting users to be added. All users will be displayed here.</h2>
}
My controller looks as follows:
public async Task<ActionResult> Index()
{
return View(await UserManager.Users.ToListAsync());
}
Is there any way workarounds to prevent this?
there are 2 option to solve:
1. PHP Side script, by setting the time limit of execution. Use this code on top your PHP script:
set_time_limit(0);
Use Footable AJAX what describe here:
http://fooplugins.github.io/FooTable/

Select field in grails workflow

I have a problem prefilling a dropdown list in an grails webflow
I have a controller for the webflow
class ClearanceRequestController {
def index() {
redirect(action: "start")
}
def startFlow = {
contact {
on('next') {
flow.developer = params.developer
flow.project = params.project
flow.projectResponsible = params.projectResponsible
flow.email = params.email
[flow : flow]
}.to('application')
on('cancel').to('finish')
...
and the view looks like this:
contact.gsp
<g:if test="${message}">
<div class="message">${message}</div>
</g:if>
<g:form action="start" method="post">
<div class="dialog">
<table>
<tbody>
<tr class="prop">
<td valign="top" class="name">
<label for="projectName">Projekt:</label>
</td>
<td valign="top">
<input type="text" id="projectName" name="project" value="${params.project}" />
</td>
</tr>
<g:select name="state" from="${Project?.DIVISION_OPTIONS}" value="${Project?.DIVISION_OPTIONS}"/>
This is the Project definition
class Project {
static DIVISION_OPTIONS = ["A", "B", "C", "D"]
String name
String division
String toString(){
"$name"
}
static constraints = {
name(unique: true)
division(inList: DIVISION_OPTIONS)
}
}
I don't know how to get the data from the constraints. I tried to access
Project.constraints.division.inList
or
Project.DIVISION_OPTIONS
but both didn't worked. I assume I have to initialize the Project somewhere and pass it to the contact.gsp, but I don't know how.
OK I got it, just import the Project in the page, like
<%# page import="com.companyName.Project" contentType="text/html;charset=UTF-8" %>
or like:
<g:select name="state" from="${com.companyName.Project?.DIVISION_OPTIONS}" value="${com.companyName.Project?.DIVISION_OPTIONS}"/>

Spring 3 form validation shows error messages but field name not displayed

I have a 2 item form, that requires that both fields be entered. I'm using annotated validations, and am getting error messages, but they do not print the field name, just "may not be blank" instead of "one may not be blank" where one is the field name.
Any ideas? This is a pretty simple example:
#Controller
#SessionAttributes
public class HomeController
{
private static final Logger logger = LoggerFactory
.getLogger(HomeController.class);
#RequestMapping(value = "/", method = RequestMethod.GET)
public String home(Locale locale, Model model)
{
logger.info("Welcome home! The client locale is {}.", locale);
model.addAttribute("homeformitem", new HomeFormItem());
return "home";
}
#RequestMapping(value = "/", method = RequestMethod.POST)
public String home(
#ModelAttribute("homeformitem") #Valid HomeFormItem item,
BindingResult result)
{
logger.info("Posting form");
logger.info(item.toString());
if (result.hasErrors())
{
return "home";
} else
{
logger.info("No Errors");
return "done";
}
}
}
Here is the form. I get the error message, but not the field name.
Form Validation!
<f:form method="post" modelAttribute="homeformitem">
<fieldset>
<legend>Fields</legend>
<table>
<tr><td colspan="3"><f:errors path="*"/></td></tr>
<tr>
<td><f:label path="one" for="one">One: </f:label></td>
<td><f:input path="one" /></td>
<td><f:errors path="one" cssClass="errorblock"/></td>
</tr>
<tr>
<td><f:label path="two" for="two">Two: </f:label></td>
<td><f:input path="two" /></td>
<td><f:errors path="two" cssClass="errorblock"/></td>
</tr>
<tr>
<td colspan="3"><input type="submit" value="Test" /></td>
</tr>
</table>
</fieldset>
</f:form>
You need a validation.properties file at /WEB-INF/messages with an entry similar to this (for example):
NotEmpty.homeFormItem.one=The field {0} is empty
And don't forget to add a spring bean to resolve your validation messages:
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="/WEB-INF/messages/validation" />
</bean>