You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fetch documents (e.g. needed to view full patient details including none standard fields)
update document (e.g. needed to create patients)
implement document updates that require auto merge
(document api is currently in PR
Example to add a new document and update it:
// get the graphql apiconstapi=getApi();// pick one storeconststores=(awaitapi.getStores()).stores.nodes;conststore0=stores[0];console.log(`Store: ${store0.id}, code: ${store0.code}`);// insert first version of the documentconstu0=awaitapi.updateDocument({storeId: store0.id,input: {author: "me",type: "testtype",data: {version: 1,txt: "hello",},name: docName,parents: [],schemaId: undefined,timestamp: newDate().toISOString(),},});console.log(u0);// fetch the latest version of the documentconstfilter={name: {equalTo: docName,},};constd1=awaitapi.getDocuments({storeId: store0.id,
filter,});console.log(d1);// modify the last version and set parents correctlyconstu1=awaitapi.updateDocument({storeId: store0.id,input: {author: "me",type: "testtype",data: {version: 2,txt: "hello update",more: "more",},name: docName,parents: [d1.documents.nodes[0].id],schemaId: undefined,timestamp: newDate().toISOString(),},});console.log(u1);constexhaustiveCheck=(_: never)=>{};// example error handlingletdocId: string="";switch(u1.updateDocument.__typename){case"DocumentNode":
docId=u1.updateDocument.id;break;case"UpdateDocumentError": {consterror=u1.updateDocument.error;switch(error.__typename){case"MergeRequiredError":
// TODO: merge and resubmitthrowError("unhandled");default:
//exhaustiveCheck(error);}throwError("unhandled");}default:
exhaustiveCheck(u1.updateDocument);}// do another updateconstu2=awaitapi.updateDocument({storeId: store0.id,input: {author: "me",type: "testtype",data: {version: 3,txt: "hello update 2",more: "more...",},name: docName,parents: [docId],schemaId: undefined,timestamp: newDate().toISOString(),},});console.log(u2);
Merge concurrently edited documents
The API may detect concurrent edits which requires a merge of both versions.
In this case the API returns a MergeRequiredError.
The MergeRequiredError error contains a proposed auto-merged document.
If the FE is happy the auto-merged version can be used to update the document.
This operation will succeeds as long as there wasn't a further concurrent edit.
The text was updated successfully, but these errors were encountered:
Integrate the document api (#19) to:
implement document updates that require auto merge(document api is currently in PR
Example to add a new document and update it:
Merge concurrently edited documents
The API may detect concurrent edits which requires a merge of both versions.
In this case the API returns a MergeRequiredError.
The MergeRequiredError error contains a proposed auto-merged document.
If the FE is happy the auto-merged version can be used to update the document.
This operation will succeeds as long as there wasn't a further concurrent edit.
The text was updated successfully, but these errors were encountered: