Skip to content

Commit

Permalink
Merge branch '6.0.1' into 6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
petmongrels committed Jan 12, 2024
2 parents 771ec08 + 51f037a commit b4b613e
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 17 deletions.
14 changes: 7 additions & 7 deletions packages/openchs-android/package-lock.json

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

Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class ProgramEncounterCancelState extends AbstractDataEntryState {
}

getNextScheduledVisits(ruleService, context) {
const nextScheduledVisits = ruleService.getNextScheduledVisits(this.getEntity(), this.getEntityType());
const nextScheduledVisits = ruleService.getNextScheduledVisits(this.getEntity(), this.getEntityType()).filter((x) => !this.isAlreadyScheduled(this.programEncounter.programEnrolment, x));
return context.get(IndividualService).validateAndInjectOtherSubjectForScheduledVisit(this.getEntity().individual, nextScheduledVisits);
}

Expand Down
9 changes: 9 additions & 0 deletions packages/openchs-android/src/state/AbstractDataEntryState.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,15 @@ class AbstractDataEntryState {
getEntityResultSetByType(context) {
return []
}

isAlreadyScheduled(programEnrolment, newlyScheduledEncounter) {
//paranoid code
if (_.isNil(programEnrolment) || _.isNil(programEnrolment.everScheduledEncountersOfType)) return false;

return _.some(programEnrolment.everScheduledEncountersOfType(newlyScheduledEncounter.encounterType), (alreadyScheduledEncounter) => {
return General.datesAreSame(newlyScheduledEncounter.earliestDate, alreadyScheduledEncounter.earliestVisitDateTime) && General.datesAreSame(newlyScheduledEncounter.maxDate, alreadyScheduledEncounter.maxVisitDateTime) && newlyScheduledEncounter.name === alreadyScheduledEncounter.name;
});
}
}

export default AbstractDataEntryState;
9 changes: 3 additions & 6 deletions packages/openchs-android/src/state/ProgramEncounterState.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import AbstractDataEntryState from "./AbstractDataEntryState";
import Wizard from "./Wizard";
import {
AbstractEncounter,
ObservationsHolder,
ProgramEncounter,
StaticFormElementGroup
} from "avni-models";
import {AbstractEncounter, ObservationsHolder, ProgramEncounter, StaticFormElementGroup} from "avni-models";
import ConceptService from "../service/ConceptService";
import _ from 'lodash';
import IndividualService from "../service/IndividualService";
import EntityService from "../service/EntityService";
import ObservationHolderActions from "../action/common/ObservationsHolderActions";
import TimerState from "./TimerState";
import General from "../utility/General";

class ProgramEncounterState extends AbstractDataEntryState {
constructor(formElementGroup, wizard, isNewEntity, programEncounter, filteredFormElements, workLists, messageDisplayed, timerState, isFirstFlow) {
Expand Down Expand Up @@ -109,6 +105,7 @@ class ProgramEncounterState extends AbstractDataEntryState {

getNextScheduledVisits(ruleService, context) {
const nextScheduledVisits = ruleService.getNextScheduledVisits(this.programEncounter, ProgramEncounter.schema.name, [])
.filter((x) => !this.isAlreadyScheduled(this.programEncounter.programEnrolment, x))
.map(k => _.assignIn({}, k));
return context.get(IndividualService).validateAndInjectOtherSubjectForScheduledVisit(this.programEncounter.individual, nextScheduledVisits);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/openchs-android/src/state/ProgramEnrolmentState.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ class ProgramEnrolmentState extends AbstractDataEntryState {

getNextScheduledVisits(ruleService, context) {
if (this.usage === ProgramEnrolmentState.UsageKeys.Enrol) {
const nextScheduledVisits = ruleService.getNextScheduledVisits(this.enrolment, ProgramEnrolment.schema.name, []);
const nextScheduledVisits = ruleService.getNextScheduledVisits(this.enrolment, ProgramEnrolment.schema.name, [])
.filter((x) => !this.isAlreadyScheduled(this.enrolment, x));
return context.get(IndividualService).validateAndInjectOtherSubjectForScheduledVisit(this.enrolment.individual, nextScheduledVisits);
} else {
return null;
}

}

static isInitialised(programEnrolmentState) {
Expand Down
8 changes: 7 additions & 1 deletion packages/openchs-android/src/utility/General.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,14 @@ class General {
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
}

static toISTDate(x) {
if (x.toString().includes("18:30:00"))
return moment(x).add(330, "m").toDate();
return x;
}

static datesAreSame(a, b) {
return moment(a).isSame(moment(b), 'day');
return moment(General.toISTDate(a)).isSame(moment(General.toISTDate(b)), 'day');
}

static dateAIsAfterB(a, b) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import RuleEvaluationService from "../../service/RuleEvaluationService";
import {Rule} from 'openchs-models';
import SelectableItemGroup from "../primitives/SelectableItemGroup";
import UserInfoService from "../../service/UserInfoService";
import moment from "moment";

@Path('/devSettingsView')
class DevSettingsView extends AbstractComponent {
Expand Down Expand Up @@ -93,6 +94,10 @@ class DevSettingsView extends AbstractComponent {
<Text>Server URL:</Text>
<TextInput value={settings.serverURL} onChangeText={(text) => this.dispatchAction(Actions.ON_SERVER_URL_CHANGE, {value: text})}/>
</View>
<View style={{marginBottom: 20}}>
<Text>Current App Time:</Text>
<Text>{moment().format("DD MMM YYYY hh:mm a")}</Text>
</View>
</View>);
}
}
Expand Down

0 comments on commit b4b613e

Please sign in to comment.