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

Dev #78

Merged
merged 15 commits into from
Sep 30, 2024
Merged

Dev #78

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
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
# Base image
FROM gradle:6.9.0-jdk11

# Set working directory so that all subsequent command runs in this folder
WORKDIR /test-ehr
# Copy app files to container
COPY --chown=gradle:gradle . .
RUN gradle build
# Expose port to access the app
EXPOSE 8080

#HealthCheck
HEALTHCHECK --interval=45s --start-period=60s --timeout=10m --retries=10 CMD curl --fail http://localhost:8080/test-ehr/r4/metadata || exit 1

# Command to run our app
CMD ./dockerRunnerProd.sh
4 changes: 4 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Base image
FROM gradle:6.9.0-jdk11

# Set working directory so that all subsequent command runs in this folder
WORKDIR /test-ehr
# Copy app files to container
Expand All @@ -8,5 +9,8 @@ RUN gradle build
# Expose port to access the app
EXPOSE 8080
EXPOSE 8081

HEALTHCHECK --interval=45s --start-period=60s --timeout=10m --retries=10 CMD curl --fail http://localhost:8080/test-ehr/r4/metadata || exit 1

# Command to run our app
CMD ./dockerRunnerDev.sh
9 changes: 9 additions & 0 deletions Dockerfile.keycloak
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
FROM registry.access.redhat.com/ubi9 AS ubi-micro-build
RUN mkdir -p /mnt/rootfs
RUN dnf install --installroot /mnt/rootfs curl --releasever 9 --setopt install_weak_deps=false --nodocs -y && \
dnf --installroot /mnt/rootfs clean all && \
rpm --root /mnt/rootfs -e --nodeps setup


FROM keycloak/keycloak:22.0.1
COPY --from=ubi-micro-build /mnt/rootfs /
HEALTHCHECK --interval=30s --start-period=15s --timeout=10m --retries=10 CMD curl --fail http://localhost:8080 || exit 1
COPY ./src/main/resources/ClientFhirServerRealm.json /opt/keycloak/data/import/ClientFhirServerRealm.json
53 changes: 53 additions & 0 deletions src/main/java/org/hl7/codex/rems/script/Body.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package org.hl7.codex.rems.script;

import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlElement;

@XmlRootElement(name="Body")
public class Body {
private RxFill rxFill;
private Status status;
private Error error;

@XmlElement(name="RxFill")
public RxFill getRxFill() {
return rxFill;
}
public void setRxFill(RxFill rxFill) {
this.rxFill = rxFill;
}

@XmlElement(name="Status")
public Status getStatus() {
return status;
}
public void setStatus(Status status) {
this.status = status;
}

@XmlElement(name="Error")
public Error getError() {
return error;
}
public void setError(Error error) {
this.error = error;
}

public Body() {
this.rxFill = null;
this.status = null;
this.error = null;
}

public Body(RxFill rxFill) {
this.rxFill = rxFill;
}

public Body(Status status) {
this.status = status;
}

public Body(Error error) {
this.error = error;
}
}
19 changes: 19 additions & 0 deletions src/main/java/org/hl7/codex/rems/script/Error.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.hl7.codex.rems.script;

public class Error {
public String Code;
public String DescriptionCode;
public String Description;

public Error() {
this.Code = null;
this.DescriptionCode = null;
this.Description = null;
}

public Error(String code, String descriptionCode, String description) {
this.Code = code;
this.DescriptionCode = descriptionCode;
this.Description = description;
}
}
21 changes: 20 additions & 1 deletion src/main/java/org/hl7/codex/rems/script/Message.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,18 @@

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

public Message() {
this.header = null;
this.body = null;
}

public Message(Header header, Body body) {
this.header = header;
this.body = body;
}

