Skip to content

Commit

Permalink
Merge pull request #480 from udsm-dhis2-lab/feature/visitdatacheckup
Browse files Browse the repository at this point in the history
Feature/visitdatacheckup
  • Loading branch information
iamgaspardev authored Nov 17, 2024
2 parents 2c66330 + 5f1a4be commit 5a56ad3
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ export class InpatientHomeComponent implements OnInit {

// console.log("this.currentLocation?.uuid", this.currentLocation);
this.currentLocation = this.location;
console.log("currentLocation ....",this.currentLocation);
this.bedsUnderCurrentWard$ = this.store.select(getAllBedsUnderCurrentWard, {
id: this.currentLocation?.uuid,
tagName: "Bed Location",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ import { ObservationService } from "../../resources/observation/services";
import {
formatDateToString,
formatDateToYYMMDD,
toISOStringFormat,
} from "../../helpers/format-date.helper";
import { getAllDiagnosesFromVisitDetails } from "../../helpers/patient.helper";
import { Diagnosis } from "../../resources/diagnosis/models/diagnosis.model";
import { take } from "rxjs/operators";

@Component({
selector: "app-discharge-patient-modal",
Expand Down Expand Up @@ -431,6 +433,10 @@ export class DischargePatientModalComponent implements OnInit {
this.visitService
.dischargePatient(dischargeObjects?.encounterDetails)
.subscribe((response) => {
let visitObject: any = {
stopDatetime: toISOStringFormat(),
};

if (response) {
this.savingData = false;
this.store.dispatch(
Expand All @@ -439,11 +445,30 @@ export class DischargePatientModalComponent implements OnInit {
visitUuid: dischargeObjects.visitDetails?.uuid,
})
);
setTimeout(() => {
this.store.dispatch(go({ path: ["/inpatient"] }));
}, 200);
// get the uuid after update
this.visit$.pipe(take(1)).subscribe((visitResponse) => {
const visitUuid = visitResponse?.uuid;

if (visitUuid) {
this.visitService
.updateVisit(visitUuid, visitObject)
.subscribe((response) => {
if (response?.error) {
console.log('Error closing discharge visit');
}
});

setTimeout(() => {
this.store.dispatch(go({ path: ["/inpatient"] }));
}, 200);
} else {
console.error("No visit UUID found");
}
});
}
});


this.dialogRef.close(true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ export class PatientListComponent implements OnInit, OnChanges {
)
.pipe(
tap((response: any) => {
console.log("response data .....",response);
this.loadingPatients = false;
if (response?.error) {
this.errors = [...this.errors, response?.error];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,10 @@ export class SharedPatientDischargeDetailsComponent implements OnInit {

ngOnInit(): void {
this.diagnoses = getAllDiagnosesFromVisitDetails(this.activeVisit);
console.log("diagnoses .................................",this.diagnoses);
this.diagnoses =
this.diagnoses?.filter(
(diagnosis: Diagnosis) => diagnosis?.isConfirmedDiagnosis
) || [];
console.log("diagonosis updated .........",this.diagnoses)
this.encounterProvider = {
...this.visitDetails?.admissionEncounter?.encounterProviders[0]?.provider,
display:
Expand All @@ -61,7 +59,6 @@ export class SharedPatientDischargeDetailsComponent implements OnInit {
this.observations = groupObservationByConcept(
this.activeVisit?.observations
);
console.log("observations .........",this.observations)
this.dischargeForm$ = this.store.select(
getCustomOpenMRSFormById(this.dischargeFormUuid)
);
Expand Down

0 comments on commit 5a56ad3

Please sign in to comment.