Skip to content

Commit

Permalink
BAH-3459 | Refactor. shouldn't proceed to update if ABHA Number linke…
Browse files Browse the repository at this point in the history
…d to the matching patient
  • Loading branch information
SanoferSameera committed Jan 12, 2024
1 parent 04bfc9e commit f89ca45
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 37 deletions.
67 changes: 34 additions & 33 deletions .github/workflows/build_and_upload_artifact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
branches:
- main
- 'release-*'
- BAH-3459
tags:
- '[0-9]+.[0-9]+.[0-9]+'
workflow_dispatch:
Expand Down Expand Up @@ -48,36 +49,36 @@ jobs:
file: package/docker/Dockerfile
push: true
tags: bahmniindiadistro/abha-verification:${{env.ARTIFACT_VERSION}},bahmniindiadistro/abha-verification:latest
- name: Helm - Update Version and Image Tag
run: |
yq --inplace '.image.tag = "${{ env.ARTIFACT_VERSION }}"' $HELM_CHART_PATH/values.yaml
yq --inplace '.version = "${{ env.ARTIFACT_VERSION }}"' $HELM_CHART_PATH/Chart.yaml
- name: Helm Lint
run: helm lint $HELM_CHART_PATH

- name: Helm Package
run: helm package $HELM_CHART_PATH

- name: Helm - Checkout Charts Repository
uses: actions/checkout@v2
with:
repository: Bahmniindiadistro/helm-charts
ref: gh-pages
path: helm-charts
persist-credentials: false

- name: Helm - Copy chart
run: mkdir -p helm-charts/abha-verification/ && cp abha-verification-${{ env.ARTIFACT_VERSION }}.tgz helm-charts/abha-verification/

- name: Helm - reIndex
working-directory: helm-charts/
run: helm repo index --merge index.yaml --url https://bahmniindiadistro.github.io/helm-charts/ .

- name: Helm - Publish Chart
working-directory: helm-charts/
run: |
git config user.name ${{ secrets.BAHMNI_USERNAME}}
git config user.email ${{ secrets.BAHMNI_EMAIL}}
git add .
git commit -m "Release of abha-verification-${{ env.ARTIFACT_VERSION }}"
git push 'https://${{ secrets.BAHMNI_USERNAME}}:${{ secrets.BAHMNI_PAT}}@github.com/bahmniindiadistro/helm-charts.git' gh-pages
# - name: Helm - Update Version and Image Tag
# run: |
# yq --inplace '.image.tag = "${{ env.ARTIFACT_VERSION }}"' $HELM_CHART_PATH/values.yaml
# yq --inplace '.version = "${{ env.ARTIFACT_VERSION }}"' $HELM_CHART_PATH/Chart.yaml
# - name: Helm Lint
# run: helm lint $HELM_CHART_PATH
#
# - name: Helm Package
# run: helm package $HELM_CHART_PATH
#
# - name: Helm - Checkout Charts Repository
# uses: actions/checkout@v2
# with:
# repository: Bahmniindiadistro/helm-charts
# ref: gh-pages
# path: helm-charts
# persist-credentials: false
#
# - name: Helm - Copy chart
# run: mkdir -p helm-charts/abha-verification/ && cp abha-verification-${{ env.ARTIFACT_VERSION }}.tgz helm-charts/abha-verification/
#
# - name: Helm - reIndex
# working-directory: helm-charts/
# run: helm repo index --merge index.yaml --url https://bahmniindiadistro.github.io/helm-charts/ .
#
# - name: Helm - Publish Chart
# working-directory: helm-charts/
# run: |
# git config user.name ${{ secrets.BAHMNI_USERNAME}}
# git config user.email ${{ secrets.BAHMNI_EMAIL}}
# git add .
# git commit -m "Release of abha-verification-${{ env.ARTIFACT_VERSION }}"
# git push 'https://${{ secrets.BAHMNI_USERNAME}}:${{ secrets.BAHMNI_PAT}}@github.com/bahmniindiadistro/helm-charts.git' gh-pages
9 changes: 9 additions & 0 deletions src/api/hipServiceApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -561,3 +561,12 @@ export const fetchGlobalProperty = async (property) => {
return Constants.openMrsDown;
}
}