@XmlElement(name="Header")
public Header getHeader() {
Expand All @@ -14,4 +25,12 @@ public Header getHeader() {
public void setHeader(Header header) {
this.header = header;
}

@XmlElement(name="Body")
public Body getBody() {
return body;
}
public void setBody(Body body) {
this.body = body;
}
}
54 changes: 40 additions & 14 deletions src/main/java/org/hl7/codex/rems/script/NcpdpScriptController.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,48 @@ public class NcpdpScriptController {
* @param payload - the object used to serialize the XML in the request body.
* @return - an object containing the NCPDP Script Status to return.
*/
@PostMapping(value = "/script/rxfill", produces = {APPLICATION_XML}, consumes = {APPLICATION_XML})
@PostMapping(value = "/ncpdp/script", produces = {APPLICATION_XML}, consumes = {APPLICATION_XML})
@ResponseBody
public RxFillStatusMessage getScriptResponse(@RequestBody RxFillMessage payload) {
logger.info("NcpdpScriptController::getScriptResponse /script/rxfill");
public Message handleScriptMessage(@RequestBody Message payload) {
logger.info("NcpdpScriptController::handleScriptMessage /ncpdp/script");

Header header = payload.getHeader();
RxFillBody body = payload.getBody();
FillStatus.DispensedStatusEnum dispensedStatus = body.getRxFill().getFillStatus().getStatus();
Body body = payload.getBody();

Boolean returnSuccess = false;
String errorMessage = "";

if (body.getRxFill() != null) {
logger.info("NcpdpScriptController::handleScriptMessage RxFill Message");
handleRxFillMessage(body.getRxFill(), header);
returnSuccess = true;
} else if (body.getStatus() != null) {
errorMessage = "Status Message NOT supported";
logger.info("NcpdpScriptController::handleScriptMessage " + errorMessage);
} else {
errorMessage = "Unsupported NCPDP SCRIPT Message";
logger.info("NcpdpScriptController::handleScriptMessage " + errorMessage);
}

Body returnBody;
if (returnSuccess) {
// build the status to return
Status status = new Status("000", null, null, null);
returnBody = new Body(status);
} else {
// build the error to return
Error error = new Error("900", "1000", errorMessage);
returnBody = new Body(error);
}

Header returnHeader = new Header(header.getFrom().value, header.getTo().value,
header.getMessageId(), header.getPrescriberOrderNumber());
Message returnMessage = new Message(returnHeader, returnBody);
return returnMessage;
}

private void handleRxFillMessage(RxFill rxFill, Header header) {
FillStatus.DispensedStatusEnum dispensedStatus = rxFill.getFillStatus().getStatus();

logger.info(" PrescriberOrderNumber: " + header.getPrescriberOrderNumber());
logger.info(" Dispensed Status: " + dispensedStatus);
Expand Down Expand Up @@ -86,15 +120,7 @@ public RxFillStatusMessage getScriptResponse(@RequestBody RxFillMessage payload)
dispenseDetails.setRequestId(dispenseId);
medicationDispenseDao.update(medicationDispense, dispenseDetails);
logger.info(" Created new MedicationDispense: " + dispenseId);
}

// build the status to return
Header statusHeader = new Header(header.getFrom().value, header.getTo().value,
header.getMessageId(), header.getPrescriberOrderNumber());
Status status = new Status("000", null, null, null);
RxFillStatusBody statusBody = new RxFillStatusBody(status);
RxFillStatusMessage statusMessage = new RxFillStatusMessage(statusHeader, statusBody);
return statusMessage;
}
}

private MedicationDispense.MedicationDispenseStatus convertRxFillDispensedStatusToMedicationDispenseStatus(FillStatus.DispensedStatusEnum dispensedStatus) {
Expand Down
15 changes: 0 additions & 15 deletions src/main/java/org/hl7/codex/rems/script/RxFillBody.java

This file was deleted.

26 changes: 0 additions & 26 deletions src/main/java/org/hl7/codex/rems/script/RxFillMessage.java

This file was deleted.

23 changes: 0 additions & 23 deletions src/main/java/org/hl7/codex/rems/script/RxFillStatusBody.java

This file was deleted.

36 changes: 0 additions & 36 deletions src/main/java/org/hl7/codex/rems/script/RxFillStatusMessage.java

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ hapi:
# max_binary_size: 104857600
# max_page_size: 200
# retain_cached_searches_mins: 60
# reuse_cached_search_results_millis: 60000
reuse_cached_search_results_millis: 100
tester:
home:
name: Local Tester
Expand Down
Loading