Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RxFill support to test-ehr #67

Merged
merged 4 commits into from
Feb 15, 2024
Merged
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Finally, ensure that the [request generator](https://github.com/mcode/request-ge
| -------------- | ------------------------------------------------------ |
| `/test-ehr/` | Base server endpoint |
| `/test-ehr/r4` | EHR FHIR Server endpoint (will not resolve in browser) |
| `/test-ehr/script/rxfill` | NCPDP SCRIPT endpoint that RxFill messages from the pharmacy can be sent to (will not resolve in browser) |

## Version

Expand Down
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ dependencies {
// providedImplementation 'javax.servlet:javax.servlet-api:3.1.0'
// implementation group:'org.apache.tomcat', name:'tomcat-juli', version:property('tomcat.version')
implementation 'javax.interceptor:javax.interceptor-api:1.2.2'

implementation 'javax.xml.bind:jaxb-api:2.3.0'
implementation 'com.sun.xml.bind:jaxb-core:2.3.0'
implementation 'com.sun.xml.bind:jaxb-impl:2.3.0'
}

// To specify folder use -Dfhir_dir=<path>
Expand Down
21 changes: 20 additions & 1 deletion src/main/java/ca/uhn/fhir/jpa/starter/BaseJpaRestfulServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import ca.uhn.fhir.jpa.api.config.DaoConfig;
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao;
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao;
import ca.uhn.fhir.jpa.binstore.BinaryStorageInterceptor;
import ca.uhn.fhir.jpa.bulk.export.provider.BulkDataExportProvider;
import ca.uhn.fhir.jpa.interceptor.CascadingDeleteInterceptor;
Expand Down Expand Up @@ -66,7 +67,9 @@
import java.util.Optional;
import java.util.stream.Collectors;


import ca.uhn.fhir.rest.server.IResourceProvider;
import org.hl7.fhir.r4.model.DomainResource;
import ca.uhn.fhir.jpa.provider.BaseJpaResourceProvider;

public class BaseJpaRestfulServer extends RestfulServer {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseJpaRestfulServer.class);
Expand Down Expand Up @@ -420,4 +423,20 @@ private ServerConformanceR4 createConformance(RestfulServer theRestfulServer, IF
myApplicationContext.getAutowireCapableBeanFactory().autowireBean(con);
return con;
}

/*
* Get the FHIR Resource DAO for the specified FHIR Resource.
*/
public <T extends DomainResource> IFhirResourceDao<T> getDao(Class<T> c) {
List<IResourceProvider> resProvList = getResourceProviders();
for (IResourceProvider prov : resProvList) {

if (prov.getResourceType() == c) {
ourLog.info("BaseJpaRestfulServer::getDao: " + prov.getClass());
BaseJpaResourceProvider<T> sProv = (BaseJpaResourceProvider<T>)prov;
return sProv.getDao();
}
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
@Configuration
@Conditional(OnR4Condition.class)
@ComponentScan(basePackages = "org.hl7.davinci.ehrserver.authproxy")
@ComponentScan(basePackages = "org.hl7.codex.rems.script")
@Import(StarterCqlR4Config.class)
public class FhirServerConfigR4 extends BaseJavaConfigR4 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
@Configuration
@ComponentScan(basePackages = "org.hl7.davinci.ehrserver.authproxy")
@ComponentScan(basePackages = "org.hl7.codex.rems.script")
@Import(FhirTesterMvcConfig.class)
public class FhirTesterConfig {

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/ca/uhn/fhir/jpa/starter/JpaRestfulServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
import org.springframework.context.annotation.Import;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Component("JpaRestfulServer")
@Import(AppProperties.class)
public class JpaRestfulServer extends BaseJpaRestfulServer {
@Autowired
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/org/hl7/codex/rems/script/DispensedStatus.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.hl7.codex.rems.script;

/*
* The possible values include: Dispensed, PartiallyDispensed, NotDispensed, Transferred
*/
public class DispensedStatus {
public String ReferenceNumber;
public String Note;
public String ReasonCode;
}
65 changes: 65 additions & 0 deletions src/main/java/org/hl7/codex/rems/script/FillStatus.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package org.hl7.codex.rems.script;

import javax.xml.bind.annotation.XmlElement;

public class FillStatus {
private DispensedStatus dispensed;
private DispensedStatus partiallyDispensed;
private DispensedStatus notDispensed;
private DispensedStatus transferred;

enum DispensedStatusEnum {
DISPENSED,
PARTIALLY_DISPENSED,
NOT_DISPENSED,
TRANSFERRED,
UNKNOWN
}

@XmlElement(name="Dispensed")
public DispensedStatus getDispensed() {
return dispensed;
}
public void setDispensed(DispensedStatus dispensed) {
this.dispensed = dispensed;
}

@XmlElement(name="PartiallyDispensed")
public DispensedStatus getPartiallyDispensed() {
return partiallyDispensed;
}
public void setPartiallyDispensed(DispensedStatus partiallyDispensed) {
this.partiallyDispensed = partiallyDispensed;
}

@XmlElement(name="NotDispensed")
public DispensedStatus getNotDispensed() {
return notDispensed;
}
public void setNotDispensed(DispensedStatus notDispensed) {
this.notDispensed = notDispensed;
}

@XmlElement(name="Transferred")
public DispensedStatus getTransferred() {
return transferred;
}
public void setTransferred(DispensedStatus transferred) {
this.transferred = transferred;
}

public DispensedStatusEnum getStatus() {
if (getDispensed() != null) {
return DispensedStatusEnum.DISPENSED;
} else if (getPartiallyDispensed() != null) {
return DispensedStatusEnum.PARTIALLY_DISPENSED;
} else if (getNotDispensed() != null) {
return DispensedStatusEnum.NOT_DISPENSED;
} else if (getTransferred() != null) {
return DispensedStatusEnum.TRANSFERRED;
} else {
return DispensedStatusEnum.UNKNOWN;
}
}

}
87 changes: 87 additions & 0 deletions src/main/java/org/hl7/codex/rems/script/Header.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package org.hl7.codex.rems.script;

import javax.xml.bind.annotation.XmlElement;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class Header {
private Tag to;
private Tag from;
private String sentTime;
private String messageId;
private String relatesToMessageId;
private String prescriberOrderNumber;

public Header() {
this.to = null;
this.from = null;
this.sentTime = null;
this.messageId = null;
this.relatesToMessageId = null;
this.prescriberOrderNumber = null;
}

public Header(String to, String from, String relatesToMessageId,
String prescriberOrderNumber) {
this.to = new Tag("P", to);
this.from = new Tag("C", from);

LocalDateTime now = LocalDateTime.now();
this.sentTime = now.toString();

DateTimeFormatter nowFormatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSSSSS");
String nowFormatted = now.format(nowFormatter);
this.messageId = nowFormatted;

this.relatesToMessageId = relatesToMessageId;
this.prescriberOrderNumber = prescriberOrderNumber;
}

@XmlElement(name="To")
public Tag getTo() {
return to;
}
public void setTo(Tag to) {
this.to = to;
}

@XmlElement(name="From")
public Tag getFrom() {
return from;
}
public void setFrom(Tag from) {
this.from = from;
}

@XmlElement(name="SentTime")
public String getSentTime() {
return sentTime;
}
public void setSentTime(String sentTime) {
this.sentTime = sentTime;
}

@XmlElement(name="MessageID")
public String getMessageId() {
return messageId;
}
public void setMessageId(String messageId) {
this.messageId = messageId;
}

@XmlElement(name="RelatesToMessageID")
public String getRelatesToMessageId() {
return relatesToMessageId;
}
public void setRelatesToMessageId(String relatesToMessageId) {
this.relatesToMessageId = relatesToMessageId;
}

@XmlElement(name="PrescriberOrderNumber")
public String getPrescriberOrderNumber() {
return prescriberOrderNumber;
}
public void setPrescriberOrderNumber(String prescriberOrderNumber) {
this.prescriberOrderNumber = prescriberOrderNumber;
}
}
30 changes: 30 additions & 0 deletions src/main/java/org/hl7/codex/rems/script/Message.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.hl7.codex.rems.script;

//import java.io.Serializable;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlElement;

@XmlRootElement(name="Message")
//public class Message implements Serializable {
public class Message {
protected Header header;
//protected Body body;

@XmlElement(name="Header")
public Header getHeader() {
return header;
}
public void setHeader(Header header) {
this.header = header;
}

/*
@XmlElement(name="Body")
public Body getBody() {
return body;
}
public void setBody(Body body) {
this.body = body;
}
*/
}
Loading
Loading