export const checkIfHealthNumberExists = async (patientUuid) => {
try {
const response = await axios.get(Constants.bahmniUrl + Constants.existingPatientUrl + "/checkHealthNumber/" + patientUuid, Constants.headers);
return response.data;
} catch (error) {
return Constants.openMrsDown;
}
}
21 changes: 19 additions & 2 deletions src/components/Common/CheckIdentifierExists.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import React, {useEffect, useState} from "react";
import {fetchPatientFromBahmniWithHealthId, getHealthIdStatus} from '../../api/hipServiceApi';
import {
checkIfHealthNumberExists,
fetchPatientFromBahmniWithHealthId,
getHealthIdStatus
} from '../../api/hipServiceApi';
import '../verifyHealthId/verifyHealthId.scss';

const CheckIdentifierExists = (props) => {
Expand All @@ -8,6 +12,7 @@ const CheckIdentifierExists = (props) => {
const [healthIdIsVoided, setHealthIdIsVoided] = useState(false);
const [errorHealthId, setErrorHealthId] = useState('');
const [showError, setShowError] = useState(false);
const [matchingPatientHasHealthIdNumberLinked, setMatchingPatientHasHealthIdNumberLinked] = useState(false);

async function checkIfAlreadyExistingIdentifier(id) {
if(props.setHealthIdIsVoided !== undefined)
Expand All @@ -30,6 +35,11 @@ const CheckIdentifierExists = (props) => {
else {
setMatchingPatientFound(true);
setMatchingPatientUuid(matchingPatientId.patientUuid);
const response = await checkIfHealthNumberExists(matchingPatientId.patientUuid);
if (response.Error === undefined && response !== "") {
props?.setHealthNumberAlreadyLinked(response);
setMatchingPatientHasHealthIdNumberLinked(response);
}
}
if(props.setMatchingPatientUuid !== undefined)
props?.setMatchingPatientUuid(matchingPatientId.patientUuid);
Expand All @@ -47,9 +57,16 @@ const CheckIdentifierExists = (props) => {
await checkIfAlreadyExistingIdentifier(props.id);
},[props.id])

function redirectToPatientDashboard() {
window.parent.postMessage({"patientUuid" : matchingpatientUuid}, "*");
}

return (
<div>
{matchingPatientFound && <div className="matched-patient-info">Matching record with {props.id} found. Please proceed to update the record</div>}
{matchingPatientFound && !matchingPatientHasHealthIdNumberLinked && <div className="matched-patient-info">Matching record with {props.id} found. Please proceed to update the record with ABHA Number</div>}
{matchingPatientFound && matchingPatientHasHealthIdNumberLinked && <div className="patient-existed" onClick={redirectToPatientDashboard}>
Matching record with {props.id} found
</div>}
{healthIdIsVoided && <div className="id-deactivated">
{props.id} is deactivated
</div>}
Expand Down
5 changes: 3 additions & 2 deletions src/components/creation/LinkABHAAddress.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const LinkABHAAddress = (props) => {
const [healthIdIsVoided, setHealthIdIsVoided] = useState(false);
const [matchingPatientUuid, setMatchingPatientUuid] = useState(undefined);
const [isAbhaSelected, setIsAbhaSelected] = useState(false);
const [healthNumberAlreadyLinked, setHealthNumberAlreadyLinked] = useState(false);
let isLinkingEnabled;
const refEls = useRef({});

Expand Down Expand Up @@ -113,9 +114,9 @@ const LinkABHAAddress = (props) => {
</div>
{phrAddressList}
</div>
{isAbhaSelected && <CheckIdentifierExists id={abhaAddress} setHealthIdIsVoided={setHealthIdIsVoided} setMatchingPatientUuid={setMatchingPatientUuid}/>}
{isAbhaSelected && <CheckIdentifierExists id={abhaAddress} setHealthIdIsVoided={setHealthIdIsVoided} setMatchingPatientUuid={setMatchingPatientUuid} setHealthNumberAlreadyLinked={setHealthNumberAlreadyLinked}/>}
{abhaAddress !== '' && <div className="center">
<button type="button" disabled={healthIdIsVoided || !isAbhaSelected? true : false} className="proceed" onClick={onProceed}>Proceed</button>
<button type="button" disabled={healthNumberAlreadyLinked || healthIdIsVoided || !isAbhaSelected? true : false} className="proceed" onClick={onProceed}>Proceed</button>
</div>}
</div>}
{isLinkingEnabled && <div className="left-button">
Expand Down

0 comments on commit f89ca45

Please sign in to comment.