 Hi everyone, welcome to the last session, you are done for the day. My name is Sachi Gurd, I have an introduction slide as well. Today I am here to talk to you about interpolation rules as code, rack, and we used openfisca as well for storing the rules, I will be walking through that as well. So this is the agenda. So we will have a small introduction about me and my co-presenter, yes I do not have a co-presenter. What is rack? Then we did a proof of concept for GalCMS, we will be walking you through that. We did a website for benefit me, benefit me.nz. This website actually won a runners up award in the splash awards yesterday. So I will be showing, doing a demo for that as well, then I will be talking about a few things about the process that we followed and a bit about the solution architecture as well. So introductions, the main presenter for this session was supposed to be Philippa Martin, she is my colleague, unfortunately she is really, really sick and the doctors had asked her not to fly, so me here and she has actually recorded her part so I will be playing a recording of that, but I know the project as well inside out so happy to answer any questions. So Philippa, 25 plus years experience in content, she is a content specialist, in salsa digital she is doing content, she is doing project management and now she is doing rules as code as well. She is a print and digital expert and by the way she is a doctor, Philippa Martin. And that is me, Sushik Garg, I am a technical manager at salsa digital and I have been working with Drupal for a pretty long time, 2006 onwards, so 4.2. I have been a developer, I have been a TL, solution architect, trainer, mentor, everything. In this particular project, especially in actually both the projects, I was a Drupal developer, I did development after quite a long time, so it was very interesting. All right, so what is actually rules as code? And we have a video, Philippa for that. Thanks Vici, first of all I want to apologize for not being there in person, obviously the intention was always for me to be there in person, but as you can probably hear, I have caught a bit of a lurky, not COVID thankfully, but I have been told that I can't fly, so I am zooming this into you as it were. So straight on to what is rules as code? At a very basic level, it is simply legislation, regulations and or policies that are turned into machine readable code. There is many benefits of this, such as reducing ambiguity, makes it really clear what the rules are, makes it more accessible, easy for citizens to access and find the information they are looking for, it is reusable. Once the rules are coded, they can be reused by different interfaces, websites, chatbots, etc., it is easier to manage once the rules are coded as well. It is also transparent, people can see what the rules are much more easily and rules as code can also be used to inform policy and feed in policy changes to see how they will impact people down the line. Now, in terms of the two projects that Salsa was involved in last year for rules as code, I am going to talk a little bit about each one. The first one was for GovCMS, which was a proof of concept. This one just for a bit of background. Salsa responded to a GovCMS request for expressions of interest for digital experience platform solutions. There were six potential user journeys and one journey really stood out for us and that journey was this is the stage where a citizen is figuring out what they need to do to either access an entitlement or to comply with the government policy or legal requirement. In the end, once we started working on the rules as code project proof of concept, GovCMS wanted us to look at COVID vaccinations. It was actually quite a complex area at the time and we looked at two main journeys. One was am I up to date with my COVID vaccinations and the next one was do I have to be vaccinated for my work? This enabled us to also show how state rules and federal rules can be combined together in one engine. The final product was two different websites to showcase again how the user interface can pull two different user interfaces can pull from one rules as code engine. In terms of website user journeys, to show the code in action, we set up some different scenarios which we took people through during GovCMS showcase. For example, the first one was a 55-year-old who's had five doses, their last dose being the fifth of the 622, 32-year-old, a parent looking for a 15-year-old immunocompromised person and a parent looking for a four-year-old. On this side of the slide, you can see what the interface looked like which was a civic theme website front-end build. Now, the other project that we had actually going on at the same time was rules as code for New Zealand. This project or this website has ended up being called Benefit Me. So this looks at New Zealand's social security benefits, obviously very relevant given we're here in New Zealand. And we've been working on this project last year with the Digital Aeteroa Collective, including Pia Andrews. We were able to feed the learnings of GovCMS into this longer-term project. Although Benefit Me actually started first, we had been going through the mapping process, which I'll look at a bit later on, and we were able to feed that into the GovCMS project. And then once we built the Drupal module, we were able to feed that back into Benefit Me. Benefit Me includes a web form, so this is the main Drupal component, and Suchi will take you through this in a moment. But basically, it integrates a web form with OpenFisca that checks eligibility for four social security benefits and includes some calculation logic, and that's the URL where you can find this one. So I'll now pass back to Suchi for a live Rulz's Code demo. So the first demo that I'll be doing is the GovCMS POC that we did. This is the URL as it was a POC. That's why we don't have an official domain. So this is the website. I pray to the demo gods. Hopefully it will work fine. But this was the website that we created for the POC. And these were the mainly two journeys that we created. I'll be walking through the first one here. So am I up to date with my COVID vaccinations? And it gives you some information with, and we also had a demonstration about when rules change, what happens, what can be done. This is no longer relevant because we made a change for apparently 1st January, which has already happened. It's no longer future. So let me just go ahead and start. So this is basically a series of web forms that we created in Rulz. And each time a web form submission is done, it actually goes to OpenFisk and asks for something. And based on whatever is returned, we have different pathways. So in this one, for example, if I go ahead and say, I'm a 55-year-old, sorry one sec, get rid of this bottom thing here. So because I'm 55-year-old now, I go to the next one and say, do any of the falling health conditions apply to you? Are you severely immunopharmized? Do you have a disability? Do you have a complex health condition? Et cetera. So let's say I say no. All of these questions are really relevant because all of these questions and the answers to them actually, they are sent to OpenFisk when we are doing the final result of final calculation. So the next step it asks is, how many vaccinations have you already had? So in this case, for example, I'll say I've already had five. I'm not even sure if people have had five. I've had four, but that's fine. And the date I'll probably put in, let's say, 5th of June 2022. Now this is the point where it's taking all the inputs that we have done and going back to OpenFisk. Actually it's going to the OpenFisk API and asking for questions on each and every reform summit. And based on the results that we got from OpenFisk, it's going to a content page that says you're currently not up to date because it's been more than six months. You can see that we have actually highlighted a few of these. The reason we have highlighted that these are the parameters that are coming from OpenFisk. This was a POC, so we could make it ugly. So we just wanted to showcase that those parameters we have put into our content page are tokens. So any time the parameter changed in the source in OpenFisk, this will automatically get updated in Drupal as well. So we don't really need to keep on changing things. So you're currently not up to date because as per the rule, if it's more than six months since your last vaccination, you should get another booster vaccination. It tries to explain this thing. You can make a booking. It has a URL. And then it also tries to give you the recommended wax for your age group. Again, as I said, all the yellow parts are actually coming in from OpenFisk. Everything is stored in OpenFisk that we are just showing. Yes. So that is why we have a big huge thing here. This is a proof of concept. We had tried to interpret the regulations as much as we could, but we are not saying that this is the source of truth. Don't rely on this. This is a proof of concept only. Yes. So this, for example, we actually found it in the health government, on the health government website legislations. We actually found and extracted from that. So we, and we'll talk, Philippa will be talking about the process as well, but we spent quite a lot of time trying to entangle that huge web it is. It's not easy. So that was one of the, one of the data, one of the parts so a person can go over and start. So basically what, as I said, what is happening is, in this case, for example, the moment I put something like two, because each and every web form is going to OpenFisk, it will, it has different pathways. So the moment I put something like two for a parent who has a two-year-old child, for example, you're currently not eligible. And all of this, the fact that you are currently not eligible, that rule calculation, this, it's not stored in Google. Everything is in OpenFisk. The other, other demo that we wanted to show you about was about the benefit me. So this is a website that we created. This tries to calculate the benefits that you can get. Currently there's support for calculation of only four benefits, not more than that. And again, this also uses web forms and OpenFisk. So we can have, now in this case, there was one big, huge form because we needed all the parameters and all the variables in one go and it will go and calculate and come back with your eligible for this, but not for this, etc. So this is one huge web form conditional. There are a lot of conditions. It's not a very straightforward web form, but it's not again, not too bad. So I am, let's say a 32-year-old. I'm currently without work. Actually, I do have work, working part-time. I do not have an injury. I am single. I have zero dependent children, let's say. I earn $100 per week. I'm currently receiving none of the benefits below and I'm not receiving family tax. And it also asks for accommodation costs here. So my weekly accommodation costs are, let's say, $400. Yes, I'm earning $100 and I'm spending $400. And it also asks for a postcode because this is based on postcodes as well. So let me try to put in a Wellington postcode. So this is actually going to the OpenFisca API. So what you told us? You told us this and this tries to calculate your eligibility. So as per this, so as I said, currently this tool supports just four. So that is the job seeker, the sole parent that will support the disability and the accommodation supplement. And as per this calculator, you are eligible for $407 per week after tax. And what are the payments that you are eligible for? You are eligible entitled for job seeker support. And you're eligible for this much of accommodation supplement. It also tells you that you're not actually eligible for disability or the sole parent. Okay, coming back to our presentation. Any questions about the demo or anything specific you want to have a look? Yes. I also saw that and frankly speaking, I don't know the answer to this. Why this happened? I saw that and I was like, I hope nobody saw it. But people have seen it. But again, this is actually coming from OpenFisca. So OpenFisca has done something here. Maybe it has slabs or what, but I don't know what's happening here. I can find out and I'll tell you later. Yes. It depends on the kind of access you have. Because OpenFisca, the APIs, yes, they are open. But the whole calculations, et cetera, they are not. But OpenFisca is open source. And everything is repository-based. So if you have the code-based access, for example, you can actually see all the parameters, all the variables, all the calculations. So it depends exactly on how, you know, what kind of... For this one, for example, I'm pretty sure we would not want a normal layperson to have... How is this calculated? I don't think that's the kind of thing that we'll need. All right. So we've already done this as well. I would also very quickly touch on the solution architecture, the prod, the compulsory diagram. We have to have that, right? So as I had already talked about, we have the legislation here, and we try to convert it into rules as code. We try to convert it into calculations, et cetera, et cetera. And we fit that into OpenFisca. And then in Drupal, we had the content API for it. We had the rules content and code relationships. I'll be talking about this a bit more. And this can, because Drupal content and Drupal API is available, so this can now be fed into anything we want to. We can feed it to websites. We can feed it to mobile apps if needed. We can feed it to Alexa. Also, a very small note about OpenFisca. So as the slide says, OpenFisca was actually developed by French government in 2011. And they're still using it for rules as code. And when we were trying to look at the PLC that needed to be done and benefit from the website, we were trying to research stuff. That's when we came across OpenFisca. OpenFisca is actually Python-based. Yeah, it's a Python-based, and OpenFisca is open. Too many of them. All right, the next thing is about what was the process that we followed. And again, my colleague. Okay, so I'm going to now take you through the rules as code process, or the first part of it, before handing back to Suchi for the more technical elements. So in terms of the process itself, there's five steps involved that we follow. First one is to look at rules analysis and mapping. Then the rules get coded in OpenFisca. So OpenFisca gets configured and the rules coded in. Then that's set up with the Drupal OpenFisca module and also a Drupal web form so that the inputs can be fed in. And then finally, the results are set up also in Drupal. In terms of the rules mapping, the initial part is actually really important because, of course, traditionally rules and legislation tend to be written in very complex language. So one of the first steps is to actually do some analysis and extract the rules in plain English. From there, we get a high-level model, capturing the entities, legislative requirements, eligibility logic, and calculation logic if you're talking about something like social security benefits where there's a figure that's involved. Finally, we create a logical decision model that matches machine-conscionable legislation. It includes user variables and parameters, obligations, and test cases as well. Up from the diagrams up there, you can see that we use MIRO for our rules mapping process. The one up the top there is just looking at it from the age perspective. In Australia, the rules around COVID vaccinations, so this is a COVID vaccination one for GovCMS, were very much based around age. So here in the first one, you can see the branching of the different variables for someone who's aged between 5 and 12. And then from there, the second model shows you up-to-date equals. Okay, next then is the process of coding the rules. So again, it starts in the mapping process. We create test scenarios, we create entities, we create parameters, we create variables, including inputs and outputs, formulas. And finally, before I hand over to Sitchi, we also create some test scenarios. So this is looking at the inputs that we would expect. So in the case that's on the screen there, we can see if someone's aged 10, they've got two vaccine doses and they're not immunocompromised, what do we expect the output to be? Okay, that's it from me. I will hand over to Sitchi. I hope you're enjoying your Drupal South and New Zealand and wish I could be there. Thank you. So that was the sort of non-technical part of it. Now I'm coming to the other part. I'm comfortable with this. Not too comfortable with the other part. So this is the first step that we are showing is the sort of configuration, the sort of coding that we did in Open Fisca. So if you look at... So Open Fisca actually has a concept of entities and where rules can be defined for entities. So in this case, for example, the entity would be a person because naturally the vaccine would be for a person basis. But for example, the BenefitMe case, where if the person has said that I am not a single... I'm not single, I have a family, then that goes into the realm of household because the calculation for anything like that is on a household basis and not on a person basis if they are not single. So the concept of entities we can have, as Sitchi says, we can have persons, household companies, etc. So the first step in... and what I'm showing you is actually what we did for the GovCMS, but we did something similar for the BenefitMe as well. So the first step was to create the entity called persons. Then the next step was to start creating the parameters that we'll be needing. So parameter, as the name suggests, all of us are assuming we are dense here. So we do know what a parameter is. So the parameter is a property of the rule that changes over time. So one of the easiest things that we could look as a parameter was the minimum eligibility age. So the minimum age of eligibility was created as a parameter. One very interesting thing about rules as code is that it has a concept of unit. It has a concept of what is the reference and what is the unit. So in this case, for example, if you look at this, remember when I was showing you the demo, we also tried to show you a future version. So we had to find the value of this parameter. So first of August 2022, the value was 5, but this demo was coded in 2022. So as a future version, we said, what happens if the value becomes 3? So everything will work the same. It will automatically take the current date and associated parameter value. So it makes things very, very easy because you can actually define parameters on a date basis and on an yearly basis, that kind of thing. The other things are the variables. The variables can be input variables or the output variables. The input variables, for example, yes, which are your minimal compromise or what was your last date of vaccine? How many vaccines have you had? These are all the input variables and output variables are, of course, that are calculated after those calculations are done. So the attributes of these variables are the value type, entity definition period, etc. So if you look at this as an example or maybe this is an example, the number of vaccine doses, that's the variable. It's of the type int. The entity is person because everything that we are defining is for a person in this case. The definition period is day and the label is how many vaccine doses have you had. Similarly, for even a compromise disability, it's a bulletin, yes or no. And accordingly, entity is always person. For our whole thing in this example, the entity would always be person. And then we would create the formula based on all the inputs that we receive. We would create a formula and give out the output variable. Again, all of this is being done in OpenFisca. So that was the OpenFisca part of it. But now comes the Drupal part of it. We are at Drupal South. That's the most exciting part, especially for me because I did not do the OpenFisca part. Okay, so we wanted to make sure that we don't code too much. We don't hard code stuff. We wanted to make sure that the site builder or the content creators are able to control things. So, yeah, the aim was to make the editor experience as plain as possible. So before we actually go here, let me just stop. I have to read my notes. So we created a custom module called WebFoneFisca. And the concept on the Drupal site can be split into two parts. One was the rules content. The other was the related content. Very broadly, I'll explain those things to you, but very broadly, the related content is the content we see as a result. And it was just some content with tokens in it. And the rules content was the actual thing that calculated stuff and defined where we're going based on the response, etc. So the rules content was, again, divided into two parts. First part was the WebFone, which defined the user journey. We also tried to make sure... So this was actually defined a bit... This was actually created a bit later into the whole process because earlier what we did was we were hard coding that if WebFone1 returns this result, then we'll be redirected to node number X. Otherwise redirected to node number Y. Which was like, if you're hard coding it, what's the point? So we went ahead and created a content type called rules as code. Very imaginative, of course. So where we could say... So each WebFone could have a rules as code node associated with it, where we could define that as a return value. If you get this as true, this as false, go here. This is true, this is false, this is false, go here, etc. I'll be showing you that a bit. So this was the journey that we saw. WebFone 1, 2, 3 and 4. And this is how it was created. All of these are very plain, simple WebFones. But because of WebFone Fisca, they had the ability to be connected to the OpenFisca API. And how did that happen? So because of the module we created, so in the WebFone handler in settings, we can actually add a handler called OpenFisca journey handler. That was a custom handler that we had created. And the moment we added that in the third-party settings, we started seeing something like this. So it asked us whether we want to enable it, yes. And then we had to give it the OpenFisca API input. This is the keys for the return value. So this particular WebFone as a return value, what is it interested in? And this one, what did I do? So this is automatically created. I'll show you how in the next one. So don't worry about this one. But the top two we have to enter. Now what actually happens in the WebFone? If you look at the first screenshot, we are just defining different fields. But when you're editing the field, you start seeing something extra. And this extra is actually this one. So this field, do you want it to be Fisca-enabled or not? If you want it to be Fisca-enabled, which OpenFisca variable do you want to map this particular field to? And because we had put the API URL in the third-party settings, it automatically pulls all the... Sorry, my mouse is too... Yeah. Because we had put the API URL, it pulls all the variables that are available, all the input variables, it gives you a list. So you can just say, hmm, that first one is what age are you? So I'll probably, I'll map it with the age field and so on and so forth. And this was the second part of the rules content, the rules content type that we created. Very simple content type. No rocket science here, one paragraph type where we can add value of this. So multiple values, value of this is false, this is this, this is this, et cetera, et cetera. And so we can associate it with the waveform. And within each rule we could say, redirect to node 1, redirect to node 2, redirect to node 4, et cetera, et cetera. So node 1, 2, and 4, et cetera are actually the related content. So for example, with the moment I entered 2 as a, what's your age thing? It went to node number 1, let's say, which said, sorry, you're not eligible and added a token or something like that. So the related content was very, very simple. This is more of an explanation of the rules as code content. So variable this. So whenever we waveform mix a call there, it comes back with output variables and based on those variables values, we define the path. And as I said, this is the related content. We've created related content and we added some tokens, waveforms, tokens, very easy. What we did was that all the return values were in the URL. So we, in the token values, we used the URL tokens and we were easily able to show things like three months of Pfizer or Moderna and et cetera. And that's it for my presentation. Questions? Yes, so the whole concept, the whole thing was that Drupal is dumb in the sense that it's not doing any calculations. All the calculations are being done on open-fiskined and based on the return values only, Drupal is just showing I have to go here if the return value is this I have to go there if the return value is this. So that is the kind of very good question and that was the first question I asked when I was put on the project as a developer and I was like, why are we using open-fiskar? But the whole thing was, again, it started off as a POC and we wanted something, we did not want the rules to be in Drupal. We wanted it to be at a separate place and open-fiskar, again, has its own API. So nothing prevents Alexa, for example, to directly go to open-fiskar and quote that thing, et cetera, et cetera. So we wanted Drupal to be just a front-end to that rules calculator instead of putting it... Yeah, we could have probably rules kind of a module, et cetera, et cetera, but that was not the end. Yes, and I am frank to be very, very frank. I don't have a definitive answer to that. It was a decision made before I joined the project and it was just... And this is a question we as devs have asked several times during the project as well, but it's just a decision. I think, and as I said, this was a... So I don't know if you attended Sharon's so they had actually opened... They were talking about DXP and personalization and this was our thing for the personalization part because we wanted to go really out of the box and everything. But, yeah, one of the reasons was this as well, that we wanted to, you know, not put rules in Drupal. We wanted it to be a totally separate entity so that it can be managed centrally rather than it being... So the question is if there is anything around actually creating a rules builder kind of an interface, nothing yet. That's the short answer. I can give you a very long answer, but yeah, nothing yet. But be sure to... Well, I think for my part of the issue was translating by having the first part. I don't even know if I could ever be... He's giving the long answer.