Skip to content
This repository has been archived by the owner on Oct 15, 2019. It is now read-only.

Commit

Permalink
Added Web Service Endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesMarcogliese committed Oct 19, 2017
1 parent d7a3cce commit 9677379
Show file tree
Hide file tree
Showing 12 changed files with 108 additions and 26 deletions.
6 changes: 3 additions & 3 deletions src/main/java/core/IFhirSenderService.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,21 @@ public interface IFhirSenderService {
* @param options The options.
* @return A Fhir patient.
*/
public ca.uhn.fhir.model.dstu2.resource.Patient returnSoap(Demographic options);
public String returnSoap(Demographic options);

/**
* Returns the specified patients.
* @param patients The patients.
* @return A Fhir patient list.
*/
public List<ca.uhn.fhir.model.dstu2.resource.Patient> returnSoap(Iterable<Patient> patients);
public List<String> returnSoap(Iterable<Patient> patients);

/**
* Returns the specified patient.
* @param patient The patient.
* @return A Fhir patient.
*/
public ca.uhn.fhir.model.dstu2.resource.Patient returnSoap(Patient patient);
public String returnSoap(Patient patient);
//public Task sendAsync(Demographic options);
//public Task sendAsync(Iterable<Patient> patients);
//public void sendAsync(Patient patient);
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/core/model/Metadata.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package core.model;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;

/**
* Represents metadata about patient registration.
*/
@XmlRootElement(name = "metadata")
@XmlAccessorType(XmlAccessType.FIELD)
public class Metadata {
private String assigningAuthority;
private String receivingApplication;
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/core/model/componentModel/Address.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package core.model.componentModel;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;

/**
* Represents address options for a patient.
*/
@XmlRootElement(name = "address")
@XmlAccessorType(XmlAccessType.FIELD)
public class Address {
private String city;
private String country;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package core.model.componentModel;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;

/**
* Represents assigning authority options.
*/
@XmlRootElement(name = "alternateIdentifier")
@XmlAccessorType(XmlAccessType.FIELD)
public class AlternateIdentifier {
private String type;
private String value;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package core.model.componentModel;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Calendar;

/**
* Date of birth options for a patient.
*/
@XmlRootElement(name = "dateOfBirthOptions")
@XmlAccessorType(XmlAccessType.FIELD)
public class DateOfBirthOptions {
private Calendar end;
private Calendar exact;
Expand Down
27 changes: 19 additions & 8 deletions src/main/java/core/model/componentModel/Demographic.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,32 @@

import core.model.Metadata;

import javax.xml.bind.annotation.*;
import java.util.List;
import java.util.ArrayList;

/**
* Represents demographic options for a patient.
*/
@XmlRootElement(name = "demographic")
@XmlAccessorType(XmlAccessType.FIELD)
public class Demographic {
private ArrayList<Address> addresses;
@XmlElementWrapper(name = "addresses")
@XmlElement(name = "address")
private List<Address> addresses;
private DateOfBirthOptions dateOfBirthOptions;
private String gender;
private Metadata metadata;
private ArrayList<Name> names;
private ArrayList<AlternateIdentifier> otherIdentifiers;
@XmlElementWrapper(name = "names")
@XmlElement(name = "name")
private List<Name> names;
@XmlElementWrapper(name = "otherIdentifiers")
@XmlElement(name = "otherIdentifier")
private List<AlternateIdentifier> otherIdentifiers;
private String personIdentifier;
private ArrayList<RelatedPerson> relatedPersons;
@XmlElementWrapper(name = "relatedPersons")
@XmlElement(name = "relatedPerson")
private List<RelatedPerson> relatedPersons;
private Telecommunication telecomOptions;

/**
Expand All @@ -35,15 +46,15 @@ public Demographic() {
* Gets the address options for a patient.
* @return addresses
*/
public ArrayList<Address> getAddresses() {
public List<Address> getAddresses() {
return addresses;
}

/**
* Sets the address options for a patient.
* @param addresses Address options for a patient.
*/
public void setAddresses(ArrayList<Address> addresses) {
public void setAddresses(List<Address> addresses) {
this.addresses = addresses;
}

Expand Down Expand Up @@ -107,7 +118,7 @@ public List<Name> getNames() {
* Sets the name options for a patient.
* @param names Names of a patient.
*/
public void setNames(ArrayList<Name> names) {
public void setNames(List<Name> names) {
this.names = names;
}

Expand Down Expand Up @@ -155,7 +166,7 @@ public List<RelatedPerson> getRelatedPersons() {
* Sets the related persons options for a patient.
* @param relatedPersons Related Options for a patient.
*/
public void setRelatedPersons(ArrayList<RelatedPerson> relatedPersons) {
public void setRelatedPersons(List<RelatedPerson> relatedPersons) {
this.relatedPersons = relatedPersons;
}

Expand Down
7 changes: 7 additions & 0 deletions src/main/java/core/model/componentModel/Name.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
package core.model.componentModel;

import javax.xml.bind.annotation.*;
import java.util.List;
import java.util.ArrayList;

/**
* Represents name options for a patient.
*/
@XmlRootElement(name = "name")
@XmlAccessorType(XmlAccessType.FIELD)
public class Name {
private String firstName;
private String lastName;
@XmlElementWrapper(name = "middleNames")
@XmlElement(name = "middleName")
private List<String> middleNames;
private String prefix;
@XmlElementWrapper(name = "suffixes")
@XmlElement(name = "suffix")
private List<String> suffixes;

/**
Expand Down
22 changes: 19 additions & 3 deletions src/main/java/core/model/componentModel/RelatedPerson.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
package core.model.componentModel;

import javax.xml.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;

/**
* Represents related person options.
*/
@XmlRootElement(name = "relatedPerson")
@XmlAccessorType(XmlAccessType.FIELD)
public class RelatedPerson {
private List<Address> address;
@XmlElementWrapper(name = "addresses")
@XmlElement(name = "address")
private List<Address> addresses;
@XmlElementWrapper(name = "names")
@XmlElement(name = "name")
private List<Name> names;
private String phone;
private PatientRelationshipType relationship;

/**
* Initializes a new instance of the RelatedPerson class.
*/
public RelatedPerson() {
this.names = new ArrayList<>();
this.addresses = new ArrayList<>();
}

/**
* Represents a patient relationship type.
*/
Expand All @@ -30,15 +46,15 @@ public enum PatientRelationshipType {
* @return address
*/
public List<Address> getAddress() {
return address;
return addresses;
}

/**
* Sets the address.
* @param address The address of the related person.
*/
public void setAddress(List<Address> address) {
this.address = address;
this.addresses = address;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
package core.model.componentModel;

import javax.xml.bind.annotation.*;
import java.util.List;
import java.util.ArrayList;

/**
* Represents telecom options for a patient.
*/
@XmlRootElement(name = "telecommunication")
@XmlAccessorType(XmlAccessType.FIELD)
public class Telecommunication {
@XmlElementWrapper(name = "emailAddresses")
@XmlElement(name = "emailAddress")
private List<String> emailAddresses;
@XmlElementWrapper(name = "phoneNumbers")
@XmlElement(name = "phoneNumber")
private List<String> phoneNumbers;

/**
Expand Down
18 changes: 11 additions & 7 deletions src/main/java/fhir/FhirSenderService.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@ public void sendHttp(core.model.common.Patient patient) {
* @return A Fhir patient.
*/
@Override
public Patient returnSoap(Demographic options) {
public String returnSoap(Demographic options) {

FhirUtility fhirUtility = new FhirUtility();
return fhirUtility.generateCandidateRegistry(options);
Patient patient = fhirUtility.generateCandidateRegistry(options);
return fhirUtility.encodePatientToString(patient);
}

/**
Expand All @@ -84,10 +85,10 @@ public Patient returnSoap(Demographic options) {
* @return A Fhir patient list.
*/
@Override
public List<Patient> returnSoap(Iterable<core.model.common.Patient> patients) {
public List<String> returnSoap(Iterable<core.model.common.Patient> patients) {

FhirUtility fhirUtility = new FhirUtility();
ArrayList<Patient> arr = new ArrayList<>();
ArrayList<String> arr = new ArrayList<>();
Metadata metadata = new Metadata();
metadata.setAssigningAuthority("0.0.0.0"); //FILL
metadata.setReceivingApplication("Endpoint"); //FILL
Expand All @@ -97,7 +98,8 @@ public List<Patient> returnSoap(Iterable<core.model.common.Patient> patients) {

for (core.model.common.Patient currentPatient : patients) {

arr.add(fhirUtility.generateCandidateRegistry(currentPatient, metadata));
Patient patient = fhirUtility.generateCandidateRegistry(currentPatient, metadata);
arr.add(fhirUtility.encodePatientToString(patient));
}

return arr;
Expand All @@ -109,7 +111,7 @@ public List<Patient> returnSoap(Iterable<core.model.common.Patient> patients) {
* @return A Fhir patient.
*/
@Override
public Patient returnSoap(core.model.common.Patient patient) {
public String returnSoap(core.model.common.Patient patient) {

FhirUtility fhirUtility = new FhirUtility();
Metadata metadata = new Metadata();
Expand All @@ -119,7 +121,9 @@ public Patient returnSoap(core.model.common.Patient patient) {
metadata.setSendingApplication("Test");
metadata.setSendingFacility("Test");

return fhirUtility.generateCandidateRegistry(patient, metadata);
Patient patientResource = fhirUtility.generateCandidateRegistry(patient, metadata);

return fhirUtility.encodePatientToString(patientResource);
}

/* @Override
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/fhir/FhirUtility.java
Original file line number Diff line number Diff line change
Expand Up @@ -352,4 +352,11 @@ private String getAuthorizationToken(FhirEndpoint endpoint){

return accessToken;
}

public String encodePatientToString(Patient patient){

FhirContext ctx = FhirContext.forDstu2();

return ctx.newXmlParser().setPrettyPrint(true).encodeResourceToString(patient);
}
}
17 changes: 12 additions & 5 deletions src/main/java/messaging/model/GenerationResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,22 @@

import ca.uhn.fhir.model.dstu2.resource.Patient;

import javax.xml.bind.annotation.*;
import java.util.ArrayList;

/**
* Represents a generation response.
*/
@XmlRootElement(name = "generationResponse")
@XmlAccessorType(XmlAccessType.FIELD)
public class GenerationResponse {
private ArrayList<String> messages;
@XmlElementWrapper(name = "messages")
@XmlElement(name = "message")
private ArrayList<String> messages;
private Boolean hasErrors;
private ArrayList<Patient> patients;
@XmlElementWrapper(name = "patients")
@XmlElement(name = "patient")
private ArrayList<String> patients;

/**
* Initializes a new instance of the GenerationResponse class.
Expand Down Expand Up @@ -57,23 +64,23 @@ public void setHasErrors(Boolean hasErrors) {
* Gets the patients list.
* @return The patients.
*/
public ArrayList<Patient> getPatients() {
public ArrayList<String> getPatients() {
return patients;
}

/**
* Sets the patients list.
* @param patients The patients.
*/
public void setPatients(ArrayList<Patient> patients) {
public void setPatients(ArrayList<String> patients) {
this.patients = patients;
}

/**
* Adds a patient to the patient list.
* @param patient The patient.
*/
public void addPatient(Patient patient){
public void addPatient(String patient){
this.patients.add(patient);
}
}

0 comments on commit 9677379

Please sign in to comment.