@ovok/native 1.17.0-dev.2313 → 1.17.0-dev.2315
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getLatestObservationDatesByCode=void 0;var _fhirSystems=require("./fhir-systems.js");const
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getLatestObservationDatesByCode=void 0;var _core=require("@ovok/core"),_fhirSystems=require("./fhir-systems.js");const SEARCH_CONCURRENCY=4,observationQuery=(e,t,r)=>({code:e,identifier:`${_fhirSystems.OBSERVATION_SYNC_PROVIDER_SYSTEM}|${r}`,subject:`Patient/${t}`,_elements:"effective",_sort:"-date"}),dateOf=e=>e?.effectivePeriod?.end??e?.effectiveDateTime,getLatestObservationDatesByCode=async({codes:e,patientId:t,client:r,provider:o})=>{if(0===e.length)return[];const s=e.map(e=>observationQuery(e,t,o)),a=s.map(e=>({request:{method:"GET",url:`Observation?${new URLSearchParams({...e,_count:"1"})}`}}));try{return((await r.fhir.batch({resourceType:"Bundle",type:"batch",entry:a})).entry??[]).map((t,r)=>({code:e[r],date:dateOf(t.resource?.entry?.[0]?.resource)}))}catch(e){if(!(e instanceof _core.OvokNotFoundError))throw e}const i=[];for(let e=0;e<s.length;e+=4){const t=await Promise.all(s.slice(e,e+4).map(async e=>({code:e.code,date:dateOf(await r.fhir.searchOne("Observation",e))})));i.push(...t)}return i};exports.getLatestObservationDatesByCode=getLatestObservationDatesByCode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{OvokNotFoundError as e}from"@ovok/core";import{OBSERVATION_SYNC_PROVIDER_SYSTEM as t}from"./fhir-systems.js";const r=e=>e?.effectivePeriod?.end??e?.effectiveDateTime;export const getLatestObservationDatesByCode=async({codes:o,patientId:a,client:c,provider:n})=>{if(0===o.length)return[];const s=o.map(e=>((e,r,o)=>({code:e,identifier:`${t}|${o}`,subject:`Patient/${r}`,_elements:"effective",_sort:"-date"}))(e,a,n)),i=s.map(e=>({request:{method:"GET",url:`Observation?${new URLSearchParams({...e,_count:"1"})}`}}));try{return((await c.fhir.batch({resourceType:"Bundle",type:"batch",entry:i})).entry??[]).map((e,t)=>({code:o[t],date:r(e.resource?.entry?.[0]?.resource)}))}catch(t){if(!(t instanceof e))throw t}const d=[];for(let e=0;e<s.length;e+=4){const t=await Promise.all(s.slice(e,e+4).map(async e=>({code:e.code,date:r(await c.fhir.searchOne("Observation",e))})));d.push(...t)}return d};
|