Skip to content

Commit

Permalink
#1381 - minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
petmongrels committed May 31, 2024
1 parent 9f1b42c commit 3aec19e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ class ReportCardService extends BaseService {
]);
const standardReportCardTypeName = reportCard.standardReportCardType.name;
const resultFunc = typeToMethodMap.get(standardReportCardTypeName);
const programEncounterCriteria = RealmQueryService.programEncounterCriteria(reportCard.subjectTypes, reportCard.programs, reportCard.encounterTypes);
const generalEncounterCriteria = RealmQueryService.generalEncounterCriteria(reportCard.subjectTypes, reportCard.encounterTypes);

const programEncounterCriteria = RealmQueryService.programEncounterCriteria(reportCard.standardReportCardInputSubjectTypes,
reportCard.standardReportCardInputPrograms, reportCard.standardReportCardInputEncounterTypes);
const generalEncounterCriteria = RealmQueryService.generalEncounterCriteria(reportCard.standardReportCardInputSubjectTypes, reportCard.standardReportCardInputEncounterTypes);
const result = standardReportCardTypeName === StandardReportCardType.type.Total ? resultFunc(undefined, reportFilters) : resultFunc(new Date(), reportFilters, programEncounterCriteria, generalEncounterCriteria);
const sortedResult = standardReportCardTypeName === StandardReportCardType.type.Total ? result : _.orderBy(result, ({visitInfo}) => visitInfo.sortingBy, 'desc');
return {status: standardReportCardTypeName, result: sortedResult};
Expand Down Expand Up @@ -149,7 +151,7 @@ class ReportCardService extends BaseService {
*/
getPlainUUIDFromCompositeReportCardUUID(reportCardUUID) {
return reportCardUUID && (typeof reportCardUUID === 'string' || reportCardUUID instanceof String)
? reportCardUUID.substring(0, reportCardUUID.indexOf('#')) : null;
? reportCardUUID.substring(0, reportCardUUID.indexOf('#')) : null;
}
}

Expand Down
10 changes: 5 additions & 5 deletions packages/openchs-android/src/service/query/RealmQueryService.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ class RealmQueryService {
}

static programEncounterCriteria(subjectTypes, programs, encounterTypes) {
const subjectTypeQuery = subjectTypes.length > 0 ? `programEnrolment.individual.subjectType.uuid IN ["${subjectTypes.join('", "')}"]` : "";
const programQuery = programs.length > 0 ? `programEnrolment.program.uuid IN ["${programs.join('", "')}"]` : "";
const encounterTypeQuery = encounterTypes.length > 0 ? `encounterType.uuid IN ["${encounterTypes.join('", "')}"]` : "";
const subjectTypeQuery = RealmQueryService.orKeyValueQuery("programEnrolment.individual.subjectType.uuid", subjectTypes.map((x) => x.uuid));
const programQuery = RealmQueryService.orKeyValueQuery("programEnrolment.program.uuid", programs.map((x) => x.uuid));
const encounterTypeQuery = RealmQueryService.orKeyValueQuery("encounterType.uuid", encounterTypes.map((x) => x.uuid));
return RealmQueryService.andQuery([subjectTypeQuery, programQuery, encounterTypeQuery]);
}

static generalEncounterCriteria(subjectTypes, encounterTypes) {
const subjectTypeQuery = subjectTypes.length > 0 ? `individual.subjectType.uuid IN ["${subjectTypes.join('", "')}"]` : "";
const encounterTypeQuery = encounterTypes.length > 0 ? `encounterType.uuid IN ["${encounterTypes.join('", "')}"]` : "";
const subjectTypeQuery = RealmQueryService.orKeyValueQuery("individual.subjectType.uuid", subjectTypes.map((x) => x.uuid));
const encounterTypeQuery = RealmQueryService.orKeyValueQuery("encounterType.uuid", encounterTypes.map((x) => x.uuid));
return RealmQueryService.andQuery([subjectTypeQuery, encounterTypeQuery]);
}
}
Expand Down

0 comments on commit 3aec19e

Please sign in to comment.