Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.
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 @@ -112,3 +112,4 @@ Questions about the project can be asked in the [Da Vinci CRD stream on the FHIR

This project welcomes Pull Requests. Any issues identified with the RI should be submitted via the [GitHub issue tracker](https://github.com/HL7-DaVinci/CRD/issues).


15 changes: 13 additions & 2 deletions resources/src/main/java/org/cdshooks/CdsRequest.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.cdshooks;

import com.fasterxml.jackson.annotation.JsonGetter;

import javax.validation.constraints.NotNull;
import org.hl7.davinci.EncounterBasedServiceContext;

Expand Down Expand Up @@ -83,5 +81,18 @@ public void setContext(serviceContextTypeT context) {
*/
public abstract Object getDataForPrefetchToken();

@Override
public String toString(){
StringBuilder sb = new StringBuilder();
sb.append("[hook: " + hook + "]");
sb.append("[hookInstance: " + hookInstance + "]");
sb.append("[fhirServer: " + fhirServer + "]");
sb.append("[fhirAuthorization: " + fhirAuthorization + "]");
sb.append("[context: " + context + "]");
sb.append("[extension: " + extension + "]");
sb.append("[prefetch: " + prefetch + "]");
return sb.toString();
}


}
19 changes: 19 additions & 0 deletions resources/src/main/java/org/cdshooks/Coding.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.cdshooks;

public class Coding {

private String code;

private String system = null;

private String display = null;

public String getCode() { return code; }
public void setCode(String code) { this.code = code; }

public String getSystem() { return system; }
public void setSystem(String system) { this.system = system; }

public String getDisplay() { return display; }
public void setDisplay(String display) { this.display = display; }
}
4 changes: 4 additions & 0 deletions resources/src/main/java/org/cdshooks/Extension.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ public class Extension {
public Configuration getConfiguration() { return configuration; }

public void setConfiguration(Configuration configuration) { this.configuration = configuration; }

public String toString(){
return "Extension configuration: " + configuration;
}
}
16 changes: 13 additions & 3 deletions resources/src/main/java/org/cdshooks/Source.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ public class Source {

private String url = null;

private String icon = null;

private Coding topic = null;

public String getLabel() {
return label;
}

public void setLabel(String label) {
this.label = label;
}
public void setLabel(String label) { this.label = label; }

public String getUrl() {
return url;
Expand All @@ -20,4 +22,12 @@ public String getUrl() {
public void setUrl(String url) {
this.url = url;
}

public String getIcon() { return icon; }

public void setIcon(String icon) { this.icon = icon; }

public Coding getTopic() { return topic; }

public void setTopic(Coding topic) { this.topic = topic; }
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package org.hl7.davinci;

import org.hl7.fhir.r4.model.Bundle;

public interface EncounterBasedServiceContext {
String getUserId();
String getPatientId();
String getEncounterId();
Bundle getDraftOrders();
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,9 @@ public String getQuery() {
public Class getReturnType() {
return returnType;
}

@Override
public String toString(){
return "[" + key + ", " + query + ", " + returnType + "]";
}
}
45 changes: 45 additions & 0 deletions resources/src/main/java/org/hl7/davinci/r4/CardTypes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package org.hl7.davinci.r4;

import org.cdshooks.Coding;

public enum CardTypes {
COVERAGE("coverage", "Coverage"),
DOCUMENTATION("documentation", "Documentation"),
PRIOR_AUTH("prior-auth", "Prior Authorization"),
DTR_CLIN("dtr-clin", "DTR Clin"),
DTR_ADMIN("dtr-admin", "DTR Admin"),
CLAIM("claim", "Claim"),
INSURANCE("insurance", "Insurance"),
LIMITS("limits", "Limits"),
NETWORK("network", "Network"),
APPROPRIATE_USE("appropriate-use", "Appropriate Use"),
COST("cost", "Cost"),
THERAPY_ALTERNATIVES_OPT("therapy-alternatives-opt", "Therapy Alternatives Opt"),
THERAPY_ALTERNATIVES_REG("therapy-alternatives-req", "Therapy Alternatives Req"),
CLINICAL_REMINDER("clinical-reminder", "Clinical Reminder"),
DUPLICATE_THERAPY("duplicate-therapy", "Duplicate Therapy"),
CONTRAINDICATION("contraindication", "Contraindication"),
GUIDELINE("guideline", "Guideline"),
OFF_GUIDELINE("off-guideline", "Off Guideline");

private String code;
private String display;
private static String codeSystem = "http://hl7.org/fhir/us/davinci-crd/CodeSystem/cardType";

CardTypes(String code, String display) {
this.code = code;
this.display = display;
}

public String getCode() { return code; }
public String getDisplay() { return display; }
public String getCodeSystem() { return codeSystem; }

public Coding getCoding() {
Coding coding = new Coding();
coding.setSystem(codeSystem);
coding.setCode(code);
coding.setDisplay(display);
return coding;
}
}
33 changes: 33 additions & 0 deletions resources/src/main/java/org/hl7/davinci/r4/CoverageGuidance.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.hl7.davinci.r4;

import org.hl7.fhir.r4.model.Coding;

public enum CoverageGuidance {
NOT_COVERED("not-covered", "Not Covered"),
COVERED("covered", "Covered"),
PRIOR_AUTH("prior-auth", "Prior authorization"),
CLINICAL("clinical", "Clinical"),
ADMIN("admin", "Admin");


private String code;
private String display;
private static String codeSystem = "http://hl7.org/fhir/us/davinci-crd/CodeSystem/coverageGuidance";

CoverageGuidance(String code, String display) {
this.code = code;
this.display = display;
}

public String getCode() { return code; }
public String getDisplay() { return display; }
public String getCodeSystem() { return codeSystem; }

public Coding getCoding() {
Coding coding = new Coding();
coding.setSystem(codeSystem);
coding.setCode(code);
coding.setDisplay(display);
return coding;
}
}
11 changes: 8 additions & 3 deletions resources/src/main/java/org/hl7/davinci/r4/Utilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.parser.IParser;

import org.hl7.davinci.*;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.r4.model.*;
Expand Down Expand Up @@ -169,9 +170,13 @@ public static PractitionerRoleInfo getPractitionerRoleInfo(
public static List<Organization> getPayors(List<Coverage> coverages) {
List<Organization> payors = new ArrayList<>();
for (Coverage coverage: coverages){
for (Reference ref: coverage.getPayor()){
Organization organization = (Organization) ref.getResource();
payors.add(organization);
if (coverage != null) {
for (Reference ref: coverage.getPayor()){
Organization organization = (Organization) ref.getResource();
if (organization != null) {
payors.add(organization);
}
}
}
}
return payors;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package org.hl7.davinci.r4.crdhook;

import java.util.ArrayList;
import java.util.List;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.hl7.davinci.r4.JacksonBundleDeserializer;
import org.hl7.davinci.r4.JacksonHapiSerializer;
import org.hl7.fhir.r4.model.*;
import org.hl7.fhir.r4.model.Bundle.BundleEntryComponent;

/**
* Class that supports the representation of prefetch information in a CDS Hook request.
Expand Down Expand Up @@ -103,4 +107,74 @@ public void setSupplyRequestBundle(Bundle supplyRequestBundle) {
public Bundle getMedicationStatementBundle() { return medicationStatementBundle; }

public void setMedicationStatementBundle(Bundle medicationStatementBundle) { this.medicationStatementBundle = medicationStatementBundle; }

/**
* Checks whether the given resource exists in the requested resource type.
* @param id
* @return
*/
public boolean containsRequestResourceId(String id) {
return this.bundleContainsResourceId(this.deviceRequestBundle, id)
|| this.bundleContainsResourceId(this.medicationRequestBundle, id)
|| this.bundleContainsResourceId(this.nutritionOrderBundle, id)
|| this.bundleContainsResourceId(this.serviceRequestBundle, id)
|| this.bundleContainsResourceId(this.supplyRequestBundle, id)
|| this.bundleContainsResourceId(this.appointmentBundle, id)
|| this.bundleContainsResourceId(this.encounterBundle, id)
|| this.bundleContainsResourceId(this.medicationDispenseBundle, id)
|| this.bundleContainsResourceId(this.medicationStatementBundle, id);
}

/**
* Returns whether the given bundle contains the given resource.
* @param bundle
* @param id
* @return
*/
private boolean bundleContainsResourceId(Bundle bundle, String id) {
if (bundle == null) {
return false;
}
if (id.contains("/")) {
String[] splitId = id.split("/");
id = splitId[splitId.length-1];
}
final String idToCheck = id;
return bundle.getEntry().stream().anyMatch(entry -> entry.getResource().getId().contains(idToCheck));
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
List<BundleEntryComponent> entries = new ArrayList<>();
if(this.deviceRequestBundle != null){
entries = this.deviceRequestBundle.getEntry();
} else if(this.nutritionOrderBundle != null){
entries = this.nutritionOrderBundle.getEntry();
} else if(this.serviceRequestBundle != null){
entries = this.serviceRequestBundle.getEntry();
} else if(this.medicationDispenseBundle != null){
entries = this.medicationDispenseBundle.getEntry();
} else if(this.medicationStatementBundle != null){
entries = this.medicationStatementBundle.getEntry();
} else if(this.encounterBundle != null){
entries = this.encounterBundle.getEntry();
} else if(this.appointmentBundle != null){
entries = this.appointmentBundle.getEntry();
} else if(this.medicationRequestBundle != null){
entries = this.medicationRequestBundle.getEntry();
} else if(this.supplyRequestBundle != null){
entries = this.supplyRequestBundle.getEntry();
}
sb.append("[");
for(BundleEntryComponent entry : entries) {
sb.append(entry.getResource());
sb.append("-");
sb.append(entry.getResource().getId());
sb.append(",");
}
sb.setLength(sb.length()-1);
sb.append("]");
return sb.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,10 @@ public Object getDataForPrefetchToken() {
return mapForPrefetchTemplates;
}

@Override
public String toString() {
return "Super: " + super.toString() + " OrderSignRequest: " + getDataForPrefetchToken().toString();
}


}
Loading