Skip to content

Commit

Permalink
Merge pull request REAN-Foundation#942 from REAN-Foundation/feature/d…
Browse files Browse the repository at this point in the history
…ata_file_issue
  • Loading branch information
tabbasum-rean authored Mar 28, 2024
2 parents 14ba1e3 + b2d6352 commit 4c1c7f6
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 19 deletions.
6 changes: 5 additions & 1 deletion src/api/users/patient/patient/patient.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,11 @@ export class PatientController extends BaseUserController {
if (m.FrequencyUnit !== 'Other') {
var deletedMedicationCount = await this._medicationConsumptionService.deleteFutureMedicationSchedules(m.id);
var startDate = await this._userService.getDateInUserTimeZone(m.PatientUserId, new Date().toISOString().split('T')[0]);
m.Duration = deletedMedicationCount;
if (m.FrequencyUnit === 'Weekly' || m.FrequencyUnit === 'Monthly') {
m.Duration = deletedMedicationCount;
} else if (m.FrequencyUnit === 'Daily') {
m.Duration = Math.ceil(deletedMedicationCount / m.Frequency);
}
m.StartDate = startDate;
await this._medicationConsumptionService.create(m);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class StepCountController {

const domainModel = await this._validator.create(request);
const recordDate = request.body.RecordDate;
const provider = request.body.Provider;
const provider = request.body.Provider ?? null;

var existingRecord =
await this._service.getByRecordDateAndPatientUserId(recordDate, request.body.PatientUserId, provider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export class StepCountValidator extends BaseValidator {
await this.validateUuid(request, 'PatientUserId', Where.Body, true, false);
await this.validateInt(request, 'StepCount', Where.Body, true, false);
await this.validateString(request, 'Unit', Where.Body, true, true);
await this.validateString(request, 'Provider', Where.Body, false, true);
await this.validateDate(request, 'RecordDate', Where.Body, false, false);

this.validateRequest(request);
Expand All @@ -69,6 +70,7 @@ export class StepCountValidator extends BaseValidator {
await this.validateUuid(request, 'PatientUserId', Where.Body, false, false);
await this.validateInt(request, 'StepCount', Where.Body, false, false);
await this.validateString(request, 'Unit', Where.Body, false, false);
await this.validateString(request, 'Provider', Where.Body, false, false);
await this.validateDate(request, 'RecordDate', Where.Body, false, false);

this.validateRequest(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class StepCountRepo implements IStepCountRepo {
TerraSummaryId : createModel.TerraSummaryId ?? null,
Provider : createModel.Provider ?? null,
StepCount : createModel.StepCount ?? null,
Unit : createModel.Unit ?? null,
Unit : createModel.Unit ?? 'steps',
RecordDate : createModel.RecordDate ?? null,
};
const stepCount = await StepCount.create(entity);
Expand Down Expand Up @@ -59,13 +59,22 @@ export class StepCountRepo implements IStepCountRepo {
getByRecordDateAndPatientUserId = async (date: Date, patientUserId: string, provider?: string): Promise<StepCountDto> => {
try {
const new_date = new Date(date);
const allStepCount = await StepCount.findOne({
where : {
RecordDate : new_date,
PatientUserId : patientUserId,
Provider : provider
}
});
var allStepCount = null;
var whereClause = {
RecordDate : new_date,
PatientUserId : patientUserId,
};

if (provider != null) {
whereClause["Provider"] = provider;
allStepCount = await StepCount.findOne({
where : whereClause,
});
} else {
allStepCount = await StepCount.findOne({
where : whereClause,
});
}
//const providerStepCount = allStepCount.filter(step => step.Provider !== null);

return StepCountMapper.toDto(allStepCount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class EHRHowDoYouFeelService {
model: HowDoYouFeelDto,
appName?: string) => {

if (model.Feeling === '1') {
if (model.Feeling == '1') {
EHRAnalyticsHandler.addStringRecord(
model.PatientUserId,
model.id,
Expand All @@ -24,11 +24,12 @@ export class EHRHowDoYouFeelService {
null,
'Better',
null,
appName
appName,
model.RecordDate ? model.RecordDate : null
);
}

if (model.Feeling === '0') {
if (model.Feeling == '0') {
EHRAnalyticsHandler.addStringRecord(
model.PatientUserId,
model.id,
Expand All @@ -37,11 +38,13 @@ export class EHRHowDoYouFeelService {
model.Feeling,
null,
'Same',
appName
null,
appName,
model.RecordDate ? model.RecordDate : null
);
}

if (model.Feeling === '-1') {
if (model.Feeling == '-1') {
EHRAnalyticsHandler.addStringRecord(
model.PatientUserId,
model.id,
Expand All @@ -50,7 +53,9 @@ export class EHRHowDoYouFeelService {
model.Feeling,
null,
'Worse',
appName
null,
appName,
model.RecordDate ? model.RecordDate : null
);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class EHRPhysicalActivityService {
EHRAnalyticsHandler.addFloatRecord(
model.PatientUserId,
model.id,
null,
model.Provider ? model.Provider : null,
EHRRecordTypes.PhysicalActivity,
model.StepCount,
model.Unit,
Expand All @@ -50,7 +50,7 @@ export class EHRPhysicalActivityService {
EHRAnalyticsHandler.addBooleanRecord(
model.PatientUserId,
model.id,
model.Provider,
model.Provider ? model.Provider : null,
EHRRecordTypes.PhysicalActivity,
model.PhysicalActivityQuestionAns,
null,
Expand All @@ -65,7 +65,7 @@ export class EHRPhysicalActivityService {
EHRAnalyticsHandler.addFloatRecord(
model.PatientUserId,
model.id,
model.Provider,
model.Provider ? model.Provider : null,
EHRRecordTypes.PhysicalActivity,
model.DurationInMin,
'mins',
Expand Down

0 comments on commit 4c1c7f6

Please sign in to comment.