Skip to content

Commit

Permalink
Date Roller update to remove legacy formatting requirements (#423)
Browse files Browse the repository at this point in the history
Updated date roller to enable updates on prefetch elements without the legacy formatting requirements
  • Loading branch information
c-schuler authored Mar 23, 2023
1 parent b11282c commit dbb6b6c
Show file tree
Hide file tree
Showing 2 changed files with 153 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ public HookDataDateRoller(FhirContext FHIRContext, IOUtils.Encoding encoding) {
}

public JsonObject rollJSONHookDates(JsonObject hook) {
if (!hook.get("context").isJsonNull()) {
if (hook.has("context")) {
JsonObject context = hook.getAsJsonObject("context");
this.rollContextDates(context);
hook.remove("context");
hook.add("context", context);
}
if (!hook.get("prefetch").isJsonNull()) {
if (hook.has("prefetch")) {
JsonObject prefetch = hook.getAsJsonObject("prefetch");
this.rollPrefetchItemsDates(prefetch);
hook.remove("prefetch");
Expand All @@ -41,7 +41,7 @@ public JsonObject rollJSONHookDates(JsonObject hook) {
}

public void rollContextDates(JsonObject context) {
if (!context.get("draftOrders").isJsonNull()) {
if (context.has("draftOrders")) {
JsonObject draftOrders = context.getAsJsonObject("draftOrders");
IBaseResource resource = resourceParser.parseResource(draftOrders.toString());
if (null == resource) {
Expand Down Expand Up @@ -69,7 +69,13 @@ public void rollPrefetchItemsDates(JsonObject prefetch) {
}else{
continue;
}
IBaseResource resource = resourceParser.parseResource(item.getAsJsonObject("resource").toString());
IBaseResource resource;
if (item.has("resource")) {
resource = resourceParser.parseResource(item.getAsJsonObject("resource").toString());
}
else {
resource = resourceParser.parseResource(item.toString());
}
if (null == resource) {
logger.info("This hook did not contain prefetch items");
continue;
Expand All @@ -79,8 +85,10 @@ public void rollPrefetchItemsDates(JsonObject prefetch) {
} else {
ResourceDataDateRoller.rollResourceDates(fhirContext, resource);
}
JsonObject response = item.getAsJsonObject("response");
item.add("response", response);
if (item.has("response")) {
JsonObject response = item.getAsJsonObject("response");
item.add("response", response);
}
addUpdatedJsonObject(resource, item, "resource");
// addUpdatedJsonObject(resource, prefetch, "item" + i);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
{
"hookInstance": "6bc883b2-b795-4dcb-b661-34884a31d472",
"fhirServer": "http://localhost:8080/fhir",
"hook": "order-sign",
"context": {
"userId": "Practitioner/example",
"patientId": "Patient/example-rec-01-true-make-recommendations",
"draftOrders": {
"resourceType": "Bundle",
"type": "collection",
"entry": [
{
"resource": {
"resourceType": "MedicationRequest",
"id": "05f8cb26-2eb6-4124-b65d-bb1f13e21c49",
"extension": [
{
"url": "http://fhir.org/guides/cdc/opioid-cds/StructureDefinition/dataDateRoller",
"extension": [
{
"url": "dateLastUpdated",
"valueDateTime": "2022-10-10"
},
{
"url": "frequency",
"valueDuration": {
"value": 30.0,
"unit": "days",
"system": "http://unitsofmeasure.org",
"code": "d"
}
}
]
}
],
"status": "active",
"intent": "order",
"category": [
{
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/medicationrequest-category",
"code": "community",
"display": "Community"
}
]
}
],
"medicationCodeableConcept": {
"coding": [
{
"system": "http://www.nlm.nih.gov/research/umls/rxnorm",
"code": "1010603",
"display": "Suboxone 2 MG / 0.5 MG Sublingual Film"
}
]
},
"subject": {
"reference": "Patient/example-rec-01-true-make-recommendations"
},
"encounter": {
"reference": "Encounter/example-rec-01-in-outpatient-opioid-context"
},
"authoredOn": "2022-10-10",
"dosageInstruction": [
{
"timing": {
"repeat": {
"frequency": 1,
"period": 1.0,
"periodUnit": "d"
}
},
"asNeededBoolean": false,
"doseAndRate": [
{
"doseQuantity": {
"value": 1.0,
"unit": "film"
}
}
]
}
],
"dispenseRequest": {
"validityPeriod": {
"start": "2022-10-10T00:00:00-06:00",
"end": "2023-01-10T00:00:00-07:00"
},
"numberOfRepeatsAllowed": 1,
"expectedSupplyDuration": {
"value": 27,
"unit": "days",
"system": "http://unitsofmeasure.org",
"code": "d"
}
}
}
}
]
}
},
"prefetch": {
"item1": {
"resourceType": "Patient",
"id": "example-rec-01-true-make-recommendations",
"extension": [
{
"url": "http://fhir.org/guides/cdc/opioid-cds/StructureDefinition/dataDateRoller",
"extension": [
{
"url": "dateLastUpdated",
"valueDateTime": "2022-10-10"
},
{
"url": "frequency",
"valueDuration": {
"value": 30.0,
"unit": "days",
"system": "http://unitsofmeasure.org",
"code": "d"
}
}
]
}
],
"birthDate": "2002-10-10"
},
"item2": null,
"item3": null,
"item4": null,
"item5": null,
"item6": null,
"item7": null,
"item8": null,
"item9": null,
"item10": null
}
}

0 comments on commit dbb6b6c

Please sign in to comment.