Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 147 additions & 1 deletion src/edu/gatech/i3l/HealthPort/HealthPortInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@
import ca.uhn.fhir.model.dstu.composite.CodeableConceptDt;
import ca.uhn.fhir.model.dstu.composite.CodingDt;
import ca.uhn.fhir.model.dstu.composite.ContainedDt;
import ca.uhn.fhir.model.dstu.composite.PeriodDt;
import ca.uhn.fhir.model.dstu.composite.QuantityDt;
import ca.uhn.fhir.model.dstu.composite.ResourceReferenceDt;
import ca.uhn.fhir.model.dstu.resource.Condition;
import ca.uhn.fhir.model.dstu.resource.Medication;
import ca.uhn.fhir.model.dstu.resource.MedicationPrescription;
import ca.uhn.fhir.model.dstu.resource.Observation;
import ca.uhn.fhir.model.dstu.resource.Procedure;
import ca.uhn.fhir.model.dstu.resource.MedicationPrescription.Dispense;
import ca.uhn.fhir.model.dstu.resource.MedicationPrescription.DosageInstruction;
import ca.uhn.fhir.model.dstu.valueset.ConditionStatusEnum;
Expand Down Expand Up @@ -64,6 +66,7 @@ public class HealthPortInfo {
public static String OBSERVATION = "OBSERVATION";
public static String CONDITION = "CONDITIONS";
public static String MEDICATIONPRESCRIPTION = "MEDICATIONPRESCRIPTION";
public static String PROCEDURE = "PROCEDURES";

private DataSource dataSource;

Expand Down Expand Up @@ -643,7 +646,150 @@ else if (textStatus.equalsIgnoreCase("EXTENSIONS"))
NarrativeStatusEnum.EXTENSIONS);
}
retVal.add(medicationPrescript);
}
} else if (tableName.equals(PROCEDURE)) {
String theId = rs.getString("ID");
String patientId = rs.getString("SUBJECT");
String typeUri = rs.getString("TYPEURI");
String typeCode = rs.getString("TYPECODING");
String typeDisp = rs.getString("TYPEDISPLAY");
String indicationUri = rs.getString("INDICATIONURI");
String indicationCode = rs.getString("INDICATIONCODING");
String indicationText = rs.getString("INDICATIONTEXT");
//String performerName = rs.getString("PERFORMER");
String outcome = rs.getString("OUTCOME");
String report = rs.getString("REPORT");
String complicationUri = rs.getString("COMPLICATIONURI");
String complicationCode = rs.getString("COMPLICATIONCODING");
String complicationText = rs.getString("COMPLICATIONTEXT");
String followup = rs.getString("FOLLOWUP");
String notes = rs.getString("NOTES");

Timestamp startDateTS = rs.getTimestamp("STARTDATE");
java.util.Date startDate = null;
if (startDateTS != null) {
startDate = new Date(startDateTS.getTime());
}

Timestamp endDateTS = rs.getTimestamp("ENDDATE");
java.util.Date endDate = null;
if (endDateTS != null) {
endDate = new Date(endDateTS.getTime());
}

Procedure proc = new Procedure();

// Procedure ID
proc.setId(new IdDt(theId));

// Procedure Subject
proc.setSubject(new ResourceReferenceDt(patientId));

// Procedure Type
CodingDt typeCoding = new CodingDt(typeUri, typeCode);
if (typeDisp != null) {
typeCoding.setDisplay(typeDisp);
}

ArrayList<CodingDt> codingList = new ArrayList<CodingDt>();
codingList.add(typeCoding);

CodeableConceptDt typeDt = new CodeableConceptDt();
typeDt.setCoding(codingList);

proc.setType(typeDt);

// Procedure Indication
if ((indicationUri != null && indicationCode != null) || indicationText != null) {
CodeableConceptDt indicationDt = new CodeableConceptDt();

if (indicationUri != null && indicationCode != null) {
CodingDt indicationCoding = new CodingDt(indicationUri, indicationCode);

ArrayList<CodingDt> indicationList = new ArrayList<CodingDt>();
codingList.add(indicationCoding);
indicationDt.setCoding(indicationList);
}

if (indicationText != null) {
indicationDt.setText(indicationText);
}

ArrayList<CodeableConceptDt> indCodeableList = new ArrayList<CodeableConceptDt>();
indCodeableList.add(indicationDt);

proc.setIndication(indCodeableList);
}

// Procedure Performer. We don't have Performer resource yet.
// Just display it.
// if (performerName != null) {
// ResourceReferenceDt performerRefDt = new ResourceReferenceDt();
// performerRefDt.setDisplay(performerName);
// proc.setPerformer(performerRefDt);
// }

// Procedure Date
if (startDate != null) {
PeriodDt period = new PeriodDt();
period.setStart(new DateTimeDt(startDate));

if (endDate != null) {
period.setEnd(new DateTimeDt(endDate));
}
proc.setDate(period);
}

// Procedure Outcome
if (outcome != null) {
proc.setOutcome(outcome);
}

// Procedure Report. We don't have Report resource yet.
// Just display it.
if (report != null) {
ResourceReferenceDt reportRefDt = new ResourceReferenceDt();
reportRefDt.setDisplay(report);

ArrayList<ResourceReferenceDt> referenceList = new ArrayList<ResourceReferenceDt>();
referenceList.add(reportRefDt);

proc.setReport(referenceList);
}

// Procedure Complications
if ((complicationUri != null && complicationCode != null) || complicationText != null) {
CodeableConceptDt complicationDt = new CodeableConceptDt();

if (complicationUri != null && complicationCode != null) {
CodingDt complicationCoding = new CodingDt(complicationUri, complicationCode);

ArrayList<CodingDt> complicationList = new ArrayList<CodingDt>();
codingList.add(complicationCoding);
complicationDt.setCoding(complicationList);
}

if (complicationText != null) {
complicationDt.setText(complicationText);
}

ArrayList<CodeableConceptDt> compCodeableList = new ArrayList<CodeableConceptDt>();
compCodeableList.add(complicationDt);

proc.setComplication(compCodeableList);
}

// Procedure Follow Up
if (followup != null) {
proc.setFollowUp(followup);
}

// Procedure Notes
if (notes != null) {
proc.setNotes(notes);
}

retVal.add(proc);
}
}
}
} catch (NamingException | SQLException e) {
Expand Down
33 changes: 33 additions & 0 deletions src/edu/gatech/i3l/HealthPort/ProcedureSerializable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
*
*/
package edu.gatech.i3l.HealthPort;

import java.io.Serializable;

/**
* @author kfrazer3
*
*/
public class ProcedureSerializable implements Serializable {
private static final long serialVersionUID = 1L;

public String ID;
public String SUBJECT;
public String TYPEURI;
public String TYPECODING;
public String TYPEDISPLAY;
public String INDICATIONURI;
public String INDICATIONCODING;
public String INDICATIONTEXT;
//public String PERFORMER;
public String OUTCOME;
public String REPORT;
public String COMPLICATIONURI;
public String COMPLICATIONCODING;
public String COMPLICATIONTEXT;
public String FOLLOWUP;
public String NOTES;
public java.util.Date STARTDATE;
public java.util.Date ENDDATE;
}
2 changes: 2 additions & 0 deletions src/edu/gatech/i3l/HealthPort/RestfulServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import edu.gatech.i3l.HealthPort.providers.MedicationPrescrResource;
import edu.gatech.i3l.HealthPort.providers.ObservationResourceProvider;
import edu.gatech.i3l.HealthPort.providers.PatientResourceProvider;
import edu.gatech.i3l.HealthPort.providers.ProcedureResourceProvider;

import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -63,6 +64,7 @@ protected void initialize() throws ServletException {
resourceProviders.add(new ObservationResourceProvider());
resourceProviders.add(new ConditionResourceProvider());
resourceProviders.add(new MedicationPrescrResource());
resourceProviders.add(new ProcedureResourceProvider());
setResourceProviders(resourceProviders);

// /*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package edu.gatech.i3l.HealthPort.providers;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.dstu.resource.Procedure;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.model.primitive.InstantDt;
import ca.uhn.fhir.rest.annotation.IdParam;
import ca.uhn.fhir.rest.annotation.Read;
import ca.uhn.fhir.rest.annotation.RequiredParam;
import ca.uhn.fhir.rest.annotation.Search;
import ca.uhn.fhir.rest.param.ReferenceParam;
import ca.uhn.fhir.rest.server.IBundleProvider;
import ca.uhn.fhir.rest.server.IResourceProvider;
import edu.gatech.i3l.HealthPort.HealthPortInfo;

public class ProcedureResourceProvider implements IResourceProvider {
private HealthPortInfo healthPortUser;

// Constructor
public ProcedureResourceProvider() {
healthPortUser = new HealthPortInfo("jdbc/HealthPort");
}

@Override
public Class<? extends IResource> getResourceType() {
return Procedure.class;
}

@Read()
public Procedure getResourceById(@IdParam IdDt theId) {
List<String>Ids = new ArrayList<String>();
Ids.add(theId.getIdPart());

List<IResource> resourceList = null;
try {
resourceList = healthPortUser.getResourceList(HealthPortInfo.PROCEDURE, Ids);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

if (resourceList == null || resourceList.isEmpty()) return null;
return (Procedure) resourceList.get(0);
}

@Search()
public IBundleProvider getProceduresByPatient(
@RequiredParam(name = Procedure.SP_SUBJECT) ReferenceParam theSubject) {

final InstantDt searchTime = InstantDt.withCurrentTime();
String patientID = theSubject.getIdPart();

final List<String> matchingResourceIds = healthPortUser.getResourceIdsByPatient(HealthPortInfo.PROCEDURE, patientID);

return new IBundleProvider() {

@Override
public int size() {
return matchingResourceIds.size();
}

@Override
public List<IResource> getResources(int theFromIndex, int theToIndex) {
int end = Math.min(theToIndex, matchingResourceIds.size());
// System.out.println("From:"+theFromIndex+" To:"+theToIndex+" Total:"+matchingResourceIds.size());
List<String> idsToReturn = matchingResourceIds.subList(
theFromIndex, end);

List<IResource> retVal = null;
try {
retVal = healthPortUser.getResourceList(HealthPortInfo.PROCEDURE,
idsToReturn);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

return retVal;
}

@Override
public InstantDt getPublished() {
return searchTime;
}
};
}
}