Skip to content

Commit

Permalink
Merge pull request #1127 from mozzy11/develop
Browse files Browse the repository at this point in the history
fix referal Results in React UI
  • Loading branch information
mozzy11 authored Jun 20, 2024
2 parents 750d49c + 9580590 commit da2752e
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 22 deletions.
6 changes: 2 additions & 4 deletions frontend/cypress/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{
"extends": [
"plugin:cypress/recommended"
]
}
"extends": ["plugin:cypress/recommended"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,7 @@ function OrganizationManagament() {
setFromRecordCount(
organizationsManagmentList.modelMap.form.fromRecordCount,
);
setToRecordCount(
organizationsManagmentList.modelMap.form.toRecordCount,
);
setToRecordCount(organizationsManagmentList.modelMap.form.toRecordCount);
setTotalRecordCount(
organizationsManagmentList.modelMap.form.totalRecordCount,
);
Expand Down
73 changes: 62 additions & 11 deletions frontend/src/components/resultPage/SearchResultForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,7 @@ export function SearchResults(props) {
const [rejectedItems, setRejectedItems] = useState({});
const [validationState, setValidationState] = useState({});
const saveStatus = "";
const [referTest, setReferTest] = useState(false);

const componentMounted = useRef(false);

Expand Down Expand Up @@ -1183,7 +1184,7 @@ export function SearchResults(props) {
name={"testResult[" + data.id + "].testMethod"}
labelText={intl.formatMessage({ id: "referral.label.testmethod" })}
onChange={(e) => handleChange(e, data.id)}
value={data.method}
value={data.testMethod}
>
<SelectItem text="" value="" />
{methods.map((method, method_index) => (
Expand All @@ -1195,13 +1196,28 @@ export function SearchResults(props) {
))}
</Select>
</Column>
<Column lg={1}></Column>
<Column lg={2}>
<Checkbox
labelText={intl.formatMessage({ id: "results.label.refer" })}
name={"testResult[" + data.id + "].refer"}
id={"testResult[" + data.id + "].refer"}
checked={data.refer === "true"}
onChange={(e) => {
e.target.value = e.target.checked;
handleChange(e, data.id);
}}
/>
</Column>
<Column lg={3}>
<Select
id={"referralReason" + data.id}
name={"testResult[" + data.id + "].referralReason"}
name={"testResult[" + data.id + "].referralItem.referralReasonId"}
// noLabel={true}
labelText={intl.formatMessage({ id: "referral.label.reason" })}
onChange={(e) => handleChange(e, data.id)}
value={data?.referralItem?.referralReasonId}
disabled={!referTest}
>
{/* {...updateShadowResult(e, this, param.rowId)} */}
<SelectItem text="" value="" />
Expand All @@ -1217,10 +1233,14 @@ export function SearchResults(props) {
<Column lg={3}>
<Select
id={"institute" + data.id}
name={"testResult[" + data.id + "].institute"}
name={
"testResult[" + data.id + "].referralItem.referredInstituteId"
}
// noLabel={true}
labelText={intl.formatMessage({ id: "referral.label.institute" })}
onChange={(e) => handleChange(e, data.id)}
value={data?.referralItem?.referredInstituteId}
disabled={!referTest}
>
{/* {...updateShadowResult(e, this, param.rowId)} */}

Expand All @@ -1233,12 +1253,14 @@ export function SearchResults(props) {
<Column lg={3}>
<Select
id={"testToPerform" + data.id}
name={"testResult[" + data.id + "].testToPerform"}
name={"testResult[" + data.id + "].referralItem.referredTestId"}
// noLabel={true}
labelText={intl.formatMessage({
id: "referral.label.testtoperform",
})}
onChange={(e) => handleChange(e, data.id)}
value={data?.referralItem?.referredTestId}
disabled={!referTest}
>
{/* {...updateShadowResult(e, this, param.rowId)} */}

Expand All @@ -1252,7 +1274,10 @@ export function SearchResults(props) {
id: "referral.label.sentdate",
})}
onChange={(date) => handleDatePickerChange(date, data.id)}
name={"testResult[" + data.id + "].sentDate_"}
name={"testResult[" + data.id + "].referralItem.referredSendDate"}
value={data?.referralItem?.referredSendDate}
disabled={!referTest}
disallowFutureDate={true}
/>
</Column>
</Grid>
Expand Down Expand Up @@ -1387,6 +1412,22 @@ export function SearchResults(props) {
var form = { ...props.results };
var jp = require("jsonpath");
jp.value(form, name, value);
var refer = jp.query(form, "testResult[" + rowId + "].refer")[0];
var testId = jp.query(form, "testResult[" + rowId + "].testId")[0];
setReferTest(refer === "true");
if (refer == "true") {
jp.value(
form,
"testResult[" + rowId + "].referralItem.referredTestId",
testId,
);
} else {
jp.value(
form,
"testResult[" + rowId + "].referralItem.referredTestId",
"",
);
}
var isModified = "testResult[" + rowId + "].isModified";
jp.value(form, isModified, "true");
props.setResultForm(form);
Expand Down Expand Up @@ -1417,12 +1458,22 @@ export function SearchResults(props) {
};

const handleDatePickerChange = (date, rowId) => {
console.debug("handleDatePickerChange:" + date);
var form = props.results;
var jp = require("jsonpath");
jp.value(form, "testResult[" + rowId + "].sentDate_", date);
var isModified = "testResult[" + rowId + "].isModified";
jp.value(form, isModified, "true");
var form = { ...props.results };
if (form.testResult[rowId].referralItem) {
if (form.testResult[rowId].referralItem.referredSendDate != date) {
console.debug("handleDatePickerChange:" + date);
var form = { ...props.results };
var jp = require("jsonpath");
jp.value(
form,
"testResult[" + rowId + "].referralItem.referredSendDate",
date,
);
var isModified = "testResult[" + rowId + "].isModified";
jp.value(form, isModified, "true");
props.setResultForm(form);
}
}
};

const handleAcceptAsIsChange = (e, rowId) => {
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1050,5 +1050,6 @@
"organization.previous": "Previous Page",
"organization.next": "Next Page",
"showing": "Showing",
"of": "of"
"of": "of" ,
"results.label.refer": "Refer test to a reference lab"
}
3 changes: 2 additions & 1 deletion frontend/src/languages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -961,5 +961,6 @@
"organization.previous": "Page précédente",
"organization.next": "Page suivante",
"showing": "Affichage",
"of": "de"
"of": "de" ,
"results.label.refer": "Référer le test à un laboratoire de référence"
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public interface FhirTransformService {
void transformPersistPatient(PatientManagementInfo patientInfo)
throws FhirTransformationException, FhirPersistanceException;

void transformPersistOrganization(Organization organization)
throws FhirTransformationException, FhirPersistanceException;

void transformPersistOrderEntryFhirObjects(
SamplePatientUpdateData updateData,
PatientManagementInfo patientInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,19 @@ public void transformPersistPatient(PatientManagementInfo patientInfo)
fhirPersistanceService.createUpdateFhirResourcesInFhirStore(fhirOperations);
}

@Transactional
@Async
@Override
public void transformPersistOrganization(Organization organization)
throws FhirLocalPersistingException {
CountingTempIdGenerator tempIdGenerator = new CountingTempIdGenerator();
FhirOperations fhirOperations = new FhirOperations();
org.hl7.fhir.r4.model.Organization fhirOrg = transformToFhirOrganization(organization);
this.addToOperations(fhirOperations, tempIdGenerator, fhirOrg);
Bundle responseBundle =
fhirPersistanceService.createUpdateFhirResourcesInFhirStore(fhirOperations);
}

@Override
@Async
@Transactional(readOnly = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
import org.openelisglobal.common.services.DisplayListService;
import org.openelisglobal.common.util.StringUtil;
import org.openelisglobal.common.validator.ValidationHelper;
import org.openelisglobal.dataexchange.fhir.exception.FhirPersistanceException;
import org.openelisglobal.dataexchange.fhir.exception.FhirTransformationException;
import org.openelisglobal.dataexchange.fhir.service.FhirTransformService;
import org.openelisglobal.dictionary.service.DictionaryService;
import org.openelisglobal.dictionary.valueholder.Dictionary;
import org.openelisglobal.internationalization.MessageUtil;
Expand Down Expand Up @@ -78,6 +81,7 @@ public class OrganizationRestController extends BaseController {
@Autowired private CityStateZipService cityStateZipService;
@Autowired private OrganizationTypeService organizationTypeService;
@Autowired private DictionaryService dictionaryService;
@Autowired private FhirTransformService fhirTransformService;

// @ModelAttribute("form")
// public OrganizationForm form() {
Expand Down Expand Up @@ -344,7 +348,8 @@ public ResponseEntity<Organization> getOrganization(@PathVariable("id") String i
@PostMapping(value = "/Organization")
public ResponseEntity<Object> showUpdateOrganization(
@RequestBody @Valid OrganizationForm form, BindingResult result)
throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
throws IllegalAccessException, InvocationTargetException, NoSuchMethodException,
FhirTransformationException, FhirPersistanceException {

// setDefaultButtonAttributes(request);
if (result.hasErrors()) {
Expand Down Expand Up @@ -393,6 +398,7 @@ public ResponseEntity<Object> showUpdateOrganization(
persistAddressParts(organization, addressParts);

linkOrgWithOrgType(organization, selectedOrgTypes);
fhirTransformService.transformPersistOrganization(organization);

} catch (LIMSRuntimeException e) {
// bugzilla 2154
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.openelisglobal.dataexchange.fhir.FhirConfig;
import org.openelisglobal.dataexchange.fhir.exception.FhirLocalPersistingException;
import org.openelisglobal.dataexchange.fhir.exception.FhirPersistanceException;
import org.openelisglobal.dataexchange.fhir.exception.FhirTransformationException;
import org.openelisglobal.dataexchange.fhir.service.FhirApiWorkFlowServiceImpl.ReferralResultsImportObjects;
import org.openelisglobal.dataexchange.fhir.service.FhirPersistanceService;
import org.openelisglobal.dataexchange.fhir.service.FhirTransformService;
Expand Down Expand Up @@ -204,6 +205,23 @@ public Bundle referAnalysisesToOrganization(Referral referral)

private Organization getFhirOrganization(
org.openelisglobal.organization.valueholder.Organization organization) {
Optional<Organization> fhiOrganization =
fhirPersistanceService.getFhirOrganizationByName(organization.getOrganizationName());
if (fhiOrganization.isPresent()) {
return fhiOrganization.get();
} else {
try {
Organization fhirOrg = fhirTransformService.transformToFhirOrganization(organization);
fhirPersistanceService.createFhirResourceInFhirStore(fhirOrg);
} catch (FhirTransformationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (FhirPersistanceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

return fhirPersistanceService
.getFhirOrganizationByName(organization.getOrganizationName())
.orElseThrow();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,8 @@ private void handleReferrals(
if (TypeOfTestResultServiceImpl.ResultType.isDictionaryVariant(testResultItem.getResultType())
|| TypeOfTestResultServiceImpl.ResultType.isMultiSelectVariant(
testResultItem.getResultType())) {
if ("0".equals(testResultItem.getResultValue())) {
if ("0".equals(testResultItem.getResultValue())
|| StringUtils.isBlank(testResultItem.getResultValue())) {
originalResultNote = originalResultNote + "";
} else {
Dictionary dictionary = dictionaryService.get(testResultItem.getResultValue());
Expand Down

0 comments on commit da2752e

Please sign in to comment.