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

Updates to null check for getConceptDisplayString #6

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "e-care-common-data-services",
"version": "1.4.5",
"version": "1.6.8",
"description": "Common data service for mcc-provider and mcc-care-planner",
"main": "build/main/index.js",
"typings": "build/main/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion source/lib/careplan/careplan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { fhirclient } from 'fhirclient/lib/types';

import { MccCarePlan, MccCondition } from '../../types/mcc-types';
import log from '../../utils/loglevel';
import { getConceptDisplayString } from '../goal/goal.util';

import {
fhirOptions,
getConceptDisplayString,
notFoundResponse,
resourcesFrom,
resourcesFromObject,
Expand Down
12 changes: 1 addition & 11 deletions source/lib/careplan/careplan.util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CodeableConcept, Resource } from 'fhir/r4';
import { Resource } from 'fhir/r4';
import { fhirclient } from 'fhirclient/lib/types';

export const fhirOptions: fhirclient.FhirOptions = {
Expand Down Expand Up @@ -39,13 +39,3 @@ export const resourcesFrom = (response: fhirclient.JsonArray): Resource[] => {
(resource: Resource) => resource.resourceType !== 'OperationOutcome'
);
};

export const getConceptDisplayString = (code: CodeableConcept): string => {
if (code.text) return code.text;

if (code.coding) {
return code.coding.reduce((_, curr) => curr.display, '');
}

return '';
};
16 changes: 12 additions & 4 deletions source/lib/condition/condition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ export const getSupplementalConditions = async (launchURL: string, sdsClient: Cl
if (sdsClient) {
try {
const linkages = await sdsClient.request('Linkage?item=Patient/' + sdsClient.patient.id);
console.log("patientId +linkages " + JSON.stringify(linkages));
const urlSet = new Set();

urlSet.add(launchURL)
Expand All @@ -101,8 +100,9 @@ export const getSupplementalConditions = async (launchURL: string, sdsClient: Cl
// Process third-party goals
const thirdPartyGoals: Condition[] = resourcesFrom(response) as Condition[];
thirdPartyGoals.forEach(condition => {

condition.code.text = condition.code.text + "(" + item2.resource.extension[0].valueUrl + ")"
condition.recorder = {
display: item2.resource.extension[0].valueUrl
};
allThirdPartyMappedConditions.push(condition);
});
}
Expand Down Expand Up @@ -180,7 +180,9 @@ export const getSummaryConditions = async (sdsURL: string, authURL: string, sdsS
recordProvenance(provenance1);
recordProvenance(provenance2);

const filteredConditions = [...conditions1, ...conditions2, ...sdsfilteredConditions2];
const thirdPartyStuff = await getSupplementalConditions(client.state.serverUrl, sdsClient);

const filteredConditions = [...conditions1, ...conditions2, ...sdsfilteredConditions2, ...thirdPartyStuff];

const mappedFilterConditions = await Promise.all(
filteredConditions.map(async (condition) => {
Expand All @@ -190,6 +192,12 @@ export const getSummaryConditions = async (sdsURL: string, authURL: string, sdsS
const provenance: Provenance = provenanceMap.get(`Condition/${condition.id}`);
transformedCondition.provenance = displayTransmitter(provenance);

if (!transformedCondition.provenance && condition.recorder) {
transformedCondition.provenance = condition.recorder.display
}



return transformedCondition;
})
);
Expand Down
19 changes: 9 additions & 10 deletions source/lib/condition/condition.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,7 @@ export const resourcesFrom = (response: fhirclient.JsonObject): Resource[] => {
);
};

export const getConceptDisplayString = (code: CodeableConcept): string => {
if (code.text) return code.text;

if (code.coding) {
return code.coding.reduce((_, curr) => curr.display, '');
}

return '';
};

export const getConceptCode = (code: CodeableConcept): string => {

Expand Down Expand Up @@ -89,9 +81,16 @@ export const transformToConditionSummary = async (fhirCondition: MccCondition):
const profileMapping = {
'2.16.840.1.113762.1.4.1222.159': 'CKD'
}
const code = fhirCondition.code.coding[0];
var code
if (fhirCondition?.code?.coding) {
code = fhirCondition?.code?.coding;
}

var codeName = ''
if (code) {
codeName = await getFilenameFromValueSetCode(code.system, code.code)
}

const codeName = await getFilenameFromValueSetCode(code.system, code.code)

const transformedData: MccConditionSummary = {
code: fhirCondition.code,
Expand Down
12 changes: 2 additions & 10 deletions source/lib/contact/contact.util.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { CareTeamParticipant, CodeableConcept, Practitioner, Reference, Resource } from 'fhir/r4';
import { CareTeamParticipant, Practitioner, Reference, Resource } from 'fhir/r4';
import { fhirclient } from 'fhirclient/lib/types';

import { MccPatientContact } from '../../types/mcc-types';
import { getConceptDisplayString } from '../goal/goal.util';

// import log from '../../utils/loglevel';

Expand Down Expand Up @@ -51,15 +52,6 @@ export const resourcesFrom2 = (response: fhirclient.JsonArray): Resource[] => {
);
};

export const getConceptDisplayString = (code: CodeableConcept): string => {
if (code.text) return code.text;

if (code.coding) {
return code.coding.reduce((_, curr) => curr.display, '');
}

return '';
};

function resolve(ref?: Reference, members?: Map<string, Practitioner>) {
let resourceID: string | undefined = ref?.reference?.split('/').reverse()?.[0]
Expand Down
10 changes: 1 addition & 9 deletions source/lib/counseling/counseling.util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CodeableConcept, Resource } from 'fhir/r4';
import { Resource } from 'fhir/r4';
import { fhirclient } from 'fhirclient/lib/types';

export const fhirOptions: fhirclient.FhirOptions = {
Expand Down Expand Up @@ -40,12 +40,4 @@ export const resourcesFrom = (response: fhirclient.JsonArray): Resource[] => {
);
};

export const getConceptDisplayString = (code: CodeableConcept): string => {
if (code.text) return code.text;

if (code.coding) {
return code.coding.reduce((_, curr) => curr.display, '');
}

return '';
};
11 changes: 1 addition & 10 deletions source/lib/education/education.util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CodeableConcept, Resource } from 'fhir/r4';
import { Resource } from 'fhir/r4';
import { fhirclient } from 'fhirclient/lib/types';

export const fhirOptions: fhirclient.FhirOptions = {
Expand Down Expand Up @@ -40,12 +40,3 @@ export const resourcesFrom = (response: fhirclient.JsonArray): Resource[] => {
);
};

export const getConceptDisplayString = (code: CodeableConcept): string => {
if (code.text) return code.text;

if (code.coding) {
return code.coding.reduce((_, curr) => curr.display, '');
}

return '';
};
61 changes: 26 additions & 35 deletions source/lib/goal/goal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import { displayDate } from '../service-request/service-request.util';
import {
getSupplementalDataClient,
notFoundResponse,
resourcesFrom,
// resourcesFrom,
resourcesFromObject,
resourcesFromObjectArray,
resourcesFromObjectArray2,
saveFHIRAccessData,
// saveFHIRAccessData,
transformToMccGoalSummary,
} from './goal.util';

Expand All @@ -26,8 +26,8 @@ enum ACTIVE_STATUS {
IGNORE
}

const LF_ID = '-MCP'
const fcCurrentStateKey = 'fhir-client-state' + LF_ID
// const LF_ID = '-MCP'
// const fcCurrentStateKey = 'fhir-client-state' + LF_ID

const ACTIVE_KEYS = {
proposed: ACTIVE_STATUS.ACTIVE,
Expand Down Expand Up @@ -73,7 +73,9 @@ export const getSupplementalData = async (launchURL: string, sdsClient: Client):
const thirdPartyMappedGoals: MccGoalSummary[] = thirdPartyGoals.map(transformToMccGoalSummary);

thirdPartyMappedGoals.forEach(goal => {
goal.expressedBy = (goal.expressedBy ? goal.expressedBy : '') + ' (' + item2.resource.extension[0].valueUrl + ')';
goal.expressedBy = (goal.expressedBy ? goal.expressedBy : '');

goal.source = item2.resource.extension[0].valueUrl
allThirdPartyMappedGoals.push(goal);
});
}
Expand Down Expand Up @@ -233,40 +235,29 @@ export const getSummaryGoals = async (sdsURL: string, authURL: string, sdsScope:
*/


export const getGoals = async (sdsURL: string, authURL: string, sdsScope: string): Promise<MccGoal[]> => {
const client = await FHIR.oauth2.ready();

console.error('start saveFHIRAccessData');

await saveFHIRAccessData(fcCurrentStateKey, client.state, false).then(() => {
console.log('fhirClientState saved/promise returned')
}).catch((e) => console.log(e))

console.error('end saveFHIRAccessData');

const sdsClient: Client = await getSupplementalDataClient(client, sdsURL, authURL, sdsScope);
console.error(
`getGoals - ` + JSON.stringify(sdsClient)
);

const queryPath = `Goal`;
const goalRequest: fhirclient.JsonArray = await client.patient.request(
queryPath
);
// export const getGoalsWtF = async (): Promise<MccGoal[]> => {
// const client = await FHIR.oauth2.ready();
// await saveFHIRAccessData(fcCurrentStateKey, client.state, false).then(() => {
// console.log('fhirClientState saved/promise returned')
// }).catch((e) => console.log(e))
// const queryPath = `Goal`;
// const goalRequest: fhirclient.JsonArray = await client.patient.request(
// queryPath
// );

// goal from problem list item
const filteredGoals: MccGoal[] = resourcesFrom(
goalRequest
) as MccGoal[];
// // goal from problem list item
// const filteredGoals: MccGoal[] = resourcesFrom(
// goalRequest
// ) as MccGoal[];

log.info(
`getGoals - successful`
);
// log.info(
// `getGoals - successful`
// );

log.debug({ serviceName: 'getGoals', result: filteredGoals });
// log.debug({ serviceName: 'getGoals', result: filteredGoals });

return filteredGoals;
};
// return filteredGoals;
// };

export const getGoal = async (id: string): Promise<MccGoal> => {
if (!id) {
Expand Down
Loading